studentRegistration.js 8.5 KB

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