studentRegistration.js 8.6 KB

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