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"),
        t = wx.getStorageSync("cardatawx");
      this.setData({ orderInfo: e, cardatawx: t }), this.getmoney();
    },
    getmoney: function () {
      var a = this,
        t = { type: "weibaoa_money", uid: wx.getStorageSync("uid") };
      e.getdata(t, "getcarmoney").then((t) => {
        console.log("money", t.data),
          t.data &&
            e
              .getdata({ car: a.data.orderInfo.brand }, "wxjlcxmoney")
              .then((e) => {
                console.log("数据库价格", e.data),
                  a.setData({ fee: Number(t.data) + Number(e.data.money) });
              });
      });
    },
    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: {
                m: "monai_market",
                type: "weibaoa_money",
                fee: a.data.fee,
                car: a.data.orderInfo.brand,
                orderid: a.data.orderid,
                vin: a.data.cardatawx.vin,
                chepai: a.data.cardatawx.chepai,
                engine: a.data.cardatawx.engine,
                cpimg: a.data.cardatawx.imageUrl,
                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: {
                        m: "monai_market",
                        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.errno &&
                    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: {
                            m: "monai_market",
                            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,
          chepai: a.data.cardatawx.chepai,
          engine: a.data.cardatawx.engine,
          xszimg: a.data.cardatawx.imageUrl,
          money: a.data.fee,
        };
      e.getdata(t, "wxjlcxjzb").then((e) => {
        console.log("回调数据：", e.data),
          wx.showModal({
            title: "查询成功",
            content:
              "在早上8-下午8点查询结果将在10-30分钟查到，其他时间需要到次日早上统一出结果，不成功自动退款~",
            showCancel: !1,
            success: function (a) {
              a.confirm &&
                wx.reLaunch({ url: "/pages/reporlist/reporlist?type=0" });
            },
          }),
          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 () {},
  });
