|
- // pages/scout/register/register.js
- var Mcaptcha = require('../../../utils/mcaptcha.js');
- const app = getApp()
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.urlStatic,//图片路径
- type: 0, //1车主 0非车主
- imgCode:'',//验证码
- vocationList:['网约车司机','公交司机','快的司机'],//职业列表
- vocationList2:[],//职业列表2
- vocationIndex:'0',
- allList:[],//所有列表
- cityList:[['宁波','北京'],['上海','佛山']],//城市列表
- cityIndex:['0','0'],
- getVcodeTime:0,//获取验证码倒计时
- getCodeTimeKey:null,
- photoList:[],//图片列表
- agree:false,//是否同意本协议
- getphone:"",//手机号
- maskShow: false,
- mydata:[],//我的数据
- isbtn:true,//防重复点击
- },
- /**
- * 切换车主非车主
- */
- changeType(e) {
- var type = e.currentTarget.dataset.type;
- if (this.data.type != type) {
- this.setData({
- type: type
- })
- if (type == 1) {
- setTimeout(this.vCodeRefresh, 100);
- }
- }
- },
- /**
- * 提交信息-认证
- */
- formSubmit1(e){
- console.log('form发生了submit事件,携带数据为:', e.detail.value)
- var res = this.mcaptcha.validate(e.detail.value.code);
- if (e.detail.value.VIN == "" || e.detail.value.VIN == null) {
- wx.showToast({icon:'none',title: '请输入车牌号/VIN号'})
- return;
- }else if (e.detail.value.code == "" || e.detail.value.code == null) {
- wx.showToast({icon:'none',title: '请输入图形验证码'})
- }else if (!res) {
- wx.showToast({icon:'none',title: '图形验证码错误'})
- }else{
- if(this.data.isbtn){
- this.setData({isbtn: false})
- }else{
- return;
- }
- app.wxRequest(app.globalData.urlRoot + "userInfo/certificationCar", {carInfo:e.detail.value.VIN}, res => {
- console.log(res)
- if (res.code == 200) {
- if(res.data!=null){
- app.globalData.certificationState=res.data.certificationState;
- wx.navigateTo({url: '/pages/scout/scout'})
- }else{
- this.setData({isbtn: true})
- wx.showToast({icon:'none',title: '认证失败'})
- }
- }else{
- this.setData({isbtn: true})
- wx.showToast({icon:'none',title: ''+res.msg})
- }
- }, this,"POST");
- }
- },
- /**
- * 提交信息-注册
- */
- formSubmit2(e){
- console.log('form发生了submit事件,携带数据为:', e.detail.value)
- if (e.detail.value.name == "" || e.detail.value.name == null) {
- wx.showToast({icon:'none',title: '请输入您的姓名'})
- }else if (e.detail.value.phone == "" || e.detail.value.phone == null) {
- wx.showToast({icon:'none',title: '请输入您的手机号码'})
- }else if (e.detail.value.code == "" || e.detail.value.code == null) {
- wx.showToast({icon:'none',title: '请输入您的验证码'})
- }else if(this.data.photoList.length<0){
- wx.showToast({icon:'none',title: '请上传您的照片'})
- }else if(!this.data.agree){
- wx.showToast({icon:'none',title: '请阅读并同意协议内容'})
- }else{
- if(this.data.isbtn){
- this.setData({isbtn: false})
- }else{
- return;
- }
- app.wxRequest(app.globalData.urlRoot + "userInfo/submitCertificationNoCarInfo", {
- mobile:e.detail.value.phone,
- captcha:e.detail.value.code,
- realname:e.detail.value.name,
- jobId:this.data.vocationList2[parseInt(this.data.vocationIndex)]["jobId"],
- jobDetail:this.data.vocationList2[parseInt(this.data.vocationIndex)]["jobDetail"],
- city:this.data.cityList[1][e.detail.value.city[1]],
- picArr:JSON.stringify(this.data.photoList)
- }, res => {
- console.log(res)
- if (res.code == 200) {
- this.setData({maskShow:true})
- }else{
- this.setData({isbtn: true})
- wx.showToast({icon:'none',title: ''+res.msg})
- }
- }, this,"POST");
- }
- },
- /**
- * 关闭弹窗
- */
- hiddenRule:function(){
- this.setData({maskShow: false})
- wx.navigateBack({
- delta:1
- })
- // wx.navigateTo({url: '../../star/star'})
- },
- /**
- * 更换职业
- */
- changeVocation: function (e) {
- this.setData({
- vocationIndex: e.detail.value
- })
- },
- /**
- * 切换城市
- */
- changeCity(e){
- this.setData({
- cityIndex: e.detail.value
- })
- },
- changeCity2(e){
- if(e.detail.column==0){
- var jushu=[];
- jushu[0]=e.detail.value;
- jushu[1]=0;
- this.setData({
- cityIndex:jushu
- })
- var shuju=[];
- var shuju2=[];
- for(var i=0;i<this.data.allList.length;i++){
- if(this.data.cityList[0].indexOf(this.data.allList[i]["province"])==this.data.cityIndex[0]){
- shuju2.push(this.data.allList[i]["city"]);
- }
- }
- shuju[0]=this.data.cityList[0];
- shuju[1]=shuju2;
- this.setData({
- cityList:shuju
- })
- }else{
- var jushu=[];
- jushu[0]=this.data.cityIndex[0];
- jushu[1]=e.detail.value;
- this.setData({
- cityIndex:jushu
- })
- }
- },
- /**
- * 获取手机号
- */
- getphone(e){
- this.setData({
- getphone: e.detail.value
- })
- },
- /**
- * 获取验证码
- */
- getVcode(){
- console.log('获取验证码');
- if (this.data.getphone == "" || this.data.getphone == null) {
- wx.showToast({
- icon:'none',
- title: '请输入您的手机号码'
- })
- return;
- }
- if (!app.mobileVerify(this.data.getphone)) {
- wx.showToast({
- icon:'none',
- title: '请输入正确手机号码'
- })
- return;
- }
- app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", {mobile:this.data.getphone}, res => {
- console.log(res)
- if (res.code == 200) {
- this.setData({
- getVcodeTime: 60
- })
- this.getCodeTimeKey=setInterval(this.vCodeDownTime,1000);
- }else{
- wx.showToast({icon:'none',title: ''+res.msg})
- }
- }, this);
- },
- vCodeDownTime(){
- var time = this.data.getVcodeTime-1;
- this.setData({
- getVcodeTime: time
- })
- if(time<=0){
- clearInterval(this.getCodeTimeKey);
- }
- },
- /**
- * 上传照片
- */
- chooseImage(e){
- var list=this.data.photoList;
- wx.chooseImage({
- count:1,
- sizeType: ['original'], //可选择原图
- sourceType: ['album', 'camera'], //可选择性开放访问相册、相机
- success: res => {
- wx.uploadFile({
- url: app.globalData.urlRoot + "upload/uploadImage",
- header:{"OPENID": app.globalData.openid},
- filePath: res.tempFilePaths[0],
- name: "file",
- success: res => {
- console.log(res)
- if(res.data){
- console.log(JSON.parse(res.data));
- var json=JSON.parse(res.data);
- if(json.code==200){
- console.log(json.data[0].url);
- if(e.currentTarget.dataset.value>-1){
- list[e.currentTarget.dataset.value]=json.data[0].url;
- }else{
- list.push(json.data[0].url);
- }
- this.setData({photoList:list});
- }else{
- wx.showToast({icon:'none',title: '图片上传失败'})
- }
- }
- }
- })
- }
- })
- },
- /**
- * 同意协议
- */
- agreementClick(event){
- var agree = this.data.agree;
- this.setData({ "agree": !agree });
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
-
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- wx.getSystemInfo({
- success: option => {
- var windowScale = option.windowWidth / 750;
- this.mcaptcha = new Mcaptcha({
- el: 'canvas',
- width: windowScale*205,
- height: windowScale*51,
- createCodeImg: ""
- });
- }
- })
- app.wxRequest(app.globalData.urlRoot + "userInfo/getJobList", {}, res => {
- console.log(res)
- if (res.code == 200) {
- var shuju=[];
- for(var i=0;i<res.data.length;i++){
- shuju.push(res.data[i]["jobDetail"]);
- }
- this.setData({
- vocationList:shuju,
- vocationList2:res.data
- })
- }
- }, this);
- app.wxRequest(app.globalData.urlRoot + "userInfo/getNoCarCityList", {}, res => {
- console.log(res)
- if (res.code == 200) {
- var shuju=[];
- var shuju1=[];
- var shuju2=[];
- for(var i=0;i<res.data.length;i++){
- if(shuju1.indexOf(res.data[i]["province"])==-1){
- shuju1.push(res.data[i]["province"]);
- }
- }
- for(var i=0;i<res.data.length;i++){
- if(shuju1.indexOf(res.data[i]["province"])==this.data.cityIndex[0]){
- shuju2.push(res.data[i]["city"]);
- }
- }
- shuju[0]=shuju1;
- shuju[1]=shuju2;
- this.setData({
- allList:res.data,
- cityList:shuju
- })
- this.getshow();
- }
- }, this);
- },
- /**
- * 刷新验证码
- */
- vCodeRefresh() {
- this.mcaptcha.refresh();
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- this.setData({isbtn: true})
- // this.getshow();
- },
- getshow(){
- app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationNoCarInfo", {}, res => {
- console.log(res)
- if(res.code=200 && res.data){
- if(res.data.adminState==1){//审核通过
- // this.setData({maskShow:true})
- wx.navigateTo({url: '/pages/scout/scout'})
- }else if(res.data.adminState==0 || res.data.adminState==-1){//审核中&审核失败
- if(res.data.adminState==0){
- this.setData({maskShow:true})
- }
- var jushu=[],shuju=[],shuju2=[];
- for(var i=0;i<this.data.allList.length;i++){
- if(this.data.allList[i]["city"]==res.data.city){
- jushu[0]=this.data.cityList[0].indexOf(this.data.allList[i]["province"]);
- }
- }
- for(var i=0;i<this.data.allList.length;i++){
- if(this.data.cityList[0].indexOf(this.data.allList[i]["province"])==jushu[0]){
- shuju2.push(this.data.allList[i]["city"]);
- }
- }
- for(var i=0;i<shuju2.length;i++){
- if(shuju2[i]==res.data.city){
- jushu[1]=i;
- }
- }
- shuju[0]=this.data.cityList[0];
- shuju[1]=shuju2;
-
- this.setData({
- mydata:res.data,
- vocationIndex:parseInt(res.data.jobId)-1,
- cityIndex:jushu,
- cityList:shuju,
- agree:true,
- photoList:res.data.picArr,
- getphone:res.data.mobile,
- })
- }
- }
- }, this);
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- clearInterval(this.getCodeTimeKey);
- this.data.getVcodeTime=60;
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- return app.sharePack();
- }
- })
|