console data里面的数组为什么会是空呢?
发布于 7 年前 作者 houyan 4839 次浏览 来自 官方Issues
// pages/checkoutlist/checkoutlist.js
const app = getApp();
var net, gross, bianhao = 0;
var packNum, towsName;
var bianhao_list = [];

Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderId0,
    btnusetrue
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoadfunction(options{
    
    if (options.orderId == app.orderId) {
      this.setData({
        orderId: options.orderId
      })
    } else {
      this.setData({
        orderId: app.orderId
      })
    }
  },

  onShowfunction() {
    this.initTowsData()
  },

  scanCodefunction() {
    var that = this
    wx.scanCode({
      successfunction(res{
        net = res.result.substring(2023)
        console.log("net = ", net)
        gross = res.result.substring(1720)
        console.log("gross = ", gross)
        towsName = res.result.substring(37)
        console.log("towsName = ", towsName)
        packNum = res.result.substring(717)
        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' // 默认值
          },
          successfunction(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(2023),

        })

      },
      failfunction(res{
        console.log("扫码失败 ")
      },

    })
  },
  upLoadfunction(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' // 默认值
            },
            successfunction (res{
            }
          })

        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  initTowsDatafunction () {
    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' // 默认值
      },
      successfunction(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' // 默认值
      },
      successfunction(res{
        that.setData({
          towsClass: res.data.data.list
        })
      }
    })
    console.log(that.data)
    console.log(that.data.listData)
  }

})

1 回复

猜是异步的问题,数据还没有获取到。

回到顶部