This commit is contained in:
parent
6290e963e4
commit
ecb94ba348
|
|
@ -76,6 +76,11 @@
|
|||
"style": {
|
||||
"navigationBarTitleText": "隐私协议"
|
||||
}
|
||||
}, {
|
||||
"path": "pages/me/agreement",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务协议"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/index/search/index",
|
||||
|
|
|
|||
|
|
@ -19,137 +19,134 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import listCell from '@/components/com-input';
|
||||
export default {
|
||||
components: {
|
||||
listCell
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
mobile: '',
|
||||
code: '',
|
||||
loginIng: false,
|
||||
sendIng: false,
|
||||
sendTime: '获取验证码',
|
||||
count: 60,
|
||||
type: '',
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
if (option.type) {
|
||||
this.type = option.type
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
inputChange(e) {
|
||||
const key = e.currentTarget.dataset.key;
|
||||
this[key] = e.detail.value;
|
||||
},
|
||||
|
||||
countDown() {
|
||||
const {
|
||||
count
|
||||
} = this;
|
||||
if (count === 1) {
|
||||
this.count = 60;
|
||||
this.sendIng = false;
|
||||
this.sendTime = '获取验证码'
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad} from '@dcloudio/uni-app'
|
||||
import {setSendMsg,forgetPwd} from '@/api/login/login.js';
|
||||
let data = reactive({
|
||||
mobile: '',
|
||||
code: '',
|
||||
loginIng: false,
|
||||
sendIng: false,
|
||||
sendTime: '获取验证码',
|
||||
count: 60,
|
||||
type: '',
|
||||
})
|
||||
|
||||
onLoad((option) => {
|
||||
if (option.type) {
|
||||
data.type = option.type
|
||||
}
|
||||
})
|
||||
|
||||
function inputChange(e) {
|
||||
const key = e.currentTarget.dataset.key;
|
||||
data[key] = e.detail.value;
|
||||
}
|
||||
|
||||
function countDown() {
|
||||
const {
|
||||
count
|
||||
} = data;
|
||||
if (count === 1) {
|
||||
data.count = 60;
|
||||
data.sendIng = false;
|
||||
data.sendTime = '获取验证码'
|
||||
} else {
|
||||
data.count = count - 1;
|
||||
data.sendIng = true;
|
||||
data.sendTime = count - 1 + '秒后重新获取';
|
||||
setTimeout(data.countDown.bind(data), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function sendMsg() {
|
||||
const {
|
||||
mobile
|
||||
} = data;
|
||||
if (!mobile) {
|
||||
data.$queue.showToast("请输入手机号");
|
||||
} else if (mobile.length !== 11) {
|
||||
data.$queue.showToast("请输入正确的手机号");
|
||||
} else {
|
||||
data.$queue.showLoading("正在发送验证码...");
|
||||
http.request({
|
||||
url: 'app/Login/sendMsg/' + mobile + '/gzg',
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
data.sendIng = true;
|
||||
uni.showToast({ title: '验证码发送成功请注意查收', icon: 'none', })
|
||||
data.countDown();
|
||||
} else {
|
||||
this.count = count - 1;
|
||||
this.sendIng = true;
|
||||
this.sendTime = count - 1 + '秒后重新获取';
|
||||
setTimeout(this.countDown.bind(this), 1000);
|
||||
}
|
||||
},
|
||||
sendMsg() {
|
||||
const {
|
||||
mobile
|
||||
} = this;
|
||||
if (!mobile) {
|
||||
this.$queue.showToast("请输入手机号");
|
||||
} else if (mobile.length !== 11) {
|
||||
this.$queue.showToast("请输入正确的手机号");
|
||||
} else {
|
||||
this.$queue.showLoading("正在发送验证码...");
|
||||
http.request({
|
||||
url: 'app/Login/sendMsg/' + mobile + '/gzg',
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.sendIng = true;
|
||||
this.$queue.showToast('验证码发送成功请注意查收');
|
||||
this.countDown();
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '短信发送失败',
|
||||
content: res.msg ? res.msg : '请一分钟后再获取验证码'
|
||||
});
|
||||
}
|
||||
|
||||
uni.hideLoading();
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
toLogin() {
|
||||
const {
|
||||
mobile,
|
||||
code
|
||||
} = this;
|
||||
let userId = this.$queue.getData("userId");
|
||||
if (!mobile) {
|
||||
this.$queue.showToast("请输入手机号");
|
||||
} else if (mobile.length !== 11) {
|
||||
this.$queue.showToast("请输入正确的手机号");
|
||||
} else if (!code) {
|
||||
this.$queue.showToast("请输入验证码");
|
||||
} else {
|
||||
this.$queue.showLoading("正在绑定中...");
|
||||
let openId = this.$queue.getData('openId') ? this.$queue.getData('openId') : '';
|
||||
let openidnickname = this.$queue.getData('openidnickname') ? this.$queue.getData('openidnickname') :
|
||||
'';
|
||||
let openidheadimgurl = this.$queue.getData('openidheadimgurl') ? this.$queue.getData(
|
||||
'openidheadimgurl') : '';
|
||||
let invitation = this.$queue.getData('inviterCode') ? this.$queue.getData('inviterCode') : '';
|
||||
let userId = this.$queue.getData('userId') ? this.$queue.getData('userId') : '';
|
||||
|
||||
http.request({
|
||||
url: `app/Login/registerCode`,
|
||||
method: 'post',
|
||||
data: {
|
||||
phone: mobile,
|
||||
wxId: openId,
|
||||
userId: userId,
|
||||
inviterCode: invitation,
|
||||
avatar: openidheadimgurl,
|
||||
userName: openidnickname,
|
||||
msg: code
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$queue.setData("token", res.token);
|
||||
this.$queue.setData('userId', res.user.userId);
|
||||
this.$queue.setData('userName', res.user.userName);
|
||||
this.$queue.setData('phone', res.user.phone);
|
||||
this.$queue.setData('avatar', res.user.avatar ? res.user.avatar :
|
||||
'../../static/logo.png');
|
||||
this.$queue.showToast('绑定成功');
|
||||
setTimeout(function() {
|
||||
uni.navigateBack()
|
||||
}, 1000)
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '绑定失败',
|
||||
content: res.msg,
|
||||
});
|
||||
}
|
||||
uni.hideLoading();
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '短信发送失败',
|
||||
content: res.msg ? res.msg : '请一分钟后再获取验证码'
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
uni.hideLoading();
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function toLogin() {
|
||||
const {
|
||||
mobile,
|
||||
code
|
||||
} = data;
|
||||
let userId = this.$queue.getData("userId");
|
||||
if (!mobile) {
|
||||
uni.showToast({ title: '请输入手机号', icon: 'none', })
|
||||
} else if (mobile.length !== 11) {
|
||||
uni.showToast({ title: '请输入正确的手机号', icon: 'none', })
|
||||
} else if (!code) {
|
||||
uni.showToast({ title: '请输入验证码', icon: 'none', })
|
||||
} else {
|
||||
uni.showLoading({ title: '正在绑定中...' })
|
||||
let openId = this.$queue.getData('openId') ? this.$queue.getData('openId') : '';
|
||||
let openidnickname = this.$queue.getData('openidnickname') ? this.$queue.getData('openidnickname') :
|
||||
'';
|
||||
let openidheadimgurl = this.$queue.getData('openidheadimgurl') ? this.$queue.getData(
|
||||
'openidheadimgurl') : '';
|
||||
let invitation = this.$queue.getData('inviterCode') ? this.$queue.getData('inviterCode') : '';
|
||||
let userId = this.$queue.getData('userId') ? this.$queue.getData('userId') : '';
|
||||
|
||||
http.request({
|
||||
url: `app/Login/registerCode`,
|
||||
method: 'post',
|
||||
data: {
|
||||
phone: mobile,
|
||||
wxId: openId,
|
||||
userId: userId,
|
||||
inviterCode: invitation,
|
||||
avatar: openidheadimgurl,
|
||||
userName: openidnickname,
|
||||
msg: code
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$queue.setData("token", res.token);
|
||||
this.$queue.setData('userId', res.user.userId);
|
||||
this.$queue.setData('userName', res.user.userName);
|
||||
this.$queue.setData('phone', res.user.phone);
|
||||
this.$queue.setData('avatar', res.user.avatar ? res.user.avatar :
|
||||
'../../static/logo.png');
|
||||
this.$queue.showToast('绑定成功');
|
||||
uni.showToast({ title: '绑定成功', icon: 'none', })
|
||||
setTimeout(function() {
|
||||
uni.navigateBack()
|
||||
}, 1000)
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '绑定失败',
|
||||
content: res.msg,
|
||||
});
|
||||
}
|
||||
uni.hideLoading();
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -128,34 +128,27 @@
|
|||
password: password,
|
||||
phone: mobile
|
||||
})
|
||||
|
||||
if (res.code === 0) {
|
||||
uni.setStorageSync('token', res.token)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('userName', res.user.userName)
|
||||
uni.setStorageSync('avatar', res.user.avatar ? res.user.avatar : '../../static/default/avatar.png')
|
||||
uni.setStorageSync('phone', res.user.phone)
|
||||
uni.setStorageSync('invitationCode', res.user.invitationCode)
|
||||
uni.setStorageSync('sex', res.user.sex)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
//设置渠道码
|
||||
if (res.user.qdCode) {
|
||||
uni.setStorageSync('qdCode', res.user.qdCode)
|
||||
}
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'none'
|
||||
})
|
||||
uni.reLaunch({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
} else{
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
uni.setStorageSync('token', res.token)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('userName', res.user.userName)
|
||||
uni.setStorageSync('avatar', res.user.avatar ? res.user.avatar : '../../static/default/avatar.png')
|
||||
uni.setStorageSync('phone', res.user.phone)
|
||||
uni.setStorageSync('invitationCode', res.user.invitationCode)
|
||||
uni.setStorageSync('sex', res.user.sex)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
//设置渠道码
|
||||
if (res.user.qdCode) {
|
||||
uni.setStorageSync('qdCode', res.user.qdCode)
|
||||
}
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'none'
|
||||
})
|
||||
uni.reLaunch({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,9 +70,7 @@
|
|||
if (options.invitation ) { data.invitation = options.invitation }
|
||||
|
||||
let res = await commonType(3)
|
||||
if (res.code == 0) {
|
||||
data.registerCode = res.data.value
|
||||
}
|
||||
data.registerCode = res.value
|
||||
})
|
||||
|
||||
/**
|
||||
|
|
@ -96,8 +94,9 @@
|
|||
title: '正在发送验证码...'
|
||||
})
|
||||
let res = await setSendMsg(data.mobile,'login')
|
||||
console.log(res)
|
||||
if ( res.code == 0 ) {
|
||||
uni.hideLoading();
|
||||
uni.hideToast();
|
||||
if( res ){
|
||||
data.sending = true;
|
||||
uni.showToast({
|
||||
title: '验证码发送成功请注意查收',
|
||||
|
|
@ -109,11 +108,10 @@
|
|||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '短信发送失败',
|
||||
content: res.msg ? res.msg : '请一分钟后再获取验证码'
|
||||
content: '请一分钟后再获取验证码'
|
||||
});
|
||||
}
|
||||
|
||||
uni.hideLoading();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
async function getGuize() {
|
||||
let res = await commonType(155)
|
||||
this.content = res.data.value
|
||||
this.content = res.value
|
||||
}
|
||||
|
||||
function cancel(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue