store.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <view class="content">
  3. <view class="varHeight"></view>
  4. <view class="search flex">
  5. <view class="input-box flex">
  6. <view class=" input-content flex">
  7. <view class="iconfont iconsearch"></view>
  8. <view class="input"><input type="text" placeholder="输入关键字搜索" @input='search' /></view>
  9. </view>
  10. </view>
  11. <picker mode="multiSelector" :range="listActionType" range-key='cate_name' @change="changeType"
  12. @columnchange='listChange'>
  13. <view class="shop-name clamp">分类
  14. <image src="../../static/icon/dh (2).png" mode="" style="width: 16rpx; height: 10rpx;"></image>
  15. </view>
  16. </picker>
  17. <view class="shop-name clamp" @click="initSearch">搜索</view>
  18. </view>
  19. <view class="jg" style="height: 20rpx;"></view>
  20. <block :key="ind" v-for="(lss, ind) in list">
  21. <view class="goodsList-item" v-if="lss.show">
  22. <!-- <view class="goodsList-item" v-if="lss.show" @click="chooseStore(lss)"> -->
  23. <view class="info-top flex">
  24. <image :src="lss.image" lazy-load mode="scaleToFill"></image>
  25. <view class="store-name clamp2">{{ lss.name }}</view>
  26. </view>
  27. <view class="tag">门店</view>
  28. <view class="dh" v-if="type == 0 || type == 5" @click.stop="markertap(lss)">导航</view>
  29. <!-- <view class="go" v-if="type == 7" @click.stop="navProduct(lss)">进入店铺</view> -->
  30. <view class="goodsList-content">
  31. <view class="info-tit">
  32. 地区:
  33. <text class="info-val">{{ lss.address }}</text>
  34. </view>
  35. <view class="info-tit">
  36. 电话:
  37. <text class="info-val">{{ lss.phone }}</text>
  38. </view>
  39. <view class="info-tit">
  40. 地址:
  41. <text class="info-val">{{ lss.detailed_address }}</text>
  42. </view>
  43. </view>
  44. </view>
  45. </block>
  46. <view class="jg" style="height: 20rpx;"></view>
  47. <uni-popup ref="popup" type="bottom" @click="close">
  48. <view class="popup_row">
  49. <view class="rows">
  50. <view class="rows-item" @click="toGaodeMap">高德地图</view>
  51. <view class="rows-item" @click="tobaiDuMap">百度地图</view>
  52. <!-- <view class="rows-item" @click="totengxunMap">腾讯地图</view> -->
  53. </view>
  54. </view>
  55. </uni-popup>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. mapState,
  61. mapMutations
  62. } from 'vuex';
  63. import {
  64. store_list,
  65. getStoreType
  66. } from '@/api/index.js';
  67. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  68. export default {
  69. data() {
  70. return {
  71. // 当前选中的滑块
  72. list: [],
  73. keyword: '', //查询中的内容
  74. latitude1: '',
  75. longitude1: '',
  76. address: '',
  77. // 当前动态分类
  78. typeAction: {
  79. name: '分类',
  80. cid: ''
  81. },
  82. type: 0, //3->开通会员选择门店 4->自提选择门店 5->附近门店进入不做任何操作
  83. typeActionNum: 0, //当前选中的action
  84. typeList: [], //列表分类
  85. };
  86. },
  87. watch: {
  88. keyword(newValue, oldValue) {
  89. this.keyword = newValue;
  90. console.log(newValue);
  91. this.getShoping();
  92. }
  93. },
  94. computed: {
  95. ...mapState(['latitude', 'longitude']),
  96. listActionType() {
  97. if (this.typeList.length > 0) {
  98. return [this.typeList, this.typeList[this.typeActionNum].children]
  99. } else {
  100. return []
  101. }
  102. }
  103. },
  104. onLoad(opt) {
  105. if (opt.type) {
  106. this.type = opt.type;
  107. }
  108. this.getShoping();
  109. this.getStoreType();
  110. },
  111. // // #ifndef MP
  112. // // 点击键盘搜索事件
  113. // onNavigationBarSearchInputConfirmed(e) {
  114. // this.search();
  115. // },
  116. // // 搜索栏内容变化事件
  117. // onNavigationBarSearchInputChanged(e) {
  118. // this.keyword = e.text;
  119. // },
  120. // // #endif
  121. methods: {
  122. ...mapMutations(['setLat', 'setLon', 'setStoreInfo']),
  123. initSearch() {
  124. this.keyword = '';
  125. this.typeAction.cid = '';
  126. this.getShoping();
  127. },
  128. // 确认切换
  129. changeType(res) {
  130. console.log(res);
  131. const item = res.detail.value;
  132. const ar = this.typeList[item[0]].children[item[1]];
  133. this.typeAction.name = ar.cate_name
  134. this.typeAction.cid = ar.id
  135. this.getShoping();
  136. },
  137. // 列表切换
  138. listChange(res) {
  139. if (res.detail.column == 0) {
  140. this.typeActionNum = res.detail.value;
  141. }
  142. },
  143. // 查询店铺信息
  144. search(res) {
  145. this.keyword = res.detail.value;
  146. },
  147. markertap(e) {
  148. this.longitude1 = e.longitude;
  149. this.latitude1 = e.latitude;
  150. this.address = e.detailed_address;
  151. this.$refs.popup.open();
  152. },
  153. // 跳转店铺页面
  154. navProduct(item) {
  155. uni.navigateTo({
  156. url: './index?merid=' + item.id
  157. });
  158. },
  159. // 调用高德
  160. toGaodeMap() {
  161. let latitude = this.latitude1;
  162. let longitude = this.longitude1;
  163. let address = this.address;
  164. // console.log('选择高德', latitude, longitude, address);
  165. window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
  166. },
  167. // 调用腾讯
  168. totengxunMap() {
  169. let latitude = this.latitude1;
  170. let longitude = this.longitude1;
  171. let address = this.address;
  172. console.log('选择腾讯', latitude, longitude);
  173. window.location.href =
  174. `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
  175. },
  176. // 调用百度
  177. tobaiDuMap() {
  178. let latitude = this.latitude1;
  179. let longitude = this.longitude1;
  180. let latitude6 = this.latitude;
  181. let longitude6 = this.longitude;
  182. let address = this.address;
  183. // console.log('选择百度', latitude, longitude);
  184. // console.log('获取当前经纬度', latitude6, longitude6);
  185. window.location.href =
  186. `http://api.map.baidu.com/marker?location=${latitude},${longitude}&title=${address}&content=${address}&output=html&src=webapp.baidu.openAPIdemo`;
  187. },
  188. getStoreType() {
  189. let obj = this;
  190. getStoreType()
  191. .then(function({
  192. data
  193. }) {
  194. obj.typeList = data;
  195. })
  196. .catch(e => {
  197. console.log(e);
  198. });
  199. },
  200. //获取商店信息
  201. getShoping() {
  202. let obj = this;
  203. console.log(obj.longitude, obj.latitude);
  204. store_list({
  205. longitude: obj.longitude, //经度
  206. latitude: obj.latitude, //纬度
  207. keyword: obj.keyword,
  208. cid: obj.typeAction.cid
  209. })
  210. .then(function({
  211. data
  212. }) {
  213. console.log(data);
  214. obj.list = data.list.map(e => {
  215. e.show = true;
  216. return e;
  217. });
  218. })
  219. .catch(e => {
  220. console.log(e);
  221. });
  222. },
  223. //选择门店
  224. // chooseStore(item) {
  225. // if (this.type == 3) {
  226. // this.$api.prePage().storeInfo = item;
  227. // uni.navigateBack({});
  228. // } else if (this.type == 4) {
  229. // this.$api.prePage().shopAddress = item;
  230. // uni.navigateBack({});
  231. // } else if (this.type == 5) {} else if (this.type == 7) {
  232. // this.navProduct(item);
  233. // } else if (this.type == 6) {
  234. // this.$api.prePage().storeInfo1 = item;
  235. // uni.navigateBack({});
  236. // } else {
  237. // this.setStoreInfo(item);
  238. // uni.navigateBack({});
  239. // }
  240. // }
  241. }
  242. };
  243. </script>
  244. <style lang="scss">
  245. page,
  246. .content {
  247. height: 100%;
  248. }
  249. .varHeight {
  250. height: var(--status-bar-height);
  251. }
  252. $slider-color: #fe9398; //滑块左侧颜色
  253. .goodsList-item {
  254. // background-color: #ffffff;
  255. // padding: 30rpx;
  256. // border-bottom: 1px solid $border-color-light;
  257. margin: 0 auto 20rpx;
  258. width: 710rpx;
  259. height: 231rpx;
  260. padding: 25rpx 20rpx;
  261. background: #ffffff;
  262. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  263. border-radius: 10rpx;
  264. position: relative;
  265. .tag {
  266. width: 60rpx;
  267. line-height: 40rpx;
  268. background: #ff6f0f;
  269. border-radius: 5rpx;
  270. font-size: 24rpx;
  271. font-family: PingFang SC;
  272. font-weight: 500;
  273. color: #ffffff;
  274. text-align: center;
  275. position: absolute;
  276. top: 25rpx;
  277. right: 20rpx;
  278. }
  279. .dh {
  280. z-index: 3;
  281. width: 70rpx;
  282. line-height: 44rpx;
  283. border-radius: 10rpx;
  284. background: #000;
  285. font-size: 24rpx;
  286. font-family: PingFang SC;
  287. font-weight: 500;
  288. color: #ffffff;
  289. text-align: center;
  290. position: absolute;
  291. bottom: 25rpx;
  292. right: 20rpx;
  293. }
  294. .go {
  295. z-index: 3;
  296. width: 150rpx;
  297. line-height: 44rpx;
  298. border-radius: 10rpx;
  299. background: #ff5b53;
  300. font-size: 24rpx;
  301. font-family: PingFang SC;
  302. font-weight: 500;
  303. color: #ffffff;
  304. text-align: center;
  305. position: absolute;
  306. bottom: 25rpx;
  307. right: 20rpx;
  308. }
  309. .info-top {
  310. justify-content: flex-start;
  311. .store-name {
  312. max-width: 500rpx;
  313. font-size: 32rpx;
  314. font-family: PingFang SC;
  315. font-weight: bold;
  316. color: #333333;
  317. padding-left: 11rpx;
  318. }
  319. }
  320. image {
  321. flex-shrink: 0;
  322. // border-radius: $border-radius-sm;
  323. // height: 180rpx;
  324. // width: 180rpx;
  325. width: 65rpx;
  326. height: 65rpx;
  327. border-radius: 50%;
  328. }
  329. .slider {
  330. margin-top: 15rpx;
  331. justify-content: flex-start;
  332. .slider-box {
  333. width: 196rpx;
  334. border-radius: 99px;
  335. border: 1px solid $slider-color;
  336. height: 16rpx;
  337. .slider-action {
  338. background-color: $slider-color;
  339. height: 100%;
  340. }
  341. }
  342. .sales-nub {
  343. color: $font-color-light;
  344. font-size: 24rpx;
  345. height: 2.5em;
  346. overflow: hidden;
  347. }
  348. }
  349. .goodsList-content {
  350. // margin-left: 20rpx;
  351. flex-grow: 1;
  352. // height: 180rpx;
  353. position: relative;
  354. padding-top: 20rpx;
  355. .info-tit {
  356. line-height: 1.5;
  357. font-size: 24rpx;
  358. font-family: PingFang SC;
  359. font-weight: bold;
  360. color: #333333;
  361. .info-val {
  362. font-weight: 500;
  363. }
  364. }
  365. .title {
  366. font-size: $font-base;
  367. color: $font-color-dark;
  368. font-weight: 500;
  369. width: 0;
  370. min-width: 100%;
  371. }
  372. .goods-money {
  373. position: absolute;
  374. left: 0;
  375. bottom: 0;
  376. width: 100%;
  377. .money-box {
  378. .money {
  379. font-size: $font-lg + 10rpx;
  380. color: $color-red;
  381. font-weight: bold;
  382. }
  383. .otMoney-box {
  384. font-size: $font-sm;
  385. .otMoney {
  386. color: $font-color-light;
  387. padding-right: 20rpx;
  388. }
  389. .sales {
  390. color: $font-color-light;
  391. }
  392. }
  393. }
  394. .cart {
  395. font-size: $font-base - 2rpx;
  396. border-radius: 99px;
  397. padding: 10rpx 20rpx;
  398. line-height: 1;
  399. color: #ffffff;
  400. background-color: $color-gray;
  401. &.seckill-action {
  402. border: 1px solid $color-red;
  403. background-color: $color-red;
  404. }
  405. }
  406. }
  407. }
  408. }
  409. .popup_row {
  410. width: 100%;
  411. height: 500rpx;
  412. background-color: #ffffff;
  413. border-radius: 20rpx;
  414. display: flex;
  415. justify-content: center;
  416. align-items: center;
  417. .rows {
  418. width: 100%;
  419. padding: 0 24rpx;
  420. .rows-item {
  421. height: 80rpx;
  422. line-height: 80rpx;
  423. text-align: center;
  424. width: 100%;
  425. font-size: 32rpx;
  426. color: #303133;
  427. // border-bottom: 1rpx solid #f0f0f0;
  428. }
  429. }
  430. }
  431. .search {
  432. justify-content: center;
  433. padding: 10rpx 24rpx 20rpx;
  434. align-items: center;
  435. // background: #F6F6F6;
  436. background: #FFFFFF;
  437. .address {
  438. width: 32rpx;
  439. height: 38rpx;
  440. }
  441. .shop-name {
  442. height: 38rpx;
  443. position: relative;
  444. z-index: 100;
  445. font-size: 30rpx;
  446. font-family: PingFang SC;
  447. font-weight: 500;
  448. // color: #ffffff;
  449. padding-left: 10rpx;
  450. flex-shrink: 0;
  451. }
  452. .input-box {
  453. position: relative;
  454. z-index: 99;
  455. width: 700rpx;
  456. height: 60rpx;
  457. background: #f6f6f6;
  458. // box-shadow: 0px 9rpx 21rpx 0px rgba(4, 114, 69, 0.22);
  459. border-radius: 30px;
  460. margin: 0 auto;
  461. .input-content {
  462. justify-content: center;
  463. position: relative;
  464. z-index: 11;
  465. border-radius: 99rpx;
  466. flex-grow: 1;
  467. padding: 5rpx 30rpx;
  468. background: #FFF;
  469. .iconsearch {
  470. font-size: 50rpx;
  471. color: #666666;
  472. }
  473. .input {
  474. margin-left: 19rpx;
  475. color: #666666;
  476. flex-grow: 1;
  477. input {
  478. font-size: 26rpx;
  479. color: #666666;
  480. }
  481. }
  482. }
  483. .input-button {
  484. padding-left: 20rpx;
  485. font-size: $font-base;
  486. height: 100%;
  487. }
  488. }
  489. }
  490. </style>