console data里面的数组为什么会是空呢?
// pages/checkoutlist/checkoutlist.js
const app = getApp();
var net, gross, bianhao = 0;
var packNum, towsName;
var bianhao_list = [];
Page({
/**
* 页面的初始数据
*/
data: {
orderId: 0,
btnuse: true
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
if (options.orderId == app.orderId) {
this.setData({
orderId: options.orderId
})
} else {
this.setData({
orderId: app.orderId
})
}
},
onShow: function() {
this.initTowsData()
},
scanCode: function() {
var that = this
wx.scanCode({
success: function(res) {
net = res.result.substring(20, 23)
console.log("net = ", net)
gross = res.result.substring(17, 20)
console.log("gross = ", gross)
towsName = res.result.substring(3, 7)
console.log("towsName = ", towsName)
packNum = res.result.substring(7, 17)
console.log("packNum = ", packNum)
wx.request({
url: 'https://hn2.api.okayapi.com/?&s=App.Table.CheckCreate&model_name=towsdata&data={"orderId":"' + app.orderId + '","packNum":"' + packNum + '","towsName":"0","gross":"' + gross + '","net":"' + net + '"}&check_field=packNum&app_key=88DE911C912A3CBB6279020C73DFC327',
header: {
'content-type': 'application/json' // 默认值
},
success: function(res) {
console.log(res.data);
if (res.data.data.err_code == 3) {
wx.showToast({
title: '数据已存在',
})
} else {
wx.showToast({
title: '上传成功',
})
}
}
})
that.setData({
net: res.result.substring(20, 23),
})
},
fail: function(res) {
console.log("扫码失败 ")
},
})
},
upLoad: function(e) {
wx.showModal({
title: '提示',
content: '是否全部扫码完成',
success(res) {
if (res.confirm) {
console.log('用户点击确定')
var util = require('../../utils/util.js')
var fache = util.formatTime(new Date());
var state = 1
wx.request({
url: 'https://hn2.api.okayapi.com/?&s=App.Table.CheckCreate&model_name=towsLog&data={"orderId":"' + app.orderId + '","lic":"' + lic + '","fache":"' + fache + '","state":"' + state + '"}&check_field=packNum&app_key=88DE911C912A3CBB6279020C73DFC327',
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
}
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
initTowsData: function () {
var that = this
wx.request({
url: 'https://hn2.api.okayapi.com/?&s=App.Table.FreeQuery&model_name=towsdata&logic=and&where=[["id", ">", "1"]]&page=1&perpage=50&is_real_total=1&app_key=88DE911C912A3CBB6279020C73DFC327',
header: {
'content-type': 'application/json' // 默认值
},
success: function(res) {
that.setData({
listData: res.data.data.list
});
}
})
wx.request({
url: 'https://hn2.api.okayapi.com/?&s=App.Table.FreeQuery&model_name=towsClass&logic=and&where=[["id", ">", "0"]]&page=1&perpage=50&is_real_total=1&app_key=88DE911C912A3CBB6279020C73DFC327',
header: {
'content-type': 'application/json' // 默认值
},
success: function(res) {
that.setData({
towsClass: res.data.data.list
})
}
})
console.log(that.data)
console.log(that.data.listData)
}
})