index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <!-- 地址列表 -->
  2. <template>
  3. <view class="address-container">
  4. <JHeader width="50" height="50" title="地址管理" style="padding: 24upx 0 0;"></JHeader>
  5. <view v-if="addressList && addressList.length" class="pad-bot-20 addAddress">
  6. <view v-for="(item, index) in addressList" :key="index" class="addAddress-content flex-row-plus">
  7. <view class="address-detail" @click="itemTap(item)">
  8. <view class="userName">
  9. <text>{{ item.receiveName }}</text>
  10. <text class="font-color-999 mar-left-30">
  11. {{ item.receivePhone.replace(/(\d{3})\d+(\d{4})$/, '$1****$2')
  12. }}
  13. </text>
  14. </view>
  15. <view class="defaultAD-box">
  16. <text v-if="item.ifDefault" class="def">默认</text>
  17. <text v-else-if="item.label != ''" class="lable font-color-999">{{ item.label }}</text>
  18. <text class="user-address font-color-999">{{ item.receiveAdress }}{{ item.address }}</text>
  19. </view>
  20. </view>
  21. <tui-icon name="edit" :size="50" unit="upx" color="#cccccc" @click="editAdress(item)"></tui-icon>
  22. </view>
  23. </view>
  24. <view style="padding-bottom: 45upx;">
  25. <LoadingMore
  26. :status="!isEmpty && !addressList.length
  27. ? 'loading' : !isEmpty && addressList.length && (addressList.length >= addresTotal) ? 'no-more' : ''"
  28. >
  29. </LoadingMore>
  30. <tui-no-data v-if="isEmpty" :fixed="false" style="margin-top: 60upx;">你还没有添加地址哦~</tui-no-data>
  31. </view>
  32. <!-- #ifdef MP-WEIXIN -->
  33. <view class="wxAddressNBox">
  34. <view class="flex-items btnBox flex-sp-between">
  35. <view class="wxAddress btn flex-items flex-center" @click="wxAddFn">
  36. <image src="../../../static/images/new-business/shop/weixin2x.png"></image>
  37. <text>微信导入</text>
  38. </view>
  39. <view class="addAddressBtn btn" @click="addAddressClick">添加新地址</view>
  40. </view>
  41. </view>
  42. <!-- #endif -->
  43. <!-- #ifdef H5 || APP-PLUS || MP-ALIPAY -->
  44. <view class="addAddress-box">
  45. <view class="addAddress" @click="addAddressClick">添加新地址</view>
  46. </view>
  47. <!-- #endif -->
  48. </view>
  49. </template>
  50. <script>
  51. import { T_RECEIVE_ITEM } from '../../../constant'
  52. import { getAllReceiveAddressApi } from '../../../api/anotherTFInterface'
  53. export default {
  54. name: 'Address',
  55. data() {
  56. return {
  57. type: 0,
  58. isEmpty: false,
  59. addressList: [],
  60. addresTotal: 0,
  61. queryInfo: {
  62. page: 1,
  63. pageSize: 20
  64. },
  65. addData: {}
  66. }
  67. },
  68. onLoad(options) {
  69. this.type = options.type
  70. },
  71. onShow() {
  72. this.getAddressDataList()
  73. },
  74. methods: {
  75. addAddressClick() {
  76. if ([1, 2, 3].includes(this.type)) {
  77. uni.navigateTo({
  78. url: '/another-tf/another-serve/addAddress/index?type=1&ordertype=1'
  79. })
  80. } else {
  81. uni.navigateTo({
  82. url: '/another-tf/another-serve/addAddress/index?type=1'
  83. })
  84. }
  85. },
  86. getAddressDataList(isLoadmore) {
  87. uni.showLoading()
  88. getAllReceiveAddressApi(this.queryInfo).then((res) => {
  89. this.addresTotal = res.data.total
  90. if (isLoadmore) {
  91. this.addressList.push(...res.data.list)
  92. } else {
  93. this.addressList = res.data.list
  94. }
  95. this.isEmpty = this.addressList.length === 0
  96. uni.hideLoading()
  97. })
  98. .catch((e) => {
  99. uni.hideLoading()
  100. })
  101. },
  102. editAdress(item) {
  103. uni.navigateTo({
  104. url: '/another-tf/another-serve/addAddress/index?type=2&receiveId=' + item.receiveId
  105. })
  106. },
  107. itemTap(item) {
  108. if (this.type == 1 || this.type == 2) {
  109. uni.setStorageSync(T_RECEIVE_ITEM, item)
  110. uni.navigateBack()
  111. }
  112. },
  113. // 微信导入
  114. wxAddFn() {
  115. const self = this
  116. uni.chooseAddress({
  117. success(res) {
  118. self.addData.username = res.userName
  119. self.addData.phone = res.telNumber
  120. self.addData.ssqText = `${res.provinceName}-${res.cityName}-${res.countyName}`
  121. self.addData.defaultRegion = self.addData.ssqText.split('-')
  122. self.addData.address = res.detailInfo
  123. self.addData.province = res.provinceName
  124. self.addData.city = res.cityName
  125. // uni.showLoading({
  126. // mask: true,
  127. // title: '导入中...',
  128. // })
  129. setTimeout(() => {
  130. uni.hideLoading()
  131. uni.navigateTo({
  132. url: '/another-tf/another-serve/addAddress/index?type=3&wxAddressData=' + JSON.stringify(self.addData)
  133. })
  134. }, 500)
  135. },
  136. fail: (e) => {
  137. }
  138. })
  139. }
  140. },
  141. onReachBottom() {
  142. if (this.addressList.length < this.addresTotal) {
  143. ++this.queryInfo.page
  144. this.getAddressDataList(true)
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .address-container {
  151. padding: 0 24rpx;
  152. .addAddress {
  153. border-top: 2rpx solid #F3F4F5;
  154. padding-top: 30rpx;
  155. }
  156. .addAddress-box {
  157. position: fixed;
  158. bottom: 50upx;
  159. left: 30upx;
  160. .addAddress {
  161. width: 690upx;
  162. height: 100upx;
  163. color: #FFEBC4;
  164. text-align: center;
  165. background: #333333;
  166. }
  167. }
  168. .wxAddressNBox {
  169. position: fixed;
  170. bottom: 50upx;
  171. width: 100%;
  172. left: 0;
  173. .btnBox {
  174. width: 100%;
  175. background: #FFFFFF;
  176. height: 120rpx;
  177. padding: 0 50rpx;
  178. .btn {
  179. width: 300rpx;
  180. background: #FFFFFF;
  181. height: 90rpx;
  182. line-height: 90rpx;
  183. border: 2rpx solid #E4E5E6;
  184. text-align: center;
  185. }
  186. .addAddressBtn {
  187. color: #FFEBC4;
  188. background: #333333;
  189. border: 2rpx solid #333333;
  190. }
  191. .wxAddress {
  192. image {
  193. width: 45rpx;
  194. height: 37rpx;
  195. margin-right: 20rpx;
  196. }
  197. }
  198. }
  199. }
  200. .addAddress-content {
  201. display: flex;
  202. align-items: center;
  203. justify-content: space-between;
  204. padding-bottom: 20rpx;
  205. margin-bottom: 20rpx;
  206. border-bottom: 2rpx solid #F3F4F5;
  207. .address-detail {
  208. .userName {
  209. margin-bottom: 15rpx;
  210. }
  211. }
  212. .lable {
  213. padding: 3rpx 10rpx;
  214. background: rgba(153, 153, 153, 0.2);
  215. border-radius: 4rpx;
  216. font-size: 24rpx;
  217. font-weight: 500;
  218. color: rgba(102, 102, 102, 1);
  219. }
  220. .def {
  221. padding: 3rpx 10rpx;
  222. font-size: 20rpx;
  223. font-weight: 400;
  224. color: #C5AA7B !important;
  225. background: rgba(197, 170, 123, 0.2) !important;
  226. }
  227. .user-address {
  228. font-size: 28rpx;
  229. margin-left: 10rpx;
  230. }
  231. .defaultAD-box {
  232. width: 455upx;
  233. }
  234. }
  235. }
  236. </style>