list.vue 11 KB

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