东风启辰小程序端
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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(this.data.cityList[0][e.detail.value.city[0]]);
  83. return;
  84. console.log('form发生了submit事件,携带数据为:', e.detail.value)
  85. if (e.detail.value.name == "" || e.detail.value.name == null) {
  86. wx.showToast({icon:'none',title: '请输入您的姓名'})
  87. }else if (e.detail.value.phone == "" || e.detail.value.phone == null) {
  88. wx.showToast({icon:'none',title: '请输入您的手机号码'})
  89. }else if (e.detail.value.code == "" || e.detail.value.code == null) {
  90. wx.showToast({icon:'none',title: '请输入您的验证码'})
  91. }else if(this.data.photoList.length<0){
  92. wx.showToast({icon:'none',title: '请上传您的照片'})
  93. }else if(!this.data.agree){
  94. wx.showToast({icon:'none',title: '请阅读并同意协议内容'})
  95. }else{
  96. if(this.data.isbtn){
  97. this.setData({isbtn: false})
  98. }else{
  99. return;
  100. }
  101. app.wxRequest(app.globalData.urlRoot + "userInfo/submitCertificationNoCarInfo", {
  102. mobile:e.detail.value.phone,
  103. captcha:e.detail.value.code,
  104. realname:e.detail.value.name,
  105. jobId:this.data.vocationList2[parseInt(this.data.vocationIndex)]["jobId"],
  106. jobDetail:this.data.vocationList2[parseInt(this.data.vocationIndex)]["jobDetail"],
  107. province: this.data.cityList[0][e.detail.value.city[0]],
  108. city:this.data.cityList[1][e.detail.value.city[1]],
  109. picArr:JSON.stringify(this.data.photoList)
  110. }, res => {
  111. console.log(res)
  112. if (res.code == 200) {
  113. this.setData({maskShow:true})
  114. }else{
  115. this.setData({isbtn: true})
  116. wx.showToast({icon:'none',title: ''+res.msg})
  117. }
  118. }, this,"POST");
  119. }
  120. },
  121. /**
  122. * 关闭弹窗
  123. */
  124. hiddenRule:function(){
  125. this.setData({maskShow: false})
  126. wx.navigateBack({
  127. delta:1
  128. })
  129. // wx.navigateTo({url: '../../star/star'})
  130. },
  131. /**
  132. * 更换职业
  133. */
  134. changeVocation: function (e) {
  135. this.setData({
  136. vocationIndex: e.detail.value
  137. })
  138. },
  139. /**
  140. * 切换城市
  141. */
  142. changeCity(e){
  143. this.setData({
  144. cityIndex: e.detail.value
  145. })
  146. },
  147. changeCity2(e){
  148. if(e.detail.column==0){
  149. var jushu=[];
  150. jushu[0]=e.detail.value;
  151. jushu[1]=0;
  152. this.setData({
  153. cityIndex:jushu
  154. })
  155. var shuju=[];
  156. var shuju2=[];
  157. for(var i=0;i<this.data.allList.length;i++){
  158. if(this.data.cityList[0].indexOf(this.data.allList[i]["province"])==this.data.cityIndex[0]){
  159. shuju2.push(this.data.allList[i]["city"]);
  160. }
  161. }
  162. shuju[0]=this.data.cityList[0];
  163. shuju[1]=shuju2;
  164. this.setData({
  165. cityList:shuju
  166. })
  167. }else{
  168. var jushu=[];
  169. jushu[0]=this.data.cityIndex[0];
  170. jushu[1]=e.detail.value;
  171. this.setData({
  172. cityIndex:jushu
  173. })
  174. }
  175. },
  176. /**
  177. * 获取手机号
  178. */
  179. getphone(e){
  180. this.setData({
  181. getphone: e.detail.value
  182. })
  183. },
  184. /**
  185. * 获取验证码
  186. */
  187. getVcode(){
  188. console.log('获取验证码');
  189. if (this.data.getphone == "" || this.data.getphone == null) {
  190. wx.showToast({
  191. icon:'none',
  192. title: '请输入您的手机号码'
  193. })
  194. return;
  195. }
  196. if (!app.mobileVerify(this.data.getphone)) {
  197. wx.showToast({
  198. icon:'none',
  199. title: '请输入正确手机号码'
  200. })
  201. return;
  202. }
  203. app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", {mobile:this.data.getphone}, res => {
  204. console.log(res)
  205. if (res.code == 200) {
  206. this.setData({
  207. getVcodeTime: 60
  208. })
  209. this.getCodeTimeKey=setInterval(this.vCodeDownTime,1000);
  210. }else{
  211. wx.showToast({icon:'none',title: ''+res.msg})
  212. }
  213. }, this);
  214. },
  215. vCodeDownTime(){
  216. var time = this.data.getVcodeTime-1;
  217. this.setData({
  218. getVcodeTime: time
  219. })
  220. if(time<=0){
  221. clearInterval(this.getCodeTimeKey);
  222. }
  223. },
  224. /**
  225. * 上传照片
  226. */
  227. chooseImage(e){
  228. var list=this.data.photoList;
  229. wx.chooseImage({
  230. count:1,
  231. sizeType: ['original'], //可选择原图
  232. sourceType: ['album', 'camera'], //可选择性开放访问相册、相机
  233. success: res => {
  234. wx.uploadFile({
  235. url: app.globalData.urlRoot + "upload/uploadImage",
  236. header:{"OPENID": app.globalData.openid},
  237. filePath: res.tempFilePaths[0],
  238. name: "file",
  239. success: res => {
  240. console.log(res)
  241. if(res.data){
  242. console.log(JSON.parse(res.data));
  243. var json=JSON.parse(res.data);
  244. if(json.code==200){
  245. console.log(json.data[0].url);
  246. if(e.currentTarget.dataset.value>-1){
  247. list[e.currentTarget.dataset.value]=json.data[0].url;
  248. }else{
  249. list.push(json.data[0].url);
  250. }
  251. this.setData({photoList:list});
  252. }else{
  253. wx.showToast({icon:'none',title: '图片上传失败'})
  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. })