register.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. // index.js
  2. // 获取应用实例
  3. const app = getApp();
  4. const util = require('../../../utils/jmsUtil.js');
  5. const api = require('../../../api/jms.js');
  6. import moment from 'moment'
  7. Page({
  8. data: {
  9. isAgree:false,
  10. clueId:'',
  11. cityId:'',
  12. dateTimeVisible:false,
  13. startTimeVisible:false,
  14. endTimeVisible:false,
  15. currentDate:moment(new Date()).format('YYYY-MM-DD HH:mm'),
  16. currentTime:moment(new Date()).format('HH:mm'),
  17. region:['','',''],
  18. clueInfo:{
  19. name:'',
  20. tel:'',
  21. idCard:'',
  22. fraName:'',
  23. // company:{
  24. // label:'请选择(必填)',
  25. // value:'',
  26. // },
  27. area:'请选择(必填)',
  28. province:'',
  29. city:'',
  30. district:'',
  31. address:'',
  32. remark:'',
  33. },
  34. selectValue:'',
  35. selectVisible:false,
  36. selectKey:'',
  37. post:'',
  38. fraId:'',
  39. fraDisable:false
  40. },
  41. // 事件处理函数
  42. onLoad(options) {
  43. // this.getCompanyList();
  44. console.log(options);
  45. if(options&&options.farId){
  46. this.setData({
  47. fraId:options.fraId,
  48. 'clueInfo.fraName':options.fraName,
  49. fraDisable:true
  50. })
  51. }
  52. },
  53. checkProBtn: function (e) {
  54. console.log(e.detail.value)
  55. this.setData({
  56. isAgree: true,
  57. })
  58. wx.navigateTo({
  59. url: '/pages/temp/jzxhAppletsUserPro/jzxhAppletsUserPro'
  60. })
  61. },
  62. getCompanyList(){
  63. util.request(api.WxservantGetAllList, {
  64. }, 'GET').then(res=>{
  65. if (res.errno == 0) {
  66. let data=res.data;
  67. let list=[];
  68. data.forEach(item=>{
  69. let obj={
  70. label:item.userName,
  71. value:item.userId
  72. };
  73. list.push(obj);
  74. });
  75. this.setData({
  76. list:list
  77. });
  78. }else{
  79. wx.showToast({
  80. title: res.errmsg,
  81. icon:'none'
  82. })
  83. }
  84. });
  85. },
  86. selectDateTime(){
  87. this.setData({
  88. dateTimeVisible:true
  89. });
  90. },
  91. selectStartTime(){
  92. this.setData({
  93. startTimeVisible:true
  94. });
  95. },
  96. selectEndTime(){
  97. this.setData({
  98. endTimeVisible:true
  99. });
  100. },
  101. hidePicker(){
  102. this.setData({
  103. dateTimeVisible:false
  104. });
  105. },
  106. hideStartPicker(){
  107. this.setData({
  108. startTimeVisible:false
  109. });
  110. },
  111. hideEndPicker(){
  112. this.setData({
  113. endTimeVisible:false
  114. });
  115. },
  116. onDateTimeConfirm(e){
  117. this.setData({
  118. currentDate:e.detail.value,
  119. 'clueInfo.date':e.detail.value,
  120. dateTimeVisible:false
  121. });
  122. },
  123. onStartTimeConfirm(e){
  124. this.setData({
  125. currentTime:e.detail.value,
  126. 'clueInfo.startTime':e.detail.value,
  127. startTimeVisible:false
  128. });
  129. },
  130. onEndTimeConfirm(e){
  131. this.setData({
  132. currentTime:e.detail.value,
  133. 'clueInfo.endTime':e.detail.value,
  134. endTimeVisible:false
  135. });
  136. },
  137. inputClue(e){
  138. let obj=e.currentTarget.dataset.obj;
  139. let item=`clueInfo.${obj}`;
  140. this.setData({
  141. [item]:e.detail.value
  142. });
  143. // console.log(this.data.clueInfo);
  144. },
  145. selectClue(e){
  146. let obj=e.currentTarget.dataset.obj;
  147. this.setData({
  148. selectKey:obj,
  149. selectVisible:true
  150. });
  151. console.log(this.data.selectKey);
  152. },
  153. postSelect(){
  154. this.setData({
  155. postVisible:true
  156. });
  157. },
  158. onPickerConfirm(e){
  159. console.log(e);
  160. let obj={
  161. label:e.detail.value.text,
  162. value:e.detail.value.value
  163. }
  164. this.setData({
  165. 'clueInfo.company':obj,
  166. selectVisible:false
  167. });
  168. },
  169. onPickerCancel(){
  170. this.setData({
  171. selectVisible:false
  172. });
  173. },
  174. bindRegionChange: function (e) {
  175. console.log('picker发送选择改变,携带值为', e.detail.value)
  176. this.setData({
  177. 'clueInfo.area': e.detail.value,
  178. 'clueInfo.province': e.detail.value[0],
  179. 'clueInfo.city': e.detail.value[1],
  180. 'clueInfo.district': e.detail.value[2],
  181. })
  182. },
  183. submitInterview(){
  184. if(this.data.clueInfo.name==''){
  185. wx.showToast({
  186. title: '请输入姓名',
  187. icon:'none'
  188. });
  189. }else if(this.data.clueInfo.tel==''){
  190. wx.showToast({
  191. title: '请输入手机号',
  192. icon:'none'
  193. });
  194. }else if (!/^1\d{10}$/.test(this.data.clueInfo.tel)) {
  195. wx.showToast({
  196. title: '请输入正确的手机号码',
  197. icon:'none'
  198. });
  199. return false;
  200. }else if(this.data.clueInfo.idCard==''){
  201. wx.showToast({
  202. title: '请输入身份证号',
  203. icon:'none'
  204. });
  205. }
  206. else if(!util.validIdCard(this.data.clueInfo.idCard)){
  207. wx.showToast({
  208. title: '身份证号格式不正确',
  209. icon:'none'
  210. });
  211. }else if(this.data.clueInfo.fraName==''){
  212. wx.showToast({
  213. title: '请输入所属公司',
  214. icon:'none'
  215. });
  216. }else if(this.data.clueInfo.area=='请选择(必填)'){
  217. wx.showToast({
  218. title: '请选择地址(省市区)',
  219. icon:'none'
  220. });
  221. }else if(this.data.clueInfo.address==''){
  222. wx.showToast({
  223. title: '请输入详细地址',
  224. icon:'none'
  225. });
  226. }else{
  227. wx.showLoading({
  228. title: '保存中',
  229. })
  230. let params={
  231. name:this.data.clueInfo.name,
  232. tel:this.data.clueInfo.tel,
  233. idCard:this.data.clueInfo.idCard,
  234. fraName:this.data.clueInfo.fraName,
  235. province:this.data.clueInfo.province,
  236. city:this.data.clueInfo.city,
  237. district:this.data.clueInfo.district,
  238. address:this.data.clueInfo.address,
  239. remark:this.data.clueInfo.remark,
  240. fraId:this.data.fraId
  241. }
  242. util.request(api.WxservantAdd,
  243. params
  244. , 'POST').then(res=>{
  245. wx.hideLoading();
  246. if (res.errno == 0) {
  247. // wx.showToast({
  248. // title: '提交成功',
  249. // })
  250. wx.showModal({
  251. title: '提示',
  252. content: '提交成功',
  253. showCancel:false,
  254. complete: (res) => {
  255. if (res.cancel) {
  256. }
  257. if (res.confirm) {
  258. // wx.navigateBack({
  259. // delta:1
  260. // });
  261. // wx.navigateTo({
  262. // url: '/pages/temp/login/login',
  263. // })
  264. wx.redirectTo({
  265. url: '/pages/index/index'
  266. });
  267. }
  268. }
  269. })
  270. }else{
  271. wx.showToast({
  272. title: res.errmsg,
  273. icon:'none'
  274. })
  275. }
  276. }).catch(err=>{
  277. wx.hideLoading();
  278. });
  279. }
  280. },
  281. })