123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <template>
- <view class="pages">
- <u-navbar
- title="收货地址"
- @leftClick="leftClick"
- :autoBack="true"
- :safeAreaInsetTop="true"
- >
- </u-navbar>
- <view class="page-wrap">
- <view class="full-btn" @click="newAddr">新增收货地址</view>
- <view v-if="dataList.length>0" class="addr" @click="addrClick(item)" v-for="(item,index) in dataList" :key="item.id">
- <u-swipe-action>
- <u-swipe-action-item :show="item.show" :index="index" @click.stop="swipeClick(index)" :options="options">
- <view class="u-flex">
- <view class="icon-wrap" v-if="item.ifDefault==1">
- <u-icon size="36rpx" :name="staticUrl+'/img/arrows.png'"></u-icon>
- </view>
- <view class="info u-flex-1">
- <view class="up">
- <text>{{item.receiveName}}</text>
- <text>{{item.receivePhone}}</text>
- <text class="default" v-if="item.ifDefault==1">默认</text>
- </view>
- <view class="down">{{item.receiveAdress}}{{item.address}}</view>
- </view>
- <u-icon name="edit-pen" color="#333" size="20" @click.native.stop="editAddr(item)"></u-icon>
- </view>
- </u-swipe-action-item>
- </u-swipe-action>
- </view>
- <u-empty v-else mode="list"></u-empty>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- staticUrl:this.$commonConfig.staticUrl,
- dataList:[],
- options:[
- {
- text: '删除',
- style: {
- backgroundColor: '#FF3C3F',
- 'padding-left':'10px'
- }
- }
- ],
- fromPage:'',
- }
- },
- onShow() {
- this.getAddrList();
- },
- onLoad(page) {
- console.log('page',page);
- this.fromPage = page.from;
- },
- methods: {
- leftClick(e){
- console.log('leftClick',e);
- },
- newAddr(){
- uni.$u.route('/center/addrForm', {type: 'add'});
- },
- editAddr(item){
- uni.$u.route('/center/addrForm', {type: 'edit',id:item.id});
- },
- getAddrList(){
- this.$u.api.addrList().then(res=>{
- this.dataList = res.data.rows;
- }).catch(err=>{
- console.log('getAddrList',err.data);
- })
- },
- swipeClick(index){
- let that = this;
- // console.log('swipeClick',this.dataList[index]);
- let item = this.dataList[index];
- uni.showModal({
- title: '温馨提示',
- content: '确定要删除吗?',
- success: res => {
- if (res.confirm) {
- that.deleteAddr(item.id);
- }
- },
- complete:()=>{}
- })
- },
- deleteAddr(id){
- this.$u.api.delAddr({id:id}).then(res=>{
- this.getAddrList()
- }).catch(err=>{
- console.log('deleteAddr',err.data);
- })
- },
- addrClick(item){
- console.log('selectAddr',item);
- if(this.fromPage == 'submitorder'){
- let pages = getCurrentPages(); //获取所有页面栈实例列表
- let nowPage = pages[ pages.length - 1]; //当前页页面实例
- let prevPage = pages[ pages.length - 2 ]; //上一页页面实例
- prevPage.$vm.fromPage = 'addrlist';
- prevPage.$vm.theAddr = item; // 修改上一页data里面的content参数值
- uni.navigateBack()
- }
- }
- }
- }
- </script>
- <style>
- page{
- background-color: #F5F5F5;
- }
- </style>
- <style lang="scss" scoped>
- .addr{
- background-color: #fff;
- padding: 30rpx;
- margin-bottom: 20rpx;
- .info{
- margin-left: 30rpx;
- }
- .up{
- margin-bottom: 10rpx;
- font-size: 32rpx;
- font-weight: 600;
- text{margin-right: 20rpx;}
- .default{
- padding: 5rpx 16rpx;
- border-radius: 4rpx;
- color: #FF3C3F;
- background-color: #FFECEC;
- font-size: 22rpx
- }
- }
- .down{
- font-size: 26rpx;
- color: #999;
- }
- }
- </style>
|