shopList.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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. <!-- #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.coupon">
  54. <view class="j-logo">
  55. </view>
  56. <view class="j-price">
  57. <text>¥</text>{{itemt.price}}
  58. </view>
  59. <view class="j-zk">
  60. {{(((itemt.price*10)/(itemt.ot_price*1)).toFixed(1))}}折
  61. </view>
  62. <view class="j-name">
  63. {{itemt.store_name}}
  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. this.getStoreList()
  111. },
  112. onShow() {
  113. },
  114. onReachBottom() {
  115. },
  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. navTo(url) {
  131. uni.navigateTo({
  132. url,
  133. fail() {
  134. uni.switchTab({
  135. url
  136. })
  137. }
  138. })
  139. },
  140. search() {
  141. let obj = this
  142. obj.shopList = []
  143. obj.loadingType = 'more'
  144. obj.page = 1
  145. obj.getStoreList()
  146. },
  147. // 拨打电话
  148. makeCall(phone) {
  149. uni.makePhoneCall({
  150. phoneNumber: phone //仅为示例
  151. });
  152. },
  153. // 导航
  154. dh(item) {
  155. wx.openLocation({
  156. latitude: item.latitude * 1,
  157. longitude: item.longitude * 1,
  158. name: item.name,
  159. address: item.detailed_address
  160. })
  161. },
  162. getStoreList() {
  163. let obj = this
  164. if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  165. return
  166. }
  167. obj.loadingType = 'loading'
  168. getStoreList({
  169. cate_id: obj.id,
  170. name: obj.name,
  171. latitude: obj.latitude,
  172. longitude: obj.longitude,
  173. page: obj.page,
  174. limit: obj.limit,
  175. // address: obj.$store.state.chooseDistrict,
  176. }).then(res => {
  177. console.log(res)
  178. obj.shopList = obj.shopList.concat(res.data.list)
  179. obj.page++
  180. if (obj.limit == res.data.list.length) {
  181. obj.loadingType = 'more'
  182. } else {
  183. obj.loadingType = 'noMore'
  184. }
  185. obj.loaded = true
  186. })
  187. },
  188. // 调用高德
  189. toGaodeMap(latitude, longitude, address) {
  190. console.log('选择高德', latitude, longitude, address);
  191. window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
  192. },
  193. }
  194. }
  195. </script>
  196. <style lang="scss">
  197. .search-top {
  198. // position: fixed;
  199. // top: 0;
  200. // z-index: 99;
  201. }
  202. .shop {
  203. // margin-top: 20rpx;
  204. background: #ffffff;
  205. padding: 0 12rpx;
  206. .shop-title {
  207. padding: 30rpx 0 20rpx;
  208. display: flex;
  209. align-items: center;
  210. border-bottom: 1px solid #e3e6e7;
  211. .shop-item {
  212. width: 33%;
  213. display: flex;
  214. align-items: center;
  215. justify-content: center;
  216. .sitem-font {
  217. font-size: 26rpx;
  218. font-family: PingFang SC;
  219. font-weight: bold;
  220. color: #333333;
  221. }
  222. .jt-down {
  223. width: 10rpx;
  224. height: 8rpx;
  225. margin-left: 12rpx;
  226. }
  227. }
  228. }
  229. }
  230. .shop-list-wrap {
  231. // background-color: red;
  232. padding-top: 20rpx;
  233. }
  234. .djq-wrap {
  235. width: 701rpx;
  236. // height: 255rpx;
  237. background: #FFFFFF;
  238. box-shadow: 0px 0px 27rpx 0px rgba(50, 50, 52, 0.06);
  239. border-radius: 20rpx;
  240. margin: 0 auto 20rpx;
  241. padding: 23rpx 22rpx;
  242. &:last-of-type {
  243. margin-bottom: 0;
  244. }
  245. .djq-img {
  246. flex-shrink: 0;
  247. width: 150rpx;
  248. height: 150rpx;
  249. border-radius: 10rpx;
  250. }
  251. .djq-right {
  252. flex-grow: 1;
  253. .djq-tit {
  254. font-size: 34rpx;
  255. font-weight: bold;
  256. color: #333333;
  257. line-height: 52rpx;
  258. .djq-name {
  259. max-width: 300rpx;
  260. }
  261. .djq-dis {
  262. flex-shrink: 0;
  263. image {
  264. width: 20rpx;
  265. height: 28rpx;
  266. margin-right: 10rpx;
  267. }
  268. font-size: 22rpx;
  269. font-weight: 500;
  270. color: #666666;
  271. }
  272. }
  273. .djq-dz {
  274. width: 100%;
  275. font-size: 24rpx;
  276. font-weight: 500;
  277. color: #666666;
  278. }
  279. .djq-hd {
  280. width: 100%;
  281. border-bottom: 1rpx solid #EAECED;
  282. .buy-info {
  283. display: inline-block;
  284. height: 32rpx;
  285. border-radius: 16rpx 16rpx 16rpx 0px;
  286. line-height: 32rpx;
  287. font-size: 20rpx;
  288. font-weight: 500;
  289. color: #FF440D;
  290. padding: 0 15rpx;
  291. background-color: #fff;
  292. }
  293. .hd-btn {
  294. image {
  295. width: 46rpx;
  296. height: 46rpx;
  297. }
  298. }
  299. }
  300. }
  301. }
  302. .left-btm {
  303. height: 50rpx;
  304. .j-logo {
  305. width: 32rpx;
  306. line-height: 33rpx;
  307. background: linear-gradient(-48deg, #FFA30B, #FFD158);
  308. border-radius: 13rpx;
  309. font-size: 21rpx;
  310. font-weight: 500;
  311. color: #FFFFFF;
  312. text-align: center;
  313. }
  314. .j-price {
  315. font-size: 27rpx;
  316. font-weight: bold;
  317. color: #FF4C4C;
  318. margin: 0 10rpx 0 5rpx;
  319. }
  320. .j-zk {
  321. height: 31rpx;
  322. border: 1rpx solid #FF4C4C;
  323. border-radius: 7rpx;
  324. line-height: 31rpx;
  325. padding: 0 8rpx;
  326. font-size: 20rpx;
  327. font-weight: bold;
  328. color: #FF4C4C;
  329. margin-right: 5rpx;
  330. }
  331. .j-name {
  332. font-size: 23rpx;
  333. font-weight: bold;
  334. color: #333333;
  335. }
  336. }
  337. .search {
  338. justify-content: flex-start;
  339. padding: 10rpx 32rpx 20rpx;
  340. align-items: center;
  341. background-color: #fff;
  342. .search-btn {
  343. display: inline-block;
  344. // flex-grow: ;
  345. flex-shrink: 0;
  346. padding: 0 0 0 20rpx;
  347. font-size: 32rpx;
  348. color: #FF4C4C;
  349. z-index: 99;
  350. }
  351. .address {
  352. width: 32rpx;
  353. height: 38rpx;
  354. }
  355. .shop-name {
  356. height: 38rpx;
  357. position: relative;
  358. top: -4rpx;
  359. z-index: 100;
  360. font-size: 30rpx;
  361. font-family: PingFang SC;
  362. font-weight: 500;
  363. padding-left: 10rpx;
  364. }
  365. .shop-jt {
  366. margin-left: 8rpx;
  367. width: 16rpx;
  368. height: 10rpx;
  369. }
  370. .input-box {
  371. margin-left: 10rpx;
  372. position: relative;
  373. z-index: 99;
  374. width: 710rpx;
  375. height: 60rpx;
  376. background: #EEEEEE;
  377. border-radius: 30rpx;
  378. .input-content {
  379. position: relative;
  380. z-index: 11;
  381. border-radius: 99rpx;
  382. flex-grow: 1;
  383. padding: 5rpx 30rpx;
  384. background: #EEEEEE;
  385. .iconsearch {
  386. font-size: 50rpx;
  387. color: #CBCBCB;
  388. }
  389. .input {
  390. margin-left: 19rpx;
  391. flex-grow: 1;
  392. input {
  393. font-size: 28rpx;
  394. color: #000;
  395. }
  396. }
  397. }
  398. .input-button {
  399. padding-left: 20rpx;
  400. font-size: $font-base;
  401. height: 100%;
  402. }
  403. }
  404. }
  405. </style>