storeInfo.vue 8.5 KB

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