list.vue 11 KB

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