index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <view class="content">
  3. <view class="pofMap">
  4. <view :hidden="!isHide">
  5. <map class="map" scale="16" :latitude="Number(lat)" :longitude="Number(lng)" :markers="list"
  6. @markertap="bindMarker"></map>
  7. </view>
  8. <view class="put-away flex-center" @click="bindPut">
  9. {{!isHide?'打开地图':'收起地图'}}
  10. <image src="../static/images/down.png" class="putImg" :class="!isHide?'putImgAct':''"></image>
  11. </view>
  12. </view>
  13. <!-- <view class="hg572"></view> -->
  14. <scroll-view scroll-y="true" class="scrollview" :class="!isHide?'scrollview1':''" :scroll-top="scrollTop">
  15. <view class="" style="height: 20rpx;">
  16. </view>
  17. <no-none v-if="list.length<=0"></no-none>
  18. <block v-else>
  19. <view class="item" :class="index==act_index?'act':''" v-for="(item,index) of list" :key='index'
  20. @click="bindStore(index,item.id)">
  21. <view class="box-pack-between">
  22. <view class="flex-grow-1">
  23. <view class="title">
  24. {{item.title}}
  25. </view>
  26. <view class="address flex-y-center">
  27. <text class="iconfont icon-dizhi"></text>{{item.address}}
  28. </view>
  29. </view>
  30. <view class="flex-grow-0">
  31. <image class="item-logo" :src=" item.thumb? URL+item.thumb:'../../static/avatar_def.png'">
  32. </image>
  33. </view>
  34. </view>
  35. <view class="distance box-pack-between">
  36. <text>距你{{item.juli}}公里</text>
  37. <view class="Navigation" @click.stop="getNavigation(item)">
  38. <text class="iconfont icon-icon-test"></text>
  39. 导航到店
  40. </view>
  41. </view>
  42. </view>
  43. </block>
  44. </scroll-view>
  45. <block v-if="is_auth">
  46. <view class="model"></view>
  47. <view class="model flex-center">
  48. <view class="model_cotent">
  49. <view class="model_cotent_title">地理位置未授权</view>
  50. <view class="model_cotent_qd">需要您授权打开手机中的定位授权</view>
  51. <view class="flex">
  52. <view class="flex-grow-1 flex-center model_cotent_right" @click="cancel">
  53. 取消
  54. </view>
  55. <button class="model_cotent_shezhi flex-grow-1" @click="openSetting">去授权</button>
  56. </view>
  57. </view>
  58. </view>
  59. </block>
  60. <view class="hg130">
  61. </view>
  62. <view class="store-btn flex-center" @click="getStore">
  63. <view class="flex-center">
  64. 进入门店
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. mapState,
  72. mapGetters,
  73. mapMutations
  74. } from 'vuex'
  75. export default {
  76. data() {
  77. return {
  78. Putname: '',
  79. markers: [],
  80. lat: '',
  81. lng: '',
  82. setColor: "",
  83. URL: getApp().globalData.URL,
  84. is_auth: false,
  85. systemInfo: {},
  86. isHide: true,
  87. scrollTop: 0,
  88. list: [],
  89. act_index: null,
  90. }
  91. },
  92. onLoad() {
  93. // #ifdef H5
  94. this.is_auth = false;
  95. let latitude=31.11325;
  96. let longitude=121.38206
  97. this.shop(latitude, longitude);
  98. // #endif
  99. // #ifdef MP-WEIXIN
  100. this.getLocation();
  101. // #endif
  102. this.systemInfo = uni.getStorageSync('systemInfo');
  103. uni.setNavigationBarColor({
  104. frontColor: '#ffffff',
  105. backgroundColor: this.$store.state.color,
  106. })
  107. },
  108. onShareAppMessage(e) {
  109. return {}
  110. },
  111. methods: {
  112. getStore(e) {
  113. let store_id = this.list[this.act_index].store_id;
  114. this.$store.commit('SET_STORE_ID', store_id)
  115. this.$store.commit('SET_TEEN_INDEX', 1) //重置默认
  116. this.$store.commit('SET_TABLE_ID', "")
  117. this.$store.commit('SET_CATE_ID', '')
  118. this.$store.dispatch('getSystemStup', store_id);
  119. this.$store.dispatch('getOpenid', store_id);
  120. uni.navigateTo({
  121. url: "../../pages/index/index"
  122. })
  123. },
  124. getNavigation({
  125. latitude,
  126. longitude,
  127. title,
  128. address,
  129. }) {
  130. uni.openLocation({
  131. latitude: Number(latitude),
  132. longitude: Number(longitude),
  133. address: address,
  134. name: title,
  135. success: function() {
  136. console.log('success');
  137. }
  138. });
  139. },
  140. bindStore(index, id) {
  141. this.act_index = index;
  142. this.list.forEach((i) => {
  143. i.width = 40
  144. i.height = 50
  145. });
  146. let obj = this.list.find((v, i) => v.id === id);
  147. console.log(obj);
  148. this.lat = obj.latitude;
  149. this.lng = obj.longitude;
  150. this.list[index].width = 50;
  151. this.list[index].height = 60;
  152. },
  153. bindMarker(e) {
  154. let act_index = this.list.findIndex(item => item.id === e.detail.markerId);
  155. this.scrollTop = act_index * 100;
  156. this.act_index = act_index;
  157. },
  158. bindPut(e) {
  159. this.isHide = !this.isHide;
  160. },
  161. getLocation(e) {
  162. // let markers = [];
  163. uni.getLocation({
  164. type: 'gcj02',
  165. success: (res) => {
  166. console.log('getLocation', res);
  167. // this.lat = res.latitude;
  168. // this.lng = res.longitude;
  169. this.is_auth = false;
  170. // markers.push({
  171. // id: 1,
  172. // latitude: res.latitude,
  173. // longitude: res.longitude,
  174. // title: "res.data.title",
  175. // iconPath: "../static/images/storeIcon.png",
  176. // width: 40,
  177. // height: 50,
  178. // });
  179. // this.markers = markers;
  180. this.shop(res.latitude, res.longitude);
  181. },
  182. fail: (err) => {
  183. console.log(err, "err")
  184. if (err.errMsg === "getLocation:fail auth deny" ||
  185. err.errMsg === "getLocation:fail auth deny" || err.errMsg ===
  186. "getLocation:fail authorize no response") {
  187. this.is_auth = true
  188. }
  189. }
  190. });
  191. },
  192. shop(lat, lng) {
  193. this.$http.request('xcx/Accessory_store', {
  194. store_id: this.$store.state.store_id,
  195. lat: lat,
  196. lng: lng,
  197. }, "", "", false).then(res => {
  198. if (res.code == '200' && res.data.length > 0) {
  199. this.lat = res.data[0].lat;
  200. this.lng = res.data[0].lng;
  201. for (let i of res.data) {
  202. this.list.push({
  203. id: i.id,
  204. latitude: i.lat,
  205. longitude: i.lng,
  206. title: i.title,
  207. iconPath: "/shop/static/images/storeIcon.png",
  208. width: 40,
  209. height: 50,
  210. store_id: i.id,
  211. address: i.address,
  212. thumb: i.thumb,
  213. juli: i.juli,
  214. // label:{
  215. // borderRadius:20,
  216. // bgColor:"#fff",textAlign:'center',
  217. // padding:6,
  218. // content: i.title,color:'#000'
  219. // }
  220. })
  221. }
  222. } else {
  223. this.isHide = false
  224. }
  225. }).catch(err => {})
  226. },
  227. cancel() {
  228. uni.navigateBack({
  229. delta: 1
  230. })
  231. },
  232. openSetting(e) {
  233. uni.openSetting({
  234. success: (settingdata) => {
  235. console.log("settingdata", settingdata)
  236. if (settingdata.authSetting['scope.userLocation']) {
  237. this.getLocation();
  238. } else {
  239. uni.showModal({
  240. title: '提示',
  241. content: '获取权限失败,将无法进定位哦~',
  242. showCancel: false,
  243. })
  244. }
  245. },
  246. fail(failData) {
  247. console.log("failData", failData);
  248. },
  249. complete(finishData) {
  250. console.log("finishData", finishData);
  251. }
  252. })
  253. },
  254. }
  255. }
  256. </script>
  257. <style>
  258. page {
  259. width: 100%;
  260. background-color: #F1F1F1;
  261. }
  262. .pofMap {}
  263. .scrollview {
  264. height: calc(100vh - 705rpx);
  265. }
  266. page .scrollview1 {
  267. height: calc(100vh - 205rpx);
  268. }
  269. .hg130 {
  270. height: 130rpx;
  271. }
  272. .hg572 {
  273. height: 590rpx;
  274. }
  275. .putImgAct {
  276. transform: rotate(180deg);
  277. }
  278. .map {
  279. height: 500rpx;
  280. width: 100%;
  281. }
  282. .put-away {
  283. width: 100%;
  284. height: 72rpx;
  285. background: #ffffff;
  286. font-size: 24rpx;
  287. font-family: PingFang SC, PingFang SC-Regular;
  288. font-weight: 400;
  289. text-align: center;
  290. color: #666666;
  291. }
  292. .putImg {
  293. width: 20rpx;
  294. height: 10rpx;
  295. margin-left: 4rpx;
  296. }
  297. .item {
  298. width: 700rpx;
  299. padding: 30rpx 24rpx;
  300. background: #ffffff;
  301. border-radius: 12rpx;
  302. box-shadow: 0px 8rpx 20rpx 0px rgba(0, 0, 0, 0.24);
  303. margin: 0 auto;
  304. margin-bottom: 30rpx;
  305. }
  306. .item.act {
  307. box-shadow: 0px 8rpx 20rpx 0px rgba(252, 140, 4, 0.24);
  308. border: 3rpx solid #fc8c04;
  309. }
  310. .item .title {
  311. font-size: 32rpx;
  312. font-family: PingFang SC, PingFang SC-Medium;
  313. font-weight: 500;
  314. text-align: left;
  315. color: #333333;
  316. }
  317. .item .address {
  318. font-size: 24rpx;
  319. font-family: PingFang SC, PingFang SC-Medium;
  320. font-weight: 500;
  321. text-align: left;
  322. color: #999999;
  323. padding: 16rpx 0;
  324. }
  325. .item .distance {
  326. font-size: 24rpx;
  327. font-family: PingFang SC, PingFang SC-Regular;
  328. font-weight: 400;
  329. color: #fc8e09;
  330. }
  331. .item-logo {
  332. width: 94rpx;
  333. height: 94rpx;
  334. }
  335. .item .Navigation {
  336. font-size: 24rpx;
  337. font-family: PingFang SC, PingFang SC-Medium;
  338. font-weight: 500;
  339. color: #fc8c04;
  340. }
  341. .item .icon-icon-test {
  342. font-size: 22rpx;
  343. margin-right: 10rpx;
  344. }
  345. .store-btn {
  346. position: fixed;
  347. bottom: 0;
  348. width: 100%;
  349. height: 130rpx;
  350. background: #ffffff;
  351. box-shadow: 0px -10rpx 20rpx 0px rgba(195, 202, 213, 0.16);
  352. }
  353. .store-btn view {
  354. width: 700rpx;
  355. height: 98rpx;
  356. margin: 0 auto;
  357. background: #fc8c04;
  358. border-radius: 49rpx;
  359. box-shadow: 0px 0px 8rpx 0px rgba(51, 135, 255, 0.20);
  360. font-size: 32rpx;
  361. font-family: PingFang SC, PingFang SC-Medium;
  362. font-weight: 500;
  363. text-align: left;
  364. color: #ffffff;
  365. }
  366. .model {
  367. position: fixed;
  368. top: 0;
  369. width: 100%;
  370. height: 100%;
  371. background: rgba(0, 0, 0, 0.5);
  372. }
  373. .model_cotent {
  374. width: 600rpx;
  375. text-align: center;
  376. border-radius: 16rpx;
  377. background: #fff;
  378. overflow: hidden;
  379. }
  380. .model_cotent_title {
  381. font-size: 34rpx;
  382. font-weight: 700;
  383. margin: 40rpx 0 40rpx 0;
  384. }
  385. .model_cotent_qd {
  386. font-size: 30rpx;
  387. padding-bottom: 65rpx;
  388. border-bottom: 1rpx solid #f1f1f1;
  389. }
  390. .model_cotent_shezhi {
  391. margin: 0;
  392. font-weight: 700;
  393. font-size: 30rpx;
  394. color: #4e6ef2;
  395. padding: 30rpx 0;
  396. background-color: #fff;
  397. border-radius: none;
  398. border: none;
  399. }
  400. .model_cotent_right {
  401. border-right: 1rpx solid #F1F1F1;
  402. }
  403. .icon-dizhi {
  404. font-size: 24rpx;
  405. }
  406. </style>