shopList.vue 8.1 KB

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