|
@@ -8,7 +8,8 @@
|
|
<view class="subtitle">手机号登录/注册</view>
|
|
<view class="subtitle">手机号登录/注册</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
- <view class="tbody">
|
|
|
|
|
|
+ <!-- <view class="tbody"> -->
|
|
|
|
+ <view class="tbody" style="position: fixed;top: 50%;left: 50%;transform: translate(-50%,-50%);">
|
|
<block v-if="type == 'onelogin'">
|
|
<block v-if="type == 'onelogin'">
|
|
<image class="icon" mode="widthFix" src="../../static/me/avator.png"></image>
|
|
<image class="icon" mode="widthFix" src="../../static/me/avator.png"></image>
|
|
<text class="mobile">+ 86 1**********</text>
|
|
<text class="mobile">+ 86 1**********</text>
|
|
@@ -21,35 +22,40 @@
|
|
</view>
|
|
</view>
|
|
</block>
|
|
</block>
|
|
<block v-if="type == 'pass' || type == 'mobile'">
|
|
<block v-if="type == 'pass' || type == 'mobile'">
|
|
- <view class="name">手机号码:</view>
|
|
|
|
- <view class="item">
|
|
|
|
- <input type="number" class="input" v-model="mobile" placeholder="请输入手机号码" maxlength="11" />
|
|
|
|
- </view>
|
|
|
|
- <block v-if="type == 'pass'">
|
|
|
|
- <view class="name">登录密码:</view>
|
|
|
|
- <view class="item">
|
|
|
|
- <input type="password" class="input" v-model="password" placeholder="请输入登录密码" maxlength="32" />
|
|
|
|
- </view>
|
|
|
|
- <view class="other_list">
|
|
|
|
- <text class="left" v-if="true" @click="type = 'mobile'">验证码登录</text>
|
|
|
|
- <text class="left" v-else></text>
|
|
|
|
- <text class="right" @click="type = 'mobile'" v-if="false">验证码登录</text>
|
|
|
|
- <text class="right" @click="toRegist">还没有账号?开始注册</text>
|
|
|
|
- </view>
|
|
|
|
- </block>
|
|
|
|
- <block v-if="type == 'mobile'">
|
|
|
|
- <view class="name">验证码:</view>
|
|
|
|
|
|
+ <template v-if="false">
|
|
|
|
+ <view class="name">手机号码:</view>
|
|
<view class="item">
|
|
<view class="item">
|
|
- <input type="text" class="input" v-model="code" placeholder="请输入验证码" maxlength="6" />
|
|
|
|
- <view class="btn" v-if="captchaTime === 0" @click="getCode">获取验证码</view>
|
|
|
|
- <view class="btn" v-if="captchaTime > 0">{{ captchaTime }}秒后重试</view>
|
|
|
|
- </view>
|
|
|
|
- <view class="other_list" v-if="false">
|
|
|
|
- <text class="left"></text>
|
|
|
|
- <text class="right" @click="type = 'pass'" style="color: blue;">密码登录</text>
|
|
|
|
|
|
+ <input type="number" class="input" v-model="mobile" placeholder="请输入手机号码" maxlength="11" />
|
|
</view>
|
|
</view>
|
|
- </block>
|
|
|
|
- <text class="btn_submit" @click="toLogin">登录/注册</text>
|
|
|
|
|
|
+ <block v-if="type == 'pass'">
|
|
|
|
+ <view class="name">登录密码:</view>
|
|
|
|
+ <view class="item">
|
|
|
|
+ <input type="password" class="input" v-model="password" placeholder="请输入登录密码"
|
|
|
|
+ maxlength="32" />
|
|
|
|
+ </view>
|
|
|
|
+ <view class="other_list">
|
|
|
|
+ <text class="left" v-if="true" @click="type = 'mobile'">验证码登录</text>
|
|
|
|
+ <text class="left" v-else></text>
|
|
|
|
+ <text class="right" @click="type = 'mobile'" v-if="false">验证码登录</text>
|
|
|
|
+ <text class="right" @click="toRegist">还没有账号?开始注册</text>
|
|
|
|
+ </view>
|
|
|
|
+ </block>
|
|
|
|
+
|
|
|
|
+ <block v-if="type == 'mobile'">
|
|
|
|
+ <view class="name">验证码:</view>
|
|
|
|
+ <view class="item">
|
|
|
|
+ <input type="text" class="input" v-model="code" placeholder="请输入验证码" maxlength="6" />
|
|
|
|
+ <view class="btn" v-if="captchaTime === 0" @click="getCode">获取验证码</view>
|
|
|
|
+ <view class="btn" v-if="captchaTime > 0">{{ captchaTime }}秒后重试</view>
|
|
|
|
+ </view>
|
|
|
|
+ <view class="other_list" v-if="false">
|
|
|
|
+ <text class="left"></text>
|
|
|
|
+ <text class="right" @click="type = 'pass'" style="color: blue;">密码登录</text>
|
|
|
|
+ </view>
|
|
|
|
+ </block>
|
|
|
|
+ <text class="btn_submit" @click="toLogin">登录/注册</text>
|
|
|
|
+ </template>
|
|
|
|
+ <text class="btn_submit" @click="oneClickLoginFun">一键登录</text>
|
|
</block>
|
|
</block>
|
|
|
|
|
|
<view class="wechat" v-if="false">
|
|
<view class="wechat" v-if="false">
|
|
@@ -107,6 +113,78 @@ export default {
|
|
push_token: '',
|
|
push_token: '',
|
|
lat: '',
|
|
lat: '',
|
|
lng: '',
|
|
lng: '',
|
|
|
|
+ univerifyStyle: {
|
|
|
|
+ "fullScreen": true, // 是否全屏显示,默认值: false
|
|
|
|
+ "backgroundColor": "#ffffff", // 授权页面背景颜色,默认值:#ffffff
|
|
|
|
+ "backgroundImage": "", // 全屏显示的背景图片,默认值:"" (仅支持本地图片,只有全屏显示时支持)
|
|
|
|
+ "icon": {
|
|
|
|
+ "path": "/static/logo.png", // 自定义显示在授权框中的logo,仅支持本地图片 默认显示App logo
|
|
|
|
+ "width": "60px", //图标宽度 默认值:60px
|
|
|
|
+ "height": "60px" //图标高度 默认值:60px
|
|
|
|
+ },
|
|
|
|
+ "closeIcon": {
|
|
|
|
+ "path": "/static/icon/whiteBackground.png", // 自定义显示在授权框中的取消图片,仅支持本地图片
|
|
|
|
+ "width": "60px", //图标宽度 默认值:60px (HBuilderX 4.0+ 仅iOS支持)
|
|
|
|
+ "height": "60px" //图标高度 默认值:60px (HBuilderX 4.0+ 仅iOS支持)
|
|
|
|
+ },
|
|
|
|
+ "phoneNum": {
|
|
|
|
+ "color": "#202020" // 手机号文字颜色 默认值:#202020
|
|
|
|
+ },
|
|
|
|
+ "slogan": {
|
|
|
|
+ "color": "#BBBBBB" // slogan 字体颜色 默认值:#BBBBBB
|
|
|
|
+ },
|
|
|
|
+ "authButton": {
|
|
|
|
+ "normalColor": "#131313", // 授权按钮正常状态背景颜色 默认值:#3479f5
|
|
|
|
+ "highlightColor": "#131313", // 授权按钮按下状态背景颜色 默认值:#2861c5(仅ios支持)
|
|
|
|
+ "disabledColor": "#73aaf5", // 授权按钮不可点击时背景颜色 默认值:#73aaf5(仅ios支持)
|
|
|
|
+ "textColor": "#ffffff", // 授权按钮文字颜色 默认值:#ffffff
|
|
|
|
+ "title": "本机号码一键登录", // 授权按钮文案 默认值:“本机号码一键登录”
|
|
|
|
+ "borderRadius": "24px" // 授权按钮圆角 默认值:"24px" (按钮高度的一半)
|
|
|
|
+ },
|
|
|
|
+ "otherLoginButton": {
|
|
|
|
+ "visible": false, // 是否显示其他登录按钮,默认值:true
|
|
|
|
+ "normalColor": "", // 其他登录按钮正常状态背景颜色 默认值:透明
|
|
|
|
+ "highlightColor": "", // 其他登录按钮按下状态背景颜色 默认值:透明
|
|
|
|
+ "textColor": "#656565", // 其他登录按钮文字颜色 默认值:#656565
|
|
|
|
+ "title": "其他登录方式", // 其他登录方式按钮文字 默认值:“其他登录方式”
|
|
|
|
+ "borderColor": "", //边框颜色 默认值:透明(仅iOS支持)
|
|
|
|
+ "borderRadius": "0px" // 其他登录按钮圆角 默认值:"24px" (按钮高度的一半)
|
|
|
|
+ },
|
|
|
|
+ "privacyTerms": {
|
|
|
|
+ "defaultCheckBoxState": true, // 条款勾选框初始状态 默认值: true
|
|
|
|
+ "isCenterHint": true, //未勾选服务条款时点击登录按钮的提示是否居中显示 默认值: false (3.7.13+ 版本支持)
|
|
|
|
+ "uncheckedImage": "/static/icon/wd_icon_gouxuan04.png", // 可选 条款勾选框未选中状态图片(仅支持本地图片 建议尺寸 24x24px)(3.2.0+ 版本支持)
|
|
|
|
+ "checkedImage": "/static/icon/wd_icon_gouxuan05.png", // 可选 条款勾选框选中状态图片(仅支持本地图片 建议尺寸24x24px)(3.2.0+ 版本支持)
|
|
|
|
+ "checkBoxSize": 16, // 可选 条款勾选框大小
|
|
|
|
+ "textColor": "#BBBBBB", // 文字颜色 默认值:#BBBBBB
|
|
|
|
+ "termsColor": "#5496E3", // 协议文字颜色 默认值: #5496E3
|
|
|
|
+ "prefix": "我已阅读并同意", // 条款前的文案 默认值:“我已阅读并同意”
|
|
|
|
+ "suffix": "并使用本机号码登录", // 条款后的文案 默认值:“并使用本机号码登录”
|
|
|
|
+ "privacyItems": [ // 自定义协议条款,最大支持2个,需要同时设置url和title. 否则不生效
|
|
|
|
+ {
|
|
|
|
+ "url": "https://e.zhichao.art/web/yszc.php", // 点击跳转的协议详情页面
|
|
|
|
+ "title": "隐私协议" // 协议名称
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "url": "https://e.zhichao.art/web/yhxy.php", // 点击跳转的协议详情页面
|
|
|
|
+ "title": "用户使用协议" // 协议名称
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ },
|
|
|
|
+ "buttons": { // 自定义页面下方按钮仅全屏模式生效(3.1.14+ 版本支持)
|
|
|
|
+ "iconWidth": "45px", // 图标宽度(高度等比例缩放) 默认值:45px
|
|
|
|
+ "list": [
|
|
|
|
+ {
|
|
|
|
+ "provider": "apple",
|
|
|
|
+ // "iconPath": "/static/apple.png" // 图标路径仅支持本地图片
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "provider": "weixin",
|
|
|
|
+ // "iconPath": "/static/wechat.png" // 图标路径仅支持本地图片
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onLoad() {
|
|
onLoad() {
|
|
@@ -131,6 +209,7 @@ export default {
|
|
console.log(err)
|
|
console.log(err)
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ this.oneClickLoginFun();
|
|
},
|
|
},
|
|
onShow() {
|
|
onShow() {
|
|
// let hsign = pubc.Encrypt("aboa-wifl-kwfl-zjfk-wlaa_FA0412932BAE9D98506580ADB348BEF9");
|
|
// let hsign = pubc.Encrypt("aboa-wifl-kwfl-zjfk-wlaa_FA0412932BAE9D98506580ADB348BEF9");
|
|
@@ -155,11 +234,13 @@ export default {
|
|
// console.error('获取位置失败:', error);
|
|
// console.error('获取位置失败:', error);
|
|
// }
|
|
// }
|
|
// });
|
|
// });
|
|
|
|
+
|
|
|
|
+
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
goWeb(url, title) {
|
|
goWeb(url, title) {
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
- url: `/pages/webview/index?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title) }`
|
|
|
|
|
|
+ url: `/pages/webview/index?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}`
|
|
})
|
|
})
|
|
},
|
|
},
|
|
onBack() { },
|
|
onBack() { },
|
|
@@ -199,7 +280,6 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
toLogin() {
|
|
toLogin() {
|
|
- console.log('aaa');
|
|
|
|
let that = this;
|
|
let that = this;
|
|
if (this.mobile.length != 11) {
|
|
if (this.mobile.length != 11) {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
@@ -252,6 +332,11 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ this.loginInterface({ isOneClickLogin: false, phone: '' },)
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ loginInterface({ isOneClickLogin, phone }) {
|
|
|
|
+ let that = this;
|
|
let channel = "";
|
|
let channel = "";
|
|
// #ifdef APP-PLUS
|
|
// #ifdef APP-PLUS
|
|
channel = plus.runtime.channel;
|
|
channel = plus.runtime.channel;
|
|
@@ -261,15 +346,25 @@ export default {
|
|
mask: true,
|
|
mask: true,
|
|
});
|
|
});
|
|
console.log("host", this.$apiHost + method);
|
|
console.log("host", this.$apiHost + method);
|
|
|
|
+ let mobile = this.mobile;
|
|
|
|
+ let code = this.code;
|
|
|
|
+ let type = this.type;
|
|
|
|
+ console.log(type, 89);
|
|
|
|
+ let method = '/Member/gamelogin';
|
|
|
|
+ if (isOneClickLogin) {
|
|
|
|
+ mobile = phone;
|
|
|
|
+ code = '123601';
|
|
|
|
+ type = 'mobile';
|
|
|
|
+ }
|
|
uni.request({
|
|
uni.request({
|
|
url: this.$apiHost + method,
|
|
url: this.$apiHost + method,
|
|
data: {
|
|
data: {
|
|
uuid: getApp().globalData.uuid,
|
|
uuid: getApp().globalData.uuid,
|
|
channel: channel,
|
|
channel: channel,
|
|
- loginType: this.type,
|
|
|
|
- mobile: this.mobile,
|
|
|
|
|
|
+ loginType: type,
|
|
|
|
+ mobile,
|
|
password: this.password,
|
|
password: this.password,
|
|
- code: this.code,
|
|
|
|
|
|
+ code,
|
|
push_token: this.push_token,
|
|
push_token: this.push_token,
|
|
lat: this.lat,
|
|
lat: this.lat,
|
|
lng: this.lng,
|
|
lng: this.lng,
|
|
@@ -313,6 +408,7 @@ export default {
|
|
},
|
|
},
|
|
success: (res) => {
|
|
success: (res) => {
|
|
console.log("--获取用户信息--:", res.data);
|
|
console.log("--获取用户信息--:", res.data);
|
|
|
|
+
|
|
if (res.data.need_login == "yes") {
|
|
if (res.data.need_login == "yes") {
|
|
|
|
|
|
}
|
|
}
|
|
@@ -415,8 +511,89 @@ export default {
|
|
this.getCodeTime();
|
|
this.getCodeTime();
|
|
}, 1000);
|
|
}, 1000);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ oneClickLoginFun() {
|
|
|
|
+ let _this = this;
|
|
|
|
+ //预登陆
|
|
|
|
+ uni.preLogin({
|
|
|
|
+ provider: 'univerify',
|
|
|
|
+ success() { //预登录成功
|
|
|
|
+ // 显示一键登录选项
|
|
|
|
+ uni.login({
|
|
|
|
+ provider: 'univerify',
|
|
|
|
+ univerifyStyle: _this.univerifyStyle,
|
|
|
|
+ success(res) { // 登录成功
|
|
|
|
+ console.log(res.authResult.access_token);
|
|
|
|
+ console.log(res.authResult.openid);
|
|
|
|
+ // 此处获取了openid和access_token
|
|
|
|
+ // {openid:'登录授权唯一标识',access_token:'接口返回的 token'}
|
|
|
|
+ // 通过uniCloud.callFunction函数实现前端获取手机号
|
|
|
|
+ uniCloud.callFunction({
|
|
|
|
+ name: "oneClickLogin", // 填写你自己的云函数名称
|
|
|
|
+ //传入上面获取的openid和access_token获取手机号
|
|
|
|
+ data: {
|
|
|
|
+ access_token: res.authResult.access_token, // 客户端一键登录接口返回的access_token
|
|
|
|
+ openid: res.authResult.openid // 客户端一键登录接口返回的openid
|
|
|
|
+ }
|
|
|
|
+ }).then((dataRes) => {
|
|
|
|
+ //此处已经成功获取手机号等信息
|
|
|
|
+ console.log("云函数返回的参数1", dataRes)
|
|
|
|
+ let phone = dataRes.result.data.phoneNumber
|
|
|
|
+ if (phone) {
|
|
|
|
+ _this.loginInterface({
|
|
|
|
+ isOneClickLogin: true,
|
|
|
|
+ phone,
|
|
|
|
+ })
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ uni.closeAuthView() //关闭一键登录弹出窗口
|
|
|
|
+ }, 500)
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ // 获取手机号后根据自己的需求做后面的登录操作即可
|
|
|
|
+ //...
|
|
|
|
+ }).catch((err) => {
|
|
|
|
+ console.log(err);
|
|
|
|
+ console.log("云函数报错", err)
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: err.errMsg,
|
|
|
|
+ icon: "none"
|
|
|
|
+ })
|
|
|
|
+ this_ = this
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ uni.closeAuthView() //关闭一键登录弹出窗口
|
|
|
|
+ this.onClickMsgLogin()
|
|
|
|
+ }, 500)
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ fail(res) { // 登录失败
|
|
|
|
+ console.log(res.errCode)
|
|
|
|
+ console.log(res.errMsg)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ fail(res) {
|
|
|
|
+ // 预登录失败
|
|
|
|
+ // 不显示一键登录选项(或置灰)
|
|
|
|
+ // 根据错误信息判断失败原因,如有需要可将错误提交给统计服务器
|
|
|
|
+ console.log(res.errCode)
|
|
|
|
+ console.log(res.errMsg)
|
|
|
|
+ this.onClickMsgLogin()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 一键登录失败
|
|
|
|
+ onClickMsgLogin() {
|
|
|
|
+ uni.closeAuthView()
|
|
|
|
+ uni.showToast({
|
|
|
|
+ // title: '一键登录失败,请使用其他方式登录',
|
|
|
|
+ title: '一键登录失败,请重试',
|
|
|
|
+ icon: "none"
|
|
|
|
+ })
|
|
|
|
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|