list.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <view class="content">
  3. <view class="varHeight"></view>
  4. <view class="jg" style="height: 20rpx;"></view>
  5. <block :key="ind" v-for="(lss, ind) in list">
  6. <view class="goodsList-item" v-if="lss.show" @click="chooseStore(lss)">
  7. <view class="info-top flex">
  8. <image :src="lss.image" lazy-load mode="scaleToFill"></image>
  9. <view class="store-name clamp2">{{ lss.name }}</view>
  10. </view>
  11. <view class="tag">门店</view>
  12. <view class="dh" v-if="type == 0 || type == 5" @click.stop="markertap(lss)">导航</view>
  13. <view class="go" v-if="type == 7" @click.stop="navProduct(lss)">进入店铺</view>
  14. <view class="goodsList-content">
  15. <view class="info-tit">
  16. 地区:
  17. <text class="info-val">{{ lss.address }}</text>
  18. </view>
  19. <view class="info-tit">
  20. 电话:
  21. <text class="info-val">{{ lss.phone }}</text>
  22. </view>
  23. <view class="info-tit">
  24. 地址:
  25. <text class="info-val">{{ lss.detailed_address }}</text>
  26. </view>
  27. </view>
  28. </view>
  29. </block>
  30. <view class="jg" style="height: 20rpx;"></view>
  31. <uni-popup ref="popup" type="bottom" @click="close">
  32. <view class="popup_row">
  33. <view class="rows">
  34. <view class="rows-item" @click="toGaodeMap">高德地图</view>
  35. <view class="rows-item" @click="tobaiDuMap">百度地图</view>
  36. <!-- <view class="rows-item" @click="totengxunMap">腾讯地图</view> -->
  37. </view>
  38. </view>
  39. </uni-popup>
  40. </view>
  41. </template>
  42. <script>
  43. import { mapState, mapMutations } from 'vuex';
  44. import { store_list } from '@/api/index.js';
  45. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  46. export default {
  47. data() {
  48. return {
  49. // 当前选中的滑块
  50. list: [],
  51. keyword: '', //查询中的内容
  52. latitude1: '',
  53. longitude1: '',
  54. address: '',
  55. type: 0 //3->开通会员选择门店 4->自提选择门店 5->附近门店进入不做任何操作
  56. };
  57. },
  58. watch: {
  59. keyword(newValue, oldValue) {
  60. this.keyword = newValue;
  61. console.log(newValue);
  62. this.search();
  63. }
  64. },
  65. computed: {
  66. ...mapState(['latitude', 'longitude'])
  67. },
  68. onLoad(opt) {
  69. if (opt.type) {
  70. this.type = opt.type;
  71. }
  72. this.getShoping();
  73. },
  74. // #ifndef MP
  75. // 点击键盘搜索事件
  76. onNavigationBarSearchInputConfirmed(e) {
  77. this.search();
  78. },
  79. // 搜索栏内容变化事件
  80. onNavigationBarSearchInputChanged(e) {
  81. this.keyword = e.text;
  82. },
  83. // #endif
  84. methods: {
  85. ...mapMutations(['setLat', 'setLon', 'setStoreInfo']),
  86. // 查询店铺信息
  87. search(title) {
  88. let obj = this;
  89. obj.list.forEach(e => {
  90. if (e.title.indexOf(obj.keyword) >= 0) {
  91. e.show = true;
  92. } else {
  93. e.show = false;
  94. }
  95. });
  96. },
  97. markertap(e) {
  98. this.longitude1 = e.longitude;
  99. this.latitude1 = e.latitude;
  100. this.address = e.detailed_address;
  101. this.$refs.popup.open();
  102. },
  103. // 跳转店铺页面
  104. navProduct(item) {
  105. uni.navigateTo({
  106. url: './index?merid=' + item.id
  107. });
  108. },
  109. // 调用高德
  110. toGaodeMap() {
  111. let latitude = this.latitude1;
  112. let longitude = this.longitude1;
  113. let address = this.address;
  114. console.log('选择高德', latitude, longitude, address);
  115. window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
  116. },
  117. // 调用腾讯
  118. totengxunMap() {
  119. let latitude = this.latitude1;
  120. let longitude = this.longitude1;
  121. let address = this.address;
  122. console.log('选择腾讯', latitude, longitude);
  123. window.location.href = `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
  124. },
  125. // 调用百度
  126. tobaiDuMap() {
  127. let latitude = this.latitude1;
  128. let longitude = this.longitude1;
  129. let latitude6 = this.latitude;
  130. let longitude6 = this.longitude;
  131. let address = this.address;
  132. console.log('选择百度', latitude, longitude);
  133. console.log('获取当前经纬度', latitude6, longitude6);
  134. window.location.href = `http://api.map.baidu.com/marker?location=${latitude},${longitude}&title=${address}&content=${address}&output=html&src=webapp.baidu.openAPIdemo`;
  135. },
  136. //获取商店信息
  137. getShoping() {
  138. let obj = this;
  139. console.log(obj.longitude, obj.latitude);
  140. store_list({
  141. longitude: obj.longitude, //经度
  142. latitude: obj.latitude //纬度
  143. })
  144. .then(function({ data }) {
  145. console.log(data);
  146. obj.list = data.list.map(e => {
  147. e.show = true;
  148. return e;
  149. });
  150. })
  151. .catch(e => {
  152. console.log(e);
  153. });
  154. },
  155. //选择门店
  156. chooseStore(item) {
  157. if (this.type == 3) {
  158. this.$api.prePage().storeInfo = item;
  159. uni.navigateBack({});
  160. } else if (this.type == 4) {
  161. this.$api.prePage().shopAddress = item;
  162. uni.navigateBack({});
  163. } else if (this.type == 5) {
  164. } else if (this.type == 7) {
  165. this.navProduct(item);
  166. } else if (this.type == 6) {
  167. this.$api.prePage().storeInfo1 = item;
  168. uni.navigateBack({});
  169. } else {
  170. this.setStoreInfo(item);
  171. uni.navigateBack({});
  172. }
  173. }
  174. }
  175. };
  176. </script>
  177. <style lang="scss">
  178. page,
  179. .content {
  180. height: 100%;
  181. }
  182. .varHeight {
  183. height: var(--status-bar-height);
  184. }
  185. $slider-color: #fe9398; //滑块左侧颜色
  186. .goodsList-item {
  187. // background-color: #ffffff;
  188. // padding: 30rpx;
  189. // border-bottom: 1px solid $border-color-light;
  190. margin: 0 auto 20rpx;
  191. width: 710rpx;
  192. height: 231rpx;
  193. padding: 25rpx 20rpx;
  194. background: #ffffff;
  195. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  196. border-radius: 10rpx;
  197. position: relative;
  198. .tag {
  199. width: 60rpx;
  200. line-height: 40rpx;
  201. background: #ff6f0f;
  202. border-radius: 5rpx;
  203. font-size: 24rpx;
  204. font-family: PingFang SC;
  205. font-weight: 500;
  206. color: #ffffff;
  207. text-align: center;
  208. position: absolute;
  209. top: 25rpx;
  210. right: 20rpx;
  211. }
  212. .dh {
  213. z-index: 3;
  214. width: 70rpx;
  215. line-height: 44rpx;
  216. border-radius: 10rpx;
  217. background: #000;
  218. font-size: 24rpx;
  219. font-family: PingFang SC;
  220. font-weight: 500;
  221. color: #ffffff;
  222. text-align: center;
  223. position: absolute;
  224. bottom: 25rpx;
  225. right: 20rpx;
  226. }
  227. .go {
  228. z-index: 3;
  229. width: 150rpx;
  230. line-height: 44rpx;
  231. border-radius: 10rpx;
  232. background: #ff5b53;
  233. font-size: 24rpx;
  234. font-family: PingFang SC;
  235. font-weight: 500;
  236. color: #ffffff;
  237. text-align: center;
  238. position: absolute;
  239. bottom: 25rpx;
  240. right: 20rpx;
  241. }
  242. .info-top {
  243. justify-content: flex-start;
  244. .store-name {
  245. max-width: 500rpx;
  246. font-size: 32rpx;
  247. font-family: PingFang SC;
  248. font-weight: bold;
  249. color: #333333;
  250. padding-left: 11rpx;
  251. }
  252. }
  253. image {
  254. flex-shrink: 0;
  255. // border-radius: $border-radius-sm;
  256. // height: 180rpx;
  257. // width: 180rpx;
  258. width: 65rpx;
  259. height: 65rpx;
  260. border-radius: 50%;
  261. }
  262. .slider {
  263. margin-top: 15rpx;
  264. justify-content: flex-start;
  265. .slider-box {
  266. width: 196rpx;
  267. border-radius: 99px;
  268. border: 1px solid $slider-color;
  269. height: 16rpx;
  270. .slider-action {
  271. background-color: $slider-color;
  272. height: 100%;
  273. }
  274. }
  275. .sales-nub {
  276. color: $font-color-light;
  277. font-size: 24rpx;
  278. height: 2.5em;
  279. overflow: hidden;
  280. }
  281. }
  282. .goodsList-content {
  283. // margin-left: 20rpx;
  284. flex-grow: 1;
  285. // height: 180rpx;
  286. position: relative;
  287. padding-top: 20rpx;
  288. .info-tit {
  289. line-height: 1.5;
  290. font-size: 24rpx;
  291. font-family: PingFang SC;
  292. font-weight: bold;
  293. color: #333333;
  294. .info-val {
  295. font-weight: 500;
  296. }
  297. }
  298. .title {
  299. font-size: $font-base;
  300. color: $font-color-dark;
  301. font-weight: 500;
  302. width: 0;
  303. min-width: 100%;
  304. }
  305. .goods-money {
  306. position: absolute;
  307. left: 0;
  308. bottom: 0;
  309. width: 100%;
  310. .money-box {
  311. .money {
  312. font-size: $font-lg + 10rpx;
  313. color: $color-red;
  314. font-weight: bold;
  315. }
  316. .otMoney-box {
  317. font-size: $font-sm;
  318. .otMoney {
  319. color: $font-color-light;
  320. padding-right: 20rpx;
  321. }
  322. .sales {
  323. color: $font-color-light;
  324. }
  325. }
  326. }
  327. .cart {
  328. font-size: $font-base - 2rpx;
  329. border-radius: 99px;
  330. padding: 10rpx 20rpx;
  331. line-height: 1;
  332. color: #ffffff;
  333. background-color: $color-gray;
  334. &.seckill-action {
  335. border: 1px solid $color-red;
  336. background-color: $color-red;
  337. }
  338. }
  339. }
  340. }
  341. }
  342. .popup_row {
  343. width: 100%;
  344. height: 500rpx;
  345. background-color: #ffffff;
  346. border-radius: 20rpx;
  347. display: flex;
  348. justify-content: center;
  349. align-items: center;
  350. .rows {
  351. width: 100%;
  352. padding: 0 24rpx;
  353. .rows-item {
  354. height: 80rpx;
  355. line-height: 80rpx;
  356. text-align: center;
  357. width: 100%;
  358. font-size: 32rpx;
  359. color: #303133;
  360. // border-bottom: 1rpx solid #f0f0f0;
  361. }
  362. }
  363. }
  364. </style>