studentRegistration.js 7.7 KB

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