// packageD/quickPay/member_add_bank_first/member_add_bank_first.js
let app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    name: "",
    num: "",
    bank: [],
    info: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.initData();
    this.getInfo();
    this.getBank();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  numInp(e) {
    let val = e.detail.value;
    this.setData({
      num: val,
    });
  },
  initData() {
    this.setData({
      name: "",
      num: "",
      bank: [],
      info: {},
    });
  },
  getBank() {
    let that = this;
    let urlStr = app.getNetAddresss(
      "plugin.converge_pay.frontend.controllers.quick-pay-bank-card.index"
    );
    app._getNetWork({
      url: urlStr,
      showToastIn: false,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          that.setData({
            bank: res.data,
          });
        } else {
          that.setData({
            bank: res.data,
          });
        }
      },
      fail: function (res) {
        console.log(res.msg);
      },
    });
  },
  next() {
    if (app._isTextEmpty(this.data.num)) {
      wx.showToast({
        icon: "none",
        title: "请输入卡号",
        duration: 1500,
      });

      return;
    }
    wx.navigateTo({
      url:
        "/packageD/quickPay/member_add_bank_second/member_add_bank_second?card_no=" +
        this.data.num,
    });
  },
  getInfo() {
    let that = this;
    let urlStr = app.getNetAddresss(
      "plugin.converge_pay.frontend.controllers.quick-pay-bank-card.get-payer-info"
    );
    app._getNetWork({
      url: urlStr,
      showToastIn: false,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          that.setData({
            info: res.data,
          });
        }
      },
      fail: function (res) {
        console.log(res.msg);
      },
    });
  },
});
