shopStore.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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,index) 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/dh.png" mode=""></image>
  27. 距离{{item.range}}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. <!-- #ifdef H5 -->
  42. <image src="../../static/icon/dh.png" mode=""
  43. @click.stop="toGaodeMap(item.latitude,item.longitude,item.name)"></image>
  44. <!-- #endif -->
  45. <!-- #ifdef APP -->
  46. <image src="../../static/icon/dh.png" mode="" @click.stop="toGaodeMap(index)"></image>
  47. <!-- #endif -->
  48. </view>
  49. </view>
  50. </view>
  51. <view class="" style="padding: 10rpx 0 0 0;">
  52. <view class="left-btm flex f-j-s" v-for="itemt in item.coupon">
  53. <view class="j-logo">
  54. </view>
  55. <view class="j-price">
  56. <text>¥</text>{{itemt.price}}
  57. </view>
  58. <view class="j-zk">
  59. {{(((itemt.price*10)/(itemt.ot_price*1)).toFixed(1))}}折
  60. </view>
  61. <view class="j-name">
  62. {{itemt.store_name}}
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <uni-load-more :status="loadingType"></uni-load-more>
  69. </scroll-view>
  70. </view>
  71. </template>
  72. <script>
  73. import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  74. // #ifdef H5
  75. import {
  76. weixindata,
  77. shareLoad
  78. } from '@/utils/wxAuthorized';
  79. import {
  80. jsonp
  81. } from 'vue-jsonp'
  82. // #endif
  83. import {
  84. mapState,
  85. mapMutations
  86. } from 'vuex';
  87. import {
  88. getStoreList
  89. } from '@/api/shop.js'
  90. export default {
  91. components: {
  92. empty
  93. },
  94. data() {
  95. return {
  96. id: '',
  97. page: 1,
  98. limit: 10,
  99. shopList: [],
  100. name: '',
  101. height: '',
  102. loadingType: 'more',
  103. loaded: false,
  104. latitude: '',
  105. longitude: '',
  106. }
  107. },
  108. computed: {
  109. ...mapState(['loginInterceptor', 'baseURL']),
  110. },
  111. onLoad(opt) {
  112. let obj = this
  113. if (opt.id) {
  114. this.id = opt.id
  115. }
  116. // var urlStr = encodeURI( `https://uri.amap.com/marker?position=${obj.info.longitude},${obj.info.latitude}&name=${obj.info.name}`)
  117. // plus.runtime.openURL(urlStr);
  118. //先获取当前地理位置
  119. uni.getLocation({
  120. type: 'wgs84',
  121. success: function(res) {
  122. console.log(res, 'res');
  123. obj.latitude = res.latitude
  124. obj.longitude = res.longitude
  125. console.log('当前位置的经度:', obj.latitude, obj.longitude, );
  126. obj.getStoreList()
  127. // console.log('当前位置的纬度:' + res.latitude);
  128. },fail: (err) => {
  129. console.log(err,'rrrr');
  130. }
  131. })
  132. },
  133. onShow() {
  134. // this.getStoreList()
  135. },
  136. onReachBottom() {
  137. },
  138. onReady() {
  139. var obj = this;
  140. uni.getSystemInfo({
  141. success: resu => {
  142. const query = uni.createSelectorQuery();
  143. query.select('.shop-list-wrap').boundingClientRect();
  144. query.exec(function(res) {
  145. obj.height = resu.windowHeight - res[0].top + 'px';
  146. });
  147. },
  148. fail: res => {}
  149. });
  150. },
  151. methods: {
  152. // 调用高德
  153. toGaodeMap(index) {
  154. let obj = this
  155. // console.log(obj.shopList[index],'index');
  156. console.log(obj.shopList[index].longitude,obj.shopList[index].latitude,obj.shopList[index].name,'调用高德');
  157. var urlStr = encodeURI( `https://uri.amap.com/marker?position=${obj.shopList[index].longitude},${obj.shopList[index].latitude}&name=${obj.shopList[index].name}`)
  158. plus.runtime.openURL(urlStr);
  159. },
  160. navTo(url) {
  161. console.log('没点进去,没有执行');
  162. uni.navigateTo({
  163. url,
  164. fail() {
  165. console.log(url, '没点进去');
  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. uni.makePhoneCall({
  182. phoneNumber: phone //仅为示例
  183. });
  184. },
  185. // 导航
  186. dh(item) {
  187. wx.openLocation({
  188. latitude: item.latitude * 1,
  189. longitude: item.longitude * 1,
  190. name: item.name,
  191. address: item.detailed_address
  192. })
  193. },
  194. //app导航到地图中
  195. getLocation(item) {
  196. uni.chooseLocation({
  197. latitude: item.latitude,
  198. longitude: item.longitude,
  199. success: function(res) {
  200. console.log(res, '当前地位置');
  201. console.log('位置名称:' + res.name);
  202. console.log('详细地址:' + res.address);
  203. console.log('纬度:' + res.latitude);
  204. console.log('经度:' + res.longitude);
  205. }
  206. });
  207. },
  208. getStoreList() {
  209. let obj = this
  210. if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  211. return
  212. }
  213. obj.loadingType = 'loading'
  214. console.log(obj.latitude, obj.longitude, '传给接口');
  215. getStoreList({
  216. cate_id: obj.id,
  217. name: obj.name,
  218. latitude: obj.latitude,
  219. longitude: obj.longitude,
  220. page: obj.page,
  221. limit: obj.limit,
  222. // address: obj.$store.state.chooseDistrict,
  223. }).then(res => {
  224. console.log(res,'23232')
  225. obj.shopList = obj.shopList.concat(res.data.list)
  226. obj.page++
  227. if (obj.limit == res.data.list.length) {
  228. obj.loadingType = 'more'
  229. } else {
  230. obj.loadingType = 'noMore'
  231. }
  232. obj.loaded = true
  233. })
  234. },
  235. // 调用高德
  236. // toGaodeMap(latitude, longitude, address) {
  237. // console.log('选择高德', latitude, longitude, address);
  238. // window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
  239. // },
  240. }
  241. }
  242. </script>
  243. <style lang="scss">
  244. .search-top {
  245. // position: fixed;
  246. // top: 0;
  247. // z-index: 99;
  248. }
  249. .shop {
  250. // margin-top: 20rpx;
  251. background: #ffffff;
  252. padding: 0 12rpx;
  253. .shop-title {
  254. padding: 30rpx 0 20rpx;
  255. display: flex;
  256. align-items: center;
  257. border-bottom: 1px solid #e3e6e7;
  258. .shop-item {
  259. width: 33%;
  260. display: flex;
  261. align-items: center;
  262. justify-content: center;
  263. .sitem-font {
  264. font-size: 26rpx;
  265. font-family: PingFang SC;
  266. font-weight: bold;
  267. color: #333333;
  268. }
  269. .jt-down {
  270. width: 10rpx;
  271. height: 8rpx;
  272. margin-left: 12rpx;
  273. }
  274. }
  275. }
  276. }
  277. .shop-list-wrap {
  278. // background-color: red;
  279. padding-top: 20rpx;
  280. }
  281. .djq-wrap {
  282. width: 701rpx;
  283. // height: 255rpx;
  284. background: #FFFFFF;
  285. box-shadow: 0px 0px 27rpx 0px rgba(50, 50, 52, 0.06);
  286. border-radius: 20rpx;
  287. margin: 0 auto 20rpx;
  288. padding: 23rpx 22rpx;
  289. &:last-of-type {
  290. margin-bottom: 0;
  291. }
  292. .djq-img {
  293. flex-shrink: 0;
  294. width: 150rpx;
  295. height: 150rpx;
  296. border-radius: 10rpx;
  297. }
  298. .djq-right {
  299. flex-grow: 1;
  300. .djq-tit {
  301. font-size: 34rpx;
  302. font-weight: bold;
  303. color: #333333;
  304. line-height: 52rpx;
  305. .djq-name {
  306. max-width: 300rpx;
  307. }
  308. .djq-dis {
  309. flex-shrink: 0;
  310. image {
  311. width: 20rpx;
  312. height: 28rpx;
  313. margin-right: 10rpx;
  314. }
  315. font-size: 22rpx;
  316. font-weight: 500;
  317. color: #666666;
  318. }
  319. }
  320. .djq-dz {
  321. width: 100%;
  322. font-size: 24rpx;
  323. font-weight: 500;
  324. color: #666666;
  325. }
  326. .djq-hd {
  327. width: 100%;
  328. // border-bottom: 1rpx solid #EAECED;
  329. .buy-info {
  330. display: inline-block;
  331. height: 32rpx;
  332. border-radius: 16rpx 16rpx 16rpx 0px;
  333. line-height: 32rpx;
  334. font-size: 20rpx;
  335. font-weight: 500;
  336. color: #FF440D;
  337. padding: 0 15rpx;
  338. background-color: #fff;
  339. }
  340. .hd-btn {
  341. image {
  342. width: 46rpx;
  343. height: 46rpx;
  344. }
  345. }
  346. }
  347. }
  348. }
  349. .left-btm {
  350. height: 50rpx;
  351. .j-logo {
  352. width: 32rpx;
  353. line-height: 33rpx;
  354. background: linear-gradient(-48deg, #FFA30B, #FFD158);
  355. border-radius: 13rpx;
  356. font-size: 21rpx;
  357. font-weight: 500;
  358. color: #FFFFFF;
  359. text-align: center;
  360. }
  361. .j-price {
  362. font-size: 27rpx;
  363. font-weight: bold;
  364. color: #FF4C4C;
  365. margin: 0 10rpx 0 5rpx;
  366. }
  367. .j-zk {
  368. height: 31rpx;
  369. border: 1rpx solid #FF4C4C;
  370. border-radius: 7rpx;
  371. line-height: 31rpx;
  372. padding: 0 8rpx;
  373. font-size: 20rpx;
  374. font-weight: bold;
  375. color: #FF4C4C;
  376. margin-right: 5rpx;
  377. }
  378. .j-name {
  379. font-size: 23rpx;
  380. font-weight: bold;
  381. color: #333333;
  382. }
  383. }
  384. .search {
  385. justify-content: flex-start;
  386. padding: 10rpx 32rpx 20rpx;
  387. align-items: center;
  388. background-color: #fff;
  389. .search-btn {
  390. display: inline-block;
  391. // flex-grow: ;
  392. flex-shrink: 0;
  393. padding: 0 0 0 20rpx;
  394. font-size: 32rpx;
  395. color: #FF4C4C;
  396. z-index: 99;
  397. }
  398. .address {
  399. width: 32rpx;
  400. height: 38rpx;
  401. }
  402. .shop-name {
  403. height: 38rpx;
  404. position: relative;
  405. top: -4rpx;
  406. z-index: 100;
  407. font-size: 30rpx;
  408. font-family: PingFang SC;
  409. font-weight: 500;
  410. padding-left: 10rpx;
  411. }
  412. .shop-jt {
  413. margin-left: 8rpx;
  414. width: 16rpx;
  415. height: 10rpx;
  416. }
  417. .input-box {
  418. margin-left: 10rpx;
  419. position: relative;
  420. z-index: 99;
  421. width: 710rpx;
  422. height: 60rpx;
  423. background: #EEEEEE;
  424. border-radius: 30rpx;
  425. .input-content {
  426. position: relative;
  427. z-index: 11;
  428. border-radius: 99rpx;
  429. flex-grow: 1;
  430. padding: 5rpx 30rpx;
  431. background: #EEEEEE;
  432. .iconsearch {
  433. font-size: 50rpx;
  434. color: #CBCBCB;
  435. }
  436. .input {
  437. margin-left: 19rpx;
  438. flex-grow: 1;
  439. input {
  440. font-size: 28rpx;
  441. color: #000;
  442. }
  443. }
  444. }
  445. .input-button {
  446. padding-left: 20rpx;
  447. font-size: $font-base;
  448. height: 100%;
  449. }
  450. }
  451. }
  452. </style>