register.js 5.3 KB

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