index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="refuel">
  3. <!-- 内容 -->
  4. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  5. <view class="item" v-for="(item,index) in list" :key="index" @click="goDetail(item)">
  6. <zs-img :src="item.logo" width="200rpx" height="200rpx" radius="full" ></zs-img>
  7. <view class="info">
  8. <view class="title">
  9. {{item.storeName}}
  10. </view>
  11. <view class="address" >
  12. 距离你 {{(item.distance/1000).toFixed(2)}} 公里
  13. </view>
  14. <view class="activity">
  15. <view class="price-box">
  16. <view class="price">
  17. ¥{{item |filterVipPrice}}/L
  18. </view>
  19. <view class="old-price">
  20. 国际价 ¥{{item|filterPrice}}/L
  21. </view>
  22. </view>
  23. <view class="coupon">
  24. 可使用优惠券
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </zs-list>
  30. </view>
  31. </template>
  32. <script>
  33. import { getNearbyStore } from '@/api/refuel.js';
  34. import {
  35. search
  36. } from '@/api/shop.js';
  37. export default {
  38. data() {
  39. return {
  40. map: null,
  41. longitude: 0,
  42. latitude: 0,
  43. scale:18,
  44. markers: [],
  45. destination: '',
  46. active: 0,
  47. status: 'more',
  48. list: [],
  49. list: [],
  50. // query:{
  51. // latitude:39.896751,
  52. // longitude:116.460653,
  53. // maxDistanceInKilometers:50,
  54. // pageCurrent:1,
  55. // pageSize:10
  56. // },
  57. query: {
  58. district:'',
  59. menuId: 4,
  60. queryName: '',
  61. 'location.lat': 0,
  62. 'location.lon': 0,
  63. pageCurrent: 1,
  64. pageSize: 10
  65. },
  66. }
  67. },
  68. filters: {
  69. filterVipPrice: function(item) {
  70. let arr = item.itemInfoList.filter(i=>i.itemName == '92#')
  71. if(!arr.length &&item.itemInfoList.length){
  72. arr = [item.itemInfoList[0]]
  73. }
  74. return arr.length?(arr[0].vipPrice/100).toFixed(2) : 0;
  75. },
  76. filterPrice: function(item) {
  77. let arr = item.itemInfoList.filter(i=>i.itemName == '92#')
  78. if(!arr.length &&item.itemInfoList.length){
  79. arr = [item.itemInfoList[0]]
  80. }
  81. return arr.length?(arr[0].cityPrice/100).toFixed(2) : 0;
  82. }
  83. },
  84. methods: {
  85. goDetail(item) {
  86. if(!uni.getStorageSync('token')){
  87. return uni.showModal({
  88. title:'请登录',
  89. confirmText:'去登录',
  90. success(res){
  91. console.log(res);
  92. if(res.confirm){
  93. uni.navigateTo({
  94. url:'/login/login/login?redirect=/refuel/index'
  95. })
  96. }
  97. }
  98. })
  99. }
  100. uni.navigateTo({
  101. url: `/refuel/refuelDetail?id=${item.storeId}&epId=${item.shopId}`
  102. })
  103. },
  104. loadMore() {
  105. this.search()
  106. },
  107. search() {
  108. this.status = 'loading'
  109. let obj = JSON.parse(JSON.stringify(this.query))
  110. search(obj).then(res => {
  111. uni.stopPullDownRefresh()
  112. if (res.state == 'Success') {
  113. let dataList = []
  114. res.content.records.map(item=>{
  115. let obj
  116. if(item.tripartiteJson){
  117. obj = JSON.parse(item.tripartiteJson)
  118. obj.distance = item.shopVo.distance
  119. obj.shopId = item.shopVo.id
  120. dataList.push(obj)
  121. }
  122. })
  123. this.list = this.list.concat(dataList)
  124. console.log(this.list);
  125. if (this.list.length >= res.content.total) {
  126. this.status = 'noMore'
  127. } else {
  128. this.status = 'more'
  129. this.query.pageCurrent++
  130. }
  131. }
  132. })
  133. // getNearbyStore(this.query).then(res=>{
  134. // uni.stopPullDownRefresh()
  135. // this.status = 'noMore'
  136. // if(res.state == 'Success'){
  137. // this.list = res.content
  138. // }
  139. // })
  140. },
  141. },
  142. onPullDownRefresh() {
  143. uni.getLocation({
  144. type: 'gcj02',
  145. success: (res) => {
  146. // 解析地址
  147. this.query['location.lat'] = res.latitude
  148. this.query['location.lon'] = res.longitude
  149. // 存储经纬度
  150. uni.setStorageSync('location',JSON.stringify({latitude:res.latitude,longitude:res.longitude}))
  151. this.query.pageCurrent = 1
  152. this.status = 'more'
  153. this.list = []
  154. this.search()
  155. }
  156. })
  157. },
  158. onLoad(option) {
  159. },
  160. onReady() {
  161. // let location = JSON.parse(uni.getStorageSync('location'))
  162. // this.query['location.lat'] = location.latitude
  163. // this.query['location.lon']= location.longitude
  164. // this.search()
  165. uni.getLocation({
  166. type: 'gcj02',
  167. success: (res) => {
  168. // 解析地址
  169. this.query['location.lat'] = res.latitude
  170. this.query['location.lon'] = res.longitude
  171. console.log(this);
  172. // 存储经纬度
  173. uni.setStorageSync('location',JSON.stringify({latitude:res.latitude,longitude:res.longitude}))
  174. this.search()
  175. }
  176. })
  177. }
  178. }
  179. </script>
  180. <style lang="scss">
  181. .refuel {
  182. background: #F9F9F9;
  183. padding: 20rpx 24rpx;
  184. .zs-list {
  185. // padding-top: 20rpx;
  186. .item {
  187. display: flex;
  188. padding: 24rpx;
  189. background: #fff;
  190. border-radius: 16rpx;
  191. margin-bottom: 20rpx;
  192. .icon {
  193. width: 200rpx;
  194. height: 180rpx;
  195. border-radius: 8px;
  196. }
  197. .info{
  198. flex: 1;
  199. padding: 16rpx 0 16rpx 20rpx;
  200. display: flex;
  201. flex-direction: column;
  202. justify-content: space-between;
  203. .title{
  204. font-size: 28rpx;
  205. font-weight: bold;
  206. width: 340rpx;
  207. white-space: nowrap;
  208. overflow: hidden;
  209. text-overflow: ellipsis;
  210. margin-top: 10rpx;
  211. }
  212. .address{
  213. font-weight: 300;
  214. font-size: 24rpx;
  215. color: #AAAAAA;
  216. }
  217. .activity{
  218. display: flex;
  219. align-items: center;
  220. justify-content: space-between;
  221. .price-box{
  222. display: flex;
  223. align-items: center;
  224. .price{
  225. font-weight: 600;
  226. font-size: 32rpx;
  227. color: $uni-color-primary;
  228. }
  229. .old-price{
  230. font-weight: 300;
  231. font-size: 18rpx;
  232. color: #AAAAAA;
  233. text-decoration: line-through;
  234. margin-left: 10rpx;
  235. }
  236. }
  237. .coupon{
  238. font-weight: 300;
  239. font-size: 24rpx;
  240. color: $uni-color-primary;
  241. }
  242. }
  243. }
  244. }
  245. }
  246. }
  247. </style>