个人中心-我的地址

zhc4dev
暖暖 2 years ago
parent cee9ac73f5
commit ad5580e307
  1. BIN
      ant-design-vue-jeecg/src/views/shopping/assets/erweima.png
  2. 355
      ant-design-vue-jeecg/src/views/shopping/components/addrView.vue
  3. 6
      ant-design-vue-jeecg/src/views/shopping/pages/gerenzhongxin.vue

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

@ -0,0 +1,355 @@
<template>
<div class="addrView">
<div class="weizhuce d-flex" v-if="addrList.length == 0">
<p class="c_1B f_30"> 您还未注册地址</p>
</div>
<div class="d-flex btnDiv">
<div type="primary" class="dialogButton primary f_12" @click="addAddr">创建新地址</div>
</div>
<div class="addrList" v-if="addrList.length != 0">
<div class="item" v-for="(item,index) in addrList" :key="index">
<p class="default" v-if="item.flag"><span class="f_12">默认地址</span></p>
<div class="d-flex">
<div><span>{{item.name}}</span><span v-if="item.sex == 1">女士</span><span v-if="item.sex == 2">先生</span></div>
<div class="btnDiv">
<span class="btn" @click="handleEdit(item)">编辑</span>
<a-popconfirm
title="确定删除吗?"
ok-text="Yes"
cancel-text="No"
@confirm="confirm1(item.id)"
@cancel="cancel"
><span class="btn">删除</span></a-popconfirm>
<a-popconfirm
title="确定将其设置为默认地址吗?"
ok-text="Yes"
cancel-text="No"
@confirm="confirm2(item.id)"
@cancel="cancel"
v-if="!item.flag"
><span class="btn">将其设置为默认地址</span></a-popconfirm>
<!-- <span class="btn" v-if="!item.flag" @click="handleDefault(item.id)">将其设置为默认地址</span>-->
</div>
</div>
<p>
{{item.detailed}}
</p>
<p><j-area-linkage disabled type="cascader" v-model="item.addr" placeholder="请选择省市区"/></p>
</div>
</div>
<a-modal
title="地址操作"
:visible="visible"
:width="800"
>
<template slot="footer">
<a-button key="back" @click="handleCancel">
取消
</a-button>
<a-button key="submit" type="primary" @click="handleOk">
确定
</a-button>
</template>
<template>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
:label-col="labelCol" :wrapper-col="wrapperCol"
class="modelForm"
>
<a-form-model-item label="称呼" >
<a-select v-model="form.sex" placeholder="请选择称呼">
<a-select-option value="1">
女士
</a-select-option>
<a-select-option value="2">
先生
</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item
label="姓名"
prop="name"
>
<a-input placeholder="请输入姓名" v-model="form.name" />
</a-form-model-item>
<a-form-model-item
label="选择地址"
prop="addr"
>
<j-area-linkage type="cascader" v-model="form.addr" placeholder="请选择省市区"/>
</a-form-model-item>
<a-form-model-item
label="手机号码"
prop="phone"
>
<a-input placeholder="请输入手机号码" v-model="form.phone">
<template slot="addonBefore">
<span>+86 中国大陆地区</span>
</template>
</a-input>
</a-form-model-item>
<a-form-model-item label="详细地址" prop="detailed">
<a-input v-model="form.detailed" type="textarea" />
</a-form-model-item>
<a-form-model-item>
<a-checkbox @change="onChange" :checked="form.flag">
设置为默认地址
</a-checkbox>
</a-form-model-item>
</a-form-model>
</template>
</a-modal>
</div>
</template>
<script>
export default {
name: "addrView",
components: { },
data() {
return {
visible: false,
flag:'',//addedit
copyItem:{},//
labelCol: { span: 4 },
wrapperCol: { span: 20 },
addrList:[
{
id:1,
name:'吴一',
sex:'1',
phone:'17777777777',
addr:'210521',
detailed:'黄淮学院北区',
flag:true,//
},//
{
id:2,
name:'吴二',
sex:'2',
phone:'17777777777',
addr:'210521',
detailed:'黄淮学院北区',
flag:false,//
},//
{
id:3,
name:'吴三',
sex:'1',
phone:'17777777777',
addr:'210521',
detailed:'黄淮学院北区',
flag:false,//
},//
],//
addr1:'210521',
//
form: {
id:'',
sex: undefined,
name: '',
addr: '',
detailed: '',
phone: '',
flag:false//
},
rules: {
name: [
{ required: true, message: '请输入姓名', trigger: 'blur' },
],
visit: [
{ required: true, message: '请选择您的配送方式', trigger: 'change' },
],
addr: [{ required: true, message: '请选择地址', trigger: 'blur' }],
detailed: [{ required: true, message: '请输入详细地址', trigger: 'blur' }],
phone: [{ required: true, message: '请输入手机号码', trigger: 'blur' },
],
},
};
},
methods: {
addAddr(){
this.visible = true
this.flag = 'add'
},
changeDefault(){
this.addrList.forEach(obj =>{
if(obj.flag){
obj.flag = !obj.flag
}
})
},
clearForm(){
this.form = {
id:'',
sex: undefined,
name: '',
addr: '',
detailed: '',
phone: '',
flag:false//
}
},
handleOk(e) {
//
let that = this
this.$refs.ruleForm.validate(valid => {
if (valid) {//
if(this.flag == 'add') {//
if(this.form.flag){//
this.changeDefault()
this.addrList.unshift(this.form)
}else{//
this.addrList.push(this.form)
}
}else if(this.flag == 'edit'){//
//
let itemIndex3 = this.addrList.findIndex(item =>item.id == this.form.id)
if(this.form.flag){//
this.changeDefault()
this.form.flag = true
this.addrList[itemIndex3] = this.form
console.log("this.addrList2")
console.log(this.addrList)
}else{
this.addrList[itemIndex3] = this.form
}
}
//
this.clearForm()
this.flag = ''
this.visible = false;
} else {}
});
},
handleCancel() {
this.visible = false;
if(this.flag == 'edit'){
let itemIndex4 = this.addrList.findIndex(item =>item.id == this.form.id)
this.addrList[itemIndex4] = this.copyItem
}
this.clearForm()
this.flag = ''
},
onChange(e) {
this.form.flag = e.target.checked
},
handleEdit(item){
this.copyItem = JSON.parse(JSON.stringify(item));
this.visible = true
this.flag = 'edit'
this.form = item
},
confirm1(id) {
let itemIndex = this.addrList.findIndex(item =>item.id == id)
this.addrList.splice(itemIndex,1)
},
confirm2(id) {
this.changeDefault()
let itemIndex2 = this.addrList.findIndex(item =>item.id == id)
this.addrList[itemIndex2].flag = true
},
cancel(e) {
this.$message.warning('已取消');
},
},
};
</script>
<style lang="less" scoped>
@import '../assets/common.css';
.modelForm{
padding:20px 100px;
}
.addrList .j-area-linkage /deep/ .area-select{
background-color: #fff;
border: none;
span{
padding-left: 0;
font-size: 12px;
color:#313131;
cursor:auto;
font-weight: 500;
}
i{
display: none;
}
}
.btnDiv{
justify-content: center;
.dialogButton {
width: 300px;
height: 42px;
text-align: center;
line-height: 42px;
transition: all 0.2s;
}
.primary {
background: #1b1b1b;
border: 2px solid #1b1b1b;
color: #e5dfd9;
&:hover {
opacity: 0.8;
}
}
}
.addrView{
width: 1114px;
margin:0 auto;
padding-top: 50px;
.weizhuce{
text-align: center;
flex-direction: column;
justify-content: center;
align-items: center;
p{
width: 300px;
}
}
.addrList{
width: 800px;
margin: 0 auto;
.item{
padding-top: 40px;
border-bottom: 1px solid #DADADA;
color: #1A1919;
p{
font-size: 12px;
}
.default{
span{
display: inline-block;
padding: 4px 12px;
box-sizing: content-box;
background: #F8F8F8;
width: 72px;
height: 21px;
text-align: center;
line-height: 21px;
}
}
.d-flex{
justify-content: space-between;
font-size: 14px;
.btnDiv{
.btn{
cursor: pointer;
}
}
.btn{
text-decoration: underline;
margin-right: 20px;
}
div:first-child{
margin-bottom: 12px;
}
}
}
}
}
</style>

@ -123,6 +123,7 @@
</div>
</div>
<Collection v-if="current[0] == 'collect'"></Collection>
<AddrView v-if="current[0] == 'addr'"></AddrView>
<div class="orderList" >
<div class="item" v-for="(item,index) in allOrders" :key="index">
<div class="top d-flex">
@ -170,10 +171,11 @@
import { httpAction, getAction } from '@/api/manage'
import PasswordModal from '../../system/modules/PasswordModal'
import Collection from "../components/collection";
import AddrView from "../components/addrView"
export default {
name: "gerenzhongxin",
components: { Header,Footer,PasswordModal ,Collection},
data() {0
components: { Header,Footer,PasswordModal ,Collection,AddrView},
data() {
return {
model:{
username1: ""

Loading…
Cancel
Save