| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <template>
- <view>
- <!-- 登陆拦截页面 -->
- </view>
- </template>
- <script>
- export default {
- data() {
- return {}
- },
- onLoad() {
- // let identity = uni.getStorageSync("identity");
- // let updataMsg = uni.getStorageSync("updataMsg");
- console.log('dgfskjdblail验证')
- this.loginFilter() //获取token
- },
- methods: {
- //获取token
- loginFilter() {
- let cardNumber = this.getQueryString('cardNumber')
- let error = this.getQueryString('error')
- let errorMsg = this.getQueryString('errorMsg')
- //此为微校授权地址
- let weixinUrl = `https://open.wecard.qq.com/connect/oauth/authorize?app_key=EE28EE2C93296F4E&response_type=code&scope=snsapi_base&ocode=1015730314&redirect_uri=https://jtishfw.ncjti.edu.cn/baoxiu/repairApi/wx/getCardNumber&state=STATE`
- if (error) {
- //微校服务器报错提示框
- uni.showToast({
- title: errorMsg,
- icon: 'error',
- mask: true,
- duration: 1000,
- })
- } else if (!cardNumber) {
- window.location.href = weixinUrl
- } else {
- uni.setStorageSync('token', cardNumber)
- uni.setStorageSync('identity', JSON.stringify(0)) //身份标识
- this.getDetailMess() //获取学生详细信息
- }
- },
- //获取当前URL指定参数
- getQueryString(name) {
- let url = window.location.href // 获取URL
- let pattern = new RegExp('[?&]' + name + '=([^&]+)', 'i') // 正则匹配URL
- let matcher = pattern.exec(url)
- if (matcher == null || matcher.length < 1) {
- return false
- }
- return decodeURIComponent(matcher[1]) // 输出指定的参数值中文也可以
- },
- //换取详情信息
- async getDetailMess() {
- let res = await this.$myRequest({
- method: 'post',
- url: `/student/queryByStudentId`,
- })
- // console.log(res)
- if (res.status == 200) {
- uni.setStorageSync('student', res.data)
- let updataMsg = uni.getStorageSync('updataMsg')
- if (updataMsg) {
- console.log('主页')
- uni.reLaunch({
- url: '../home/home',
- })
- } else {
- console.log('信息页')
- uni.reLaunch({
- url: '../personal-information/personal-information',
- })
- }
- }
- },
- },
- }
- </script>
- <style lang="scss"></style>
|