东风启辰小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

register.js 12KB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. // pages/scout/register/register.js
  2. var Mcaptcha = require('../../../utils/mcaptcha.js');
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. imgUrl: app.globalData.urlStatic,//图片路径
  10. type: 0, //1车主 0非车主
  11. imgCode:'',//验证码
  12. vocationList:['网约车司机','公交司机','快的司机'],//职业列表
  13. vocationList2:[],//职业列表2
  14. vocationIndex:'0',
  15. allList:[],//所有列表
  16. cityList: [[''], ['']],//城市列表
  17. cityIndex:['0','0'],
  18. getVcodeTime:0,//获取验证码倒计时
  19. getCodeTimeKey:null,
  20. photoList:[],//图片列表
  21. photoListShow:[],
  22. agree:false,//是否同意本协议
  23. getphone:"",//手机号
  24. maskShow: false,
  25. mydata:[],//我的数据
  26. isbtn:true,//防重复点击
  27. vCodeImg:null,
  28. agreement:false,
  29. auditDefeated:false,
  30. },
  31. /**
  32. * 切换车主非车主
  33. */
  34. changeType(e) {
  35. var type = e.currentTarget.dataset.type;
  36. if (this.data.type != type) {
  37. this.setData({
  38. type: type
  39. })
  40. if (type == 1) {
  41. setTimeout(this.vCodeRefresh, 100);
  42. }
  43. }
  44. },
  45. /**
  46. * 提交信息-认证
  47. */
  48. formSubmit1(e){
  49. console.log('form发生了submit事件,携带数据为:', e.detail.value)
  50. var res = this.mcaptcha.validate(e.detail.value.code);
  51. if (e.detail.value.VIN == "" || e.detail.value.VIN == null) {
  52. wx.showToast({icon:'none',title: '请输入车牌号/VIN号'})
  53. return;
  54. }else if (e.detail.value.code == "" || e.detail.value.code == null) {
  55. wx.showToast({icon:'none',title: '请输入图形验证码'})
  56. }else if (!res) {
  57. wx.showToast({icon:'none',title: '图形验证码错误'})
  58. }else{
  59. if(this.data.isbtn){
  60. this.setData({isbtn: false})
  61. }else{
  62. return;
  63. }
  64. app.wxRequest(app.globalData.urlRoot + "userInfo/certificationCar", {carInfo:e.detail.value.VIN}, res => {
  65. console.log(res)
  66. if (res.code == 200) {
  67. if(res.data!=null){
  68. app.globalData.certificationState=res.data.certificationState;
  69. wx.navigateTo({url: '/pages/scout/scout'})
  70. }else{
  71. this.setData({isbtn: true})
  72. wx.showToast({icon:'none',title: '认证失败'})
  73. }
  74. }else{
  75. this.setData({isbtn: true})
  76. wx.showToast({icon:'none',title: ''+res.msg})
  77. }
  78. }, this,"POST");
  79. }
  80. },
  81. /**
  82. * 提交信息-注册
  83. */
  84. formSubmit2(e) {
  85. console.log('form发生了submit事件,携带数据为:', e.detail.value)
  86. if (e.detail.value.name == "" || e.detail.value.name == null) {
  87. wx.showToast({icon:'none',title: '请输入您的姓名'})
  88. }else if (e.detail.value.phone == "" || e.detail.value.phone == null) {
  89. wx.showToast({icon:'none',title: '请输入您的手机号码'})
  90. }else if (e.detail.value.code == "" || e.detail.value.code == null) {
  91. wx.showToast({icon:'none',title: '请输入您的验证码'})
  92. }else if(this.data.photoList.length<1){
  93. wx.showToast({icon:'none',title: '请上传您的照片'})
  94. }else if(!this.data.agree){
  95. wx.showToast({icon:'none',title: '请阅读并同意协议内容'})
  96. } else {
  97. if(this.data.isbtn){
  98. this.setData({isbtn: false})
  99. }else{
  100. return;
  101. }
  102. app.wxRequest(app.globalData.urlRoot + "userInfo/submitCertificationNoCarInfo", {
  103. mobile:e.detail.value.phone,
  104. captcha:e.detail.value.code,
  105. realname:e.detail.value.name,
  106. jobId:this.data.vocationList2[parseInt(this.data.vocationIndex)]["jobId"],
  107. jobDetail:this.data.vocationList2[parseInt(this.data.vocationIndex)]["jobDetail"],
  108. province: this.data.cityList[0][e.detail.value.city[0]],
  109. city:this.data.cityList[1][e.detail.value.city[1]],
  110. picArr:JSON.stringify(this.data.photoList)
  111. }, res => {
  112. console.log(res)
  113. if (res.code == 200) {
  114. this.setData({maskShow:true})
  115. }else{
  116. this.setData({isbtn: true})
  117. wx.showToast({icon:'none',title: ''+res.msg})
  118. }
  119. }, this,"POST");
  120. }
  121. },
  122. /**
  123. * 关闭弹窗
  124. */
  125. hiddenRule:function(){
  126. this.setData({maskShow: false})
  127. wx.navigateBack({
  128. delta:1
  129. })
  130. // wx.navigateTo({url: '../../star/star'})
  131. },
  132. /**
  133. * 更换职业
  134. */
  135. changeVocation: function (e) {
  136. this.setData({
  137. vocationIndex: e.detail.value
  138. })
  139. },
  140. /**
  141. * 切换城市
  142. */
  143. changeCity(e){
  144. this.setData({
  145. cityIndex: e.detail.value
  146. })
  147. },
  148. changeCity2(e){
  149. if(e.detail.column==0){
  150. var jushu=[];
  151. jushu[0]=e.detail.value;
  152. jushu[1]=0;
  153. this.setData({
  154. cityIndex:jushu
  155. })
  156. var shuju=[];
  157. var shuju2=[];
  158. for(var i=0;i<this.data.allList.length;i++){
  159. if(this.data.cityList[0].indexOf(this.data.allList[i]["province"])==this.data.cityIndex[0]){
  160. shuju2.push(this.data.allList[i]["city"]);
  161. }
  162. }
  163. shuju[0]=this.data.cityList[0];
  164. shuju[1]=shuju2;
  165. this.setData({
  166. cityList:shuju
  167. })
  168. }else{
  169. var jushu=[];
  170. jushu[0]=this.data.cityIndex[0];
  171. jushu[1]=e.detail.value;
  172. this.setData({
  173. cityIndex:jushu
  174. })
  175. }
  176. },
  177. /**
  178. * 获取手机号
  179. */
  180. getphone(e){
  181. this.setData({
  182. getphone: e.detail.value
  183. })
  184. },
  185. /**
  186. * 获取验证码
  187. */
  188. getVcode(){
  189. console.log('获取验证码');
  190. if (this.data.getphone == "" || this.data.getphone == null) {
  191. wx.showToast({
  192. icon:'none',
  193. title: '请输入您的手机号码'
  194. })
  195. return;
  196. }
  197. if (!app.mobileVerify(this.data.getphone)) {
  198. wx.showToast({
  199. icon:'none',
  200. title: '请输入正确手机号码'
  201. })
  202. return;
  203. }
  204. app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", {mobile:this.data.getphone}, res => {
  205. console.log(res)
  206. if (res.code == 200) {
  207. this.setData({
  208. getVcodeTime: 60
  209. })
  210. this.getCodeTimeKey=setInterval(this.vCodeDownTime,1000);
  211. }else{
  212. wx.showToast({icon:'none',title: ''+res.msg})
  213. }
  214. }, this);
  215. },
  216. vCodeDownTime(){
  217. var time = this.data.getVcodeTime-1;
  218. this.setData({
  219. getVcodeTime: time
  220. })
  221. if(time<=0){
  222. clearInterval(this.getCodeTimeKey);
  223. }
  224. },
  225. /**
  226. * 上传照片
  227. */
  228. chooseImage(e){
  229. var list = this.data.photoList;
  230. wx.chooseImage({
  231. count: 3 - this.data.photoListShow.length,
  232. sizeType: ['original'], //可选择原图
  233. sourceType: ['album', 'camera'], //可选择性开放访问相册、相机
  234. success: res => {
  235. for (let i = 0; i < res.tempFilePaths.length; i++) {
  236. this.data.photoListShow.push(res.tempFilePaths[i]);
  237. this.setData({
  238. photoListShow: this.data.photoListShow
  239. })
  240. wx.uploadFile({
  241. url: app.globalData.urlRoot + "upload/uploadImage",
  242. header: {
  243. "OPENID": app.globalData.openid,
  244. "VERSION": 100
  245. },
  246. filePath: res.tempFilePaths[i],
  247. name: "file",
  248. formData: {
  249. filePath: "static"
  250. },
  251. success: res => {
  252. if (res.data) {
  253. var json = JSON.parse(res.data);
  254. if (json.code == 200) {
  255. if (e.currentTarget.dataset.value > -1) {
  256. list[e.currentTarget.dataset.value] = json.data[0].url;
  257. } else {
  258. list.push(json.data[0].url);
  259. }
  260. this.setData({ photoList: list });
  261. } else {
  262. wx.showToast({ icon: 'none', title: '图片上传失败' })
  263. }
  264. }
  265. }
  266. })
  267. }
  268. }
  269. })
  270. },
  271. /**
  272. * 同意协议
  273. */
  274. agreementClick(event){
  275. var agree = this.data.agree;
  276. this.setData({ "agree": !agree });
  277. },
  278. /**
  279. * 生命周期函数--监听页面加载
  280. */
  281. onLoad: function (options) {
  282. app.globalData.nowPage = 2;
  283. },
  284. /**
  285. * 生命周期函数--监听页面初次渲染完成
  286. */
  287. onReady: function() {
  288. wx.getSystemInfo({
  289. success: option => {
  290. var windowScale = option.windowWidth / 750;
  291. this.mcaptcha = new Mcaptcha({
  292. el: 'canvas',
  293. width: windowScale*205,
  294. height: windowScale*51,
  295. createCodeImg: "",
  296. callUrl:{
  297. that:this,
  298. obj:this.changeVode
  299. }
  300. });
  301. }
  302. })
  303. app.wxRequest(app.globalData.urlRoot + "userInfo/getJobList", {}, res => {
  304. console.log(res)
  305. if (res.code == 200) {
  306. var shuju=[];
  307. for(var i=0;i<res.data.length;i++){
  308. shuju.push(res.data[i]["jobDetail"]);
  309. }
  310. this.setData({
  311. vocationList:shuju,
  312. vocationList2:res.data
  313. })
  314. }
  315. }, this);
  316. app.wxRequest(app.globalData.urlRoot + "userInfo/getNoCarCityList", {}, res => {
  317. console.log(res)
  318. if (res.code == 200) {
  319. var shuju=[];
  320. var shuju1=[];
  321. var shuju2=[];
  322. for(var i=0;i<res.data.length;i++){
  323. if(shuju1.indexOf(res.data[i]["province"])==-1){
  324. shuju1.push(res.data[i]["province"]);
  325. }
  326. }
  327. for(var i=0;i<res.data.length;i++){
  328. if(shuju1.indexOf(res.data[i]["province"])==this.data.cityIndex[0]){
  329. shuju2.push(res.data[i]["city"]);
  330. }
  331. }
  332. shuju[0]=shuju1;
  333. shuju[1]=shuju2;
  334. this.setData({
  335. allList:res.data,
  336. cityList:shuju
  337. })
  338. this.getshow();
  339. }
  340. }, this);
  341. },
  342. changeVode:function(e){
  343. this.setData({
  344. vCodeImg: e.tempFilePath
  345. })
  346. },
  347. /**
  348. * 刷新验证码
  349. */
  350. vCodeRefresh() {
  351. this.mcaptcha.refresh();
  352. },
  353. /**
  354. * 生命周期函数--监听页面显示
  355. */
  356. onShow: function() {
  357. this.setData({isbtn: true})
  358. // this.getshow();
  359. },
  360. getshow(){
  361. app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationNoCarInfo", {}, res => {
  362. console.log(res)
  363. if(res.code=200 && res.data){
  364. if(res.data.adminState==1){//审核通过
  365. // this.setData({maskShow:true})
  366. wx.navigateTo({url: '/pages/scout/scout'})
  367. }else if(res.data.adminState==0){//审核中
  368. if(res.data.adminState==0){
  369. this.setData({maskShow:true})
  370. }
  371. var jushu=[],shuju=[],shuju2=[];
  372. for(var i=0;i<this.data.allList.length;i++){
  373. if(this.data.allList[i]["city"]==res.data.city){
  374. jushu[0]=this.data.cityList[0].indexOf(this.data.allList[i]["province"]);
  375. }
  376. }
  377. for(var i=0;i<this.data.allList.length;i++){
  378. if(this.data.cityList[0].indexOf(this.data.allList[i]["province"])==jushu[0]){
  379. shuju2.push(this.data.allList[i]["city"]);
  380. }
  381. }
  382. for(var i=0;i<shuju2.length;i++){
  383. if(shuju2[i]==res.data.city){
  384. jushu[1]=i;
  385. }
  386. }
  387. shuju[0]=this.data.cityList[0];
  388. shuju[1]=shuju2;
  389. this.setData({
  390. mydata:res.data,
  391. vocationIndex:parseInt(res.data.jobId)-1,
  392. cityIndex:jushu,
  393. cityList:shuju,
  394. agree:true,
  395. photoList:res.data.picArr,
  396. getphone:res.data.mobile,
  397. })
  398. }else if(res.data.adminState==-1){//审核失败
  399. this.auditDefeatedControl();
  400. }
  401. }
  402. }, this);
  403. },
  404. auditDefeatedControl:function(){
  405. this.setData({
  406. auditDefeated:!this.data.auditDefeated
  407. })
  408. },
  409. /**
  410. * 生命周期函数--监听页面隐藏
  411. */
  412. onHide: function() {
  413. },
  414. /**
  415. * 生命周期函数--监听页面卸载
  416. */
  417. onUnload: function() {
  418. clearInterval(this.getCodeTimeKey);
  419. this.data.getVcodeTime=60;
  420. },
  421. /**
  422. * 页面相关事件处理函数--监听用户下拉动作
  423. */
  424. onPullDownRefresh: function() {
  425. },
  426. /**
  427. * 页面上拉触底事件的处理函数
  428. */
  429. onReachBottom: function() {
  430. },
  431. /**
  432. * 用户点击右上角分享
  433. */
  434. onShareAppMessage: function() {
  435. return app.sharePack();
  436. },
  437. deleteImg:function(e){
  438. var index = e.currentTarget.dataset.index;
  439. this.data.photoList.splice(index, 1);
  440. this.data.photoListShow.splice(index, 1);
  441. this.setData({
  442. photoList: this.data.photoList,
  443. photoListShow: this.data.photoListShow
  444. })
  445. },
  446. agreementControl: function () {
  447. this.setData({
  448. agreement: !this.data.agreement
  449. })
  450. }
  451. })