完成用户地址
This commit is contained in:
parent
df5e9f2d15
commit
55c200b1e9
|
@ -23,6 +23,22 @@ export default {
|
|||
info: {
|
||||
url: "/user/getuserinfo",
|
||||
auth: true,
|
||||
},
|
||||
address: {
|
||||
list: {
|
||||
url: "/Useraddress/getalladdress",
|
||||
showLoading: true,
|
||||
},
|
||||
edit: {
|
||||
url: "/Useraddress/applyaddress"
|
||||
},
|
||||
detail: {
|
||||
url: "/Useraddress/addressinfo",
|
||||
showLoading: true,
|
||||
},
|
||||
delete: {
|
||||
url: "/Useraddress/deleteaddress"
|
||||
}
|
||||
}
|
||||
},
|
||||
project: {
|
||||
|
|
|
@ -49,30 +49,30 @@ export default {
|
|||
openType: "list",
|
||||
chooseAddressId: 0,
|
||||
list: [
|
||||
{
|
||||
id: 1,
|
||||
isDefault: false,
|
||||
address: "四川省绵阳市高新区",
|
||||
detail: "火炬东街110号",
|
||||
name: "李(先生)",
|
||||
mobile: "18200000001",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
isDefault: false,
|
||||
address: "四川省绵阳市高新区",
|
||||
detail: "火炬东街110号",
|
||||
name: "李(先生)",
|
||||
mobile: "18200000001",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
isDefault: true,
|
||||
address: "四川省绵阳市高新区",
|
||||
detail: "火炬东街110号",
|
||||
name: "李(先生)",
|
||||
mobile: "18200000001",
|
||||
},
|
||||
// {
|
||||
// id: 1,
|
||||
// isDefault: false,
|
||||
// address: "四川省绵阳市高新区",
|
||||
// detail: "火炬东街110号",
|
||||
// name: "李(先生)",
|
||||
// mobile: "18200000001",
|
||||
// },
|
||||
// {
|
||||
// id: 2,
|
||||
// isDefault: false,
|
||||
// address: "四川省绵阳市高新区",
|
||||
// detail: "火炬东街110号",
|
||||
// name: "李(先生)",
|
||||
// mobile: "18200000001",
|
||||
// },
|
||||
// {
|
||||
// id: 3,
|
||||
// isDefault: true,
|
||||
// address: "四川省绵阳市高新区",
|
||||
// detail: "火炬东街110号",
|
||||
// name: "李(先生)",
|
||||
// mobile: "18200000001",
|
||||
// },
|
||||
],
|
||||
};
|
||||
},
|
||||
|
@ -99,11 +99,30 @@ export default {
|
|||
this.chooseAddressId = e.id;
|
||||
}
|
||||
},
|
||||
onShow() {},
|
||||
onShow() {
|
||||
this.list = [];
|
||||
this.loadAddress();
|
||||
},
|
||||
onReady() {},
|
||||
onReachBottom() {},
|
||||
onPullDownRefresh() {},
|
||||
methods: {
|
||||
loadAddress() {
|
||||
this.$request({
|
||||
api: "user.address.list",
|
||||
}).then((response) => {
|
||||
response.data.forEach((item) => {
|
||||
this.list.push({
|
||||
id: item.id,
|
||||
address: item.address,
|
||||
detail: item.doorplate,
|
||||
name: item.name,
|
||||
mobile: item.mobil,
|
||||
isDefault: item.default == 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
selectAddress(address) {
|
||||
if (this.openType == "choose") {
|
||||
this.getOpenerEventChannel().emit("setAddress", address);
|
||||
|
@ -113,17 +132,18 @@ export default {
|
|||
}
|
||||
},
|
||||
getWechatAddress() {
|
||||
const that = this;
|
||||
// #ifndef H5
|
||||
let wechatAddress = {};
|
||||
let platformAddress = {};
|
||||
uni.chooseAddress({
|
||||
success: (data) => {
|
||||
wechatAddress.address = data.provinceName + data.cityName + data.countyName;
|
||||
wechatAddress.detail = data.detailInfo;
|
||||
wechatAddress.mobile = data.telNumber;
|
||||
wechatAddress.name = data.userName;
|
||||
wechatAddress.gender = 1;
|
||||
wechatAddress.isDefault = false;
|
||||
console.log(wechatAddress);
|
||||
platformAddress.address = data.provinceName + data.cityName + data.countyName;
|
||||
platformAddress.detail = data.detailInfo;
|
||||
platformAddress.mobile = data.telNumber;
|
||||
platformAddress.name = data.userName;
|
||||
setTimeout(() => {
|
||||
that.$utils.toPage("/pages/address/edit?addr=" + JSON.stringify(platformAddress));
|
||||
}, 200);
|
||||
},
|
||||
});
|
||||
// #endif
|
||||
|
@ -132,12 +152,24 @@ export default {
|
|||
this.$utils.toPage("/pages/address/edit?id=" + id);
|
||||
},
|
||||
deleteAddress(id, index) {
|
||||
const that = this;
|
||||
uni.showModal({
|
||||
title: "删除地址?",
|
||||
content: "数据删除后不可恢复,请谨慎操作!",
|
||||
complete: (res) => {
|
||||
complete(res) {
|
||||
if (res.confirm) {
|
||||
this.list.splice(index, 1);
|
||||
that.$request({
|
||||
api: "user.address.delete",
|
||||
data: {
|
||||
id: id,
|
||||
},
|
||||
}).then((response) => {
|
||||
if (response.code == 1) {
|
||||
that.list.splice(index, 1);
|
||||
return;
|
||||
}
|
||||
that.$utils.toast(response.msg);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -56,12 +56,7 @@
|
|||
<text>手机号码</text>
|
||||
</view>
|
||||
<view class="input-box">
|
||||
<input
|
||||
class="input"
|
||||
v-model="mobile"
|
||||
placeholder="请输入手机号码"
|
||||
placeholder-class="placeholder-style-3"
|
||||
/>
|
||||
<input class="input" v-model="mobile" placeholder="请输入手机号码" placeholder-class="placeholder-style-3" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="input-item default-address">
|
||||
|
@ -95,6 +90,8 @@ export default {
|
|||
isDefault: false,
|
||||
name: "",
|
||||
mobile: "",
|
||||
longitude: 0,
|
||||
latitude: 0,
|
||||
};
|
||||
},
|
||||
components: {
|
||||
|
@ -108,6 +105,15 @@ export default {
|
|||
uni.setNavigationBarTitle({
|
||||
title: this.pageTitle,
|
||||
});
|
||||
this.id = e.id;
|
||||
this.setAddressData();
|
||||
}
|
||||
if (e.addr) {
|
||||
let platformAddress = JSON.parse(e.addr);
|
||||
this.address = platformAddress.address;
|
||||
this.detail = platformAddress.detail;
|
||||
this.name = platformAddress.name;
|
||||
this.mobile = platformAddress.mobile;
|
||||
}
|
||||
},
|
||||
onShow() {},
|
||||
|
@ -116,7 +122,42 @@ export default {
|
|||
onPullDownRefresh() {},
|
||||
methods: {
|
||||
save() {
|
||||
uni.navigateBack();
|
||||
this.$request({
|
||||
api: "user.address.edit",
|
||||
data: {
|
||||
id: this.id,
|
||||
address: this.address,
|
||||
doorplate: this.detail,
|
||||
name: this.name,
|
||||
mobil: this.mobile,
|
||||
sex: this.gender == 1 ? "男" : "女",
|
||||
default: this.isDefault ? 1 : 0,
|
||||
lat: this.latitude,
|
||||
lng: this.longitude,
|
||||
},
|
||||
}).then((response) => {
|
||||
if (response.code == 1) {
|
||||
return this.$utils.toPage("", {}, "back");
|
||||
}
|
||||
this.$utils.toast(response.msg);
|
||||
});
|
||||
},
|
||||
setAddressData() {
|
||||
this.$request({
|
||||
api: "user.address.detail",
|
||||
data: {
|
||||
id: this.id,
|
||||
},
|
||||
}).then((response) => {
|
||||
this.address = response.data.address;
|
||||
this.detail = response.data.doorplate;
|
||||
this.name = response.data.name;
|
||||
this.mobile = response.data.mobil;
|
||||
this.gender = response.data.sex == "男" ? 1 : 2;
|
||||
this.isDefault = response.data.default == 1;
|
||||
this.latitude = response.data.lat;
|
||||
this.longitude = response.data.lng;
|
||||
});
|
||||
},
|
||||
chooseLocation() {
|
||||
const t = this;
|
||||
|
@ -124,6 +165,8 @@ export default {
|
|||
success: ({ name, address, longitude, latitude }) => {
|
||||
t.address = address;
|
||||
t.detail = name;
|
||||
t.longitude = longitude;
|
||||
t.latitude = latitude;
|
||||
},
|
||||
fail: (error) => {},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue