index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view :data-theme="theme">
  3. <view class="cart_nav" :style='"height:"+navH+"rpx;"'>
  4. <nav-bar iconColor='#fff' backgroundColor="#FF6702" ref="navBarRef" navTitle="今日吃啥">
  5. </nav-bar>
  6. </view>
  7. <view class="content" :style="{'background-image': `url(${urlDomain}crmebimage/presets/whateat/what-bg.png)`}">
  8. <view class="items">
  9. <view class="item" v-for="(item,i) in items" :key="i" :class="item.checked ? 'active':'notActive'"
  10. @click="handleCheck(i)">
  11. <img :src="item.icon" alt="" style="height: 80rpx;width: 80rpx;margin-right: 19rpx;" />
  12. <view class="">
  13. {{item.label}}
  14. </view>
  15. </view>
  16. </view>
  17. <image class="start-btn" :src="`${urlDomain}crmebimage/presets/whateat/what-nn.png`" mode="" @click="onStartBtnClick"></image>
  18. </view>
  19. <!-- 评论 -->
  20. <uni-popup type="center" animation ref="activate" :mask-click="false">
  21. <view class="model-container">
  22. <img @click="onClose" :src="`${urlDomain}crmebimage/presets/whateat/what-close.png`" alt="" style="height: 49rpx;width: 49rpx;"
  23. class="m-close" />
  24. <view class="goods-items" v-if="productList.length">
  25. <view class="g-item" v-for="ite in productList" :key="ite">
  26. <img :src="ite.image" alt="" style="height: 210rpx;width: 210rpx;" />
  27. <view class="g-title">
  28. {{ite.name||'-'}}
  29. </view>
  30. <view class="g-price">
  31. ¥{{ite.price||'-'}}
  32. </view>
  33. <view class="choose-btn" @click="onChoose({id:ite.id})">
  34. 选择
  35. </view>
  36. </view>
  37. </view>
  38. <emptyPage v-else title="暂无数据~" :imgSrc="urlDomain+'crmebimage/presets/noShopper.png'"></emptyPage>
  39. </view>
  40. </uni-popup>
  41. </view>
  42. </template>
  43. <script>
  44. import emptyPage from '@/components/emptyPage.vue'
  45. import {whattodayeatApi,whattodayeatProductApi} from '../what_to_eat_today.js'
  46. import navBar from '@/components/navBar';
  47. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  48. let app = getApp();
  49. export default {
  50. components: {
  51. navBar,
  52. emptyPage
  53. },
  54. data() {
  55. return {
  56. urlDomain: this.$Cache.get("imgHost"),
  57. theme: app.globalData.theme,
  58. navH: '',
  59. statusBarHeight: app.globalData.statusBarHeight,
  60. navigationBarHeight: 0,
  61. loading: false,
  62. loadTitle: '',
  63. productList:[],
  64. items: []
  65. // [{
  66. // label: '我不挑食',
  67. // icon: require('../static/img/甜点.png'),
  68. // checked: true
  69. // },
  70. // {
  71. // label: '减肥套餐',
  72. // icon: require('../static/img/减肥餐.png'),
  73. // checked: true
  74. // },
  75. // {
  76. // label: '精致小食',
  77. // icon: require('../static/img/小食.png'),
  78. // checked: true
  79. // },
  80. // {
  81. // label: '豪华美食',
  82. // icon: require('../static/img/豪华餐.png'),
  83. // checked: true
  84. // }
  85. // ]
  86. }
  87. },
  88. //下拉刷新
  89. onPullDownRefresh() {
  90. },
  91. onLoad(options) {
  92. this.navH = 96;
  93. whattodayeatApi().then(res => {
  94. this.items = res.data.map((ite,i) => ({
  95. label:ite.tagName,
  96. checked:i==0,
  97. ...ite
  98. }))
  99. })
  100. },
  101. onShow() {
  102. },
  103. methods: {
  104. handleCheck(i) {
  105. this.items.forEach(ite => ite.checked = false)
  106. this.items[i].checked = true
  107. },
  108. handBack() {
  109. uni.navigateBack({
  110. delta: 1
  111. })
  112. },
  113. async onStartBtnClick() {
  114. uni.showLoading()
  115. let check = this.items.filter((ite) => ite.checked)
  116. const params = {
  117. latitude: uni.getStorageSync('user_latitude'),
  118. longitude: uni.getStorageSync('user_longitude'),
  119. tagId:check[0].id
  120. }
  121. const res = await whattodayeatProductApi(params).finally(()=>uni.hideLoading())
  122. this.productList = res.data
  123. this.$refs.activate.open()
  124. },
  125. onClose() {
  126. this.$refs.activate.close()
  127. },
  128. onChoose(data) {
  129. uni.navigateTo({
  130. url: `/pages/goods/goods_details/index?id=${data.id}&mt=0`,
  131. })
  132. }
  133. },
  134. mounted() {
  135. },
  136. }
  137. </script>
  138. <style scoped>
  139. .order-nav {
  140. font-weight: 500;
  141. font-size: 35rpx;
  142. color: #FFFFFF;
  143. background-color: #FF6702;
  144. text-align: center;
  145. position: relative;
  146. }
  147. .back-button {
  148. width: 25rpx;
  149. height: 25rpx;
  150. border-right: 4rpx solid #fff;
  151. border-bottom: 4rpx solid #fff;
  152. transform: rotate(135deg);
  153. margin-left: 10rpx;
  154. display: inline-block;
  155. position: absolute;
  156. left: 40rpx;
  157. top: 25rpx;
  158. }
  159. .content {
  160. position: relative;
  161. height: calc(100vh - 49px);
  162. width: 100vw;
  163. padding-top: 135rpx;
  164. /* background-image: url('../static/img/背景.png'); */
  165. background-size: cover;
  166. background-repeat: no-repeat;
  167. }
  168. .items {
  169. display: grid;
  170. grid-template-columns: auto auto;
  171. grid-gap: 19.23rpx;
  172. margin: 0 57rpx;
  173. }
  174. .item {
  175. display: flex;
  176. align-items: center;
  177. color: #B16F22;
  178. font-size: 35rpx;
  179. font-weight: 500;
  180. font-family: PingFangSC, PingFang SC;
  181. width: 308rpx;
  182. height: 96rpx;
  183. background: linear-gradient(180deg, #FFE7CA 0%, #FFFFFF 100%);
  184. border-radius: 8rpx;
  185. border: 4rpx solid;
  186. border-image: linear-gradient(225deg, rgba(255, 194, 80, 1), rgba(255, 220, 107, 1), rgba(255, 225, 133, 1)) 4 4 !important;
  187. padding: 9rpx;
  188. }
  189. .active {
  190. border: 4rpx solid;
  191. }
  192. .notActive {
  193. border: none;
  194. }
  195. .start-btn {
  196. position: absolute;
  197. width: 153rpx;
  198. height: 80rpx;
  199. top: 55%;
  200. left: 50%;
  201. transform: translateX(-50%);
  202. }
  203. .model-container {
  204. position: relative;
  205. width: 632rpx;
  206. height: 604rpx;
  207. background-color: #fff;
  208. border-radius: 23rpx;
  209. padding-top: 96rpx;
  210. }
  211. .m-close {
  212. position: absolute;
  213. right: 39rpx;
  214. top: 20rpx;
  215. }
  216. .goods-items {
  217. margin: 0 39rpx;
  218. display: flex;
  219. gap: 20rpx;
  220. }
  221. .g-item {
  222. padding: 28.46rpx;
  223. background: linear-gradient(180deg, #FFF9F1 0%, #FFFFFF 100%);
  224. border-radius: 8rpx;
  225. border: 2rpx solid;
  226. border-image: linear-gradient(225deg, rgba(255, 194, 80, 1), rgba(255, 220, 107, 1), rgba(255, 225, 133, 1)) 2 2;
  227. }
  228. .g-title {
  229. max-width: 210rpx;
  230. margin-top: 19rpx;
  231. font-family: PingFangSC, PingFang SC;
  232. font-size: 27rpx;
  233. color: #141414;
  234. line-height: 38rpx;
  235. text-align: center;
  236. white-space: nowrap; /* 不换行 */
  237. overflow: hidden; /* 隐藏超出的内容 */
  238. text-overflow: ellipsis; /* 用省略号表示被隐藏的部分 */
  239. }
  240. .g-price {
  241. font-family: PingFangSC, PingFang SC;
  242. font-weight: 600;
  243. font-size: 31rpx;
  244. color: #FF9805;
  245. line-height: 42rpx;
  246. text-align: center;
  247. margin-bottom: 10rpx;
  248. }
  249. .choose-btn {
  250. width: 154rpx;
  251. height: 54rpx;
  252. background: linear-gradient(180deg, #FFAC3D 0%, #FF1E1D 100%);
  253. border-radius: 15rpx;
  254. border: 2rpx solid #FFD288;
  255. font-family: PingFangSC, PingFang SC;
  256. font-size: 27rpx;
  257. color: #FFFFFF;
  258. line-height: 54rpx;
  259. text-align: center;
  260. margin: auto;
  261. }
  262. ::v-deep .empty-box {
  263. padding-top: 0 !important
  264. }
  265. </style>