var e, a, t;
(e = (function (e) {
  return e && e.__esModule ? e : { default: e };
})(require("../../utils/apis.js"))),
  (a = getApp()),
  (t = getApp()),
  Page({
    data: { orderInfo: null, phone: a.getSystemPlatform() },
    onLoad: function (e) {
      var a = wx.getStorageSync("orderInfo");
      this.setData({ orderInfo: a }), this.getmoney();
    },
    getmoney: function () {
      var e = this,
        t = { type: "wz_money", uid: wx.getStorageSync("uid") };
      a.getdata(t, "getcarmoney").then((a) => {
        console.log("money", a.data), a.data && e.setData({ fee: a.data });
      });
    },
    orderid: function () {
      let e = "";
      for (var a = 0; a < 8; a++) e += Math.floor(10 * Math.random());
      (e = "D" + new Date().getTime() + e), this.setData({ orderid: e });
    },
    queryVin: function () {
      var e = this;
      e.orderid(),
        console.log(wx.getStorageSync("uid")),
        wx.getStorageSync("uid")
          ? (console.log(wx.getStorageSync("uid")),
            t.util.request({
              url: "entry/wxapp/paynum",
              data: {
                m: "monai_market",
                type: "wz_money",
                orderid: e.data.orderid,
                uid: wx.getStorageSync("uid"),
              },
              success: function (a) {
                a.data && a.data.data && 1e3 == a.data.message
                  ? t.util.request({
                      url: "entry/wxapp/Api",
                      data: {
                        m: "monai_market",
                        uid: wx.getStorageSync("uid"),
                        r: "home.weizhang.paynum",
                        orderid: a.data.data.orderid,
                      },
                      success: function (a) {
                        wx.showModal({ content: a.data.message }),
                          e.setData({
                            weizhang_num: 1 * e.data.weizhang_num + 10,
                          }),
                          e.getDetail();
                      },
                    })
                  : a.data &&
                    a.data.data &&
                    a.data.code!=200 &&
                    wx.requestPayment({
                      timeStamp: a.data.data.timeStamp,
                      nonceStr: a.data.data.nonceStr,
                      package: a.data.data.package,
                      signType: "MD5",
                      paySign: a.data.data.paySign,
                      success: function (n) {
                        t.util.request({
                          url: "entry/wxapp/Api",
                          data: {
                            m: "monai_market",
                            uid: wx.getStorageSync("uid"),
                            r: "home.weizhang.paynum",
                            orderid: a.data.data.orderid,
                          },
                          success: function (a) {
                            e.setData({
                              weizhang_num: 1 * e.data.weizhang_num + 10,
                            }),
                              wx.showModal({ content: a.data.message }),
                              e.getDetail();
                          },
                        });
                      },
                    });
              },
            }))
          : wx.showModal({
              title: "温馨提醒",
              content: "使用本功能请先登录后在使用~",
              showCancel: !1,
              success: function (e) {
                e.confirm && wx.reLaunch({ url: "/pages/mine/index" });
              },
            });
    },
    getDetail: function () {
      var e = this,
        t = wx.getStorageSync("carquery"),
        n = {
          uid: wx.getStorageSync("uid"),
          vin: e.data.orderInfo.vin,
          logo: e.data.orderInfo.logo,
          car: e.data.orderInfo.brand,
          cars: e.data.orderInfo.typeName,
          orderid: e.data.orderid,
          engine: t.engine,
          province_small: t.province_small,
          license_plate_code: t.license_plate_code,
          license_plate: t.license_plate,
          license_plate_type: t.license_plate_type,
        };
      a.getdata(n, "carwzcx").then((a) => {
        console.log("回调数据:", a.data),
          wx.navigateTo({
            url: "/packageA/pages/carwzcx/carcxjl?orderid=" + e.data.orderid,
          }),
          (a = a.data).data && e.setData({ order: a.data.result });
      });
    },
    queryVinb: function () {
      var a = this.data.orderInfo.seriousNo,
        t = this.data.orderInfo.queryType,
        n = this.data.orderInfo.name;
      console.log("queryType:" + t),
        e.default
          .wxPay({
            seriousNo: a,
            openId: wx.getStorageSync("openId"),
            money: this.data.orderInfo.money,
          })
          .then(function (e) {
            wx.requestPayment({
              timeStamp: e.data.timeStamp,
              nonceStr: e.data.nonceStr,
              package: e.data.package,
              signType: e.data.signType,
              paySign: e.data.sign,
              success: function (e) {
                wx.navigateTo({
                  url:
                    "/pages/successPage/successPage?seriousNo=" +
                    a +
                    "&queryType=" +
                    t +
                    "&name=" +
                    n,
                });
              },
              fail: function (e) {
                console.log(e);
              },
            });
          });
    },
    toDisclaimers: function () {
      wx.navigateTo({ url: "/pages/disclaimers/disclaimers" });
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    onShareAppMessage: function () {},
  });