282 lines
7.9 KiB
Vue
282 lines
7.9 KiB
Vue
|
<template>
|
|||
|
<view class="page">
|
|||
|
<view class="item">
|
|||
|
<view class="itemname">工序流转卡</view>
|
|||
|
<view class="itemtext">
|
|||
|
<input class="iteminput" disabled v-model="planNo" />
|
|||
|
</view>
|
|||
|
<uni-icons @click="scanCode1" type="scan" size="25" color='#5c91e4' class='scan_icon'></uni-icons>
|
|||
|
</view>
|
|||
|
<view class="item">
|
|||
|
<view class="itemname">工序</view>
|
|||
|
<view class="itemtext">
|
|||
|
<input class="iteminput" disabled v-model="processCode"/>
|
|||
|
</view>
|
|||
|
<uni-icons @click="scanCode2" type="scan" size="25" color='#5c91e4' class='scan_icon'></uni-icons>
|
|||
|
</view>
|
|||
|
<view class="fixBottom">
|
|||
|
<view class="uni-flex uni-row">
|
|||
|
<view style="-webkit-flex:1;flex: 1;">
|
|||
|
<button type="primary" plain="true" style="width: 90%; background: #fff;" @click="gotoPlan">取消</button>
|
|||
|
</view>
|
|||
|
<view style="-webkit-flex:1;flex: 1;">
|
|||
|
<button type="primary" style="width: 90%;" @click="getQrCodeInfo">确定</button>
|
|||
|
</view>
|
|||
|
</view>
|
|||
|
</view>
|
|||
|
</view>
|
|||
|
|
|||
|
</template>
|
|||
|
|
|||
|
<script>
|
|||
|
import jweixin from '@/jweixin-module/index.js';
|
|||
|
export default {
|
|||
|
data() {
|
|||
|
return {
|
|||
|
processName: '',
|
|||
|
code: '',
|
|||
|
planNo: '',
|
|||
|
processCode: '',
|
|||
|
tableInfo: {
|
|||
|
processCode: '',
|
|||
|
isExamine: "",
|
|||
|
processName: "",
|
|||
|
planCount: ''
|
|||
|
},
|
|||
|
}
|
|||
|
},
|
|||
|
mounted() {
|
|||
|
this.initiateWX();
|
|||
|
},
|
|||
|
methods: {
|
|||
|
// 取消
|
|||
|
gotoPlan() {
|
|||
|
uni.navigateTo({
|
|||
|
url: 'processReport'
|
|||
|
});
|
|||
|
},
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//获取微信相关
|
|||
|
initiateWX() {
|
|||
|
this.$http
|
|||
|
.request({
|
|||
|
url: '/apis/weChat/getSignature',
|
|||
|
params: {
|
|||
|
// url:"http://120.132.17.220:18090/gyhl-app/"
|
|||
|
url: window.location.href.split('#')[0]
|
|||
|
}
|
|||
|
})
|
|||
|
.then(res => {
|
|||
|
if (res.data.code == 0) {
|
|||
|
var s = res.data;
|
|||
|
jweixin.config({
|
|||
|
beta: true,
|
|||
|
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|||
|
appId: s.corpId, // 必填,公众号的唯一标识
|
|||
|
timestamp: s.timestamp, // 必填,生成签名的时间戳
|
|||
|
nonceStr: s.nonceStr, // 必填,生成签名的随机串
|
|||
|
signature: s.signature.toLowerCase(), // 必填,签名,见附录1
|
|||
|
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'scanQRCode']
|
|||
|
});
|
|||
|
} else {
|
|||
|
uni.showToast({
|
|||
|
title: res.msg ? res.msg : '获取微信配置失败',
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
}
|
|||
|
})
|
|||
|
.catch(err => {
|
|||
|
uni.showToast({
|
|||
|
title: err,
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
});
|
|||
|
},
|
|||
|
|
|||
|
/** 点击扫码按钮的方法 */
|
|||
|
scanCode1() {
|
|||
|
console.log("你点击了按钮")
|
|||
|
// 允许从相机和相册扫码
|
|||
|
let _this = this;
|
|||
|
jweixin.scanQRCode({
|
|||
|
desc: 'scanQRCode desc',
|
|||
|
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
|
|||
|
scanType: ['qrCode'], // 可以指定扫二维码还是条形码(一维码),默认二者都有"qrCode", "barCode"
|
|||
|
success: function(res) {
|
|||
|
if (res.errMsg != 'scanQRCode:ok') {
|
|||
|
uni.showToast({
|
|||
|
title: '扫描结果:' + res.resultStr,
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
} else {
|
|||
|
//扫码正确
|
|||
|
let resultStr = res.resultStr;
|
|||
|
try {
|
|||
|
resultStr = JSON.parse(resultStr);
|
|||
|
if (resultStr.planNo) {
|
|||
|
_this.planNo = resultStr.planNo
|
|||
|
// _this.getQrCodeInfo();
|
|||
|
} else {
|
|||
|
uni.showToast({
|
|||
|
title: '二维码错误,请扫描正确的二维码',
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
}
|
|||
|
} catch (e) {
|
|||
|
uni.showToast({
|
|||
|
title: '二维码错误,请扫描正确的二维码',
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
// 回调
|
|||
|
},
|
|||
|
error: function(res) {
|
|||
|
uni.showToast({
|
|||
|
title: 'error:' + res,
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
if (res.errMsg.indexOf('function_not_exist') > 0) {
|
|||
|
alert('版本过低请升级');
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
},
|
|||
|
|
|||
|
/** 点击扫码按钮的方法 */
|
|||
|
scanCode2() {
|
|||
|
console.log("你点击了按钮")
|
|||
|
// 允许从相机和相册扫码
|
|||
|
let _this = this;
|
|||
|
jweixin.scanQRCode({
|
|||
|
desc: 'scanQRCode desc',
|
|||
|
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
|
|||
|
scanType: ['qrCode'], // 可以指定扫二维码还是条形码(一维码),默认二者都有"qrCode", "barCode"
|
|||
|
success: function(res) {
|
|||
|
if (res.errMsg != 'scanQRCode:ok') {
|
|||
|
uni.showToast({
|
|||
|
title: '扫描结果:' + res.resultStr,
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
} else {
|
|||
|
//扫码正确
|
|||
|
let resultStr = res.resultStr;
|
|||
|
try {
|
|||
|
resultStr = JSON.parse(resultStr);
|
|||
|
if (resultStr.code) {
|
|||
|
_this.processCode = resultStr.code
|
|||
|
// _this.getQrCodeInfo();
|
|||
|
} else {
|
|||
|
uni.showToast({
|
|||
|
title: '二维码错误,请扫描正确的二维码',
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
}
|
|||
|
} catch (e) {
|
|||
|
uni.showToast({
|
|||
|
title: '二维码错误,请扫描正确的二维码',
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
// 回调
|
|||
|
},
|
|||
|
error: function(res) {
|
|||
|
uni.showToast({
|
|||
|
title: 'error:' + res,
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
if (res.errMsg.indexOf('function_not_exist') > 0) {
|
|||
|
alert('版本过低请升级');
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
},
|
|||
|
|
|||
|
//调用接口获取工序计划二维码信息
|
|||
|
getQrCodeInfo() {
|
|||
|
var _this = this
|
|||
|
if(this.planNo =='' || this.processCode =='') {
|
|||
|
uni.showToast({
|
|||
|
title: '请确保工序流转卡和工序都扫码',
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
}
|
|||
|
this.$http
|
|||
|
.request({
|
|||
|
url: '/apis/workingProcedurePlan/childList',
|
|||
|
params: {
|
|||
|
planCode: this.planNo,
|
|||
|
processCode: this.processCode
|
|||
|
},
|
|||
|
method: 'POST'
|
|||
|
})
|
|||
|
.then(res => {
|
|||
|
if (res.data.code == 0) {
|
|||
|
let j = {
|
|||
|
planCount:res.data.data.datas[0].planCount,
|
|||
|
processName:res.data.data.datas[0].processName,
|
|||
|
processCode: res.data.data.datas[0].processCode ,
|
|||
|
isExamine: res.data.data.datas[0].isExamine?res.data.data.datas[0].isExamine:'',
|
|||
|
}
|
|||
|
_this.tableInfo = j
|
|||
|
uni.navigateTo({
|
|||
|
url: 'processReport?+tableInfo ='+_this.tableInfo
|
|||
|
});
|
|||
|
}else{
|
|||
|
uni.showToast({
|
|||
|
title: res.data.msg? res.data.msg:'扫码失败',
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
});
|
|||
|
}
|
|||
|
});
|
|||
|
},
|
|||
|
//调用接口获取工序二维码信息
|
|||
|
// getQrCodeInfo2(code) {
|
|||
|
// this.$http
|
|||
|
// .request({
|
|||
|
// url: '/apis/workingProcedurePlan/childList',
|
|||
|
// params: {
|
|||
|
// processCode: code
|
|||
|
// },
|
|||
|
// method: 'POST'
|
|||
|
// })
|
|||
|
// .then(res => {
|
|||
|
// if (res.data.code == 0) {
|
|||
|
// this.detailHead=res.data.header
|
|||
|
// this.tableList=res.data.body
|
|||
|
// }else{
|
|||
|
// uni.showToast({
|
|||
|
// title: res.data.msg? res.data.msg:'扫码失败',
|
|||
|
// icon: 'none',
|
|||
|
// duration: 2000
|
|||
|
// });
|
|||
|
// }
|
|||
|
// });
|
|||
|
// },
|
|||
|
}
|
|||
|
}
|
|||
|
</script>
|
|||
|
|
|||
|
<style>
|
|||
|
.scan_icon{
|
|||
|
position: absolute;
|
|||
|
right: 20px;
|
|||
|
top: 10px;
|
|||
|
}
|
|||
|
</style>
|