shopList.vue 14 KB

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