| | |
| | | <block slot="content">资产报修</block> |
| | | </cu-custom> |
| | | </view> |
| | | <view class="flex align-center justify-center Tbox"> |
| | | <view class="btnBox"> |
| | | <view @click="navigateTo('Qrcode')" class="no1" hover-class="active"> |
| | | <image src="../../static/shao02.svg" mode="widthFix"></image> |
| | | <text>点击扫码获取资产信息</text> |
| | | <!-- <view class="uni-padding-wrap uni-common-mt"> |
| | | <view class="uni-title">扫码结果:</view> |
| | | <view class="uni-list" v-if="result"> |
| | | <view class="uni-cell"> |
| | | <view class="scan-result"> |
| | | {{result}} |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> --> |
| | | <!-- <view> |
| | | url:{{url}} |
| | | |
| | | </view> |
| | | <view class=""> |
| | | <u--textarea v-model="value1" placeholder="请输入内容" ></u--textarea> |
| | | </view> --> |
| | | <u-toast ref="uToast"></u-toast> |
| | | <view class="btnBox"> |
| | | <button type="primary" @click="getWxConfig">点击扫一扫</button> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | import permision from "@/common/permission.js" |
| | | const jsWx = require('@/api/jweixin-1.2.0.js') |
| | | export default { |
| | | data() { |
| | | return { |
| | | result:'', |
| | | |
| | | } |
| | | }, |
| | | methods: { |
| | | navigateTo(url) { |
| | | setTimeout(()=>{ |
| | | uni.navigateTo({ |
| | | url: `./${url}/${url}` |
| | | getWxConfig() { |
| | | let wPath = window.document.location.href.split('#')[0]; |
| | | // this.url = wPath; |
| | | // let urlStr ="http://localhost:8085/h5/pages/assets/repair"; |
| | | console.log(wPath); |
| | | this.$http.get('/assets/approval/getWxConfig',{params:{url:wPath}}) |
| | | .then(res => { |
| | | // debugger; |
| | | |
| | | if(res.data.code===0){ |
| | | let data = res.data.data; |
| | | this.value1 = JSON.stringify(data); |
| | | jsWx.config({ |
| | | beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题 |
| | | debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 |
| | | appId: data.appId, // 必填,企业微信的corpID |
| | | timestamp: data.timestamp, // 必填,生成签名的时间戳 |
| | | nonceStr: data.nonceStr, // 必填,生成签名的随机串 |
| | | signature: data.signature,// 必填,签名,见 附录-JS-SDK使用权限签名算法 |
| | | jsApiList: ['scanQRCode'] // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来 |
| | | }); |
| | | |
| | | jsWx.ready(function(){ |
| | | // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后, |
| | | //config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。 |
| | | jsWx.scanQRCode({ |
| | | desc: 'scanQRCode desc', |
| | | needResult: 0, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果, |
| | | scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是条形码(一维码),默认二者都有 |
| | | success: function(res) { |
| | | // 回调 |
| | | this.result = res.resultStr;//当needResult为1时返回处理结果 |
| | | console.log('结果',this.result) |
| | | }, |
| | | error: function(res) { |
| | | if (res.errMsg.indexOf('function_not_exist') > 0) { |
| | | alert('版本过低请升级') |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | }).catch(err => { |
| | | this.$refs.uToast.show({ |
| | | type: 'error', |
| | | message: '错误:'+err |
| | | }); |
| | | console.log(err.data) |
| | | }) |
| | | },300) |
| | | } |
| | | }, |
| | | |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | page { |
| | | background-color: #6a6a6a; |
| | | } |
| | | |
| | | .Tbox{ |
| | | height: 100vh; |
| | | width: 100vw; |
| | | } |
| | | |
| | | .btnBox { |
| | | // border: 1rpx red solid; |
| | | .btnBox{ |
| | | height: 50vh; |
| | | display: flex; |
| | | padding: 5rpx; |
| | | |
| | | >view { |
| | | color: #fff; |
| | | width: 270rpx; |
| | | height: 270rpx; |
| | | font-size: 26rpx; |
| | | display: flex; |
| | | flex-direction: column; |
| | | align-items: center; |
| | | justify-content: center; |
| | | background-color: #777777; |
| | | margin: 8rpx; |
| | | border: 1px solid #777777; |
| | | image { |
| | | margin-bottom: 12rpx; |
| | | width: 60rpx; |
| | | } |
| | | } |
| | | |
| | | >view.active { |
| | | border: 1px solid #C0C0C0; |
| | | background-color: #868686; |
| | | } |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | </style> |