index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <view class="container flex-col" :style="{height: winHeight + 'px'}">
  3. <!-- #ifdef MP -->
  4. <!-- 状态栏高度 -->
  5. <view :style="{ height: `${statusBarHeight}px` }"></view>
  6. <!-- 导航栏 -->
  7. <view class="navigationbar flex-center" :style="{ height: `${navigationBarHeight}px` }">
  8. <view class="back-button" @tap="handBack()"></view>
  9. <navigator url="/pages/merchant_search/index" class="input tui-skeleton-rect searchIpt flex-center" hover-class="none"><text
  10. class="iconfont icon-xiazai5"></text>
  11. 点击搜索外卖商家</navigator>
  12. </view>
  13. <!-- #endif -->
  14. <view class="box-merchant flex-col">
  15. <view class="top-merchant">
  16. <view class="flex-y-center">
  17. <image style="width: 96rpx; height: 96rpx;border-radius: 6rpx;" :src="recommendObj.avatar"></image>
  18. <view style="margin-left: 20rpx; flex: 1;">
  19. <view class="mer-name flex-between-center">
  20. <view>{{recommendObj.name}}</view>
  21. <view class='iconfont icon-jiantou' style="font-size: 30rpx;" @tap="merchantTab(recommendObj)"></view>
  22. </view>
  23. <view class="flex-between-center" style="padding-right: 53rpx;">
  24. <text class="mer-tj">今日推荐</text>
  25. <text class="goods-score">{{recommendObj.score}}</text>
  26. <text class="goods-info">销量{{recommendObj.salesVolume}}</text>
  27. <text v-if="!recommendObj.isfreeDeliverfee" class="goods-info" style="color: #E5AD21;margin-left: 18rpx;">免配送费</text>
  28. <view v-if="!recommendObj.isfreeDeliverfee && recommendObj.freeDeliverFee > 0" style="color: #999999;font-size: 21rpx;margin-left: 10rpx;text-decoration: line-through;">¥
  29. {{recommendObj.freeDeliverFee}}</view>
  30. <text v-if="recommendObj.isfreeDeliverfee" style="color: #999999;font-size: 21rpx;margin-left: 10rpx;">配送费¥
  31. {{recommendObj.distCosts}}</text>
  32. <text class="goods-info" style="margin-left: 10rpx;">{{recommendObj.distance}}</text>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="flex-y-center" style="margin: 15rpx 0;">
  37. <view class="cert-box" v-for="(item, index) in recommendObj.discountLabel" :key="index">{{item}}</view>
  38. </view>
  39. <scroll-view :scroll-x="true" scroll-with-animation style="white-space: nowrap;">
  40. <view class="top-box-item" v-for="(item, index) in recommendObj.proList" :key="index">
  41. <image style="width: 100%; height: 131rpx;border-radius: 10rpx;" :src="item.image"></image>
  42. <view class="name">{{item.name}}</view>
  43. <view style="padding-right: 23rpx">
  44. <text style="color: #FF6702;">¥</text><text class="bg-color">{{item.price}}</text>
  45. <!-- <text class="goods-info" style="text-decoration: line-through;">¥6</text> -->
  46. </view>
  47. </view>
  48. </scroll-view>
  49. </view>
  50. <scroll-view :scroll-x="true" scroll-with-animation style="white-space: nowrap;margin: 20rpx 0rpx;">
  51. <view :class="optionIndex == item.id ? 'active-option' : ''" style="color: #141414;display: inline-block;margin-right: 30rpx;width: 96rpx;"
  52. v-for="(item, index) in optionData" :key="index" @tap="onOptionClick(item)">
  53. <view class="flex-col flex-center">
  54. <image style="width: 100%;height: 96rpx;" :src="item.icon"></image>
  55. <view style="font-size: 21rpx;margin-top: 10rpx;">{{item.name}}</view>
  56. </view>
  57. </view>
  58. </scroll-view>
  59. <!-- 销量排行 -->
  60. <view class="tab-list" style="margin-top: 10rpx;">
  61. <view :class=" item.checked ? 'tab-item2' : 'tab-item2-false' " v-for="item in labelList" :key="item.id" @click="item2Click(item)">{{item.label}}</view>
  62. </view>
  63. <scroll-view scroll-y scroll-with-animation style="flex: 1;overflow: hidden;">
  64. <view class="content-goods2" v-for="item in merchantList" :key="item.id" @click="merchantTab(item)">
  65. <view>
  66. <image :src="item.avatar" style="width: 230rpx;height: 230rpx;"></image>
  67. </view>
  68. <view style="margin-left: 20rpx;flex: 1;">
  69. <view class="">
  70. <text class="goods-title">{{item.name}}</text>
  71. </view>
  72. <view style="margin-top: 10rpx;">
  73. <text class="goods-score">{{item.score}}</text>
  74. <text class="goods-info" style="margin-left: 10rpx;">月销 {{item.salesVolume}}</text>
  75. <text class="goods-info" style="margin-left: 25rpx;">人均 ¥ {{item.perCapita}}</text>
  76. </view>
  77. <view style="margin-top: 10rpx;display: flex;align-items: center;">
  78. <text class="goods-info">起送 ¥ {{item.perCapita}}</text>
  79. <text v-if="!item.isfreeDeliverfee" class="goods-info" style="color: #E5AD21;margin-left: 18rpx;">免配送费</text>
  80. <view v-if="!item.isfreeDeliverfee && item.freeDeliverFee > 0" style="color: #999999;font-size: 21rpx;margin-left: 10rpx;text-decoration: line-through;">¥
  81. {{item.freeDeliverFee}}</view>
  82. <text v-if="item.isfreeDeliverfee" style="color: #999999;font-size: 21rpx;margin-left: 10rpx;">配送费¥
  83. {{item.distCosts}}</text>
  84. <text class="goods-info" style="margin-left: 38rpx;">10分钟</text>
  85. <text class="goods-info" style="margin-left: 10rpx;">{{item.distance}}</text>
  86. </view>
  87. <view style="margin-top: 22rpx;"><text class="goods-sales">已售卖{{item.salesVolume}}件</text></view>
  88. <view style="margin-top: 14rpx;">
  89. <text class="goods-labels" v-for="(item2,index2) in item.discountLabel" :key="index2">{{item2}}</text>
  90. </view>
  91. </view>
  92. </view>
  93. </scroll-view>
  94. </view>
  95. </view>
  96. </template>
  97. <script>
  98. // +----------------------------------------------------------------------
  99. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  100. // +----------------------------------------------------------------------
  101. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  102. // +----------------------------------------------------------------------
  103. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  104. // +----------------------------------------------------------------------
  105. // | Author: CRMEB Team <admin@crmeb.com>
  106. // +----------------------------------------------------------------------
  107. import navBar from '@/components/navBar';
  108. import {
  109. getMerchantList,
  110. getHomeInfo
  111. } from '@/api/home.js';
  112. import {
  113. getTakeoutList,
  114. getProduct
  115. } from '@/api/takeout.js';
  116. let app = getApp();
  117. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'rpx';
  118. export default {
  119. components: {
  120. navBar
  121. },
  122. data() {
  123. return {
  124. statusBarHeight: app.globalData.statusBarHeight,
  125. navigationBarHeight: 0,
  126. takeoutId: null,
  127. winHeight: 0,
  128. recommendObj: {},
  129. optionData: [],
  130. optionIndex: 0,
  131. labelList: [{
  132. id: 1,
  133. label: "销量排行",
  134. checked: true
  135. }, {
  136. id: 2,
  137. label: "满减大促",
  138. checked: false
  139. }, {
  140. id: 3,
  141. label: "首单立减",
  142. checked: false
  143. }, {
  144. id: 4,
  145. label: "减配送费",
  146. checked: false
  147. }],
  148. merchantList: [],
  149. }
  150. },
  151. onLoad(options) {
  152. let that = this;
  153. const custom = wx.getMenuButtonBoundingClientRect()
  154. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  155. that.navigationBarHeight = custom.height + (custom.top - that.statusBarHeight) * 2
  156. that.takeoutId = options.id;
  157. uni.getSystemInfo({
  158. success: function(res) {
  159. that.winHeight = res.windowHeight
  160. },
  161. });
  162. getProduct(that.takeoutId).then(res => {
  163. const data = res.data;
  164. data[0].id = 0;
  165. data[0].name = '全部';
  166. data[0].icon = '/static/img/quanbu.png';
  167. that.optionIndex = 0;
  168. that.optionData = data || []
  169. console.log(that.optionData, '12312321321312321321312312')
  170. })
  171. that.getMatchedData()
  172. getTakeoutList({
  173. latitude: uni.getStorageSync('user_latitude'),
  174. longitude: uni.getStorageSync('user_longitude'),
  175. cateId: that.optionIndex
  176. }).then(recommendRes => {
  177. that.recommendObj = recommendRes.data
  178. console.log(that.recommendObj, '00000000000000000000000000')
  179. })
  180. },
  181. methods: {
  182. handBack() {
  183. uni.navigateBack({
  184. delta: 1
  185. })
  186. },
  187. goMerchant() {
  188. this.$util.navigateTo('/pages/merchant_search/index');
  189. },
  190. item2Click(item) {
  191. item.checked = !item.checked;
  192. },
  193. getMatchedData() {
  194. getMerchantList({
  195. latitude: uni.getStorageSync('user_latitude'),
  196. longitude: uni.getStorageSync('user_longitude'),
  197. cateId: this.optionIndex
  198. }).then(res => {
  199. this.merchantList = res.data.list;
  200. console.log('商品信息:', this.merchantList);
  201. });
  202. },
  203. onOptionClick(item) {
  204. if (this.optionIndex === item.id) return
  205. this.optionIndex = item.id;
  206. getMatchedData()
  207. },
  208. merchantTab(item) {
  209. let opitem = JSON.stringify(item)
  210. let cid = item.cid
  211. uni.setStorageSync('merId', JSON.parse(JSON.stringify(item.id)))
  212. // 修改跳转
  213. uni.navigateTo({
  214. url: '/pages/merchant/home/index'
  215. // url: `/pages/goods_cate/index?id=${item.id}`
  216. })
  217. },
  218. }
  219. }
  220. </script>
  221. <style lang="scss" scoped>
  222. .searchIpt {
  223. width: 350rpx !important;
  224. height: 75%;
  225. background-color: #fff;
  226. border-radius: 35rpx;
  227. padding-left: 20rpx;
  228. justify-content: flex-start;
  229. }
  230. .container {
  231. overflow: hidden;
  232. position: relative;
  233. }
  234. .search-box {
  235. background-color: #fff;
  236. padding: 0 39rpx;
  237. margin-top: 10rpx;
  238. box-sizing: border-box;
  239. height: 96rpx;
  240. .flex-y-center {
  241. width: 100%;
  242. height: 69rpx;
  243. padding-left: 29rpx;
  244. border-radius: 35rpx;
  245. border: 2rpx solid #FF6702;
  246. }
  247. }
  248. .icon-fanhui2 {
  249. // line-height: 66rpx;
  250. }
  251. .search-box input {
  252. width: 90%;
  253. font-size: 26rpx;
  254. }
  255. .search-box .placeholder {
  256. color: #bbb;
  257. }
  258. .search-box .iconfont {
  259. color: #000;
  260. font-size: 35rpx;
  261. }
  262. .box-merchant {
  263. background-color: #F5F5F5;
  264. border-radius: 30rpx 30rpx 0 0;
  265. padding: 20rpx 20rpx 0 20rpx;
  266. // margin-top: 30rpx;
  267. overflow: hidden;
  268. flex: 1;
  269. }
  270. .top-merchant {
  271. background-color: #fff;
  272. position: relative;
  273. padding: 20rpx;
  274. border-radius: 20rpx;
  275. .mer-name {
  276. font-weight: 600;
  277. font-size: 27rpx;
  278. color: #141414;
  279. margin-bottom: 10rpx;
  280. overflow: hidden;
  281. text-overflow: ellipsis;
  282. white-space: nowrap;
  283. }
  284. .mer-tj {
  285. background: #FAFAFA;
  286. border-radius: 19rpx;
  287. font-weight: 400;
  288. font-size: 17rpx;
  289. color: #646464;
  290. padding: 6rpx 10rpx;
  291. }
  292. .cert-box {
  293. font-size: 21rpx;
  294. color: #FF6702;
  295. background: #FEEFE5;
  296. border-radius: 8rpx;
  297. padding: 4rpx 20rpx;
  298. margin-right: 10rpx;
  299. }
  300. .top-box-item {
  301. width: 173rpx;
  302. margin-right: 20rpx;
  303. display: inline-block;
  304. .name {
  305. font-weight: 400;
  306. font-size: 21rpx;
  307. color: #141414;
  308. width: 100%;
  309. overflow: hidden;
  310. text-overflow: ellipsis;
  311. white-space: nowrap;
  312. }
  313. }
  314. }
  315. .bg-color {
  316. color: $bg-color-primary;
  317. font-weight: 600;
  318. font-size: 31rpx;
  319. }
  320. .active-option {
  321. color: $bg-color-primary !important;
  322. }
  323. .tab-list {
  324. display: flex;
  325. /* 启用弹性布局 */
  326. flex-direction: row;
  327. /* 横向排列 */
  328. justify-content: space-between;
  329. /* 均匀分布子项 */
  330. flex-wrap: wrap;
  331. /* 允许换行(适用于屏幕宽度不足时) */
  332. .tab-item2 {
  333. width: 23%;
  334. /* 5个元素平分宽度,留2%作为间隙 */
  335. text-align: center;
  336. background-color: #FFC127;
  337. border-radius: 8rpx;
  338. font-size: 23rpx;
  339. padding: 6rpx;
  340. font-weight: 400;
  341. }
  342. .tab-item2-false {
  343. width: 23%;
  344. /* 5个元素平分宽度,留2%作为间隙 */
  345. text-align: center;
  346. background-color: #fff;
  347. border-radius: 8rpx;
  348. font-size: 23rpx;
  349. padding: 6rpx;
  350. font-weight: 400;
  351. }
  352. }
  353. .content-goods2 {
  354. background: #FFFFFF;
  355. border-radius: 23rpx;
  356. margin-top: 10rpx;
  357. padding: 20rpx;
  358. display: flex;
  359. }
  360. .goods-title {
  361. color: #141414;
  362. font-size: 26rpx;
  363. font-weight: 600;
  364. }
  365. .goods-desc {
  366. color: #646464;
  367. font-size: 21rpx;
  368. margin-top: 10rpx;
  369. }
  370. .goods-price {
  371. color: #FF9805;
  372. font-size: 34rpx;
  373. font-weight: 600;
  374. }
  375. .goods-score {
  376. color: $bg-color-primary;
  377. font-size: 27rpx;
  378. }
  379. .goods-info {
  380. color: #999999;
  381. font-size: 21rpx;
  382. }
  383. .goods-info3 {
  384. color: #999999;
  385. font-size: 21rpx;
  386. margin-left: 10rpx;
  387. text-decoration: line-through;
  388. }
  389. .goods-sales {
  390. background-color: #FEEFE5;
  391. color: #FF6702;
  392. border-radius: 8rpx;
  393. font-size: 21rpx;
  394. padding: 4rpx 20rpx;
  395. }
  396. .goods-labels {
  397. background-color: #FFF6F6;
  398. color: #FF4B4B;
  399. border: 2rpx solid #FF4B4B;
  400. border-radius: 8rpx;
  401. font-size: 21rpx;
  402. padding: 4rpx 16rpx;
  403. margin-right: 20rpx;
  404. }
  405. .back-button {
  406. width: 25rpx;
  407. height: 25rpx;
  408. border-right: 4rpx solid #fff;
  409. border-bottom: 4rpx solid #fff;
  410. transform: rotate(135deg);
  411. margin-left: 10rpx;
  412. display: inline-block;
  413. }
  414. .navigationbar {
  415. position: relative;
  416. background-color: $bg-color-primary;
  417. .back-button {
  418. position: absolute;
  419. left: 40rpx;
  420. }
  421. }
  422. </style>