index.vue 8.9 KB

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