|
@@ -100,43 +100,27 @@
|
|
|
<span class="manage-all-addresses">管理全部地址</span>
|
|
|
</div>
|
|
|
<ul class="select-address-list">
|
|
|
- <li class="active">
|
|
|
+ <li :class="{active: item.is_mr == 1}" v-for="(item, index) in addressList" :key="index">
|
|
|
<div class="select-address-sidebar">
|
|
|
- <p class="people-name">胡海峰</p>
|
|
|
+ <p class="people-name" @click="changeApproveDelivery(item.id)">{{item.name}}</p>
|
|
|
<p class="addrss-box">
|
|
|
- <span class="addrss-msg">中国安徽省宣城市宁国市黄河路764号环球中心501 </span>
|
|
|
- <span class="people-phone-num">188****2323</span>
|
|
|
+ <span class="addrss-msg">
|
|
|
+ {{item.pro_name}}
|
|
|
+ {{item.city_name}}
|
|
|
+ {{item.county_name}}
|
|
|
+ {{item.street_name}}
|
|
|
+ {{item.detail}}
|
|
|
+ </span>
|
|
|
+ <span class="people-phone-num">{{item.phone}}</span>
|
|
|
</p>
|
|
|
</div>
|
|
|
<div class="select-address-btn-box">
|
|
|
- <button type="button">删除</button>
|
|
|
+ <button type="button" @click="delAddress(item.id)">删除</button>
|
|
|
<button type="button">修改</button>
|
|
|
</div>
|
|
|
</li>
|
|
|
- <li>
|
|
|
- <p class="people-name">胡海峰</p>
|
|
|
- <p class="addrss-box">
|
|
|
- <span class="addrss-msg">中国天津天津市静海县文化路657号</span>
|
|
|
- <span class="people-phone-num">188****2323</span>
|
|
|
- </p>
|
|
|
- <div class="select-address-btn-box">
|
|
|
- <button type="button">删除</button>
|
|
|
- <button type="button">修改</button>
|
|
|
- </div>
|
|
|
- </li>
|
|
|
- <li>
|
|
|
- <p class="people-name">胡海峰</p>
|
|
|
- <p class="addrss-box">
|
|
|
- <span class="addrss-msg">中国天津天津市静海县文化路657号</span>
|
|
|
- <span class="people-phone-num">188****2323</span>
|
|
|
- </p>
|
|
|
- <div class="select-address-btn-box">
|
|
|
- <button type="button">删除</button>
|
|
|
- <button type="button">修改</button>
|
|
|
- </div>
|
|
|
- </li>
|
|
|
<!-- 无内容时显示 -->
|
|
|
- <div class="normal-box">
|
|
|
+ <div class="normal-box" v-if="addressList.length == 0">
|
|
|
<img src="../../assets/normal-3.png">
|
|
|
暂无收货地址
|
|
|
</div>
|
|
@@ -152,7 +136,7 @@
|
|
|
<label class="row-start-label"><span class="red-color">*</span>收货人</label>
|
|
|
<div class="row-sidebar" style="flex-direction: column;align-items: flex-start;">
|
|
|
<div style="min-width: 234px;display: flex;align-items: center;">
|
|
|
- <el-input v-model="input" placeholder="收货人姓名"></el-input>
|
|
|
+ <el-input v-model="addressParams.name" placeholder="收货人姓名"></el-input>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -160,7 +144,7 @@
|
|
|
<label class="row-start-label"><span class="red-color">*</span>手机号</label>
|
|
|
<div class="row-sidebar" style="flex-direction: column;align-items: flex-start;">
|
|
|
<div style="min-width: 234px;display: flex;align-items: center;">
|
|
|
- <el-input v-model="input" placeholder="手机号"></el-input>
|
|
|
+ <el-input v-model="addressParams.phone" placeholder="手机号"></el-input>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -170,21 +154,43 @@
|
|
|
<div
|
|
|
style="width: 548px;display: flex;align-items: center;justify-content: space-between;">
|
|
|
<div class="select-item">
|
|
|
- <el-select v-model="region" placeholder="请选择省份">
|
|
|
- <el-option label="山东省" value="shanghai"></el-option>
|
|
|
- <el-option label="区域二" value="beijing"></el-option>
|
|
|
+ <el-select v-model="addressPickerValue[0]" @change="bindColumnchange(0, $event)" placeholder="请选择省份">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in addressPickerData[0]"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="index">
|
|
|
+ </el-option>
|
|
|
</el-select>
|
|
|
</div>
|
|
|
<div class="select-item">
|
|
|
- <el-select v-model="region2" placeholder="请选择城市">
|
|
|
- <el-option label="临沂市" value="shanghai"></el-option>
|
|
|
- <el-option label="区域二" value="beijing"></el-option>
|
|
|
+ <el-select v-model="addressPickerValue[1]" @change="bindColumnchange(1, $event)" placeholder="请选择城市">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in addressPickerData[1]"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="index">
|
|
|
+ </el-option>
|
|
|
</el-select>
|
|
|
</div>
|
|
|
<div class="select-item">
|
|
|
- <el-select v-model="region3" placeholder="区/县/街道">
|
|
|
- <el-option label="河东区" value="shanghai"></el-option>
|
|
|
- <el-option label="兰山区" value="beijing"></el-option>
|
|
|
+ <el-select v-model="addressPickerValue[2]" @change="bindColumnchange(2, $event)" placeholder="请选择区/县">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in addressPickerData[2]"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="index">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <div class="select-item">
|
|
|
+ <el-select v-model="addressPickerValue[3]" @change="bindColumnchange(3, $event)" placeholder="请选择街道">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in addressPickerData[3]"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="index">
|
|
|
+ </el-option>
|
|
|
</el-select>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -194,7 +200,7 @@
|
|
|
<div class="flex-end-box">
|
|
|
<div
|
|
|
style="width: 548px;display: flex;align-items: center;justify-content: space-between;">
|
|
|
- <el-input type="textarea" placeholder="请填写详细地址~" class="textarea" v-model="desc">
|
|
|
+ <el-input type="textarea" placeholder="请填写详细地址~" class="textarea" v-model="addressParams.detail">
|
|
|
</el-input>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -203,8 +209,8 @@
|
|
|
<div class="flex-end-box">
|
|
|
<div
|
|
|
style="width: 548px;display: flex;align-items: center;justify-content: space-between;">
|
|
|
- <label for="c1" class="form-bottom">
|
|
|
- <input id="c1" name="pass" type="checkbox" checked />
|
|
|
+ <label for="c12" class="form-bottom">
|
|
|
+ <input id="c12" name="pass" type="checkbox" checked ref="is_mr" @change="addressParams.is_mr = ($refs['is_mr'].checked ? 1 : 0)"/>
|
|
|
<span>设为默认地址</span>
|
|
|
</label>
|
|
|
</div>
|
|
@@ -215,8 +221,8 @@
|
|
|
<div
|
|
|
style="width: 548px;display: flex;align-items: center;justify-content: space-between;">
|
|
|
<div class="form-btn-box">
|
|
|
- <button type="button" class="active">保存</button>
|
|
|
- <button type="button" class="active">取消</button>
|
|
|
+ <button type="button" class="active" @click="setDeliveryAddress()">保存</button>
|
|
|
+ <button type="button" class="active" @click="initAddress()">取消</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -252,11 +258,11 @@
|
|
|
<li>将解除与其它网站、其他APP的授权或绑定关系</li>
|
|
|
</ul>
|
|
|
<label for="c1" class="logout-bottom">
|
|
|
- <input id="c1" name="pass" type="checkbox" checked />
|
|
|
+ <input id="c1" name="pass" type="checkbox" checked ref="CancelUserInfo"/>
|
|
|
<span style="flex: 1;">申请提交即表示您自愿放弃账户内所有虚拟财产并同意<span class="red-color">《注销须知》</span></span>
|
|
|
</label>
|
|
|
<div class="logout-btn-box">
|
|
|
- <button type="button">申请注销用户</button>
|
|
|
+ <button type="button" @click="cancelUserInfo()">申请注销用户</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -272,6 +278,17 @@
|
|
|
<script>
|
|
|
import Header from '../../components/header.vue';
|
|
|
import Footer from '../../components/footer.vue';
|
|
|
+ import {
|
|
|
+ areaGetAreaChildrenByID,
|
|
|
+ userManageGetDeliveryAddressDetail,
|
|
|
+ userManageSetDeliveryAddress,
|
|
|
+ userManageChangeApproveDelivery,
|
|
|
+ userManageDelDeliveryAddress,
|
|
|
+ userManageGetDeliveryAddressList,
|
|
|
+ userCenterCancelUserInfo,
|
|
|
+ } from '../../service/service';
|
|
|
+ import { validatorFun } from '../../utils/util';
|
|
|
+
|
|
|
export default {
|
|
|
components: {
|
|
|
Header,
|
|
@@ -308,14 +325,261 @@
|
|
|
region: '',
|
|
|
region2: '',
|
|
|
region3: '',
|
|
|
- desc: ''
|
|
|
+ desc: '',
|
|
|
+
|
|
|
+
|
|
|
+ addressList: [],
|
|
|
+ addressParams: {
|
|
|
+ id: 0, // 收货地址记录id(不传值是添加)
|
|
|
+ pro_name: '', // 省名
|
|
|
+ city_name: '', // 市名
|
|
|
+ county_name: '', // 县区名
|
|
|
+ street_name: '', // 街道
|
|
|
+ detail: '', // 详细地址
|
|
|
+ phone: '', // 联系电话
|
|
|
+ name: '', // 联系人
|
|
|
+ is_mr: 0, // 是否是默认(0不默认,1默认)
|
|
|
+ },
|
|
|
+
|
|
|
+ // 地址
|
|
|
+ addressPickerData: [[], [], [], []],
|
|
|
+ addressPickerDataNames: [[], [], [], []],
|
|
|
+ addressPickerValue: [0, 0, 0, 0],
|
|
|
+ addressPickerValueStr: '',
|
|
|
};
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ this.getAddressList();
|
|
|
+ this.initAddress();
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ initAddress() {
|
|
|
+ this.addressParams = {
|
|
|
+ id: 0, // 收货地址记录id(不传值是添加)
|
|
|
+ pro_name: '', // 省名
|
|
|
+ city_name: '', // 市名
|
|
|
+ county_name: '', // 县区名
|
|
|
+ street_name: '', // 街道
|
|
|
+ detail: '', // 详细地址
|
|
|
+ phone: '', // 联系电话
|
|
|
+ name: '', // 联系人
|
|
|
+ is_mr: 0, // 是否是默认(0不默认,1默认)
|
|
|
+ };
|
|
|
+ // 地址
|
|
|
+ this.addressPickerData = [[], [], [], []];
|
|
|
+ this.addressPickerDataNames = [[], [], [], []];
|
|
|
+ this.addressPickerValue = [0, 0, 0, 0];
|
|
|
+ this.addressPickerValueStr = '';
|
|
|
+ this.getAreaChildrenByID();
|
|
|
+ },
|
|
|
+ // 获取列表
|
|
|
+ getAddressList() {
|
|
|
+ userManageGetDeliveryAddressList({
|
|
|
+ page: 1,
|
|
|
+ page_num: 999999,
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === 1) {
|
|
|
+ const list = res.data.list.map(item => {
|
|
|
+ const [first_name, ...last_name] = item.name.split('');
|
|
|
+ item['first_name'] = first_name;
|
|
|
+ item['last_name'] = last_name.join('');
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ this.addressList = list;
|
|
|
+ // this.addressList = page > 1 ? [...this.list, ...list] : list;
|
|
|
+ // if (list.length === 0) {
|
|
|
+ // this.$message.warning(msg);
|
|
|
+ // } else {
|
|
|
+ // this.page = this.page + 1;
|
|
|
+ // }
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 新增地址
|
|
|
+ setDeliveryAddress() {
|
|
|
+ const params = this.addressParams;
|
|
|
+ console.log(params);
|
|
|
+ const errList = validatorFun(params, [
|
|
|
+ ['name', ['notNull', '请输入收货人']],
|
|
|
+ ['phone', ['notNull', '请输入手机号码'], ['isMobile', '请输入正确手机号']],
|
|
|
+ ['pro_name', ['notNull', '请输入选择所在地区']],
|
|
|
+ ['city_name', ['notNull', '请输入选择所在地区']],
|
|
|
+ ['county_name', ['notNull', '请输入选择所在地区']],
|
|
|
+ ['street_name', ['notNull', '请输入选择所在地区']],
|
|
|
+ ['detail', ['notNull', '请输入详细地址']],
|
|
|
+ ]);
|
|
|
+ if (errList.length > 0) {
|
|
|
+ return this.$message.warning(errList[0].errMsg);
|
|
|
+ }
|
|
|
+ userManageSetDeliveryAddress(params).then(({code, msg, data}) => {
|
|
|
+ if (code == 1) {
|
|
|
+ this.getAddressList();
|
|
|
+ this.initAddress();
|
|
|
+ this.$message.success(msg);
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取地址详情
|
|
|
+ getAddressDetail() {
|
|
|
+ userManageGetDeliveryAddressDetail({ id: this.addressParams.id }).then(({code, msg, data})=> {
|
|
|
+ if (code == 1) {
|
|
|
+ const {
|
|
|
+ id,
|
|
|
+ pro_id,
|
|
|
+ city_id,
|
|
|
+ county_id,
|
|
|
+ pro_name,
|
|
|
+ city_name,
|
|
|
+ county_name,
|
|
|
+ street_name,
|
|
|
+ detail,
|
|
|
+ phone,
|
|
|
+ name,
|
|
|
+ is_mr,
|
|
|
+ } = data;
|
|
|
+ this.addressParams = {
|
|
|
+ id,
|
|
|
+ pro_name,
|
|
|
+ city_name,
|
|
|
+ county_name,
|
|
|
+ street_name,
|
|
|
+ detail,
|
|
|
+ phone,
|
|
|
+ name,
|
|
|
+ is_mr,
|
|
|
+ };
|
|
|
+ const arr = [
|
|
|
+ pro_name,
|
|
|
+ city_name,
|
|
|
+ county_name,
|
|
|
+ street_name,
|
|
|
+ ];
|
|
|
+ this.select = is_mr == 1;
|
|
|
+ this.addressPickerValueStr = arr.join(' ');
|
|
|
+ const fn = (id2 = 0, idx2, level = 1) => {
|
|
|
+ const name = arr.splice(0, 1)[0];
|
|
|
+ this.getAreaChildrenByID(id2, idx2, level, level, () => {
|
|
|
+ const idx = this.addressPickerDataNames[level - 1].indexOf(name);
|
|
|
+ if ( arr.length > 0 ) {
|
|
|
+ let id3 = this.addressPickerData[level - 1][idx].id;
|
|
|
+ fn(id3, idx, level + 1);
|
|
|
+ } else {
|
|
|
+ this.getAreaChildrenByID(0, idx, level + 1, level);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ fn();
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getAreaChildrenByID(id = 0, idx = 0, level = 1, maxLevel = 4, callback) {
|
|
|
+ const list = [...this.addressPickerData];
|
|
|
+ const listIds = [...this.addressPickerDataNames];
|
|
|
+ const vals = [...this.addressPickerValue];
|
|
|
+ vals[level - 2] = idx;
|
|
|
+ const fn = (id = 0, level2 = 1) => {
|
|
|
+ if (level2 > maxLevel) {
|
|
|
+ this.addressPickerData = list;
|
|
|
+ this.addressPickerDataNames = listIds;
|
|
|
+ this.addressPickerValue = vals;
|
|
|
+ this.bindPickerChange();
|
|
|
+ callback && callback();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ areaGetAreaChildrenByID({id}).then(({code, msg, data}) => {
|
|
|
+ if (code == 1) {
|
|
|
+ list[level2 - 1] = data.list;
|
|
|
+ listIds[level2 - 1] = data.list.map(item => item.name);
|
|
|
+ vals[level2 - 1] = 0;
|
|
|
+ fn(data.list[0].id, level2 + 1);
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ fn(id, level);
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // 设置默认地址
|
|
|
+ changeApproveDelivery(id) {
|
|
|
+ this.$confirm('确认设为默认地址?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }).then(() => {
|
|
|
+ userManageChangeApproveDelivery({ id }).then(({code, msg, data}) => {
|
|
|
+ if (code == 1) {
|
|
|
+ this.getAddressList();
|
|
|
+ this.$message.success(msg);
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 删除地址
|
|
|
+ delAddress(id) {
|
|
|
+ this.$confirm('确认删除地址?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }).then(() => {
|
|
|
+ userManageDelDeliveryAddress({ id }).then(({code, msg, data}) => {
|
|
|
+ if (code == 1) {
|
|
|
+ this.getAddressList();
|
|
|
+ this.$message.success(msg);
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ bindPickerChange() {
|
|
|
+ const [pIdx, cIdx, aIdx, sIdx] = this.addressPickerValue;
|
|
|
+ const [province, city, area, street] = this.addressPickerData;
|
|
|
+ this.addressPickerValueStr = `${province[pIdx].name} ${city[cIdx].name} ${area[aIdx].name} ${street[sIdx].name}`;
|
|
|
+ this.addressParams.pro_name = province[pIdx].name;
|
|
|
+ this.addressParams.city_name = city[cIdx].name;
|
|
|
+ this.addressParams.county_name = area[aIdx].name;
|
|
|
+ this.addressParams.street_name= street[sIdx].name;
|
|
|
+ console.log(this.addressParams);
|
|
|
+ },
|
|
|
+ bindColumnchange(column, value) {
|
|
|
+ this.getAreaChildrenByID(this.addressPickerData[column][value].id, value, column + 2);
|
|
|
+ },
|
|
|
//选项卡
|
|
|
active(index) {
|
|
|
this.active = index
|
|
|
},
|
|
|
+
|
|
|
+ // 注销账户
|
|
|
+ cancelUserInfo() {
|
|
|
+ if (!this.$refs['CancelUserInfo'].checked) {
|
|
|
+ return this.$message.warning('请阅读并同意《注销须知》');
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$confirm('确定注销账户吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }).then(() => {
|
|
|
+ userCenterCancelUserInfo().then(({code, msg}) => {
|
|
|
+ if (code == 1) {
|
|
|
+ this.$message.success(msg);
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -506,7 +770,7 @@
|
|
|
align-items: center;
|
|
|
}
|
|
|
|
|
|
- >>>.el-input__inner {
|
|
|
+ >>> .el-input__inner {
|
|
|
height: 30px !important;
|
|
|
line-height: 30px !important;
|
|
|
border: 1px solid #BBBBBB !important;
|
|
@@ -514,7 +778,7 @@
|
|
|
font-size: 16px !important;
|
|
|
}
|
|
|
|
|
|
- >>>.el-input__icon {
|
|
|
+ >>> .el-input__icon {
|
|
|
line-height: 30px !important;
|
|
|
}
|
|
|
|
|
@@ -972,4 +1236,4 @@
|
|
|
width: 280px;
|
|
|
margin-bottom: 7px;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|