shopList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <template>
  2. <view class="content">
  3. <!-- <view class="shop">
  4. <view class="shop-title">
  5. <view class="shop-item" @click="changePx(0)">
  6. <view class="sitem-font" :class="{ choose: PXType == 0 }">销量</view>
  7. <view class="p-box">
  8. <text :class="{ active: PXType == 0 && numberOrder === 1 }" class="iconfont iconfold"></text>
  9. <text :class="{ active: PXType == 0 && numberOrder === 2 }"
  10. class="iconfont iconfold xia"></text>
  11. </view>
  12. </view>
  13. <view class="shop-item" @click="changePx(1)">
  14. <view class="sitem-font" :class="{ choose: PXType == 1 }">位置距离</view>
  15. <view class="p-box">
  16. <text :class="{ active: PXType == 1 && distance === 1 }" class="iconfont iconfold"></text>
  17. <text :class="{ active: PXType == 1 && distance === 2 }" class="iconfont iconfold xia"></text>
  18. </view>
  19. </view>
  20. <view class="shop-item" @click="changePx(2)">
  21. <view class="sitem-font" :class="{ choose: PXType == 2 }">趣豆赠送</view>
  22. <view class="p-box">
  23. <text :class="{ active: PXType == 2 && qudou === 1 }" class="iconfont iconfold"></text>
  24. <text :class="{ active: PXType == 2 && qudou === 2 }" class="iconfont iconfold xia"></text>
  25. </view>
  26. </view>
  27. </view>
  28. </view> -->
  29. <scroll-view scroll-y="true" :style="{ height: height }" class="shop-list-wrap" @scrolltolower="getStoreList()">
  30. <!-- 空白页 -->
  31. <empty v-if="loaded === true && shopList.length === 0"></empty>
  32. <view class="djq-wrap flex f-ai-s" v-for="item in shopList"
  33. @click="navTo('/pages/store/shopDetail?id=' + item.id)">
  34. <image :src="item.image" mode="" class="djq-img"></image>
  35. <view class="djq-right pl20">
  36. <view class="djq-tit flex f-j-sb f-ai-s">
  37. <view class="djq-name clamp">{{ item.name }}</view>
  38. <view class="djq-dis">
  39. <image src="../../static/icon/dw.png" mode=""></image>
  40. 距离{{ (item.range * 1).toFixed(2) }}KM
  41. </view>
  42. </view>
  43. <view class="flex f-d-c f-j-sb f-ai-s fg1" style="height: 110rpx;">
  44. <view class="djq-dz-box">
  45. <view class="djq-dz clamp2">{{ item.detailed_address }}</view>
  46. <!-- <view class="djq-dz">每100元赠送趣豆{{ item.gift_integral * 1 }}</view> -->
  47. </view>
  48. <view class="djq-hd flex f-j-sb">
  49. <view class="hd-btn">
  50. <image src="../../static/icon/call.png" mode="" style="margin-right: 15rpx;"
  51. @click.stop="makeCall(item.phone)"></image>
  52. <!-- #ifdef H5 -->
  53. <image src="../../static/icon/dh.png" mode=""
  54. @click.stop="toGaodeMap(item.latitude, item.longitude, item.name)"></image>
  55. <!-- #endif -->
  56. <!-- #ifdef MP -->
  57. <image src="../../static/icon/dh.png" mode="" @click.stop="dh(item)"></image>
  58. <!-- #endif -->
  59. <!-- #ifdef APP-PLUS -->
  60. <image src="../../static/icon/dh.png" mode=""
  61. @click.stop="gomapApp(item.latitude, item.longitude, item.name)"></image>
  62. <!-- #endif -->
  63. </view>
  64. </view>
  65. </view>
  66. <view class="" style="padding: 10rpx 0 0 0;">
  67. <view class="left-btm flex f-j-s" v-for="itemt in item.cou">
  68. <view class="j-price">
  69. <text>¥</text>
  70. {{ itemt.coupon_price }}
  71. </view>
  72. <view class="j-name">{{ itemt.title }}</view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <uni-load-more :status="loadingType"></uni-load-more>
  78. </scroll-view>
  79. </view>
  80. </template>
  81. <script>
  82. import empty from '@/components/empty';
  83. // #ifdef H5
  84. import {
  85. weixindata,
  86. shareLoad
  87. } from '@/utils/wxAuthorized';
  88. // #endif
  89. import {
  90. mapState,
  91. mapMutations
  92. } from 'vuex';
  93. import {
  94. getStoreList
  95. } from '@/api/user.js';
  96. export default {
  97. components: {
  98. empty
  99. },
  100. data() {
  101. return {
  102. page: 1,
  103. limit: 10,
  104. shopList: [],
  105. name: '',
  106. height: '',
  107. PXType: 0, //店铺排序规则 0-》销量排序 1-》距离排序 2-》趣豆多少排序
  108. numberOrder: 1, //销量排序1升2降
  109. distance: 1, //距离排序1升2降
  110. qudou: 1, //趣豆多少排序1升2降
  111. loadingType: 'more',
  112. loaded: false
  113. };
  114. },
  115. computed: {
  116. ...mapState(['loginInterceptor', 'baseURL', 'latitude', 'longitude'])
  117. },
  118. onLoad(opt) {
  119. if (opt.id) {
  120. this.id = opt.id;
  121. }
  122. console.log(opt.id, '分类id');
  123. this.getStoreList();
  124. },
  125. onShow() {},
  126. onReachBottom() {},
  127. onReady() {
  128. var obj = this;
  129. uni.getSystemInfo({
  130. success: resu => {
  131. const query = uni.createSelectorQuery();
  132. query.select('.shop-list-wrap').boundingClientRect();
  133. query.exec(function(res) {
  134. obj.height = resu.windowHeight - res[0].top + 'px';
  135. });
  136. },
  137. fail: res => {}
  138. });
  139. },
  140. methods: {
  141. changePx(index) {
  142. let obj = this;
  143. obj.PXType = index;
  144. if (index === 0) {
  145. this.order = this.numberOrder === 1 ? 'asc' : 'desc';
  146. this.numberOrder = this.numberOrder === 1 ? 2 : 1;
  147. }
  148. if (index === 1) {
  149. this.order = this.distance === 1 ? 'asc' : 'desc';
  150. this.distance = this.distance === 1 ? 2 : 1;
  151. }
  152. // 判断是否为价格优先
  153. if (index === 2) {
  154. this.order = this.qudou === 1 ? 'asc' : 'desc';
  155. this.qudou = this.qudou === 1 ? 2 : 1;
  156. }
  157. console.log('切换显示');
  158. this.page = 1;
  159. this.loadingType = 'more';
  160. this.getStoreList('reload');
  161. },
  162. navTo(url) {
  163. uni.navigateTo({
  164. url,
  165. fail() {
  166. uni.switchTab({
  167. url
  168. });
  169. }
  170. });
  171. },
  172. search() {
  173. let obj = this;
  174. obj.shopList = [];
  175. obj.loadingType = 'more';
  176. obj.page = 1;
  177. obj.getStoreList();
  178. },
  179. // 拨打电话
  180. makeCall(phone) {
  181. console.log(phone, '121345');
  182. uni.makePhoneCall({
  183. phoneNumber: phone //仅为示例
  184. });
  185. },
  186. // 导航
  187. dh(item) {
  188. wx.openLocation({
  189. latitude: item.latitude * 1,
  190. longitude: item.longitude * 1,
  191. name: item.name,
  192. address: item.detailed_address
  193. });
  194. },
  195. getStoreList(type) {
  196. let obj = this;
  197. if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  198. return;
  199. }
  200. obj.loadingType = 'loading';
  201. getStoreList({
  202. cid: obj.id,
  203. name: obj.name,
  204. latitude: obj.latitude,
  205. longitude: obj.longitude,
  206. page: obj.page,
  207. limit: obj.limit,
  208. // address: obj.$store.state.chooseDistrict,
  209. sort: obj.PXType == 0 ? 'achievement' : obj.PXType == 1 ? 'distance' : 'gift_integral',
  210. order: obj.order
  211. }).then(res => {
  212. console.log(res, type);
  213. if (type == 'reload') {
  214. obj.shopList = [];
  215. }
  216. console.log(obj.shopList, '12456');
  217. obj.shopList = obj.shopList.concat(res.data.list);
  218. obj.page++;
  219. if (obj.limit == res.data.list.length) {
  220. obj.loadingType = 'more';
  221. } else {
  222. obj.loadingType = 'noMore';
  223. }
  224. obj.loaded = true;
  225. });
  226. },
  227. gomapApp(latitude, longitude, name) {
  228. let url = '';
  229. if (plus.os.name == 'Android') {
  230. //判断是安卓端
  231. plus.nativeUI.actionSheet({
  232. //选择菜单
  233. title: '选择地图应用',
  234. cancel: '取消',
  235. buttons: [{
  236. title: '腾讯地图'
  237. }, {
  238. title: '百度地图'
  239. }, {
  240. title: '高德地图'
  241. }]
  242. },
  243. function(e) {
  244. switch (e.index) {
  245. //下面是拼接url,不同系统以及不同地图都有不同的拼接字段
  246. case 1:
  247. //注意referer=xxx的xxx替换成你在腾讯地图开发平台申请的key
  248. url = `qqmap://map/geocoder?coord=${latitude},${longitude}&referer=xxx`;
  249. break;
  250. case 2:
  251. url =
  252. `baidumap://map/marker?location=${latitude},${longitude}&title=${name}&coord_type=gcj02&src=andr.baidu.openAPIdemo`;
  253. break;
  254. case 3:
  255. url =
  256. `androidamap://viewMap?sourceApplication=appname&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
  257. break;
  258. default:
  259. break;
  260. }
  261. if (url != '') {
  262. url = encodeURI(url);
  263. //plus.runtime.openURL(url,function(e){})调起手机APP应用
  264. plus.runtime.openURL(url, function(e) {
  265. plus.nativeUI.alert('本机未安装指定的地图应用');
  266. });
  267. }
  268. }
  269. );
  270. } else {
  271. // iOS上获取本机是否安装了百度高德地图,需要在manifest里配置
  272. // 在manifest.json文件app-plus->distribute->apple->urlschemewhitelist节点下添加
  273. //(如urlschemewhitelist:["iosamap","baidumap"])
  274. plus.nativeUI.actionSheet({
  275. title: '选择地图应用',
  276. cancel: '取消',
  277. buttons: [{
  278. title: '腾讯地图'
  279. }, {
  280. title: '百度地图'
  281. }, {
  282. title: '高德地图'
  283. }]
  284. },
  285. function(e) {
  286. switch (e.index) {
  287. case 1:
  288. url = `qqmap://map/geocoder?coord=${latitude},${longitude}&referer=xxx`;
  289. break;
  290. case 2:
  291. url =
  292. `baidumap://map/marker?location=${latitude},${longitude}&title=${name}&content=${name}&src=ios.baidu.openAPIdemo&coord_type=gcj02`;
  293. break;
  294. case 3:
  295. url =
  296. `iosamap://viewMap?sourceApplication=applicationName&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
  297. break;
  298. default:
  299. break;
  300. }
  301. if (url != '') {
  302. url = encodeURI(url);
  303. plus.runtime.openURL(url, function(e) {
  304. plus.nativeUI.alert('本机未安装指定的地图应用');
  305. });
  306. }
  307. }
  308. );
  309. }
  310. },
  311. // 调用高德
  312. toGaodeMap(latitude, longitude, address) {
  313. console.log('选择高德', latitude, longitude, address);
  314. window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
  315. }
  316. }
  317. };
  318. </script>
  319. <style lang="scss">
  320. .search-top {
  321. // position: fixed;
  322. // top: 0;
  323. // z-index: 99;
  324. }
  325. .shop {
  326. // margin-top: 20rpx;
  327. background: #ffffff;
  328. padding: 0 12rpx;
  329. .shop-title {
  330. padding: 30rpx 0 20rpx;
  331. display: flex;
  332. align-items: center;
  333. border-bottom: 1px solid #e3e6e7;
  334. .shop-item {
  335. width: 33%;
  336. display: flex;
  337. align-items: center;
  338. justify-content: center;
  339. .sitem-font {
  340. font-size: 26rpx;
  341. font-family: PingFang SC;
  342. font-weight: bold;
  343. color: #333333;
  344. }
  345. .jt-down {
  346. width: 10rpx;
  347. height: 8rpx;
  348. margin-left: 12rpx;
  349. }
  350. }
  351. }
  352. }
  353. .shop-list-wrap {
  354. // background-color: red;
  355. padding-top: 20rpx;
  356. }
  357. .djq-wrap {
  358. width: 701rpx;
  359. // height: 255rpx;
  360. background: #ffffff;
  361. box-shadow: 0px 0px 27rpx 0px rgba(50, 50, 52, 0.06);
  362. border-radius: 20rpx;
  363. margin: 0 auto 20rpx;
  364. padding: 23rpx 22rpx;
  365. &:last-of-type {
  366. margin-bottom: 0;
  367. }
  368. .djq-img {
  369. flex-shrink: 0;
  370. width: 150rpx;
  371. height: 150rpx;
  372. border-radius: 10rpx;
  373. }
  374. .djq-right {
  375. width: 500rpx;
  376. margin-left: 10rpx;
  377. .djq-tit {
  378. font-size: 34rpx;
  379. font-weight: bold;
  380. color: #333333;
  381. line-height: 52rpx;
  382. .djq-name {
  383. max-width: 300rpx;
  384. }
  385. .djq-dis {
  386. display: flex;
  387. align-items: center;
  388. flex-shrink: 0;
  389. image {
  390. width: 20rpx;
  391. height: 28rpx;
  392. margin-right: 10rpx;
  393. }
  394. font-size: 22rpx;
  395. font-weight: 500;
  396. color: #666666;
  397. }
  398. }
  399. .djq-dz-box {
  400. width: 60%;
  401. }
  402. .djq-dz {
  403. width: 100%;
  404. font-size: 24rpx;
  405. font-weight: 500;
  406. color: #666666;
  407. }
  408. .djq-hd {
  409. width: 30%;
  410. display: flex;
  411. justify-content: end;
  412. .buy-info {
  413. display: inline-block;
  414. height: 32rpx;
  415. border-radius: 16rpx 16rpx 16rpx 0px;
  416. line-height: 32rpx;
  417. font-size: 20rpx;
  418. font-weight: 500;
  419. color: #ff440d;
  420. padding: 0 15rpx;
  421. background-color: #fff;
  422. }
  423. .hd-btn {
  424. image {
  425. width: 46rpx;
  426. height: 46rpx;
  427. }
  428. }
  429. }
  430. }
  431. }
  432. .left-btm {
  433. height: 50rpx;
  434. .j-logo {
  435. width: 32rpx;
  436. line-height: 33rpx;
  437. background: linear-gradient(-48deg, #ffa30b, #ffd158);
  438. border-radius: 13rpx;
  439. font-size: 21rpx;
  440. font-weight: 500;
  441. color: #ffffff;
  442. text-align: center;
  443. }
  444. .j-price {
  445. font-size: 27rpx;
  446. font-weight: bold;
  447. color: #ff4c4c;
  448. margin: 0 10rpx 0 5rpx;
  449. }
  450. .j-zk {
  451. height: 31rpx;
  452. border: 1rpx solid #ff4c4c;
  453. border-radius: 7rpx;
  454. line-height: 31rpx;
  455. padding: 0 8rpx;
  456. font-size: 20rpx;
  457. font-weight: bold;
  458. color: #ff4c4c;
  459. margin-right: 5rpx;
  460. }
  461. .j-name {
  462. font-size: 23rpx;
  463. font-weight: bold;
  464. color: #333333;
  465. }
  466. }
  467. .search {
  468. justify-content: flex-start;
  469. padding: 10rpx 32rpx 20rpx;
  470. align-items: center;
  471. background-color: #fff;
  472. .search-btn {
  473. display: inline-block;
  474. // flex-grow: ;
  475. flex-shrink: 0;
  476. padding: 0 0 0 20rpx;
  477. font-size: 32rpx;
  478. color: #ff4c4c;
  479. z-index: 99;
  480. }
  481. .address {
  482. width: 32rpx;
  483. height: 38rpx;
  484. }
  485. .shop-name {
  486. height: 38rpx;
  487. position: relative;
  488. top: -4rpx;
  489. z-index: 100;
  490. font-size: 30rpx;
  491. font-family: PingFang SC;
  492. font-weight: 500;
  493. padding-left: 10rpx;
  494. }
  495. .shop-jt {
  496. margin-left: 8rpx;
  497. width: 16rpx;
  498. height: 10rpx;
  499. }
  500. .input-box {
  501. margin-left: 10rpx;
  502. position: relative;
  503. z-index: 99;
  504. width: 710rpx;
  505. height: 60rpx;
  506. background: #eeeeee;
  507. border-radius: 30rpx;
  508. .input-content {
  509. position: relative;
  510. z-index: 11;
  511. border-radius: 99rpx;
  512. flex-grow: 1;
  513. padding: 5rpx 30rpx;
  514. background: #eeeeee;
  515. .iconsearch {
  516. font-size: 50rpx;
  517. color: #cbcbcb;
  518. }
  519. .input {
  520. margin-left: 19rpx;
  521. flex-grow: 1;
  522. input {
  523. font-size: 28rpx;
  524. color: #000;
  525. }
  526. }
  527. }
  528. .input-button {
  529. padding-left: 20rpx;
  530. font-size: $font-base;
  531. height: 100%;
  532. }
  533. }
  534. }
  535. .shop {
  536. margin-top: 20rpx;
  537. background: #ffffff;
  538. padding: 0 12rpx;
  539. .shop-title {
  540. padding: 30rpx 0 20rpx;
  541. display: flex;
  542. align-items: center;
  543. border-bottom: 1px solid #e3e6e7;
  544. .shop-item {
  545. width: 25%;
  546. display: flex;
  547. align-items: center;
  548. justify-content: center;
  549. .sitem-font {
  550. font-size: 26rpx;
  551. font-family: PingFang SC;
  552. font-weight: bold;
  553. color: #333333;
  554. }
  555. .choose {
  556. color: #ff4c4c;
  557. }
  558. .p-box {
  559. display: flex;
  560. flex-direction: column;
  561. .iconfont {
  562. display: flex;
  563. align-items: center;
  564. justify-content: center;
  565. width: 30rpx;
  566. height: 14rpx;
  567. line-height: 1;
  568. margin-left: 4rpx;
  569. font-size: 26rpx;
  570. color: #888;
  571. &.active {
  572. color: $base-color;
  573. }
  574. }
  575. .xia {
  576. transform: scaleY(-1);
  577. }
  578. }
  579. }
  580. }
  581. }
  582. </style>