shopDetail.vue 11 KB

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