address.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <!-- 地址列表 -->
  2. <template>
  3. <view class="container">
  4. <global-loading />
  5. <view v-if="addresListlist.length" class="pad-bot-140 addAddress">
  6. <view v-for="(item, index) in addresListlist" :key="index" class="addAddress-content flex-row-plus">
  7. <!-- <view class="address-hesd">{{item.username1}}</view> -->
  8. <view class="address-detail" @click="itemTap(item)">
  9. <view class="userName">
  10. <text>{{ item.receiveName }}</text>
  11. <text class="font-color-999 mar-left-30">{{ item.receivePhone }}</text>
  12. </view>
  13. <view class="defaultAD-box">
  14. <text v-if="item.ifDefault" class="def">默认</text>
  15. <text v-else-if="item.label != ''" class="lable font-color-999">{{ item.label }}</text>
  16. <text class="user-address font-color-999">{{ item.receiveAdress }}{{ item.address }}</text>
  17. </view>
  18. </view>
  19. <view class="editIcon" @click="editAdress(index, item)"></view>
  20. </view>
  21. </view>
  22. <view v-else class="emptyAddress-box">
  23. <image class="emptyAddress" src="../../static/images/origin/noAddress.png"></image>
  24. <text>你还没有添加地址哦~</text>
  25. </view>
  26. <!-- #ifdef MP-WEIXIN -->
  27. <view class="wxAddressNBox">
  28. <view class="flex-items btnBox flex-sp-between">
  29. <view class="wxAddress btn flex-items flex-center" @click="wxAddFn">
  30. <image src="../../static/images/origin/weixin2x.png"></image>
  31. <text>微信导入</text>
  32. </view>
  33. <view class="addAddressBtn btn" @click="addAddressClick">添加新地址</view>
  34. </view>
  35. </view>
  36. <!-- #endif -->
  37. <!-- #ifdef H5 || APP-PLUS || MP-ALIPAY -->
  38. <view class="addAddress-box">
  39. <view class="addAddress" @click="addAddressClick">添加新地址</view>
  40. </view>
  41. <!-- #endif -->
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. hidden
  47. } from '../../utils/hidden'
  48. const NET = require('../../utils/request')
  49. const API = require('../../config/api')
  50. export default {
  51. data() {
  52. return {
  53. addresList: [],
  54. headWord: '',
  55. editAddress: [],
  56. type: 0,
  57. addresListlist: [],
  58. page: 1, // 当前页
  59. pageSize: 20, // 每页记录数
  60. loadingType: 0,
  61. addData: {}
  62. }
  63. },
  64. onLoad(options) {
  65. this.type = options.type
  66. },
  67. onShow(options) {
  68. this.addresListlist = []
  69. this.page = 1
  70. this.getAddressData()
  71. },
  72. onBackPress(e) {
  73. if (e.from === 'navigateBack') {
  74. return false
  75. }
  76. this.back()
  77. return true
  78. },
  79. onReachBottom() {
  80. if (this.loadingType == 1) {
  81. uni.stopPullDownRefresh()
  82. } else {
  83. this.page = this.page + 1
  84. this.getAddressData()
  85. }
  86. },
  87. methods: {
  88. back() {
  89. if (this.type == 1 || this.type == 2) {
  90. uni.navigateTo({
  91. url: '../../pages_category_page1/orderModule/orderConfirm?type=' + this.type
  92. })
  93. } else {
  94. this.$switchTab('/pages/tabbar/user/index')
  95. }
  96. },
  97. addAddressClick() {
  98. if (this.type == 1 || this.type == 2) {
  99. uni.navigateTo({
  100. url: 'addAddress?type=1&ordertype=1'
  101. })
  102. } else {
  103. uni.navigateTo({
  104. url: 'addAddress?type=1'
  105. })
  106. }
  107. },
  108. getAddressData() {
  109. // uni.showLoading({
  110. // mask: true,
  111. // title: '加载中...',
  112. // })
  113. NET.request(API.QueryMemberAddres, {
  114. page: this.page,
  115. pageSize: this.pageSize
  116. }, 'GET').then((res) => {
  117. this.addresList = res.data
  118. if (res.data.list.length == 0) {
  119. this.loadingType = 1
  120. this.page = this.page
  121. }
  122. for (let i = 0; i < res.data.list.length; i++) {
  123. this.addresList.list[i].username1 = this.addresList.list[i].receiveName.slice(0, 1)
  124. }
  125. this.addresListlist = this.addresListlist.concat(res.data.list)
  126. this.addresListlist.forEach((item) => {
  127. item.receivePhone = hidden(item.receivePhone, 3, 4)
  128. })
  129. uni.hideLoading()
  130. })
  131. .catch((err) => {
  132. uni.hideLoading()
  133. })
  134. },
  135. editAdress(id, item) {
  136. uni.setStorageSync('editAddress', JSON.stringify(this.addresList.list[id]))
  137. uni.navigateTo({
  138. url: 'addAddress?type=2&receiveId=' + item.receiveId
  139. })
  140. },
  141. itemTap(item) {
  142. if (this.type == 1 || this.type == 2) {
  143. uni.setStorageSync('receiveItem', item)
  144. uni.navigateTo({
  145. url: '../../pages_category_page1/orderModule/orderConfirm?receiveId=' + item
  146. .receiveId + '&type=' + this.type
  147. })
  148. }
  149. },
  150. // 微信导入
  151. wxAddFn() {
  152. const self = this
  153. uni.chooseAddress({
  154. success(res) {
  155. self.addData.username = res.userName
  156. self.addData.phone = res.telNumber
  157. self.addData.ssqText = `${res.provinceName}-${res.cityName}-${res.countyName}`
  158. self.addData.defaultRegion = self.addData.ssqText.split('-')
  159. self.addData.address = res.detailInfo
  160. self.addData.province = res.provinceName
  161. self.addData.city = res.cityName
  162. // uni.showLoading({
  163. // mask: true,
  164. // title: '导入中...',
  165. // })
  166. setTimeout(() => {
  167. uni.hideLoading()
  168. uni.navigateTo({
  169. url: 'addAddress?type=3&wxAddressData=' + JSON.stringify(self
  170. .addData)
  171. })
  172. }, 500)
  173. },
  174. fail: (res) => {
  175. }
  176. })
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss">
  182. .container {
  183. padding: 0 24rpx;
  184. .addAddress {
  185. border-top: 2rpx solid #F3F4F5;
  186. padding-top: 30rpx;
  187. }
  188. .emptyAddress-box {
  189. display: flex;
  190. justify-content: center;
  191. flex-direction: column;
  192. align-items: center;
  193. margin-top: 50%;
  194. .emptyAddress {
  195. width: 186upx;
  196. height: 150upx;
  197. }
  198. text {
  199. margin-top: 40upx;
  200. color: #999999;
  201. }
  202. }
  203. .addAddress-box {
  204. position: fixed;
  205. bottom: 50upx;
  206. left: 30upx;
  207. .addAddress {
  208. width: 690upx;
  209. height: 100upx;
  210. color: #FFEBC4;
  211. text-align: center;
  212. background: #333333;
  213. }
  214. }
  215. .wxAddressNBox {
  216. position: fixed;
  217. bottom: 50upx;
  218. width: 100%;
  219. left: 0;
  220. .btnBox {
  221. width: 100%;
  222. background: #FFFFFF;
  223. height: 120rpx;
  224. padding: 0 50rpx;
  225. .btn {
  226. width: 300rpx;
  227. background: #FFFFFF;
  228. height: 90rpx;
  229. line-height: 90rpx;
  230. border: 2rpx solid #E4E5E6;
  231. text-align: center;
  232. }
  233. .addAddressBtn {
  234. color: #FFEBC4;
  235. background: #333333;
  236. border: 2rpx solid #333333;
  237. }
  238. .wxAddress {
  239. image {
  240. width: 45rpx;
  241. height: 37rpx;
  242. margin-right: 20rpx;
  243. }
  244. }
  245. }
  246. }
  247. .addAddress-content {
  248. display: flex;
  249. align-items: center;
  250. justify-content: space-between;
  251. padding-bottom: 40rpx;
  252. margin-bottom: 40rpx;
  253. border-bottom: 2rpx solid #F3F4F5;
  254. .address-detail {
  255. .userName {
  256. margin-bottom: 15rpx;
  257. }
  258. }
  259. .lable {
  260. padding: 3rpx 10rpx;
  261. background: rgba(153, 153, 153, 0.2);
  262. border-radius: 4rpx;
  263. font-size: 24rpx;
  264. font-weight: 500;
  265. color: rgba(102, 102, 102, 1);
  266. }
  267. .def {
  268. padding: 3rpx 10rpx;
  269. font-size: 20rpx;
  270. font-weight: 400;
  271. color: #C5AA7B !important;
  272. background: rgba(197, 170, 123, 0.2) !important;
  273. }
  274. .user-address {
  275. font-size: 28rpx;
  276. margin-left: 10rpx;
  277. }
  278. .address-hesd {
  279. height: 70upx;
  280. width: 70upx;
  281. background-color: #BBBBBB;
  282. color: #FFFFFF;
  283. border-radius: 50%;
  284. line-height: 70upx;
  285. text-align: center;
  286. }
  287. .defaultAD-box {
  288. width: 455upx;
  289. .default-textBox {
  290. padding-right: 20upx;
  291. width: 80upx;
  292. }
  293. .default-content {
  294. width: 435upx;
  295. }
  296. .default-text {
  297. color: #C5AA7B;
  298. background-color: #FFE4CC;
  299. height: 36upx;
  300. width: 60upx;
  301. font-size: 26upx;
  302. border-radius: 4upx;
  303. align-items: center;
  304. line-height: 36upx;
  305. }
  306. }
  307. .editIcon {
  308. width: 50rpx;
  309. height: 50rpx;
  310. display: block;
  311. background: url("../../static/images/origin/addEdit.png") no-repeat center center;
  312. background-size: contain;
  313. }
  314. }
  315. }
  316. </style>