1. 为所有登录跳转调用添加redirectTo跳转类型参数 2. 调整部分页面的onShow生命周期执行顺序和定时器包装 3. 补充缺失的ns-login组件引用到两个diy组件中 4. 修复部分页面登录后返回出现循环跳转的问题
971 lines
24 KiB
JavaScript
971 lines
24 KiB
JavaScript
import validate from '@/common/js/validate.js';
|
||
import memberPublic from './member-public.js';
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
registerConfig: {},
|
||
indent: 'all',
|
||
customNavTitle: "",
|
||
formData: {
|
||
userHeadImg: '',
|
||
number: '', //账号
|
||
nickName: '', //昵称
|
||
sex: '', //性别
|
||
realName: '', //真实姓名
|
||
birthday: '', //生日
|
||
currentPassword: '', //当前密码
|
||
newPassword: '', //新密码
|
||
confirmPassword: '', //确认密码
|
||
mobile: '', //手机号
|
||
mobileVercode: '', //手机验证码
|
||
mobileDynacode: '', //手机动态验证吗
|
||
mobileCodeText: "",
|
||
username: '',
|
||
provinceId: 0,
|
||
cityId: 0,
|
||
districtId: 0,
|
||
fullAddress: '',
|
||
address: ''
|
||
},
|
||
memberInfoformData: {
|
||
userHeadImg: '',
|
||
number: '', //账号
|
||
nickName: '', //昵称
|
||
sex: '', //性别
|
||
realName: '', //真实姓名
|
||
birthday: '', //生日
|
||
currentPassword: '', //当前密码
|
||
newPassword: '', //新密码
|
||
confirmPassword: '', //确认密码
|
||
mobile: '', //手机号
|
||
mobileVercode: '', //手机验证码
|
||
mobileDynacode: '', //手机动态验证吗
|
||
mobileCodeText: "",
|
||
},
|
||
langList: [],
|
||
langIndex: 0,
|
||
seconds: 120,
|
||
timer: null,
|
||
isSend: false,
|
||
captcha: {
|
||
id: '',
|
||
img: ''
|
||
},
|
||
isIphoneX: false,
|
||
items: [],
|
||
current: 0,
|
||
memberConfig: {
|
||
is_audit: 0,
|
||
is_enable: 0
|
||
},
|
||
defaultRegions: [],
|
||
};
|
||
},
|
||
onLoad(option) {
|
||
this.isIphoneX = this.$util.uniappIsIPhoneX()
|
||
this.formData.mobileCodeText = this.$lang('findanimateCode');
|
||
|
||
if (option.back) {
|
||
this.back = option.back;
|
||
}
|
||
|
||
this.getCaptcha();
|
||
|
||
if (option.action) {
|
||
this.indent = option.action;
|
||
this.setNavbarTitle()
|
||
|
||
// #ifdef MP-WEIXIN
|
||
option.action == 'bind_mobile' && this.getCode()
|
||
// #endif
|
||
}
|
||
|
||
this.getRegisterConfig();
|
||
this.initSexItems();
|
||
this.initLang();
|
||
this.getMemberConfig();
|
||
},
|
||
onShow() {
|
||
if (!this.storeToken) {
|
||
// 使用redirectTo模式:当前页被登录页替换,返回时直接回到上一页,不会产生循环
|
||
setTimeout(() => {
|
||
this.$refs.login.open('/pages_tool/member/info', 'redirectTo');
|
||
}, 100);
|
||
return;
|
||
}
|
||
this.getInfo();
|
||
},
|
||
onHide() {
|
||
this.seconds = 120;
|
||
this.formData.mobileCodeText = this.$lang('findanimateCode');
|
||
this.isSend = false;
|
||
clearInterval(this.timer);
|
||
},
|
||
watch: {
|
||
seconds(value) {
|
||
if (value == 0) {
|
||
this.seconds = 120;
|
||
this.formData.mobileCodeText = this.$lang('findanimateCode');
|
||
this.isSend = false;
|
||
clearInterval(this.timer);
|
||
}
|
||
}
|
||
},
|
||
computed: {
|
||
startDate() {
|
||
return this.getDate('start');
|
||
},
|
||
endDate() {
|
||
return this.getDate('end');
|
||
}
|
||
},
|
||
filters: {
|
||
mobile(mobile) {
|
||
return mobile.substring(0, 4 - 1) + '****' + mobile.substring(6 + 1);
|
||
}
|
||
},
|
||
methods: {
|
||
...memberPublic.methods,
|
||
// 初始化性别选项
|
||
initSexItems() {
|
||
this.items = [{
|
||
value: '0',
|
||
name: this.$lang('sexUnknown')
|
||
},
|
||
{
|
||
value: '1',
|
||
name: this.$lang('sexMale'),
|
||
checked: 'true'
|
||
},
|
||
{
|
||
value: '2',
|
||
name: this.$lang('sexFemale')
|
||
}
|
||
];
|
||
},
|
||
// 初始化语言
|
||
initLang() {
|
||
//获取语言列表
|
||
this.langList = this.$langConfig.list();
|
||
if (!uni.getStorageSync("lang")) {
|
||
this.langIndex = 0;
|
||
} else {
|
||
for (let i = 0; i < this.langList.length; i++) {
|
||
if (this.langList[i].value == uni.getStorageSync("lang")) {
|
||
this.langIndex = i;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
},
|
||
setNavbarTitle() {
|
||
let title = this.$lang('title');
|
||
switch (this.indent) {
|
||
case 'name':
|
||
title = this.$lang('modifyNickname');
|
||
break;
|
||
case 'realName':
|
||
title = this.$lang('realName');
|
||
break;
|
||
case 'sex':
|
||
title = this.$lang('sex');
|
||
break;
|
||
case 'birthday':
|
||
title = this.$lang('birthday');
|
||
break;
|
||
case 'password':
|
||
title = this.$lang('password');
|
||
break;
|
||
case 'mobile':
|
||
title = this.$lang('mobile');
|
||
break;
|
||
}
|
||
this.$langConfig.title(title);
|
||
},
|
||
// 初始化用户信息
|
||
getInfo() {
|
||
this.memberInfoformData.userHeadImg = this.memberInfo.headimg;
|
||
this.memberInfoformData.number = this.memberInfo.username; //账号
|
||
this.memberInfoformData.nickName = this.memberInfo.nickname; //昵称
|
||
this.memberInfoformData.realName = this.memberInfo.realname ? this.memberInfo.realname : this.$lang('pleaseRealName'); //真实姓名
|
||
this.memberInfoformData.sex = this.memberInfo.sex == 0 ? this.$lang('sexUnknown') : this.memberInfo.sex == 1 ? this.$lang('sexMale') : this.$lang('sexFemale'); //性别
|
||
this.memberInfoformData.birthday = this.memberInfo.birthday ? this.$util.timeStampTurnTime(this.memberInfo.birthday, 'YYYY-MM-DD') : this.$lang('pleaseSelectBirthday'); //生日
|
||
this.memberInfoformData.mobile = this.memberInfo.mobile; //手机号
|
||
|
||
this.formData.username = this.memberInfo.username; //用户名
|
||
this.formData.nickName = this.memberInfo.nickname; //昵称
|
||
this.formData.realName = this.memberInfo.realname; //真实姓名
|
||
this.formData.sex = this.memberInfo.sex; //性别
|
||
this.formData.birthday = this.memberInfo.birthday ? this.$util.timeStampTurnTime(this.memberInfo.birthday, 'YYYY-MM-DD') : ''; //生日
|
||
this.formData.provinceId = this.memberInfo.province_id;
|
||
this.formData.cityId = this.memberInfo.city_id;
|
||
this.formData.districtId = this.memberInfo.district_id;
|
||
this.formData.fullAddress = this.memberInfo.full_address;
|
||
this.formData.address = this.memberInfo.address;
|
||
if (this.memberInfo.full_address) this.defaultRegions = [this.memberInfo
|
||
.province_id, this.memberInfo.city_id, this.memberInfo.district_id
|
||
];
|
||
},
|
||
// 切换编辑项
|
||
modifyInfo(action) {
|
||
switch (action) {
|
||
case 'cancellation':
|
||
this.getCancelStatus();
|
||
break;
|
||
case 'language':
|
||
let newArray = [];
|
||
for (let i = 0; i < this.langList.length; i++) {
|
||
newArray.push(this.langList[i].name)
|
||
}
|
||
uni.showActionSheet({
|
||
itemList: newArray,
|
||
success: function (res) {
|
||
if (vm.langIndex != res.tapIndex) {
|
||
vm.$langConfig.change(vm.langList[res.tapIndex].value)
|
||
}
|
||
}
|
||
});
|
||
break;
|
||
case 'mobile':
|
||
// #ifdef MP
|
||
this.$util.redirectTo('/pages_tool/member/info_edit', {
|
||
action: 'bind_mobile'
|
||
});
|
||
// #endif
|
||
// #ifndef MP
|
||
this.$util.redirectTo('/pages_tool/member/info_edit', {
|
||
action
|
||
});
|
||
// #endif
|
||
break;
|
||
default:
|
||
this.$util.redirectTo('/pages_tool/member/info_edit', {
|
||
action
|
||
});
|
||
}
|
||
},
|
||
// 导航返回
|
||
NavReturn() {
|
||
uni.navigateBack({
|
||
delta: 1
|
||
})
|
||
},
|
||
// 获取验证码
|
||
getCaptcha() {
|
||
this.$api.sendRequest({
|
||
url: '/api/captcha/captcha',
|
||
data: {
|
||
captcha_id: this.captcha.id
|
||
},
|
||
success: res => {
|
||
if (res.code >= 0) {
|
||
this.captcha = res.data;
|
||
this.captcha.img = this.captcha.img.replace(/\r\n/g, '');
|
||
}
|
||
}
|
||
});
|
||
},
|
||
headImage() {
|
||
this.$util.redirectTo("/pages_tool/member/modify_face");
|
||
},
|
||
// 检测手机是否已绑定
|
||
async testBinding(type) {
|
||
var res = await this.checkMobile();
|
||
return res;
|
||
},
|
||
//获取注销的配置信息
|
||
getMemberConfig() {
|
||
this.$api.sendRequest({
|
||
url: '/membercancel/api/membercancel/config',
|
||
success: res => {
|
||
if (res.code >= 0) {
|
||
this.memberConfig = res.data
|
||
}
|
||
}
|
||
});
|
||
|
||
},
|
||
save(type) {
|
||
switch (type) {
|
||
case 'username':
|
||
this.modifyUserName();
|
||
break;
|
||
case 'name':
|
||
this.modifyNickName();
|
||
break;
|
||
case 'realName':
|
||
this.modifyRealName();
|
||
break;
|
||
case 'sex':
|
||
this.modifySex();
|
||
break;
|
||
case 'birthday':
|
||
this.modifyBirthday();
|
||
break;
|
||
case 'password':
|
||
this.modifyPassword();
|
||
break;
|
||
case 'mobile':
|
||
this.modifyMobile();
|
||
break;
|
||
case 'address':
|
||
this.modifyAddress();
|
||
break;
|
||
}
|
||
},
|
||
|
||
// ------------------------修改用户名------------------------------
|
||
modifyUserName() {
|
||
if (this.formData.username == this.memberInfo.username) {
|
||
this.$util.showToast({
|
||
title: this.$lang('alikeusername')
|
||
});
|
||
return;
|
||
}
|
||
var rule = [{
|
||
name: 'username',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang('noEmityUsername')
|
||
}];
|
||
if (!rule.length) return;
|
||
var checkRes = validate.check(this.formData, rule);
|
||
if (checkRes) {
|
||
this.$api.sendRequest({
|
||
url: '/api/member/modifyusername',
|
||
data: {
|
||
username: this.formData.username
|
||
},
|
||
success: res => {
|
||
if (res.code == 0) {
|
||
this.memberInfo.username = this.formData.username;
|
||
this.$store.commit('setMemberInfo', this.memberInfo);
|
||
this.$util.showToast({
|
||
title: this.$lang("updateSuccess")
|
||
});
|
||
this.NavReturn();
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
this.$util.showToast({
|
||
title: validate.error
|
||
});
|
||
}
|
||
},
|
||
// ------------------------修改昵称------------------------------
|
||
|
||
modifyNickName() {
|
||
if (this.formData.nickName == this.memberInfo.nickname) {
|
||
this.$util.showToast({
|
||
title: this.$lang('alikeNickname')
|
||
});
|
||
return;
|
||
}
|
||
var rule = [{
|
||
name: 'nickName',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang('noEmityNickname')
|
||
}];
|
||
if (!rule.length) return;
|
||
var checkRes = validate.check(this.formData, rule);
|
||
if (checkRes) {
|
||
this.$api.sendRequest({
|
||
url: '/api/member/modifynickname',
|
||
data: {
|
||
nickname: this.formData.nickName
|
||
},
|
||
success: res => {
|
||
if (res.code == 0) {
|
||
this.memberInfo.nickname = this.formData.nickName;
|
||
this.$store.commit('setMemberInfo', this.memberInfo);
|
||
this.$util.showToast({
|
||
title: this.$lang("updateSuccess")
|
||
});
|
||
this.NavReturn();
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
this.$util.showToast({
|
||
title: validate.error
|
||
});
|
||
}
|
||
},
|
||
|
||
// ------------------------修改真实姓名------------------------------
|
||
modifyRealName() {
|
||
if (this.formData.realName == this.memberInfo.realname && this.memberInfo.realname) {
|
||
this.$util.showToast({
|
||
title: this.$lang('alikeRealName')
|
||
});
|
||
return;
|
||
}
|
||
var rule = [{
|
||
name: 'realName',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang('noEmptyRealName')
|
||
}];
|
||
if (!rule.length) return;
|
||
var checkRes = validate.check(this.formData, rule);
|
||
if (checkRes) {
|
||
this.$api.sendRequest({
|
||
url: '/api/member/modifyrealname',
|
||
data: {
|
||
realname: this.formData.realName
|
||
},
|
||
success: res => {
|
||
if (res.code == 0) {
|
||
this.memberInfo.realname = this.formData.realName;
|
||
this.$store.commit('setMemberInfo', this.memberInfo);
|
||
this.$util.showToast({
|
||
title: this.$lang("updateSuccess")
|
||
});
|
||
this.NavReturn();
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
this.$util.showToast({
|
||
title: validate.error
|
||
});
|
||
}
|
||
},
|
||
|
||
// ------------------------修改性别------------------------------
|
||
radioChange: function (evt) {
|
||
for (let i = 0; i < this.items.length; i++) {
|
||
if (this.items[i].value === evt.target.value) {
|
||
this.formData.sex = i;
|
||
break;
|
||
}
|
||
}
|
||
},
|
||
|
||
modifySex() {
|
||
this.$api.sendRequest({
|
||
url: '/api/member/modifysex',
|
||
data: {
|
||
sex: this.formData.sex
|
||
},
|
||
success: res => {
|
||
if (res.code == 0) {
|
||
this.memberInfo.sex = this.formData.sex;
|
||
this.$store.commit('setMemberInfo', this.memberInfo);
|
||
this.$util.showToast({
|
||
title: this.$lang("updateSuccess")
|
||
});
|
||
this.NavReturn();
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
}
|
||
}
|
||
});
|
||
},
|
||
|
||
// ------------------------修改生日------------------------------
|
||
|
||
bindDateChange: function (e) {
|
||
this.formData.birthday = e.target.value
|
||
},
|
||
|
||
getDate(type) {
|
||
const date = new Date();
|
||
let year = date.getFullYear();
|
||
let month = date.getMonth() + 1;
|
||
let day = date.getDate();
|
||
|
||
if (type === 'start') {
|
||
year = year - 60;
|
||
} else if (type === 'end') {
|
||
year = year + 2;
|
||
}
|
||
month = month > 9 ? month : '0' + month;
|
||
day = day > 9 ? day : '0' + day;
|
||
return `${year}-${month}-${day}`;
|
||
},
|
||
|
||
modifyBirthday() {
|
||
if (this.formData.birthday.length == 0) {
|
||
this.$util.showToast({
|
||
title: this.$lang('pleaseSelectBirthday')
|
||
});
|
||
return;
|
||
}
|
||
this.$api.sendRequest({
|
||
url: '/api/member/modifybirthday',
|
||
data: {
|
||
birthday: this.$util.timeTurnTimeStamp(this.formData.birthday)
|
||
},
|
||
success: res => {
|
||
if (res.code == 0) {
|
||
this.memberInfo.birthday = this.$util.timeTurnTimeStamp(this.formData.birthday);
|
||
this.$store.commit('setMemberInfo', this.memberInfo);
|
||
this.$util.showToast({
|
||
title: this.$lang("updateSuccess")
|
||
});
|
||
this.NavReturn();
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
}
|
||
}
|
||
});
|
||
},
|
||
|
||
// ------------------------修改密码------------------------------
|
||
/**
|
||
* 获取注册配置
|
||
*/
|
||
getRegisterConfig() {
|
||
this.$api.sendRequest({
|
||
url: '/api/register/config',
|
||
success: res => {
|
||
if (res.code >= 0) {
|
||
this.registerConfig = res.data.value;
|
||
}
|
||
}
|
||
});
|
||
},
|
||
modifyPassword() {
|
||
if (this.memberInfo.password) {
|
||
var rule = [{
|
||
name: 'currentPassword',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang("pleaseInputOldPassword")
|
||
},
|
||
{
|
||
name: 'newPassword',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang("pleaseInputNewPassword")
|
||
}
|
||
];
|
||
} else {
|
||
var rule = [{
|
||
name: 'mobileVercode',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang("confirmCodeInput")
|
||
},
|
||
{
|
||
name: 'mobileDynacode',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang("animateCodeInput")
|
||
},
|
||
{
|
||
name: 'newPassword',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang("pleaseInputNewPassword")
|
||
}
|
||
];
|
||
}
|
||
|
||
let regConfig = this.registerConfig;
|
||
if (regConfig.pwd_len > 0) {
|
||
rule.push({
|
||
name: 'newPassword',
|
||
checkType: 'lengthMin',
|
||
checkRule: regConfig.pwd_len,
|
||
errorMsg: this.$lang('passwordMinLength', { num: regConfig.pwd_len })
|
||
});
|
||
}
|
||
if (regConfig.pwd_complexity) {
|
||
let passwordErrorMsg = this.$lang('passwordComplexityPrefix'),
|
||
reg = '';
|
||
let firstItem = true;
|
||
if (regConfig.pwd_complexity.indexOf('number') != -1) {
|
||
reg += '(?=.*?[0-9])';
|
||
passwordErrorMsg += (firstItem ? '' : this.$lang('passwordSeparator')) + this.$lang('passwordNumber');
|
||
firstItem = false;
|
||
}
|
||
if (regConfig.pwd_complexity.indexOf('letter') != -1) {
|
||
reg += '(?=.*?[a-z])';
|
||
passwordErrorMsg += (firstItem ? '' : this.$lang('passwordSeparator')) + this.$lang('passwordLowercase');
|
||
firstItem = false;
|
||
}
|
||
if (regConfig.pwd_complexity.indexOf('upper_case') != -1) {
|
||
reg += '(?=.*?[A-Z])';
|
||
passwordErrorMsg += (firstItem ? '' : this.$lang('passwordSeparator')) + this.$lang('passwordUppercase');
|
||
firstItem = false;
|
||
}
|
||
if (regConfig.pwd_complexity.indexOf('symbol') != -1) {
|
||
reg += '(?=.*?[#?!@$%^&*-])';
|
||
passwordErrorMsg += (firstItem ? '' : this.$lang('passwordSeparator')) + this.$lang('passwordSymbol');
|
||
firstItem = false;
|
||
}
|
||
rule.push({
|
||
name: 'newPassword',
|
||
checkType: 'reg',
|
||
checkRule: reg,
|
||
errorMsg: passwordErrorMsg
|
||
});
|
||
}
|
||
var checkRes = validate.check(this.formData, rule);
|
||
if (checkRes) {
|
||
if (this.formData.currentPassword == this.formData.newPassword) {
|
||
this.$util.showToast({
|
||
title: this.$lang('samePassword')
|
||
});
|
||
return;
|
||
}
|
||
if (this.formData.newPassword != this.formData.confirmPassword) {
|
||
this.$util.showToast({
|
||
title: this.$lang('alikePassword')
|
||
});
|
||
return;
|
||
}
|
||
this.$api.sendRequest({
|
||
url: '/api/member/modifypassword',
|
||
data: {
|
||
new_password: this.formData.newPassword,
|
||
old_password: this.formData.currentPassword,
|
||
code: this.formData.mobileDynacode,
|
||
key: uni.getStorageSync("password_mobile_key"),
|
||
},
|
||
success: res => {
|
||
if (res.code == 0) {
|
||
this.memberInfo.password = 1;
|
||
this.$store.commit('setMemberInfo', this.memberInfo);
|
||
this.$util.showToast({
|
||
title: this.$lang('updateSuccess')
|
||
});
|
||
this.NavReturn();
|
||
uni.removeStorageSync('password_mobile_key');
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
this.getCaptcha();
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
this.$util.showToast({
|
||
title: validate.error
|
||
});
|
||
}
|
||
},
|
||
|
||
// ------------------------修改手机号------------------------------
|
||
// 验证手机号
|
||
vertifyMobile() {
|
||
var rule = [{
|
||
name: 'mobile',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang('pleaseInputMobile')
|
||
}, {
|
||
name: 'mobile',
|
||
checkType: 'phoneno',
|
||
errorMsg: this.$lang('surePhoneNumber')
|
||
}];
|
||
var checkRes = validate.check(this.formData, rule);
|
||
if (!checkRes) {
|
||
this.$util.showToast({
|
||
title: validate.error
|
||
});
|
||
return false;
|
||
}
|
||
return true;
|
||
},
|
||
// 检测手机号是否存在
|
||
async checkMobile() {
|
||
if (!this.vertifyMobile()) return;
|
||
let res = await this.$api.sendRequest({
|
||
url: '/api/member/checkmobile',
|
||
data: {
|
||
mobile: this.formData.mobile
|
||
},
|
||
async: false
|
||
});
|
||
if (res.code != 0) {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
return false;
|
||
}
|
||
return true;
|
||
},
|
||
|
||
// 发送短信动态码
|
||
async bindMoblieCode() {
|
||
if (this.seconds != 120) return;
|
||
var rule = [{
|
||
name: 'mobile',
|
||
checkType: 'phoneno',
|
||
errorMsg: this.$lang("surePhoneNumber")
|
||
},
|
||
{
|
||
name: 'mobileVercode',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang("confirmCodeInput")
|
||
},
|
||
];
|
||
|
||
var checkRes = validate.check(this.formData, rule);
|
||
|
||
if (checkRes && !this.isSend) {
|
||
this.isSend = true;
|
||
this.$api.sendRequest({
|
||
url: '/api/member/bindmobliecode',
|
||
data: {
|
||
mobile: this.formData.mobile,
|
||
captcha_id: this.captcha.id,
|
||
captcha_code: this.formData.mobileVercode
|
||
},
|
||
success: res => {
|
||
let data = res.data;
|
||
if (data.key) {
|
||
if (this.seconds == 120 && this.timer == null) {
|
||
this.timer = setInterval(() => {
|
||
this.seconds--;
|
||
this.formData.mobileCodeText = this.$lang('codeSent', { seconds: this.seconds });
|
||
}, 1000);
|
||
}
|
||
uni.setStorageSync('mobile_key', data.key);
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
this.isSend = false;
|
||
}
|
||
},
|
||
fail: res => {
|
||
this.isSend = false;
|
||
this.getCaptcha();
|
||
}
|
||
});
|
||
} else {
|
||
this.$util.showToast({
|
||
title: validate.error ? validate.error : this.$lang('doNotRepeatedlyClick')
|
||
});
|
||
}
|
||
},
|
||
async modifyMobile() {
|
||
|
||
var mobileRule = [{
|
||
name: 'mobile',
|
||
checkType: 'phoneno',
|
||
errorMsg: this.$lang("surePhoneNumber")
|
||
},
|
||
{
|
||
name: 'mobileVercode',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang("confirmCodeInput")
|
||
},
|
||
{
|
||
name: 'mobileDynacode',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang("animateCodeInput")
|
||
},
|
||
];
|
||
var checkRes = validate.check(this.formData, mobileRule);
|
||
|
||
if (checkRes) {
|
||
if (this.formData.mobile == this.memberInfo.mobile) {
|
||
this.$util.showToast({
|
||
title: this.$lang("alikePhone")
|
||
});
|
||
return;
|
||
}
|
||
this.$api.sendRequest({
|
||
url: '/api/member/modifymobile',
|
||
data: {
|
||
mobile: this.formData.mobile,
|
||
captcha_id: this.captcha.id,
|
||
captcha_code: this.formData.mobileVercode,
|
||
code: this.formData.mobileDynacode,
|
||
key: uni.getStorageSync("mobile_key"),
|
||
},
|
||
success: res => {
|
||
if (res.code == 0) {
|
||
this.memberInfo.mobile = this.formData.mobile;
|
||
this.$store.commit('setMemberInfo', this.memberInfo);
|
||
this.$util.showToast({
|
||
title: this.$lang("updateSuccess")
|
||
});
|
||
if (this.back) {
|
||
this.$util.redirectTo('/pages_tool/member/pay_password', {
|
||
'back': this.back
|
||
}, 'redirectTo')
|
||
} else {
|
||
this.NavReturn();
|
||
}
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
this.getCaptcha();
|
||
}
|
||
},
|
||
fail: res => {
|
||
this.isSend = false;
|
||
this.getCaptcha();
|
||
}
|
||
});
|
||
} else {
|
||
this.$util.showToast({
|
||
title: validate.error
|
||
});
|
||
}
|
||
},
|
||
/**
|
||
* 修改密码发送动态码
|
||
*/
|
||
passwordMoblieCode() {
|
||
if (this.seconds != 120) return;
|
||
|
||
if (this.formData.mobileVercode == '') {
|
||
this.$util.showToast({
|
||
title: this.$lang("confirmCodeInput")
|
||
});
|
||
return;
|
||
}
|
||
|
||
if (!this.isSend) {
|
||
this.isSend = true;
|
||
this.$api.sendRequest({
|
||
url: '/api/member/pwdmobliecode',
|
||
data: {
|
||
captcha_id: this.captcha.id,
|
||
captcha_code: this.formData.mobileVercode
|
||
},
|
||
success: res => {
|
||
let data = res.data;
|
||
if (data.key) {
|
||
if (this.seconds == 120 && this.timer == null) {
|
||
this.timer = setInterval(() => {
|
||
this.seconds--;
|
||
this.formData.mobileCodeText = this.$lang('codeSent', { seconds: this.seconds });
|
||
}, 1000);
|
||
}
|
||
uni.setStorageSync('password_mobile_key', data.key);
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
this.isSend = false;
|
||
}
|
||
},
|
||
fail: res => {
|
||
this.isSend = false;
|
||
this.getCaptcha();
|
||
}
|
||
});
|
||
} else {
|
||
this.$util.showToast({
|
||
title: this.$lang('doNotRepeatedlyClick')
|
||
});
|
||
}
|
||
},
|
||
modifyAddress() {
|
||
var rule = [{
|
||
name: 'fullAddress',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang('pleaseSelectRegion')
|
||
},
|
||
{
|
||
name: 'address',
|
||
checkType: 'required',
|
||
errorMsg: this.$lang('pleaseInputDetailAddress')
|
||
}
|
||
];
|
||
if (!rule.length) return;
|
||
var checkRes = validate.check(this.formData, rule);
|
||
if (checkRes) {
|
||
this.$api.sendRequest({
|
||
url: '/api/member/modifyaddress',
|
||
data: {
|
||
province_id: this.formData.provinceId,
|
||
city_id: this.formData.cityId,
|
||
district_id: this.formData.districtId,
|
||
address: this.formData.address,
|
||
full_address: this.formData.fullAddress
|
||
},
|
||
success: res => {
|
||
if (res.code == 0) {
|
||
this.memberInfo.province_id = this.formData.provinceId;
|
||
this.memberInfo.city_id = this.formData.cityId;
|
||
this.memberInfo.district_id = this.formData.districtId;
|
||
this.memberInfo.address = this.formData.address;
|
||
this.memberInfo.full_address = this.formData.fullAddress;
|
||
this.$store.commit('setMemberInfo', this.memberInfo);
|
||
this.$util.showToast({
|
||
title: this.$lang("updateSuccess")
|
||
});
|
||
this.NavReturn();
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
this.$util.showToast({
|
||
title: validate.error
|
||
});
|
||
}
|
||
},
|
||
initFormData() {
|
||
this.formData.currentPassword = '';
|
||
this.formData.newPassword = '';
|
||
this.formData.confirmPassword = '';
|
||
this.formData.mobileVercode = '';
|
||
this.formData.mobileDynacode = '';
|
||
this.formData.mobile = '';
|
||
},
|
||
handleGetRegions(regions) {
|
||
this.formData.fullAddress = '';
|
||
this.formData.fullAddress += regions[0] != undefined ? regions[0].label : '';
|
||
this.formData.fullAddress += regions[1] != undefined ? '-' + regions[1].label : '';
|
||
this.formData.fullAddress += regions[2] != undefined ? '-' + regions[2].label : '';
|
||
this.formData.provinceId = regions[0] ? regions[0].value : 0;
|
||
this.formData.cityId = regions[1] ? regions[1].value : 0;
|
||
this.formData.districtId = regions[2] ? regions[2].value : 0;
|
||
},
|
||
/**
|
||
* 手动绑定手机号
|
||
*/
|
||
manualBinding() {
|
||
this.indent = 'mobile';
|
||
},
|
||
mobileAuth(e) {
|
||
if (e.detail.errMsg == 'getPhoneNumber:ok') {
|
||
let data = e.detail
|
||
// #ifdef MP-WEIXIN
|
||
Object.assign(data, this.authInfo)
|
||
// #endif
|
||
this.$api.sendRequest({
|
||
url: '/api/member/mobileauth',
|
||
data,
|
||
success: res => {
|
||
if (res.code == 0) {
|
||
this.$util.showToast({
|
||
title: this.$lang("updateSuccess")
|
||
});
|
||
this.NavReturn();
|
||
} else {
|
||
this.$util.showToast({
|
||
title: res.message
|
||
});
|
||
}
|
||
}
|
||
})
|
||
}
|
||
}
|
||
}
|
||
}; |