shopDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <template>
  2. <view class="center">
  3. <view class="store-info flex">
  4. <view class="store-top flex">
  5. <image class="simage" :src="info.image" mode=""></image>
  6. <view class="stop-main">
  7. <view class="stop-title">{{ info.name }}</view>
  8. <view class="stop-address">
  9. <image class="mrt-image" src="../../static/index/index10.png" mode=""></image>
  10. <view class="mrt-font">距离您{{ info.jl.toFixed(2)}}KM</view>
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="store-item">
  16. <image class="store-image1" src="../../static/img/store2.png" mode=""></image>
  17. <view class="store-font">营业时间:{{ info.day_time }}</view>
  18. </view>
  19. <view class="store-item">
  20. <image class="store-image2" src="../../static/img/store3.png" mode=""></image>
  21. <view class="store-font">预约电话:{{ info.phone }}</view>
  22. </view>
  23. <view class="store-item">
  24. <image class="store-image3" src="../../static/index/index10.png" mode=""></image>
  25. <view class="store-font">门店地址:{{ info.detailed_address }}</view>
  26. </view>
  27. <view class="store-main" v-if="info.images != null">
  28. <view class="smain-title">门头照片</view>
  29. <scroll-view class="scroll-box flex" @scroll="scroll" scroll-x="true" :scroll-with-animation="true"
  30. scroll-left="10px">
  31. <view class="scroll-item" v-for="(item, index) in info.images" :key="index">
  32. <image class="scroll-image" :src="item" mode="heightFix" @click="openImg(info.images,item)"></image>
  33. </view>
  34. </scroll-view>
  35. </view>
  36. <view class="" style="padding: 20rpx 20rpx 1rpx 20rpx;background-color: #fff;margin-top: 20rpx;">
  37. <view class="shop-dhq flex" v-for="qitem in info.coupon">
  38. <view class="dhq-left flex f-d-c f-j-c fg1 f-ai-s">
  39. <view class="dhq-name">
  40. {{qitem.store_name}}
  41. </view>
  42. <view class="dhq-price flex">
  43. <view class="j-price">
  44. {{qitem.price}}
  45. </view>
  46. <view class="j-zk">
  47. {{(((qitem.price*10)/(qitem.ot_price*1)).toFixed(1))}}折
  48. </view>
  49. </view>
  50. </view>
  51. <view class="dhq-right fs0">
  52. <view class="right-btn" @click="goBuy(qitem)">
  53. 抢购
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="store-main" v-if="info.slider_image != null">
  59. <view class="smain-title">店内照片</view>
  60. <scroll-view class="scroll-box flex" @scroll="scroll" scroll-x="true" :scroll-with-animation="true"
  61. scroll-left="10px">
  62. <view class="scroll-item" v-for="(item, index) in info.slider_image" :key="index">
  63. <image class="scroll-image" :src="item" mode="heightFix" @click="openImg(info.slider_image,item)">
  64. </image>
  65. </view>
  66. </scroll-view>
  67. </view>
  68. <view class="" style="height: 100rpx;">
  69. </view>
  70. <view class="btn-box flex">
  71. <view class="btn-left" @click="tocall()">联系商家</view>
  72. <!-- #ifdef H5 -->
  73. <view class="btn-right" @click="toGaodeMap()">导航到店</view>
  74. <!-- #endif -->
  75. <!-- #ifdef MP -->
  76. <view class="btn-right" @click="dh()">导航到店</view>
  77. <!-- #endif -->
  78. <!-- #ifdef APP -->
  79. <!-- <view class="btn-right" @click="getLocation()">导航到店</view> -->
  80. <view class="btn-right" @click="toGaodeMap()">导航到店</view>
  81. <!-- #endif -->
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. // #ifdef H5
  87. import {
  88. weixindata,
  89. shareLoad
  90. } from '@/utils/wxAuthorized';
  91. // #endif
  92. import {
  93. mapState,
  94. mapMutations
  95. } from 'vuex';
  96. import {
  97. getStoreDetail
  98. } from '@/api/shop.js'
  99. import {
  100. store_details
  101. } from '@/api/index.js';
  102. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  103. export default {
  104. data() {
  105. return {
  106. id: '',
  107. info: '',
  108. address: ''
  109. };
  110. },
  111. computed: {
  112. ...mapState(['loginInterceptor', 'baseURL', 'latitude', 'longitude']),
  113. },
  114. onLoad(option) {
  115. this.id = option.id;
  116. // this.loadData();
  117. if (this.latitude) {
  118. this.getStoreDetail()
  119. } else {
  120. this.getaddress()
  121. }
  122. // this.getStoreDetail()
  123. },
  124. methods: {
  125. // 获取门店详情
  126. getStoreDetail() {
  127. let obj = this
  128. getStoreDetail({}, obj.id).then(res => {
  129. console.log(res,'e1')
  130. obj.info = res.data
  131. obj.info.jl = obj.getFlatternDistance(obj.latitude, obj.longitude, obj.info.latitude, obj
  132. .info.longitude);
  133. })
  134. },
  135. markertap(e) {
  136. let obj = this
  137. // #ifdef H5
  138. weixindata().then(wxOjb => {
  139. console.log(wxOjb, '获取微信');
  140. wxOjb.openLocation({
  141. latitude: obj.info.latitude, // 纬度,浮点数,范围为90 ~ -90
  142. longitude: obj.info.longitude, // 经度,浮点数,范围为180 ~ -180。
  143. name: obj.info.name, // 位置名
  144. address: obj.info.detailed_address, // 地址详情说明
  145. scale: 28, // 地图缩放级别,整型值,范围从1~28。默认为最大
  146. infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
  147. });
  148. });
  149. // #endif
  150. },
  151. //根据经纬度计算距离
  152. getFlatternDistance(lat1, lng1, lat2, lng2) {
  153. console.log(lat1, lng1, lat2, lng2)
  154. let radLat1 = (lat1 * Math.PI) / 180.0;
  155. let radLat2 = (lat2 * Math.PI) / 180.0;
  156. let a = radLat1 - radLat2;
  157. let b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
  158. let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math
  159. .pow(Math.sin(b / 2), 2)));
  160. s = s * 6378.137;
  161. s = Math.round(s * 10000) / 10000;
  162. return s;
  163. },
  164. scroll(e) {
  165. console.log(e, '123456');
  166. },
  167. tocall() {
  168. let num = this.info.phone;
  169. console.log(num,'num');
  170. uni.makePhoneCall({
  171. phoneNumber: num //仅为示例
  172. });
  173. },
  174. goBuy(item) {
  175. uni.navigateTo({
  176. url: '/pages/product/product?id=' + item.id
  177. })
  178. },
  179. getaddress() {
  180. console.log('dizhi+++++++++++');
  181. let obj = this;
  182. // #ifdef H5
  183. weixindata().then(wxOjb => {
  184. console.log(wxOjb, '获取微信');
  185. wxOjb.getLocation({
  186. type: 'wgs84',
  187. success: res => {
  188. console.log(res, 123456);
  189. obj.setLat(res.latitude);
  190. obj.setLon(res.longitude);
  191. obj.getStoreDetail()
  192. },
  193. fail: err => {
  194. console.log(err, 'shi+++++++++++++++');
  195. openMap().then(e => {
  196. obj.getaddress();
  197. });
  198. }
  199. });
  200. });
  201. // #endif
  202. },
  203. //
  204. openImg(list, item) {
  205. uni.previewImage({
  206. current: item,
  207. urls: list
  208. })
  209. },
  210. // 调用高德
  211. toGaodeMap() {
  212. let obj = this
  213. var urlStr = encodeURI( `https://uri.amap.com/marker?position=${obj.info.longitude},${obj.info.latitude}&name=${obj.info.name}`)
  214. plus.runtime.openURL(urlStr);
  215. },
  216. getLocation(item) {
  217. let obj = this
  218. console.log(obj.info.latitude,obj.info.longitude,'定位');
  219. uni.chooseLocation({
  220. latitude:obj.info.latitude,
  221. longitude:obj.info.longitude,
  222. success: function (res) {
  223. console.log(res,'当前地位置');
  224. console.log('位置名称:' + res.name);
  225. console.log('详细地址:' + res.address);
  226. console.log('纬度:' + res.latitude);
  227. console.log('经度:' + res.longitude);
  228. }
  229. });
  230. },
  231. // 导航
  232. dh() {
  233. let obj = this
  234. wx.openLocation({
  235. latitude: obj.info.latitude * 1,
  236. longitude: obj.info.longitude * 1,
  237. name: obj.info.name,
  238. address: obj.info.detailed_address
  239. })
  240. },
  241. }
  242. };
  243. </script>
  244. <style lang="less">
  245. .center,
  246. page {
  247. background: #f8f8f8;
  248. height: 100%;
  249. }
  250. .store-info {
  251. background: #ffffff;
  252. .store-top {
  253. padding: 40rpx 20rpx;
  254. justify-content: flex-start;
  255. .simage {
  256. width: 130rpx;
  257. height: 130rpx;
  258. background: #f44939;
  259. }
  260. .stop-main {
  261. height: 130rpx;
  262. padding: 6rpx 0;
  263. margin-left: 20rpx;
  264. display: flex;
  265. flex-direction: column;
  266. justify-content: space-between;
  267. align-items: flex-start;
  268. .stop-title {
  269. font-size: 36rpx;
  270. font-family: PingFang SC;
  271. font-weight: 500;
  272. color: #000000;
  273. }
  274. .stop-address {
  275. display: flex;
  276. justify-content: flex-end;
  277. align-items: center;
  278. .mrt-image {
  279. width: 20rpx;
  280. height: 28rpx;
  281. }
  282. .mrt-font {
  283. margin-left: 8rpx;
  284. font-size: 22rpx;
  285. font-family: PingFang SC;
  286. font-weight: 500;
  287. color: #666666;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. .store-item {
  294. background: #ffffff;
  295. display: flex;
  296. justify-content: flex-start;
  297. align-items: center;
  298. padding: 30rpx 30rpx 30rpx 44rpx;
  299. .store-image1 {
  300. width: 36rpx;
  301. height: 36rpx;
  302. }
  303. .store-image2 {
  304. margin: 0 1rpx;
  305. width: 34rpx;
  306. height: 34rpx;
  307. }
  308. .store-image3 {
  309. margin: 0 7rpx;
  310. width: 22rpx;
  311. height: 28rpx;
  312. }
  313. .store-font {
  314. margin-left: 22rpx;
  315. font-size: 26rpx;
  316. font-family: PingFang SC;
  317. font-weight: 500;
  318. color: #2d2d2d;
  319. }
  320. }
  321. .store-main {
  322. margin-top: 16rpx;
  323. background: #ffffff;
  324. padding: 30rpx 42rpx 40rpx;
  325. .smain-title {
  326. font-size: 30rpx;
  327. font-family: PingFang SC;
  328. font-weight: 500;
  329. color: #464646;
  330. }
  331. }
  332. .scroll-box {
  333. white-space: nowrap;
  334. margin-top: 30rpx;
  335. height: 240rpx;
  336. .scroll-item:first-child {
  337. margin-left: 0;
  338. }
  339. .scroll-item {
  340. margin-left: 20rpx;
  341. display: inline-block;
  342. height: 240rpx;
  343. // width: 240rpx;
  344. }
  345. .scroll-image {
  346. height: 240rpx;
  347. // width: 240rpx;
  348. }
  349. }
  350. .btn-box {
  351. position: fixed;
  352. bottom: 0rpx;
  353. left: 0;
  354. right: 0;
  355. width: 750rpx;
  356. background: rgba(255, 255, 255, 0.6);
  357. box-shadow: 0rpx 0rpx 20rpx 0px rgba(50, 50, 52, 0.06);
  358. padding: 22rpx 68rpx;
  359. .btn-left {
  360. width: 280rpx;
  361. height: 80rpx;
  362. background: linear-gradient(180deg, #ffa30b, #ffd158);
  363. box-shadow: 0px 3rpx 13rpx 3rpx rgba(255, 164, 13, 0.48);
  364. border-radius: 40rpx;
  365. text-align: center;
  366. line-height: 80rpx;
  367. font-size: 32rpx;
  368. font-family: PingFang SC;
  369. font-weight: 500;
  370. color: #ffffff;
  371. }
  372. .btn-right {
  373. width: 280rpx;
  374. height: 80rpx;
  375. background: linear-gradient(180deg, #ff6223, #ffab60);
  376. box-shadow: 0px 3rpx 13rpx 3rpx rgba(255, 164, 13, 0.48);
  377. border-radius: 40rpx;
  378. text-align: center;
  379. line-height: 80rpx;
  380. font-size: 32rpx;
  381. font-family: PingFang SC;
  382. font-weight: 500;
  383. color: #ffffff;
  384. }
  385. }
  386. .popup_row {
  387. width: 100%;
  388. height: 500rpx;
  389. background-color: #ffffff;
  390. border-radius: 20rpx;
  391. display: flex;
  392. justify-content: center;
  393. align-items: center;
  394. .rows {
  395. width: 100%;
  396. padding: 0 24rpx;
  397. .rows-item {
  398. height: 80rpx;
  399. line-height: 80rpx;
  400. text-align: center;
  401. width: 100%;
  402. font-size: 32rpx;
  403. color: #303133;
  404. // border-bottom: 1rpx solid #f0f0f0;
  405. }
  406. // .row-1 {
  407. // margin: auto;
  408. // .first_aid {
  409. // width: 300rpx;
  410. // height: 300rpx;
  411. // }
  412. // }
  413. // .row-2 {
  414. // font-size: 38rpx;
  415. // margin-top: 20rpx;
  416. // }
  417. }
  418. }
  419. .shop-dhq {
  420. width: 702rpx;
  421. height: 171rpx;
  422. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.15);
  423. margin: auto;
  424. border-radius: 20rpx;
  425. background-color: #fff;
  426. padding: 0 48rpx 0 26rpx;
  427. margin-bottom: 20rpx;
  428. .dhq-left {
  429. .dhq-name {
  430. font-size: 33rpx;
  431. font-weight: bold;
  432. color: #333333;
  433. }
  434. .dhq-price {
  435. padding-top: 20rpx;
  436. .j-price {
  437. font-size: 38rpx;
  438. font-weight: bold;
  439. color: #FF4C4C;
  440. &::before {
  441. content: '¥';
  442. font-size: 24rpx;
  443. color: #FF4C4C;
  444. }
  445. }
  446. .j-zk {
  447. display: inline-block;
  448. margin-left: 10rpx;
  449. line-height: 32rpx;
  450. height: 32rpx;
  451. border: 1px solid #FF4C4C;
  452. border-radius: 5rpx;
  453. font-size: 22rpx;
  454. font-weight: 500;
  455. color: #FF4C4C;
  456. padding: 0 8rpx;
  457. }
  458. }
  459. }
  460. .dhq-right {
  461. .right-btn {
  462. width: 105rpx;
  463. line-height: 56rpx;
  464. background: linear-gradient(143.2747deg, #FF6A00, #EE0979);
  465. border: 1rpx solid #FF4C4C;
  466. border-radius: 27rpx;
  467. text-align: center;
  468. color: #fff;
  469. font-size: 28rpx;
  470. font-weight: bold;
  471. }
  472. }
  473. }
  474. </style>