| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 | 
const Parse = getApp().Parse;const company = getApp().globalData.companyPage({  /**   * 页面的初始数据   */  data: {    show: false,    cardList:[],    name:'',    cardId:'',    bankName:'',    objectId:'',    activeColor: getApp().globalData.activeColor,    titleColor: getApp().globalData.titleColor  },  onClickShow() {    this.setData({ show: true });  },  onClickHide() {    this.setData({ show: false });  },  delete(e){    let cardList = this.data.cardList    cardList.splice(e.currentTarget.dataset.index,1)        let Account = Parse.Object.extend("Account")    let account = new Account()    account.id = this.data.objectId    if((cardList && cardList.length == 0) || !cardList) {      account.set("bank",null)    }else {      account.set("bank",cardList)    }    account.save().then(res=>{      wx.showToast({        title: '删除银行卡成功',        icon: 'succee',        duration: 2000      })      this.getCardList()    })  },  submit(){    const _this = this    let reg = /[\u4e00-\u9fa5]/    let name = this.data.name    let bankName = this.data.bankName    let cardId = this.data.cardId    if(!this.data.name || !this.data.cardId || !this.data.bankName){      wx.showToast({        title: '请填写完整信息',        icon: 'none',        duration: 2000      })      return    }    if(!reg.test(name)){      wx.showToast({        title: '请输入您的真实姓名',        icon: 'none',        duration: 2000      })      return    }       let regExp = /^([1-9]{1})(\d{15}|\d{16}|\d{18})$/;    if(!regExp.test(cardId)){      wx.showToast({        title: '请输入正确的银行卡号',        icon: 'none',        duration: 2000      })      return    }    if(!reg.test(bankName)){      wx.showToast({        title: '请输入正确的开卡行',        icon: 'none',        duration: 2000      })      return    }    let Account = Parse.Object.extend("Account")    let account = new Account()    account.id = this.data.objectId    account.addUnique("bank",{      name,      cardId,      bankName    })    account.save().then(res=>{      console.log(res)      wx.showToast({        title: '添加银行卡成功',        icon: 'succee',        duration: 2000      })      this.onClickHide()      this.getCardList()      this.setData({        name:null,        cardId: null,        bankName:null      })    })  },  getCardList(){    let Account = new Parse.Query("Account")    Account.equalTo("user",Parse.User.current().id)    Account.equalTo("company",company)    Account.first().then(res=>{      let account = res.toJSON()      this.setData({        cardList:account.bank ? account.bank : [] ,        objectId:account.objectId      })          })  },  bindKeyInput(e){      this.setData({        [e.currentTarget.dataset.prop]: e.detail.value      })  },  /**   * 生命周期函数--监听页面加载   */  onLoad: function (options) {    this.getCardList()  },  /**   * 生命周期函数--监听页面初次渲染完成   */  onReady: function () {  },  /**   * 生命周期函数--监听页面显示   */  onShow: function () {  },  /**   * 生命周期函数--监听页面隐藏   */  onHide: function () {  },  /**   * 生命周期函数--监听页面卸载   */  onUnload: function () {  },  /**   * 页面相关事件处理函数--监听用户下拉动作   */  onPullDownRefresh: function () {  },  /**   * 页面上拉触底事件的处理函数   */  onReachBottom: function () {  },  /**   * 用户点击右上角分享   */  onShareAppMessage: function () {  }})
 |