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

123

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