index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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:'p-0002',//慧研学p-0002 中数p-0003 贵大 p-0001
  74. platformType:1,
  75. district:'',
  76. menuId: '',
  77. queryName: '',
  78. range:'',
  79. 'location.lat': 0,
  80. 'location.lon': 0,
  81. pageCurrent: 1,
  82. pageSize: 100
  83. },
  84. location:'',
  85. tabList: [{
  86. id: 1,
  87. label: '区域',
  88. list: [
  89. {
  90. id: 1,
  91. label: '观山湖'
  92. },
  93. {
  94. id: 2,
  95. label: '白云区'
  96. },
  97. {
  98. id: 3,
  99. label: '花果山区'
  100. }
  101. ]
  102. },
  103. {
  104. id: 1,
  105. label: '全部分类',
  106. list: [{
  107. label: '甜点饮品'
  108. },
  109. {
  110. label: '特色美食'
  111. },
  112. {
  113. label: '风味小吃'
  114. }
  115. ]
  116. },
  117. {
  118. id: 1,
  119. label: '附近',
  120. list: [
  121. {
  122. id:5,
  123. label: '5KM'
  124. },
  125. {
  126. id:10,
  127. label: '10KM'
  128. },
  129. {
  130. id:20,
  131. label: '20KM'
  132. },
  133. {
  134. id:50,
  135. label: '50KM'
  136. }
  137. ]
  138. },
  139. ]
  140. }
  141. },
  142. methods: {
  143. // 筛选前两个商品
  144. filterData(data){
  145. if(data){
  146. return data.slice(0,2)
  147. }else{
  148. return []
  149. }
  150. },
  151. // 金刚区
  152. getMenu(parentId) {
  153. return new Promise((resolve, reject) => {
  154. getMenu({
  155. currentPage: 1,
  156. pageSize: 10,
  157. status: 2,
  158. parentId
  159. }).then(res => {
  160. if (res.state == 'Success') {
  161. let list = []
  162. res.content.records.map(item => {
  163. list.push({
  164. id: item.id,
  165. label: item.menuName
  166. })
  167. })
  168. this.tabList[1].list = list
  169. console.log(this.tabList);
  170. }
  171. })
  172. })
  173. },
  174. chooseTab(val) {
  175. this.query.range = val[2].id
  176. if(val[0]){
  177. // this.query['location.lat'] = val[0].location.lat
  178. // this.query['location.lon'] = val[0].location.lng
  179. this.query.range = 50
  180. this.query.district = val[0].label
  181. }else if(!val[0]){
  182. this.query['location.lat'] = this.location.latitude
  183. this.query['location.lon'] = this.location.longitude
  184. this.query.district = ''
  185. }
  186. if(val[1]){
  187. this.query.secondMenuId =+val[1].id
  188. }else if(!val[1]){
  189. delete this.query.secondMenuId
  190. }
  191. this.query.pageCurrent = 1
  192. this.status = 'more'
  193. this.list = []
  194. this.search()
  195. console.log(this.query.menuId);
  196. },
  197. goDetail(item) {
  198. let shopInfo = {
  199. shopId:item.shopVo.shopId,
  200. shopName:item.shopVo.shopName,
  201. detailContent:item.detailContent,
  202. logoPath:item.logoPath,
  203. }
  204. uni.setStorageSync('shopInfo', JSON.stringify(shopInfo))
  205. uni.navigateTo({
  206. url: '../shopDetail/shopDetail'
  207. })
  208. },
  209. loadMore() {
  210. this.search()
  211. },
  212. search() {
  213. return new Promise((resolve, reject) => {
  214. if (this.status == 'noMore') return
  215. this.status = 'loading'
  216. let obj = JSON.parse(JSON.stringify(this.query))
  217. if(!obj.range){
  218. delete obj.range
  219. }
  220. if(uni.getStorageSync('city').indexOf(uni.getStorageSync('HomeCity')) == -1){
  221. obj.city = uni.getStorageSync('HomeCity')
  222. }
  223. search(obj).then(res => {
  224. if (res.state == 'Success') {
  225. this.list = this.list.concat(res.content.records)
  226. if (this.list.length >= res.content.total) {
  227. this.status = 'noMore'
  228. } else {
  229. this.status = 'more'
  230. this.query.pageCurrent++
  231. }
  232. resolve()
  233. }
  234. })
  235. })
  236. },
  237. },
  238. onPullDownRefresh() {
  239. this.query.pageCurrent = 1
  240. this.list = []
  241. this.status = 'more'
  242. this.search().then(() => {
  243. uni.stopPullDownRefresh()
  244. })
  245. },
  246. onLoad(option) {
  247. this.tabList[0].list = JSON.parse(uni.getStorageSync('districtList'))
  248. this.menuId = option.id
  249. this.getMenu(option.id)
  250. let that = this
  251. const eventChannel = this.getOpenerEventChannel();
  252. if (JSON.stringify(eventChannel) !== '{}') {
  253. eventChannel.on('banner', function(data) {
  254. that.banner = data
  255. })
  256. }
  257. uni.setNavigationBarTitle({
  258. title: option.title
  259. });
  260. this.query.menuId = option.id
  261. this.location = JSON.parse(uni.getStorageSync('location'))
  262. this.query['location.lat'] = this.location.latitude
  263. this.query['location.lon'] = this.location.longitude
  264. this.search()
  265. },
  266. }
  267. </script>
  268. <style lang="scss">
  269. .bar-item-text {
  270. max-width: 250rpx !important;
  271. }
  272. .screen-bar::after {
  273. display: none;
  274. }
  275. .discountsDetail cc-drop-down-menu .screen-bar {
  276. // position: fixed;
  277. top: 0%;
  278. left: 0;
  279. width: 100%;
  280. }
  281. .discountsDetail {
  282. background: #F9F9F9;
  283. padding-top: 80rpx;
  284. .banner {
  285. width: 100%;
  286. height: 310rpx;
  287. position: relative;
  288. z-index: 99;
  289. }
  290. .zs-list {
  291. margin: 0 24rpx;
  292. .item {
  293. padding: 24rpx;
  294. background: #fff;
  295. border-radius: 16rpx;
  296. margin: 20rpx 0 0;
  297. .box {
  298. display: flex;
  299. .icon {
  300. border-radius: 16px;
  301. }
  302. .info {
  303. flex: 1;
  304. padding-left: 20rpx;
  305. display: flex;
  306. flex-direction: column;
  307. position: relative;
  308. .title {
  309. font-weight: 600;
  310. font-size: 36rpx;
  311. color: #222222;
  312. width: 340rpx;
  313. white-space: nowrap;
  314. overflow: hidden;
  315. text-overflow: ellipsis;
  316. margin-top: 25rpx;
  317. }
  318. .desc {
  319. margin-top: 20rpx;
  320. font-size: 24rpx;
  321. color: #AAAAAA;
  322. overflow: hidden;
  323. text-overflow: ellipsis;
  324. /* 弹性伸缩盒子模型显示 */
  325. display: -webkit-box;
  326. /* 限制在一个块元素显示的文本的行数 */
  327. -webkit-line-clamp: 2;
  328. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  329. -webkit-box-orient: vertical;
  330. }
  331. }
  332. }
  333. .goods-item.none{
  334. border: none;
  335. padding-bottom: 0;
  336. }
  337. .goods-item{
  338. display: flex;
  339. padding: 10rpx 0;
  340. display: flex;
  341. align-items: center;
  342. .tag{
  343. text-align: center;
  344. font-size: 20rpx;
  345. color: #FFFFFF;
  346. background: $uni-color-primary;
  347. padding: 2rpx 10rpx;
  348. border-radius: 8rpx 8rpx 8rpx 8rpx;
  349. }
  350. .goods-name{
  351. font-weight: 400;
  352. font-size: 24rpx;
  353. color: #222222;
  354. margin-left: 18rpx;
  355. width: 250rpx;
  356. white-space: nowrap;
  357. overflow: hidden;
  358. text-overflow: ellipsis;
  359. }
  360. .price-box {
  361. display: flex;
  362. align-items: center;
  363. margin-left: 10rpx;
  364. .unit {
  365. font-size: 20rpx;
  366. color: $uni-color-primary;
  367. font-weight: bold;
  368. }
  369. .price {
  370. font-size: 28rpx;
  371. color: $uni-color-primary;
  372. font-weight: bold;
  373. }
  374. .discount-tag{
  375. display: flex;
  376. align-items: center;
  377. width: 82rpx;
  378. height: 28rpx;
  379. line-height: 28rpx;
  380. background: #FFF6F5;
  381. border-radius: 8rpx 8rpx 8rpx 8rpx;
  382. border: 1rpx solid $uni-color-primary;
  383. margin-left: 10rpx;
  384. .icon{
  385. width: 30.5rpx;
  386. height: 28rpx;
  387. }
  388. .discount-num{
  389. flex: 1;
  390. text-align: center;
  391. font-size: 20rpx;
  392. color: $uni-color-primary;
  393. }
  394. }
  395. .old-price {
  396. font-size: 20rpx;
  397. color: #AAAAAA;
  398. text-decoration: line-through;
  399. margin-left: 12rpx;
  400. }
  401. }
  402. }
  403. }
  404. }
  405. }
  406. </style>