二维码登录

This commit is contained in:
zdg 2024-09-29 15:13:27 +08:00
parent 28b189e965
commit 61493a7f4e
1 changed files with 25 additions and 25 deletions

View File

@ -52,7 +52,7 @@
<div :title="value" v-if="!!value"> <div :title="value" v-if="!!value">
<vue-qr :text="value" :size="200" :margin="10" colorDark="green" colorLight="white" :logoSrc="getStaticUrl('/img/logo.png')" :logoScale="0.2" :dotScale="0.7"></vue-qr> <vue-qr :text="value" :size="200" :margin="10" colorDark="green" colorLight="white" :logoSrc="getStaticUrl('/img/logo.png')" :logoScale="0.2" :dotScale="0.7"></vue-qr>
</div> </div>
<!-- <el-button type="primary" :icon="Refresh" round title="刷新" @click="getQrUrl()" /> --> <el-button type="primary" :icon="Refresh" round title="刷新" @click="getQrUrl()" />
<!-- <el-button type="warning" :loading="dt.loadingDel" @click="removeClasscourse()">删除记录</el-button>--> <!-- <el-button type="warning" :loading="dt.loadingDel" @click="removeClasscourse()">删除记录</el-button>-->
</template> </template>
<!-- 手机登录 --> <!-- 手机登录 -->
@ -96,7 +96,7 @@ import * as Http_api from '@/api/apiService' // api接口
import useUserStore from "@/store/modules/user" // user import useUserStore from "@/store/modules/user" // user
import CryptoJS from 'crypto-js' import CryptoJS from 'crypto-js'
const baseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH let baseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
const userStore = useUserStore() const userStore = useUserStore()
const visible = ref(false) // const visible = ref(false) //
const myClassActive = ref({}) // APT const myClassActive = ref({}) // APT
@ -286,30 +286,30 @@ const getQrUrl = async() => {
const { userName, userId } = userStore.user const { userName, userId } = userStore.user
if (!id||!userName) return if (!id||!userName) return
// (wx) // (wx)
const qrCodeUrl = `wxlogin?username=${userName}&nextaction=classteaching&id=${id}` // const qrCodeUrl = `wxlogin?username=${userName}&nextaction=classteaching&id=${id}`
// teacherForm.form.qrUrl = baseUrl + qrCodeUrl
// baseUrl = 'https://localhost:7860'
// token
const url = `/teaching/classteachingonmobile?classcourseid=${id}` // -
let qrCodeUrl = '' // -
try {
// url
const res = await Http_api.toLink.setLink(url) // -
if (res.code == 200) {
const redisKey = res.data
const base64Key = CryptoJS.enc.Utf8.parse(redisKey).toString(CryptoJS.enc.Base64) // base64
const enStrUrl = encodeURIComponent(base64Key) // url
qrCodeUrl = `${url}&_server=${enStrUrl}`
teacherForm.form.qrUrl = baseUrl + qrCodeUrl
}
} catch (error) { // , token
const jsonStr = JSON.stringify({ url, token: userStore.token }) // json{url, token}
const key = `Ax19i14Ga6qEDOkGTo` // AES-key
const enStr = CryptoJS.AES.encrypt(jsonStr, key).toString() // AES-
const enStrUrl = encodeURIComponent(enStr) // url
qrCodeUrl = `${url}&?_web=${enStrUrl}`
}
teacherForm.form.qrUrl = baseUrl + qrCodeUrl teacherForm.form.qrUrl = baseUrl + qrCodeUrl
// // const baseUrl = 'https://localhost:7860'
// // token
// const url = `/teaching/classteachingonmobile?classcourseid=${id}` // -
// let qrCodeUrl = '' // -
// try {
// // url
// const res = await Http_api.toLink.setLink(url) // -
// if (res.code == 200) {
// const redisKey = res.data
// const base64Key = CryptoJS.enc.Utf8.parse(redisKey).toString(CryptoJS.enc.Base64) // base64
// const enStrUrl = encodeURIComponent(base64Key) // url
// qrCodeUrl = `?_server=${enStrUrl}`
// teacherForm.form.qrUrl = baseUrl + qrCodeUrl
// }
// } catch (error) { // , token
// const jsonStr = JSON.stringify({ url, token: userStore.token }) // json{url, token}
// const key = `Ax19i14Ga6qEDOkGTo` // AES-key
// const enStr = CryptoJS.AES.encrypt(jsonStr, key).toString() // AES-
// const enStrUrl = encodeURIComponent(enStr) // url
// qrCodeUrl = `?_web=${enStrUrl}`
// }
// teacherForm.form.qrUrl = baseUrl + qrCodeUrl
} }
// //