address.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. uni.switchTab({
  95. url: '../../pages/tabbar/user/index'
  96. })
  97. }
  98. },
  99. addAddressClick() {
  100. if (this.type == 1 || this.type == 2) {
  101. uni.navigateTo({
  102. url: 'addAddress?type=1&ordertype=1'
  103. })
  104. } else {
  105. uni.navigateTo({
  106. url: 'addAddress?type=1'
  107. })
  108. }
  109. },
  110. getAddressData() {
  111. // uni.showLoading({
  112. // mask: true,
  113. // title: '加载中...',
  114. // })
  115. NET.request(API.QueryMemberAddres, {
  116. page: this.page,
  117. pageSize: this.pageSize
  118. }, 'GET').then((res) => {
  119. this.addresList = res.data
  120. if (res.data.list.length == 0) {
  121. this.loadingType = 1
  122. this.page = this.page
  123. }
  124. for (let i = 0; i < res.data.list.length; i++) {
  125. this.addresList.list[i].username1 = this.addresList.list[i].receiveName.slice(0, 1)
  126. }
  127. this.addresListlist = this.addresListlist.concat(res.data.list)
  128. this.addresListlist.forEach((item) => {
  129. item.receivePhone = hidden(item.receivePhone, 3, 4)
  130. })
  131. uni.hideLoading()
  132. })
  133. .catch((err) => {
  134. uni.hideLoading()
  135. })
  136. },
  137. editAdress(id, item) {
  138. uni.setStorageSync('editAddress', JSON.stringify(this.addresList.list[id]))
  139. uni.navigateTo({
  140. url: 'addAddress?type=2&receiveId=' + item.receiveId
  141. })
  142. },
  143. itemTap(item) {
  144. if (this.type == 1 || this.type == 2) {
  145. uni.setStorageSync('receiveItem', item)
  146. uni.navigateTo({
  147. url: '../../pages_category_page1/orderModule/orderConfirm?receiveId=' + item
  148. .receiveId + '&type=' + this.type
  149. })
  150. }
  151. },
  152. // 微信导入
  153. wxAddFn() {
  154. const self = this
  155. uni.chooseAddress({
  156. success(res) {
  157. self.addData.username = res.userName
  158. self.addData.phone = res.telNumber
  159. self.addData.ssqText = `${res.provinceName}-${res.cityName}-${res.countyName}`
  160. self.addData.defaultRegion = self.addData.ssqText.split('-')
  161. self.addData.address = res.detailInfo
  162. self.addData.province = res.provinceName
  163. self.addData.city = res.cityName
  164. // uni.showLoading({
  165. // mask: true,
  166. // title: '导入中...',
  167. // })
  168. setTimeout(() => {
  169. uni.hideLoading()
  170. uni.navigateTo({
  171. url: 'addAddress?type=3&wxAddressData=' + JSON.stringify(self
  172. .addData)
  173. })
  174. }, 500)
  175. },
  176. fail: (res) => {
  177. }
  178. })
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. .container {
  185. padding: 0 24rpx;
  186. .addAddress {
  187. border-top: 2rpx solid #F3F4F5;
  188. padding-top: 30rpx;
  189. }
  190. .emptyAddress-box {
  191. display: flex;
  192. justify-content: center;
  193. flex-direction: column;
  194. align-items: center;
  195. margin-top: 50%;
  196. .emptyAddress {
  197. width: 186upx;
  198. height: 150upx;
  199. }
  200. text {
  201. margin-top: 40upx;
  202. color: #999999;
  203. }
  204. }
  205. .addAddress-box {
  206. position: fixed;
  207. bottom: 50upx;
  208. left: 30upx;
  209. .addAddress {
  210. width: 690upx;
  211. height: 100upx;
  212. color: #FFEBC4;
  213. text-align: center;
  214. background: #333333;
  215. }
  216. }
  217. .wxAddressNBox {
  218. position: fixed;
  219. bottom: 50upx;
  220. width: 100%;
  221. left: 0;
  222. .btnBox {
  223. width: 100%;
  224. background: #FFFFFF;
  225. height: 120rpx;
  226. padding: 0 50rpx;
  227. .btn {
  228. width: 300rpx;
  229. background: #FFFFFF;
  230. height: 90rpx;
  231. line-height: 90rpx;
  232. border: 2rpx solid #E4E5E6;
  233. text-align: center;
  234. }
  235. .addAddressBtn {
  236. color: #FFEBC4;
  237. background: #333333;
  238. border: 2rpx solid #333333;
  239. }
  240. .wxAddress {
  241. image {
  242. width: 45rpx;
  243. height: 37rpx;
  244. margin-right: 20rpx;
  245. }
  246. }
  247. }
  248. }
  249. .addAddress-content {
  250. display: flex;
  251. align-items: center;
  252. justify-content: space-between;
  253. padding-bottom: 40rpx;
  254. margin-bottom: 40rpx;
  255. border-bottom: 2rpx solid #F3F4F5;
  256. .address-detail {
  257. .userName {
  258. margin-bottom: 15rpx;
  259. }
  260. }
  261. .lable {
  262. padding: 3rpx 10rpx;
  263. background: rgba(153, 153, 153, 0.2);
  264. border-radius: 4rpx;
  265. font-size: 24rpx;
  266. font-weight: 500;
  267. color: rgba(102, 102, 102, 1);
  268. }
  269. .def {
  270. padding: 3rpx 10rpx;
  271. font-size: 20rpx;
  272. font-weight: 400;
  273. color: #C5AA7B !important;
  274. background: rgba(197, 170, 123, 0.2) !important;
  275. }
  276. .user-address {
  277. font-size: 28rpx;
  278. margin-left: 10rpx;
  279. }
  280. .address-hesd {
  281. height: 70upx;
  282. width: 70upx;
  283. background-color: #BBBBBB;
  284. color: #FFFFFF;
  285. border-radius: 50%;
  286. line-height: 70upx;
  287. text-align: center;
  288. }
  289. .defaultAD-box {
  290. width: 455upx;
  291. .default-textBox {
  292. padding-right: 20upx;
  293. width: 80upx;
  294. }
  295. .default-content {
  296. width: 435upx;
  297. }
  298. .default-text {
  299. color: #C5AA7B;
  300. background-color: #FFE4CC;
  301. height: 36upx;
  302. width: 60upx;
  303. font-size: 26upx;
  304. border-radius: 4upx;
  305. align-items: center;
  306. line-height: 36upx;
  307. }
  308. }
  309. .editIcon {
  310. width: 50rpx;
  311. height: 50rpx;
  312. display: block;
  313. background: url("../../static/images/origin/addEdit.png") no-repeat center center;
  314. background-size: contain;
  315. }
  316. }
  317. }
  318. </style>