index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view class="refuel">
  3. <image class="banner" src="https://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/03uYm9N6msBkfcb964559107edb57a716b835f90fde5.jpg/1.jpg" mode=""></image>
  4. <view class="notice-box">
  5. <image class="icon" src="../static/notice.png" mode=""></image>
  6. 进入加油站后,请前往安全区域使用手机
  7. </view>
  8. <!-- 内容 -->
  9. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  10. <view class="item" v-for="(item,index) in list" :key="index" @click="goDetail(item)">
  11. <image class="tag" src="../static/refuel-tag.png" mode=""></image>
  12. <!-- <zs-img :src="item.logo" width="200rpx" height="200rpx" radius="full" ></zs-img> -->
  13. <view class="info">
  14. <view class="title-box">
  15. <view class="title">
  16. {{item.storeName}}
  17. </view>
  18. <view class="diatance-box">
  19. <image class="icon" src="../static/refuel/nav-icon-black.png" mode=""></image>
  20. {{(item.distance/1000).toFixed(2)}}km
  21. </view>
  22. </view>
  23. <view class="address" >
  24. 距离你 {{(item.distance/1000).toFixed(2)}} 公里
  25. </view>
  26. <view class="activity">
  27. <view class="discount">
  28. 满200元减14
  29. </view>
  30. <!-- <view class="coupon">
  31. <image class="icon" src="../static/refuel/card-icon.png" mode=""></image>
  32. 优惠券省999
  33. </view> -->
  34. <view class="price-box">
  35. <view class="label">
  36. 特惠价
  37. </view>
  38. <view class="price">
  39. ¥{{item |filterVipPrice}}/L
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </zs-list>
  46. </view>
  47. </template>
  48. <script>
  49. import { getNearbyStore } from '@/api/refuel.js';
  50. import {
  51. search
  52. } from '@/api/shop.js';
  53. export default {
  54. data() {
  55. return {
  56. map: null,
  57. longitude: 0,
  58. latitude: 0,
  59. scale:18,
  60. markers: [],
  61. destination: '',
  62. active: 0,
  63. status: 'more',
  64. list: [],
  65. list: [],
  66. // query:{
  67. // latitude:39.896751,
  68. // longitude:116.460653,
  69. // maxDistanceInKilometers:50,
  70. // pageCurrent:1,
  71. // pageSize:10
  72. // },
  73. query: {
  74. district:'',
  75. menuId: 4,
  76. queryName: '',
  77. 'location.lat': 0,
  78. 'location.lon': 0,
  79. pageCurrent: 1,
  80. pageSize: 10,
  81. userId: uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).userId:''
  82. },
  83. }
  84. },
  85. filters: {
  86. filterVipPrice: function(item) {
  87. let arr = item.itemInfoList.filter(i=>i.itemName == '92#')
  88. if(!arr.length &&item.itemInfoList.length){
  89. arr = [item.itemInfoList[0]]
  90. }
  91. return arr.length?(arr[0].vipPrice/100).toFixed(2) : 0;
  92. },
  93. filterPrice: function(item) {
  94. let arr = item.itemInfoList.filter(i=>i.itemName == '92#')
  95. if(!arr.length &&item.itemInfoList.length){
  96. arr = [item.itemInfoList[0]]
  97. }
  98. return arr.length?(arr[0].cityPrice/100).toFixed(2) : 0;
  99. }
  100. },
  101. methods: {
  102. goDetail(item) {
  103. if(!uni.getStorageSync('token')){
  104. return uni.showModal({
  105. title:'请登录',
  106. confirmText:'去登录',
  107. success(res){
  108. console.log(res);
  109. if(res.confirm){
  110. uni.navigateTo({
  111. url:'/login/login/login?redirect=/refuel/index'
  112. })
  113. }
  114. }
  115. })
  116. }
  117. uni.navigateTo({
  118. url: `/refuel/refuelDetail?id=${item.storeId}&epId=${item.shopId}`
  119. })
  120. },
  121. loadMore() {
  122. this.search()
  123. },
  124. search() {
  125. this.status = 'loading'
  126. let obj = JSON.parse(JSON.stringify(this.query))
  127. search(obj).then(res => {
  128. uni.stopPullDownRefresh()
  129. if (res.state == 'Success') {
  130. let dataList = []
  131. res.content.records.map(item=>{
  132. let obj
  133. if(item.tripartiteJson){
  134. obj = JSON.parse(item.tripartiteJson)
  135. obj.distance = item.shopVo.distance
  136. obj.shopId = item.shopVo.id
  137. dataList.push(obj)
  138. }
  139. })
  140. this.list = this.list.concat(dataList)
  141. console.log(this.list);
  142. if (this.list.length >= res.content.total) {
  143. this.status = 'noMore'
  144. } else {
  145. this.status = 'more'
  146. this.query.pageCurrent++
  147. }
  148. }
  149. })
  150. // getNearbyStore(this.query).then(res=>{
  151. // uni.stopPullDownRefresh()
  152. // this.status = 'noMore'
  153. // if(res.state == 'Success'){
  154. // this.list = res.content
  155. // }
  156. // })
  157. },
  158. },
  159. onPullDownRefresh() {
  160. uni.getLocation({
  161. type: 'gcj02',
  162. success: (res) => {
  163. // 解析地址
  164. this.query['location.lat'] = res.latitude
  165. this.query['location.lon'] = res.longitude
  166. // 存储经纬度
  167. uni.setStorageSync('location',JSON.stringify({latitude:res.latitude,longitude:res.longitude}))
  168. this.query.pageCurrent = 1
  169. this.status = 'more'
  170. this.list = []
  171. this.search()
  172. }
  173. })
  174. },
  175. onLoad(option) {
  176. },
  177. onReady() {
  178. // let location = JSON.parse(uni.getStorageSync('location'))
  179. // this.query['location.lat'] = location.latitude
  180. // this.query['location.lon']= location.longitude
  181. // this.search()
  182. uni.getLocation({
  183. type: 'gcj02',
  184. success: (res) => {
  185. // 解析地址
  186. this.query['location.lat'] = res.latitude
  187. this.query['location.lon'] = res.longitude
  188. console.log(this);
  189. // 存储经纬度
  190. uni.setStorageSync('location',JSON.stringify({latitude:res.latitude,longitude:res.longitude}))
  191. this.search()
  192. }
  193. })
  194. }
  195. }
  196. </script>
  197. <style lang="scss">
  198. .refuel {
  199. background: #F9F9F9;
  200. padding: 20rpx 24rpx;
  201. .banner{
  202. width: 100%;
  203. height: 132rpx;
  204. border-radius: 16rpx;
  205. }
  206. .notice-box{
  207. display: flex;
  208. align-items: center;
  209. font-weight: 300;
  210. font-size: 22rpx;
  211. color: #EE4927;
  212. margin: 20rpx 0;
  213. .icon{
  214. width: 26rpx;
  215. height: 26rpx;
  216. margin-right: 10rpx;
  217. }
  218. }
  219. .zs-list {
  220. // padding-top: 20rpx;
  221. .item {
  222. display: flex;
  223. padding: 24rpx;
  224. background: #fff;
  225. border-radius: 16rpx;
  226. margin-bottom: 20rpx;
  227. position: relative;
  228. .tag{
  229. position: absolute;
  230. top: 0%;
  231. left: 0%;
  232. width: 150rpx;
  233. height: 53rpx;
  234. }
  235. .info{
  236. flex: 1;
  237. padding: 26rpx 0 0;
  238. .title-box{
  239. display: flex;
  240. align-items: center;
  241. justify-content: space-between;
  242. .title{
  243. font-size: 28rpx;
  244. font-weight: bold;
  245. width: 500rpx;
  246. white-space: nowrap;
  247. overflow: hidden;
  248. text-overflow: ellipsis;
  249. margin-top: 10rpx;
  250. }
  251. .diatance-box{
  252. display: flex;
  253. align-items: center;
  254. font-weight: 400;
  255. font-size: 24rpx;
  256. color: #222222;
  257. .icon{
  258. width: 20rpx;
  259. height: 20rpx;
  260. margin-right: 8rpx;
  261. }
  262. }
  263. }
  264. .address{
  265. font-weight: 300;
  266. font-size: 24rpx;
  267. color: #AAAAAA;
  268. margin-top: 12rpx;
  269. }
  270. .activity{
  271. display: flex;
  272. align-items: center;
  273. justify-content: space-between;
  274. margin-top: 10rpx;
  275. .price-box{
  276. display: flex;
  277. align-items: center;
  278. .label{
  279. font-weight: 300;
  280. font-size: 20rpx;
  281. color: #FF4D3A;
  282. }
  283. .price{
  284. font-weight: 600;
  285. font-size: 32rpx;
  286. color: $uni-color-primary;
  287. margin-left: 8rpx;
  288. }
  289. }
  290. .coupon{
  291. font-weight: 300;
  292. padding: 4rpx 16rpx;
  293. font-weight: 400;
  294. font-size: 24rpx;
  295. color: #FFFFFF;
  296. border-radius: 8rpx 8rpx 8rpx 8rpx;
  297. background: linear-gradient( 270deg, #EE4320 0%, #FF9C87 100%);
  298. display: flex;
  299. align-items: center;
  300. .icon{
  301. width: 30rpx;
  302. height: 30rpx;
  303. }
  304. }
  305. }
  306. .discount{
  307. display: inline-block;
  308. font-weight: 300;
  309. font-size: 22rpx;
  310. color: #AAAAAA;
  311. padding: 2rpx 12rpx;
  312. border: 1rpx solid #F0F0F0;
  313. border-radius: 4rpx 4rpx 4rpx 4rpx;
  314. margin-top: 10rpx;
  315. }
  316. }
  317. }
  318. }
  319. }
  320. </style>