提交 3de4d89e 编写于 作者: L linju

123

上级 3f548d5c
......@@ -10,7 +10,7 @@
<uni-forms-item name="phone">
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.phone" maxlength="11" placeholder="请输入手机号">
<template slot="left">
<template slot="left">
<!-- 当前仅支持中国大陆手机号 -->
<!-- <picker mode="selector" :range="phoneArea" @change="selectPhoneArea"> -->
<text class="phone-area" @click="selectPhoneArea">{{currenPhoneArea}}</text>
......@@ -38,10 +38,10 @@
</view>
</template>
<script>
import mixin from '../../common/loginPage.mixin.js';
<script>
import mixin from '../../common/loginPage.mixin.js';
var currentPage;
export default {
export default {
mixins:[mixin],
data() {
return {
......@@ -56,7 +56,7 @@
currenPhoneArea: '+86',
formData: {
phone: '17777777777'
phone: '17769516081'
},
rules: {
// 对phone字段进行必填验证
......@@ -79,16 +79,16 @@
currentPage = pages[pages.length - 1];
currentPage.$getAppWebview().setStyle({
top:"1000px"
})
},
onReady() {
this.$refs.uniQuickLogin.login('univerify')
setTimeout(() => {
currentPage.$getAppWebview().setStyle({
top:"0"
})
}, 1500);
},
})
},
onReady() {
this.$refs.uniQuickLogin.login('univerify')
setTimeout(() => {
currentPage.$getAppWebview().setStyle({
top:"0"
})
}, 1500);
},
computed: {
canGetShortMsg() {
......@@ -105,10 +105,10 @@
console.log('表单错误信息:', err);
})
},
selectPhoneArea(event) {
uni.showToast({
title: '当前仅支持中国大陆手机号',
icon: 'none'
selectPhoneArea(event) {
uni.showToast({
title: '当前仅支持中国大陆手机号',
icon: 'none'
});
// this.currenPhoneArea = this.phoneArea[event.detail.value];
},
......@@ -118,13 +118,13 @@
* 发送验证吗
*/
uni.showLoading();
uni.navigateTo({
url: './phone-code?phoneNumber=' + this.formData.phone + '&phoneArea=' +
this.currenPhoneArea,
success: res => {},
fail: () => {},
complete: () => {}
});
uni.navigateTo({
url: './phone-code?phoneNumber=' + this.formData.phone + '&phoneArea=' +
this.currenPhoneArea,
success: res => {},
fail: () => {},
complete: () => {}
});
},
/**
* 去密码登录页
......@@ -164,4 +164,4 @@
border-right: 1rpx solid #d7d9d8;
/* #endif */
}
</style>
</style>
......@@ -8,14 +8,14 @@
<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
<uni-forms ref="form" :value="formData" :rules="rules">
<uni-forms-item name="phone">
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.phone" maxlength="11" placeholder="请输入手机号">
<template slot="left">
<!-- 当前仅支持中国大陆手机号 -->
<!-- <picker mode="selector" :range="phoneArea" @change="selectPhoneArea"> -->
<text class="phone-area" @click="selectPhoneArea">{{currenPhoneArea}}</text>
<!-- </picker> -->
</template>
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.phone" maxlength="11" placeholder="请输入手机号">
<template slot="left">
<!-- 当前仅支持中国大陆手机号 -->
<!-- <picker mode="selector" :range="phoneArea" @change="selectPhoneArea"> -->
<text class="phone-area" @click="selectPhoneArea">{{currenPhoneArea}}</text>
<!-- </picker> -->
</template>
</uni-easyinput>
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.pwd" placeholder="请输入密码"></uni-easyinput>
......@@ -34,49 +34,49 @@
</view>
</template>
<script>
<script>
import mixin from '../../common/loginPage.mixin.js';
export default {
export default {
mixins:[mixin],
data() {
return {
link: [{
text: '用户协议',
to: '/pages/ucenter/agree-list/service/service'
}, {
text: '隐私政策',
to: '/pages/ucenter/agree-list/privacy/privacy'
link: [{
text: '用户协议',
to: '/pages/ucenter/agree-list/service/service'
}, {
text: '隐私政策',
to: '/pages/ucenter/agree-list/privacy/privacy'
}],
phoneArea: ['+86'],
currenPhoneArea: '+86',
formData: {
phone: '17777777777',
pwd:'123456'
},
rules: {
phone: {
rules: [{
required: true,
errorMessage: '请输入手机号',
},
{
pattern: /^1\d{10}$/,
errorMessage: '手机号格式不正确',
}
]
},
pwd:{
rules: [{
required: true,
errorMessage: '请输入密码',
},
{
pattern: /^.{6,20}$/,
errorMessage: '密码应为6到20位',
}
]
}
currenPhoneArea: '+86',
formData: {
phone: '17769516081',
pwd:'123456'
},
rules: {
phone: {
rules: [{
required: true,
errorMessage: '请输入手机号',
},
{
pattern: /^1\d{10}$/,
errorMessage: '手机号格式不正确',
}
]
},
pwd:{
rules: [{
required: true,
errorMessage: '请输入密码',
},
{
pattern: /^.{6,20}$/,
errorMessage: '密码应为6到20位',
}
]
}
}
}
},
......@@ -111,61 +111,61 @@
*/
pwdLogin() {
if (!this.canLogin) return;
// 下边是可以登录
uniCloud.callFunction({
name:"user-center",
"data":{
"action":"login",
"params":{
"username":this.formData.phone,
"password":this.formData.pwd
}
},
success:async (e) => {
uni.hideLoading()
console.log(e.result);
if(e.result.code === 0){
uni.setStorageSync('uni_id_uid', e.result.uid)
uni.setStorageSync('uni_id_token', e.result.token)
uni.setStorageSync('uni_id_token_expired', e.result.tokenExpired)
// console.log('66666=',e.result.uid,e.result.token,e.result.tokenExpired);
delete e.result.userInfo.token
this.setUserInfo(e.result.userInfo)
uni.showToast({
title: '登陆成功',
icon: 'none'
});
uni.navigateBack()
}else{
uni.showModal({
title: '错误',
content: e.result.msg,
showCancel: false,
confirmText: '知道了',
});
}
},
fail: (err) => {
console.log(err);
uni.showModal({
title: '错误',
content: JSON.stringify(err),
showCancel: false,
confirmText: '知道了',
});
if(err.errCode===30002){
}
},
complete: () => {
uni.hideLoading()
}
// 下边是可以登录
uniCloud.callFunction({
name:"user-center",
"data":{
"action":"login",
"params":{
"username":this.formData.phone,
"password":this.formData.pwd
}
},
success:async (e) => {
uni.hideLoading()
console.log(e.result);
if(e.result.code === 0){
uni.setStorageSync('uni_id_uid', e.result.uid)
uni.setStorageSync('uni_id_token', e.result.token)
uni.setStorageSync('uni_id_token_expired', e.result.tokenExpired)
// console.log('66666=',e.result.uid,e.result.token,e.result.tokenExpired);
delete e.result.userInfo.token
this.setUserInfo(e.result.userInfo)
uni.showToast({
title: '登陆成功',
icon: 'none'
});
uni.navigateBack()
}else{
uni.showModal({
title: '错误',
content: e.result.msg,
showCancel: false,
confirmText: '知道了',
});
}
},
fail: (err) => {
console.log(err);
uni.showModal({
title: '错误',
content: JSON.stringify(err),
showCancel: false,
confirmText: '知道了',
});
if(err.errCode===30002){
}
},
complete: () => {
uni.hideLoading()
}
})
},
selectPhoneArea(event) {
uni.showToast({
title: '当前仅支持中国大陆手机号',
icon: 'none'
selectPhoneArea(event) {
uni.showToast({
title: '当前仅支持中国大陆手机号',
icon: 'none'
});
// this.currenPhoneArea = this.phoneArea[event.detail.value];
},
......@@ -181,11 +181,11 @@
}
.auth-box {
justify-content: flex-start;
justify-content: flex-start;
margin-top: 20rpx;
}
.login-text-sub {
color: #8a8f8b;
}
</style>
</style>
......@@ -18,7 +18,7 @@
v-model="formData.pwd" placeholder="请输入新密码"></uni-easyinput>
</uni-forms-item>
<button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
@click="submit">完成</button>
@click="checkCode(submit)">完成</button>
</uni-forms>
</view>
</view>
......@@ -130,17 +130,14 @@ import mixin from '../../common/loginPage.mixin.js';
}
})
},
/**
* 完成并提交
*/
submit(){
uniCloud.callFunction({
name:"user-center",
"data":{
"action":"login",
checkCode(callback){
uniCloud.callFunction({//联网验证登陆
"name": "user-center",
"data": {
"action": "loginBySms",
"params":{
"username":this.formData.phone,
"password":this.formData.pwd
"mobile":this.phoneNumber,
"code":this.formData.code
}
},
success:async (e) => {
......@@ -150,14 +147,11 @@ import mixin from '../../common/loginPage.mixin.js';
uni.setStorageSync('uni_id_uid', e.result.uid)
uni.setStorageSync('uni_id_token', e.result.token)
uni.setStorageSync('uni_id_token_expired', e.result.tokenExpired)
// console.log('66666=',e.result.uid,e.result.token,e.result.tokenExpired);
delete e.result.userInfo.token
this.setUserInfo(e.result.userInfo)
uni.showToast({
title: '登陆成功',
icon: 'none'
});
uni.navigateBack()
// uni.showToast({
// title: '登陆成功',
// icon: 'none'
// });
callback()
}else{
uni.showModal({
title: '错误',
......@@ -183,6 +177,46 @@ import mixin from '../../common/loginPage.mixin.js';
uni.hideLoading()
}
})
},
/**
* 完成并提交
*/
submit(){
uniCloud.callFunction({
name:"user-center",
"data":{
"action":"resetPwd",
"params":{
"password":this.formData.pwd
}
},
success:async (e) => {
uni.hideLoading()
console.log(e.result);
uni.showToast({
title: e.result.msg,
icon: 'none'
});
if(e.result.code === 0){
uni.navigateBack()
}
},
fail: (err) => {
console.log(err);
uni.showModal({
title: '错误',
content: JSON.stringify(err),
showCancel: false,
confirmText: '知道了',
});
if(err.errCode===30002){
}
},
complete: () => {
uni.hideLoading()
}
})
}
}
}
......
......@@ -32,6 +32,7 @@ exports.main = async (event, context) => {
'createCaptcha', 'verifyCaptcha','refreshCaptcha', 'inviteLogin',
'login_by_weixin','login_by_univerify','login_by_apple','loginBySms'
]
let payload;
console.log(event.action);
if (!noCheckAction.includes(event.action)) {
if (!event.uniIdToken) {
......@@ -40,7 +41,7 @@ exports.main = async (event, context) => {
msg: '缺少token'
}
}
let payload = await uniID.checkToken(event.uniIdToken)
payload = await uniID.checkToken(event.uniIdToken)
if (payload.code && payload.code > 0) {
return payload
}
......@@ -88,7 +89,10 @@ exports.main = async (event, context) => {
}
if (!needCaptcha || passed) {
res = await uniID.login({...params,"queryField":['username','email','mobile']});
res = await uniID.login({
...params,
queryField: ['username', 'email', 'mobile']
});
await loginLog(res);
needCaptcha = await getNeedCaptcha();
}
......@@ -124,7 +128,7 @@ exports.main = async (event, context) => {
msg: '请求过于频繁'
}
}
const templateId = '' // 替换为自己申请的模板id
const templateId = '11753' // 替换为自己申请的模板id
if (!templateId) {
return {
code: 500,
......@@ -192,6 +196,9 @@ exports.main = async (event, context) => {
break;
case 'refreshCaptcha':
res = await uniCaptcha.refresh(params)
break;
case 'resetPwd':
res = await uniID.resetPwd({...params,"uid":payload.uid})
break;
default:
res = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册