index.vue 8.9 KB

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