kaifapiao.js 5.3 KB
// pages/kaifapiao/kaifapiao.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    company:'',
    shuihao:'',
    companyaddress:'',
    companyphone:'',
    companyname:'',
    bankname:'',
    banknum:'',
    shouname:'',
    shouphone:'',
    shouaddress:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      order_id:JSON.parse(options.ids)
    })
    console.log(this.data.order_id)
  },
  // 公司名称
  company(e){
    this.setData({
      company:e.detail.value
    })
  },
  // 税号
  shuihao(e){
    this.setData({
      shuihao:e.detail.value
    })
  },
  // 公司地址
  companyaddress(e){
    this.setData({
      companyaddress:e.detail.value
    })
  },
// 公司联系电话
  conpanyphone(e){
    this.setData({
      companyphone:e.detail.value
    })
   
  },
  // 开户银行名称
  bankname(e){
    this.setData({
      bankname:e.detail.value
    })
  },
  // 开户银行账号
  banknum(e){
    this.setData({
      banknum:e.detail.value
    })
  },
  // 收货人姓名
  shouname(e){
    this.setData({
      shouname:e.detail.value
    })
  },
  // 收货人电话
  shouphone(e){
    this.setData({
      shouphone:e.detail.value
    })
  },
  // 收货人地址
  shouaddress(e){
    this.setData({
      shouaddress:e.detail.value
    })
  },
  // 提交订单

  finish(){
    let that = this;
    if (that.data.company==''){
      wx.showToast({
        title: '请输入公司名称',
        icon:"none"
      })
      return false
    }

    if (that.data.shuihao == '') {
      wx.showToast({
        title: '请输入公司纳税人识别号',
        icon: "none"
      })
      return false
    }

    if (that.data.companyaddress == '') {
      wx.showToast({
        title: '请输入公司地址',
        icon: "none"
      })
      return false
    }
    if (that.data.companyphone == '') {
      wx.showToast({
        title: '请输入公司联系电话',
        icon: "none"
      })
      return false
    }
    if (that.data.companyphone != '') {

      // let isMobilePhone = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
      // let isFixMob = /^0?1[3|4|5|8][0-9]\d{8}$/;

      // if (isFixMob.test(that.data.companyphone) || isMobilePhone.test(that.data.companyphone)) {
      //   console.log(8080800)

      // } else {

      //   wx.showToast({
      //     title: '请输入正确的公司联系电话',
      //     icon: 'none'
      //   })

      //   return false
      // }
      console.log(that.checkTel(that.data.companyphone))

      if (that.checkTel(that.data.companyphone)==false){
        wx.showToast({
          title: '请输入正确的公司联系电话',
          icon: 'none'
        })

        return false
      }

    }

    if (that.data.bankname == '') {
      wx.showToast({
        title: '请输入开户银行名称',
        icon: "none"
      })
      return false
    }
    if (that.data.banknum == '') {
      wx.showToast({
        title: '请输入开户银行账号',
        icon: "none"
      })
      return false
    }
    if (that.data.shouname == '') {
      wx.showToast({
        title: '请输入收件人姓名',
        icon: "none"
      })
      return false
    }
    if (that.data.shouphone == '') {
      wx.showToast({
        title: '请输入收件人电话',
        icon: "none"
      })
      return false
    }
    if (that.data.shouphone != ''){
      var reg = /^[1][3,4,5,6,,7,8,9][0-9]{9}$/;
      if (!reg.test(that.data.shouphone)) {
        wx.showToast({
          title: '请输入正确的收件人电话',
          icon: "none"
        })
        return false
      }
    }
    if (that.data.shouaddress == '') {
      wx.showToast({
        title: '请输入收件人地址',
        icon: "none"
      })
      return false
    }

    let neworder_id=that.data.order_id;
    neworder_id=neworder_id.join(",");
    neworder_id = ',' + neworder_id+','

    let canshu={};
    canshu.name = that.data.company;
    canshu.tel = that.data.companyphone;
    canshu.adress = that.data.companyaddress;
    canshu.duty = that.data.shuihao;
    canshu.bank = that.data.bankname;
    canshu.card = that.data.banknum;
    canshu.linkname = that.data.shouname;
    canshu.linktel = that.data.shouphone;
    canshu.linkadress=that.data.shouaddress;
    canshu.order_id=neworder_id;
    canshu=JSON.stringify(canshu);
    console.log(canshu);
    wx.navigateTo({
      url: '/pages/yulanfapiao/yulanfapiao?canshu='+canshu,
    })
    


   
   
    
  },

  checkTel(tel) {
    var mobile = /^1[3|5|8]\d{9}$/, phone = /^0\d{2,3}-?\d{7,8}$/;
    return mobile.test(tel) || phone.test(tel);
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

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

  },

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

  },

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

  },

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

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})