Selaa lähdekoodia

扫码报到

西昌缴费二期
杨晓琪 2 vuotta sitten
vanhempi
commit
830eefee4b
2 muutettua tiedostoa jossa 104 lisäystä ja 33 poistoa
  1. +67
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/scanCode.vue
  2. +37
    -33
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/EducationalAdministration/R_EnterSchool/list.vue

+ 67
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/scanCode.vue Näytä tiedosto

@@ -0,0 +1,67 @@
<template>
<view></view>
</template>
<script>
import wx from '@/common/js/weixin-js-sdk.js';
export default {
name:"scanCode",
props:{},
data() {
return {
scanCodeReady:false,
};
},
mounted() {
this.setConfig()
},
methods: {
setConfig() {
const promise = new Promise((resolve, reject) => {
this.HTTP_GET("weixinapi/getweixinwebaccess_token?url=" + encodeURIComponent(window.location.href)).then((success)=>{
if(!success){
resolve(false)
return
}
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: success.appid, // 必填,公众号的唯一标识
timestamp: success.timestamp, // 必填,生成签名的时间戳
nonceStr: success.noncestr, // 必填,生成签名的随机串
signature: success.certificate, // 必填,签名
jsApiList: ["scanQRCode"] // 必填,需要使用的JS接口列表
});
wx.ready(() => {
this.scanCodeReady = true
})
})
})
return promise
},
scanCode(){
return new Promise((resolve)=>{
if(!this.scanCodeReady){
resolve(false)
}
wx.scanQRCode({
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
success: function (res) {
var result = res.resultStr; // 当 needResult 为 1 时,扫码返回的结果
var resultArr = result.split(','); // 扫描结果以逗号分割数组
var codeContent = resultArr[resultArr.length - 1]; // 获取数组最后一个元素,也就是最终的内容
resolve({result:codeContent})
},
fail: function (res) {
this.TOAST("调用扫码失败")
resolve(false)
}
});
})
}
},
}
</script>

<style>

</style>

+ 37
- 33
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/EducationalAdministration/R_EnterSchool/list.vue Näytä tiedosto

@@ -1,42 +1,46 @@
<template>
<view class=""><view class="btn" @click="tabCode">扫码</view></view>
<view class="page">
<view class="btn scanCodeBtn" @click="tapScan">扫码</view>
<scanCode ref="refScanCode"></scanCode>
</view>
</template>

<script>
import scanCodeFun from '@/common/js/scanCodeFun.js';
import scanCode from "@/components/scanCode.vue"
export default {
data() {
return {};
},
methods: {
init() {
let _this = this;
// 允许从相机和相册扫码
scanCodeFun.scanCodeFun().then(res => {
//console.log(res);
if(!res) return
_this.LOADING('正在提交数据…');
_this.HTTP_GET('learun/adms/EducationalAdministration/StuInfoBasic/stuinfo', res.result, '加载数据时出错').then(res => {
_this.HIDE_LOADING();
//console.log(res);
if(res){
let url = res.HealthStatus == '0'? '../StudentQRCode/Normal/list' : res.HealthStatus == '1'? '../StudentQRCode/AbNormalWeak/list' : res.HealthStatus == '2'? '../StudentQRCode/AbNormalSerious/list' : '../StudentQRCode/Normal/list';
_this.NAV_TO(url, {stuNo:res.StuNo}, true);
}
})
components:{scanCode},
data() {
return {};
},
methods: {
tapScan() {
this.$refs['refScanCode'].scanCode().then(res=>{
if (!res) return;
var userInfo = this.GET_GLOBAL("loginUser");
var result = this.HTTP_GET(
"learun/adms/EducationalAdministration/StuInfoBasic/stuinfo",
{
userid: userInfo.userId,
meetid: res.result,
},
"扫码出错"
).then(res1=>{
this.TOAST(res1.result)
})
},
tabCode() {
this.init();
}
},
mounted() {
let _this = this;
setTimeout(function() {
_this.init();
}, 100);
}
})
},
},
};
</script>

<style></style>
<style lang="less" scoped>
@import "~@/common/css/sidepage.less";
@import "~@/common/css/customlist.less";
.scanCodeBtn{
width: 120px;
height: 120px;
border-radius: 50%;
line-height: 120px;
margin-top: 180px;
}
</style>

Ladataan…
Peruuta
Tallenna