|
@@ -1,5 +1,6 @@
|
|
// pages/workbench/workbench.js
|
|
// pages/workbench/workbench.js
|
|
import { writeOffOrder, confirmOrder } from '../../api/workbench'
|
|
import { writeOffOrder, confirmOrder } from '../../api/workbench'
|
|
|
|
+import { bindCar } from '../../api/permission'
|
|
const app = getApp()
|
|
const app = getApp()
|
|
Page({
|
|
Page({
|
|
|
|
|
|
@@ -9,7 +10,7 @@ Page({
|
|
data: {
|
|
data: {
|
|
scanFlag: true,
|
|
scanFlag: true,
|
|
overlayShow: false,
|
|
overlayShow: false,
|
|
- deviceName: '',
|
|
|
|
|
|
+ deviceName: 'XX',
|
|
userName: '',
|
|
userName: '',
|
|
headImg: '',
|
|
headImg: '',
|
|
workerId: '',
|
|
workerId: '',
|
|
@@ -17,7 +18,9 @@ Page({
|
|
personSex: true,
|
|
personSex: true,
|
|
birthday: '',
|
|
birthday: '',
|
|
orderId: '',
|
|
orderId: '',
|
|
- orderNo: ''
|
|
|
|
|
|
+ orderNo: '',
|
|
|
|
+ age: '',
|
|
|
|
+ useNum: ''
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
@@ -34,13 +37,109 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
|
+ */
|
|
|
|
+ onShow() {
|
|
|
|
+ if (!app.globalData.accessToken) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ content: '请先登录',
|
|
|
|
+ confirmColor: '#333',
|
|
|
|
+ showCancel: false,
|
|
|
|
+ success (scanres) {
|
|
|
|
+ if (scanres.confirm) {
|
|
|
|
+ wx.redirectTo({
|
|
|
|
+ url: '/pages/login/login'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 拉起微信扫一扫,扫描用户档案二维码
|
|
|
|
+ handleWxScanUser () {
|
|
|
|
+ var that = this
|
|
|
|
+ wx.scanCode({
|
|
|
|
+ onlyFromCamera: true,
|
|
|
|
+ success (scanRes) {
|
|
|
|
+ that.handleScanUser(scanRes.result)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 处理扫描用户二维码
|
|
|
|
+ handleScanUser (response) {
|
|
|
|
+ var scodeType = response.split('|')[0] == 'DOCUMENT' ? true : false
|
|
|
|
+ if (!scodeType) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ content: '请扫描正确的二维码',
|
|
|
|
+ confirmColor: '#333',
|
|
|
|
+ showCancel: false
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ // DOCUMENT|documentId|uuid
|
|
|
|
+ var successScanTimer = setTimeout(() => {
|
|
|
|
+ var documentId = response.split('|')[1]
|
|
|
|
+ var uuid = response.split('|')[2]
|
|
|
|
+ this.writeOffOrderFn(documentId, uuid)
|
|
|
|
+ clearTimeout(successScanTimer)
|
|
|
|
+ }, 500);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 核销用户检测次数
|
|
|
|
+ writeOffOrderFn (documentId = '', uuid = '') {
|
|
|
|
+ var that = this
|
|
|
|
+ var data = {
|
|
|
|
+ documentId: documentId,
|
|
|
|
+ uuid: uuid
|
|
|
|
+ }
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: '加载中...',
|
|
|
|
+ })
|
|
|
|
+ writeOffOrder(data).then(res => {
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ const response = res.data
|
|
|
|
+ if (response.useNum == 0) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ content: '该用户检测次数为0,提示充值',
|
|
|
|
+ confirmColor: '#333',
|
|
|
|
+ showCancel: false
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ that.setData({
|
|
|
|
+ orderNo: response.orderNo,
|
|
|
|
+ orderId: response.orderId,
|
|
|
|
+ personName: response.personName,
|
|
|
|
+ personSex: response.personSex,
|
|
|
|
+ birthday: response.birthday,
|
|
|
|
+ age: response.age,
|
|
|
|
+ useNum: response.useNum,
|
|
|
|
+ overlayShow: true
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }).catch(e => {
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ wx.showModal({
|
|
|
|
+ content: e.msg,
|
|
|
|
+ confirmColor: '#333',
|
|
|
|
+ showCancel: false
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 取消用户扫描结果
|
|
handlecancel() {
|
|
handlecancel() {
|
|
this.setData({
|
|
this.setData({
|
|
overlayShow: false
|
|
overlayShow: false
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // 提交用户扫描结果
|
|
handlesubmit() {
|
|
handlesubmit() {
|
|
|
|
+ var that =this
|
|
var data = {
|
|
var data = {
|
|
orderId: this.data.orderId
|
|
orderId: this.data.orderId
|
|
}
|
|
}
|
|
@@ -54,6 +153,9 @@ Page({
|
|
title: res.msg,
|
|
title: res.msg,
|
|
icon: 'success'
|
|
icon: 'success'
|
|
})
|
|
})
|
|
|
|
+ that.setData({
|
|
|
|
+ overlayShow: false
|
|
|
|
+ })
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
wx.hideLoading()
|
|
wx.hideLoading()
|
|
wx.showModal({
|
|
wx.showModal({
|
|
@@ -64,116 +166,74 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- /**
|
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
|
- */
|
|
|
|
- onShow() {
|
|
|
|
- if (!app.globalData.accessToken) {
|
|
|
|
- wx.showModal({
|
|
|
|
- content: '请先登录',
|
|
|
|
- confirmColor: '#333',
|
|
|
|
- showCancel: false,
|
|
|
|
- success (scanres) {
|
|
|
|
- if (scanres.confirm) {
|
|
|
|
- wx.redirectTo({
|
|
|
|
- url: '/pages/login/login'
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ // 拉起微信扫一扫,扫车辆 获取新车权限
|
|
|
|
+ handleWXScanDevice () {
|
|
|
|
+ var that = this
|
|
|
|
+ wx.scanCode({
|
|
|
|
+ onlyFromCamera: true,
|
|
|
|
+ success (scanRes) {
|
|
|
|
+ that.handleScanDevice(scanRes.result)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
- bindscancode (e) {
|
|
|
|
|
|
+ // 处理扫描的设备二维码
|
|
|
|
+ handleScanDevice (response) {
|
|
var that = this
|
|
var that = this
|
|
- if (that.data.scanFlag) {
|
|
|
|
- var response = e.detail.result
|
|
|
|
- console.log(response, 'response');
|
|
|
|
- var scodeType = response.split('|')[0] == 'DOCUMENT' ? true : false
|
|
|
|
- if (!scodeType) {
|
|
|
|
- that.setData({
|
|
|
|
- scanFlag: false
|
|
|
|
- })
|
|
|
|
- wx.showModal({
|
|
|
|
- content: '请扫描正确的二维码',
|
|
|
|
- confirmColor: '#333',
|
|
|
|
- showCancel: false,
|
|
|
|
- success (scanres) {
|
|
|
|
- if (scanres.confirm) {
|
|
|
|
- that.setData({
|
|
|
|
- scanFlag: true
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- // DOCUMENT|documentId|uuid
|
|
|
|
- var documentId = response.split('|')[1]
|
|
|
|
- var uuid = response.split('|')[2]
|
|
|
|
- that.writeOffOrderFn(documentId, uuid)
|
|
|
|
- }
|
|
|
|
|
|
+ var scodeType = response.split('|')[0] == 'DEVICE' ? true : false
|
|
|
|
+ if (!scodeType) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ content: '请扫描正确的设备二维码',
|
|
|
|
+ confirmColor: '#333',
|
|
|
|
+ showCancel: false
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ // DEVICE|deviceCode|nonceCode|timeStamp
|
|
|
|
+ var deviceTimer = setTimeout(() => {
|
|
|
|
+ var deviceCode = response.split('|')[1]
|
|
|
|
+ var nonceCode = response.split('|')[2]
|
|
|
|
+ var timeStamp = response.split('|')[3]
|
|
|
|
+ that.bindCarFn(deviceCode, nonceCode, timeStamp)
|
|
|
|
+ clearTimeout(deviceTimer)
|
|
|
|
+ }, 500);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- writeOffOrderFn (documentId = '', uuid = '') {
|
|
|
|
|
|
+ // 绑定设备
|
|
|
|
+ bindCarFn (deviceCode = '', nonceCode = '', timeStamp = '') {
|
|
var that = this
|
|
var that = this
|
|
var data = {
|
|
var data = {
|
|
- documentId: documentId,
|
|
|
|
- uuid: uuid
|
|
|
|
|
|
+ deviceCode: deviceCode,
|
|
|
|
+ nonceCode: nonceCode,
|
|
|
|
+ timeStamp: timeStamp
|
|
}
|
|
}
|
|
wx.showLoading({
|
|
wx.showLoading({
|
|
- title: '加载中...',
|
|
|
|
|
|
+ title: '绑定中...',
|
|
mask: true
|
|
mask: true
|
|
})
|
|
})
|
|
- writeOffOrder(data).then(res => {
|
|
|
|
- console.log(res, 'writeOffOrder');
|
|
|
|
- that.setData({
|
|
|
|
- scanFlag: true,
|
|
|
|
- orderNo: res.data.orderNo,
|
|
|
|
- orderId: res.data.orderId,
|
|
|
|
- personName: res.data.personName,
|
|
|
|
- personSex: res.data.personSex,
|
|
|
|
- birthday: res.data.birthday,
|
|
|
|
- overlayShow: true
|
|
|
|
- })
|
|
|
|
- }).catch(e => {
|
|
|
|
- that.setData({
|
|
|
|
- scanFlag: false
|
|
|
|
- })
|
|
|
|
|
|
+ bindCar(data).then(scanres => {
|
|
|
|
+ // 绑定成功到扫描档案页面
|
|
wx.hideLoading()
|
|
wx.hideLoading()
|
|
wx.showModal({
|
|
wx.showModal({
|
|
- content: e.msg,
|
|
|
|
|
|
+ content: '权限登录成功',
|
|
confirmColor: '#333',
|
|
confirmColor: '#333',
|
|
showCancel: false,
|
|
showCancel: false,
|
|
- confirmText: '重新扫描',
|
|
|
|
- success (res) {
|
|
|
|
- if (res.confirm) {
|
|
|
|
- var timer = setTimeout(() => {
|
|
|
|
- that.setData({
|
|
|
|
- scanFlag: true
|
|
|
|
- })
|
|
|
|
- clearTimeout(timer)
|
|
|
|
- }, 400);
|
|
|
|
|
|
+ success (pres) {
|
|
|
|
+ if (pres.confirm) {
|
|
|
|
+ that.setData({
|
|
|
|
+ deviceName: scanres.data.deviceName
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+ }).catch(e => {
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ wx.showModal({
|
|
|
|
+ content: e.msg,
|
|
|
|
+ confirmColor: '#333',
|
|
|
|
+ showCancel: false
|
|
|
|
+ })
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- bindscanerror () {
|
|
|
|
- wx.showModal({
|
|
|
|
- content: '请打开相机权限',
|
|
|
|
- confirmColor: '#333',
|
|
|
|
- showCancel: false,
|
|
|
|
- success (auth) {
|
|
|
|
- if (auth.confirm) {
|
|
|
|
- wx.openSetting({
|
|
|
|
- success (res) {
|
|
|
|
- console.log(res.authSetting)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
})
|
|
})
|