shopList.vue 9.0 KB

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