index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view class="discountsDetail">
  3. <zs-choose-tab :tabList="tabList" @choose="chooseTab"></zs-choose-tab>
  4. <!-- 内容 -->
  5. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  6. <view class="item" v-for="(item,index) in list" :key="index" @click="goDetail(item)">
  7. <!-- <image :src="item.src" mode="" class="icon" @click="goDetail(item)"></image> -->
  8. <view class="box">
  9. <zs-img :src="item.logoPath" width="200rpx" height="200rpx" radius="full"
  10. ></zs-img>
  11. <view class="info">
  12. <view class="title">
  13. {{item.shopVo.shopName}}
  14. </view>
  15. <view class="desc">
  16. {{item.address}}
  17. </view>
  18. <view class="desc">
  19. 距离你{{(item.shopVo.distance/1000).toFixed(2)}}km
  20. </view>
  21. </view>
  22. </view>
  23. <view class="goods-item" :class="[d != 0?'none':'']" v-for="(i,d) in filterData(item.goodsVos)" :key="d">
  24. <view class="tag" v-if="i.goodsLabel">
  25. {{i.goodsLabel}}
  26. </view>
  27. <view class="price-box">
  28. <view class="unit">
  29. </view>
  30. <view class="price">
  31. {{i.realPrice}}
  32. </view>
  33. <view class="discount-tag" v-if="i.marketPrice">
  34. <image class="icon" src="https://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/HZm0fGVdMht36ef982cd73bdd6733a803e1ba6a80fa2.png/1.png" mode=""></image>
  35. <view class="discount-num">
  36. {{((i.realPrice/i.marketPrice)*10).toFixed(1)}}折
  37. </view>
  38. </view>
  39. <view class="old-price">
  40. ¥{{i.marketPrice}}
  41. </view>
  42. </view>
  43. <view class="goods-name">
  44. {{i.goodsName}}
  45. </view>
  46. </view>
  47. </view>
  48. </zs-list>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. search
  54. } from '@/api/shop.js';
  55. import {
  56. getMenu
  57. } from '@/api/common.js'
  58. export default {
  59. options: {
  60. styleIsolation: 'shared'
  61. },
  62. data() {
  63. return {
  64. longitude: '',
  65. latitude: '',
  66. destination: '',
  67. _mapContext: null,
  68. status: 'more',
  69. list: [],
  70. btnText: '去使用',
  71. banner: '',
  72. menuId:'',
  73. query: {
  74. district:'',
  75. menuId: '',
  76. queryName: '',
  77. range:'',
  78. 'location.lat': 0,
  79. 'location.lon': 0,
  80. pageCurrent: 1,
  81. pageSize: 100
  82. },
  83. location:'',
  84. tabList: [{
  85. id: 1,
  86. label: '区域',
  87. list: [
  88. {
  89. id: 1,
  90. label: '观山湖'
  91. },
  92. {
  93. id: 2,
  94. label: '白云区'
  95. },
  96. {
  97. id: 3,
  98. label: '花果山区'
  99. }
  100. ]
  101. },
  102. {
  103. id: 1,
  104. label: '全部分类',
  105. list: [{
  106. label: '甜点饮品'
  107. },
  108. {
  109. label: '特色美食'
  110. },
  111. {
  112. label: '风味小吃'
  113. }
  114. ]
  115. },
  116. {
  117. id: 1,
  118. label: '附近',
  119. list: [
  120. {
  121. id:5,
  122. label: '5KM'
  123. },
  124. {
  125. id:10,
  126. label: '10KM'
  127. },
  128. {
  129. id:20,
  130. label: '20KM'
  131. },
  132. {
  133. id:50,
  134. label: '50KM'
  135. }
  136. ]
  137. },
  138. ]
  139. }
  140. },
  141. methods: {
  142. // 筛选前两个商品
  143. filterData(data){
  144. return data.slice(0,2)
  145. },
  146. // 金刚区
  147. getMenu(parentId) {
  148. return new Promise((resolve, reject) => {
  149. getMenu({
  150. currentPage: 1,
  151. pageSize: 10,
  152. status: 2,
  153. parentId
  154. }).then(res => {
  155. if (res.state == 'Success') {
  156. let list = []
  157. res.content.records.map(item => {
  158. list.push({
  159. id: item.id,
  160. label: item.menuName
  161. })
  162. })
  163. this.tabList[1].list = list
  164. console.log(this.tabList);
  165. }
  166. })
  167. })
  168. },
  169. chooseTab(val) {
  170. this.query.range = val[2].id
  171. if(val[0]){
  172. this.query['location.lat'] = val[0].location.lat
  173. this.query['location.lon'] = val[0].location.lng
  174. this.query.range = 50
  175. this.query.district = val[0].label
  176. }else if(!val[0]){
  177. this.query['location.lat'] = this.location.latitude
  178. this.query['location.lon'] = this.location.longitude
  179. this.query.district = ''
  180. }
  181. if(val[1]){
  182. this.query.secondMenuId =+val[1].id
  183. }else if(!val[1]){
  184. delete this.query.secondMenuId
  185. }
  186. this.query.pageCurrent = 1
  187. this.status = 'more'
  188. this.list = []
  189. this.search()
  190. console.log(this.query.menuId);
  191. },
  192. goDetail(item) {
  193. let shopInfo = {
  194. shopId:item.shopVo.shopId,
  195. shopName:item.shopVo.shopName,
  196. detailContent:item.detailContent,
  197. logoPath:item.logoPath,
  198. }
  199. uni.setStorageSync('shopInfo', JSON.stringify(shopInfo))
  200. uni.navigateTo({
  201. url: '../shopDetail/shopDetail'
  202. })
  203. },
  204. loadMore() {
  205. this.search()
  206. },
  207. search() {
  208. return new Promise((resolve, reject) => {
  209. if (this.status == 'noMore') return
  210. this.status = 'loading'
  211. let obj = JSON.parse(JSON.stringify(this.query))
  212. if(!obj.range){
  213. delete obj.range
  214. }
  215. search(obj).then(res => {
  216. if (res.state == 'Success') {
  217. this.list = this.list.concat(res.content.records)
  218. if (this.list.length >= res.content.total) {
  219. this.status = 'noMore'
  220. } else {
  221. this.status = 'more'
  222. this.query.pageCurrent++
  223. }
  224. resolve()
  225. }
  226. })
  227. })
  228. },
  229. },
  230. onPullDownRefresh() {
  231. this.query.pageCurrent = 1
  232. this.list = []
  233. this.status = 'more'
  234. this.search().then(() => {
  235. uni.stopPullDownRefresh()
  236. })
  237. },
  238. onLoad(option) {
  239. this.tabList[0].list = JSON.parse(uni.getStorageSync('districtList'))
  240. this.menuId = option.id
  241. this.getMenu(option.id)
  242. let that = this
  243. const eventChannel = this.getOpenerEventChannel();
  244. if (JSON.stringify(eventChannel) !== '{}') {
  245. eventChannel.on('banner', function(data) {
  246. that.banner = data
  247. })
  248. }
  249. uni.setNavigationBarTitle({
  250. title: option.title
  251. });
  252. this.query.menuId = option.id
  253. this.location = JSON.parse(uni.getStorageSync('location'))
  254. this.query['location.lat'] = this.location.latitude
  255. this.query['location.lon'] = this.location.longitude
  256. this.search()
  257. },
  258. }
  259. </script>
  260. <style lang="scss">
  261. .bar-item-text {
  262. max-width: 250rpx !important;
  263. }
  264. .screen-bar::after {
  265. display: none;
  266. }
  267. .discountsDetail cc-drop-down-menu .screen-bar {
  268. // position: fixed;
  269. top: 0%;
  270. left: 0;
  271. width: 100%;
  272. }
  273. .discountsDetail {
  274. background: #F9F9F9;
  275. padding-top: 80rpx;
  276. .banner {
  277. width: 100%;
  278. height: 310rpx;
  279. position: relative;
  280. z-index: 99;
  281. }
  282. .zs-list {
  283. margin: 0 24rpx;
  284. .item {
  285. padding: 24rpx;
  286. background: #fff;
  287. border-radius: 16rpx;
  288. margin: 20rpx 0 0;
  289. .box {
  290. display: flex;
  291. .icon {
  292. border-radius: 16px;
  293. }
  294. .info {
  295. flex: 1;
  296. padding-left: 20rpx;
  297. display: flex;
  298. flex-direction: column;
  299. position: relative;
  300. .title {
  301. font-weight: 600;
  302. font-size: 36rpx;
  303. color: #222222;
  304. width: 340rpx;
  305. white-space: nowrap;
  306. overflow: hidden;
  307. text-overflow: ellipsis;
  308. margin-top: 25rpx;
  309. }
  310. .desc {
  311. margin-top: 20rpx;
  312. font-size: 24rpx;
  313. color: #AAAAAA;
  314. overflow: hidden;
  315. text-overflow: ellipsis;
  316. /* 弹性伸缩盒子模型显示 */
  317. display: -webkit-box;
  318. /* 限制在一个块元素显示的文本的行数 */
  319. -webkit-line-clamp: 2;
  320. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  321. -webkit-box-orient: vertical;
  322. }
  323. }
  324. }
  325. .goods-item.none{
  326. border: none;
  327. padding-bottom: 0;
  328. }
  329. .goods-item{
  330. display: flex;
  331. padding: 10rpx 0;
  332. display: flex;
  333. align-items: center;
  334. .tag{
  335. text-align: center;
  336. font-size: 20rpx;
  337. color: #FFFFFF;
  338. background: $uni-color-primary;
  339. padding: 2rpx 10rpx;
  340. border-radius: 8rpx 8rpx 8rpx 8rpx;
  341. }
  342. .goods-name{
  343. font-weight: 400;
  344. font-size: 24rpx;
  345. color: #222222;
  346. margin-left: 18rpx;
  347. width: 260rpx;
  348. white-space: nowrap;
  349. overflow: hidden;
  350. text-overflow: ellipsis;
  351. }
  352. .price-box {
  353. display: flex;
  354. align-items: center;
  355. margin-left: 10rpx;
  356. .unit {
  357. font-size: 20rpx;
  358. color: $uni-color-primary;
  359. font-weight: bold;
  360. }
  361. .price {
  362. font-size: 28rpx;
  363. color: $uni-color-primary;
  364. font-weight: bold;
  365. }
  366. .discount-tag{
  367. display: flex;
  368. align-items: center;
  369. width: 92rpx;
  370. height: 28rpx;
  371. line-height: 28rpx;
  372. background: #FFF6F5;
  373. border-radius: 8rpx 8rpx 8rpx 8rpx;
  374. border: 1rpx solid $uni-color-primary;
  375. margin-left: 10rpx;
  376. .icon{
  377. width: 30.5rpx;
  378. height: 28rpx;
  379. }
  380. .discount-num{
  381. flex: 1;
  382. text-align: center;
  383. font-size: 20rpx;
  384. color: $uni-color-primary;
  385. }
  386. }
  387. .old-price {
  388. font-size: 20rpx;
  389. color: #AAAAAA;
  390. text-decoration: line-through;
  391. margin-left: 12rpx;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. }
  398. </style>