indexShip.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. // pages/register/indexShip.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. showModal: false,
  9. isSubmitting:false,
  10. defaultText: '请选择',
  11. userId:'',
  12. name:'',
  13. phone:'',
  14. nickname: '',
  15. // fileList:[],
  16. },
  17. toLogin:function(){
  18. wx.navigateBack()
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. this.setData({
  25. loginStatus: wx.getStorageSync('loginStatus') ? wx.getStorageSync('loginStatus') : false,
  26. userId:wx.getStorageSync('id'),
  27. name:wx.getStorageSync('name'),
  28. phone:wx.getStorageSync('phone'),
  29. nickname: wx.getStorageSync('nickname'),
  30. roleName: "2",
  31. })
  32. },
  33. // //图片上传
  34. // afterRead:function(event){
  35. // const { file } = event.detail;
  36. // const { type } = event.currentTarget.dataset
  37. // app.request.uploadDIY({
  38. // url: app.API.uploadImgMap,
  39. // page: this,
  40. // filePaths:file.url,
  41. // setfiled:'file',
  42. // params: {},
  43. // //isToken: false,
  44. // isLoading: false,
  45. // successFun: true
  46. // }).then(res => {
  47. // const imgArray = this.data[type];
  48. // imgArray.push({
  49. // ...file,
  50. // url: app.host.BASEIMG_URL + JSON.parse(res.data).data.imageFile,
  51. // imgUrl: JSON.parse(res.data).data.imageFile
  52. // });
  53. // this.setData({
  54. // [type]: imgArray
  55. // });
  56. // })
  57. // },
  58. // // 删除图片
  59. // deleteImg: function (event) {
  60. // const { type } = event.currentTarget.dataset
  61. // let getFileList = this.data[type];
  62. // getFileList.splice(event.detail.index, 1)
  63. // this.setData({
  64. // [type]: getFileList
  65. // })
  66. // },
  67. //表单提交
  68. formSubmit: function (e) {
  69. let formData = e.detail.value;
  70. let reg = /^1[3-9]\d{9}$/;
  71. var mobile = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
  72. var warn = ""; //弹框时提示的内容
  73. if (formData.account == '') {
  74. warn = "请输入账号!";
  75. } else if (formData.name == '') {
  76. warn = "请输入船主姓名!";
  77. } else if (formData.phone == '') {
  78. warn = "请输入船主手机号!";
  79. } else if(!reg.test(formData.phone)){
  80. warn = "请确认手机号格式!";
  81. } else if (formData.nickname == '') {
  82. warn = "请输入船舶号!";
  83. }
  84. // /** 图片处理 START **/
  85. // let getfileList = this.data.fileList
  86. // if(getfileList.length < 1){
  87. // warn = "请上传船舶证书图片!";
  88. // }
  89. // let fileNameList = []
  90. // let filePathList = []
  91. // getfileList.forEach((element,index) => {
  92. // console.log("element-----" + JSON.stringify(element))
  93. // fileNameList.push('图片'+(index+1)+'.'+element.imgUrl.split('.')[1])
  94. // filePathList.push(element.imgUrl)
  95. // });
  96. // formData.fileNameList = fileNameList
  97. // formData.filePathList = filePathList
  98. // /** 图片处理 END **/
  99. if (warn != '') {
  100. app.util.checkForm(warn);
  101. } else {
  102. app.request.POST({
  103. url: app.API.register,
  104. params: formData,
  105. page: this,
  106. isLoadingTxt: '船主注册中...',
  107. isToken:false,
  108. isSubmitting: true,
  109. successFun: true
  110. }).then(res => {
  111. let _this = this
  112. wx.showToast({
  113. title: '注册成功',
  114. icon: 'success',
  115. duration: 1500,
  116. mask:true,
  117. complete: function () {
  118. setTimeout( ()=> {
  119. wx.setStorageSync('name', formData.name); //用户姓名
  120. wx.setStorageSync('nickname', formData.nickname); //船舶号
  121. wx.navigateBack()
  122. }, 1500) //延迟时间
  123. }
  124. })
  125. })
  126. }
  127. },
  128. /**
  129. * 生命周期函数--监听页面初次渲染完成
  130. */
  131. onReady: function () {
  132. },
  133. /**
  134. * 生命周期函数--监听页面显示
  135. */
  136. onShow: function () {
  137. },
  138. /**
  139. * 生命周期函数--监听页面隐藏
  140. */
  141. onHide: function () {
  142. },
  143. /**
  144. * 生命周期函数--监听页面卸载
  145. */
  146. onUnload: function () {
  147. },
  148. /**
  149. * 页面相关事件处理函数--监听用户下拉动作
  150. */
  151. onPullDownRefresh: function () {
  152. },
  153. /**
  154. * 页面上拉触底事件的处理函数
  155. */
  156. onReachBottom: function () {
  157. },
  158. /**
  159. * 用户点击右上角分享
  160. */
  161. onShareAppMessage: function () {
  162. }
  163. })