index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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.platformPrice?i.platformPrice.price:i.realPrice}}
  32. </view>
  33. <view class="discount-tag" v-if="i.marketPrice">
  34. <view class="discount-num">
  35. {{(((i.platformPrice?i.platformPrice.price:i.realPrice)/i.marketPrice)*10).toFixed(1)}}折
  36. </view>
  37. </view>
  38. <view class="old-price">
  39. ¥{{i.marketPrice}}
  40. </view>
  41. </view>
  42. <view class="goods-name">
  43. {{i.goodsName}}
  44. </view>
  45. </view>
  46. </view>
  47. </zs-list>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. search
  53. } from '@/api/shop.js';
  54. import {
  55. getMenu
  56. } from '@/api/common.js'
  57. export default {
  58. options: {
  59. styleIsolation: 'shared'
  60. },
  61. data() {
  62. return {
  63. longitude: '',
  64. latitude: '',
  65. destination: '',
  66. _mapContext: null,
  67. status: 'more',
  68. list: [],
  69. btnText: '去使用',
  70. banner: '',
  71. menuId:'',
  72. query: {
  73. platform:'520100',//慧研学520100 中数5201000 贵大 p-0001
  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. if(data){
  145. return data.slice(0,2)
  146. }else{
  147. return []
  148. }
  149. },
  150. // 金刚区
  151. getMenu(parentId) {
  152. return new Promise((resolve, reject) => {
  153. getMenu({
  154. currentPage: 1,
  155. pageSize: 10,
  156. status: 2,
  157. parentId
  158. }).then(res => {
  159. if (res.state == 'Success') {
  160. let list = []
  161. res.content.records.map(item => {
  162. list.push({
  163. id: item.id,
  164. label: item.menuName
  165. })
  166. })
  167. this.tabList[1].list = list
  168. console.log(this.tabList);
  169. }
  170. })
  171. })
  172. },
  173. chooseTab(val) {
  174. this.query.range = val[2].id
  175. if(val[0]){
  176. // this.query['location.lat'] = val[0].location.lat
  177. // this.query['location.lon'] = val[0].location.lng
  178. this.query.range = 50
  179. this.query.district = val[0].label
  180. }else if(!val[0]){
  181. this.query['location.lat'] = this.location.latitude
  182. this.query['location.lon'] = this.location.longitude
  183. this.query.district = ''
  184. }
  185. if(val[1]){
  186. this.query.secondMenuId =+val[1].id
  187. }else if(!val[1]){
  188. delete this.query.secondMenuId
  189. }
  190. this.query.pageCurrent = 1
  191. this.status = 'more'
  192. this.list = []
  193. this.search()
  194. console.log(this.query.menuId);
  195. },
  196. goDetail(item) {
  197. let shopInfo = {
  198. shopId:item.shopVo.shopId,
  199. shopName:item.shopVo.shopName,
  200. detailContent:item.detailContent,
  201. logoPath:item.logoPath,
  202. }
  203. uni.setStorageSync('shopInfo', JSON.stringify(shopInfo))
  204. uni.navigateTo({
  205. url: '../shopDetail/shopDetail'
  206. })
  207. },
  208. loadMore() {
  209. this.search()
  210. },
  211. search() {
  212. return new Promise((resolve, reject) => {
  213. if (this.status == 'noMore') return
  214. this.status = 'loading'
  215. let obj = JSON.parse(JSON.stringify(this.query))
  216. if(!obj.range){
  217. delete obj.range
  218. }
  219. if(uni.getStorageSync('city').indexOf(uni.getStorageSync('HomeCity')) == -1){
  220. obj.city = uni.getStorageSync('HomeCity')
  221. }
  222. search(obj).then(res => {
  223. if (res.state == 'Success') {
  224. this.list = this.list.concat(res.content.records)
  225. if (this.list.length >= res.content.total) {
  226. this.status = 'noMore'
  227. } else {
  228. this.status = 'more'
  229. this.query.pageCurrent++
  230. }
  231. resolve()
  232. }
  233. })
  234. })
  235. },
  236. },
  237. onPullDownRefresh() {
  238. this.query.pageCurrent = 1
  239. this.list = []
  240. this.status = 'more'
  241. this.search().then(() => {
  242. uni.stopPullDownRefresh()
  243. })
  244. },
  245. onLoad(option) {
  246. this.tabList[0].list = JSON.parse(uni.getStorageSync('districtList'))
  247. this.menuId = option.id
  248. this.getMenu(option.id)
  249. let that = this
  250. const eventChannel = this.getOpenerEventChannel();
  251. if (JSON.stringify(eventChannel) !== '{}') {
  252. eventChannel.on('banner', function(data) {
  253. that.banner = data
  254. })
  255. }
  256. uni.setNavigationBarTitle({
  257. title: option.title
  258. });
  259. this.query.menuId = option.id
  260. this.location = JSON.parse(uni.getStorageSync('location'))
  261. this.query['location.lat'] = this.location.latitude
  262. this.query['location.lon'] = this.location.longitude
  263. this.search()
  264. },
  265. }
  266. </script>
  267. <style lang="scss">
  268. .bar-item-text {
  269. max-width: 250rpx !important;
  270. }
  271. .screen-bar::after {
  272. display: none;
  273. }
  274. .discountsDetail cc-drop-down-menu .screen-bar {
  275. // position: fixed;
  276. top: 0%;
  277. left: 0;
  278. width: 100%;
  279. }
  280. .discountsDetail {
  281. background: #F9F9F9;
  282. padding-top: 80rpx;
  283. .banner {
  284. width: 100%;
  285. height: 310rpx;
  286. position: relative;
  287. z-index: 99;
  288. }
  289. .zs-list {
  290. margin: 0 24rpx;
  291. .item {
  292. padding: 24rpx;
  293. background: #fff;
  294. border-radius: 16rpx;
  295. margin: 20rpx 0 0;
  296. .box {
  297. display: flex;
  298. .icon {
  299. border-radius: 16px;
  300. }
  301. .info {
  302. flex: 1;
  303. padding-left: 20rpx;
  304. display: flex;
  305. flex-direction: column;
  306. position: relative;
  307. .title {
  308. font-weight: 600;
  309. font-size: 36rpx;
  310. color: #222222;
  311. width: 340rpx;
  312. white-space: nowrap;
  313. overflow: hidden;
  314. text-overflow: ellipsis;
  315. margin-top: 25rpx;
  316. }
  317. .desc {
  318. margin-top: 20rpx;
  319. font-size: 24rpx;
  320. color: #AAAAAA;
  321. overflow: hidden;
  322. text-overflow: ellipsis;
  323. /* 弹性伸缩盒子模型显示 */
  324. display: -webkit-box;
  325. /* 限制在一个块元素显示的文本的行数 */
  326. -webkit-line-clamp: 2;
  327. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  328. -webkit-box-orient: vertical;
  329. }
  330. }
  331. }
  332. .goods-item.none{
  333. border: none;
  334. padding-bottom: 0;
  335. }
  336. .goods-item{
  337. display: flex;
  338. padding: 10rpx 0;
  339. display: flex;
  340. align-items: center;
  341. .tag{
  342. text-align: center;
  343. font-size: 20rpx;
  344. color: #FFFFFF;
  345. background: $uni-color-primary;
  346. padding: 2rpx 10rpx;
  347. border-radius: 8rpx 8rpx 8rpx 8rpx;
  348. }
  349. .goods-name{
  350. font-weight: 400;
  351. font-size: 24rpx;
  352. color: #222222;
  353. margin-left: 18rpx;
  354. width: 250rpx;
  355. white-space: nowrap;
  356. overflow: hidden;
  357. text-overflow: ellipsis;
  358. }
  359. .price-box {
  360. display: flex;
  361. align-items: center;
  362. margin-left: 10rpx;
  363. .unit {
  364. font-size: 20rpx;
  365. color: $uni-color-primary;
  366. font-weight: bold;
  367. }
  368. .price {
  369. font-size: 28rpx;
  370. color: $uni-color-primary;
  371. font-weight: bold;
  372. }
  373. .discount-tag{
  374. display: flex;
  375. align-items: center;
  376. width: 82rpx;
  377. height: 28rpx;
  378. line-height: 28rpx;
  379. background: #FFF6F5;
  380. border-radius: 8rpx 8rpx 8rpx 8rpx;
  381. border: 1rpx solid $uni-color-primary;
  382. margin-left: 10rpx;
  383. .icon{
  384. width: 30.5rpx;
  385. height: 28rpx;
  386. }
  387. .discount-num{
  388. flex: 1;
  389. text-align: center;
  390. font-size: 20rpx;
  391. color: $uni-color-primary;
  392. }
  393. }
  394. .old-price {
  395. font-size: 20rpx;
  396. color: #AAAAAA;
  397. text-decoration: line-through;
  398. margin-left: 12rpx;
  399. }
  400. }
  401. }
  402. }
  403. }
  404. }
  405. </style>