128 lines
3.6 KiB
Vue
128 lines
3.6 KiB
Vue
<template>
|
|
<view>
|
|
<view class="hm-p-b-100">
|
|
<view class="hm-header-xian"></view>
|
|
<view v-if="list.data.length">
|
|
<view v-for="(item, index) in list.data" :key="index" class="hm-bg-f hm-m-b-10">
|
|
<view class="hm-p-20 hm-border-b">
|
|
<view class="hm-font-30 hm-col-main">
|
|
<text class="hm-font-b">{{item.name}}</text>
|
|
<text class="hm-col-tips hm-m-l-10">({{item.gender.text}})</text>
|
|
<text class="hm-m-l-20">{{item.phone}}</text>
|
|
</view>
|
|
<view class="hm-font-26 hm-col-tips hm-p-t-10">
|
|
{{item.province}} {{item.city}} {{item.district}} {{item.detail}}
|
|
</view>
|
|
</view>
|
|
<view class="hm-p-20">
|
|
<view class="hm-dis-block-inline">
|
|
<radio-group @change="setDefault">
|
|
<label>
|
|
<radio :checked="item.address_id == default_id" color="#fa3534"
|
|
:value="toString(item.address_id)"></radio>
|
|
<text class="hm-font-26" :class="item.address_id == default_id ? 'hm-col-error hm-font-b' : 'hm-col-tips'">{{item.address_id == default_id ? '默认' : '选择'}}</text>
|
|
</label>
|
|
</radio-group>
|
|
</view>
|
|
<view class="hm-dis-block-inline hm-fr">
|
|
<view class="hm-dis-block-inline">
|
|
<u-button @click="goTo('user/address/edit?id='+item.address_id)" icon="edit-pen" size="small" text="编辑" plain></u-button>
|
|
</view>
|
|
<view class="hm-dis-block-inline hm-m-l-20" >
|
|
<u-button @click="remove(item.address_id)" icon="trash" size="small" text="删除" plain></u-button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-else class="hm">
|
|
<img :src="applet.domain + '/addons/food/img/empty/address.png'" />
|
|
<view class="text">暂无地址数据</view>
|
|
</view>
|
|
<!-- 技术支持 -->
|
|
<view class="hm">
|
|
{{applet.copyright}} <text class="v">V{{applet.version}}</text>
|
|
</view>
|
|
<view class="hm-footer-fixed">
|
|
<view class="hm-p-lr-b25 hm-w-b100">
|
|
<u-button @click="goTo('user/address/add')" type="success" text="添加地址"></u-button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
let App = getApp();
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
applet: {},
|
|
list: {data:{}},
|
|
default_id: null,
|
|
options:{}
|
|
};
|
|
},
|
|
onLoad: function(options) {
|
|
let _this = this;
|
|
_this.options = options;
|
|
_this.applet = uni.getStorageSync('applet');
|
|
},
|
|
onShow: function() {
|
|
let _this = this;
|
|
_this.getList();// 获取收货地址列表
|
|
},
|
|
methods: {
|
|
/**
|
|
* 获取收货地址列表
|
|
*/
|
|
getList: function() {
|
|
let _this = this;
|
|
App._get('user.address/lists', {}, function(result) {
|
|
_this.setData(result.data);
|
|
});
|
|
},
|
|
/**
|
|
* 设置为默认地址
|
|
*/
|
|
setDefault: function(e) {
|
|
let _this = this;
|
|
_this.default_id = parseInt(e.detail.value);
|
|
App._post_form('user.address/setDefault', {
|
|
id: e.detail.value
|
|
}, function(result) {
|
|
_this.options.from === 'flow' && uni.navigateBack();
|
|
});
|
|
return false;
|
|
},
|
|
/**
|
|
* 移除收货地址
|
|
*/
|
|
remove: function(address_id) {
|
|
let _this = this;
|
|
uni.showModal({
|
|
title: "提示",
|
|
content: "您确定要移除当前收货地址吗?",
|
|
success: function(o) {
|
|
o.confirm && App._post_form('user.address/delete', {
|
|
id: address_id
|
|
}, function(result) {
|
|
_this.getList();
|
|
});
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* 页面跳转
|
|
*/
|
|
goTo: function(url) {
|
|
App.goTo(url);
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
<style>
|
|
|
|
</style>
|