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