Commit 9af987a2 authored by Morson's avatar Morson

我的地址模块页面搭建与页面交互

parent 0775e789
...@@ -106,29 +106,28 @@ export default { ...@@ -106,29 +106,28 @@ export default {
} catch (a) { } catch (a) {
} }
}, },
async getBaseInfo(vm, callBack) { async getBaseInfo(vm, callBack) {
uni.showLoading({ uni.showLoading({
title: "加载中……", title: "加载中……",
}); });
const res = await vm.$u.api.getSettleBaseInfo(); const res = await vm.$u.api.getSettleBaseInfo();
console.log(res, "res"); if (res.code !== 200) {
if (res.code !== 200) { uni.showToast({
uni.showToast({ title: (res && res.message) || "获取基本信息错误",
title: (res && res.message) || "获取基本信息错误", icon: "none",
icon: "none", });
}); return false;
return false; }
}
vm.$u.vuex('vuex_settled', res.data && res.data.record || null);
this.globalData.settledInfo = res.data; if (!res.data) {
if (!res.data) { return;
return; }
} if (typeof callBack == "function") {
if (typeof callBack == "function") { callBack(vm, res.data);
callBack(vm, res.data); }
} uni.hideLoading();
uni.hideLoading(); return res.data;
return res.data;
}, },
/** /**
......
...@@ -41,6 +41,11 @@ let settledApiFun = function(vm){ ...@@ -41,6 +41,11 @@ let settledApiFun = function(vm){
/* 获取消息内容列表 */ /* 获取消息内容列表 */
let listByNotice = async (params = {}) => await vm.$u.get(ucenterApiUrl+'/v1/notice/home-list', params); let listByNotice = async (params = {}) => await vm.$u.get(ucenterApiUrl+'/v1/notice/home-list', params);
/**
* 我的-更新收货地址
*/
let syncAddress = async (params = {}) => await vm.$u.post(ucenterApiUrl+'/v1/settled/sync-address', params);
const settledApi = { const settledApi = {
getSettleBaseInfo, getSettleBaseInfo,
getSettleArea, getSettleArea,
...@@ -56,6 +61,7 @@ let settledApiFun = function(vm){ ...@@ -56,6 +61,7 @@ let settledApiFun = function(vm){
listOrderingTutorials, listOrderingTutorials,
saveCourseRate, saveCourseRate,
listByNotice, listByNotice,
syncAddress,
} }
return settledApi return settledApi
} }
......
...@@ -93,7 +93,10 @@ const install = (Vue, vm) => { ...@@ -93,7 +93,10 @@ const install = (Vue, vm) => {
message:msg message:msg
}; };
case 401: case 401:
// token失效,跳转登录 // token失效,清空登录信息,同时跳转登录
vm.$u.vuex('vuex_token', '');
vm.$u.vuex('vuex_user', null);
vm.$u.vuex('vuex_wx_uid', '');
toLoginPage() toLoginPage()
case 403://没有权限访问 case 403://没有权限访问
case 500: case 500:
......
...@@ -106,10 +106,10 @@ ...@@ -106,10 +106,10 @@
}; };
}, },
watch: { watch: {
vuex_token(val, oldVal) { // vuex_token(val, oldVal) {
// 监听token变化,如果更新则重新加载页面数据 // // 监听token变化,如果更新则重新加载页面数据
val && this.initSettleInfo() // val && this.initSettleInfo()
} // }
}, },
computed: { computed: {
buttonStyle() { buttonStyle() {
......
<template> <template>
<view class="wrap"> <view class="wrap">
<w-navbar :title="title"></w-navbar>
<view class="top"> <view class="top">
<view class="item"> <view class="item">
<view class="left">收货人</view> <view class="left">姓名</view>
<input type="text" placeholder-class="line" placeholder="请填写收货人姓名" /> <input disabled v-model="name" type="text" placeholder-class="line" placeholder="请填写姓名" />
</view> </view>
<view class="item"> <view class="item">
<view class="left">手机号码</view> <view class="left">电话</view>
<input type="text" placeholder-class="line" placeholder="请填写收货人手机号" /> <input disabled v-model="mobile" type="text" placeholder-class="line" placeholder="请填写电话" />
</view>
<view class="item" @tap="showRegionPicker">
<view class="left">所在地区</view>
<input disabled type="text" placeholder-class="line" placeholder="省市区县、乡镇等" />
</view>
<view class="item address">
<view class="left">详细地址</view>
<textarea type="text" placeholder-class="line" placeholder="街道、楼牌等" />
</view> </view>
<u-field
v-model="address"
label="地址"
label-width="88"
type="textarea"
:border-bottom="false"
placeholder="请填写地址">
<view slot="right" class="right" @tap="autoLocation">
<u-icon name="map" color="#2272FF" size="30"></u-icon>
<text>自动定位</text>
</view>
</u-field>
<!-- <view class="site-clipboard"> <!-- <view class="site-clipboard">
<textarea placeholder-class="line" value="" placeholder="粘贴文本,可自动识别姓名和地址等" /> <textarea placeholder-class="line" value="" placeholder="粘贴文本,可自动识别姓名和地址等" />
<view class="clipboard"> <view class="clipboard">
...@@ -26,38 +31,161 @@ ...@@ -26,38 +31,161 @@
</view> --> </view> -->
</view> </view>
<view class="bottom"> <view class="bottom">
<view class="tag"> <button class="btn, bottom-btn" @click="show = true">
<view class="left">标签</view> <text class="button-text">保存</text>
<view class="right"> </button>
<text class="tags">家</text> <!-- <view class="default">
<text class="tags">公司</text>
<text class="tags">学校</text>
<view class="tags plus"><u-icon size="22" name="plus"></u-icon></view>
</view>
</view>
<view class="default">
<view class="left"> <view class="left">
<view class="set">设置默认地址</view> <view class="set">设置默认地址</view>
<view class="tips">提醒:每次下单会默认推荐该地址</view> <view class="tips">提醒:每次下单会默认推荐该地址</view>
</view> </view>
<view class="right"><switch color="red" @change="setDefault" /></view> <view class="right"><switch color="red" @change="setDefault" /></view>
</view> </view> -->
</view> </view>
<u-picker mode="region" ref="uPicker" v-model="show" /> <u-popup
border-radius="12"
width="690"
height="520"
v-model="show"
mode="center">
<view class="save-pop">
<view class="header">确认保存信息</view>
<view class="content">
<view class="tips">您填写的信息尚未保存,是否保存</view>
</view>
</view>
<view class="pop-bottom">
<button class="plain" @click="show = false" shape="circle" :plain="true">不保存</button>
<button
class="solid"
shape="circle"
@click="$u.throttle(submitForm, 500)"
:loading="submiting"
:disabled="disabledSubmit">保存</button>
</view>
</u-popup>
</view> </view>
</template> </template>
<script> <script>
let r = require("libs/bmap-wx.min.js");
let h = new r.BMapWX({
// ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG",
ak: "lF1HoyXdiv4uZx6TrGQEZs48F5y8kEHI"
});
export default { export default {
data() { data() {
return { return {
show: false title: '新增地址',
show: false,
type: '充电桩安装',
name: '',
mobile: '',
address: '',
location: '',
}; };
}, },
async onLoad(e) {
if(e && e.title) {
this.title = decodeURIComponent(e.title)
}
if(this.vuex_token && this.vuex_settled) {
const settled = this.vuex_settled
this.name = settled.id_card_name || settled.nickname || settled.name || '--'
this.mobile = settled.mobile
this.address = settled.address
this.type = settled.type
} else {
this.$u.route({
type: 'redirect',
url: "pages/mine/address/index",
params: {
sync: true
}
})
}
await this.setDefault()
},
methods: { methods: {
setDefault() {}, async setDefault() {
showRegionPicker() { this.initLocation()
this.show = true; },
/**
* 初始化位置
*/
initLocation() {
const self = this
uni.getLocation({
type: 'wgs84',
success: function(res) {
self.baiduLocation(res.longitude, res.latitude)
}
});
},
/**
* 百度定位
* @param {Object} long
* @param {Object} lat
*/
baiduLocation(long, lat) {
let self = this,
t = function() {
let t = {
success: function(res) {
let e = res.wxMarkerData[0];
let i = e.address;
self.location = i
},
fail: function(error) {
// n.error(a), console.log(a);
}
};
if (lat && long) {
let e = lat + "," + long
// let e = "113.88308" + ',' + "22.55329"
// let e = "22.55329" + ',' + "113.88308"
t.location = e;
}
h.regeocoding(t);
};
t()
},
/**
* 自动定位
*/
autoLocation() {
let that = this
uni.chooseLocation({
success: function(res) {
that.address = res.address + res.name
},
fail: function(res) {
// uni.showToast({
// title: '定位失败'
// })
}
});
},
async submitForm() {
let self = this
let params = {
type: self.type,
address: self.address
}
let res = await self.$u.api.syncAddress(params)
if(res && res.code == 200) {
self.$u.route({
type: 'redirect',
url: "pages/mine/address/index",
params: {
sync: true
}
})
}
} }
} }
}; };
...@@ -69,25 +197,49 @@ export default { ...@@ -69,25 +197,49 @@ export default {
font-size: 28rpx; font-size: 28rpx;
} }
.wrap { .wrap {
background-color: #f2f2f2; background-color: #FFFFFF;
width: 750rpx;
height: 100vh;
.top { .top {
background-color: #ffffff; background-color: #ffffff;
border-top: solid 2rpx $u-border-color; padding: 10rpx 30rpx 0 30rpx;
padding: 22rpx;
.item { .item {
display: flex; display: flex;
font-size: 32rpx; font-size: 28rpx;
line-height: 100rpx; font-weight: 400;
color: #333333;
line-height: 88rpx;
align-items: center; align-items: center;
border-bottom: solid 2rpx $u-border-color; border-bottom: solid 2rpx $u-border-color;
.left { .left {
width: 180rpx; width: 88rpx;
color: #999999;
} }
input { input {
text-align: left; text-align: left;
} }
} }
/deep/ .u-field {
padding: 24rpx 0;
border-bottom: solid 2rpx $u-border-color;
.u-label-text {
font-weight: 400;
color: #999999;
}
textarea {
line-height: 40rpx;
}
.u-button-wrap {
align-self: flex-start;
margin-left: 42rpx;
}
.right {
font-size: 24rpx;
font-weight: 400;
color: #2272FF;
line-height: 40rpx;
}
}
.address { .address {
padding: 20rpx 0; padding: 20rpx 0;
textarea { textarea {
...@@ -124,38 +276,10 @@ export default { ...@@ -124,38 +276,10 @@ export default {
} }
} }
.bottom { .bottom {
margin-top: 20rpx; margin-top: 160rpx;
padding: 40rpx; padding: 0 40rpx;
padding-right: 0;
background-color: #ffffff; background-color: #ffffff;
font-size: 28rpx; font-size: 28rpx;
.tag {
display: flex;
.left {
width: 160rpx;
}
.right {
display: flex;
flex-wrap: wrap;
.tags {
width: 140rpx;
padding: 16rpx 8rpx;
border: solid 2rpx $u-border-color;
text-align: center;
border-radius: 50rpx;
margin: 0 10rpx 20rpx;
display: flex;
font-size: 28rpx;
align-items: center;
justify-content: center;
color: $u-content-color;
line-height: 1;
}
.plus {
//padding: 10rpx 0;
}
}
}
.default { .default {
margin-top: 50rpx; margin-top: 50rpx;
display: flex; display: flex;
...@@ -169,5 +293,65 @@ export default { ...@@ -169,5 +293,65 @@ export default {
} }
} }
} }
.save-pop {
padding: 0 30rpx;
.header {
text-align: center;
font-size: 40rpx;
font-weight: bold;
color: #333333;
border-bottom: solid 2rpx #F4F5F7;
line-height: 40rpx;
padding: 60rpx 0 40rpx 0;
}
.content {
margin-top: 80rpx;
margin-bottom: 116rpx;
.tips {
text-align: center;
font-size: 28rpx;
font-weight: 400;
color: #999999;
line-height: 28rpx;
}
}
}
/deep/ .pop-bottom {
padding: 0 16rpx;
margin-top: 0;
display: flex;
justify-content: space-between;
button {
width: 300rpx;
height: 104rpx;
border-radius: 52rpx;
padding: 0;
}
.plain {
border: 2px solid #2272FF;
color: #2272FF;
}
.solid {
color: #FFFFFF;
background-color: #2272FF;
}
}
}
.btn {
padding: 30rpx;
border-radius: 52rpx;
line-height: 44rpx;
font-size: 32rpx;
text-align: center;
background-color: #2272ff;
color: #fff;
&::after {
content: '';
height: 0;
border: none;
}
} }
</style> </style>
<template> <template>
<view class="address-wrap"> <view class="address-wrap">
<w-navbar title="收货地址"></w-navbar> <w-navbar title="收货地址"></w-navbar>
<view class="item" v-for="(res, sindex) in siteList" :key="res.id"> <view class="item">
<view class="top"> <view class="top">
<view class="name">{{ res.name }}</view> <view class="name">{{ settledInfo.id_card_name || settledInfo.nickname || settledInfo.name || '--' }}</view>
<view class="phone">{{ res.phone }}</view> <view class="phone">{{ settledInfo.mobile }}</view>
</view> </view>
<view class="bottom"> <view class="bottom">
<view class="address">广东省深圳市宝安区宝城67区留芳路6号庭威产业园3栋10C</view> <view class="address">{{ settledInfo.address }}</view>
<u-icon :name="editPen" :size="32" color="#999999"></u-icon> <u-icon :name="editPen" :size="32" color="#999999" @tap="toAddSite('修改地址')"></u-icon>
</view> </view>
<view class="default" v-show="true"> <view class="default" v-show="true">
<u-icon name="checkmark-circle" color="#2272FF" size="32"></u-icon> <u-icon name="checkmark-circle" color="#2272FF" size="32"></u-icon>
<text class="txt">默认地址</text> <text class="txt">默认地址</text>
</view> </view>
</view> </view>
<view class="addSite" @tap="toAddSite"> <!-- <view class="addSite" @tap="toAddSite('新增地址')">
<view class="add"> <view class="add">
<u-icon name="plus" color="#ffffff" class="icon" :size="30"></u-icon>新建收货地址 <u-icon name="plus" color="#ffffff" class="icon" :size="30"></u-icon>新建收货地址
</view> </view>
</view> </view> -->
</view> </view>
</template> </template>
<script> <script>
const app = getApp();
export default { export default {
data() { data() {
return { return {
background: { background: {
backgroundColor: 'none' backgroundColor: 'none'
}, },
settledInfo: null,
siteList: [] siteList: []
}; };
}, },
onLoad() { onLoad(e) {
this.getData(); if(e && e.sync) {
this.getData();
} else {
if(this.vuex_token && this.vuex_settled) {
this.settledInfo = this.vuex_settled
} else {
this.getData();
}
}
}, },
computed: { computed: {
editPen() { editPen() {
...@@ -43,45 +53,23 @@ export default { ...@@ -43,45 +53,23 @@ export default {
}, },
methods: { methods: {
getData() { getData() {
this.siteList = [ let self = this
{ const callBack = (vm, result) => {
id: 1, // 后台自动判断入驻流程是否完成,前台通过status确定状态
name: '游X', if (result && result.record) {
phone: '183****5523', self.settledInfo = result.record
tag: [
{
tagText: '默认'
},
{
tagText: '家'
}
],
site: '广东省深圳市宝安区宝城67区留芳路6号庭威产业园3栋10C'
},
{
id: 2,
name: '李XX',
phone: '183****5555',
tag: [
{
tagText: '公司'
}
],
site: '广东省深圳市宝安区 翻身路xx号'
},
{
id: 3,
name: '王YY',
phone: '153****5555',
tag: [],
site: '广东省深圳市宝安区 平安路13号'
} }
]; };
app.getBaseInfo(self, callBack);
}, },
toAddSite(){ toAddSite(title){
uni.navigateTo({ this.$u.route({
url: '/pages/mine/address/addSite' type: 'redirect',
}); url: 'pages/mine/address/addSite',
params: {
title: title
}
})
} }
} }
}; };
......
...@@ -35,7 +35,7 @@ const store = new Vuex.Store({ ...@@ -35,7 +35,7 @@ const store = new Vuex.Store({
vuex_version: '1.0.1', vuex_version: '1.0.1',
vuex_config: {}, vuex_config: {},
// 入驻信息 // 入驻信息
vuex_settled: {}, vuex_settled: null,
vuex_wx_uid: lifeData.vuex_wx_uid || 0, vuex_wx_uid: lifeData.vuex_wx_uid || 0,
}, },
mutations: { mutations: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment