studentRegistration.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. const tools = require('../../utils/tools.js');
  2. const app = require('../../utils/util.js');
  3. Page({
  4. data: {
  5. jobArr: [],
  6. jobtext: '请选择',
  7. kaihutext: '请选择',
  8. kaihuList: [{
  9. name: '高中'
  10. },
  11. {
  12. name: '大专'
  13. },
  14. {
  15. name: '本科'
  16. },
  17. {
  18. name: '硕士'
  19. },
  20. ],
  21. kaihuindex: 0,
  22. nameIsTrue: false, //名字是否填写
  23. cultureIsTrue: false, //文化是否填写
  24. graduationIsTrue: false, //毕业学校
  25. majorIsTrue: false, //所有专业
  26. postIsTrue: false, //现任职务
  27. renzhishijianIsTrue: false,
  28. phoneIsTrue: false, //电话
  29. peixunshijianTrue: false, // 培训时间
  30. nameMessage: '',
  31. tenure: '', //在线时间
  32. peixunTime: '', //培训时间
  33. headmasterText: '请选择任职时间', //
  34. peixunText: '请选择培训时间',
  35. radio: '1',
  36. username: 'asdsadsad',
  37. info: {},
  38. parameter: [{
  39. id: 1,
  40. name: '男',
  41. value: '0',
  42. checked: false
  43. }, {
  44. id: 2,
  45. name: '女',
  46. checked: false,
  47. value: '1',
  48. }],
  49. renzhiDate: '',
  50. postshow: false,
  51. postshow1: false,
  52. errorIsTrue: false,
  53. currentDate: new Date().getTime(),
  54. currentDate1: new Date().getTime(),
  55. minDate: new Date().getTime,
  56. formatter(type, value) {
  57. if (type === 'year') {
  58. return `${value}年`;
  59. } else if (type === 'month') {
  60. return `${value}月`;
  61. }
  62. return value;
  63. },
  64. },
  65. onChange(event) {
  66. this.setData({
  67. radio: event.detail,
  68. });
  69. },
  70. jobChange(e) {
  71. console.log(e)
  72. this.setData({
  73. jobIndex: e.detail.value,
  74. jobtext: this.data.jobArr[e.detail.value].dictLabel
  75. })
  76. },
  77. share() {
  78. this.setData({
  79. show: true
  80. });
  81. },
  82. onClose() {
  83. this.setData({
  84. postshow: false
  85. });
  86. },
  87. onClose1() {
  88. this.setData({
  89. postshow1: false
  90. });
  91. },
  92. onInput(event) {
  93. this.setData({
  94. currentDate: event.detail,
  95. });
  96. },
  97. onInput1(event) {
  98. this.setData({
  99. currentDate1: event.detail,
  100. });
  101. },
  102. formatDate(date) {
  103. date = new Date(date);
  104. return `${date.getFullYear()-1}/${date.getMonth() + 1}/${date.getDate()}`;
  105. },
  106. kaihuListChange(e) {
  107. console.log(e, "8888888888888")
  108. this.setData({
  109. kaihuindex: e.detail.value,
  110. kaihutext: this.data.kaihuList[e.detail.value].name,
  111. })
  112. },
  113. share1() {
  114. this.setData({
  115. postshow: true
  116. });
  117. },
  118. share() {
  119. this.setData({
  120. postshow1: true
  121. });
  122. },
  123. formatDate(date) {
  124. date = new Date(date);
  125. return `${date.getFullYear()-1}/${date.getMonth() + 1}/${date.getDate()}`;
  126. },
  127. onConfirm(event) {
  128. let timeValue = this.timeFormat(new Date(event.detail), "yyyy-MM-dd");
  129. this.setData({
  130. tenure: timeValue,
  131. postshow: false,
  132. headmasterText: ''
  133. });
  134. },
  135. onConfirm1(event) {
  136. let timeValue = this.timeFormat(new Date(event.detail), "yyyy-MM-dd");
  137. this.setData({
  138. peixunTime: timeValue,
  139. postshow1: false,
  140. peixunText: ''
  141. });
  142. },
  143. parameterTap: function (e) {
  144. let that = this
  145. let this_checked = e.currentTarget.dataset.id
  146. let parameterList = this.data.parameter //获取Json数组
  147. for (let i = 0; i < parameterList.length; i++) {
  148. if (parameterList[i].id == this_checked) {
  149. parameterList[i].checked = true; //当前点击的位置为true即选中
  150. } else {
  151. parameterList[i].checked = false; //其他的位置为false
  152. }
  153. }
  154. that.setData({
  155. parameter: parameterList
  156. })
  157. },
  158. formSubmit(e) {
  159. if (!e.detail.value.username) {
  160. this.setData({
  161. nameIsTrue: true
  162. })
  163. } else {
  164. this.setData({
  165. nameIsTrue: false
  166. })
  167. }
  168. let sex = '';
  169. if (this.data.parameter[0].checked) {
  170. sex = this.data.parameter[0].name
  171. this.setData({
  172. errorIsTrue: false
  173. })
  174. } else if (this.data.parameter[1].checked) {
  175. sex = this.data.parameter[1].name
  176. this.setData({
  177. errorIsTrue: false
  178. })
  179. } else {
  180. this.setData({
  181. errorIsTrue: true
  182. })
  183. }
  184. if (!e.detail.value.work) {
  185. this.setData({
  186. workIsTrue: true
  187. })
  188. } else {
  189. this.setData({
  190. workIsTrue: false
  191. })
  192. }
  193. if (!e.detail.value.culture) {
  194. this.setData({
  195. cultureIsTrue: true
  196. })
  197. } else {
  198. this.setData({
  199. cultureIsTrue: false
  200. })
  201. }
  202. if (!e.detail.value.graduation) {
  203. this.setData({
  204. graduationIsTrue: true
  205. })
  206. } else {
  207. this.setData({
  208. graduationIsTrue: false
  209. })
  210. }
  211. if (!e.detail.value.major) {
  212. this.setData({
  213. majorIsTrue: true
  214. })
  215. } else {
  216. this.setData({
  217. majorIsTrue: false
  218. })
  219. }
  220. if (!e.detail.value.post) {
  221. this.setData({
  222. postIsTrue: true
  223. })
  224. } else {
  225. this.setData({
  226. postIsTrue: false
  227. })
  228. }
  229. if (!e.detail.value.phone) {
  230. this.setData({
  231. phoneIsTrue: true
  232. })
  233. } else {
  234. this.setData({
  235. phoneIsTrue: false
  236. })
  237. }
  238. if (!this.data.tenure) {
  239. this.setData({
  240. renzhishijianIsTrue: true
  241. })
  242. } else {
  243. this.setData({
  244. renzhishijianIsTrue: false
  245. })
  246. }
  247. if (!this.data.peixunTime) {
  248. this.setData({
  249. peixunshijianTrue: true
  250. })
  251. } else {
  252. this.setData({
  253. peixunshijianTrue: false
  254. })
  255. }
  256. console.log(this.data.jobArr,this.data.jobIndex, "55555555")
  257. e.detail.value.culture = this.data.kaihuList[this.data.kaihuindex].name;
  258. e.detail.value.studentDuty = this.data.jobtext;
  259. e.detail.value.tenure = this.data.tenure;
  260. e.detail.value.sessionKey = this.data.sessionKey;
  261. let aa = e.detail.value
  262. console.log(aa, "00000000")
  263. if (aa.culture && aa.school && aa.studentDuty && aa.tenure && aa.studentDept) {
  264. wx.request({
  265. url: app.globalData.publicUrl + '/wx/student/upStudent',
  266. method: "post",
  267. data: {
  268. studentDept: aa.studentDept,
  269. culture: aa.culture,
  270. school: aa.school,
  271. studentDuty: aa.studentDuty,
  272. tenure: aa.tenure,
  273. studentPhone: aa.studentPhone,
  274. sessionKey: this.data.sessionKey,
  275. mcajor: aa.mcajor,
  276. },
  277. success: () => {
  278. wx.showModal({
  279. showCancel: false,
  280. content: '报到成功',
  281. success() {
  282. wx.navigateBack({
  283. delta: 1
  284. })
  285. }
  286. })
  287. },
  288. fail: (res) => {
  289. console.log(res)
  290. wx.showModal({
  291. showCancel: false,
  292. content: '报到失败',
  293. success() {
  294. wx.navigateBack({
  295. delta: 1
  296. })
  297. }
  298. })
  299. }
  300. })
  301. } else {
  302. wx.showModal({
  303. showCancel: false,
  304. content: '请补全除了“所学专业”以外的其他信息'
  305. })
  306. }
  307. },
  308. timeFormat(date, fmt) {
  309. let o = {
  310. "M+": date.getMonth() + 1, //月份   
  311. "d+": date.getDate(), //日
  312. "h+": date.getHours(), //小时   
  313. "m+": date.getMinutes(), //分   
  314. "s+": date.getSeconds(), //秒   
  315. "q+": Math.floor((date.getMonth() + 3) / 3), //季度   
  316. "S": date.getMilliseconds() //毫秒   
  317. };
  318. if (/(y+)/.test(fmt))
  319. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  320. for (let k in o)
  321. if (new RegExp("(" + k + ")").test(fmt))
  322. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  323. return fmt;
  324. },
  325. getjob(sessionKey) {
  326. wx.request({
  327. url: app.globalData.publicUrl + '/wx/student/position',
  328. method: "get",
  329. data: {
  330. sessionKey
  331. },
  332. success: (res) => {
  333. let Arr=[];
  334. res.data.data.forEach(item => {
  335. let newdata = {};
  336. newdata.dictLabel = item.dictLabel;
  337. Arr.push(newdata);
  338. });
  339. this.setData({
  340. jobArr:Arr
  341. })
  342. console.log(this.data.jobArr,'我是新组成的数组')
  343. }
  344. })
  345. },
  346. onReady: function () {},
  347. async onLoad() {
  348. const sessionKey = await tools.checkSessionAndLogin();
  349. console.log(sessionKey, "000000");
  350. this.setData({
  351. sessionKey: sessionKey
  352. })
  353. this.getBanner(sessionKey);
  354. this.getjob(sessionKey)
  355. },
  356. getBanner(sessionKey) {
  357. wx.request({
  358. url: app.globalData.publicUrl + '/wx/student/selStudentSessionKeyEcho',
  359. method: "post",
  360. data: {
  361. sessionKey: sessionKey,
  362. },
  363. success: (res) => {
  364. console.log(res.data.data.studentDuty)
  365. if (res.data.code == 0) {
  366. this.data.parameter.forEach(item => {
  367. if (item.value == res.data.data.studentSex) {
  368. item.checked = true;
  369. }
  370. })
  371. this.setData({
  372. info: res.data.data,
  373. parameter: this.data.parameter,
  374. studentDept: res.data.data.studentDept,
  375. jobtext: res.data.data.studentDuty,
  376. kaihutext: res.data.data.culture,
  377. major: res.data.data.major,
  378. tenure: res.data.data.tenure,
  379. studentPhone: res.data.data.studentPhone,
  380. })
  381. }
  382. }
  383. })
  384. }
  385. })