storeList.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <template>
  2. <view class="content">
  3. <!-- <view class="search flex">
  4. <view class="input-box flex" @click.stop="clickSearch">
  5. <view class=" input-content flex">
  6. <view class="iconfont iconsearch"></view>
  7. <view class="input"><input type="text" placeholder="请输入店铺名称" v-model="name" /></view>
  8. </view>
  9. </view>
  10. <view class="search-btn" @click="search()">
  11. 搜索
  12. </view>
  13. </view> -->
  14. <scroll-view scroll-y="true" :style="{'height': height}" class="shop-list-wrap" @scrolltolower="getStoreList()">
  15. <!-- 空白页 -->
  16. <!-- <empty v-if="loaded === true && shopList.length === 0"></empty> -->
  17. <view class="djq-wrap flex f-ai-s" v-for="item in shopList"
  18. @click="navTo('/pages/shop/shopDetail?id=' + item.id)">
  19. <image :src="item.image" mode="" class="djq-img"></image>
  20. <view class="djq-right pl20">
  21. <view class="djq-tit flex f-j-sb f-ai-s">
  22. <view class="djq-name clamp">
  23. {{item.name}}
  24. </view>
  25. <view class="djq-dis">
  26. <!-- <image src="../../static/icon/dw.png" mode=""></image> -->
  27. <!-- 距离{{item.range*1}}KM -->
  28. </view>
  29. </view>
  30. <view class="flex f-d-c f-j-sb f-ai-s fg1" style="height: 110rpx;">
  31. <view class="djq-dz clamp2">
  32. {{item.detailed_address}}
  33. </view>
  34. <view class="djq-hd flex f-j-sb">
  35. <view class="buy-info">
  36. <!-- {{item.count}}人已购买 -->
  37. </view>
  38. <view class="hd-btn">
  39. <image src="../../static/icon/call.png" mode="" style="margin-right: 15rpx;"
  40. @click.stop="makeCall(item.phone)"></image>
  41. <image src="../../static/icon/dh.png" mode=""
  42. @click.stop="toGaodeMap(item)"></image>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="" style="padding: 10rpx 0 0 0;">
  47. <view class="left-btm flex f-j-s" v-for="itemt in item.coupon">
  48. <view class="j-logo">
  49. </view>
  50. <view class="j-price">
  51. <text>¥</text>{{itemt.price}}
  52. </view>
  53. <view class="j-zk">
  54. {{(((itemt.price*10)/(itemt.ot_price*1)).toFixed(1))}}折
  55. </view>
  56. <view class="j-name">
  57. {{itemt.store_name}}
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <uni-load-more :status="loadingType"></uni-load-more>
  64. </scroll-view>
  65. </view>
  66. </template>
  67. <script>
  68. // import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  69. // #ifdef H5
  70. import {
  71. weixindata,
  72. shareLoad
  73. } from '@/utils/wxAuthorized';
  74. // #endif
  75. import {
  76. mapState,
  77. mapMutations
  78. } from 'vuex';
  79. import {
  80. getStoreList
  81. } from '@/api/index.js'
  82. import {
  83. Cookie
  84. } from 'tough-cookie';
  85. export default {
  86. // components: {
  87. // empty
  88. // },
  89. data() {
  90. return {
  91. page: 1,
  92. limit: 10,
  93. shopList: [],
  94. name: '',
  95. height: '',
  96. loadingType: 'more',
  97. loaded: false,
  98. latitude: '',
  99. longitude: '',
  100. current_address: ''
  101. }
  102. },
  103. computed: {
  104. ...mapState(['loginInterceptor', 'baseURL']),
  105. },
  106. onLoad(opt) {
  107. let that = this
  108. console.log('获取经纬度')
  109. uni.getLocation({
  110. geocode: true,
  111. complete(res) {
  112. console.log(res)
  113. that.latitude = res.latitude
  114. that.longitude = res.longitude
  115. that.current_address = res.address.province + res.address.city + res.address.district + res
  116. .address.street + res.address.streetNum + res.address.poiName;
  117. },
  118. fail() {
  119. }
  120. })
  121. that.getStoreList()
  122. },
  123. onShow() {
  124. },
  125. onReachBottom() {
  126. },
  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. navTo(url) {
  142. uni.navigateTo({
  143. url,
  144. fail() {
  145. uni.switchTab({
  146. url
  147. })
  148. }
  149. })
  150. },
  151. search() {
  152. let obj = this
  153. obj.shopList = []
  154. obj.loadingType = 'more'
  155. obj.page = 1
  156. obj.getStoreList()
  157. },
  158. // 拨打电话
  159. makeCall(phone) {
  160. uni.makePhoneCall({
  161. phoneNumber: phone //仅为示例
  162. });
  163. },
  164. // 导航
  165. dh(item) {
  166. // #ifdef H5
  167. weixindata().then(wxOjb => {
  168. console.log(wxOjb, '获取微信');
  169. wxOjb.openLocation({
  170. latitude: item.latitude, // 纬度,浮点数,范围为90 ~ -90
  171. longitude: item.longitude, // 经度,浮点数,范围为180 ~ -180。
  172. name: item.name, // 位置名
  173. address: item.detailed_address, // 地址详情说明
  174. scale: 28, // 地图缩放级别,整型值,范围从1~28。默认为最大
  175. infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
  176. });
  177. });
  178. // #endif
  179. },
  180. getStoreList() {
  181. let obj = this
  182. if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  183. return
  184. }
  185. obj.loadingType = 'loading'
  186. console.log('开始')
  187. getStoreList({
  188. name: obj.name,
  189. latitude: obj.latitude,
  190. longitude: obj.longitude,
  191. page: obj.page,
  192. limit: obj.limit
  193. }).then(res => {
  194. console.log(res)
  195. obj.shopList = obj.shopList.concat(res.data.list)
  196. obj.page++
  197. if (obj.limit == res.data.list.length) {
  198. obj.loadingType = 'more'
  199. } else {
  200. obj.loadingType = 'noMore'
  201. }
  202. obj.loaded = true
  203. }).catch(err => {
  204. console.log(err)
  205. })
  206. },
  207. // 调用高德
  208. toGaodeMap(item) {
  209. // #ifdef H5
  210. // console.log('选择高德', latitude, longitude, address);
  211. window.location.href = `https://uri.amap.com/marker?position=${item.longitude},${item.latitude}&name=${item.address}`;
  212. return
  213. // #endif
  214. uni.openLocation({
  215. latitude:+item.latitude,
  216. longitude:+item.longitude,
  217. name:item.name,
  218. address:item.detailed_address,
  219. fail(e){
  220. console.log(e,'连接失败');
  221. }
  222. })
  223. },
  224. }
  225. }
  226. </script>
  227. <style lang="scss">
  228. .search-top {
  229. // position: fixed;
  230. // top: 0;
  231. // z-index: 99;
  232. }
  233. .shop {
  234. // margin-top: 20rpx;
  235. background: #ffffff;
  236. padding: 0 12rpx;
  237. .shop-title {
  238. padding: 30rpx 0 20rpx;
  239. display: flex;
  240. align-items: center;
  241. border-bottom: 1px solid #e3e6e7;
  242. .shop-item {
  243. width: 33%;
  244. display: flex;
  245. align-items: center;
  246. justify-content: center;
  247. .sitem-font {
  248. font-size: 26rpx;
  249. font-family: PingFang SC;
  250. font-weight: bold;
  251. color: #333333;
  252. }
  253. .jt-down {
  254. width: 10rpx;
  255. height: 8rpx;
  256. margin-left: 12rpx;
  257. }
  258. }
  259. }
  260. }
  261. .shop-list-wrap {
  262. // background-color: red;
  263. padding-top: 20rpx;
  264. }
  265. .djq-wrap {
  266. width: 701rpx;
  267. // height: 255rpx;
  268. background: #FFFFFF;
  269. box-shadow: 0px 0px 27rpx 0px rgba(50, 50, 52, 0.06);
  270. border-radius: 20rpx;
  271. margin: 0 auto 20rpx;
  272. padding: 23rpx 22rpx;
  273. &:last-of-type {
  274. margin-bottom: 0;
  275. }
  276. .djq-img {
  277. flex-shrink: 0;
  278. width: 150rpx;
  279. height: 150rpx;
  280. border-radius: 10rpx;
  281. }
  282. .djq-right {
  283. padding-left: 15rpx;
  284. flex-grow: 1;
  285. .djq-tit {
  286. font-size: 34rpx;
  287. font-weight: bold;
  288. color: #333333;
  289. line-height: 52rpx;
  290. .djq-name {
  291. max-width: 300rpx;
  292. }
  293. .djq-dis {
  294. flex-shrink: 0;
  295. image {
  296. width: 20rpx;
  297. height: 28rpx;
  298. margin-right: 10rpx;
  299. }
  300. font-size: 22rpx;
  301. font-weight: 500;
  302. color: #666666;
  303. }
  304. }
  305. .djq-dz {
  306. width: 100%;
  307. font-size: 24rpx;
  308. font-weight: 500;
  309. color: #666666;
  310. }
  311. .djq-hd {
  312. width: 100%;
  313. .buy-info {
  314. display: inline-block;
  315. height: 32rpx;
  316. border-radius: 16rpx 16rpx 16rpx 0px;
  317. line-height: 32rpx;
  318. font-size: 20rpx;
  319. font-weight: 500;
  320. color: #FF440D;
  321. padding: 0 15rpx;
  322. background-color: #fff;
  323. }
  324. .hd-btn {
  325. image {
  326. width: 46rpx;
  327. height: 46rpx;
  328. }
  329. }
  330. }
  331. }
  332. }
  333. .left-btm {
  334. height: 50rpx;
  335. .j-logo {
  336. width: 32rpx;
  337. line-height: 33rpx;
  338. background: linear-gradient(-48deg, #FFA30B, #FFD158);
  339. border-radius: 13rpx;
  340. font-size: 21rpx;
  341. font-weight: 500;
  342. color: #FFFFFF;
  343. text-align: center;
  344. }
  345. .j-price {
  346. font-size: 27rpx;
  347. font-weight: bold;
  348. color: #FF4C4C;
  349. margin: 0 10rpx 0 5rpx;
  350. }
  351. .j-zk {
  352. height: 31rpx;
  353. border: 1rpx solid #FF4C4C;
  354. border-radius: 7rpx;
  355. line-height: 31rpx;
  356. padding: 0 8rpx;
  357. font-size: 20rpx;
  358. font-weight: bold;
  359. color: #FF4C4C;
  360. margin-right: 5rpx;
  361. }
  362. .j-name {
  363. font-size: 23rpx;
  364. font-weight: bold;
  365. color: #333333;
  366. }
  367. }
  368. .search {
  369. justify-content: flex-start;
  370. padding: 10rpx 32rpx 20rpx;
  371. align-items: center;
  372. background-color: #fff;
  373. .search-btn {
  374. display: inline-block;
  375. // flex-grow: ;
  376. flex-shrink: 0;
  377. padding: 0 0 0 20rpx;
  378. font-size: 32rpx;
  379. color: #FF4C4C;
  380. z-index: 99;
  381. }
  382. .address {
  383. width: 32rpx;
  384. height: 38rpx;
  385. }
  386. .shop-name {
  387. height: 38rpx;
  388. position: relative;
  389. top: -4rpx;
  390. z-index: 100;
  391. font-size: 30rpx;
  392. font-family: PingFang SC;
  393. font-weight: 500;
  394. padding-left: 10rpx;
  395. }
  396. .shop-jt {
  397. margin-left: 8rpx;
  398. width: 16rpx;
  399. height: 10rpx;
  400. }
  401. .input-box {
  402. margin-left: 10rpx;
  403. position: relative;
  404. z-index: 99;
  405. width: 710rpx;
  406. height: 60rpx;
  407. background: #EEEEEE;
  408. border-radius: 30rpx;
  409. .input-content {
  410. position: relative;
  411. z-index: 11;
  412. border-radius: 99rpx;
  413. flex-grow: 1;
  414. padding: 5rpx 30rpx;
  415. background: #EEEEEE;
  416. .iconsearch {
  417. font-size: 50rpx;
  418. color: #CBCBCB;
  419. }
  420. .input {
  421. margin-left: 19rpx;
  422. flex-grow: 1;
  423. input {
  424. font-size: 28rpx;
  425. color: #000;
  426. }
  427. }
  428. }
  429. .input-button {
  430. padding-left: 20rpx;
  431. font-size: $font-base;
  432. height: 100%;
  433. }
  434. }
  435. }
  436. </style>