var a, t;
(a = getApp()),
  (t = getApp()),
  Page({
    data: { orderInfo: null, phone: a.getSystemPlatform() },
    onLoad: function (a) {
      var e = wx.getStorageSync("orderInfo"),
        t = wx.getStorageSync("cardatawx");
      this.setData({ orderInfo: e, cardatawx: t }), this.getmoney();
    },
    getmoney: function () {
      var e = this,
        t = { type: "dcbg_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 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",
              method: "post",
              dataType: "json",
              data: {

                type: "dcbg_money",
                orderid: a.data.orderid,
                vin: a.data.cardatawx.vin,
                chepai: a.data.cardatawx.chepai,
                engine: a.data.cardatawx.engine,
                cpimg: a.data.cardatawx.imageUrl,
                uid: wx.getStorageSync("uid"),
                postcardata: JSON.stringify(a.data),
              },
              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 () {
      wx.showModal({
        title: "查询成功",
        content: "结果将在5-10分钟通知你，不成功自动退款~",
        showCancel: !1,
        success: function (a) {
          a.confirm &&
            wx.reLaunch({ url: "/pages/reporlist/reporlist?type=23" });
        },
      });
    },
    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 (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 () {},
  });
