companyidentity.js 4.2 KB
// pages/companyidentity/companyidentity.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    identity: true,
    company_status:'',
    companyname:'请选择企业',
    companyarray:[],
    companyid:'',
    companyindex:0,
    name:'',
    phone:'',
    card:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.getcompanylist();
    this.getuserinfo()
  },
  finish(){
    wx.navigateTo({
      url: '/pages/start/start',
    })
  },
  getuserinfo(){
    let that = this;
    var url = '/api/user/index';
    var params = {


    }
    app.post(url, params).then((res) => {
      console.log(res);
      that.setData({
        company_status: res.company_status
      })

      console.log(this.data.company_status)
      



    }).catch((err) => {

    })
  },
  getcompanylist(){
    let that = this;
    var url = '/api/index/company';
    var params = {


    }
    app.post(url, params).then((res) => {
      console.log(res);
      that.setData({
        companyarray: res.company
      })

      console.log(this.data.company_status)




    }).catch((err) => {

    })
    
  },

  bindprovinceChange: function (e) {
    console.log('picker发送选择改变,携带值为', e.detail.value)
    this.setData({
      companyindex: e.detail.value,
      companyid: this.data.companyarray[e.detail.value].id,
      companyname: this.data.companyarray[e.detail.value].name,
      
    })
    

  },

  // 输入姓名
  entername(e){
    this.setData({
      name:e.detail.value
    })
  },
  // 输入手机号
  enterphone(e){
    this.setData({
      phone:e.detail.value
    })
  },
  entercard(e){
    this.setData({
      card:e.detail.value
    })
  },
  finish(){
    let that = this;
    console.log(that.data.name)
    if(that.data.companyid==''){
      wx.showToast({
        title: '请选择企业',
        icon: "none"
      })
      return false
    }
    if(that.data.name==''){
      wx.showToast({
        title: '请输入姓名',
        icon:"none"
      })
      return false
    }
    if (that.data.phone == '') {
      wx.showToast({
        title: '请输入电话',
        icon: "none"
      })
      return false
    }
    
    if (that.data.card == '') {
      wx.showToast({
        title: '请输入身份证号',
        icon: "none"
      })
      return false
    }
    if(that.data.card!=''){
      if(that.data.card.length!=18){
        wx.showToast({
          title: '请输入正确的身份证',
          icon:'none'
        })

        return false

      }
    }
    var url = '/api/user/company_submit';
    var params = {
      company_id:that.data.companyid,
      realname:that.data.name,
      mobile:that.data.phone,
      identity:that.data.card

    }
    app.post(url, params,"post").then((res) => {
      console.log(res);
      wx.showToast({
        title: '提交成功,等待后台审核',
        icon:'none'
      })

     setTimeout(function(){
      wx.navigateTo({
        url: '/pages/shenhez/shenhez',
      })
     },1500)


    }).catch((err) => {
      wx.showToast({
        title: err.data.msg,
        icon:'none'
      })

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

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    let token=wx.getStorageSync("token");
    if(token==''){
      wx.showToast({
        title: '请先授权登录',
        icon: "none"
      })

      setTimeout(function () {
        wx.navigateTo({
          url: '/pages/start/start',
        })
      }, 1500)

      let url ='/pages/companyidentity/companyidentity';
      wx.setStorageSync("url", url)
      wx.setStorageSync("nologin", true)
    }

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})