choisestore.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <view class="stores-wrapper">
  3. <scroll-view scroll-y="true" :style="{ height: height }" @scrolltolower="loadDate()" class="scroll-wrapper">
  4. <empty v-if="loaded === true && list.length === 0"></empty>
  5. <view class="store" v-for="item in list" @click="sele(item)">
  6. <view class="store-logo">
  7. <image :src="item.image" mode="" v-if="type == 1"></image>
  8. <text class="store-name clamp">{{ item.name }}</text>
  9. </view>
  10. <view class="store-addr store-base">
  11. 地区:
  12. <text>{{ item.detailed_address }}</text>
  13. </view>
  14. <view class="store-addr store-base">
  15. 电话:
  16. <text>{{ item.phone }}</text>
  17. </view>
  18. <view class="store-addr store-base">
  19. 距离:
  20. <text>{{ item.distance | distance }}</text>
  21. </view>
  22. <view class="store-addr store-base">
  23. 营业时间:
  24. <text>{{ item.day_time }}</text>
  25. </view>
  26. <view class="store-lv ">{{ type == 1 ? '门店' : '自提点' }}</view>
  27. <view class="store-lv " v-if="item.store_user" style="background: #9a0b09;">采购</view>
  28. <!-- <view class="store-can">支持自取</view> -->
  29. <view class="tocall flex" style="background-color: #9a0b09;" @click.stop="tocall(item.phone)">
  30. <image src="../../static/icon/tocall.png" mode=""></image>
  31. </view>
  32. <view class="todh flex" style="background-color: #388bff;" @click.stop="todh(item)">
  33. <image src="../../static/icon/todh.png" mode=""></image>
  34. </view>
  35. </view>
  36. <uni-load-more :status="loadingType"></uni-load-more>
  37. </scroll-view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. loadIndexs,
  43. getIndexData,
  44. getStoreList,
  45. getPointList
  46. } from '@/api/index.js';
  47. import {
  48. mapState,
  49. mapMutations
  50. } from 'vuex';
  51. import empty from '@/components/empty';
  52. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  53. export default {
  54. components: {
  55. empty,
  56. uniLoadMore
  57. },
  58. data() {
  59. return {
  60. list: [],
  61. page: 1,
  62. limit: 10,
  63. loadingType: 'more',
  64. loaded: false,
  65. height: '',
  66. type: 0, //1为选择门店,2为选择自提点
  67. store_id: 0
  68. };
  69. },
  70. onLoad(opt) {
  71. this.type = opt.type;
  72. if (this.type == 2) {
  73. this.store_id = opt.id;
  74. uni.setNavigationBarTitle({
  75. title: '选择自提点'
  76. });
  77. }
  78. this.loadDate();
  79. },
  80. onReady() {
  81. var _this = this;
  82. uni.getSystemInfo({
  83. success: resu => {
  84. const query = uni.createSelectorQuery();
  85. query.select('.scroll-wrapper').boundingClientRect();
  86. query.exec(function(res) {
  87. console.log(res, 'ddddddddddddd');
  88. _this.height = resu.windowHeight - res[0].top + 'px';
  89. console.log('打印页面的剩余高度', _this.height);
  90. });
  91. },
  92. fail: res => {}
  93. });
  94. },
  95. computed: {
  96. ...mapState('user', ['userInfo', 'checkedStore', 'des', 'latlng', 'latitude', 'longitude'])
  97. },
  98. filters: {
  99. distance(val) {
  100. let str = '';
  101. if (val) {
  102. if (val * 1 > 1000) {
  103. return (str = ((val * 1) / 1000).toFixed(1) + 'km');
  104. } else {
  105. return (str = (val * 1).toFixed(0) + 'm');
  106. }
  107. }
  108. return str;
  109. }
  110. },
  111. methods: {
  112. ...mapMutations('user', ['setUserInfo', 'setOrderInfo', 'setStoreInfo', 'setPointInfo', 'setDes']),
  113. loadDate() {
  114. if (this.loadingType === 'loading') {
  115. //防止重复加载
  116. return;
  117. }
  118. //修改当前对象状态为加载中
  119. this.loadingType = 'loading';
  120. if (this.type == 1) {
  121. getStoreList({
  122. page: this.page,
  123. limit: this.limit,
  124. latitude: this.latitude,
  125. longitude: this.longitude
  126. })
  127. .then(({
  128. data
  129. }) => {
  130. console.log(data.list, '店面列表');
  131. let arr = data.list.map(item => {
  132. return item;
  133. });
  134. this.list = this.list.concat(arr);
  135. this.page++;
  136. if (this.limit == data.list.length) {
  137. this.loadingType = 'more';
  138. } else {
  139. this.loadingType = 'noMore';
  140. }
  141. this.$set(this, 'loaded', true);
  142. })
  143. .catch(err => {
  144. console.log(err);
  145. });
  146. } else {
  147. getPointList({
  148. page: this.page,
  149. limit: this.limit,
  150. latitude: this.latitude,
  151. longitude: this.longitude
  152. },
  153. this.store_id
  154. )
  155. .then(({
  156. data
  157. }) => {
  158. console.log(data.list, '自提点列表');
  159. let arr = data.list.map(item => {
  160. return item;
  161. });
  162. this.list = this.list.concat(arr);
  163. this.page++;
  164. if (this.limit == data.list.length) {
  165. this.loadingType = 'more';
  166. } else {
  167. this.loadingType = 'noMore';
  168. }
  169. this.$set(this, 'loaded', true);
  170. })
  171. .catch(err => {
  172. console.log(err);
  173. });
  174. }
  175. },
  176. sele(item) {
  177. this.getCurrentPages;
  178. let obj = this;
  179. let pages = getCurrentPages();
  180. let prevPage = pages[pages.length - 2];
  181. if (this.type == 1) {
  182. this.setStoreInfo(item);
  183. this.setDes(item.distance);
  184. this.setPointInfo('');
  185. uni.navigateBack({
  186. success: function() {
  187. console.log(prevPage.$vm);
  188. prevPage.$vm.refrech(); // 执行上一页的onLoad方法
  189. }
  190. });
  191. } else if (this.type == 2) {
  192. this.setPointInfo(item);
  193. uni.navigateBack({});
  194. }
  195. },
  196. tocall(phone) {
  197. uni.makePhoneCall({
  198. phoneNumber: phone
  199. })
  200. },
  201. // 导航
  202. todh(item) {
  203. console.log(item)
  204. wx.openLocation({
  205. latitude: item.latitude * 1,
  206. longitude: item.longitude * 1,
  207. name: item.name,
  208. address: item.detailed_address
  209. })
  210. }
  211. }
  212. };
  213. </script>
  214. <style lang="scss" scoped>
  215. page {
  216. background-color: #f8f6f6;
  217. height: 100%;
  218. }
  219. .stores-wrapper {
  220. padding-top: 20rpx;
  221. height: 100%;
  222. .store {
  223. width: 710rpx;
  224. // height: 231rpx;
  225. background: #ffffff;
  226. box-shadow: 0px 0px 20rpx 0rpx rgba(50, 50, 52, 0.06);
  227. border-radius: 10rpx;
  228. // margin-bottom: 15rpx;
  229. margin: 0 auto 15rpx;
  230. position: relative;
  231. padding: 25rpx 0 20rpx 20rpx;
  232. .store-logo {
  233. height: 65rpx;
  234. font-size: 32rpx;
  235. font-weight: bold;
  236. color: #333333;
  237. line-height: 65rpx;
  238. margin-bottom: 20rpx;
  239. position: relative;
  240. image {
  241. width: 65rpx;
  242. height: 65rpx;
  243. border-radius: 50%;
  244. }
  245. .store-name {
  246. max-width: 500rpx;
  247. display: inline-block;
  248. padding-left: 12rpx;
  249. position: absolute;
  250. top: 0;
  251. }
  252. }
  253. .store-base {
  254. height: 37rpx;
  255. line-height: 37rpx;
  256. font-size: 24rpx;
  257. font-weight: bold;
  258. color: #333333;
  259. text {
  260. font-weight: normal;
  261. }
  262. }
  263. .store-lv {
  264. display: inline-block;
  265. // width: 60rpx;
  266. padding: 0 10rpx;
  267. height: 40rpx;
  268. background: linear-gradient(-90deg, #dcb876 0%, #eecd92 100%);
  269. border-radius: 5rpx;
  270. text-align: center;
  271. line-height: 40rpx;
  272. color: #fff;
  273. font-size: 23rpx;
  274. position: absolute;
  275. right: 20rpx;
  276. top: 38rpx;
  277. }
  278. .store-can {
  279. width: 113rpx;
  280. height: 44rpx;
  281. border: 2px solid #901b21;
  282. border-radius: 5rpx;
  283. font-size: 23rpx;
  284. text-align: center;
  285. line-height: 44rpx;
  286. font-weight: 500;
  287. color: #901b21;
  288. position: absolute;
  289. right: 20rpx;
  290. bottom: 25rpx;
  291. }
  292. }
  293. }
  294. .tocall {
  295. position: absolute;
  296. right: 25rpx;
  297. bottom: 50rpx;
  298. height: 50rpx;
  299. width: 50rpx;
  300. border-radius: 25rpx;
  301. color: #fff;
  302. font-size: 28rpx;
  303. justify-content: center;
  304. line-height: 50rpx;
  305. image {
  306. width: 32rpx;
  307. height: 32rpx;
  308. }
  309. }
  310. .todh {
  311. position: absolute;
  312. right: 100rpx;
  313. bottom: 50rpx;
  314. height: 50rpx;
  315. width: 50rpx;
  316. border-radius: 25rpx;
  317. color: #fff;
  318. font-size: 28rpx;
  319. justify-content: center;
  320. line-height: 50rpx;
  321. image {
  322. width: 32rpx;
  323. height: 32rpx;
  324. }
  325. }
  326. </style>