YanxueInfo.vue
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<template>
<div>
<van-field v-model="school" label="学校" readonly placeholder="学校" />
<van-field v-model="name" label="学生姓名" readonly placeholder="姓名" />
<van-field v-model="userNum" label="用户编号" readonly placeholder="用户编号" />
<van-field v-model="codeNum" label="研学码" readonly placeholder="研学码">
<van-button slot="button" size="small" native-type="button" @click="saoYiSao">扫一扫</van-button>
</van-field>
<van-button type="primary" block @click="getbind">提交</van-button>
</div>
</template>
<script>
export default {
data () {
return {
codeNum: '',
userNum: '',
school: '',
name: ''
}
},
created () {
let studentInfo = JSON.parse(localStorage.getItem('StudentDetialInfo'));
this.userNum = studentInfo.travelerNum
this.school = studentInfo.schoolName
this.name = studentInfo.travelerName
this.codeNum = this.GetQueryString('qrresult') || studentInfo.studyCode;
},
methods: {
getbind () {
if (this.userNum == '' || this.codeNum == '') {
return this.$toast('请先填写完整信息!');
}
this.yxAxios.get('https://proxy.shunzhi.net/prod/user/info/bingStudyCode?userNum=' + this.userNum + '&code=' + this.codeNum)
.then((res) => {
console.log('接口返回', res.data)
if (res.data.code == '200') {
this.$toast('操作成功');
this.$router.push({ name: 'YanxueCode' })
} else {
this.$toast('操作失败:'+ res.data.message);
}
})
},
//扫一扫
saoYiSao () {
ZWJSBridge.scan({
type: 'qrCode',
})
.then((res) => {
if(res.qrcode&&!isNaN(Number(res.qrcode))){
this.$router.push({ name: 'YanxueInfo', query: { qrresult: res.qrcode } })
}else{
this.$toast.fail('扫码失败')
}
})
.catch((err) => {
console.log(err)
})
},
// 获取链接参数
GetQueryString (name) {
var reg = new RegExp("\\b" + name + "=([^&]*)");
var r = location.href.match(reg);
if (r != null) return decodeURIComponent(r[1]);
}
}
}
</script>
<style>
</style>