页面加支付密码

2022-04-11 18:22:34 阅读:2 编辑
@import '/zhy/resource/css/coinpaypassword.wxss';
 <block>
        <include src="/pages/com/coinpaypassword.wxml"></include>
  </block>
{
  "usingComponents": {
    "van-popup": "/zhy/vant/popup/index"
  }
}
{
    pay_password_callback: null,
    isnosubmit: true,
    is_paypassword_open:0,
    }
let config = wx.getStorageSync('setting').config;
    this.setData({
      is_paypassword_open:config.is_paypassword_open
    });
onBuyMoneyTab(e) {
    console.log("onBuyMoneyTab");
    let _this = this;
    let psLength = _this.data.psLength;
    let showoverlay = _this.data.showoverlay;
    let coinpassword = _this.data.coinpassword;
    if (!showoverlay) {
      _this.setData({
        showoverlay: true,
      })
      return;
    }
    if (coinpassword.length != psLength) {
      _this.setData({
        coinpasserror: true,
      })
      return;
    } else {
      let param = {
        user_id: this.data.user.id,
        coinpassword: coinpassword
      }
      app.api.apiUserCheckotherpaypassword(param).then(res => {
        this.setData({
          showoverlay: false,
          isnosubmit: true,
        })
        if (this.data.pay_password_callback) {
          this.data.pay_password_callback();
        }
      }).catch(res => {
        if (res.code == 3001) {
          _this.setData({
            coinpasserror: true,
            coinpasserrortext: res.msg
          })
          return;
        } else { // 执行失败回调操作
          app.tips(res);
        }
      })

    }

  },
  handlePayPassword(cb) {
    if(this.data.is_paypassword_open == 1){
      let _this = this;
      _this.setData({
        showoverlay: true,
      });
      this.setData({
        pay_password_callback: cb,
      });
    }else{
      cb && cb();
    }
  },
this.handlePayPassword(() => {

});
 onShow(){
    this.checkLogin((user) => {
      this.setData({
        user,
        user_id: user.id
      })
    }, '/base/carorder/carorder', true)
  },
注意事项:

1.checkLogin最后一个参数为true