...
|
...
|
@@ -13,11 +13,18 @@ |
|
|
</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
<u-modal :show="showMessage" :title="`title`">
|
|
|
<view class="slot-content">
|
|
|
<rich-text :nodes="message"></rich-text>
|
|
|
</view>
|
|
|
</u-modal>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { ref, getCurrentInstance, ComponentPublicInstance } from 'vue'
|
|
|
import { DebounceBy } from '@/utils/debounceBy'
|
|
|
import { doctorPhoneEasyLogin } from '../../../api'
|
|
|
import { doctorPhoneEasyLoginType } from '../../../types'
|
|
|
|
|
|
interface IProps {
|
|
|
loginState: number
|
...
|
...
|
@@ -32,17 +39,23 @@ const isConfirmProtocol = ref<Boolean>(false) |
|
|
|
|
|
const login = DebounceBy(() => (isConfirmProtocol.value ? emit('login', props.loginState) : uni.$u.toast('请先同意协议')), 1500)
|
|
|
|
|
|
const message = ref({})
|
|
|
|
|
|
const showMessage = ref<boolean>(false)
|
|
|
|
|
|
const oneClickLoginHandler = () => {
|
|
|
// uniCloud
|
|
|
// .callFunction({
|
|
|
// name: 'oneclicklogin', // 你的云函数名称
|
|
|
// data: {
|
|
|
// access_token: 'xxx', // 客户端一键登录接口返回的access_token
|
|
|
// openid: 'xxx' // 客户端一键登录接口返回的openid
|
|
|
// access_token: 'bm1mYjQ0MGFkODcwMmU0OWM1YjUzODFhYzY5NmQ0YWYxY3wwNjM1fDN8djJ8M3w0MjYwNzgwM2FkMTUzMmY1YWNkZDUxN2Y1YzIwNTZlZg==', // 客户端一键登录接口返回的access_token
|
|
|
// openid: '100gtc_244041310f9634388fe309834f34e77838' // 客户端一键登录接口返回的openid
|
|
|
// }
|
|
|
// })
|
|
|
// .then(res => {
|
|
|
// console.log(res, 'callFunction res')
|
|
|
// message.value = JSON.stringify(res)
|
|
|
// showMessage.value = true
|
|
|
// // res.result = {
|
|
|
// // code: '',
|
|
|
// // message: ''
|
...
|
...
|
@@ -50,81 +63,63 @@ const oneClickLoginHandler = () => { |
|
|
// })
|
|
|
// .catch(err => {
|
|
|
// console.log(err, 'callFunction err')
|
|
|
// message.value = JSON.stringify(err)
|
|
|
// showMessage.value = true
|
|
|
// // 处理错误
|
|
|
// })
|
|
|
uni.login({
|
|
|
provider: 'univerify',
|
|
|
univerifyStyle: {
|
|
|
fullScreen: false, // 是否全屏显示,默认值: false
|
|
|
backgroundColor: '#ffffff', // 授权页面背景颜色,默认值:#ffffff
|
|
|
backgroundImage: '', // 全屏显示的背景图片,默认值:"" (仅支持本地图片,只有全屏显示时支持)
|
|
|
icon: {
|
|
|
path: 'static/xxx.png', // 自定义显示在授权框中的logo,仅支持本地图片 默认显示App logo
|
|
|
width: '60px', //图标宽度 默认值:60px
|
|
|
height: '60px' //图标高度 默认值:60px
|
|
|
},
|
|
|
closeIcon: {
|
|
|
path: 'static/xxx.png' // 自定义关闭按钮,仅支持本地图片。 HBuilderX3.3.7+版本支持
|
|
|
},
|
|
|
phoneNum: {
|
|
|
color: '#202020' // 手机号文字颜色 默认值:#202020
|
|
|
},
|
|
|
slogan: {
|
|
|
color: '#BBBBBB' // slogan 字体颜色 默认值:#BBBBBB
|
|
|
},
|
|
|
authButton: {
|
|
|
normalColor: '#3479f5', // 授权按钮正常状态背景颜色 默认值:#3479f5
|
|
|
highlightColor: '#2861c5', // 授权按钮按下状态背景颜色 默认值:#2861c5(仅ios支持)
|
|
|
disabledColor: '#73aaf5', // 授权按钮不可点击时背景颜色 默认值:#73aaf5(仅ios支持)
|
|
|
textColor: '#ffffff', // 授权按钮文字颜色 默认值:#ffffff
|
|
|
title: '本机号码一键登录', // 授权按钮文案 默认值:“本机号码一键登录”
|
|
|
borderRadius: '24px' // 授权按钮圆角 默认值:"24px" (按钮高度的一半)
|
|
|
},
|
|
|
fullScreen: true,
|
|
|
otherLoginButton: {
|
|
|
visible: true, // 是否显示其他登录按钮,默认值:true
|
|
|
normalColor: '', // 其他登录按钮正常状态背景颜色 默认值:透明
|
|
|
highlightColor: '', // 其他登录按钮按下状态背景颜色 默认值:透明
|
|
|
textColor: '#656565', // 其他登录按钮文字颜色 默认值:#656565
|
|
|
title: '其他登录方式', // 其他登录方式按钮文字 默认值:“其他登录方式”
|
|
|
borderColor: '', //边框颜色 默认值:透明(仅iOS支持)
|
|
|
borderRadius: '0px' // 其他登录按钮圆角 默认值:"24px" (按钮高度的一半)
|
|
|
},
|
|
|
privacyTerms: {
|
|
|
defaultCheckBoxState: true, // 条款勾选框初始状态 默认值: true
|
|
|
isCenterHint: false, //未勾选服务条款时点击登录按钮的提示是否居中显示 默认值: false (3.7.13+ 版本支持)
|
|
|
uncheckedImage: '', // 可选 条款勾选框未选中状态图片(仅支持本地图片 建议尺寸 24x24px)(3.2.0+ 版本支持)
|
|
|
checkedImage: '', // 可选 条款勾选框选中状态图片(仅支持本地图片 建议尺寸24x24px)(3.2.0+ 版本支持)
|
|
|
checkBoxSize: 12, // 可选 条款勾选框大小
|
|
|
textColor: '#BBBBBB', // 文字颜色 默认值:#BBBBBB
|
|
|
termsColor: '#5496E3', // 协议文字颜色 默认值: #5496E3
|
|
|
prefix: '我已阅读并同意', // 条款前的文案 默认值:“我已阅读并同意”
|
|
|
suffix: '并使用本机号码登录', // 条款后的文案 默认值:“并使用本机号码登录”
|
|
|
privacyItems: [
|
|
|
// 自定义协议条款,最大支持2个,需要同时设置url和title. 否则不生效
|
|
|
{
|
|
|
url: 'https://', // 点击跳转的协议详情页面
|
|
|
title: '用户服务协议' // 协议名称
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
buttons: {
|
|
|
// 自定义页面下方按钮仅全屏模式生效(3.1.14+ 版本支持)
|
|
|
iconWidth: '45px', // 图标宽度(高度等比例缩放) 默认值:45px
|
|
|
list: [
|
|
|
{
|
|
|
provider: 'apple',
|
|
|
iconPath: '/static/apple.png' // 图标路径仅支持本地图片
|
|
|
},
|
|
|
{
|
|
|
provider: 'weixin',
|
|
|
iconPath: '/static/wechat.png' // 图标路径仅支持本地图片
|
|
|
}
|
|
|
]
|
|
|
visible: false
|
|
|
}
|
|
|
},
|
|
|
success(res) {
|
|
|
async success(res) {
|
|
|
// 登录成功
|
|
|
console.log(res, '成功') // {openid:'登录授权唯一标识',access_token:'接口返回的 token'}
|
|
|
// uniCloud
|
|
|
// .callFunction({
|
|
|
// name: 'oneclicklogin', // 你的云函数名称
|
|
|
// data: {
|
|
|
// access_token: res.authResult.access_token, // 客户端一键登录接口返回的access_token
|
|
|
// openid: res.authResult.openid // 客户端一键登录接口返回的openid
|
|
|
// }
|
|
|
// })
|
|
|
// .then(res => {
|
|
|
// console.log(res, 'callFunction res')
|
|
|
// message.value = JSON.stringify(res)
|
|
|
// showMessage.value = true
|
|
|
// // res.result = {
|
|
|
// // code: '',
|
|
|
// // message: ''
|
|
|
// // }
|
|
|
// })
|
|
|
// .catch(err => {
|
|
|
// console.log(err, 'callFunction err')
|
|
|
// message.value = JSON.stringify(err)
|
|
|
// showMessage.value = true
|
|
|
// // 处理错误
|
|
|
// })
|
|
|
// try {
|
|
|
// const { result } = await doctorPhoneEasyLogin(res.authResult)
|
|
|
|
|
|
// console.log(result, '一键登录')
|
|
|
|
|
|
// uni.setStorageSync('token', result.token)
|
|
|
|
|
|
// uni.setStorageSync('UserInfo', result.userInfo)
|
|
|
|
|
|
// setTimeout(() => {
|
|
|
// uni.$u.toast('登录成功')
|
|
|
// }, 1000)
|
|
|
|
|
|
// uni.reLaunch({ url: '/pages/index/index' })
|
|
|
// } catch (error) {
|
|
|
// console.log(error, '一键登录err')
|
|
|
|
|
|
// uni.$u.toast(error)
|
|
|
// }
|
|
|
},
|
|
|
fail(res) {
|
|
|
// 登录失败
|
...
|
...
|
@@ -132,15 +127,16 @@ const oneClickLoginHandler = () => { |
|
|
console.log(res.errMsg)
|
|
|
}
|
|
|
})
|
|
|
uni.getProvider({
|
|
|
service: 'oauth',
|
|
|
success: function (res) {
|
|
|
console.log(res, '权限') // ['qq', 'univerify']
|
|
|
},
|
|
|
fail: function (err) {
|
|
|
console.log(err, '错误')
|
|
|
}
|
|
|
})
|
|
|
// uni.getProvider({
|
|
|
// service: 'oauth',
|
|
|
// success: function (res) {
|
|
|
// console.log(res, '登录权限') // ['qq', 'univerify']
|
|
|
// // authResult
|
|
|
// },
|
|
|
// fail: function (err) {
|
|
|
// console.log(err, '登录权限错误')
|
|
|
// }
|
|
|
// })
|
|
|
|
|
|
// uni.preLogin({
|
|
|
// provider: 'univerify',
|
...
|
...
|
|