|
@@ -1,4 +1,6 @@
|
|
// pages/workbench/workbench.js
|
|
// pages/workbench/workbench.js
|
|
|
|
+import { writeOffOrder, confirmOrder } from '../../api/workbench'
|
|
|
|
+const app = getApp()
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -6,25 +8,30 @@ Page({
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
scanFlag: true,
|
|
scanFlag: true,
|
|
- overlayShow: false
|
|
|
|
|
|
+ overlayShow: false,
|
|
|
|
+ deviceName: '',
|
|
|
|
+ userName: '',
|
|
|
|
+ headImg: '',
|
|
|
|
+ workerId: '',
|
|
|
|
+ personName: '',
|
|
|
|
+ personSex: true,
|
|
|
|
+ birthday: '',
|
|
|
|
+ orderId: '',
|
|
|
|
+ orderNo: ''
|
|
},
|
|
},
|
|
|
|
|
|
- bindscancode (e) {
|
|
|
|
- var that = this
|
|
|
|
- if (that.data.scanFlag) {
|
|
|
|
- var response = e.detail.result
|
|
|
|
- console.log(response, 'response');
|
|
|
|
- that.setData({
|
|
|
|
- scanFlag: false
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * 生命周期函数--监听页面加载
|
|
|
|
- */
|
|
|
|
- onLoad(options) {
|
|
|
|
|
|
+ onLoad (options) {
|
|
|
|
+ this.getInitData(options)
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+ getInitData (data) {
|
|
|
|
+ this.setData({
|
|
|
|
+ deviceName: data.deviceName ? data.deviceName : '',
|
|
|
|
+ userName: app.globalData.userName,
|
|
|
|
+ headImg: app.globalData.headImg,
|
|
|
|
+ workerId: app.globalData.workerId
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
handlecancel() {
|
|
handlecancel() {
|
|
@@ -34,45 +41,138 @@ Page({
|
|
},
|
|
},
|
|
|
|
|
|
handlesubmit() {
|
|
handlesubmit() {
|
|
- /* wx.showLoading({
|
|
|
|
|
|
+ var data = {
|
|
|
|
+ orderId: this.data.orderId
|
|
|
|
+ }
|
|
|
|
+ wx.showLoading({
|
|
title: '加载中...',
|
|
title: '加载中...',
|
|
mask: true
|
|
mask: true
|
|
- }) */
|
|
|
|
|
|
+ })
|
|
|
|
+ confirmOrder(data).then(res => {
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: res.msg,
|
|
|
|
+ icon: 'success'
|
|
|
|
+ })
|
|
|
|
+ }).catch(e => {
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ wx.showModal({
|
|
|
|
+ content: e.msg,
|
|
|
|
+ confirmColor: '#333',
|
|
|
|
+ showCancel: false
|
|
|
|
+ })
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
*/
|
|
onShow() {
|
|
onShow() {
|
|
-
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 生命周期函数--监听页面卸载
|
|
|
|
- */
|
|
|
|
- onUnload() {
|
|
|
|
-
|
|
|
|
|
|
+ if (!app.globalData.accessToken) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ content: '请先登录',
|
|
|
|
+ confirmColor: '#333',
|
|
|
|
+ showCancel: false,
|
|
|
|
+ success (scanres) {
|
|
|
|
+ if (scanres.confirm) {
|
|
|
|
+ wx.redirectTo({
|
|
|
|
+ url: '/pages/login/login'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
- /**
|
|
|
|
- * 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
- */
|
|
|
|
- onPullDownRefresh() {
|
|
|
|
-
|
|
|
|
|
|
+ bindscancode (e) {
|
|
|
|
+ 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)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
- /**
|
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
|
- */
|
|
|
|
- onReachBottom() {
|
|
|
|
-
|
|
|
|
|
|
+ writeOffOrderFn (documentId = '', uuid = '') {
|
|
|
|
+ var that = this
|
|
|
|
+ var data = {
|
|
|
|
+ documentId: documentId,
|
|
|
|
+ uuid: uuid
|
|
|
|
+ }
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: '加载中...',
|
|
|
|
+ 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
|
|
|
|
+ })
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ wx.showModal({
|
|
|
|
+ content: e.msg,
|
|
|
|
+ confirmColor: '#333',
|
|
|
|
+ showCancel: false,
|
|
|
|
+ confirmText: '重新扫描',
|
|
|
|
+ success (res) {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ that.setData({
|
|
|
|
+ scanFlag: true
|
|
|
|
+ })
|
|
|
|
+ }, 400);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
- /**
|
|
|
|
- * 用户点击右上角分享
|
|
|
|
- */
|
|
|
|
- onShareAppMessage() {
|
|
|
|
-
|
|
|
|
|
|
+ bindscanerror () {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ content: '请打开相机权限',
|
|
|
|
+ confirmColor: '#333',
|
|
|
|
+ showCancel: false,
|
|
|
|
+ success (auth) {
|
|
|
|
+ if (auth.confirm) {
|
|
|
|
+ wx.openSetting({
|
|
|
|
+ success (res) {
|
|
|
|
+ console.log(res.authSetting)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
})
|
|
})
|