|
|
|
@ -1,14 +1,14 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { debounce } from 'feng-uniapp-exploit/utils/index' |
|
|
|
import { getMobile, getSign } from '@/api/login' |
|
|
|
import { debounce } from 'feng-uniapp-exploit/utils/index' |
|
|
|
import { getMobile, getSign} from '@/api/login' |
|
|
|
|
|
|
|
import useUserStore from '@/store/user' |
|
|
|
const userStore = useUserStore() |
|
|
|
import useUserStore from '@/store/user' |
|
|
|
const userStore = useUserStore() |
|
|
|
|
|
|
|
const loginCode = ref('') |
|
|
|
const loginCode = ref('') |
|
|
|
|
|
|
|
// 获取微信登录 code |
|
|
|
const getLoginCode = async (): Promise<string> => { |
|
|
|
// 获取微信登录 code |
|
|
|
const getLoginCode = async () : Promise<string> => { |
|
|
|
try { |
|
|
|
const res = await uni.login({ provider: 'weixin' }) |
|
|
|
loginCode.value = res.code |
|
|
|
@ -17,14 +17,14 @@ const getLoginCode = async (): Promise<string> => { |
|
|
|
console.error('获取登录code失败:', error) |
|
|
|
throw error |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 处理获取手机号 |
|
|
|
// 处理获取手机号 |
|
|
|
|
|
|
|
interface phoneEvent { |
|
|
|
detail: { errMsg: string; iv: string; encryptedData: string; code: string } |
|
|
|
} |
|
|
|
const onGetPhoneNumber = debounce(async (e: phoneEvent) => { |
|
|
|
interface phoneEvent { |
|
|
|
detail : { errMsg : string; iv : string; encryptedData : string; code : string } |
|
|
|
} |
|
|
|
const onGetPhoneNumber = debounce(async (e : phoneEvent) => { |
|
|
|
if (e.detail.errMsg.includes('fail')) { |
|
|
|
uni.showToast({ title: '用户拒绝授权', icon: 'none' }) |
|
|
|
return |
|
|
|
@ -41,7 +41,7 @@ const onGetPhoneNumber = debounce(async (e: phoneEvent) => { |
|
|
|
|
|
|
|
getMobile({ openid: userStore.openId, code: e.detail.code }) |
|
|
|
.then((res) => { |
|
|
|
const { data: phone } = res as { data: string } |
|
|
|
const { data: phone } = res as { data : string } |
|
|
|
|
|
|
|
userStore.mobile = phone |
|
|
|
|
|
|
|
@ -55,57 +55,52 @@ const onGetPhoneNumber = debounce(async (e: phoneEvent) => { |
|
|
|
} catch (error) { |
|
|
|
uni.showToast({ title: '登录失败', icon: 'none' }) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
const meetid = ref('') |
|
|
|
}) |
|
|
|
|
|
|
|
const onLoginSuccess = () => { |
|
|
|
const onLoginSuccess = () => { |
|
|
|
uni.showToast({ |
|
|
|
title: '登录成功', |
|
|
|
icon: 'none', |
|
|
|
success: () => { |
|
|
|
setTimeout(() => { |
|
|
|
userStore.showtoast = false |
|
|
|
uni.reLaunch({ url: '/pages/votingElection/index?meetId='+ meetid.value }) |
|
|
|
|
|
|
|
uni.reLaunch({ url: '/pages/votingElection/index?meetId=' + userStore.meetId }) |
|
|
|
}, 1000) |
|
|
|
} |
|
|
|
}) |
|
|
|
getSign({openid: userStore.openId, meetId: meetid.value}) |
|
|
|
|
|
|
|
} |
|
|
|
onLoad((options: any) => { |
|
|
|
} |
|
|
|
onLoad((options : any) => { |
|
|
|
console.log('扫码参数1:', options); |
|
|
|
if(options.scene){ |
|
|
|
meetid.value = options.scene |
|
|
|
if (options.scene) { |
|
|
|
userStore.meetId = options.scene |
|
|
|
uni.setStorageSync('meetstorage', { |
|
|
|
meetid: options.scene |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
onShow(() => { |
|
|
|
if (userStore.mobile) { |
|
|
|
onLoginSuccess() |
|
|
|
} |
|
|
|
}) |
|
|
|
onShow(() => { |
|
|
|
// if (userStore.mobile) { |
|
|
|
// onLoginSuccess() |
|
|
|
// } |
|
|
|
}) |
|
|
|
</script> |
|
|
|
<template> |
|
|
|
<view class="login"> |
|
|
|
<image class="logo-img" src="@/static/logo.png" mode="widthFix" /> |
|
|
|
|
|
|
|
<view class="btn_box"> |
|
|
|
<u-button |
|
|
|
@getphonenumber="onGetPhoneNumber" |
|
|
|
text="请签到后进行投票" |
|
|
|
icon-color="#fff" |
|
|
|
open-type="getPhoneNumber" |
|
|
|
color="linear-gradient(270deg, rgba(232, 123, 7, 1) 0%, rgba(247, 205, 77, 1) 100%)" |
|
|
|
shape="circle" |
|
|
|
/> |
|
|
|
<u-button @getphonenumber="onGetPhoneNumber" text="请签到后进行投票" icon-color="#fff" open-type="getPhoneNumber" |
|
|
|
color="linear-gradient(270deg, rgba(232, 123, 7, 1) 0%, rgba(247, 205, 77, 1) 100%)" shape="circle" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
|
.login { |
|
|
|
.login { |
|
|
|
width: 100%; |
|
|
|
height: 100vh; |
|
|
|
overflow: hidden; |
|
|
|
@ -119,5 +114,5 @@ onShow(() => { |
|
|
|
width: 220rpx; |
|
|
|
margin-bottom: 60rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |