123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <template>
- <view id="addressList">
- <view class="addresBox" v-for="item in newsInfo" :key="item.id">
- <!-- <image src="../../../static/img/common/addresList.svg" mode=""></image> -->
- <view @click="getItem(item)" class="adresInfo bb">
- <view class="adresName">
- {{ item.name }}
- <text class="textgrey">{{ item.phone }}</text>
- </view>
- <view class="adresDet">
- <text v-if="item.is_check == 1" class="promain">默认</text>
- {{ item.mergename }}{{ item.detail }}
- </view>
- </view>
- <!-- "is_default": 1, //是否默认 1=默认 0=不默认 -->
- <view class="adresDo dfsb">
- <view @click="showDefault(1, item)" class="flex1 dffs">
- <image class="icon" v-if="item.is_default == 1" src="/static/img/pro/chenggong.png" mode=""></image>
- <image class="icon" v-if="item.is_default == 0" src="/static/img/pro/wxz.png" mode=""></image>
- 设为默认
- </view>
- <text @click="showDefault(2, item)" class="textgrey fontsm">删除</text>
- <text @click="showDefault(3, item)" class="textgrey fontsm">修改</text>
- </view>
- </view>
- <u-empty v-if="newsInfo.length < 1" icon-size="200" text="还没有收货地址哦,快去添加吧!" mode="list"></u-empty>
- <!-- #ifdef MP -->
- <!-- #endif -->
- <view @tap="doAddres('add')" class="fixBox"><view class="clickbtn">添加新地址</view></view>
- </view>
- </template>
- <script>
- export default {
- name: 'addressList',
- data() {
- return {
- newsInfo: [],
- page: 1,
- limit: 10,
- status: 'more'
- };
- },
- onNavigationBarButtonTap(e) {
- uni.navigateTo({
- url: './editAddres?type=add'
- });
- },
- onReachBottom() {
- if (this.status == 'nomore') return;
- this.page = ++this.page;
- this.getAddList();
- },
- onLoad(opt) {
- // this.selType = opt.type || '';
- },
- onShow() {
- // this.selType = opt.type || '';
- this.status = 'loadmore';
- this.page = 1;
- this.getAddList();
- },
- methods: {
- doAddres(type, val) {
- console.log(2);
- uni.navigateTo({
- url: './editAddres?type=' + type
- });
- },
- getItem(item) {
- let address = { shou_name: item.name, shou_phone: item.phone, address_id: item.id, shou_address: item.mergename + item.detail };
- // console.log(this.$api.prePage().$data.addressInfo);
- this.$api.prePage().addressInfo = address;
- uni.navigateBack({
- delta: 1
- });
- },
- getAddList() {
- this.$api
- .request('user_address/addressList', {
- page: this.page,
- limit: this.limit
- })
- .then(data => {
- if (data.code == 200) {
- this.newsInfo = data.data.list;
- if (data.data.list.length < this.limit) {
- this.status = 'nomore';
- }
- } else {
- this.$api.toast(data.msg);
- }
- });
- },
- // 设为默认
- showDefault(val, item) {
- if (val == 3) {
- uni.navigateTo({
- url: '/pages/user/address/editAddres?type=edit' + '&id=' + item.id
- });
- return;
- }
- let url = val == 1 ? 'user_address/setDefault' : 'user_address/addressDel';
- this.$api
- .request(url, {
- id: item.id
- })
- .then(data => {
- this.$api.toast(data.msg);
- if (data.code == 200) {
- setTimeout(res => {
- this.getAddList();
- }, 800);
- }
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- #addressList {
- padding: 30rpx 30rpx 120rpx;
- .addresBox {
- background: rgba(255, 255, 255, 1);
- border-radius: 16rpx;
- padding: 0 30rpx;
- margin-bottom: 30rpx;
- image {
- width: 72rpx;
- height: 72rpx;
- }
- .adresInfo {
- flex: 1;
- padding: 20rpx 0;
- .adresName {
- font-size: 30rpx;
- line-height: 44rpx;
- text {
- font-size: 30rpx;
- margin-left: 8rpx;
- }
- }
- .adresDet {
- line-height: 40rpx;
- font-size: 30rpx;
- .promain {
- font-size: 24rpx;
- min-width: 80rpx;
- padding: 0 16rpx;
- height: 40rpx;
- line-height: 40rpx;
- background: rgba(224, 40, 40, 0.1);
- border-radius: 4rpx;
- margin-right: 8rpx;
- }
- }
- }
- .adresDo {
- padding: 17rpx 0 29rpx;
- color: #999;
- .icon {
- width: 30rpx;
- height: 30rpx;
- margin-right: 12rpx;
- }
- .flex1 {
- font-size: 26rpx;
- }
- .textgrey {
- margin-left: 65rpx;
- }
- }
- }
- .clickbtn {
- margin: 0 auto;
- border-radius: 11rpx;
- }
- }
- </style>
|