shop-item.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="shop-item" :style="{ 'background-image': `url(${item.background})` }">
  3. <view class="shop-hd flex row-between m-l-20" v-if='lx == 2'>
  4. <view>
  5. <view class="flex">
  6. <u-image width="68rpx" height="68rpx" border-radius="60rpx" :src="item.logo" />
  7. <view class="white md m-l-20 bold">{{ item.name }}</view>
  8. </view>
  9. <router-link :to="{ path: '/bundle_b/pages/nearby_shops/neardetail', query: { id: item.id } }">
  10. <view class="enter-btn flex row-center bg-white xxs">进店看看 ></view>
  11. </router-link>
  12. </view>
  13. <view>
  14. <view class="white flex row-center xs m-r-10" v-if="item.distance">
  15. <u-icon name="map" size="30"></u-icon>
  16. <text class="m-l-4">距离{{ item.distance }}</text>
  17. </view>
  18. <view class="hd-btn" v-if="item.mobile">
  19. <image src="../../static/my/call.png" mode="" style="margin-right: 15rpx;" @click.stop="tocall()">
  20. </image>
  21. <!-- #ifdef H5 -->
  22. <image src="../../static/my/dh.png" mode=""
  23. @click.stop="toGaodeMap(item.latitude, item.longitude, item.name)"></image>
  24. <!-- #endif -->
  25. <!-- #ifdef MP -->
  26. <image src="../../static/my/dh.png" mode="" @click.stop="dh(item)"></image>
  27. <!-- #endif -->
  28. <!-- #ifdef APP-PLUS -->
  29. <image src="../../static/my/dh.png" mode=""
  30. @click.stop="gomapApp(item.latitude, item.longitude, item.name)"></image>
  31. <!-- #endif -->
  32. </view>
  33. <view class="hd-btn" v-if="!item.mobile">
  34. <!-- #ifdef H5 -->
  35. <image src="../../static/my/dh.png" mode=""
  36. @click.stop="toGaodeMap(item.latitude, item.longitude, item.name)"></image>
  37. <!-- #endif -->
  38. <!-- #ifdef MP -->
  39. <image src="../../static/my/dh.png" mode="" @click.stop="dh(item)"></image>
  40. <!-- #endif -->
  41. <!-- #ifdef APP-PLUS -->
  42. <image src="../../static/my/dh.png" mode=""
  43. @click.stop="gomapApp(item.latitude, item.longitude, item.name)"></image>
  44. <!-- #endif -->
  45. </view>
  46. </view>
  47. </view>
  48. <view class="shop-hd flex row-between m-l-20" v-if="lx==1">
  49. <view>
  50. <view class="flex">
  51. <u-image width="68rpx" height="68rpx" border-radius="60rpx" :src="item.logo" />
  52. <view class="white md m-l-20 bold">{{ item.name }}</view>
  53. </view>
  54. <router-link :to="{ path: '/pages/store_index/store_index', query: { id: item.id } }">
  55. <view class="enter-btn flex row-center bg-white xxs">进店看看 ></view>
  56. </router-link>
  57. </view>
  58. <view>
  59. <!-- <view class="shop-tips white flex row-center xxs">
  60. {{item.visited_num}}人进店
  61. </view> -->
  62. <view class="m-t-30 white flex row-center xs m-r-10" v-if="item.distance">
  63. <u-icon name="map" size="30"></u-icon>
  64. <text class="m-l-4">距离{{ item.distance }}</text>
  65. </view>
  66. </view>
  67. </view>
  68. <scroll-view style="white-space: nowrap;" :scroll-x="true" v-if="lx==1">
  69. <view class="goods"><goods-list width="200rpx" type="row" :list="item.goods_list"></goods-list></view>
  70. </scroll-view>
  71. </view>
  72. </template>
  73. <script>
  74. export default {
  75. name: 'shop-item',
  76. props: {
  77. item: {
  78. type: Object,
  79. defalut: () => ({})
  80. },
  81. lx: {
  82. type: String,
  83. defalut: '2'
  84. }
  85. },
  86. data() {
  87. return {};
  88. },
  89. methods: {
  90. tocall() {
  91. let num = this.item.mobile;
  92. console.log(num);
  93. uni.makePhoneCall({
  94. phoneNumber: num //仅为示例
  95. });
  96. },
  97. toGaodeMap() {
  98. let obj = this;
  99. window.location.href =
  100. `https://uri.amap.com/marker?position=${obj.item.longitude},${obj.item.latitude}&name=${obj.item.name}`;
  101. },
  102. dh() {
  103. let obj = this;
  104. wx.openLocation({
  105. latitude: obj.item.latitude * 1,
  106. longitude: obj.item.longitude * 1,
  107. name: obj.item.name,
  108. address: obj.item.detailed_address
  109. });
  110. },
  111. gomapApp(latitude, longitude, name) {
  112. let url = '';
  113. if (plus.os.name == 'Android') {
  114. //判断是安卓端
  115. plus.nativeUI.actionSheet({
  116. //选择菜单
  117. title: '选择地图应用',
  118. cancel: '取消',
  119. buttons: [{
  120. title: '腾讯地图'
  121. }, {
  122. title: '百度地图'
  123. }, {
  124. title: '高德地图'
  125. }]
  126. },
  127. function(e) {
  128. switch (e.index) {
  129. //下面是拼接url,不同系统以及不同地图都有不同的拼接字段
  130. case 1:
  131. //注意referer=xxx的xxx替换成你在腾讯地图开发平台申请的key
  132. url = `qqmap://map/geocoder?coord=${latitude},${longitude}&referer=xxx`;
  133. break;
  134. case 2:
  135. url =
  136. `baidumap://map/marker?location=${latitude},${longitude}&title=${name}&coord_type=gcj02&src=andr.baidu.openAPIdemo`;
  137. break;
  138. case 3:
  139. url =
  140. `androidamap://viewMap?sourceApplication=appname&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
  141. break;
  142. default:
  143. break;
  144. }
  145. if (url != '') {
  146. url = encodeURI(url);
  147. //plus.runtime.openURL(url,function(e){})调起手机APP应用
  148. plus.runtime.openURL(url, function(e) {
  149. plus.nativeUI.alert('本机未安装指定的地图应用');
  150. });
  151. }
  152. }
  153. );
  154. } else {
  155. // iOS上获取本机是否安装了百度高德地图,需要在manifest里配置
  156. // 在manifest.json文件app-plus->distribute->apple->urlschemewhitelist节点下添加
  157. //(如urlschemewhitelist:["iosamap","baidumap"])
  158. plus.nativeUI.actionSheet({
  159. title: '选择地图应用',
  160. cancel: '取消',
  161. buttons: [{
  162. title: '腾讯地图'
  163. }, {
  164. title: '百度地图'
  165. }, {
  166. title: '高德地图'
  167. }]
  168. },
  169. function(e) {
  170. switch (e.index) {
  171. case 1:
  172. url = `qqmap://map/geocoder?coord=${latitude},${longitude}&referer=xxx`;
  173. break;
  174. case 2:
  175. url =
  176. `baidumap://map/marker?location=${latitude},${longitude}&title=${name}&content=${name}&src=ios.baidu.openAPIdemo&coord_type=gcj02`;
  177. break;
  178. case 3:
  179. url =
  180. `iosamap://viewMap?sourceApplication=applicationName&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
  181. break;
  182. default:
  183. break;
  184. }
  185. if (url != '') {
  186. url = encodeURI(url);
  187. plus.runtime.openURL(url, function(e) {
  188. plus.nativeUI.alert('本机未安装指定的地图应用');
  189. });
  190. }
  191. }
  192. );
  193. }
  194. }
  195. }
  196. };
  197. </script>
  198. <style lang="scss">
  199. .shop-item {
  200. padding: 30rpx 0;
  201. background-repeat: no-repeat;
  202. background-size: cover;
  203. background-position: center;
  204. border-radius: 20rpx;
  205. background-color: #fff;
  206. .shop-hd {
  207. .enter-btn {
  208. height: 48rpx;
  209. width: 148rpx;
  210. margin-top: 30rpx;
  211. border-radius: 50rpx;
  212. }
  213. .shop-tips {
  214. background-color: rgba($color: #000000, $alpha: 0.6);
  215. border-radius: 50rpx 0rpx 0rpx 50rpx;
  216. height: 50rpx;
  217. min-width: 152rpx;
  218. padding: 0 10rpx;
  219. }
  220. }
  221. .goods {
  222. padding: 20rpx;
  223. display: inline-block;
  224. }
  225. }
  226. .hd-btn {
  227. display: flex;
  228. align-items: center;
  229. justify-content: space-around;
  230. padding: 40rpx 68rpx 0;
  231. image {
  232. width: 46rpx;
  233. height: 46rpx;
  234. }
  235. }
  236. </style>