index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view>
  3. <!-- #ifdef MP-ALIPAY -->
  4. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="使用范围" leftIconSize="0">
  5. </u-navbar>
  6. <!-- #endif -->
  7. <!-- #ifdef MP-WEIXIN -->
  8. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="使用范围"></u-navbar>
  9. <!-- #endif -->
  10. <!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
  11. <view v-if="pagesNum > 1">
  12. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="使用范围" />
  13. </view>
  14. <view v-else>
  15. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="使用范围">
  16. <view class="nav-left flex" slot="left" @click="$toIndex()">
  17. <u-icon name="arrow-left" size="20" color="#333"></u-icon>
  18. </view>
  19. </u-navbar>
  20. </view>
  21. <!-- #endif -->
  22. <view class="address-wrap">
  23. <view class="header-title" @click="selectAddress">
  24. <view class="adderss-select">
  25. {{ confirm ? confirm : '所有地区' }}
  26. </view>
  27. <view class="adderss-select-icon">
  28. <u-icon name="arrow-right" color="#999" size="12"></u-icon>
  29. </view>
  30. </view>
  31. <view class="content">
  32. <view class="address-box" v-for="(item,index) in list" :key="index">
  33. <text class="store-name" selectable="true" user-select={true}>{{item.siteName}}</text>
  34. <view class="store-address">
  35. <text>地址:{{item.addressAll}}</text>
  36. <view @click="copyDeliveryFlowId(item.addressAll)">复制</view>
  37. </view>
  38. </view>
  39. </view>
  40. <u-loadmore :line="true" v-if="list.length>10" :status="status" :loading-text="'努力加载中'"
  41. :nomore-text="'已经到底了'" />
  42. </view>
  43. <view class="flex empty" v-if="!list.length">
  44. <view class="center">
  45. <image class="center-img"
  46. src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/static/lucky_empty_list.png" mode="scaleToFill">
  47. </image>
  48. <view class="center-font">暂无门店</view>
  49. </view>
  50. </view>
  51. <u-toast ref="uToast"></u-toast>
  52. <address-popup :address-show="addressShow" @cancel="cancel" @confirmAddress="confirmAddress" />
  53. </view>
  54. </template>
  55. <script>
  56. import $http from '@/utils/request.js'
  57. import AddressPopup from '../components/address-popup/address-popup.vue'
  58. export default {
  59. components: {
  60. AddressPopup
  61. },
  62. data() {
  63. return {
  64. list: [],
  65. couponId: null,
  66. addressShow: false,
  67. confirm: '',
  68. info: {},
  69. total: 0,
  70. pageNum: 1,
  71. pagesNum: '',
  72. status: 'nomore', //上拉刷新状态
  73. };
  74. },
  75. onShow() {
  76. this.pagesNum = getCurrentPages().length
  77. },
  78. onLoad(options) {
  79. this.couponId = options.couponId
  80. this.pageList()
  81. },
  82. methods: {
  83. pageList() {
  84. this.pageNum = 1
  85. this.total = 0
  86. this.list = []
  87. this.getList()
  88. },
  89. getList() {
  90. uni.showLoading({
  91. title: '加载中'
  92. });
  93. $http.post(`/api/v1/mp/user/mine/coupon/channel/list?pageNum=${this.pageNum}&pageSize=20`, { ...this.info,
  94. couponId: this.couponId }).then(
  95. res => {
  96. uni.hideLoading();
  97. if (res.code == 0) {
  98. this.list = this.list.concat(res.rows)
  99. this.list.forEach(item => {
  100. item.addressAll = `${item.province} ${item.city} ${item.area} ${item.address}`
  101. })
  102. this.total = res.total
  103. }
  104. }).catch(() => {
  105. uni.hideLoading();
  106. })
  107. },
  108. selectAddress() {
  109. this.addressShow = true
  110. },
  111. cancel() {
  112. this.addressShow = false
  113. },
  114. confirmAddress(obj) {
  115. this.info = {
  116. provinceId: obj.provinceId,
  117. cityId: obj.cityId,
  118. }
  119. this.confirm = obj.cityShow
  120. this.addressShow = false
  121. this.pageList()
  122. },
  123. copyDeliveryFlowId(data) {
  124. uni.setClipboardData({ data });
  125. // #ifdef MP-ALIPAY
  126. this.$refs.uToast.show({ message: "内容已复制" })
  127. // #endif
  128. },
  129. },
  130. onReachBottom() {
  131. if (this.total < this.pageNum * 20) return;
  132. this.status = 'loading';
  133. ++this.pageNum
  134. if (this.total < this.pageNum * 20) this.status = 'nomore';
  135. else this.status = 'loading';
  136. this.getList()
  137. },
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .address-wrap {
  142. .header-title {
  143. background-color: #fff;
  144. padding: 0 20rpx;
  145. display: flex;
  146. height: 90rpx;
  147. box-shadow: 0 5rpx 5rpx #ececec;
  148. line-height: 90rpx;
  149. .adderss-select {
  150. margin-right: 10rpx;
  151. font-size: 30rpx;
  152. }
  153. .adderss-select-icon {
  154. display: inline-block;
  155. margin-top: 34rpx;
  156. }
  157. }
  158. .content {
  159. margin: 20rpx 10rpx;
  160. padding: 0 25rpx;
  161. border-radius: 12rpx;
  162. background-color: #fff;
  163. .address-box {
  164. width: 100%;
  165. padding: 30rpx 0;
  166. border-bottom: 2rpx solid #dadbde;
  167. .store-name {
  168. font-size: 30rpx;
  169. color: #000;
  170. margin-bottom: 15rpx;
  171. }
  172. .store-address {
  173. text {
  174. font-size: 24rpx;
  175. color: #999;
  176. }
  177. view {
  178. margin-left: 8rpx;
  179. background-color: rgba(153, 153, 153, .1);
  180. display: inline-block;
  181. width: 80rpx;
  182. height: 40rpx;
  183. line-height: 34rpx;
  184. text-align: center;
  185. font-size: 24rpx;
  186. border-radius: 8rpx;
  187. }
  188. }
  189. }
  190. .address-box:last-child {
  191. border-bottom: none;
  192. }
  193. }
  194. }
  195. .empty {
  196. height: 60vh;
  197. .center {
  198. text-align: center;
  199. &-img {
  200. width: 228rpx;
  201. height: 320rpx;
  202. }
  203. &-font {
  204. font-size: 30rpx;
  205. font-weight: 400;
  206. color: #999999;
  207. margin-bottom: 250rpx;
  208. }
  209. }
  210. }
  211. </style>