fix 修改主题色,完善收货地址
This commit is contained in:
parent
1e70076d96
commit
c22a924221
1
app.wxss
1
app.wxss
@ -1,3 +1,2 @@
|
|||||||
@import 'style/iconfont.wxss';
|
@import 'style/iconfont.wxss';
|
||||||
|
|
||||||
@import 'style/theme.wxss';
|
@import 'style/theme.wxss';
|
@ -4038,7 +4038,7 @@ export const areaData = [
|
|||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
label: '上海市',
|
label: '上海市',
|
||||||
value: '310100',
|
value: '310010',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
label: '黄浦区',
|
label: '黄浦区',
|
||||||
|
@ -8,6 +8,7 @@ Page({
|
|||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
|
back: true,
|
||||||
bg_image: "",
|
bg_image: "",
|
||||||
checked: true,
|
checked: true,
|
||||||
code: ""
|
code: ""
|
||||||
@ -24,7 +25,13 @@ Page({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 登录请求
|
// 登录请求
|
||||||
login(data)
|
login(data).then((res) => {
|
||||||
|
if (res.data != null) {
|
||||||
|
that.setData({
|
||||||
|
back: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {}
|
} else {}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -76,9 +83,12 @@ Page({
|
|||||||
* 生命周期函数--监听页面卸载
|
* 生命周期函数--监听页面卸载
|
||||||
*/
|
*/
|
||||||
onUnload() {
|
onUnload() {
|
||||||
wx.navigateTo({
|
let that = this
|
||||||
url: `/pages/home/home`
|
if (that.data.back == true) {
|
||||||
});
|
wx.reLaunch({
|
||||||
|
url: '/pages/home/home'
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,13 +1,25 @@
|
|||||||
import Toast from 'tdesign-miniprogram/toast/index';
|
import Toast from 'tdesign-miniprogram/toast/index';
|
||||||
import { fetchDeliveryAddress } from '../../../../services/address/fetchAddress';
|
import {
|
||||||
import { areaData } from '../../../../config/index';
|
fetchDeliveryAddress
|
||||||
import { resolveAddress, rejectAddress } from './util';
|
} from '~/services/address/fetchAddress';
|
||||||
|
import {
|
||||||
|
addOrUpdateAddress
|
||||||
|
} from '~/services/address/addOrUpdateAddress';
|
||||||
|
import {
|
||||||
|
areaData
|
||||||
|
} from '~/config/index';
|
||||||
|
|
||||||
|
|
||||||
const innerPhoneReg = '^1(?:3\\d|4[4-9]|5[0-35-9]|6[67]|7[0-8]|8\\d|9\\d)\\d{8}$';
|
const innerPhoneReg = '^1(?:3\\d|4[4-9]|5[0-35-9]|6[67]|7[0-8]|8\\d|9\\d)\\d{8}$';
|
||||||
const innerNameReg = '^[a-zA-Z\\d\\u4e00-\\u9fa5]+$';
|
const innerNameReg = '^[a-zA-Z\\d\\u4e00-\\u9fa5]+$';
|
||||||
const labelsOptions = [
|
const labelsOptions = [{
|
||||||
{ id: 0, name: '家' },
|
id: 0,
|
||||||
{ id: 1, name: '公司' },
|
name: '家'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: '公司'
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
@ -47,15 +59,17 @@ Page({
|
|||||||
privateData: {
|
privateData: {
|
||||||
verifyTips: '',
|
verifyTips: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
const { id } = options;
|
const {
|
||||||
|
id
|
||||||
|
} = options;
|
||||||
this.init(id);
|
this.init(id);
|
||||||
},
|
},
|
||||||
|
|
||||||
onUnload() {
|
onUnload() {
|
||||||
if (!this.hasSava) {
|
|
||||||
rejectAddress();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
hasSava: false,
|
hasSava: false,
|
||||||
@ -65,10 +79,17 @@ Page({
|
|||||||
this.getAddressDetail(Number(id));
|
this.getAddressDetail(Number(id));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 获取收货地址详情 */
|
||||||
getAddressDetail(id) {
|
getAddressDetail(id) {
|
||||||
fetchDeliveryAddress(id).then((detail) => {
|
fetchDeliveryAddress(id).then((detail) => {
|
||||||
this.setData({ locationState: detail }, () => {
|
this.setData({
|
||||||
const { isLegal, tips } = this.onVerifyInputLegal();
|
locationState: detail
|
||||||
|
}, () => {
|
||||||
|
const {
|
||||||
|
isLegal,
|
||||||
|
tips
|
||||||
|
} = this.onVerifyInputLegal();
|
||||||
this.setData({
|
this.setData({
|
||||||
submitActive: isLegal,
|
submitActive: isLegal,
|
||||||
});
|
});
|
||||||
@ -76,12 +97,17 @@ Page({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 地区Change事件 */
|
||||||
onInputValue(e) {
|
onInputValue(e) {
|
||||||
const { item } = e.currentTarget.dataset;
|
const {
|
||||||
|
item
|
||||||
|
} = e.currentTarget.dataset;
|
||||||
if (item === 'address') {
|
if (item === 'address') {
|
||||||
const { selectedOptions = [] } = e.detail;
|
const {
|
||||||
this.setData(
|
selectedOptions = []
|
||||||
{
|
} = e.detail;
|
||||||
|
this.setData({
|
||||||
'locationState.provinceCode': selectedOptions[0].value,
|
'locationState.provinceCode': selectedOptions[0].value,
|
||||||
'locationState.provinceName': selectedOptions[0].label,
|
'locationState.provinceName': selectedOptions[0].label,
|
||||||
'locationState.cityName': selectedOptions[1].label,
|
'locationState.cityName': selectedOptions[1].label,
|
||||||
@ -91,7 +117,10 @@ Page({
|
|||||||
areaPickerVisible: false,
|
areaPickerVisible: false,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
const { isLegal, tips } = this.onVerifyInputLegal();
|
const {
|
||||||
|
isLegal,
|
||||||
|
tips
|
||||||
|
} = this.onVerifyInputLegal();
|
||||||
this.setData({
|
this.setData({
|
||||||
submitActive: isLegal,
|
submitActive: isLegal,
|
||||||
});
|
});
|
||||||
@ -99,13 +128,17 @@ Page({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const { value = '' } = e.detail;
|
const {
|
||||||
this.setData(
|
value = ''
|
||||||
{
|
} = e.detail;
|
||||||
|
this.setData({
|
||||||
[`locationState.${item}`]: value,
|
[`locationState.${item}`]: value,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
const { isLegal, tips } = this.onVerifyInputLegal();
|
const {
|
||||||
|
isLegal,
|
||||||
|
tips
|
||||||
|
} = this.onVerifyInputLegal();
|
||||||
this.setData({
|
this.setData({
|
||||||
submitActive: isLegal,
|
submitActive: isLegal,
|
||||||
});
|
});
|
||||||
@ -115,12 +148,18 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPickArea() {
|
onPickArea() {
|
||||||
this.setData({ areaPickerVisible: true });
|
this.setData({
|
||||||
|
areaPickerVisible: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onPickLabels(e) {
|
onPickLabels(e) {
|
||||||
const { item } = e.currentTarget.dataset;
|
|
||||||
const {
|
const {
|
||||||
locationState: { labelIndex = undefined },
|
item
|
||||||
|
} = e.currentTarget.dataset;
|
||||||
|
const {
|
||||||
|
locationState: {
|
||||||
|
labelIndex = undefined
|
||||||
|
},
|
||||||
labels = [],
|
labels = [],
|
||||||
} = this.data;
|
} = this.data;
|
||||||
let payload = {
|
let payload = {
|
||||||
@ -128,7 +167,10 @@ Page({
|
|||||||
addressTag: labels[item].name,
|
addressTag: labels[item].name,
|
||||||
};
|
};
|
||||||
if (item === labelIndex) {
|
if (item === labelIndex) {
|
||||||
payload = { labelIndex: null, addressTag: '' };
|
payload = {
|
||||||
|
labelIndex: null,
|
||||||
|
addressTag: ''
|
||||||
|
};
|
||||||
}
|
}
|
||||||
this.setData({
|
this.setData({
|
||||||
'locationState.labelIndex': payload.labelIndex,
|
'locationState.labelIndex': payload.labelIndex,
|
||||||
@ -141,10 +183,16 @@ Page({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
confirmHandle() {
|
confirmHandle() {
|
||||||
const { labels, labelValue } = this.data;
|
const {
|
||||||
|
labels,
|
||||||
|
labelValue
|
||||||
|
} = this.data;
|
||||||
this.setData({
|
this.setData({
|
||||||
visible: false,
|
visible: false,
|
||||||
labels: [...labels, { id: labels[labels.length - 1].id + 1, name: labelValue }],
|
labels: [...labels, {
|
||||||
|
id: labels[labels.length - 1].id + 1,
|
||||||
|
name: labelValue
|
||||||
|
}],
|
||||||
labelValue: '',
|
labelValue: '',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -154,15 +202,25 @@ Page({
|
|||||||
labelValue: '',
|
labelValue: '',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onCheckDefaultAddress({ detail }) {
|
onCheckDefaultAddress({
|
||||||
const { value } = detail;
|
detail
|
||||||
|
}) {
|
||||||
|
const {
|
||||||
|
value
|
||||||
|
} = detail;
|
||||||
this.setData({
|
this.setData({
|
||||||
'locationState.isDefault': value,
|
'locationState.isDefault': value,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 表单验证 */
|
||||||
onVerifyInputLegal() {
|
onVerifyInputLegal() {
|
||||||
const { name, phone, detailAddress, districtName } = this.data.locationState;
|
const {
|
||||||
|
name,
|
||||||
|
phone,
|
||||||
|
detailAddress,
|
||||||
|
districtName
|
||||||
|
} = this.data.locationState;
|
||||||
const prefixPhoneReg = String(this.properties.phoneReg || innerPhoneReg);
|
const prefixPhoneReg = String(this.properties.phoneReg || innerPhoneReg);
|
||||||
const prefixNameReg = String(this.properties.nameReg || innerNameReg);
|
const prefixNameReg = String(this.properties.nameReg || innerNameReg);
|
||||||
const nameRegExp = new RegExp(prefixNameReg);
|
const nameRegExp = new RegExp(prefixNameReg);
|
||||||
@ -216,7 +274,10 @@ Page({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
builtInSearch({ code, name }) {
|
builtInSearch({
|
||||||
|
code,
|
||||||
|
name
|
||||||
|
}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
wx.getSetting({
|
wx.getSetting({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
@ -259,7 +320,10 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onSearchAddress() {
|
onSearchAddress() {
|
||||||
this.builtInSearch({ code: 'scope.userLocation', name: '地址位置' }).then(() => {
|
this.builtInSearch({
|
||||||
|
code: 'scope.userLocation',
|
||||||
|
name: '地址位置'
|
||||||
|
}).then(() => {
|
||||||
wx.chooseLocation({
|
wx.chooseLocation({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.name) {
|
if (res.name) {
|
||||||
@ -294,8 +358,12 @@ Page({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 保存 */
|
||||||
formSubmit() {
|
formSubmit() {
|
||||||
const { submitActive } = this.data;
|
const {
|
||||||
|
submitActive
|
||||||
|
} = this.data;
|
||||||
if (!submitActive) {
|
if (!submitActive) {
|
||||||
Toast({
|
Toast({
|
||||||
context: this,
|
context: this,
|
||||||
@ -306,46 +374,50 @@ Page({
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { locationState } = this.data;
|
const {
|
||||||
|
locationState
|
||||||
|
} = this.data;
|
||||||
|
|
||||||
this.hasSava = true;
|
this.hasSava = true;
|
||||||
|
|
||||||
resolveAddress({
|
addOrUpdateAddress({
|
||||||
saasId: '88888888',
|
CustomerAddressId: locationState.customerAddressId,
|
||||||
uid: `88888888205500`,
|
CustomerAddressGuid: locationState.customerAddressGuid,
|
||||||
authToken: null,
|
// countryName: locationState.countryName, // 国家
|
||||||
id: locationState.addressId,
|
// countryCode: locationState.countryCode,
|
||||||
addressId: locationState.addressId,
|
ProvinceCode: locationState.provinceCode, // 省Code
|
||||||
phone: locationState.phone,
|
CityCode: locationState.cityCode, // 市Code
|
||||||
name: locationState.name,
|
DistrictCode: locationState.districtCode, // 区Code
|
||||||
countryName: locationState.countryName,
|
CustomerAddressPhone: locationState.phone, // 手机号
|
||||||
countryCode: locationState.countryCode,
|
CustomerAddressName: locationState.name, // 收货人
|
||||||
provinceName: locationState.provinceName,
|
CustomerAddressDetailed: locationState.detailAddress, // 地址
|
||||||
provinceCode: locationState.provinceCode,
|
IsDefault: locationState.isDefault === true ? 1 : 0, // 是否为默认地址
|
||||||
cityName: locationState.cityName,
|
}).then((res) => {
|
||||||
cityCode: locationState.cityCode,
|
wx.reLaunch({
|
||||||
districtName: locationState.districtName,
|
url: '/pages/usercenter/address/list/index',
|
||||||
districtCode: locationState.districtCode,
|
})
|
||||||
detailAddress: locationState.detailAddress,
|
|
||||||
isDefault: locationState.isDefault === 1 ? 1 : 0,
|
|
||||||
addressTag: locationState.addressTag,
|
|
||||||
latitude: locationState.latitude,
|
|
||||||
longitude: locationState.longitude,
|
|
||||||
storeId: null,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
wx.navigateBack({ delta: 1 });
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/** 获取微信地址 */
|
||||||
getWeixinAddress(e) {
|
getWeixinAddress(e) {
|
||||||
const { locationState } = this.data;
|
const {
|
||||||
|
locationState
|
||||||
|
} = this.data;
|
||||||
const weixinAddress = e.detail;
|
const weixinAddress = e.detail;
|
||||||
this.setData(
|
this.setData({
|
||||||
{
|
locationState: {
|
||||||
locationState: { ...locationState, ...weixinAddress },
|
...locationState,
|
||||||
|
...weixinAddress
|
||||||
|
},
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
const { isLegal, tips } = this.onVerifyInputLegal();
|
const {
|
||||||
|
isLegal,
|
||||||
|
tips
|
||||||
|
} = this.onVerifyInputLegal();
|
||||||
this.setData({
|
this.setData({
|
||||||
submitActive: isLegal,
|
submitActive: isLegal,
|
||||||
});
|
});
|
||||||
@ -353,4 +425,4 @@ Page({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
@ -69,7 +69,7 @@
|
|||||||
</t-cell>
|
</t-cell>
|
||||||
|
|
||||||
<view class="divider-line" />
|
<view class="divider-line" />
|
||||||
<t-cell
|
<!-- <t-cell
|
||||||
class="form-cell"
|
class="form-cell"
|
||||||
t-class-note="t-cell-note address__tag"
|
t-class-note="t-cell-note address__tag"
|
||||||
t-class-title="t-cell-title"
|
t-class-title="t-cell-title"
|
||||||
@ -92,7 +92,7 @@
|
|||||||
<t-icon name="add" size="40rpx" color="#bbb" />
|
<t-icon name="add" size="40rpx" color="#bbb" />
|
||||||
</t-button>
|
</t-button>
|
||||||
</view>
|
</view>
|
||||||
</t-cell>
|
</t-cell> -->
|
||||||
<view class="divider-line" />
|
<view class="divider-line" />
|
||||||
<t-cell title="设置为默认收货地址" bordered="{{false}}">
|
<t-cell title="设置为默认收货地址" bordered="{{false}}">
|
||||||
<t-switch
|
<t-switch
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
let addressPromise = [];
|
|
||||||
|
|
||||||
/** 地址编辑Promise */
|
|
||||||
export const getAddressPromise = () => {
|
|
||||||
let resolver;
|
|
||||||
let rejecter;
|
|
||||||
const nextPromise = new Promise((resolve, reject) => {
|
|
||||||
resolver = resolve;
|
|
||||||
rejecter = reject;
|
|
||||||
});
|
|
||||||
|
|
||||||
addressPromise.push({ resolver, rejecter });
|
|
||||||
|
|
||||||
return nextPromise;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 用户保存了一个地址 */
|
|
||||||
export const resolveAddress = (address) => {
|
|
||||||
const allAddress = [...addressPromise];
|
|
||||||
addressPromise = [];
|
|
||||||
|
|
||||||
console.info('用户保存了一个地址', address);
|
|
||||||
|
|
||||||
allAddress.forEach(({ resolver }) => resolver(address));
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 取消编辑 */
|
|
||||||
export const rejectAddress = () => {
|
|
||||||
const allAddress = [...addressPromise];
|
|
||||||
addressPromise = [];
|
|
||||||
|
|
||||||
allAddress.forEach(({ rejecter }) => rejecter(new Error('cancel')));
|
|
||||||
};
|
|
@ -1,14 +1,13 @@
|
|||||||
/* eslint-disable no-param-reassign */
|
/* eslint-disable no-param-reassign */
|
||||||
import { fetchDeliveryAddressList } from '../../../../services/address/fetchAddress';
|
import { fetchDeliveryAddressList } from '~/services/address/fetchAddress';
|
||||||
import Toast from 'tdesign-miniprogram/toast/index';
|
import Toast from 'tdesign-miniprogram/toast/index';
|
||||||
import { resolveAddress, rejectAddress } from './util';
|
import { resolveAddress, rejectAddress } from './util';
|
||||||
import { getAddressPromise } from '../edit/util';
|
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
addressList: [],
|
addressList: [],
|
||||||
deleteID: '',
|
deleteID: '',
|
||||||
showDeleteConfirm: false,
|
showDeleteConfirm: true,
|
||||||
isOrderSure: false,
|
isOrderSure: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -26,26 +25,29 @@ Page({
|
|||||||
this.selectMode = !!selectMode;
|
this.selectMode = !!selectMode;
|
||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.getAddressList();
|
this.getAddressList();
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
if (this.selectMode && !this.hasSelect) {
|
if (this.selectMode && !this.hasSelect) {
|
||||||
rejectAddress();
|
rejectAddress(this.data.addressList);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 获取收货地址列表 */
|
||||||
getAddressList() {
|
getAddressList() {
|
||||||
const { id } = this.data;
|
const { id } = this.data;
|
||||||
fetchDeliveryAddressList().then((addressList) => {
|
fetchDeliveryAddressList().then((addressList) => {
|
||||||
addressList.forEach((address) => {
|
addressList.forEach((address) => {
|
||||||
if (address.id === id) {
|
if (address.customerAddressGuid === id) {
|
||||||
address.checked = true;
|
address.checked = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.setData({ addressList });
|
this.setData({ addressList });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 获取微信地址 */
|
||||||
getWXAddressHandle() {
|
getWXAddressHandle() {
|
||||||
wx.chooseAddress({
|
wx.chooseAddress({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
@ -80,6 +82,8 @@ Page({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 删除地址操作 */
|
||||||
confirmDeleteHandle({ detail }) {
|
confirmDeleteHandle({ detail }) {
|
||||||
const { id } = detail || {};
|
const { id } = detail || {};
|
||||||
if (id !== undefined) {
|
if (id !== undefined) {
|
||||||
@ -109,83 +113,25 @@ Page({
|
|||||||
showDeleteConfirm: false,
|
showDeleteConfirm: false,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
editAddressHandle({ detail }) {
|
|
||||||
this.waitForNewAddress();
|
|
||||||
|
|
||||||
const { id } = detail || {};
|
/** 跳转编辑 */
|
||||||
wx.navigateTo({ url: `/pages/usercenter/address/edit/index?id=${id}` });
|
editAddressHandle({ detail }) {
|
||||||
|
const { customerAddressId } = detail || {};
|
||||||
|
wx.navigateTo({ url: `/pages/usercenter/address/edit/index?id=${customerAddressId}` });
|
||||||
},
|
},
|
||||||
selectHandle({ detail }) {
|
selectHandle({ detail }) {
|
||||||
if (this.selectMode) {
|
if (this.selectMode) {
|
||||||
this.hasSelect = true;
|
this.hasSelect = true;
|
||||||
resolveAddress(detail);
|
resolveAddress(this.data.addressList,detail);
|
||||||
wx.navigateBack({ delta: 1 });
|
wx.navigateBack({ delta: 1 });
|
||||||
} else {
|
} else {
|
||||||
this.editAddressHandle({ detail });
|
this.editAddressHandle({ detail });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 跳转添加 */
|
||||||
createHandle() {
|
createHandle() {
|
||||||
this.waitForNewAddress();
|
|
||||||
wx.navigateTo({ url: '/pages/usercenter/address/edit/index' });
|
wx.navigateTo({ url: '/pages/usercenter/address/edit/index' });
|
||||||
},
|
},
|
||||||
|
|
||||||
waitForNewAddress() {
|
|
||||||
getAddressPromise()
|
|
||||||
.then((newAddress) => {
|
|
||||||
let addressList = [...this.data.addressList];
|
|
||||||
|
|
||||||
newAddress.phoneNumber = newAddress.phone;
|
|
||||||
newAddress.address = `${newAddress.provinceName}${newAddress.cityName}${newAddress.districtName}${newAddress.detailAddress}`;
|
|
||||||
newAddress.tag = newAddress.addressTag;
|
|
||||||
|
|
||||||
if (!newAddress.addressId) {
|
|
||||||
newAddress.id = `${addressList.length}`;
|
|
||||||
newAddress.addressId = `${addressList.length}`;
|
|
||||||
|
|
||||||
if (newAddress.isDefault === 1) {
|
|
||||||
addressList = addressList.map((address) => {
|
|
||||||
address.isDefault = 0;
|
|
||||||
|
|
||||||
return address;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
newAddress.isDefault = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
addressList.push(newAddress);
|
|
||||||
} else {
|
|
||||||
addressList = addressList.map((address) => {
|
|
||||||
if (address.addressId === newAddress.addressId) {
|
|
||||||
return newAddress;
|
|
||||||
}
|
|
||||||
return address;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
addressList.sort((prevAddress, nextAddress) => {
|
|
||||||
if (prevAddress.isDefault && !nextAddress.isDefault) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (!prevAddress.isDefault && nextAddress.isDefault) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setData({
|
|
||||||
addressList: addressList,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
if (e.message !== 'cancel') {
|
|
||||||
Toast({
|
|
||||||
context: this,
|
|
||||||
selector: '#t-toast',
|
|
||||||
message: '地址编辑发生错误',
|
|
||||||
icon: '',
|
|
||||||
duration: 1000,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
extra-space="{{extraSpace}}"
|
extra-space="{{extraSpace}}"
|
||||||
class-prefix="ym"
|
class-prefix="ym"
|
||||||
address="{{address}}"
|
address="{{address}}"
|
||||||
data-id="{{address.id}}"
|
data-id="{{address.customerAddressGuid}}"
|
||||||
bind:onSelect="selectHandle"
|
bind:onSelect="selectHandle"
|
||||||
bind:onDelete="deleteAddressHandle"
|
bind:onDelete="deleteAddressHandle"
|
||||||
bind:onEdit="editAddressHandle"
|
bind:onEdit="editAddressHandle"
|
||||||
@ -33,7 +33,7 @@
|
|||||||
isCustomStyle="{{true}}"
|
isCustomStyle="{{true}}"
|
||||||
bind:navigate="waitForNewAddress"
|
bind:navigate="waitForNewAddress"
|
||||||
/>
|
/>
|
||||||
<view class="address-btn {{addressList.length >= 20 ? 'btn-default':''}}" bind:tap="createHandle">
|
<view class="address-btn root-bg-color {{addressList.length >= 20 ? 'btn-default':''}}" bind:tap="createHandle">
|
||||||
<t-icon
|
<t-icon
|
||||||
name="add"
|
name="add"
|
||||||
size="48rpx"
|
size="48rpx"
|
||||||
|
@ -82,7 +82,7 @@ page {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: #fa4126;
|
/* background-color: #fa4126; */
|
||||||
border-radius: 44rpx;
|
border-radius: 44rpx;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
@ -15,17 +15,11 @@ export const getAddressPromise = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** 用户选择了一个地址 */
|
/** 用户选择了一个地址 */
|
||||||
export const resolveAddress = (address) => {
|
export const resolveAddress = (allAddress,address) => {
|
||||||
const allAddress = [...addressPromise];
|
|
||||||
addressPromise = [];
|
|
||||||
|
|
||||||
allAddress.forEach(({ resolver }) => resolver(address));
|
allAddress.forEach(({ resolver }) => resolver(address));
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 用户没有选择任何地址只是返回上一页了 */
|
/** 用户没有选择任何地址只是返回上一页了 */
|
||||||
export const rejectAddress = () => {
|
export const rejectAddress = (allAddress) => {
|
||||||
const allAddress = [...addressPromise];
|
|
||||||
addressPromise = [];
|
|
||||||
|
|
||||||
allAddress.forEach(({ rejecter }) => rejecter(new Error('cancel')));
|
allAddress.forEach(({ rejecter }) => rejecter(new Error('cancel')));
|
||||||
};
|
};
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="label-adds">
|
<view class="label-adds">
|
||||||
<text class="adds address-info-class">
|
<text class="adds address-info-class">
|
||||||
<text wx:if="{{address.isDefault === 1}}" class="tag tag-default default-tag-class">默认</text>
|
<text wx:if="{{address.isDefault === true}}" class="tag tag-default default-tag-class">默认</text>
|
||||||
<text wx:if="{{address.tag}}" class="tag tag-primary normal-tag-class">{{address.tag}}</text>
|
<!-- <text wx:if="{{address.tag}}" class="tag tag-primary normal-tag-class">{{address.tag}}</text> -->
|
||||||
<text class="address-text">{{address.address}}</text>
|
<text class="address-text">{{address.address}}</text>
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
import { fetchPerson } from '../../../services/usercenter/fetchPerson';
|
import {
|
||||||
import { phoneEncryption } from '../../../utils/util';
|
fetchPerson
|
||||||
|
} from '~/services/usercenter/fetchPerson';
|
||||||
|
import {
|
||||||
|
updatePerson
|
||||||
|
} from '~/services/usercenter/updatePerson';
|
||||||
|
import {
|
||||||
|
phoneEncryption
|
||||||
|
} from '~/utils/util';
|
||||||
import Toast from 'tdesign-miniprogram/toast/index';
|
import Toast from 'tdesign-miniprogram/toast/index';
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
@ -11,8 +18,7 @@ Page({
|
|||||||
phoneNumber: '',
|
phoneNumber: '',
|
||||||
},
|
},
|
||||||
showUnbindConfirm: false,
|
showUnbindConfirm: false,
|
||||||
pickerOptions: [
|
pickerOptions: [{
|
||||||
{
|
|
||||||
name: '男',
|
name: '男',
|
||||||
code: '1',
|
code: '1',
|
||||||
},
|
},
|
||||||
@ -30,17 +36,51 @@ Page({
|
|||||||
init() {
|
init() {
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchData() {
|
fetchData() {
|
||||||
fetchPerson().then((personInfo) => {
|
fetchPerson().then(({
|
||||||
|
personInfo
|
||||||
|
}) => {
|
||||||
this.setData({
|
this.setData({
|
||||||
personInfo,
|
personInfo,
|
||||||
'personInfo.phoneNumber': phoneEncryption(personInfo.phoneNumber),
|
'personInfo.phoneNumber': phoneEncryption(personInfo.phoneNumber),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onClickCell({ currentTarget }) {
|
|
||||||
const { dataset } = currentTarget;
|
/** 提交 */
|
||||||
const { nickName } = this.data.personInfo;
|
submit() {
|
||||||
|
let personInfo = this.data.personInfo
|
||||||
|
let data = {
|
||||||
|
customerAvatar: personInfo.avatarUrl,
|
||||||
|
customerNickname: personInfo.nickName,
|
||||||
|
customerGender: personInfo.gender,
|
||||||
|
}
|
||||||
|
updatePerson(data).then((res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
Toast({
|
||||||
|
context: this,
|
||||||
|
selector: '#t-toast',
|
||||||
|
message: `保存成功`,
|
||||||
|
theme: 'success',
|
||||||
|
})
|
||||||
|
wx.reLaunch({
|
||||||
|
url: `/pages/usercenter/index`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 点击单元格 */
|
||||||
|
onClickCell({
|
||||||
|
currentTarget
|
||||||
|
}) {
|
||||||
|
const {
|
||||||
|
dataset
|
||||||
|
} = currentTarget;
|
||||||
|
const {
|
||||||
|
nickName
|
||||||
|
} = this.data.personInfo;
|
||||||
|
|
||||||
switch (dataset.type) {
|
switch (dataset.type) {
|
||||||
case 'gender':
|
case 'gender':
|
||||||
@ -67,9 +107,10 @@ Page({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
onConfirm(e) {
|
onConfirm(e) {
|
||||||
const { value } = e.detail;
|
const {
|
||||||
this.setData(
|
value
|
||||||
{
|
} = e.detail;
|
||||||
|
this.setData({
|
||||||
typeVisible: false,
|
typeVisible: false,
|
||||||
'personInfo.gender': value,
|
'personInfo.gender': value,
|
||||||
},
|
},
|
||||||
@ -83,7 +124,17 @@ Page({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 修改昵称 */
|
||||||
|
changeNickName(e) {
|
||||||
|
this.setData({
|
||||||
|
'personInfo.nickName': e.detail.value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 修改头像 */
|
||||||
async toModifyAvatar() {
|
async toModifyAvatar() {
|
||||||
|
let that = this
|
||||||
try {
|
try {
|
||||||
const tempFilePath = await new Promise((resolve, reject) => {
|
const tempFilePath = await new Promise((resolve, reject) => {
|
||||||
wx.chooseImage({
|
wx.chooseImage({
|
||||||
@ -91,24 +142,47 @@ Page({
|
|||||||
sizeType: ['compressed'],
|
sizeType: ['compressed'],
|
||||||
sourceType: ['album', 'camera'],
|
sourceType: ['album', 'camera'],
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
const { path, size } = res.tempFiles[0];
|
const {
|
||||||
|
path,
|
||||||
|
size
|
||||||
|
} = res.tempFiles[0];
|
||||||
|
const tempFilePaths = res.tempFilePaths;
|
||||||
|
let tempFilePath = tempFilePaths[0];
|
||||||
|
// 上传图片到服务器
|
||||||
|
wx.uploadFile({
|
||||||
|
url: 'http://localhost:8888/api/Common/UploadFile', // 上传接口地址
|
||||||
|
filePath: tempFilePath, // 要上传的文件的临时路径
|
||||||
|
name: 'file', // 上传文件对应的字段名
|
||||||
|
success: function (uploadRes) {
|
||||||
|
// 上传成功,服务器返回的数据
|
||||||
|
let url = JSON.parse(uploadRes.data).data.url
|
||||||
|
that.setData({
|
||||||
|
'personInfo.avatarUrl': url
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
fail: function (uploadError) {
|
||||||
|
// 上传失败,处理错误
|
||||||
|
console.error(uploadError);
|
||||||
|
}
|
||||||
|
});
|
||||||
if (size <= 10485760) {
|
if (size <= 10485760) {
|
||||||
resolve(path);
|
resolve(path);
|
||||||
} else {
|
} else {
|
||||||
reject({ errMsg: '图片大小超出限制,请重新上传' });
|
reject({
|
||||||
|
errMsg: '图片大小超出限制,请重新上传'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => reject(err),
|
fail: (err) => reject(err),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const tempUrlArr = tempFilePath.split('/');
|
|
||||||
const tempFileName = tempUrlArr[tempUrlArr.length - 1];
|
|
||||||
Toast({
|
Toast({
|
||||||
context: this,
|
context: this,
|
||||||
selector: '#t-toast',
|
selector: '#t-toast',
|
||||||
message: `已选择图片-${tempFileName}`,
|
message: `头像上传成功`,
|
||||||
theme: 'success',
|
theme: 'success',
|
||||||
});
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.errMsg === 'chooseImage:fail cancel') return;
|
if (error.errMsg === 'chooseImage:fail cancel') return;
|
||||||
Toast({
|
Toast({
|
||||||
@ -119,4 +193,4 @@ Page({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
@ -7,6 +7,9 @@
|
|||||||
"t-image": "/components/webp-image/index",
|
"t-image": "/components/webp-image/index",
|
||||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||||
"t-select-picker": "../components/ui-select-picker/index"
|
"t-select-picker": "../components/ui-select-picker/index",
|
||||||
|
"t-upload": "tdesign-miniprogram/upload/upload",
|
||||||
|
"t-avatar": "tdesign-miniprogram/avatar/avatar",
|
||||||
|
"t-input": "tdesign-miniprogram/input/input"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,17 +8,10 @@
|
|||||||
arrow
|
arrow
|
||||||
t-class-left="order-group__left"
|
t-class-left="order-group__left"
|
||||||
>
|
>
|
||||||
<t-image slot="note" src="{{personInfo.avatarUrl}}" t-class="avatarUrl" mode="aspectFill" />
|
<t-avatar slot="note" image="{{personInfo.avatarUrl}}" class="user-center-card__header__avatar" />
|
||||||
|
<!-- <t-image slot="note" src="{{personInfo.avatarUrl}}" t-class="avatarUrl" mode="aspectFill" /> -->
|
||||||
</t-cell>
|
</t-cell>
|
||||||
<t-cell
|
<t-input value="{{ personInfo.nickName }}" label="昵称" placeholder="请输入昵称" align="right" bindchange="changeNickName" />
|
||||||
title="昵称"
|
|
||||||
arrow
|
|
||||||
note="{{personInfo.nickName}}"
|
|
||||||
data-type="name"
|
|
||||||
bind:click="onClickCell"
|
|
||||||
t-class="t-cell-class"
|
|
||||||
t-class-left="order-group__left"
|
|
||||||
/>
|
|
||||||
<t-cell
|
<t-cell
|
||||||
title="性别"
|
title="性别"
|
||||||
arrow
|
arrow
|
||||||
@ -41,7 +34,7 @@
|
|||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
</view>
|
</view>
|
||||||
<view class="person-info__wrapper">
|
<view class="person-info__wrapper">
|
||||||
<view class="person-info__btn" bind:tap="openUnbindConfirm"> 切换账号登录 </view>
|
<view class="person-info__btn root-bg-color" bind:tap="submit"> 保存 </view>
|
||||||
</view>
|
</view>
|
||||||
<t-select-picker
|
<t-select-picker
|
||||||
show="{{typeVisible}}"
|
show="{{typeVisible}}"
|
||||||
|
@ -10,6 +10,7 @@ page view {
|
|||||||
|
|
||||||
.person-info__btn {
|
.person-info__btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
color: white;
|
||||||
border: 2rpx solid #ddd;
|
border: 2rpx solid #ddd;
|
||||||
border-radius: 48rpx;
|
border-radius: 48rpx;
|
||||||
padding: 18rpx 0;
|
padding: 18rpx 0;
|
||||||
@ -21,9 +22,10 @@ page view {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0 32rpx;
|
padding: 0 32rpx;
|
||||||
padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
|
padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
|
||||||
position: absolute;
|
margin-top: 100rpx;
|
||||||
bottom: 0;
|
/* position: absolute; */
|
||||||
left: 0;
|
/* bottom: 0; */
|
||||||
|
/* left: 0; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatarUrl {
|
.avatarUrl {
|
||||||
@ -43,3 +45,10 @@ page view {
|
|||||||
.person-info .t-cell-class {
|
.person-info .t-cell-class {
|
||||||
height: 112rpx;
|
height: 112rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user-center-card__header__avatar {
|
||||||
|
width: 96rpx;
|
||||||
|
height: 96rpx;
|
||||||
|
border-radius: 48rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
@ -24,7 +24,7 @@ export function request(option) {
|
|||||||
header: {
|
header: {
|
||||||
Authorization: `Bearer ${getStorage('Authorization')}`,
|
Authorization: `Bearer ${getStorage('Authorization')}`,
|
||||||
},
|
},
|
||||||
timeout: 30000, //设置超时时间
|
timeout: 50000, //设置超时时间
|
||||||
url: ServerBasePath + url,
|
url: ServerBasePath + url,
|
||||||
data: data,
|
data: data,
|
||||||
method: method,
|
method: method,
|
||||||
|
22
services/address/addOrUpdateAddress.js
Normal file
22
services/address/addOrUpdateAddress.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import {
|
||||||
|
request
|
||||||
|
} from '../_utils/request';
|
||||||
|
|
||||||
|
|
||||||
|
/** 编辑个人资料 */
|
||||||
|
export function addOrUpdateAddress(data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: `CustomerAddressApi/addOrUpdateCustomerAddress`,
|
||||||
|
method: 'POST',
|
||||||
|
data: data,
|
||||||
|
success: function (res) {
|
||||||
|
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: function (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -1,48 +1,42 @@
|
|||||||
import { config } from '../../config/index';
|
import {
|
||||||
|
request
|
||||||
|
} from '../_utils/request';
|
||||||
|
|
||||||
/** 获取收货地址 */
|
|
||||||
function mockFetchDeliveryAddress(id) {
|
|
||||||
const { delay } = require('../_utils/delay');
|
|
||||||
const { genAddress } = require('../../model/address');
|
|
||||||
|
|
||||||
return delay().then(() => genAddress(id));
|
/** 获取收货地址详情 */
|
||||||
}
|
export function fetchDeliveryAddress(id) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
/** 获取收货地址 */
|
request({
|
||||||
export function fetchDeliveryAddress(id = 0) {
|
url: `CustomerAddressApi/getCustomerAddressDetails?CustomerAddressId=` + id,
|
||||||
if (config.useMock) {
|
method: 'GET',
|
||||||
return mockFetchDeliveryAddress(id);
|
success: function (res) {
|
||||||
}
|
let detail = res.data;
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
resolve(detail);
|
||||||
resolve('real api');
|
},
|
||||||
|
fail: function (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获取收货地址列表 */
|
|
||||||
function mockFetchDeliveryAddressList(len = 0) {
|
|
||||||
const { delay } = require('../_utils/delay');
|
|
||||||
const { genAddressList } = require('../../model/address');
|
|
||||||
|
|
||||||
return delay().then(() =>
|
|
||||||
genAddressList(len).map((address) => {
|
|
||||||
return {
|
|
||||||
...address,
|
|
||||||
phoneNumber: address.phone,
|
|
||||||
address: `${address.provinceName}${address.cityName}${address.districtName}${address.detailAddress}`,
|
|
||||||
tag: address.addressTag,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 获取收货地址列表 */
|
/** 获取收货地址列表 */
|
||||||
export function fetchDeliveryAddressList(len = 10) {
|
export function fetchDeliveryAddressList() {
|
||||||
if (config.useMock) {
|
return new Promise((resolve, reject) => {
|
||||||
return mockFetchDeliveryAddressList(len);
|
request({
|
||||||
}
|
url: `CustomerAddressApi/getCustomerAddressList`,
|
||||||
|
method: 'GET',
|
||||||
return new Promise((resolve) => {
|
success: function (res) {
|
||||||
resolve('real api');
|
let list = res.data;
|
||||||
|
|
||||||
|
resolve(list);
|
||||||
|
},
|
||||||
|
fail: function (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
23
services/address/getRegionTreeList.js
Normal file
23
services/address/getRegionTreeList.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import {
|
||||||
|
request
|
||||||
|
} from '../_utils/request';
|
||||||
|
|
||||||
|
|
||||||
|
/** 获取省市区树形列表 */
|
||||||
|
export function getRegionTreeList() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: `RegionApi/getRegionTreeList`,
|
||||||
|
method: 'GET',
|
||||||
|
success: function (res) {
|
||||||
|
let list = res.data;
|
||||||
|
|
||||||
|
resolve(list);
|
||||||
|
},
|
||||||
|
fail: function (error) {
|
||||||
|
console.log(error,'报错');
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -8,25 +8,28 @@ import {
|
|||||||
|
|
||||||
/** 登录 */
|
/** 登录 */
|
||||||
export function login(data) {
|
export function login(data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: `WeChatLogin/Login`,
|
||||||
|
method: 'POST',
|
||||||
|
data: data,
|
||||||
|
success: async function (res) {
|
||||||
|
setStorage('userInfo', res.data.user, 86400);
|
||||||
|
setStorage('Authorization', res.data.jwt, 86400);
|
||||||
|
const pages = getCurrentPages(); //获取小程序页面栈
|
||||||
|
const beforePage = pages[pages.length - 1]; //获取上个页面的实例对象 -3是上上一个页面
|
||||||
|
wx.navigateBack({
|
||||||
|
delta: 1,
|
||||||
|
});
|
||||||
|
beforePage.onLoad();
|
||||||
|
wx.showToast({
|
||||||
|
icon: 'success',
|
||||||
|
title: '登录成功',
|
||||||
|
});
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
request({
|
})
|
||||||
url: `WeChatLogin/Login`,
|
|
||||||
method: 'POST',
|
|
||||||
data: data,
|
|
||||||
success: async function (res) {
|
|
||||||
setStorage('userInfo', res.data.user, 86400);
|
|
||||||
setStorage('Authorization', res.data.jwt, 86400);
|
|
||||||
const pages = getCurrentPages(); //获取小程序页面栈
|
|
||||||
const beforePage = pages[pages.length - 1]; //获取上个页面的实例对象 -3是上上一个页面
|
|
||||||
wx.navigateBack({
|
|
||||||
delta: 2,
|
|
||||||
});
|
|
||||||
beforePage.onLoad();
|
|
||||||
wx.showToast({
|
|
||||||
icon: 'success',
|
|
||||||
title: '登录成功',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
@ -8,14 +8,16 @@ import {
|
|||||||
|
|
||||||
/** 发送验证码 */
|
/** 发送验证码 */
|
||||||
export function sendPhoneCode(data) {
|
export function sendPhoneCode(data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: `WeChatLogin/sendPhoneCode`,
|
||||||
|
method: 'POST',
|
||||||
|
data: data,
|
||||||
|
success: async function (res) {
|
||||||
|
|
||||||
request({
|
resolve(res);
|
||||||
url: `WeChatLogin/sendPhoneCode`,
|
},
|
||||||
method: 'POST',
|
});
|
||||||
data: data,
|
})
|
||||||
success: async function (res) {
|
|
||||||
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,28 +1,32 @@
|
|||||||
import { config } from '../../config/index';
|
import {
|
||||||
|
request
|
||||||
|
} from '../_utils/request';
|
||||||
|
import {
|
||||||
|
getStorage
|
||||||
|
} from '~/utils/storage'
|
||||||
|
const userData = getStorage('userInfo');
|
||||||
|
|
||||||
/** 获取个人中心信息 */
|
/** 获取个人中心详情信息 */
|
||||||
function mockFetchPerson() {
|
|
||||||
const { delay } = require('../_utils/delay');
|
|
||||||
const { genSimpleUserInfo } = require('../../model/usercenter');
|
|
||||||
const { genAddress } = require('../../model/address');
|
|
||||||
const address = genAddress();
|
|
||||||
return delay().then(() => ({
|
|
||||||
...genSimpleUserInfo(),
|
|
||||||
address: {
|
|
||||||
provinceName: address.provinceName,
|
|
||||||
provinceCode: address.provinceCode,
|
|
||||||
cityName: address.cityName,
|
|
||||||
cityCode: address.cityCode,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 获取个人中心信息 */
|
|
||||||
export function fetchPerson() {
|
export function fetchPerson() {
|
||||||
if (config.useMock) {
|
return new Promise((resolve, reject) => {
|
||||||
return mockFetchPerson();
|
request({
|
||||||
}
|
url: `CustomerApi/getCustomerDetails?CustomerGuid=` + userData?.customerGuid,
|
||||||
return new Promise((resolve) => {
|
method: 'GET',
|
||||||
resolve('real api');
|
success: function (res) {
|
||||||
|
let personInfo = res.data;
|
||||||
|
let data = {
|
||||||
|
personInfo: {
|
||||||
|
avatarUrl: personInfo.customerAvatar,
|
||||||
|
nickName: personInfo.customerNickname,
|
||||||
|
phoneNumber: personInfo.customerMobilePhoneNumber,
|
||||||
|
gender : personInfo.customerGender,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
resolve(data);
|
||||||
|
},
|
||||||
|
fail: function (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -17,17 +17,14 @@ export function logout() {
|
|||||||
removeStorage('userInfo')
|
removeStorage('userInfo')
|
||||||
removeStorage('Authorization')
|
removeStorage('Authorization')
|
||||||
|
|
||||||
// 回到上一页
|
// 回到首页
|
||||||
const pages = getCurrentPages(); //获取小程序页面栈
|
|
||||||
const beforePage = pages[pages.length - 1]; //获取上个页面的实例对象 -3是上上一个页面
|
|
||||||
wx.navigateBack({
|
|
||||||
delta: 2,
|
|
||||||
});
|
|
||||||
beforePage.onLoad();
|
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
title: '登出成功',
|
title: '登出成功',
|
||||||
});
|
});
|
||||||
|
wx.reLaunch({
|
||||||
|
url: '/pages/home/home'
|
||||||
|
})
|
||||||
resolve(res);
|
resolve(res);
|
||||||
},
|
},
|
||||||
fail: function (error) {
|
fail: function (error) {
|
||||||
|
22
services/usercenter/updatePerson.js
Normal file
22
services/usercenter/updatePerson.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import {
|
||||||
|
request
|
||||||
|
} from '../_utils/request';
|
||||||
|
|
||||||
|
|
||||||
|
/** 编辑个人资料 */
|
||||||
|
export function updatePerson(data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: `CustomerApi/UpdateCustomer`,
|
||||||
|
method: 'POST',
|
||||||
|
data: data,
|
||||||
|
success: function (res) {
|
||||||
|
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: function (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -1,4 +1,8 @@
|
|||||||
/* 主题定制 */
|
/* 主题定制 */
|
||||||
|
.root-bg-color{
|
||||||
|
background-color: #1989fa;
|
||||||
|
}
|
||||||
|
|
||||||
.t-input {
|
.t-input {
|
||||||
--td-input-placeholder-text-color: #bbbbbb;
|
--td-input-placeholder-text-color: #bbbbbb;
|
||||||
--td-input-text-color: #333333;
|
--td-input-text-color: #333333;
|
||||||
@ -10,7 +14,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.t-cascader {
|
.t-cascader {
|
||||||
--td-cascader-active-color: #fa4126;
|
--td-cascader-active-color: #1989fa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.t-switch {
|
.t-switch {
|
||||||
@ -21,13 +25,13 @@
|
|||||||
--td-button-font-weight: 500;
|
--td-button-font-weight: 500;
|
||||||
--td-button-medium-font-size: 32rpx;
|
--td-button-medium-font-size: 32rpx;
|
||||||
--td-button-default-color: #fff;
|
--td-button-default-color: #fff;
|
||||||
--td-button-default-bg-color: #fa4126;
|
--td-button-default-bg-color: #1989fa;
|
||||||
--td-button-default-border-color: #fa4126;
|
--td-button-default-border-color: #1989fa;
|
||||||
--td-button-default-disabled-color: #fff;
|
--td-button-default-disabled-color: #fff;
|
||||||
--td-button-default-disabled-bg: #cccccc;
|
--td-button-default-disabled-bg: #cccccc;
|
||||||
--td-button-default-disabled-border-color: #cccccc;
|
--td-button-default-disabled-border-color: #cccccc;
|
||||||
--td-button-default-active-bg-color: #fa4126;
|
--td-button-default-active-bg-color: #1989fa;
|
||||||
--td-button-default-active-border-color: #fa4126;
|
--td-button-default-active-border-color: #1989fa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.t-textarea {
|
.t-textarea {
|
||||||
@ -35,11 +39,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.t-checkbox {
|
.t-checkbox {
|
||||||
--td-checkbox-icon-checked-color: #fa4126;
|
--td-checkbox-icon-checked-color: #1989fa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog__button-confirm {
|
.dialog__button-confirm {
|
||||||
color: #fa4126 !important;
|
color: #1989fa !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog__button-cancel {
|
.dialog__button-cancel {
|
||||||
|
Loading…
Reference in New Issue
Block a user