123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- <!-- 地址列表 -->
- <template>
- <view class="container">
- <global-loading />
- <view v-if="addresListlist.length" class="pad-bot-140 addAddress">
- <view v-for="(item, index) in addresListlist" :key="index" class="addAddress-content flex-row-plus">
- <!-- <view class="address-hesd">{{item.username1}}</view> -->
- <view class="address-detail" @click="itemTap(item)">
- <view class="userName">
- <text>{{ item.receiveName }}</text>
- <text class="font-color-999 mar-left-30">{{ item.receivePhone }}</text>
- </view>
- <view class="defaultAD-box">
- <text v-if="item.ifDefault" class="def">默认</text>
- <text v-else-if="item.label != ''" class="lable font-color-999">{{ item.label }}</text>
- <text class="user-address font-color-999">{{ item.receiveAdress }}{{ item.address }}</text>
- </view>
- </view>
- <view class="editIcon" @click="editAdress(index, item)"></view>
- </view>
- </view>
- <view v-else class="emptyAddress-box">
- <image class="emptyAddress" src="../../static/images/origin/noAddress.png"></image>
- <text>你还没有添加地址哦~</text>
- </view>
- <!-- #ifdef MP-WEIXIN -->
- <view class="wxAddressNBox">
- <view class="flex-items btnBox flex-sp-between">
- <view class="wxAddress btn flex-items flex-center" @click="wxAddFn">
- <image src="../../static/images/origin/weixin2x.png"></image>
- <text>微信导入</text>
- </view>
- <view class="addAddressBtn btn" @click="addAddressClick">添加新地址</view>
- </view>
- </view>
- <!-- #endif -->
- <!-- #ifdef H5 || APP-PLUS || MP-ALIPAY -->
- <view class="addAddress-box">
- <view class="addAddress" @click="addAddressClick">添加新地址</view>
- </view>
- <!-- #endif -->
- </view>
- </template>
- <script>
- import {
- hidden
- } from '../../utils/hidden'
- const NET = require('../../utils/request')
- const API = require('../../config/api')
- export default {
- data() {
- return {
- addresList: [],
- headWord: '',
- editAddress: [],
- type: 0,
- addresListlist: [],
- page: 1, // 当前页
- pageSize: 20, // 每页记录数
- loadingType: 0,
- addData: {}
- }
- },
- onLoad(options) {
- this.type = options.type
- },
- onShow(options) {
- this.addresListlist = []
- this.page = 1
- this.getAddressData()
- },
- onBackPress(e) {
- if (e.from === 'navigateBack') {
- return false
- }
- this.back()
- return true
- },
- onReachBottom() {
- if (this.loadingType == 1) {
- uni.stopPullDownRefresh()
- } else {
- this.page = this.page + 1
- this.getAddressData()
- }
- },
- methods: {
- back() {
- if (this.type == 1 || this.type == 2) {
- uni.navigateTo({
- url: '../../pages_category_page1/orderModule/orderConfirm?type=' + this.type
- })
- } else {
- this.$switchTab('/pages/tabbar/user/index')
- }
- },
- addAddressClick() {
- if (this.type == 1 || this.type == 2) {
- uni.navigateTo({
- url: 'addAddress?type=1&ordertype=1'
- })
- } else {
- uni.navigateTo({
- url: 'addAddress?type=1'
- })
- }
- },
- getAddressData() {
- // uni.showLoading({
- // mask: true,
- // title: '加载中...',
- // })
- NET.request(API.QueryMemberAddres, {
- page: this.page,
- pageSize: this.pageSize
- }, 'GET').then((res) => {
- this.addresList = res.data
- if (res.data.list.length == 0) {
- this.loadingType = 1
- this.page = this.page
- }
- for (let i = 0; i < res.data.list.length; i++) {
- this.addresList.list[i].username1 = this.addresList.list[i].receiveName.slice(0, 1)
- }
- this.addresListlist = this.addresListlist.concat(res.data.list)
- this.addresListlist.forEach((item) => {
- item.receivePhone = hidden(item.receivePhone, 3, 4)
- })
- uni.hideLoading()
- })
- .catch((err) => {
- uni.hideLoading()
- })
- },
- editAdress(id, item) {
- uni.setStorageSync('editAddress', JSON.stringify(this.addresList.list[id]))
- uni.navigateTo({
- url: 'addAddress?type=2&receiveId=' + item.receiveId
- })
- },
- itemTap(item) {
- if (this.type == 1 || this.type == 2) {
- uni.setStorageSync('receiveItem', item)
- uni.navigateTo({
- url: '../../pages_category_page1/orderModule/orderConfirm?receiveId=' + item
- .receiveId + '&type=' + this.type
- })
- }
- },
- // 微信导入
- wxAddFn() {
- const self = this
- uni.chooseAddress({
- success(res) {
- self.addData.username = res.userName
- self.addData.phone = res.telNumber
- self.addData.ssqText = `${res.provinceName}-${res.cityName}-${res.countyName}`
- self.addData.defaultRegion = self.addData.ssqText.split('-')
- self.addData.address = res.detailInfo
- self.addData.province = res.provinceName
- self.addData.city = res.cityName
- // uni.showLoading({
- // mask: true,
- // title: '导入中...',
- // })
- setTimeout(() => {
- uni.hideLoading()
- uni.navigateTo({
- url: 'addAddress?type=3&wxAddressData=' + JSON.stringify(self
- .addData)
- })
- }, 500)
- },
- fail: (res) => {
- }
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .container {
- padding: 0 24rpx;
- .addAddress {
- border-top: 2rpx solid #F3F4F5;
- padding-top: 30rpx;
- }
- .emptyAddress-box {
- display: flex;
- justify-content: center;
- flex-direction: column;
- align-items: center;
- margin-top: 50%;
- .emptyAddress {
- width: 186upx;
- height: 150upx;
- }
- text {
- margin-top: 40upx;
- color: #999999;
- }
- }
- .addAddress-box {
- position: fixed;
- bottom: 50upx;
- left: 30upx;
- .addAddress {
- width: 690upx;
- height: 100upx;
- color: #FFEBC4;
- text-align: center;
- background: #333333;
- }
- }
- .wxAddressNBox {
- position: fixed;
- bottom: 50upx;
- width: 100%;
- left: 0;
- .btnBox {
- width: 100%;
- background: #FFFFFF;
- height: 120rpx;
- padding: 0 50rpx;
- .btn {
- width: 300rpx;
- background: #FFFFFF;
- height: 90rpx;
- line-height: 90rpx;
- border: 2rpx solid #E4E5E6;
- text-align: center;
- }
- .addAddressBtn {
- color: #FFEBC4;
- background: #333333;
- border: 2rpx solid #333333;
- }
- .wxAddress {
- image {
- width: 45rpx;
- height: 37rpx;
- margin-right: 20rpx;
- }
- }
- }
- }
- .addAddress-content {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding-bottom: 40rpx;
- margin-bottom: 40rpx;
- border-bottom: 2rpx solid #F3F4F5;
- .address-detail {
- .userName {
- margin-bottom: 15rpx;
- }
- }
- .lable {
- padding: 3rpx 10rpx;
- background: rgba(153, 153, 153, 0.2);
- border-radius: 4rpx;
- font-size: 24rpx;
- font-weight: 500;
- color: rgba(102, 102, 102, 1);
- }
- .def {
- padding: 3rpx 10rpx;
- font-size: 20rpx;
- font-weight: 400;
- color: #C5AA7B !important;
- background: rgba(197, 170, 123, 0.2) !important;
- }
- .user-address {
- font-size: 28rpx;
- margin-left: 10rpx;
- }
- .address-hesd {
- height: 70upx;
- width: 70upx;
- background-color: #BBBBBB;
- color: #FFFFFF;
- border-radius: 50%;
- line-height: 70upx;
- text-align: center;
- }
- .defaultAD-box {
- width: 455upx;
- .default-textBox {
- padding-right: 20upx;
- width: 80upx;
- }
- .default-content {
- width: 435upx;
- }
- .default-text {
- color: #C5AA7B;
- background-color: #FFE4CC;
- height: 36upx;
- width: 60upx;
- font-size: 26upx;
- border-radius: 4upx;
- align-items: center;
- line-height: 36upx;
- }
- }
- .editIcon {
- width: 50rpx;
- height: 50rpx;
- display: block;
- background: url("../../static/images/origin/addEdit.png") no-repeat center center;
- background-size: contain;
- }
- }
- }
- </style>
|