var a, e, t;
(a = (function (a) {
  return a && a.__esModule ? a : { default: a };
})(require("../../utils/apis.js"))),
  (e = getApp()),
  (t = getApp()),
  Page({
    data: { orderInfo: null, phone: e.getSystemPlatform() },
    onLoad: function (a) {
      var e = wx.getStorageSync("orderInfo");
      this.setData({ orderInfo: e }), this.getmoney();
    },
    getmoney: function () {
      var a = this,
        t = { type: "weibao_money", uid: wx.getStorageSync("uid") };
      e.getdata(t, "getcarmoney").then((e) => {
        console.log("money", e.data), e.data && a.setData({ fee: e.data });
      });
    },
    orderid: function () {
      let a = "";
      for (var e = 0; e < 8; e++) a += Math.floor(10 * Math.random());
      (a = "D" + new Date().getTime() + a), this.setData({ orderid: a });
    },
    queryVin: function () {
      var a = this;
      a.orderid(),
        console.log(wx.getStorageSync("uid")),
        wx.getStorageSync("uid")
          ? (console.log(wx.getStorageSync("uid")),
            t.util.request({
              url: "entry/wxapp/paynum",
              data: {

                type: "weibao_money",
                orderid: a.data.orderid,
                uid: wx.getStorageSync("uid"),
              },
              success: function (e) {
                e.data && e.data.data && 1e3 == e.data.message
                  ? t.util.request({
                      url: "entry/wxapp/Api",
                      data: {

                        uid: wx.getStorageSync("uid"),
                        r: "home.weizhang.paynum",
                        orderid: e.data.data.orderid,
                      },
                      success: function (e) {
                        wx.showModal({ content: e.data.message }),
                          a.setData({
                            weizhang_num: 1 * a.data.weizhang_num + 10,
                          }),
                          a.getDetail();
                      },
                    })
                  : e.data &&
                    e.data.data &&
                    e.data.code!=200 &&
                    wx.requestPayment({
                      timeStamp: e.data.data.timeStamp,
                      nonceStr: e.data.data.nonceStr,
                      package: e.data.data.package,
                      signType: "MD5",
                      paySign: e.data.data.paySign,
                      success: function (n) {
                        t.util.request({
                          url: "entry/wxapp/Api",
                          data: {

                            uid: wx.getStorageSync("uid"),
                            r: "home.weizhang.paynum",
                            orderid: e.data.data.orderid,
                          },
                          success: function (e) {
                            a.setData({
                              weizhang_num: 1 * a.data.weizhang_num + 10,
                            }),
                              wx.showModal({ content: e.data.message }),
                              a.getDetail();
                          },
                        });
                      },
                    });
              },
            }))
          : wx.showModal({
              title: "温馨提醒",
              content: "使用本功能请先登录后在使用~",
              showCancel: !1,
              success: function (a) {
                a.confirm && wx.reLaunch({ url: "/pages/mine/index" });
              },
            });
    },
    getDetail: function () {
      var a = this,
        t = {
          uid: wx.getStorageSync("uid"),
          frameno: a.data.orderInfo.vin,
          logo: a.data.orderInfo.logo,
          car: a.data.orderInfo.brand,
          cars: a.data.orderInfo.typeName,
          orderid: a.data.orderid,
        };
      e.getdata(t, "wxjlcx").then((e) => {
        console.log("回调数据：", e.data),
          wx.showModal({
            title: "查询成功",
            content: "结果将在5-10分钟通知你，不成功自动退款~",
            showCancel: !1,
            success: function (a) {
              a.confirm && wx.reLaunch({ url: "/pages/reporlist/reporlist" });
            },
          }),
          e.data && a.setData({ order: e.data });
      });
    },
    queryVinb: function () {
      var e = this.data.orderInfo.seriousNo,
        t = this.data.orderInfo.queryType,
        n = this.data.orderInfo.name;
      console.log("queryType:" + t),
        a.default
          .wxPay({
            seriousNo: e,
            openId: wx.getStorageSync("openId"),
            money: this.data.orderInfo.money,
          })
          .then(function (a) {
            wx.requestPayment({
              timeStamp: a.data.timeStamp,
              nonceStr: a.data.nonceStr,
              package: a.data.package,
              signType: a.data.signType,
              paySign: a.data.sign,
              success: function (a) {
                wx.navigateTo({
                  url:
                    "/pages/successPage/successPage?seriousNo=" +
                    e +
                    "&queryType=" +
                    t +
                    "&name=" +
                    n,
                });
              },
              fail: function (a) {
                console.log(a);
              },
            });
          });
    },
    toDisclaimers: function () {
      wx.navigateTo({ url: "/pages/disclaimers/disclaimers" });
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    onShareAppMessage: function () {},
  });
