index.vue 13 KB

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