getApp(), require("../../utils/util.js");
var e = require("../../utils/network.js");
Page({
    data: {
        userInfo: [],
        unpaynum0:0,
        unpaynum1: 0,
        unpaynum2: 0,
        unpaynum3: 0,
    },
 my_order: function (ouid, status) {
     var t = this;
     e.POST({
      url: "User/my_order",
      header: "application/x-www-form-urlencoded",
      params: {
       ouid: ouid,
       status: status
      },
      success: function (e) {
       if (status == 0){
        t.setData({
         unpaynum0: e.data.orders.length
        })
       } else if (status == 1){
        t.setData({
         unpaynum1: e.data.orders.length
        })
       } else if (status == 2){
        t.setData({
         unpaynum2: e.data.orders.length
        })
       }else{
        t.setData({
         unpaynum3: e.data.orders.length
        })
       }
      
      }
     });
    },
    payment: function() {
        wx.navigateTo({
            url: "../my/payment/payment"
        });
    },
    delivery: function() {
        wx.navigateTo({
            url: "../my/delivery/delivery"
        });
    },
    shipped: function() {
        wx.navigateTo({
            url: "../my/shipped/shipped"
        });
    },
    completed: function() {
        wx.navigateTo({
            url: "../my/completed/completed"
        });
    },
    gotomyoder: function() {
        wx.navigateTo({
            url: "payment/payment"
        });
    },
    gomyoder: function() {
        wx.navigateTo({
            url: "myoder/myoder"
        });
    },
 gomy_wallet(){
  wx.navigateTo({
   url: "../my_wallet/my_wallet"
  });
 },
    onLoad: function(n) {
        var e = this;
        wx.getStorage({
            key: "userInfo",
            success: function(n) {
                e.setData({
                    userInfo: n.data
                });
            }
        }), 
        wx.getStorage({
            key: "ouid",
            success: function(n) {
             
              e.my_order(n.data,0);
             e.my_order(n.data, 1);
             e.my_order(n.data, 2);
             e.my_order(n.data, 3);
             
             
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
 onShareAppMessage: function (options) {
  let that = this;
  let ouid;
  // 设置菜单中的转发按钮触发转发事件时的转发内容
  var shareObj = {
   title: '嗒咕商场', // 默认是小程序的名称(可以写slogan等)
   path: '/pages/start/start?share_id=' + wx.getStorageSync('ouid'), // 默认是当前页面,必须是以‘/’开头的完整路径
   imgUrl: '',//自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
   success: function (res) {
    // 转发成功之后的回调
    if (res.errMsg == 'shareAppMessage:ok') { }
   },
   fail: function () {
    // 转发失败之后的回调
    if (res.errMsg == 'shareAppMessage:fail cancel') {
     // 用户取消转发
    } else if (res.errMsg == 'shareAppMessage:fail') {
     // 转发失败,其中 detail message 为详细失败信息
    }
   },
   complete: function () {
    // 转发结束之后的回调(转发成不成功都会执行)
   }
  }
  return shareObj;
 },
});