mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-17 16:13:48 +08:00
地址以及数据
This commit is contained in:
@@ -7,32 +7,34 @@
|
||||
<h2>新增收货地址</h2>
|
||||
<div class="rc-max-width--xl rc-people">
|
||||
<span>收货人:</span>
|
||||
<input type="text" placeholder="请输入收货人姓名">
|
||||
<input type="text" placeholder="请输入收货人姓名" v-model="userpeople">
|
||||
</div>
|
||||
<div class="rc-max-width--xl rc-phone">
|
||||
<span>手机号码:</span>
|
||||
<input type="text" placeholder="请输入11位手机号码">
|
||||
<input type="text" placeholder="请输入11位手机号码" v-model="tel" :error-message="usertel">
|
||||
</div>
|
||||
<div class="rc-max-width--xl rc-address">
|
||||
<span>所在地区:</span>
|
||||
<input type="text" placeholder="请选择所在地区">
|
||||
<!-- <input type="text" placeholder="请选择所在地区"> -->
|
||||
<addressInput @getmenu="onGetMenu" @closeDialog = "handleClose1" :dialogInfo1="dialogInfo1"></addressInput>
|
||||
</div>
|
||||
<div class="rc-max-width--xl rc-useaddress">
|
||||
<span>详细地址:</span>
|
||||
<input type="text" placeholder="小区、门牌号等" class="userinput">
|
||||
<input type="text" placeholder="小区、门牌号等" class="userinput" v-model="alladdress">
|
||||
<textarea rows="10" cols="30" placeholder="请输入详细地址">
|
||||
|
||||
</textarea>
|
||||
|
||||
</div>
|
||||
|
||||
<addressInput @getmenu="onGetMenu" @closeDialog = "handleClose1" :dialogInfo1="dialogInfo1"></addressInput>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="rc-button">
|
||||
<span @click="openclose()">取消</span>
|
||||
<em @click="openclose()">确认</em>
|
||||
<em @click="register()">确认</em>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="rc-button">
|
||||
<div class="rc-footbutton" @click="onAdd()">
|
||||
<span>新增收货地址</span>
|
||||
@@ -51,14 +53,19 @@
|
||||
import Myheader from '~/components/header.vue'
|
||||
import MyFooter from '~/components/rc-footer.vue'
|
||||
import addressInput from '~/components/addressInput.vue'
|
||||
import {editaddress} from "../../ajax/getData";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
chosenAddressId: "1",
|
||||
usermessage:null,
|
||||
checked: true,
|
||||
tel: "",
|
||||
alladdress:'',
|
||||
userid: null,
|
||||
usermessage:null,
|
||||
dialogInfo1:false,
|
||||
userpeople:'',
|
||||
list: [
|
||||
{
|
||||
id: 1,
|
||||
@@ -89,36 +96,58 @@ export default {
|
||||
handleClose1(){
|
||||
this.dialogInfo1 = false
|
||||
},
|
||||
onEdit(item, index) {
|
||||
// let userid = item.id;
|
||||
console.log(item);
|
||||
this.$router.push({
|
||||
path: "/useraddress/editaddress",
|
||||
query: {
|
||||
id: item,
|
||||
},
|
||||
});
|
||||
|
||||
register(){
|
||||
console.log(this.tel)
|
||||
if (!/^[1][3,4,5,7,8][0-9]{9}$/.test(this.tel) || this.tel === "") {
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '手机号码输入有误'
|
||||
});
|
||||
return
|
||||
}else if(this.alladdress===''){
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '请输入详细地址'
|
||||
});
|
||||
return
|
||||
}
|
||||
else if(this.userpeople===''){
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '请输入姓名'
|
||||
});
|
||||
return
|
||||
}
|
||||
|
||||
else{
|
||||
this.editaddress();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
//添加
|
||||
async editaddress(item) {
|
||||
// this.userid
|
||||
let useradd={
|
||||
memberId:this.userid,
|
||||
detailAddress:this.alladdress,
|
||||
recipient:this.userpeople,
|
||||
recipientPhone:this.tel,
|
||||
provinceId:'',
|
||||
cityId:'',
|
||||
districtId:'',
|
||||
|
||||
}
|
||||
let data = await editaddress(useradd);
|
||||
if(data){
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '地址添加成功'
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
onAdd(item, index) {
|
||||
// let userid = item.id;
|
||||
// console.log(item);
|
||||
this.$router.push({
|
||||
path: "/useraddress/addaddress",
|
||||
// query: {
|
||||
// id: userid,
|
||||
// },
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
//删除地址
|
||||
// async userdelete(item) {
|
||||
// console.log(item.memberId);
|
||||
// let data = await editdelete(this.userid, item.id);
|
||||
// this.editaddress(this.usermessage);
|
||||
// console.log(data);
|
||||
// },
|
||||
|
||||
//查询人的所有地址
|
||||
// async editaddress(user) {
|
||||
@@ -134,8 +163,23 @@ export default {
|
||||
MyFooter,
|
||||
addressInput
|
||||
},
|
||||
computed:{
|
||||
usertel() {
|
||||
if (this.tel === "") {
|
||||
return "";
|
||||
} else if (!/^[1][3,4,5,7,8][0-9]{9}$/.test(this.tel)) {
|
||||
return "手机号格式错误";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
|
||||
this.usermessage = JSON.parse(localStorage.getItem("userInfo"));
|
||||
// this.editaddress(this.usermessage);
|
||||
this.userid = this.usermessage.data.id;
|
||||
//地址的查询
|
||||
// this.usermessage = JSON.parse(localStorage.getItem("userInfo"));
|
||||
// this.editaddress(this.usermessage);
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
<div>
|
||||
<Myheader></Myheader>
|
||||
<div class="rc-top"></div>
|
||||
|
||||
<div class="rc-max-width--xl rc-main">
|
||||
<div class="usercontend">
|
||||
<div class="rc-max-width--xl">
|
||||
<div class="rc-max-width--xl rc-people">
|
||||
<span>收货人:</span>
|
||||
<input type="text" placeholder="李某某">
|
||||
<input type="text" placeholder="" v-model="recipient">
|
||||
</div>
|
||||
<div class="rc-max-width--xl rc-phone">
|
||||
<span>手机号码:</span>
|
||||
<input type="text" placeholder="15279944631">
|
||||
<input type="text" placeholder="" v-model="recipientPhone">
|
||||
</div>
|
||||
<div class="rc-max-width--xl rc-address">
|
||||
<span>所在地区:</span>
|
||||
<input type="text" placeholder="请选择所在地区">
|
||||
<addressInput @getmenu="onGetMenu" @closeDialog = "handleClose1" :dialogInfo1="dialogInfo1"></addressInput>
|
||||
</div>
|
||||
<div class="rc-max-width--xl rc-useaddress">
|
||||
<span>详细地址:</span>
|
||||
<input type="text" placeholder="天河客运站">
|
||||
<input type="text" placeholder="" v-model="detailAddress" >
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -27,12 +27,14 @@
|
||||
<span>新增收货地址</span>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="rc-button">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="rc-button">
|
||||
<span @click="openclose()">取消</span>
|
||||
<em @click="openclose()">确认</em>
|
||||
<em @click="register()">确认</em>
|
||||
</div>
|
||||
<!-- <MyFooter></MyFooter> -->
|
||||
|
||||
<MyFooter></MyFooter>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -40,13 +42,20 @@
|
||||
|
||||
import Myheader from '~/components/header.vue'
|
||||
import MyFooter from '~/components/rc-footer.vue'
|
||||
import { editupdate} from "../../ajax/getData";
|
||||
import addressInput from '~/components/addressInput.vue'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
chosenAddressId: "1",
|
||||
checked: true,
|
||||
userid: null,
|
||||
dialogInfo1:false,
|
||||
usermessage:null,
|
||||
detailAddress:'',
|
||||
recipientPhone:'',
|
||||
recipient:'',
|
||||
addressid:'',
|
||||
list: [
|
||||
{
|
||||
id: 1,
|
||||
@@ -71,26 +80,63 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onEdit(item, index) {
|
||||
// let userid = item.id;
|
||||
console.log(item);
|
||||
this.$router.push({
|
||||
path: "/useraddress/editaddress",
|
||||
query: {
|
||||
id: item,
|
||||
},
|
||||
});
|
||||
onGetMenu(values){
|
||||
console.log(values,+'111111');
|
||||
},
|
||||
onAdd(item, index) {
|
||||
// let userid = item.id;
|
||||
// console.log(item);
|
||||
this.$router.push({
|
||||
path: "/useraddress/addaddress",
|
||||
// query: {
|
||||
// id: userid,
|
||||
// },
|
||||
});
|
||||
handleClose1(){
|
||||
this.dialogInfo1 = false
|
||||
},
|
||||
|
||||
register(){
|
||||
console.log(this.tel)
|
||||
if (!/^[1][3,4,5,7,8][0-9]{9}$/.test(this.recipientPhone) || this.recipientPhone === "") {
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '手机号码输入有误'
|
||||
});
|
||||
return
|
||||
}else if(this.alladdress===''){
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '请输入详细地址'
|
||||
});
|
||||
return
|
||||
}
|
||||
else if(this.userpeople===''){
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '请输入姓名'
|
||||
});
|
||||
return
|
||||
}
|
||||
|
||||
else{
|
||||
this.editaddress();
|
||||
}
|
||||
},
|
||||
|
||||
//更改
|
||||
async editaddress(item) {
|
||||
let useradd={
|
||||
memberId:this.userid,
|
||||
id:this.id,
|
||||
provinceId:'',//省份id,
|
||||
cityId:'',//城市id,
|
||||
districtId:'',//区域id,
|
||||
detailAddress:this.detailAddress, //详细地址
|
||||
recipient:this.recipient, //收件人姓名
|
||||
recipientPhone:this.recipientPhone, //收件人电话
|
||||
}
|
||||
let data = await editupdate(useradd);
|
||||
if(data){
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '地址修改成功'
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -114,9 +160,19 @@ export default {
|
||||
components: {
|
||||
Myheader,
|
||||
MyFooter,
|
||||
addressInput
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// if(this.$route.query.id){
|
||||
this.userid = JSON.parse(localStorage.getItem("userInfo")).data.id;
|
||||
this.recipient=this.$route.query.recipient
|
||||
this.recipientPhone=this.$route.query.recipientPhone
|
||||
this.detailAddress=this.$route.query.detailAddress
|
||||
this.id=this.$route.query.id;
|
||||
console.log(this.recipient,this.recipientPhone,this.detailAddress, this.id)
|
||||
|
||||
// }
|
||||
//地址的查询
|
||||
// this.usermessage = JSON.parse(localStorage.getItem("userInfo"));
|
||||
// this.editaddress(this.usermessage);
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
<div class="rc-center">
|
||||
<div class=" rc-title">
|
||||
<em>
|
||||
{{ item.name }}
|
||||
{{ item.recipient }}
|
||||
</em>
|
||||
<span>
|
||||
{{ item.tel }}
|
||||
{{ item.recipientPhone }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="rc-address">
|
||||
<span>
|
||||
{{ item.address }}
|
||||
{{item.provinceName}}{{ item.districtName }}{{item.detailAddress}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="rc-footer">
|
||||
@@ -47,9 +47,10 @@
|
||||
</div>
|
||||
|
||||
<div class="usercontshow useredit">
|
||||
|
||||
<img src="../../assets/image/userselect.png" alt="">
|
||||
<div class="usercontshow alledit" @click="onAdd()">
|
||||
<img src="../../static/images/adddress.png" alt="">
|
||||
<span>添加收货地址</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rc-button">
|
||||
<div class="rc-footbutton" @click="onAdd()">
|
||||
@@ -65,6 +66,7 @@
|
||||
<script>
|
||||
import Myheader from '~/components/header.vue'
|
||||
import MyFooter from '~/components/rc-footer.vue'
|
||||
import { selectaddress,editupdate,editdelete} from "../../ajax/getData";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -96,13 +98,30 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
changeadddress(item,index){
|
||||
console.log(item,index);
|
||||
console.log(item.isDefault)
|
||||
if(item.isDefault==false){
|
||||
item.isDefault=true
|
||||
}else{
|
||||
item.isDefault=false;
|
||||
}
|
||||
this.editupdate(this.userid,item.id,item.isDefault)
|
||||
this.editaddress();
|
||||
|
||||
},
|
||||
onEdit(item, index) {
|
||||
// let userid = item.id;
|
||||
console.log(item);
|
||||
// debugger
|
||||
|
||||
this.$router.push({
|
||||
path: "/useraddress/editaddress",
|
||||
query: {
|
||||
id: item,
|
||||
recipient: item.recipient,
|
||||
recipientPhone:item.recipientPhone,
|
||||
detailAddress:item.detailAddress,
|
||||
id:item.id
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -117,24 +136,37 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
//更改地址
|
||||
async editupdate(userid,addressid,isDefault) {
|
||||
let useradd={
|
||||
memberId:userid,
|
||||
id:addressid,
|
||||
isDefault:isDefault,
|
||||
}
|
||||
|
||||
let data = await editupdate(useradd);
|
||||
// if(data){
|
||||
// this.editaddress();
|
||||
// }
|
||||
|
||||
},
|
||||
|
||||
//删除地址
|
||||
// async userdelete(item) {
|
||||
// console.log(item.memberId);
|
||||
// let data = await editdelete(this.userid, item.id);
|
||||
// this.editaddress(this.usermessage);
|
||||
// console.log(data);
|
||||
// },
|
||||
|
||||
async userdelete(item) {
|
||||
console.log(item.memberId);
|
||||
let data = await editdelete(this.userid, item.id);
|
||||
this.editaddress();
|
||||
console.log(data);
|
||||
},
|
||||
//查询人的所有地址
|
||||
// async editaddress(user) {
|
||||
// user.data.id=844350
|
||||
// let data = await selectaddress(user.data.id);
|
||||
// this.list=data.data;
|
||||
// console.log(this.list);
|
||||
// console.log(data);
|
||||
// },
|
||||
async editaddress(user) {
|
||||
// user.data.id=844350;
|
||||
let data = await selectaddress(this.userid);
|
||||
console.log(data);
|
||||
// this.list=data;
|
||||
// console.log(this.list);
|
||||
console.log(data);
|
||||
},
|
||||
},
|
||||
components: {
|
||||
Myheader,
|
||||
@@ -143,9 +175,11 @@ export default {
|
||||
|
||||
mounted() {
|
||||
//地址的查询
|
||||
// this.usermessage = JSON.parse(localStorage.getItem("userInfo"));
|
||||
// this.editaddress(this.usermessage);
|
||||
// this.userid = this.usermessage.data.id;
|
||||
this.usermessage = JSON.parse(localStorage.getItem("userInfo"));
|
||||
this.userid = this.usermessage.data.id;
|
||||
console.log(this.userid);
|
||||
this.editaddress(this.userid);
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user