|
@@ -19,7 +19,7 @@
|
|
|
class="radio_icon"
|
|
|
:src="item.is_default ? 'https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/radioed.png' : 'https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/radio.png'"
|
|
|
></image>
|
|
|
- <text :class="item.is_default ? 'radioed_text' : ''">{{ item.is_default ? "已默认" : "设为默认" }}</text>
|
|
|
+ <text :class="item.is_default ? 'radioed_text' : ''">{{ item.is_default ? '已默认' : '设为默认' }}</text>
|
|
|
</view>
|
|
|
<view class="addr_right_btn" @click="removeAddr(index)">删除</view>
|
|
|
<view class="addr_right_btn" @click="openForm(item)">编辑</view>
|
|
@@ -94,7 +94,7 @@
|
|
|
<view class="form_group">
|
|
|
<view class="group_title">设为默认</view>
|
|
|
<view class="group_box">
|
|
|
- <switch color="#E03519" style="transform: scale(0.6); float: right" @change="defaultSwitch" :checked="addrRequest.is_default ? true : false" />
|
|
|
+ <switch color="#F89C33" style="transform: scale(0.6); float: right" @change="defaultSwitch" :checked="addrRequest.is_default ? true : false" />
|
|
|
</view>
|
|
|
</view>
|
|
|
<button class="submit_btn" @click="saveAddr">保存地址</button>
|
|
@@ -105,8 +105,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getProvinces, getMyCity, getAreas, getProvincesIndex, getCityIndex, getAreaIndex } from "../../utils/city";
|
|
|
-import Empty from "@/components/Empty/Empty.vue";
|
|
|
+import { getProvinces, getMyCity, getAreas, getProvincesIndex, getCityIndex, getAreaIndex } from '../../utils/city';
|
|
|
+import Empty from '@/components/Empty/Empty.vue';
|
|
|
|
|
|
// 防抖函数
|
|
|
function debounce(func, wait) {
|
|
@@ -131,13 +131,13 @@ export default {
|
|
|
// 保存地址
|
|
|
addrRequest: {
|
|
|
id: 0,
|
|
|
- contact_name: "",
|
|
|
- contact_phone: "",
|
|
|
- contact_province: "",
|
|
|
- contact_city: "",
|
|
|
- contact_area: "",
|
|
|
- contact_addr: "",
|
|
|
- contact_shop: "",
|
|
|
+ contact_name: '',
|
|
|
+ contact_phone: '',
|
|
|
+ contact_province: '',
|
|
|
+ contact_city: '',
|
|
|
+ contact_area: '',
|
|
|
+ contact_addr: '',
|
|
|
+ contact_shop: '',
|
|
|
is_default: 0,
|
|
|
shop_type: 1,
|
|
|
},
|
|
@@ -154,9 +154,9 @@ export default {
|
|
|
AddrEmit: false,
|
|
|
//终端类型
|
|
|
terminalType: [
|
|
|
- { key: 1, label: "单店" },
|
|
|
- { key: 2, label: "连锁" },
|
|
|
- { key: 3, label: "诊所、社康等" },
|
|
|
+ { key: 1, label: '单店' },
|
|
|
+ { key: 2, label: '连锁' },
|
|
|
+ { key: 3, label: '诊所、社康等' },
|
|
|
],
|
|
|
//获取的默认地址
|
|
|
defaultAddr: {},
|
|
@@ -165,8 +165,8 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
onLoad(param) {
|
|
|
- this.AddrEmit = param.notify == "addr" ? true : false;
|
|
|
- this.autoShowForm = param.type == "create" ? true : false;
|
|
|
+ this.AddrEmit = param.notify == 'addr' ? true : false;
|
|
|
+ this.autoShowForm = param.type == 'create' ? true : false;
|
|
|
// 获取列表
|
|
|
this.getList();
|
|
|
this.get_remark_addr();
|
|
@@ -192,16 +192,16 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
onSearchInput: debounce(function (inputVal, isSelect) {
|
|
|
- console.log("搜索关键字:", this.addrRequest.contact_shop);
|
|
|
- console.log("是否选择:", isSelect);
|
|
|
+ console.log('搜索关键字:', this.addrRequest.contact_shop);
|
|
|
+ console.log('是否选择:', isSelect);
|
|
|
if (isSelect) return;
|
|
|
- if (this.addrRequest.contact_shop.trim() === "" || this.addrRequest.contact_shop.length < 2) {
|
|
|
+ if (this.addrRequest.contact_shop.trim() === '' || this.addrRequest.contact_shop.length < 2) {
|
|
|
this.searchResults = [];
|
|
|
return;
|
|
|
}
|
|
|
- this.$http.request("api/custom_addr/get_guess_addr", { contact_shop: this.addrRequest.contact_shop }).then((callback) => {
|
|
|
+ this.$http.request('api/custom_addr/get_guess_addr', { contact_shop: this.addrRequest.contact_shop }).then((callback) => {
|
|
|
// 获取成功
|
|
|
- if (callback.code == "success") {
|
|
|
+ if (callback.code == 'success') {
|
|
|
this.searchResults = callback.data.map((item, index) => ({
|
|
|
text: item.contact_shop,
|
|
|
value: index,
|
|
@@ -226,9 +226,9 @@ export default {
|
|
|
},
|
|
|
//获取get_remark_addr
|
|
|
get_remark_addr() {
|
|
|
- this.$http.request("api/custom_addr/get_remark_addr").then((callback) => {
|
|
|
+ this.$http.request('api/custom_addr/get_remark_addr').then((callback) => {
|
|
|
// 获取成功
|
|
|
- if (callback.code == "success") {
|
|
|
+ if (callback.code == 'success') {
|
|
|
// 通知地址变更
|
|
|
this.defaultAddr = callback.data;
|
|
|
}
|
|
@@ -239,12 +239,12 @@ export default {
|
|
|
// 登录提示
|
|
|
if (!this.$checkAccess.alterLogin()) return;
|
|
|
// 判断数据
|
|
|
- this.$http.request("api/custom_addr/get_list").then((callback) => {
|
|
|
+ this.$http.request('api/custom_addr/get_list').then((callback) => {
|
|
|
// 获取成功
|
|
|
- if (callback.code == "success") {
|
|
|
+ if (callback.code == 'success') {
|
|
|
this.addrList = callback.data;
|
|
|
// 通知地址变更
|
|
|
- if (this.AddrEmit) uni.$emit("addr_list_change", { list: this.addrList });
|
|
|
+ if (this.AddrEmit) uni.$emit('addr_list_change', { list: this.addrList });
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -257,13 +257,13 @@ export default {
|
|
|
this.addrRequest.contact_shop = this.defaultAddr.contact_shop;
|
|
|
this.addrRequest.contact_addr = this.defaultAddr.contact_addr;
|
|
|
this.addrRequest.is_default = 0;
|
|
|
- this.addrRequest.shop_type = this.defaultAddr.shop_type == "" ? 1 : this.defaultAddr.shop_type;
|
|
|
+ this.addrRequest.shop_type = this.defaultAddr.shop_type == '' ? 1 : this.defaultAddr.shop_type;
|
|
|
const { contact_province, contact_city, contact_area } = this.defaultAddr;
|
|
|
- if (contact_province == "") {
|
|
|
+ if (contact_province == '') {
|
|
|
this.cityValue = [0, 0, 0];
|
|
|
- this.addrRequest.contact_province = "请选择";
|
|
|
- this.addrRequest.contact_city = "请选择";
|
|
|
- this.addrRequest.contact_area = "请选择";
|
|
|
+ this.addrRequest.contact_province = '请选择';
|
|
|
+ this.addrRequest.contact_city = '请选择';
|
|
|
+ this.addrRequest.contact_area = '请选择';
|
|
|
} else {
|
|
|
const provinces = getProvincesIndex(contact_province);
|
|
|
const city = getCityIndex(contact_city, provinces.city, provinces.index);
|
|
@@ -274,8 +274,8 @@ export default {
|
|
|
this.addrRequest.contact_province = contact_province;
|
|
|
this.addrRequest.contact_area = contact_area;
|
|
|
this.addrRequest.contact_city = contact_city;
|
|
|
- if (contact_area == "") this.addrRequest.contact_area = "请选择";
|
|
|
- if (contact_city == "") this.addrRequest.contact_city = "请选择";
|
|
|
+ if (contact_area == '') this.addrRequest.contact_area = '请选择';
|
|
|
+ if (contact_city == '') this.addrRequest.contact_city = '请选择';
|
|
|
}
|
|
|
} else {
|
|
|
if (!item.shop_type) item.shop_type = 1;
|
|
@@ -289,7 +289,7 @@ export default {
|
|
|
this.cityArray.splice(2, 1, city.area);
|
|
|
}
|
|
|
// 显示下单弹出层
|
|
|
- this.$refs.addrForm.open("bottom");
|
|
|
+ this.$refs.addrForm.open('bottom');
|
|
|
},
|
|
|
// 默认开关
|
|
|
defaultSwitch(e) {
|
|
@@ -302,7 +302,7 @@ export default {
|
|
|
},
|
|
|
// 城市修改
|
|
|
cityChange(e) {
|
|
|
- this.onFocus()
|
|
|
+ this.onFocus();
|
|
|
// 替换三个选项
|
|
|
this.cityValue.splice(e.detail.column, 1, e.detail.value);
|
|
|
// 下一级设置为0
|
|
@@ -328,49 +328,49 @@ export default {
|
|
|
saveAddr() {
|
|
|
// 判断姓名
|
|
|
if (!this.addrRequest.contact_name) {
|
|
|
- uni.showToast({ icon: "none", title: "请填写收件人" });
|
|
|
+ uni.showToast({ icon: 'none', title: '请填写收件人' });
|
|
|
return;
|
|
|
}
|
|
|
if (this.addrRequest.contact_name.length < 2) {
|
|
|
- uni.showToast({ icon: "none", title: "请填写收件人完整姓名" });
|
|
|
+ uni.showToast({ icon: 'none', title: '请填写收件人完整姓名' });
|
|
|
return;
|
|
|
}
|
|
|
if (!this.addrRequest.contact_shop) {
|
|
|
- uni.showToast({ icon: "none", title: "请填写店铺名称" });
|
|
|
+ uni.showToast({ icon: 'none', title: '请填写店铺名称' });
|
|
|
return;
|
|
|
}
|
|
|
if (!this.addrRequest.contact_phone) {
|
|
|
- uni.showToast({ icon: "none", title: "请填写收件人手机号" });
|
|
|
+ uni.showToast({ icon: 'none', title: '请填写收件人手机号' });
|
|
|
return;
|
|
|
}
|
|
|
if (!this.addrRequest.contact_addr) {
|
|
|
- uni.showToast({ icon: "none", title: "请填写联系地址" });
|
|
|
+ uni.showToast({ icon: 'none', title: '请填写联系地址' });
|
|
|
return;
|
|
|
}
|
|
|
if (this.addrRequest.contact_addr.length < 3) {
|
|
|
- uni.showToast({ icon: "none", title: "请填写可用联系地址" });
|
|
|
+ uni.showToast({ icon: 'none', title: '请填写可用联系地址' });
|
|
|
return;
|
|
|
}
|
|
|
const _clone = JSON.parse(JSON.stringify(this.addrRequest));
|
|
|
- if (_clone.contact_province == "请选择" || _clone.contact_city == "请选择" || _clone.contact_area == "请选择") {
|
|
|
+ if (_clone.contact_province == '请选择' || _clone.contact_city == '请选择' || _clone.contact_area == '请选择') {
|
|
|
uni.showToast({
|
|
|
- icon: "none",
|
|
|
- title: "请选择完整的省市区信息",
|
|
|
+ icon: 'none',
|
|
|
+ title: '请选择完整的省市区信息',
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
// 请求状态
|
|
|
uni.showLoading({ mask: true });
|
|
|
// 请求路径
|
|
|
- var url = this.addrRequest.id ? "api/custom_addr/edit" : "api/custom_addr/add";
|
|
|
+ var url = this.addrRequest.id ? 'api/custom_addr/edit' : 'api/custom_addr/add';
|
|
|
// 授权成功以后,调用绑定
|
|
|
- this.$http.request(url, this.addrRequest, "post").then((re) => {
|
|
|
+ this.$http.request(url, this.addrRequest, 'post').then((re) => {
|
|
|
// 关闭
|
|
|
uni.hideLoading();
|
|
|
// 成功的话
|
|
|
- if (re.code != "success") {
|
|
|
+ if (re.code != 'success') {
|
|
|
// 跳转
|
|
|
- uni.showToast({ title: re.msg, icon: "none" });
|
|
|
+ uni.showToast({ title: re.msg, icon: 'none' });
|
|
|
return;
|
|
|
}
|
|
|
// 地址变动
|
|
@@ -382,19 +382,19 @@ export default {
|
|
|
// 删除地址
|
|
|
removeAddr(index) {
|
|
|
// 授权成功以后,调用绑定
|
|
|
- this.$http.request("api/custom_addr/del", { id: this.addrList[index].id }, "post").then((re) => {
|
|
|
+ this.$http.request('api/custom_addr/del', { id: this.addrList[index].id }, 'post').then((re) => {
|
|
|
// 关闭
|
|
|
uni.hideLoading();
|
|
|
// 成功的话
|
|
|
- if (re.code != "success") {
|
|
|
+ if (re.code != 'success') {
|
|
|
// 跳转
|
|
|
- uni.showToast({ title: re.msg, icon: "none" });
|
|
|
+ uni.showToast({ title: re.msg, icon: 'none' });
|
|
|
return;
|
|
|
}
|
|
|
// 成功删除该项
|
|
|
this.addrList.splice(index, 1);
|
|
|
// 通知地址变更
|
|
|
- if (this.AddrEmit) uni.$emit("addr_list_change", { list: this.addrList });
|
|
|
+ if (this.AddrEmit) uni.$emit('addr_list_change', { list: this.addrList });
|
|
|
});
|
|
|
},
|
|
|
// 设置默认
|
|
@@ -402,13 +402,13 @@ export default {
|
|
|
// 如果已经是默认状态
|
|
|
if (this.addrList[index].is_default) return;
|
|
|
// 授权成功以后,调用绑定
|
|
|
- this.$http.request("api/custom_addr/set_default", { id: this.addrList[index].id }, "post").then((re) => {
|
|
|
+ this.$http.request('api/custom_addr/set_default', { id: this.addrList[index].id }, 'post').then((re) => {
|
|
|
// 关闭
|
|
|
uni.hideLoading();
|
|
|
// 成功的话
|
|
|
- if (re.code != "success") {
|
|
|
+ if (re.code != 'success') {
|
|
|
// 跳转
|
|
|
- uni.showToast({ title: re.msg, icon: "none" });
|
|
|
+ uni.showToast({ title: re.msg, icon: 'none' });
|
|
|
return;
|
|
|
}
|
|
|
// 更新其他的默认项
|
|
@@ -418,16 +418,16 @@ export default {
|
|
|
// 成功修改值
|
|
|
this.addrList[index].is_default = 1;
|
|
|
// 通知地址变更
|
|
|
- if (this.AddrEmit) uni.$emit("addr_list_change", { list: this.addrList });
|
|
|
+ if (this.AddrEmit) uni.$emit('addr_list_change', { list: this.addrList });
|
|
|
});
|
|
|
},
|
|
|
handleRadioChange(key) {
|
|
|
- this.onFocus()
|
|
|
+ this.onFocus();
|
|
|
this.addrRequest.shop_type = Number(key);
|
|
|
},
|
|
|
- onFocus(){
|
|
|
- this.$refs.combox.close()
|
|
|
- }
|
|
|
+ onFocus() {
|
|
|
+ this.$refs.combox.close();
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -483,7 +483,7 @@ export default {
|
|
|
vertical-align: middle;
|
|
|
}
|
|
|
.radioed_text {
|
|
|
- color: #e03519;
|
|
|
+ color: #f89c33;
|
|
|
}
|
|
|
}
|
|
|
.addr_right_btn {
|
|
@@ -516,7 +516,7 @@ export default {
|
|
|
margin: 0rpx auto;
|
|
|
margin-top: 20rpx;
|
|
|
border-radius: 40rpx;
|
|
|
- background-color: #e03519;
|
|
|
+ background-color: #f89c33;
|
|
|
}
|
|
|
}
|
|
|
.popup {
|
|
@@ -594,7 +594,7 @@ export default {
|
|
|
margin: 20rpx auto;
|
|
|
margin-top: 40rpx;
|
|
|
border-radius: 40rpx;
|
|
|
- background-color: #e03519;
|
|
|
+ background-color: #f89c33;
|
|
|
}
|
|
|
}
|
|
|
}
|