123 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			123 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
| // pages/candidate/index.js
 | |
| const api = require("../../utils/request.js");
 | |
| Page({
 | |
| 
 | |
|   /**
 | |
|    * 页面的初始数据
 | |
|    */
 | |
|   data: {
 | |
|     ID_number:null,
 | |
|     realname:null,
 | |
|     candidates:[]
 | |
|   },
 | |
| 
 | |
|   /**
 | |
|    * 生命周期函数--监听页面加载
 | |
|    */
 | |
|   onLoad: function (options) {
 | |
|     if(getApp().globalData.userinfo.ID_number && getApp().globalData.userinfo.realname){
 | |
|       this.setData({
 | |
|         ID_number:getApp().globalData.userinfo.ID_number,
 | |
|         realname:getApp().globalData.userinfo.realname,
 | |
|       })
 | |
|       this.search()
 | |
|     }
 | |
|   },
 | |
| 
 | |
|   /**
 | |
|    * 生命周期函数--监听页面初次渲染完成
 | |
|    */
 | |
|   onReady: function () {
 | |
| 
 | |
|   },
 | |
| 
 | |
|   /**
 | |
|    * 生命周期函数--监听页面显示
 | |
|    */
 | |
|   onShow: function () {
 | |
|     
 | |
|   },
 | |
| 
 | |
|   /**
 | |
|    * 生命周期函数--监听页面隐藏
 | |
|    */
 | |
|   onHide: function () {
 | |
| 
 | |
|   },
 | |
| 
 | |
|   /**
 | |
|    * 生命周期函数--监听页面卸载
 | |
|    */
 | |
|   onUnload: function () {
 | |
| 
 | |
|   },
 | |
| 
 | |
|   /**
 | |
|    * 页面相关事件处理函数--监听用户下拉动作
 | |
|    */
 | |
|   onPullDownRefresh: function () {
 | |
| 
 | |
|   },
 | |
| 
 | |
|   /**
 | |
|    * 页面上拉触底事件的处理函数
 | |
|    */
 | |
|   onReachBottom: function () {
 | |
| 
 | |
|   },
 | |
| 
 | |
|   /**
 | |
|    * 用户点击右上角分享
 | |
|    */
 | |
|   onShareAppMessage: function () {
 | |
| 
 | |
|   },
 | |
|   bindinput1: function(e){
 | |
|     this.data.realname = e.detail.value
 | |
|   },
 | |
|   bindinput2: function(e){
 | |
|     this.data.ID_number = e.detail.value
 | |
|   },
 | |
|   search: function() {
 | |
|     if(this.data.realname && this.data.ID_number){
 | |
|       var data = {
 | |
|         realname:this.data.realname,
 | |
|         ID_number:this.data.ID_number
 | |
|       }
 | |
|       wx.showLoading({
 | |
|         title: '查询中..',
 | |
|         mask:true
 | |
|       })
 | |
|       api.request('/crm/consumer/candidate/', 'GET', data).then(res => {
 | |
|         wx.hideLoading({
 | |
|           success: (res) => {},
 | |
|         })
 | |
|         // console.log(res.data.candidates)
 | |
|           this.setData({
 | |
|             candidates:res.data.candidates
 | |
|           })
 | |
|       }).catch(e=>{
 | |
|         wx.hideLoading({
 | |
|           success: (res) => {},
 | |
|         })
 | |
|       })
 | |
|       api.request('/crm/consumer/realinfo/', 'POST', data).then(res=>{
 | |
|       })
 | |
|     }else{
 | |
|       wx.showToast({
 | |
|         title: '请填写姓名和身份证号',
 | |
|         icon: 'none',
 | |
|         duration: 1500
 | |
|       })
 | |
|     }
 | |
|     
 | |
|   },
 | |
|   toDetail: function(e){
 | |
|     var url = e.currentTarget.dataset.url
 | |
|     getApp().globalData.candidate_url = url
 | |
|     wx.navigateTo({
 | |
|       url: 'detail',
 | |
|     })
 | |
|   }
 | |
|   
 | |
| }) |