东风启辰小程序端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

register.js 11KB

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