shopList.vue 9.3 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. <image src="../../static/icon/dh.png" mode=""
  42. @click.stop="toGaodeMap(item.latitude,item.longitude,item.name)"></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/shop.js'
  82. export default {
  83. components: {
  84. empty
  85. },
  86. data() {
  87. return {
  88. page: 1,
  89. limit: 10,
  90. shopList: [],
  91. name: '',
  92. height: '',
  93. loadingType: 'more',
  94. loaded: false
  95. }
  96. },
  97. computed: {
  98. ...mapState(['loginInterceptor', 'baseURL', 'latitude', 'longitude']),
  99. },
  100. onLoad(opt) {
  101. if (opt.id) {
  102. this.id = opt.id
  103. }
  104. this.getStoreList()
  105. },
  106. onShow() {
  107. },
  108. onReachBottom() {
  109. },
  110. onReady() {
  111. var obj = this;
  112. uni.getSystemInfo({
  113. success: resu => {
  114. const query = uni.createSelectorQuery();
  115. query.select('.shop-list-wrap').boundingClientRect();
  116. query.exec(function(res) {
  117. obj.height = resu.windowHeight - res[0].top + 'px';
  118. });
  119. },
  120. fail: res => {}
  121. });
  122. },
  123. methods: {
  124. navTo(url) {
  125. uni.navigateTo({
  126. url,
  127. fail() {
  128. uni.switchTab({
  129. url
  130. })
  131. }
  132. })
  133. },
  134. search() {
  135. let obj = this
  136. obj.shopList = []
  137. obj.loadingType = 'more'
  138. obj.page = 1
  139. obj.getStoreList()
  140. },
  141. // 拨打电话
  142. makeCall(phone) {
  143. uni.makePhoneCall({
  144. phoneNumber: phone //仅为示例
  145. });
  146. },
  147. // 导航
  148. dh(item) {
  149. // #ifdef H5
  150. weixindata().then(wxOjb => {
  151. console.log(wxOjb, '获取微信');
  152. wxOjb.openLocation({
  153. latitude: item.latitude, // 纬度,浮点数,范围为90 ~ -90
  154. longitude: item.longitude, // 经度,浮点数,范围为180 ~ -180。
  155. name: item.name, // 位置名
  156. address: item.detailed_address, // 地址详情说明
  157. scale: 28, // 地图缩放级别,整型值,范围从1~28。默认为最大
  158. infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
  159. });
  160. });
  161. // #endif
  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. }).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>