shopDetail.vue 9.5 KB

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