|
@@ -2,24 +2,42 @@
|
|
<mobile-frame>
|
|
<mobile-frame>
|
|
<view class="main">
|
|
<view class="main">
|
|
<view class="one" v-if="platform.uniPlatform=='app'">
|
|
<view class="one" v-if="platform.uniPlatform=='app'">
|
|
- <uni-forms ref="form" :rules="rules" :model="form" label-width="auto">
|
|
|
|
- <uni-forms-item label="手机号" name="phone">
|
|
|
|
- <uni-easyinput type="text" v-model="form.phone" placeholder="请输入手机号" />
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item label="验证码" name="code">
|
|
|
|
- <view class="yzm">
|
|
|
|
- <view class="l">
|
|
|
|
- <uni-easyinput type="text" v-model="form.code" placeholder="请输入手机验证码" />
|
|
|
|
- </view>
|
|
|
|
- <view class="r">
|
|
|
|
- <button type="default" size="mini" @tap.stop="sendCount">{{time_count==0?'验证码':time_count}}</button>
|
|
|
|
|
|
+ <view class="one_2">
|
|
|
|
+ <uni-data-checkbox mode="tag" v-model="loginType" :localdata="loginTypeList" @change="logintypeChange"></uni-data-checkbox>
|
|
|
|
+ </view>
|
|
|
|
+ <view class="one_3" v-if="loginType==0">
|
|
|
|
+ <uni-forms ref="codeForm" :rules="codeRules" :model="codeForm" label-width="auto">
|
|
|
|
+ <uni-forms-item label="手机号" name="phone">
|
|
|
|
+ <uni-easyinput type="number" v-model="codeForm.phone" placeholder="请输入手机号" />
|
|
|
|
+ </uni-forms-item>
|
|
|
|
+ <uni-forms-item label="验证码" name="code">
|
|
|
|
+ <view class="yzm">
|
|
|
|
+ <view class="l">
|
|
|
|
+ <uni-easyinput type="text" v-model="codeForm.code" placeholder="请输入手机验证码" />
|
|
|
|
+ </view>
|
|
|
|
+ <view class="r">
|
|
|
|
+ <button type="default" size="mini" @tap.stop="appsendCount">{{time_count==0?'验证码':time_count}}</button>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
|
|
+ </uni-forms-item>
|
|
|
|
+ <view class="btn">
|
|
|
|
+ <button type="default" size="mini" @click="codeSubmit('codeForm')">提交登录</button>
|
|
|
|
+ </view>
|
|
|
|
+ </uni-forms>
|
|
|
|
+ </view>
|
|
|
|
+ <view class="one_4" v-else-if="loginType==1">
|
|
|
|
+ <uni-forms ref="accountForm" :rules="accountRules" :model="accountForm" label-width="auto">
|
|
|
|
+ <uni-forms-item label="手机号" name="phone">
|
|
|
|
+ <uni-easyinput type="number" v-model="accountForm.phone" placeholder="请输入手机号" />
|
|
|
|
+ </uni-forms-item>
|
|
|
|
+ <uni-forms-item label="登录密码" name="password">
|
|
|
|
+ <uni-easyinput type="number" v-model="accountForm.password" placeholder="请输入登录密码" />
|
|
|
|
+ </uni-forms-item>
|
|
|
|
+ <view class="btn">
|
|
|
|
+ <button type="default" size="mini" @click="accountSubmit('accountForm')">提交登录</button>
|
|
</view>
|
|
</view>
|
|
- </uni-forms-item>
|
|
|
|
- <view class="btn">
|
|
|
|
- <button type="default" size="mini" @click="toSubmit('form')">提交登录</button>
|
|
|
|
- </view>
|
|
|
|
- </uni-forms>
|
|
|
|
|
|
+ </uni-forms>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
<view class="two" v-else-if="platform.uniPlatform=='mp-weixin'">
|
|
<view class="two" v-else-if="platform.uniPlatform=='mp-weixin'">
|
|
<view class="icon">
|
|
<view class="icon">
|
|
@@ -77,16 +95,31 @@
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ point_title: this.$config.point_title,
|
|
// 平台信息
|
|
// 平台信息
|
|
platform: {},
|
|
platform: {},
|
|
//openid
|
|
//openid
|
|
openid: '',
|
|
openid: '',
|
|
// 隐私协议
|
|
// 隐私协议
|
|
agree: false,
|
|
agree: false,
|
|
- form: {},
|
|
|
|
- rules: {
|
|
|
|
|
|
+ // app-start
|
|
|
|
+ loginType: 0,
|
|
|
|
+ // 短信登录
|
|
|
|
+ loginTypeList: [ //
|
|
|
|
+ {
|
|
|
|
+ "value": 0,
|
|
|
|
+ "text": "短信登录"
|
|
|
|
+ }, {
|
|
|
|
+ "value": 1,
|
|
|
|
+ "text": "密码登录"
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ // 验证码登录
|
|
|
|
+ codeForm: {},
|
|
|
|
+ codeRules: {
|
|
phone: {
|
|
phone: {
|
|
- rules: [{
|
|
|
|
|
|
+ rules: [ //
|
|
|
|
+ {
|
|
required: true,
|
|
required: true,
|
|
errorMessage: '请输入手机号',
|
|
errorMessage: '请输入手机号',
|
|
},
|
|
},
|
|
@@ -98,12 +131,40 @@
|
|
]
|
|
]
|
|
},
|
|
},
|
|
code: {
|
|
code: {
|
|
- rules: [{
|
|
|
|
- required: true,
|
|
|
|
- errorMessage: '请输入验证码',
|
|
|
|
- }, ]
|
|
|
|
|
|
+ rules: [ //
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ errorMessage: '请输入短信验证码',
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 密码登录
|
|
|
|
+ accountForm: {},
|
|
|
|
+ accountRules: {
|
|
|
|
+ phone: {
|
|
|
|
+ rules: [ //
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ errorMessage: '请输入手机号',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ minLength: 11,
|
|
|
|
+ maxLength: 11,
|
|
|
|
+ errorMessage: '账号长度在{maxLength}个字符',
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
},
|
|
},
|
|
|
|
+ password: {
|
|
|
|
+ rules: [ //
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ errorMessage: '请输入登录密码',
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
+ // app-end
|
|
// 微信登陆
|
|
// 微信登陆
|
|
// 无账号
|
|
// 无账号
|
|
is_user: false,
|
|
is_user: false,
|
|
@@ -283,17 +344,27 @@
|
|
},
|
|
},
|
|
// 短信验证
|
|
// 短信验证
|
|
// 获取验证码
|
|
// 获取验证码
|
|
- sendCount() {
|
|
|
|
|
|
+ async sendCount() {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ let user = this.user;
|
|
let form = that.form && that.form.phone ? that.form : that.phoneForm;
|
|
let form = that.form && that.form.phone ? that.form : that.phoneForm;
|
|
if (form && form.phone) {
|
|
if (form && form.phone) {
|
|
- let time_count = 60;
|
|
|
|
- uni.showToast({
|
|
|
|
- title: '发送成功',
|
|
|
|
- icon: 'none'
|
|
|
|
- });
|
|
|
|
- that.$set(that, `time_count`, time_count);
|
|
|
|
- that.timeDown();
|
|
|
|
|
|
+ let res = await that.$api(`/user/toBindPhone`, 'POST', {
|
|
|
|
+ id: user._id,
|
|
|
|
+ phone: form.phone
|
|
|
|
+ })
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '发送成功'
|
|
|
|
+ })
|
|
|
|
+ that.$set(that, `time_count`, 60);
|
|
|
|
+ that.timeDown();
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.errmsg,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: '输入错误,请重新输入!',
|
|
title: '输入错误,请重新输入!',
|
|
@@ -321,12 +392,30 @@
|
|
if (form.type == '0') {
|
|
if (form.type == '0') {
|
|
if (form && form.phone) that.updatePhone(form.phone);
|
|
if (form && form.phone) that.updatePhone(form.phone);
|
|
} else if (form.type == '1') {
|
|
} else if (form.type == '1') {
|
|
- let code = '1234';
|
|
|
|
- if (form.code == code) {
|
|
|
|
- if (form && form.phone) that.updatePhone(form.phone);
|
|
|
|
|
|
+ const res = await that.$api(`/user/checkBindPhone`, 'POST', {
|
|
|
|
+ id: user._id,
|
|
|
|
+ code: form.code,
|
|
|
|
+ phone: form.phone
|
|
|
|
+ });
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ const arr = await that.$api(`/user/${user._id}`, 'POST', {
|
|
|
|
+ phone: form.phone
|
|
|
|
+ });
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '绑定手机号成功',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ that.wxLogins();
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: arr.errmsg,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- title: '短信验证失败,请重新输入!',
|
|
|
|
|
|
+ title: res.errmsg,
|
|
icon: 'none'
|
|
icon: 'none'
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -355,24 +444,101 @@
|
|
that.wxLogins();
|
|
that.wxLogins();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ // 账号登录-start
|
|
|
|
+ // 选择登录类型
|
|
|
|
+ logintypeChange(e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.$set(that, `loginType`, e.detail.value)
|
|
|
|
+ },
|
|
|
|
+ // 验证码登录
|
|
|
|
+ async appsendCount() {
|
|
|
|
+ const that = this;
|
|
|
|
+ let form = that.codeForm;
|
|
|
|
+ if (form && form.phone) {
|
|
|
|
+ let res = await that.$api(`/user/toLoginByCode`, 'POST', {
|
|
|
|
+ phone: form.phone
|
|
|
|
+ })
|
|
|
|
+ console.log(res);
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '发送成功'
|
|
|
|
+ })
|
|
|
|
+ that.$set(that, `time_count`, 60);
|
|
|
|
+ that.timeDown();
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.errmsg,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '输入错误,请重新输入!',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ codeSubmit(ref) {
|
|
|
|
+ const that = this;
|
|
|
|
+ let agree = that.agree;
|
|
|
|
+ that.$refs[ref].validate().then(async params => {
|
|
|
|
+ if (agree) {
|
|
|
|
+ const res = await that.$api(`/user/checkLoginCode`, 'POST', params);
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ uni.setStorage({
|
|
|
|
+ key: 'token',
|
|
|
|
+ data: res.data,
|
|
|
|
+ success: function() {
|
|
|
|
+ uni.navigateBack({
|
|
|
|
+ delta: 1
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.errmsg,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '请阅读并同意用户协议和隐私政策',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }).catch(err => {
|
|
|
|
+ console.log(err);
|
|
|
|
+ })
|
|
|
|
+ },
|
|
// 账号登录
|
|
// 账号登录
|
|
- toSubmit(ref) {
|
|
|
|
|
|
+ accountSubmit(ref) {
|
|
const that = this;
|
|
const that = this;
|
|
let agree = that.agree;
|
|
let agree = that.agree;
|
|
that.$refs[ref].validate().then(async params => {
|
|
that.$refs[ref].validate().then(async params => {
|
|
- let code = '1234';
|
|
|
|
- if (params.code == code) {
|
|
|
|
- if (agree) {
|
|
|
|
- console.log(params);
|
|
|
|
|
|
+ if (agree) {
|
|
|
|
+ const res = await that.$api(`/user/login`, 'POST', {
|
|
|
|
+ ...params
|
|
|
|
+ })
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ uni.setStorage({
|
|
|
|
+ key: 'token',
|
|
|
|
+ data: res.data,
|
|
|
|
+ success: function() {
|
|
|
|
+ uni.navigateBack({
|
|
|
|
+ delta: 1
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ });
|
|
} else {
|
|
} else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- title: '请阅读并同意用户协议和隐私政策',
|
|
|
|
|
|
+ title: res.errmsg,
|
|
icon: 'none'
|
|
icon: 'none'
|
|
})
|
|
})
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- title: '验证码错误',
|
|
|
|
|
|
+ title: '请阅读并同意用户协议和隐私政策',
|
|
icon: 'none'
|
|
icon: 'none'
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -380,6 +546,7 @@
|
|
console.log(err);
|
|
console.log(err);
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ // 账号登录-end
|
|
// 同意隐私协议
|
|
// 同意隐私协议
|
|
changeAgree() {
|
|
changeAgree() {
|
|
const that = this;
|
|
const that = this;
|
|
@@ -401,6 +568,11 @@
|
|
.one {
|
|
.one {
|
|
padding: 2vw;
|
|
padding: 2vw;
|
|
|
|
|
|
|
|
+ .one_2 {
|
|
|
|
+ margin: 4vw 22vw;
|
|
|
|
+ text-align: center;
|
|
|
|
+ }
|
|
|
|
+
|
|
.btn {
|
|
.btn {
|
|
text-align: center;
|
|
text-align: center;
|
|
margin: 0 0 2vw 0;
|
|
margin: 0 0 2vw 0;
|