index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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. // 修改跳转
  217. uni.navigateTo({
  218. url: `/pages/merchant/home/index?merId=${item.id}`
  219. // url: `/pages/goods_cate/index?id=${item.id}`
  220. })
  221. },
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .searchIpt {
  227. width: 350rpx !important;
  228. height: 75%;
  229. background-color: #fff;
  230. border-radius: 35rpx;
  231. padding-left: 20rpx;
  232. justify-content: flex-start;
  233. }
  234. .no-data-tip {
  235. color: #CCC;
  236. }
  237. .container {
  238. overflow: hidden;
  239. position: relative;
  240. }
  241. .search-box {
  242. background-color: #fff;
  243. padding: 0 39rpx;
  244. margin-top: 10rpx;
  245. box-sizing: border-box;
  246. height: 96rpx;
  247. .flex-y-center {
  248. width: 100%;
  249. height: 69rpx;
  250. padding-left: 29rpx;
  251. border-radius: 35rpx;
  252. border: 2rpx solid #FF6702;
  253. }
  254. }
  255. .icon-fanhui2 {
  256. // line-height: 66rpx;
  257. }
  258. .search-box input {
  259. width: 90%;
  260. font-size: 26rpx;
  261. }
  262. .search-box .placeholder {
  263. color: #bbb;
  264. }
  265. .search-box .iconfont {
  266. color: #000;
  267. font-size: 35rpx;
  268. }
  269. .box-merchant {
  270. background-color: #F5F5F5;
  271. border-radius: 30rpx 30rpx 0 0;
  272. padding: 20rpx 20rpx 0 20rpx;
  273. // margin-top: 30rpx;
  274. overflow: hidden;
  275. flex: 1;
  276. }
  277. .top-merchant {
  278. background-color: #fff;
  279. position: relative;
  280. padding: 20rpx;
  281. border-radius: 20rpx;
  282. .mer-name {
  283. font-weight: 600;
  284. font-size: 27rpx;
  285. color: #141414;
  286. margin-bottom: 10rpx;
  287. overflow: hidden;
  288. text-overflow: ellipsis;
  289. white-space: nowrap;
  290. }
  291. .mer-tj {
  292. background: #FAFAFA;
  293. border-radius: 19rpx;
  294. font-weight: 400;
  295. font-size: 17rpx;
  296. color: #646464;
  297. padding: 6rpx 10rpx;
  298. }
  299. .cert-box {
  300. font-size: 21rpx;
  301. color: #FF6702;
  302. background: #FEEFE5;
  303. border-radius: 8rpx;
  304. padding: 4rpx 20rpx;
  305. margin-right: 10rpx;
  306. }
  307. .top-box-item {
  308. width: 173rpx;
  309. margin-right: 20rpx;
  310. display: inline-block;
  311. .name {
  312. font-weight: 400;
  313. font-size: 21rpx;
  314. color: #141414;
  315. width: 100%;
  316. overflow: hidden;
  317. text-overflow: ellipsis;
  318. white-space: nowrap;
  319. }
  320. }
  321. }
  322. .bg-color {
  323. color: $bg-color-primary;
  324. font-weight: 600;
  325. font-size: 31rpx;
  326. }
  327. .active-option {
  328. color: $bg-color-primary !important;
  329. }
  330. .tab-list {
  331. display: flex;
  332. /* 启用弹性布局 */
  333. flex-direction: row;
  334. /* 横向排列 */
  335. justify-content: space-between;
  336. /* 均匀分布子项 */
  337. flex-wrap: wrap;
  338. /* 允许换行(适用于屏幕宽度不足时) */
  339. .tab-item2 {
  340. width: 23%;
  341. /* 5个元素平分宽度,留2%作为间隙 */
  342. text-align: center;
  343. background-color: #FFC127;
  344. border-radius: 8rpx;
  345. font-size: 23rpx;
  346. padding: 6rpx;
  347. font-weight: 400;
  348. }
  349. .tab-item2-false {
  350. width: 23%;
  351. /* 5个元素平分宽度,留2%作为间隙 */
  352. text-align: center;
  353. background-color: #fff;
  354. border-radius: 8rpx;
  355. font-size: 23rpx;
  356. padding: 6rpx;
  357. font-weight: 400;
  358. }
  359. }
  360. .content-goods2 {
  361. background: #FFFFFF;
  362. border-radius: 23rpx;
  363. margin-top: 10rpx;
  364. padding: 20rpx;
  365. display: flex;
  366. }
  367. .goods-title {
  368. color: #141414;
  369. font-size: 26rpx;
  370. font-weight: 600;
  371. }
  372. .goods-desc {
  373. color: #646464;
  374. font-size: 21rpx;
  375. margin-top: 10rpx;
  376. }
  377. .goods-price {
  378. color: #FF9805;
  379. font-size: 34rpx;
  380. font-weight: 600;
  381. }
  382. .goods-score {
  383. color: $bg-color-primary;
  384. font-size: 27rpx;
  385. }
  386. .goods-info {
  387. color: #999999;
  388. font-size: 21rpx;
  389. }
  390. .goods-info3 {
  391. color: #999999;
  392. font-size: 21rpx;
  393. margin-left: 10rpx;
  394. text-decoration: line-through;
  395. }
  396. .goods-sales {
  397. background-color: #FEEFE5;
  398. color: #FF6702;
  399. border-radius: 8rpx;
  400. font-size: 21rpx;
  401. padding: 4rpx 20rpx;
  402. }
  403. .goods-labels {
  404. background-color: #FFF6F6;
  405. color: #FF4B4B;
  406. border: 2rpx solid #FF4B4B;
  407. border-radius: 8rpx;
  408. font-size: 21rpx;
  409. padding: 4rpx 16rpx;
  410. margin-right: 20rpx;
  411. }
  412. .back-button {
  413. width: 25rpx;
  414. height: 25rpx;
  415. border-right: 4rpx solid #fff;
  416. border-bottom: 4rpx solid #fff;
  417. transform: rotate(135deg);
  418. margin-left: 10rpx;
  419. display: inline-block;
  420. }
  421. .navigationbar {
  422. position: relative;
  423. background-color: $bg-color-primary;
  424. .back-button {
  425. position: absolute;
  426. left: 40rpx;
  427. }
  428. }
  429. </style>