1
This commit is contained in:
parent
6ac6cab661
commit
3931cecc8c
@ -9,3 +9,10 @@ export function postForkUser(params) {
|
||||
params: params
|
||||
})
|
||||
}
|
||||
//查询城市树结构
|
||||
export function treeCity() {
|
||||
return request({
|
||||
url: '/base/city/treeCity',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
@ -8,10 +8,46 @@ export function getUserBusiCard() {
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
// 查询当前登录用户的名片
|
||||
// 查询当前登录用户的收货地址
|
||||
export function getUserAddress() {
|
||||
return request({
|
||||
url: '/member/address/listByUser',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
//保存地址信息
|
||||
export function saveAddress(data) {
|
||||
return request({
|
||||
url: '/member/address/save',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 设置默认收货地址
|
||||
export function setDefault(params) {
|
||||
return request({
|
||||
url: '/member/address/setDefault',
|
||||
method: 'get',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
// 删除地址
|
||||
export function removeAddress(params) {
|
||||
return request({
|
||||
url: '/member/address/remove',
|
||||
method: 'delete',
|
||||
params:params
|
||||
})
|
||||
}
|
||||
|
||||
// 获取地址详细信息
|
||||
export function getById(params) {
|
||||
return request({
|
||||
url: '/member/address/getById',
|
||||
method: 'get',
|
||||
params:params
|
||||
})
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// 应用全局配置
|
||||
module.exports = {
|
||||
baseUrl: 'http://192.168.1.17:8080',
|
||||
baseUrl: 'http://192.168.1.4:8080',
|
||||
// baseUrl: 'http://localhost:8080',
|
||||
// 应用信息
|
||||
appInfo: {
|
||||
|
@ -24,7 +24,7 @@
|
||||
</view>
|
||||
<view class="item-value">
|
||||
<uni-data-picker placeholder="请选择" popup-title="请选择收件地址" :localdata="dataTree"
|
||||
v-model="dataObj.city" @change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened"
|
||||
v-model="dataObj.cityId" @change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened"
|
||||
@popupclosed="onpopupclosed">
|
||||
</uni-data-picker>
|
||||
<textarea style="margin-top: 10rpx;" v-model="dataObj.detail" placeholder="请输入详细地址" />
|
||||
@ -39,7 +39,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="item-field" style="align-items: center;">
|
||||
<view class="submit-box" @click="submit()">提交</view>
|
||||
<view class="submit-box" @click="submitForm()">提交</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -47,6 +47,9 @@
|
||||
|
||||
<script>
|
||||
import config from '@/config'
|
||||
import {treeCity} from '@/api/business/base.js'
|
||||
import {saveAddress,getById} from '@/api/business/member.js'
|
||||
import {toast} from '@/utils/common.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -58,58 +61,96 @@
|
||||
text: '否',
|
||||
value: "0"
|
||||
}],
|
||||
dataTree: [{
|
||||
text: "山东省",
|
||||
value: "1",
|
||||
children: [{
|
||||
text: "济南市",
|
||||
value: "2",
|
||||
children: [{
|
||||
text: "历城区",
|
||||
value: "3",
|
||||
children: [{
|
||||
text: "华山街道",
|
||||
value: "4"
|
||||
},
|
||||
{
|
||||
text: "东风街道",
|
||||
value: "东风街道"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
text: "历下区",
|
||||
value: "历下区"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
text: "临沂市",
|
||||
value: "临沂市",
|
||||
children: [{
|
||||
text: "兰陵县",
|
||||
value: "兰陵县",
|
||||
children: [{
|
||||
text: "向城镇",
|
||||
value: "向城镇"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
]
|
||||
}],
|
||||
//城市树结构
|
||||
dataTree: [],
|
||||
//名片数据对象
|
||||
dataObj: {
|
||||
name: "",
|
||||
tel: "",
|
||||
city: "",
|
||||
cityId: "",
|
||||
detail: "",
|
||||
isDefault: "0"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options){
|
||||
this.initData(options.id,options.isCopy);
|
||||
},
|
||||
|
||||
onShow(options) {
|
||||
this.initAddress();
|
||||
},
|
||||
methods: {
|
||||
|
||||
/**初始化界面*/
|
||||
initData(id,isCopy){
|
||||
if (id) {
|
||||
getById({id:id}).then(res =>{
|
||||
this.dataObj = res.data
|
||||
if (isCopy){
|
||||
this.dataObj.id = null
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.dataObj = {
|
||||
name: "",
|
||||
tel: "",
|
||||
cityId: "",
|
||||
detail: "",
|
||||
isDefault: "0"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**初始化树结构*/
|
||||
initAddress(){
|
||||
treeCity().then(res => {
|
||||
this.dataTree = res.data
|
||||
}).catch((e) => {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
duration: 2000,
|
||||
title: e
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
/**提交*/
|
||||
submitForm(){
|
||||
if (this.dataObj.name == null || this.dataObj.name == ""){
|
||||
toast("收件人姓名不能为空")
|
||||
return
|
||||
}
|
||||
if (this.dataObj.tel == null || this.dataObj.tel == ""){
|
||||
toast("联系电话不能为空")
|
||||
return
|
||||
}
|
||||
if (this.dataObj.cityId == null || this.dataObj.cityId == ""){
|
||||
toast("收件地址不能为空")
|
||||
return
|
||||
}
|
||||
saveAddress(this.dataObj).then(res => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
title: '保存成功'
|
||||
});
|
||||
uni.navigateBack()
|
||||
}
|
||||
}).catch((e) => {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
duration: 2000,
|
||||
title: e
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
onnodeclick(e) {
|
||||
console.log(e);
|
||||
console.log(e,135);
|
||||
},
|
||||
onpopupopened(e) {
|
||||
console.log('popupopened');
|
||||
|
@ -11,39 +11,36 @@
|
||||
size="16"></uni-icons><text>退出管理</text></view>
|
||||
</view>
|
||||
<view class="addr-list-box">
|
||||
<scroll-view style="height: 100%;" scroll-y="true" @scrolltolower="onReachBottomCus" refresher-enabled
|
||||
@refresherrefresh="onRefresherrefresh" :refresher-triggered="isTriggered">
|
||||
<view v-for="(item,index) in dataList" class="addr-item-box">
|
||||
<view class="addr-item-top">
|
||||
<view class="item-info">
|
||||
<view class="text little-1">{{ item.city }}</view>
|
||||
<view class="text little-1">{{ item.cityName }}</view>
|
||||
<view class="text">{{ item.detail }}</view>
|
||||
<view class="text little-2 item-flex">
|
||||
{{ item.name }} {{ item.tel }}
|
||||
<view v-if="item.isDefault=='1'" class="item-icon">默认</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item-opt">
|
||||
<uni-icons type="compose" color="#565656" size="16"></uni-icons><text>编辑</text>
|
||||
<view class="item-opt" @click="toEdit(item.id)">
|
||||
<uni-icons type="compose" color="#565656" size="16" ></uni-icons><text>编辑</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="addr-item-opt" v-if="ifEdit">
|
||||
<view class="opt-button choose" v-if="item.isDefault!='1'">设为默认</view>
|
||||
<view class="opt-button">复制</view>
|
||||
<view class="opt-button">删除</view>
|
||||
<view class="opt-button choose" @click="setDefaultCity(item.id)" v-if="item.isDefault!='1'">设为默认</view>
|
||||
<view class="opt-button" @click="toCopy(item.id)">复制</view>
|
||||
<view class="opt-button" @click="remove(item.id)">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
<view style="text-align: center" v-if="dataList.length==0">
|
||||
<image class="" src="@/static/images/nothing.png"></image>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getUserAddress
|
||||
getUserAddress,setDefault,removeAddress
|
||||
} from '@/api/business/member.js'
|
||||
export default {
|
||||
data() {
|
||||
@ -59,10 +56,12 @@
|
||||
dataList: []
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.initData();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.initData();
|
||||
},
|
||||
methods: {
|
||||
/**初始化数据*/
|
||||
initData() {
|
||||
getUserAddress().then(res => {
|
||||
this.dataList = res.data
|
||||
@ -74,36 +73,64 @@
|
||||
});
|
||||
})
|
||||
},
|
||||
/**设为默认方法*/
|
||||
setDefaultCity(id){
|
||||
setDefault({id:id}).then(res => {
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
title: '设置成功'
|
||||
});
|
||||
this.ifEdit = false
|
||||
this.initData()
|
||||
}).catch((e) => {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
duration: 2000,
|
||||
title: e
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
/**删除地址*/
|
||||
remove(id) {
|
||||
removeAddress({id:id}).then(res => {
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
title: '删除成功'
|
||||
});
|
||||
this.ifEdit = false
|
||||
this.initData()
|
||||
}).catch((e) => {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
duration: 2000,
|
||||
title: e
|
||||
});
|
||||
})
|
||||
},
|
||||
/**新增页面*/
|
||||
addNew() {
|
||||
this.$tab.navigateTo(`/pages/mine/addr/addr-detail`)
|
||||
},
|
||||
/**编辑页面*/
|
||||
toEdit(id){
|
||||
this.$tab.navigateTo(`/pages/mine/addr/addr-detail?id=`+id)
|
||||
},
|
||||
|
||||
/**复制*/
|
||||
toCopy(id){
|
||||
this.$tab.navigateTo(`/pages/mine/addr/addr-detail?id=`+id+`&isCopy=1`)
|
||||
},
|
||||
|
||||
/**
|
||||
* 进入管理
|
||||
*/
|
||||
manager(flag) {
|
||||
this.ifEdit = flag
|
||||
},
|
||||
/**
|
||||
* 上滑加载数据
|
||||
*/
|
||||
onReachBottomCus() {
|
||||
//判断 如果页码*页容量大于等于总条数,提示该页数据加载完毕
|
||||
if (this.queryParams.pageNum * this.queryParams.pageSize >= this.total) {
|
||||
toast("没有更多数据了")
|
||||
return
|
||||
}
|
||||
//页码+1,调用获取数据的方法获取第二页数据
|
||||
this.queryParams.pageNum++
|
||||
},
|
||||
/**
|
||||
* 下拉刷新数据
|
||||
*/
|
||||
onRefresherrefresh() {
|
||||
this.isTriggered = true
|
||||
this.queryParams.pageNum = 1
|
||||
this.total = 0
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -150,7 +177,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
justify-content: start;
|
||||
|
||||
.addr-item-box {
|
||||
width: 100%;
|
||||
|
Loading…
Reference in New Issue
Block a user