index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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. search(obj).then(res => {
  215. if (res.state == 'Success') {
  216. this.list = this.list.concat(res.content.records)
  217. if (this.list.length >= res.content.total) {
  218. this.status = 'noMore'
  219. } else {
  220. this.status = 'more'
  221. this.query.pageCurrent++
  222. }
  223. resolve()
  224. }
  225. })
  226. })
  227. },
  228. },
  229. onPullDownRefresh() {
  230. this.query.pageCurrent = 1
  231. this.list = []
  232. this.status = 'more'
  233. this.search().then(() => {
  234. uni.stopPullDownRefresh()
  235. })
  236. },
  237. onLoad(option) {
  238. this.tabList[0].list = JSON.parse(uni.getStorageSync('districtList'))
  239. this.menuId = option.id
  240. this.getMenu(option.id)
  241. let that = this
  242. const eventChannel = this.getOpenerEventChannel();
  243. if (JSON.stringify(eventChannel) !== '{}') {
  244. eventChannel.on('banner', function(data) {
  245. that.banner = data
  246. })
  247. }
  248. uni.setNavigationBarTitle({
  249. title: option.title
  250. });
  251. this.query.menuId = option.id
  252. this.location = JSON.parse(uni.getStorageSync('location'))
  253. this.query['location.lat'] = this.location.latitude
  254. this.query['location.lon'] = this.location.longitude
  255. this.search()
  256. },
  257. }
  258. </script>
  259. <style lang="scss">
  260. .bar-item-text {
  261. max-width: 250rpx !important;
  262. }
  263. .screen-bar::after {
  264. display: none;
  265. }
  266. .discountsDetail cc-drop-down-menu .screen-bar {
  267. // position: fixed;
  268. top: 0%;
  269. left: 0;
  270. width: 100%;
  271. }
  272. .discountsDetail {
  273. background: #F9F9F9;
  274. padding-top: 80rpx;
  275. .banner {
  276. width: 100%;
  277. height: 310rpx;
  278. position: relative;
  279. z-index: 99;
  280. }
  281. .zs-list {
  282. margin: 0 24rpx;
  283. .item {
  284. padding: 24rpx;
  285. background: #fff;
  286. border-radius: 16rpx;
  287. margin: 20rpx 0 0;
  288. .box {
  289. display: flex;
  290. .icon {
  291. border-radius: 16px;
  292. }
  293. .info {
  294. flex: 1;
  295. padding-left: 20rpx;
  296. display: flex;
  297. flex-direction: column;
  298. position: relative;
  299. .title {
  300. font-weight: 600;
  301. font-size: 36rpx;
  302. color: #222222;
  303. width: 340rpx;
  304. white-space: nowrap;
  305. overflow: hidden;
  306. text-overflow: ellipsis;
  307. margin-top: 25rpx;
  308. }
  309. .desc {
  310. margin-top: 20rpx;
  311. font-size: 24rpx;
  312. color: #AAAAAA;
  313. overflow: hidden;
  314. text-overflow: ellipsis;
  315. /* 弹性伸缩盒子模型显示 */
  316. display: -webkit-box;
  317. /* 限制在一个块元素显示的文本的行数 */
  318. -webkit-line-clamp: 2;
  319. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  320. -webkit-box-orient: vertical;
  321. }
  322. }
  323. }
  324. .goods-item.none{
  325. border: none;
  326. padding-bottom: 0;
  327. }
  328. .goods-item{
  329. display: flex;
  330. padding: 10rpx 0;
  331. display: flex;
  332. align-items: center;
  333. .tag{
  334. text-align: center;
  335. font-size: 20rpx;
  336. color: #FFFFFF;
  337. background: $uni-color-primary;
  338. padding: 2rpx 10rpx;
  339. border-radius: 8rpx 8rpx 8rpx 8rpx;
  340. }
  341. .goods-name{
  342. font-weight: 400;
  343. font-size: 24rpx;
  344. color: #222222;
  345. margin-left: 18rpx;
  346. width: 250rpx;
  347. white-space: nowrap;
  348. overflow: hidden;
  349. text-overflow: ellipsis;
  350. }
  351. .price-box {
  352. display: flex;
  353. align-items: center;
  354. margin-left: 10rpx;
  355. .unit {
  356. font-size: 20rpx;
  357. color: $uni-color-primary;
  358. font-weight: bold;
  359. }
  360. .price {
  361. font-size: 28rpx;
  362. color: $uni-color-primary;
  363. font-weight: bold;
  364. }
  365. .discount-tag{
  366. display: flex;
  367. align-items: center;
  368. width: 82rpx;
  369. height: 28rpx;
  370. line-height: 28rpx;
  371. background: #FFF6F5;
  372. border-radius: 8rpx 8rpx 8rpx 8rpx;
  373. border: 1rpx solid $uni-color-primary;
  374. margin-left: 10rpx;
  375. .icon{
  376. width: 30.5rpx;
  377. height: 28rpx;
  378. }
  379. .discount-num{
  380. flex: 1;
  381. text-align: center;
  382. font-size: 20rpx;
  383. color: $uni-color-primary;
  384. }
  385. }
  386. .old-price {
  387. font-size: 20rpx;
  388. color: #AAAAAA;
  389. text-decoration: line-through;
  390. margin-left: 12rpx;
  391. }
  392. }
  393. }
  394. }
  395. }
  396. }
  397. </style>