refuel.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <template>
  2. <view class="discountsDetail">
  3. <!-- 地图 -->
  4. <map id="map" class="map" style="width: 100%;" :longitude="longitude" :latitude="latitude" :scale='scale'
  5. enable-poi show-location :markers="markers"
  6. @regionchange="mapChange" @callouttap="handleCallout">
  7. <image class="position" src="../../static/map-position.png" mode="" @click="myPosition"></image>
  8. <cover-view slot="callout">
  9. <cover-view v-for="(item,index) in markers" :key="item.id" class="callout" :marker-id="item.id" @click="test">
  10. <cover-image class="icon" src="@/static/jiayou.png"></cover-image>
  11. <cover-view class="title">
  12. 7.65/L
  13. </cover-view>
  14. <cover-view class="triangle"></cover-view>
  15. </cover-view>
  16. </cover-view>
  17. </map>
  18. <!-- titleArr: 选择项数组 dropArr: 下拉项数组 二维数组 @finishDropClick: 下拉筛选完成事件-->
  19. <cc-dropDownMenu :titleArr="titleArr" :dropArr="dropArr" @finishDropClick="finishClick"></cc-dropDownMenu>
  20. <!-- 内容 -->
  21. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  22. <view class="item" v-for="(item,index) in list" :key="index">
  23. <!-- <image :src="item.src" mode="" class="icon" @click="goDetail(item)"></image> -->
  24. <zs-img :src="item.logoPath" width="164rpx" height="164rpx" radius="full" @click.native="goDetail(item)"></zs-img>
  25. <view class="info">
  26. <view class="title">
  27. {{item.shopVo.shopName}}
  28. </view>
  29. <view class="activity" :class="!item.activityContent?'white':''">
  30. <image class="card" src="../../static/card-icon.png" mode=""></image>
  31. {{item.activityContent || '-'}}
  32. </view>
  33. <view class="address" >
  34. <image class="position" src="../../static/address-icon.png" mode=""></image>
  35. 距离你{{(item.shopVo.distance/1000).toFixed(2)}}km ·{{item.district}}
  36. </view>
  37. </view>
  38. </view>
  39. </zs-list>
  40. </view>
  41. </template>
  42. <script>
  43. import { search } from '@/api/shop.js';
  44. export default {
  45. options: {
  46. styleIsolation: 'shared'
  47. },
  48. data() {
  49. return {
  50. map: null,
  51. longitude: 0,
  52. latitude: 0,
  53. scale:18,
  54. markers: [],
  55. destination: '',
  56. active: 0,
  57. status: 'more',
  58. list: [],
  59. btnText: '去加油',
  60. list: [],
  61. titleArr: ['全城', '距离最近'],
  62. dropArr: [
  63. // 距离
  64. [{
  65. text: '全城',
  66. value: ""
  67. },
  68. {
  69. text: '观山湖区',
  70. value: "440103"
  71. }
  72. ],
  73. // 类型
  74. [{
  75. text: '距离最远',
  76. value: "0-40"
  77. },
  78. {
  79. text: '距离最近',
  80. value: "40-60"
  81. }
  82. ],
  83. ],
  84. filterResultData: [],
  85. query:{
  86. menuId:'',
  87. queryName:'',
  88. 'location.lat':0,
  89. 'location.lon':0,
  90. pageCurrent:1,
  91. pageSize:10
  92. }
  93. }
  94. },
  95. methods: {
  96. // 点击地图气泡
  97. handleCallout(val){
  98. console.log(val);
  99. },
  100. // 地图中打开商家
  101. handleAdress(item) {
  102. this.map.openMapApp({
  103. longitude: Number(item.longitude) ,
  104. latitude: Number(item.latitude),
  105. destination: item.shopVo.shopName,
  106. complete(r) {
  107. console.log(r);
  108. }
  109. })
  110. },
  111. // 获取初始位置
  112. initPosition() {
  113. let that = this
  114. uni.getLocation({
  115. type: 'gcj02',
  116. success(res) {
  117. that.longitude = res.longitude
  118. that.latitude = res.latitude
  119. }
  120. })
  121. },
  122. // 回到我的位置
  123. myPosition() {
  124. let that = this
  125. console.log(that.map);
  126. uni.getLocation({
  127. type: 'gcj02',
  128. success(res) {
  129. that.map.moveToLocation({
  130. longitude: res.longitude,
  131. latitude: res.latitude
  132. })
  133. console.log(res);
  134. // that.markers =[
  135. // { id:1,
  136. // latitude: res.latitude,
  137. // longitude: res.longitude,
  138. // width: '42rpx',
  139. // height: '42rpx',
  140. // iconPath: '/static/jiayou.png',
  141. // callout:{
  142. // content:'#92 7.5元/L',
  143. // bgColor:'#fff',
  144. // color:'#222',
  145. // borderRadius:'50%',
  146. // fontSize: '22rpx',
  147. // padding:'16rpx',
  148. // display:'ALWAYS'
  149. // },
  150. // },
  151. // ]
  152. }
  153. })
  154. },
  155. // 地图拖动
  156. mapChange(val) {
  157. },
  158. finishClick(resultData) {
  159. this.filterResultData = resultData;
  160. // uni.showModal({
  161. // title: '温馨提示',
  162. // content: '筛选数据 = ' + JSON.stringify(resultData)
  163. // })
  164. },
  165. goDetail(item) {
  166. uni.setStorageSync('shopInfo', JSON.stringify(item))
  167. uni.navigateTo({
  168. url: '../shopDetail/shopDetail?type=' + this.active
  169. })
  170. },
  171. loadMore() {
  172. this.search()
  173. },
  174. search() {
  175. return new Promise((resolve,reject)=>{
  176. if(this.status == 'noMore') return
  177. this.status = 'loading'
  178. search(this.query).then(res=>{
  179. if(res.state == 'Success'){
  180. this.list = this.list.concat(res.content.records)
  181. res.content.records.map((item,index)=>{
  182. this.markers.push(
  183. {
  184. id: index+1,
  185. latitude: item.shopVo.location.lat,
  186. longitude: item.shopVo.location.lon,
  187. zIndex: '1',
  188. iconPath: '/static/triangle.png',
  189. width: '18rpx',
  190. height: '16rpx',
  191. customCallout: {
  192. anchorY: 0,
  193. anchorX: 0,
  194. display: 'ALWAYS'
  195. },
  196. label:{
  197. content:item.shopVo.shopName,
  198. fontSize:'10',
  199. textAlign:'center'
  200. },
  201. joinCluster:true
  202. }
  203. )
  204. })
  205. if(this.list.length >= res.content.total){
  206. this.status = 'noMore'
  207. }else{
  208. this.status = 'more'
  209. this.query.pageCurrent++
  210. }
  211. resolve()
  212. }
  213. })
  214. })
  215. },
  216. },
  217. onLoad(option) {
  218. this.initPosition()
  219. this.query.menuId = option.id
  220. },
  221. onReady() {
  222. this.map = uni.createMapContext("map", this);
  223. let location = JSON.parse(uni.getStorageSync('location'))
  224. this.query['location.lat'] = location.latitude
  225. this.query['location.lon'] = location.longitude
  226. this.search()
  227. }
  228. }
  229. </script>
  230. <style lang="scss">
  231. .callout{
  232. width: 150rpx;
  233. height: 54rpx;
  234. background: #61B5FD;
  235. // box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0,0,0,0.2);
  236. border-radius: 60rpx 60rpx 60rpx 60rpx;
  237. display: flex;
  238. align-items: center;
  239. position: relative;
  240. .icon{
  241. width: 42rpx;
  242. height: 42rpx;
  243. margin-left: 6rpx;
  244. }
  245. .title{
  246. flex: 1;
  247. color: #FFFFFF;
  248. font-weight: bold;
  249. font-size: 20rpx;
  250. text-align: center;
  251. }
  252. .triangle{
  253. width: 0;
  254. height: 0;
  255. border-top: 16rpx solid red;
  256. border-bottm: 16rpx solid transparent;
  257. border-left: 16rpx solid transparent;
  258. border-right: 16rpx solid transparent;
  259. position: absolute;
  260. bottom: -16rpx;
  261. z-index: 9999999;
  262. left: 50%;
  263. // transform: translate(-50%,100%);
  264. }
  265. }
  266. .bar-item-text {
  267. max-width: 250rpx !important;
  268. }
  269. .screen-bar::after {
  270. display: none;
  271. }
  272. .discountsDetail cc-drop-down-menu .screen-bar {
  273. // position: fixed;
  274. top: 0%;
  275. left: 0;
  276. width: 100%;
  277. }
  278. .discountsDetail {
  279. .banner {
  280. width: 100%;
  281. height: 310rpx;
  282. position: relative;
  283. z-index: 99;
  284. }
  285. .recommend {
  286. display: flex;
  287. justify-content: space-between;
  288. margin: 20rpx 30rpx;
  289. .recommend-item.color {
  290. background: linear-gradient(0deg, #FFDA84 0%, #FFF6E1 100%);
  291. }
  292. .recommend-item {
  293. padding: 18rpx;
  294. border-radius: 16rpx;
  295. width: 335rpx;
  296. box-sizing: border-box;
  297. background: linear-gradient(0deg, #FF9898 0%, rgba(255, 101, 101, 0.09) 100%);
  298. ;
  299. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  300. .top {
  301. display: flex;
  302. align-items: center;
  303. justify-content: space-between;
  304. .title {
  305. color: #0F0F0F;
  306. font-size: 26rpx;
  307. }
  308. .type-box {
  309. display: flex;
  310. align-items: center;
  311. padding: 0 16rpx;
  312. height: 40rpx;
  313. line-height: 40rpx;
  314. border-radius: 20rpx;
  315. border: 1rpx solid #FF4343;
  316. .hot {
  317. width: 16.7rpx;
  318. height: 21.7rpx;
  319. }
  320. .type {
  321. font-size: 20rpx;
  322. font-weight: 400;
  323. color: #FF4343;
  324. margin-left: 6rpx;
  325. }
  326. }
  327. }
  328. .image-box {
  329. position: relative;
  330. margin-top: 20rpx;
  331. background: #fff;
  332. border-radius: 16rpx;
  333. display: flex;
  334. .icon {
  335. width: 116rpx;
  336. height: 116rpx;
  337. margin-left: 15rpx;
  338. }
  339. .info {
  340. padding: 16rpx;
  341. display: flex;
  342. flex-direction: column;
  343. justify-content: space-between;
  344. .title {
  345. font-size: 20rpx;
  346. font-weight: bold;
  347. }
  348. .btn-box {
  349. display: flex;
  350. align-items: center;
  351. width: 100%;
  352. font-size: 18rpx;
  353. height: 36rpx;
  354. line-height: 36rpx;
  355. margin-top: 10rpx;
  356. .btn {
  357. height: 36rpx;
  358. line-height: 36rpx;
  359. padding: 0 14rpx;
  360. background: #FE5B47;
  361. color: #FFFFFF;
  362. }
  363. .desc {
  364. height: 36rpx;
  365. line-height: 36rpx;
  366. font-weight: 400;
  367. color: #FF4343;
  368. padding: 0 18rpx 0 10rpx;
  369. background: rgba(254, 91, 71, .17);
  370. border-radius: 0 8rpx 8rpx 0;
  371. }
  372. }
  373. }
  374. }
  375. }
  376. }
  377. .zs-list {
  378. // padding-top: 20rpx;
  379. .item {
  380. display: flex;
  381. padding: 20rpx 30rpx;
  382. background: #fff;
  383. border-radius: 16rpx;
  384. margin: 20rpx 30rpx 0;
  385. border-bottom: 1rpx solid #F0F0F0;
  386. .icon {
  387. width: 200rpx;
  388. height: 180rpx;
  389. border-radius: 8px;
  390. }
  391. .info{
  392. flex: 1;
  393. padding-left: 20rpx;
  394. display: flex;
  395. flex-direction: column;
  396. justify-content: space-between;
  397. position: relative;
  398. .title{
  399. font-size: 28rpx;
  400. font-weight: bold;
  401. width: 340rpx;
  402. white-space: nowrap;
  403. overflow: hidden;
  404. text-overflow: ellipsis;
  405. margin-top: 10rpx;
  406. }
  407. .address{
  408. color: #bebebe;
  409. display: flex;
  410. align-items: center;
  411. font-size: 24rpx;
  412. .u-icon{
  413. align-self: flex-start;
  414. }
  415. .position {
  416. width: 30rpx;
  417. height: 30rpx;
  418. margin-right: 8rpx;
  419. }
  420. }
  421. .activity.white{
  422. color: #fff;
  423. background: #fff;
  424. .card{
  425. display: none;
  426. }
  427. }
  428. .activity{
  429. font-size: 24rpx;
  430. color: $uni-color-primary;
  431. line-height: 42rpx;
  432. display: flex;
  433. align-items: center;
  434. background: linear-gradient(90deg, #FAF4EB 0%, rgba(255,235,207,0) 100%);
  435. .card{
  436. width: 30.4rpx;
  437. height: 30rpx;
  438. vertical-align: bottom;
  439. margin: 0 8rpx 0 14rpx;
  440. }
  441. // text-align: center;
  442. // background: linear-gradient(90deg, rgba(253,149,108,0) 0%, #FD8B64 50%, rgba(253,140,101,0) 100%);
  443. }
  444. }
  445. }
  446. }
  447. .map {
  448. height: 480rpx;
  449. position: relative;
  450. .position {
  451. position: absolute;
  452. bottom: 20rpx;
  453. right: 20rpx;
  454. width: 60rpx;
  455. height: 60rpx;
  456. }
  457. }
  458. }
  459. </style>