123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- // pages/order/access/access.js
- const app=getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- orders:"",
- network_id:0,
- orde_num:0
-
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(options.q);
- var network_id=options.network_id;
- if(options.q){
- var url=decodeURIComponent(options.q)
- var order_num=app.getQueryVariable(url,"orde_num");
- var network_id=wx.getStorageSync('nid');
- }
- this.setData({
- network_id:network_id,
- orde_num:order_num?order_num:0
- })
-
-
- },
- scan(){
- wx.scanCode({
- onlyFromCamera: true,
- success: (result) => {
- var url=result.result;
- var network_id=this.data.network_id;
- var order_num=app.getQueryVariable(url,"orde_num");
- wx.navigateTo({
- url: '/pages/order/deposit/deposit?network_id='+network_id+"&device_id="+order_num+"&order_num="+order_num+"&is_deposit=1"
- })
- console.log(result)
- },
- fail: (res) => {},
- complete: (res) => {},
- })
- },
- /**
- * 取件
- */
- receive(){
- wx.scanCode({
- onlyFromCamera: true,
- success: (result) => {
- var url=result.result;
- var network_id=this.data.network_id?this.data.network_id:app.getQueryVariable(url,"network_id");
- var order_num=app.getQueryVariable(url,"orde_num");
- wx.navigateTo({
- url: '/pages/order/deposit/deposit?network_id='+network_id+"&order_num="+order_num+"&is_deposit=0",
- })
- console.log(result)
- },
- fail: (res) => {},
- complete: (res) => {},
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- var that=this;
- var token =wx.getStorageSync('token');
- if(!token){
- app.login().then(res => {
- console.log(res)
- that.setData({
- token: res.message.token,
- })
- that.getDeviceinfo(that.data.orde_num);
- })
-
- }else{
- that.getDeviceinfo(that.data.orde_num);
- }
-
-
- },
- /**
- * @name 获取当前网点存取单
- * @param int network_id 网点id
- */
- getDeviceinfo:function(order_num){
- var that=this;
- wx.showLoading({
- title: '加载中...',
- })
- app.api.useApi(app.globalData.baseAppUrl+"api/order/getDeviceinfo",{
- order_num:order_num,
- network_id:this.data.network_id
- }).then((res)=>{
- if(res.code!=200){
- setTimeout(() => {
- that.getDeviceinfo(order_num)
- }, 1000);
- // wx.showToast({
- // title: res.message.msg,
- // icon:"none",
- // success:function(){
- // setTimeout(() => {
- // wx.hideLoading({
- // success: (res) => {},
- // })
- // }, 2000);
- // }
- // })
- }else{
- wx.hideLoading()
- var orders=res.message.data;
- that.setData({
- orders:orders
- })
-
- if(orders.send_count<1 && orders.receive_count <1){
- wx.navigateTo({
- url: "/pages/order/placeOrder/placeOrder?network_id="+orders.network.id
- })
- }
- }
- }).catch((err)=>{
- console.log(err);
- })
- }
- })
|