shopDetail.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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" v-if="info.jl">
  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.slider_image != 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.slider_image" :key="index">
  32. <image class="scroll-image" :src="item" mode="heightFix"></image>
  33. </view>
  34. </scroll-view>
  35. </view>
  36. <view class="shop-dhq">
  37. <view class="dhq-left">
  38. </view>
  39. <view class="dhq-right">
  40. <view class="right-btn">
  41. 抢购
  42. </view>
  43. <view class="right-btn">
  44. 抢购
  45. </view>
  46. </view>
  47. </view>
  48. <view class="store-main" v-if="info.images != null">
  49. <view class="smain-title">店内图片</view>
  50. <scroll-view class="scroll-box flex" @scroll="scroll" scroll-x="true" :scroll-with-animation="true"
  51. scroll-left="10px">
  52. <view class="scroll-item" v-for="(item, index) in info.images" :key="index">
  53. <image class="scroll-image" :src="item" mode="heightFix"></image>
  54. </view>
  55. </scroll-view>
  56. </view>
  57. <view class="btn-box flex">
  58. <view class="btn-left" @click="tocall()">联系商家</view>
  59. <view class="btn-right" @click="markertap()">导航到店</view>
  60. </view>
  61. <uni-popup ref="popup" type="bottom" @click="close">
  62. <view class="popup_row">
  63. <view class="rows">
  64. <view class="rows-item" @click="toGaodeMap">高德地图</view>
  65. <view class="rows-item" @click="tobaiDuMap">百度地图</view>
  66. <!-- <view class="rows-item" @click="totengxunMap">腾讯地图</view> -->
  67. </view>
  68. </view>
  69. </uni-popup>
  70. </view>
  71. </template>
  72. <script>
  73. import {
  74. store_details
  75. } from '@/api/index.js';
  76. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  77. export default {
  78. data() {
  79. return {
  80. id: '',
  81. info: '',
  82. longitude: '',
  83. latitude: '',
  84. latitude1: '',
  85. longitude1: '',
  86. address: ''
  87. };
  88. },
  89. onLoad(option) {
  90. // this.id = option.id;
  91. // this.loadData();
  92. },
  93. methods: {
  94. markertap(e) {
  95. this.$refs.popup.open();
  96. },
  97. loadData() {
  98. const obj = this;
  99. // store_details({}, this.id).then(({ data }) => {
  100. // console.log(data);
  101. // this.info = data;
  102. // });
  103. uni.getLocation({
  104. type: 'gcj02',
  105. success: res => {
  106. console.log('dizhi+++++++++++');
  107. this.longitude = res.longitude; //经度
  108. this.latitude = res.latitude; //纬度
  109. store_details({}, this.id).then(({
  110. data
  111. }) => {
  112. obj.longitude1 = data.longitude;
  113. obj.latitude1 = data.latitude;
  114. obj.address = data.detailed_address;
  115. data.jl = this.getFlatternDistance(this.latitude, this.longitude, data
  116. .latitude, data.longitude);
  117. this.info = data;
  118. });
  119. },
  120. fail: err => {
  121. console.log(err);
  122. openMap().then(e => {
  123. this.getaddress();
  124. });
  125. }
  126. });
  127. },
  128. //根据经纬度计算距离
  129. getFlatternDistance(lat1, lng1, lat2, lng2) {
  130. let radLat1 = (lat1 * Math.PI) / 180.0;
  131. let radLat2 = (lat2 * Math.PI) / 180.0;
  132. let a = radLat1 - radLat2;
  133. let b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
  134. let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math
  135. .pow(Math.sin(b / 2), 2)));
  136. s = s * 6378.137;
  137. s = Math.round(s * 10000) / 10000;
  138. return s;
  139. },
  140. scroll(e) {
  141. console.log(e, '123456');
  142. },
  143. tocall() {
  144. let num = this.info.phone;
  145. console.log(num);
  146. uni.makePhoneCall({
  147. phoneNumber: num //仅为示例
  148. });
  149. },
  150. // 调用高德
  151. toGaodeMap() {
  152. let latitude = this.latitude1;
  153. let longitude = this.longitude1;
  154. let address = this.address;
  155. console.log('选择高德', latitude, longitude, address);
  156. window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
  157. },
  158. // 调用腾讯
  159. totengxunMap() {
  160. let latitude = this.latitude1;
  161. let longitude = this.longitude1;
  162. let address = this.address;
  163. console.log('选择腾讯', latitude, longitude);
  164. window.location.href =
  165. `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
  166. },
  167. // 调用百度
  168. tobaiDuMap() {
  169. let latitude = this.latitude1;
  170. let longitude = this.longitude1;
  171. let latitude6 = this.latitude;
  172. let longitude6 = this.longitude;
  173. let address = this.address;
  174. console.log('选择百度', latitude, longitude);
  175. console.log('获取当前经纬度', latitude6, longitude6);
  176. window.location.href =
  177. `http://api.map.baidu.com/direction?origin=latlng:${latitude6},${longitude6}|name:我的位置&destination=${latitude},${longitude}&mode=driving&region=${address}&output=html&src=webapp.baidu.openAPIdemo`;
  178. }
  179. }
  180. };
  181. </script>
  182. <style lang="less">
  183. .center,
  184. page {
  185. background: #f8f8f8;
  186. height: 100%;
  187. }
  188. .store-info {
  189. background: #ffffff;
  190. .store-top {
  191. padding: 40rpx 20rpx;
  192. justify-content: flex-start;
  193. .simage {
  194. width: 130rpx;
  195. height: 130rpx;
  196. background: #f44939;
  197. }
  198. .stop-main {
  199. height: 130rpx;
  200. padding: 6rpx 0;
  201. margin-left: 20rpx;
  202. display: flex;
  203. flex-direction: column;
  204. justify-content: space-between;
  205. align-items: flex-start;
  206. .stop-title {
  207. font-size: 36rpx;
  208. font-family: PingFang SC;
  209. font-weight: 500;
  210. color: #000000;
  211. }
  212. .stop-address {
  213. display: flex;
  214. justify-content: flex-end;
  215. align-items: center;
  216. .mrt-image {
  217. width: 20rpx;
  218. height: 28rpx;
  219. }
  220. .mrt-font {
  221. margin-left: 8rpx;
  222. font-size: 22rpx;
  223. font-family: PingFang SC;
  224. font-weight: 500;
  225. color: #666666;
  226. }
  227. }
  228. }
  229. }
  230. }
  231. .store-item {
  232. background: #ffffff;
  233. display: flex;
  234. justify-content: flex-start;
  235. align-items: center;
  236. padding: 30rpx 30rpx 30rpx 44rpx;
  237. .store-image1 {
  238. width: 36rpx;
  239. height: 36rpx;
  240. }
  241. .store-image2 {
  242. margin: 0 1rpx;
  243. width: 34rpx;
  244. height: 34rpx;
  245. }
  246. .store-image3 {
  247. margin: 0 7rpx;
  248. width: 22rpx;
  249. height: 28rpx;
  250. }
  251. .store-font {
  252. margin-left: 22rpx;
  253. font-size: 26rpx;
  254. font-family: PingFang SC;
  255. font-weight: 500;
  256. color: #2d2d2d;
  257. }
  258. }
  259. .store-main {
  260. margin-top: 16rpx;
  261. background: #ffffff;
  262. padding: 30rpx 42rpx 40rpx;
  263. .smain-title {
  264. font-size: 30rpx;
  265. font-family: PingFang SC;
  266. font-weight: 500;
  267. color: #464646;
  268. }
  269. }
  270. .scroll-box {
  271. white-space: nowrap;
  272. margin-top: 30rpx;
  273. height: 240rpx;
  274. .scroll-item:first-child {
  275. margin-left: 0;
  276. }
  277. .scroll-item {
  278. margin-left: 20rpx;
  279. display: inline-block;
  280. height: 240rpx;
  281. width: 240rpx;
  282. }
  283. .scroll-image {
  284. height: 240rpx;
  285. width: 240rpx;
  286. }
  287. }
  288. .btn-box {
  289. position: fixed;
  290. bottom: 0rpx;
  291. left: 0;
  292. right: 0;
  293. width: 750rpx;
  294. background: rgba(255, 255, 255, 0.6);
  295. box-shadow: 0rpx 0rpx 20rpx 0px rgba(50, 50, 52, 0.06);
  296. padding: 22rpx 68rpx;
  297. .btn-left {
  298. width: 280rpx;
  299. height: 80rpx;
  300. background: linear-gradient(180deg, #ffa30b, #ffd158);
  301. box-shadow: 0px 3rpx 13rpx 3rpx rgba(255, 164, 13, 0.48);
  302. border-radius: 40rpx;
  303. text-align: center;
  304. line-height: 80rpx;
  305. font-size: 32rpx;
  306. font-family: PingFang SC;
  307. font-weight: 500;
  308. color: #ffffff;
  309. }
  310. .btn-right {
  311. width: 280rpx;
  312. height: 80rpx;
  313. background: linear-gradient(180deg, #ff6223, #ffab60);
  314. box-shadow: 0px 3rpx 13rpx 3rpx rgba(255, 164, 13, 0.48);
  315. border-radius: 40rpx;
  316. text-align: center;
  317. line-height: 80rpx;
  318. font-size: 32rpx;
  319. font-family: PingFang SC;
  320. font-weight: 500;
  321. color: #ffffff;
  322. }
  323. }
  324. .popup_row {
  325. width: 100%;
  326. height: 500rpx;
  327. background-color: #ffffff;
  328. border-radius: 20rpx;
  329. display: flex;
  330. justify-content: center;
  331. align-items: center;
  332. .rows {
  333. width: 100%;
  334. padding: 0 24rpx;
  335. .rows-item {
  336. height: 80rpx;
  337. line-height: 80rpx;
  338. text-align: center;
  339. width: 100%;
  340. font-size: 32rpx;
  341. color: #303133;
  342. // border-bottom: 1rpx solid #f0f0f0;
  343. }
  344. // .row-1 {
  345. // margin: auto;
  346. // .first_aid {
  347. // width: 300rpx;
  348. // height: 300rpx;
  349. // }
  350. // }
  351. // .row-2 {
  352. // font-size: 38rpx;
  353. // margin-top: 20rpx;
  354. // }
  355. }
  356. }
  357. .shop-dhq {
  358. width: 702rpx;
  359. height: 171rpx;
  360. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  361. margin: auto;
  362. border-radius: 20rpx;
  363. background-color: #fff;
  364. }
  365. </style>