index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. if (this.list.length >= res.content.total) {
  142. this.status = 'noMore'
  143. } else {
  144. this.status = 'more'
  145. this.query.pageCurrent++
  146. }
  147. }
  148. })
  149. // getNearbyStore(this.query).then(res=>{
  150. // uni.stopPullDownRefresh()
  151. // this.status = 'noMore'
  152. // if(res.state == 'Success'){
  153. // this.list = res.content
  154. // }
  155. // })
  156. },
  157. },
  158. onPullDownRefresh() {
  159. uni.getLocation({
  160. type: 'gcj02',
  161. success: (res) => {
  162. // 解析地址
  163. this.query['location.lat'] = res.latitude
  164. this.query['location.lon'] = res.longitude
  165. // 存储经纬度
  166. uni.setStorageSync('location',JSON.stringify({latitude:res.latitude,longitude:res.longitude}))
  167. this.query.pageCurrent = 1
  168. this.status = 'more'
  169. this.list = []
  170. this.search()
  171. }
  172. })
  173. },
  174. onLoad(option) {
  175. },
  176. onReady() {
  177. // let location = JSON.parse(uni.getStorageSync('location'))
  178. // this.query['location.lat'] = location.latitude
  179. // this.query['location.lon']= location.longitude
  180. // this.search()
  181. uni.getLocation({
  182. type: 'gcj02',
  183. success: (res) => {
  184. // 解析地址
  185. this.query['location.lat'] = res.latitude
  186. this.query['location.lon'] = res.longitude
  187. console.log(this);
  188. // 存储经纬度
  189. uni.setStorageSync('location',JSON.stringify({latitude:res.latitude,longitude:res.longitude}))
  190. this.search()
  191. }
  192. })
  193. }
  194. }
  195. </script>
  196. <style lang="scss">
  197. .refuel {
  198. background: #F9F9F9;
  199. padding: 20rpx 24rpx;
  200. .banner{
  201. width: 100%;
  202. height: 132rpx;
  203. border-radius: 16rpx;
  204. }
  205. .notice-box{
  206. display: flex;
  207. align-items: center;
  208. font-weight: 300;
  209. font-size: 22rpx;
  210. color: #EE4927;
  211. margin: 20rpx 0;
  212. .icon{
  213. width: 26rpx;
  214. height: 26rpx;
  215. margin-right: 10rpx;
  216. }
  217. }
  218. .zs-list {
  219. // padding-top: 20rpx;
  220. .item {
  221. display: flex;
  222. padding: 24rpx;
  223. background: #fff;
  224. border-radius: 16rpx;
  225. margin-bottom: 20rpx;
  226. position: relative;
  227. .tag{
  228. position: absolute;
  229. top: 0%;
  230. left: 0%;
  231. width: 150rpx;
  232. height: 53rpx;
  233. }
  234. .info{
  235. flex: 1;
  236. padding: 26rpx 0 0;
  237. .title-box{
  238. display: flex;
  239. align-items: center;
  240. justify-content: space-between;
  241. .title{
  242. font-size: 28rpx;
  243. font-weight: bold;
  244. width: 500rpx;
  245. white-space: nowrap;
  246. overflow: hidden;
  247. text-overflow: ellipsis;
  248. margin-top: 10rpx;
  249. }
  250. .diatance-box{
  251. display: flex;
  252. align-items: center;
  253. font-weight: 400;
  254. font-size: 24rpx;
  255. color: #222222;
  256. .icon{
  257. width: 20rpx;
  258. height: 20rpx;
  259. margin-right: 8rpx;
  260. }
  261. }
  262. }
  263. .address{
  264. font-weight: 300;
  265. font-size: 24rpx;
  266. color: #AAAAAA;
  267. margin-top: 12rpx;
  268. }
  269. .activity{
  270. display: flex;
  271. align-items: center;
  272. justify-content: space-between;
  273. margin-top: 10rpx;
  274. .price-box{
  275. display: flex;
  276. align-items: center;
  277. .label{
  278. font-weight: 300;
  279. font-size: 20rpx;
  280. color: #FF4D3A;
  281. }
  282. .price{
  283. font-weight: 600;
  284. font-size: 32rpx;
  285. color: $uni-color-primary;
  286. margin-left: 8rpx;
  287. }
  288. }
  289. .coupon{
  290. font-weight: 300;
  291. padding: 4rpx 16rpx;
  292. font-weight: 400;
  293. font-size: 24rpx;
  294. color: #FFFFFF;
  295. border-radius: 8rpx 8rpx 8rpx 8rpx;
  296. background: linear-gradient( 270deg, #EE4320 0%, #FF9C87 100%);
  297. display: flex;
  298. align-items: center;
  299. .icon{
  300. width: 30rpx;
  301. height: 30rpx;
  302. }
  303. }
  304. }
  305. .discount{
  306. display: inline-block;
  307. font-weight: 300;
  308. font-size: 22rpx;
  309. color: #AAAAAA;
  310. padding: 2rpx 12rpx;
  311. border: 1rpx solid #F0F0F0;
  312. border-radius: 4rpx 4rpx 4rpx 4rpx;
  313. margin-top: 10rpx;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. </style>