shopList.vue 8.7 KB

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