123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- <template>
- <view class="container clearfix">
- <view v-if="isEmpty" class="empty-container">
- <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AFmO1AAGxLZjSeDg040.png" mode="aspectFit"></image>
- <view class="txt">您还没有收货地址</view>
- <view class="txt">点击底部按钮添加收货地址吧~~</view>
- <view class="login-btn" @click="addAddress('add')">添加新地址</view>
- </view>
- <view v-else class="address-list" :style="{'height': scrollHeight + 'px'}">
- <scroll-view scroll-y="true" :style="{'height': scrollHeight + 'px'}">
- <view class="list" v-for="(item, index) in addressList" :key="index" @click="checkAddress(item)">
- <view class="wrapper">
- <view class="u-box">
- <text class="name">{{item.shouHuoRen}}</text>
- <text class="mobile">{{item.mobile}}</text>
- </view>
- <view class="u-box b-b">
- <text class="address">收货地址:{{item.province}}{{item.city}}{{item.town}}{{item.address}}</text>
- </view>
- <view class="u-box b-t">
- <view v-if="item.defaultFlag == 1" class="tag-left">
- <view class="tag">默认地址</view>
- </view>
- <view v-else class="tag-left"></view>
- <view class="tag-right">
- <view class="t-b" @click.stop="deleteAddress(item.addressID)">
- <text class="iconfont icon-shanchu"></text>
- <text class="txt">删除</text>
- </view>
- <view class="t-b" @click.stop="addAddress('edit',item)">
- <text class="iconfont icon-bianji"></text>
- <text class="txt">编辑</text>
- </view>
-
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- <view class="add-btn" @click="addAddress('add')">添加新地址</view>
- </view>
- <!-- 删除弹窗 -->
- <model-alert v-if="isShowDelModal"
- :alertText='alertText'
- @btnConfirm ='confirmDetele'>
- </model-alert>
- </view>
- </template>
- <script>
- import authorize from '@/common/config/authorize.js'
- import modelAlert from '@/components/cm-module/modelAlert/modelAlert.vue'
- export default {
- components:{
- modelAlert
- },
- data() {
- return {
- isSelect:false,
- isEmpty:false,
- isLoadMore:false,
- userID:'',
- pageNum:1,
- pageSize:10,
- addressList: [],
- hasNextPage:false,
- allowDataStatus:true,
- wrapperHeight:'100%',
- scrollHeight:'',
- currPage:'',//当前页面
- prevPage:''//上一个页面
- }
- },
- onLoad(option){
- if(option.type=='select'){this.isSelect = true;}
- this.setScrollHeight();
- },
- onReachBottom() {
- if(this.isLoadMore) {
- this.initAddressList();
- }
- },
- methods: {
- setScrollHeight() { // 窗口高度 - 底部距离
- setTimeout(()=> {
- const query = wx.createSelectorQuery().in(this);
- query.selectAll('.add-btn').boundingClientRect();
- query.exec(res => {
- if(res[0][0]){
- let winHeight = this.$api.getWindowHeight(),
- eleTop = res[0][0].top - 1;
- this.scrollHeight = eleTop;
- }
- })
- }, 500)
- },
- initAddressList(){
- this.$api.getComStorage('orderUserInfo').then((resolve) =>{
- this.userID = resolve.userID
- let params = {pageNum:this.pageNum,pageSize:this.pageSize,userID:this.userID}
- this.UserService.QueryAddressList(params).then(response =>{
- if(response.data.results == ''){
- this.isEmpty = true
- }else{
- this.isEmpty = false
- let results =[];
- results = response.data.results;
- this.addressList = this.addressList.concat(results);
- this.pageNum = response.index +1;
- if(this.pageNum === response.totalPage + 1 ){
- this.isLoadMore = false;
- } else {
- this.isLoadMore = true;
- }
- }
- }).catch(error =>{
- this.$util.msg(error.msg,2000)
- })
- })
-
- },
- //选择地址
- checkAddress(item){
- //是否需要返回地址(从订单确认页跳过来选收货地址)
- if(!this.isSelect){return ;}
- uni.setStorageSync('selectAddress',item)
- var pages = getCurrentPages();
- var prevPage = pages[pages.length - 2]; //上一个页面
- prevPage.setData({select:'select'})
- uni.navigateBack();
- },
- addAddress(type,item){
- uni.navigateTo({
- url: `/seller/pages/address/addressManage?type=${type}&data=${JSON.stringify(item)}`
- })
- },
- //删除收货地址
- deleteAddress(id){
- this.$util.modal('','确定要删除该地址?','确定','取消',true,() =>{
- this.UserService.DeleteNewAddress({addressID:id,userID:this.userID}).then(response =>{
- this.$util.msg('删除成功',2000,true,'success')
- setTimeout(() =>{
- this.pageNum = 1;
- this.addressList = [];
- this.initAddressList();
- },2000)
- }).catch(error =>{
- this.$util.msg(error.msg,2000);
- setTimeout(function(){
- uni.switchTab({
- url:'/seller/pages/home/home'
- })
- },1000)
- })
- })
- }
- },
- onShow() {
- this.$api.getStorage().then((resolve) =>{
- this.userID = resolve.userID
- this.pageNum = 1;
- this.addressList = [];
- this.initAddressList();
- var pages = getCurrentPages();
- var prevPage = pages[pages.length - 2]; //上一个页面
- // prevPage.setData({select:''})
- })
- }
- }
- </script>
- <style lang='scss'>
- page {
- height: auto;
- }
- page,.container{
- /* padding-bottom: 120upx; */
- background: #F7F7F7;
- border-top: 1px solid #EBEBEB;
- }
- .container{
- position: relative;
- }
- .list{
- display: flex;
- align-items: center;
- width: 702rpx;
- height: auto;
- padding: 24rpx;
- background: #FFFFFF;
- position: relative;
- border-bottom: 1px solid #EBEBEB;
- }
- .wrapper{
- display: flex;
- flex-direction: column;
- flex: 1;
- }
- .u-box.b-b{
-
- }
- .u-box.b-b{
- margin-bottom:24rpx;
- }
- .u-box.b-t{
- margin-bottom:0;
- }
- .u-box{
- display: flex;
- align-items: center;
- font-size: $font-size-28;
- color: $text-color;
- line-height: 40rpx;
- margin-bottom: 12rpx;
- .name{
- margin-right: 40rpx;
- font-weight: bold;
- }
- .mobile{
- font-weight: bold;
- }
- .tag-left{
- flex: 6;
- .tag{
- width: 120rpx;
- height: 40rpx;
- background: $color-system;
- border-radius: 20rpx;
- font-size: $font-size-24;
- color: #FFFFFF;
- line-height: 40rpx;
- text-align: center;
- padding: 0 6rpx;
- }
- }
- .tag-right{
- flex: 4;
- display: flex;
- text-align: right;
- .t-b{
- flex: 1;
- line-height: 40rpx;
- .txt{
- font-size: $font-size-24;
- color: $text-color;
- line-height: 40rpx;
- }
- }
- .icon-shanchu{
- color:#FF2A2A ;
- margin-right: 8rpx;
- }
- .icon-bianji{
- color: #2A7AFF;
- margin-right: 8rpx;
- }
- }
- .address{
- font-size: $font-size-28;
- color: $text-color;
- line-height: 40rpx;
- -o-text-overflow: ellipsis;
- text-overflow: ellipsis;
- display: -webkit-box;
- word-break: break-all;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- }
- }
- .add-btn{
- position: fixed;
- left: 24rpx;
- right: 24rpx;
- bottom: 34rpx;
- z-index: 95;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 702rpx;
- height: 88rpx;
- font-size: $font-size-28;
- line-height: 88rpx;
- color: #FFFFFF;
- text-align: center;
- background: $btn-confirm;
- border-radius: 45rpx;
- }
- .adds-btn{
- width: 702rpx;
- height: 88rpx;
- font-size: 28rpx;
- line-height: 88rpx;
- color: #FFFFFF;
- margin: 0 auto;
- text-align: center;
- background: #000000;
- border-radius: 14rpx;
- }
- </style>
|