index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. <!-- #ifdef H5 -->
  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/v2/nodata_5.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. status: 'nomore', //上拉刷新状态
  72. };
  73. },
  74. onLoad(options) {
  75. this.couponId = options.couponId
  76. this.pageList()
  77. },
  78. methods: {
  79. pageList() {
  80. this.pageNum = 1
  81. this.total = 0
  82. this.list = []
  83. this.getList()
  84. },
  85. getList() {
  86. uni.showLoading({
  87. title: '加载中'
  88. });
  89. $http.post(`/api/v1/mp/user/mine/coupon/channel/list?pageNum=${this.pageNum}&pageSize=20`, { ...this.info,
  90. couponId: this.couponId }).then(
  91. res => {
  92. uni.hideLoading();
  93. if (res.code == 0) {
  94. this.list = this.list.concat(res.rows)
  95. this.list.forEach(item => {
  96. item.addressAll = `${item.province} ${item.city} ${item.area} ${item.address}`
  97. })
  98. this.total = res.total
  99. }
  100. }).catch(() => {
  101. uni.hideLoading();
  102. })
  103. },
  104. selectAddress() {
  105. this.addressShow = true
  106. },
  107. cancel() {
  108. this.addressShow = false
  109. },
  110. confirmAddress(obj) {
  111. this.info = {
  112. provinceId: obj.provinceId,
  113. cityId: obj.cityId,
  114. }
  115. this.confirm = obj.cityShow
  116. this.addressShow = false
  117. this.pageList()
  118. },
  119. copyDeliveryFlowId(data) {
  120. uni.setClipboardData({ data });
  121. // #ifdef MP-ALIPAY
  122. this.$refs.uToast.show({ message: "内容已复制" })
  123. // #endif
  124. },
  125. },
  126. onReachBottom() {
  127. if (this.total < this.pageNum * 20) return;
  128. this.status = 'loading';
  129. ++this.pageNum
  130. if (this.total < this.pageNum * 20) this.status = 'nomore';
  131. else this.status = 'loading';
  132. this.getList()
  133. },
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .address-wrap {
  138. .header-title {
  139. background-color: #fff;
  140. padding: 0 20rpx;
  141. display: flex;
  142. height: 90rpx;
  143. box-shadow: 0 5rpx 5rpx #ececec;
  144. line-height: 90rpx;
  145. .adderss-select {
  146. margin-right: 10rpx;
  147. font-size: 30rpx;
  148. }
  149. .adderss-select-icon {
  150. display: inline-block;
  151. margin-top: 34rpx;
  152. }
  153. }
  154. .content {
  155. margin: 20rpx 10rpx;
  156. padding: 0 25rpx;
  157. border-radius: 12rpx;
  158. background-color: #fff;
  159. .address-box {
  160. width: 100%;
  161. padding: 30rpx 0;
  162. border-bottom: 2rpx solid #dadbde;
  163. .store-name {
  164. font-size: 30rpx;
  165. color: #000;
  166. margin-bottom: 15rpx;
  167. }
  168. .store-address {
  169. text {
  170. font-size: 24rpx;
  171. color: #999;
  172. }
  173. view {
  174. margin-left: 8rpx;
  175. background-color: rgba(153, 153, 153, .1);
  176. display: inline-block;
  177. width: 80rpx;
  178. height: 40rpx;
  179. line-height: 34rpx;
  180. text-align: center;
  181. font-size: 24rpx;
  182. border-radius: 8rpx;
  183. }
  184. }
  185. }
  186. .address-box:last-child {
  187. border-bottom: none;
  188. }
  189. }
  190. }
  191. .empty {
  192. height: 60vh;
  193. .center {
  194. text-align: center;
  195. &-img {
  196. width: 228rpx;
  197. height: 320rpx;
  198. }
  199. &-font {
  200. font-size: 30rpx;
  201. font-weight: 400;
  202. color: #999999;
  203. margin-bottom: 250rpx;
  204. }
  205. }
  206. }
  207. </style>