东风启辰小程序端
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 11KB

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