StoreList.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view :class="['qn-page-' + theme]">
  3. <view style="margin-bottom: 20rpx;">
  4. <view class="store_origin" v-if="store_set.user_origin === 2">
  5. <text class="origin_text">当前位置</text>
  6. <view class="clearfix" style="margin-top: 6rpx;">
  7. <view class="float_left">
  8. <u-icon name="map-fill" color="red" style="font-size: 32rpx;"></u-icon>
  9. <text style="margin-left: 10rpx;">{{ location.address || '请手动选择' }}</text>
  10. </view>
  11. <view class="origin_desc float_right" @click="openLocation">修改位置</view>
  12. </view>
  13. </view>
  14. <view class="store_select clearfix" v-if="store_set.user_origin === 3">
  15. <view class="float_left search_text" @click="openLocation">
  16. <text class="select_text">{{ location.cityName || '请手动选择' }}</text>
  17. <u-icon name="arrow-down" style="font-size: 32rpx;"></u-icon>
  18. </view>
  19. <view class="float_left select_search">
  20. <u-search placeholder="请输入店铺名称" @search="searchShop" v-model="select_origin" :show-action="false" shape="square"></u-search>
  21. </view>
  22. </view>
  23. <view class="banner-view" v-if="store_set.images.length">
  24. <u-swiper mode="rect" border-radius="0" bg-color="#ffffff" :list="store_set.images" height="350"></u-swiper>
  25. </view>
  26. </view>
  27. <view class="store-ul">
  28. <!-- 空白页 -->
  29. <Aempty text="暂无数据" v-if="store_list.length === 0" src="https://onlineimg.qianniao.vip/data.png"></Aempty>
  30. <view class="store-li" v-for="(item, index) in store_list" :key="index">
  31. <view class="store-img" v-if="store_set.user_info.indexOf('商户LOGO') > -1"><image :src="item.license" mode="aspectFill"></image></view>
  32. <view class="store-info">
  33. <view class="store-name ellipsis">{{ item.name }}</view>
  34. <view class="store-desc ellipsis" v-if="store_set.user_info.indexOf('商户简介') > -1">{{ item.desc || '' }}</view>
  35. <view class="store-address ellipsis" v-if="store_set.user_info.indexOf('商户地址') > -1">
  36. <block v-if="item.area">{{ item.area.provinceName }}{{ item.area.cityName }}{{ item.area.districtName }}{{ item.area.address }}</block>
  37. </view>
  38. <view class="store-distance" v-if="store_set.user_info.indexOf('距离') > -1">
  39. <view class="address-icon primary-bg"><u-icon name="map-fill" color="#ffffff" size="24"></u-icon></view>
  40. <text>{{ item.distance / 1000 }}km</text>
  41. </view>
  42. </view>
  43. <view class="in-btn primary-btn" @click="inStore(item)">进店</view>
  44. </view>
  45. </view>
  46. <u-loadmore margin-top="20" :status="loading_status" v-if="store_list.length" />
  47. </view>
  48. </template>
  49. <script>
  50. import PageDesign from '@/components/PageDesign/PageDesign.vue';
  51. export default {
  52. data() {
  53. return {
  54. loading_status: 'loadmore',
  55. select_origin: '',
  56. swiper_list: [],
  57. page: 1,
  58. pageSize: 10,
  59. pageTotal: 0,
  60. store_istrue: true,
  61. store_list: [],
  62. now_sel_address: {},
  63. location: {},
  64. store_set: {
  65. user_info: ['商户LOGO', '商户简介', '商户地址', '距离']
  66. },
  67. latitude: '',
  68. longitude: ''
  69. };
  70. },
  71. onLoad() {
  72. this.location = this.$store.state.locationObj;
  73. (this.latitude = this.location.latitude), (this.longitude = this.location.longitude);
  74. this.getSettingMerchant();
  75. this.getAllApiMerchant();
  76. },
  77. onReachBottom() {
  78. if (this.pageTotal / this.pageSize > this.page) {
  79. this.page += 1;
  80. this.getAllApiMerchant();
  81. }
  82. },
  83. methods: {
  84. inStore(item) {
  85. this.goPage('/pagesT/store/StoreHome?storeData=' + JSON.stringify(item));
  86. },
  87. searchShop() {
  88. this.getAllApiMerchant();
  89. },
  90. openLocation() {
  91. // #ifdef MP-WEIXIN
  92. uni.chooseLocation({
  93. success: res => {
  94. const location = this.$_utils.getArea(res.address);
  95. this.location = location;
  96. (this.latitude = res.latitude), (this.longitude = res.longitude);
  97. }
  98. });
  99. this.getAllApiMerchant();
  100. // #endif
  101. // #ifdef APP-PLUS || MP-TOUTIAO
  102. this.goPage('/pages/index/SearchAddress');
  103. // #endif
  104. },
  105. getAllApiMerchant() {
  106. let params = {
  107. page: this.page,
  108. pageSize: this.pageSize,
  109. latitude: this.latitude,
  110. longitude: this.longitude
  111. };
  112. if (this.store_set.user_origin === 3) {
  113. params.keyword = this.select_origin;
  114. }
  115. this.loading_status = 'loading';
  116. this.$u.api.getAllApiMerchant(params).then(res => {
  117. if (this.page === 1) {
  118. this.store_list = res.data;
  119. } else {
  120. this.store_list = this.store_list.concat(res.data);
  121. }
  122. this.pageTotal = res.pageTotal;
  123. this.loading_status = this.$_utils.loadStatus(this.page, this.pageSize, this.pageTotal);
  124. });
  125. },
  126. getSettingMerchant() {
  127. this.$u.api
  128. .getSettingMerchant({
  129. type: 6
  130. })
  131. .then(res => {
  132. if (JSON.stringify(res.data) === '{}') {
  133. return;
  134. }
  135. this.store_set = res.data;
  136. });
  137. }
  138. }
  139. };
  140. </script>
  141. <style scoped lang="scss">
  142. .banner-view {
  143. background-color: #ffffff;
  144. }
  145. .store_origin {
  146. background-color: #ffffff;
  147. padding: 20rpx 24rpx;
  148. font-size: 30rpx;
  149. .origin_text {
  150. color: #999999;
  151. font-size: 24rpx;
  152. }
  153. .origin_desc {
  154. color: red;
  155. font-size: 24rpx;
  156. }
  157. }
  158. .store_select {
  159. background-color: #ffffff;
  160. padding: 20rpx 24rpx;
  161. font-size: 30rpx;
  162. .search_text {
  163. margin-top: 10rpx;
  164. .select_text {
  165. font-weight: 560;
  166. margin-right: 10rpx;
  167. }
  168. }
  169. .select_search {
  170. width: 520rpx;
  171. margin-left: 30rpx;
  172. }
  173. }
  174. .store-ul {
  175. background-color: #ffffff;
  176. padding: 30rpx 24rpx 0;
  177. margin-bottom: 20rpx;
  178. .store-li {
  179. display: flex;
  180. margin-bottom: 30rpx;
  181. .store-img {
  182. image {
  183. width: 170rpx;
  184. height: 170rpx;
  185. border-radius: 8rpx;
  186. }
  187. }
  188. .store-info {
  189. width: 412rpx;
  190. padding: 0 30rpx;
  191. .store-name {
  192. font-size: 30rpx;
  193. }
  194. .store-desc {
  195. font-size: 24rpx;
  196. color: #999999;
  197. -webkit-line-clamp: 1;
  198. margin-bottom: 10rpx;
  199. }
  200. .store-address {
  201. font-size: 26rpx;
  202. color: #666666;
  203. -webkit-line-clamp: 1;
  204. margin-bottom: 10rpx;
  205. }
  206. .store-distance {
  207. font-size: 24rpx;
  208. color: #666666;
  209. -webkit-line-clamp: 1;
  210. .address-icon {
  211. display: inline-block;
  212. width: 30rpx;
  213. height: 30rpx;
  214. line-height: 30rpx;
  215. text-align: center;
  216. border-radius: 4rpx;
  217. margin-right: 10rpx;
  218. }
  219. }
  220. }
  221. .in-btn {
  222. width: 120rpx;
  223. line-height: 50rpx;
  224. color: #ffffff;
  225. border-radius: 6rpx;
  226. height: 50rpx;
  227. text-align: center;
  228. font-size: 24rpx;
  229. transform: translateY(60rpx);
  230. }
  231. }
  232. }
  233. </style>