index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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">
  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. @click.native="goDetail(item)"></zs-img>
  11. <view class="info">
  12. <view class="title">
  13. {{item.shopVo.shopName}}
  14. </view>
  15. <view class="desc">
  16. {{item.district}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="goods-item" :class="[d != 0?'none':'']" v-for="(i,d) in filterData(item.goodsVos)" :key="d">
  21. <view class="goods-info">
  22. <!-- <view class="tag">
  23. </view> -->
  24. <view class="goods-name">
  25. {{i.goodsName}}
  26. </view>
  27. </view>
  28. <view class="price-box">
  29. <view class="unit">
  30. </view>
  31. <view class="price">
  32. {{i.realPrice}}
  33. </view>
  34. <view class="old-price">
  35. 市场价 ¥{{i.marketPrice}}
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </zs-list>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. search
  46. } from '@/api/shop.js';
  47. import {
  48. getMenu
  49. } from '@/api/common.js'
  50. export default {
  51. options: {
  52. styleIsolation: 'shared'
  53. },
  54. data() {
  55. return {
  56. longitude: '',
  57. latitude: '',
  58. destination: '',
  59. _mapContext: null,
  60. status: 'more',
  61. list: [],
  62. btnText: '去使用',
  63. banner: '',
  64. menuId:'',
  65. query: {
  66. district:'',
  67. menuId: '',
  68. queryName: '',
  69. range:'',
  70. 'location.lat': 0,
  71. 'location.lon': 0,
  72. pageCurrent: 1,
  73. pageSize: 10
  74. },
  75. location:'',
  76. tabList: [{
  77. id: 1,
  78. label: '区域',
  79. list: [
  80. {
  81. id: 1,
  82. label: '观山湖'
  83. },
  84. {
  85. id: 2,
  86. label: '白云区'
  87. },
  88. {
  89. id: 3,
  90. label: '花果山区'
  91. }
  92. ]
  93. },
  94. {
  95. id: 1,
  96. label: '全部分类',
  97. list: [{
  98. label: '甜点饮品'
  99. },
  100. {
  101. label: '特色美食'
  102. },
  103. {
  104. label: '风味小吃'
  105. }
  106. ]
  107. },
  108. {
  109. id: 1,
  110. label: '附近',
  111. list: [
  112. {
  113. id:5,
  114. label: '5KM'
  115. },
  116. {
  117. id:10,
  118. label: '10KM'
  119. },
  120. {
  121. id:20,
  122. label: '20KM'
  123. },
  124. {
  125. id:50,
  126. label: '50KM'
  127. }
  128. ]
  129. },
  130. ]
  131. }
  132. },
  133. methods: {
  134. // 筛选前两个商品
  135. filterData(data){
  136. return data.slice(0,2)
  137. },
  138. // 金刚区
  139. getMenu(parentId) {
  140. return new Promise((resolve, reject) => {
  141. getMenu({
  142. currentPage: 1,
  143. pageSize: 10,
  144. status: 2,
  145. parentId
  146. }).then(res => {
  147. if (res.state == 'Success') {
  148. let list = []
  149. res.content.records.map(item => {
  150. list.push({
  151. id: item.id,
  152. label: item.menuName
  153. })
  154. })
  155. this.tabList[1].list = list
  156. console.log(this.tabList);
  157. }
  158. })
  159. })
  160. },
  161. chooseTab(val) {
  162. console.log(val);
  163. this.query.range = val[2].id
  164. if(val[0]){
  165. this.query['location.lat'] = val[0].location.lat
  166. this.query['location.lon'] = val[0].location.lng
  167. this.query.range = 50
  168. this.query.district = val[0].label
  169. }else if(!val[0]){
  170. this.query['location.lat'] = this.location.latitude
  171. this.query['location.lon'] = this.location.longitude
  172. this.query.district = ''
  173. }
  174. if(val[1]){
  175. this.query.menuId = val[1].id
  176. }else if(!val[1]){
  177. this.query.menuId = this.menuId
  178. }
  179. this.query.pageCurrent = 1
  180. this.status = 'more'
  181. this.list = []
  182. this.search()
  183. },
  184. goDetail(item) {
  185. uni.setStorageSync('shopInfo', JSON.stringify(item))
  186. uni.navigateTo({
  187. url: '../shopDetail/shopDetail'
  188. })
  189. },
  190. loadMore() {
  191. this.search()
  192. },
  193. search() {
  194. return new Promise((resolve, reject) => {
  195. if (this.status == 'noMore') return
  196. this.status = 'loading'
  197. let obj = JSON.parse(JSON.stringify(this.query))
  198. if(!obj.range){
  199. delete obj.range
  200. }
  201. search(obj).then(res => {
  202. if (res.state == 'Success') {
  203. this.list = this.list.concat(res.content.records)
  204. if (this.list.length >= res.content.total) {
  205. this.status = 'noMore'
  206. } else {
  207. this.status = 'more'
  208. this.query.pageCurrent++
  209. }
  210. resolve()
  211. }
  212. })
  213. })
  214. },
  215. },
  216. onPullDownRefresh() {
  217. this.query.pageCurrent = 1
  218. this.list = []
  219. this.status = 'more'
  220. this.search().then(() => {
  221. uni.stopPullDownRefresh()
  222. })
  223. },
  224. onLoad(option) {
  225. this.tabList[0].list = JSON.parse(uni.getStorageSync('districtList'))
  226. this.menuId = option.id
  227. this.getMenu(option.id)
  228. let that = this
  229. const eventChannel = this.getOpenerEventChannel();
  230. if (JSON.stringify(eventChannel) !== '{}') {
  231. eventChannel.on('banner', function(data) {
  232. that.banner = data
  233. })
  234. }
  235. uni.setNavigationBarTitle({
  236. title: option.title
  237. });
  238. this.query.menuId = option.id
  239. this.location = JSON.parse(uni.getStorageSync('location'))
  240. this.query['location.lat'] = this.location.latitude
  241. this.query['location.lon'] = this.location.longitude
  242. this.search()
  243. },
  244. }
  245. </script>
  246. <style lang="scss">
  247. .bar-item-text {
  248. max-width: 250rpx !important;
  249. }
  250. .screen-bar::after {
  251. display: none;
  252. }
  253. .discountsDetail cc-drop-down-menu .screen-bar {
  254. // position: fixed;
  255. top: 0%;
  256. left: 0;
  257. width: 100%;
  258. }
  259. .discountsDetail {
  260. background: #F9F9F9;
  261. padding-top: 80rpx;
  262. .banner {
  263. width: 100%;
  264. height: 310rpx;
  265. position: relative;
  266. z-index: 99;
  267. }
  268. .zs-list {
  269. margin: 0 24rpx;
  270. .item {
  271. padding: 24rpx;
  272. background: #fff;
  273. border-radius: 16rpx;
  274. margin: 20rpx 0 0;
  275. .box {
  276. display: flex;
  277. .icon {
  278. border-radius: 16px;
  279. }
  280. .info {
  281. flex: 1;
  282. padding-left: 20rpx;
  283. display: flex;
  284. flex-direction: column;
  285. position: relative;
  286. .title {
  287. font-weight: 600;
  288. font-size: 36rpx;
  289. color: #222222;
  290. width: 340rpx;
  291. white-space: nowrap;
  292. overflow: hidden;
  293. text-overflow: ellipsis;
  294. margin-top: 25rpx;
  295. }
  296. .desc {
  297. margin-top: 30rpx;
  298. font-size: 24rpx;
  299. color: #AAAAAA;
  300. overflow: hidden;
  301. text-overflow: ellipsis;
  302. /* 弹性伸缩盒子模型显示 */
  303. display: -webkit-box;
  304. /* 限制在一个块元素显示的文本的行数 */
  305. -webkit-line-clamp: 2;
  306. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  307. -webkit-box-orient: vertical;
  308. }
  309. }
  310. }
  311. .goods-item.none{
  312. border: none;
  313. padding-bottom: 0;
  314. }
  315. .goods-item{
  316. display: flex;
  317. justify-content: space-between;
  318. padding: 20rpx 0;
  319. border-bottom: 1rpx solid #F0F0F0;
  320. .goods-info{
  321. display: flex;
  322. align-items: center;
  323. .tag{
  324. text-align: center;
  325. font-size: 24rpx;
  326. color: #FFFFFF;
  327. width: 30rpx;
  328. height: 30rpx;
  329. line-height: 30rpx;
  330. background: #EE4320;
  331. border-radius: 8rpx 8rpx 8rpx 8rpx;
  332. }
  333. .goods-name{
  334. font-weight: 400;
  335. font-size: 24rpx;
  336. color: #222222;
  337. margin-left: 18rpx;
  338. }
  339. }
  340. .price-box {
  341. display: flex;
  342. align-items: center;
  343. .unit {
  344. font-size: 20rpx;
  345. color: #FF4D3A;
  346. font-weight: bold;
  347. }
  348. .price {
  349. font-size: 32rpx;
  350. color: #FF4D3A;
  351. font-weight: bold;
  352. }
  353. .old-price {
  354. font-size: 20rpx;
  355. color: #AAAAAA;
  356. text-decoration: line-through;
  357. margin-left: 12rpx;
  358. }
  359. }
  360. }
  361. }
  362. }
  363. }
  364. </style>