myData.js 22 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. // pages/my/myData/myData.js
  2. var App = getApp()
  3. const util = require('../../../utils/util');
  4. let CityArray0 = [];
  5. let CityArray1 = [];
  6. let CityArray2 = [];
  7. let g1 = [];
  8. let g2 = [];
  9. Page({
  10. /**
  11. * 页面的初始数据
  12. */
  13. data: {
  14. bottomLeft: App.bottomLeft,
  15. load: true,
  16. nodata: util.nodata(),
  17. u: [],
  18. hiddenmodalput: true,
  19. sexArray: [],
  20. sexIndex: 0,
  21. maskShow: false,
  22. inputValue: '',
  23. multiArray: [0, 0],
  24. multiIndex: [0, 0],
  25. schoolItem: [],
  26. schIndex: 0,
  27. isHealthy: [],
  28. isHealthyIndex: 0,
  29. birthday: util.getNowDate(),
  30. birthdayIndex: 0,
  31. nowTime: util.getNowDate(),
  32. gradeIndex: [0, 0],
  33. gradeItem: [],
  34. weightItem: [],
  35. weightIndex: 0,
  36. userphoto: App.appAssetsUrl + '/images/tx.png',
  37. checkTimeItems: [],
  38. checkskillItems: [],
  39. checkboxValue: [],
  40. checkboxTxt: '',
  41. checkboxText: '',
  42. nolink: true,
  43. selectShow: false,
  44. vague: [],
  45. inputSch: '',
  46. graduationDate: '',
  47. /**
  48. * 所有需要提交的数据
  49. */
  50. allData: {
  51. college: '',
  52. province: null,
  53. graduationDate: ''
  54. },
  55. isDev: true //开发环境隐藏"编辑资料"页面的部分数据项
  56. },
  57. /**
  58. * 防止穿透
  59. */
  60. preventTouchMove() {},
  61. //绑定选择器滑动事件 地区
  62. MultiPickerAreaChange: function(e) {
  63. this.data.load = false;
  64. let _this = this;
  65. if (e.detail.column === 0) {
  66. let pid = CityArray0[e.detail.value].areaid
  67. _this.data.multiIndex[0] = e.detail.value;
  68. _this.loadCity(pid);
  69. } else if (e.detail.column === 1) {
  70. _this.data.multiIndex[1] = e.detail.value;
  71. _this.setData({
  72. multiIndex: _this.data.multiIndex
  73. })
  74. }
  75. },
  76. //点击完成修改后 地区
  77. PickerAreaChange: function(e) {
  78. this.data.load = false;
  79. let _this = this;
  80. _this.data.multiIndex[0] = e.detail.value[0]
  81. _this.data.multiIndex[1] = e.detail.value[1]
  82. _this.setData({
  83. multiIndex: _this.data.multiIndex,
  84. ['allData.province']: CityArray0[_this.data.multiIndex[0]].areaid,
  85. ['allData.region']: CityArray1[_this.data.multiIndex[1]].areaid
  86. })
  87. _this.loadSchool(_this.data.allData.region)
  88. },
  89. // 学校选择事件
  90. bindSchChange: function(e) {
  91. this.data.load = false;
  92. this.setData({
  93. schIndex: e.detail.value
  94. })
  95. if (this.data.schoolItem.length > 0) {
  96. this.data.allData.college = this.data.schoolItem[e.detail.value].itemcode
  97. }
  98. },
  99. /**
  100. * 年级 完成
  101. */
  102. pickerSchChange: function(e) {
  103. this.data.load = false;
  104. this.data.gradeIndex[0] = e.detail.value[0]
  105. this.data.gradeIndex[1] = e.detail.value[1]
  106. this.setData({
  107. gradeIndex: this.data.gradeIndex
  108. })
  109. if (this.data.gradeItem) {
  110. this.setData({
  111. ['allData.rank']: this.data.gradeItem[1][e.detail.value[1]].id,
  112. ['allData.grade']: this.data.gradeItem[0][e.detail.value[0]].id
  113. })
  114. }
  115. },
  116. /**
  117. * 体重滑轨完成
  118. */
  119. bindWeightChange: function(e) {
  120. this.data.load = false;
  121. this.setData({
  122. weightIndex: e.detail.value
  123. })
  124. if (this.data.weightItem) {
  125. if (this.data.weightItem[e.detail.value].itemcode) {
  126. this.data.allData.weighttype = this.data.weightItem[e.detail.value].itemcode
  127. }
  128. }
  129. },
  130. /**
  131. * 年级滑轨后
  132. */
  133. MultiPickerSchChange: function(e) {
  134. this.data.load = false;
  135. if (e.detail.column === 0) {
  136. let pid = g1[e.detail.value].id;
  137. let newg2List = [];
  138. for (let i = 0; i < g2.length; i++) {
  139. if (pid === g2[i].pid) {
  140. newg2List.push(g2[i])
  141. }
  142. }
  143. this.data.gradeItem[1] = newg2List
  144. this.setData({
  145. gradeItem: this.data.gradeItem
  146. })
  147. }
  148. },
  149. /**
  150. * 性别滑轨完成
  151. */
  152. bindSexChange: function(e) {
  153. this.setData({
  154. sexIndex: e.detail.value
  155. })
  156. this.data.load = false;
  157. if (this.data.sexArray) {
  158. if (this.data.sexArray[e.detail.value].itemcode) {
  159. this.data.allData.sex = this.data.sexArray[e.detail.value].itemcode
  160. }
  161. }
  162. },
  163. //生日
  164. bindTimeChange: function(e) {
  165. if (e.detail.value) {
  166. this.setData({
  167. birthday: e.detail.value
  168. })
  169. this.data.allData.birthday = e.detail.value
  170. }
  171. },
  172. //毕业时间
  173. bindTimeChange2: function(e) {
  174. if (e.detail.value) {
  175. this.setData({
  176. graduationDate: e.detail.value
  177. })
  178. this.data.allData.graduationDate = e.detail.value
  179. }
  180. console.log(e.detail.value)
  181. },
  182. //健康
  183. bindhisChange: function(e) {
  184. this.setData({
  185. isHealthyIndex: e.detail.value
  186. })
  187. this.data.load = false;
  188. if (this.data.isHealthy) {
  189. this.data.allData.ishealth = this.data.isHealthy[e.detail.value].itemcode
  190. }
  191. },
  192. /**
  193. * 绑定用户信息展示在页面上(普通文本)
  194. */
  195. loadUser() {
  196. // let uinfo = util.getUser();
  197. // console.log(uinfo)
  198. let _this = this;
  199. let id = util.getUserId();
  200. let parm = {
  201. id
  202. }
  203. App._post_form('member/apiSelectMeberInfo', 'application/json', JSON.stringify(parm),
  204. function(res) {
  205. if (res.code === 0) {
  206. wx.setStorageSync("USER", res.member);
  207. let uinfo = res.member;
  208. _this.setData({
  209. u: uinfo,
  210. birthday: uinfo.birthday === "" || uinfo.birthday === null ? '' : uinfo.birthday,
  211. userphoto: uinfo.memberphoto === '' || uinfo.memberphoto === null ?
  212. '{{appAssetsUrl}}/images/tx.png' : uinfo.memberphoto,
  213. ['allData.college']: uinfo.college,
  214. ['allData.collegeName']: uinfo.collegeName,
  215. ['allData.province']: uinfo.province,
  216. ['allData.region']: uinfo.region,
  217. ['allData.rank']: uinfo.rank,
  218. ['allData.grade']: uinfo.grade,
  219. graduationDate: uinfo.graduationDate,
  220. ['allData.graduationDate']:uinfo.graduationDate
  221. })
  222. }
  223. })
  224. this.loadDictionary();
  225. this.searchProvince();
  226. g1 = [{
  227. id: '11',
  228. name: '研究生'
  229. }, {
  230. id: '12',
  231. name: '大学'
  232. }, {
  233. id: '13',
  234. name: '高中'
  235. }, {
  236. id: '14',
  237. name: '初中'
  238. }]
  239. g2 = [{
  240. id: "1101",
  241. name: '研一',
  242. pid: '11'
  243. }, {
  244. id: "1102",
  245. name: '研二',
  246. pid: '11'
  247. }, {
  248. id: "1103",
  249. name: '研三',
  250. pid: '11'
  251. }, {
  252. id: "1201",
  253. name: '大一',
  254. pid: '12'
  255. }, {
  256. id: "1202",
  257. name: '大二',
  258. pid: '12'
  259. }, {
  260. id: "1203",
  261. name: '大三',
  262. pid: '12'
  263. }, {
  264. id: "1204",
  265. name: '大四',
  266. pid: '12'
  267. }, {
  268. id: "1301",
  269. name: '高一',
  270. pid: '13'
  271. }, {
  272. id: "1302",
  273. name: '高二',
  274. pid: '13'
  275. }, {
  276. id: "1303",
  277. name: '高三',
  278. pid: '13'
  279. }, {
  280. id: "1401",
  281. name: '初一',
  282. pid: '14'
  283. }, {
  284. id: "1402",
  285. name: '初二',
  286. pid: '14'
  287. }, {
  288. id: "1403",
  289. name: '初三',
  290. pid: '14'
  291. }]
  292. this.data.gradeItem.push(g1);
  293. let newg2List = [];
  294. let gra = this.data.u.rank;
  295. let rank = "";
  296. rank = this.data.u.grade;
  297. if (rank) {
  298. for (let i = 0; i < g1.length; i++) {
  299. if (g1[i].id === rank) {
  300. this.data.gradeIndex[0] = i;
  301. break;
  302. }
  303. }
  304. } else {
  305. rank = g1[0].id
  306. }
  307. for (let i = 0; i < g2.length; i++) {
  308. if (rank === g2[i].pid) {
  309. newg2List.push(g2[i])
  310. }
  311. }
  312. if (gra) {
  313. for (let i = 0; i < newg2List.length; i++) {
  314. if (newg2List[i].id === gra) {
  315. this.data.gradeIndex[1] = i;
  316. break;
  317. }
  318. }
  319. }
  320. this.data.gradeItem[1] = newg2List;
  321. this.setData({
  322. gradeItem: this.data.gradeItem,
  323. gradeIndex: this.data.gradeIndex
  324. })
  325. wx.hideLoading();
  326. },
  327. changeAvatar() {
  328. let _this = this;
  329. var tempFile;
  330. wx.showActionSheet({
  331. itemList: ['拍照上传', '从相册中选择'],
  332. success(res) {
  333. if (res.tapIndex === 0) {
  334. wx.chooseImage({
  335. count: 1,
  336. sizeType: ['original', 'compressed'],
  337. sourceType: ['camera'],
  338. success(res) {
  339. const tempFilePaths = res.tempFilePaths
  340. wx.uploadFile({
  341. url: App.apiRoot + 'member/addPhoto/' + util
  342. .getUserId(),
  343. filePath: tempFilePaths[0],
  344. name: 'file',
  345. success: function(res) {
  346. if (res.errMsg === "uploadFile:ok") {
  347. wx.showToast({
  348. title: '修改成功',
  349. image: '',
  350. duration: 1500,
  351. mask: false
  352. });
  353. _this.setData({
  354. userphoto: tempFilePaths[0]
  355. })
  356. }
  357. },
  358. function() {
  359. wx.showToast({
  360. title: '修改失败',
  361. icon: 'none',
  362. image: '',
  363. duration: 1500,
  364. mask: false,
  365. });
  366. }
  367. })
  368. }
  369. })
  370. } else if (res.tapIndex === 1) {
  371. wx.chooseImage({
  372. count: 1,
  373. sizeType: ['original', 'compressed'],
  374. sourceType: ['album'],
  375. success(res) {
  376. const tempFilePaths = res.tempFilePaths
  377. wx.uploadFile({
  378. url: App.apiRoot + 'member/addPhoto/' + util
  379. .getUserId(),
  380. filePath: tempFilePaths[0],
  381. name: 'file',
  382. success: function(res) {
  383. if (res.errMsg === "uploadFile:ok") {
  384. wx.showToast({
  385. title: '修改成功',
  386. image: '',
  387. duration: 1500,
  388. mask: false
  389. });
  390. _this.setData({
  391. userphoto: tempFilePaths[0]
  392. })
  393. }
  394. },
  395. function() {
  396. wx.showToast({
  397. title: '修改失败',
  398. icon: 'none',
  399. image: '',
  400. duration: 1500,
  401. mask: false,
  402. success: (result) => {},
  403. fail: () => {},
  404. complete: () => {}
  405. });
  406. }
  407. })
  408. }
  409. })
  410. }
  411. },
  412. fail(res) {}
  413. })
  414. },
  415. /**
  416. * 查询字典项,渲染页面下拉框数据
  417. */
  418. loadDictionary() {
  419. let _this = this;
  420. /**
  421. * 性别
  422. */
  423. App._post_form('bizcatelog/apiSelectBizcatelog/gender', '', null, function(res) {
  424. if (res.code === 0) {
  425. let gender = res.dictList
  426. let all = {
  427. itemcode: "",
  428. itemname: "全部"
  429. }
  430. gender.unshift(all)
  431. let sexI = 0;
  432. if (_this.data.u.sex) {
  433. let sex = _this.data.u.sex;
  434. if (gender.length) {
  435. for (let i = 0; i < gender.length; i++) {
  436. if (gender[i].itemcode === sex) {
  437. sexI = i;
  438. }
  439. }
  440. }
  441. }
  442. _this.setData({
  443. sexArray: gender,
  444. sexIndex: sexI
  445. })
  446. }
  447. })
  448. /**
  449. * 体重
  450. */
  451. App._post_form('bizcatelog/apiSelectBizcatelog/WEIGHTTYPE', '', null, function(res) {
  452. if (res.code === 0) {
  453. let weight = res.dictList
  454. let all = {
  455. itemcode: "",
  456. itemname: "全部"
  457. }
  458. weight.unshift(all)
  459. if (_this.data.u.weighttype) {
  460. if (weight.length) {
  461. for (let i = 0; i < weight.length; i++) {
  462. if (_this.data.u.weighttype === weight[i].itemcode) {
  463. _this.data.weightIndex = i;
  464. break;
  465. }
  466. }
  467. }
  468. }
  469. _this.setData({
  470. weightItem: weight,
  471. weightIndex: _this.data.weightIndex
  472. })
  473. }
  474. })
  475. /**
  476. * 健康证
  477. */
  478. App._post_form('bizcatelog/apiSelectBizcatelog/YF', '', null, function(res) {
  479. if (res.code === 0) {
  480. let healthy = res.dictList
  481. if (_this.data.u.ishealth) {
  482. let health = _this.data.u.ishealth;
  483. if (healthy.length) {
  484. for (let i = 0; i < healthy.length; i++) {
  485. if (healthy[i].itemcode === health) {
  486. _this.data.isHealthyIndex = i;
  487. break;
  488. }
  489. }
  490. }
  491. }
  492. _this.setData({
  493. isHealthy: healthy,
  494. isHealthyIndex: _this.data.isHealthyIndex
  495. })
  496. }
  497. })
  498. /***空闲时间*/
  499. App._post_form('bizcatelog/apiSelectBizcatelog/FREETIME', '', null, function(res) {
  500. if (res.code === 0) {
  501. let FREETIME = res.dictList
  502. if (FREETIME.length) {
  503. _this.data.checkTimeItems = FREETIME;
  504. if (_this.data.u.freetime) {
  505. _this.changeTxt(_this.data.checkTimeItems, _this.data.u.freetime, "freetime")
  506. }
  507. }
  508. }
  509. })
  510. /*** 技能 */
  511. App._post_form('bizcatelog/apiSelectBizcatelog/skill', '', null, function(res) {
  512. if (res.code === 0) {
  513. let skill = res.dictList
  514. if (skill.length) {
  515. _this.data.checkskillItems = skill;
  516. //加载技能
  517. if (_this.data.u.skill) {
  518. _this.changeTxt(_this.data.checkskillItems, _this.data.u.skill, "skill")
  519. }
  520. }
  521. }
  522. })
  523. },
  524. /**
  525. * 加载省份
  526. */
  527. searchProvince() {
  528. let _this = this;
  529. let proId = '';
  530. let prov = '';
  531. App._post_form('areainfo/province', '', null, function(res) {
  532. if (res.code === 0) {
  533. let provice = res.list
  534. _this.data.multiArray[0] = provice;
  535. CityArray0 = provice;
  536. if (_this.data.u.region) {
  537. prov = _this.data.u.province;
  538. if (CityArray0.length) {
  539. for (let i = 0; i < CityArray0.length; i++) {
  540. if (CityArray0[i].areaid === prov) {
  541. _this.data.multiIndex[0] = i;
  542. break;
  543. }
  544. }
  545. }
  546. }
  547. if (prov && _this.data.load === true) {
  548. proId = prov
  549. } else {
  550. //根据默认省,获取默认市
  551. if (_this.data.multiArray[0].length) {
  552. proId = _this.data.multiArray[0][0].areaid;
  553. }
  554. }
  555. _this.loadCity(proId)
  556. }
  557. })
  558. },
  559. //获取市级
  560. loadCity(cid) {
  561. let _this = this;
  562. App._post_form('areainfo/city/' + cid, '', null, function(res) {
  563. if (res.code === 0) {
  564. let city = res.list;
  565. _this.data.multiArray[1] = city;
  566. CityArray1 = city;
  567. if (_this.data.u.region) {
  568. let region = _this.data.u.region;
  569. if (CityArray1.length) {
  570. for (let i = 0; i < CityArray1.length; i++) {
  571. if (CityArray1[i].areaid === region) {
  572. _this.data.multiIndex[1] = i;
  573. break;
  574. }
  575. }
  576. }
  577. let cityId = '';
  578. if (region && _this.data.load === true) {
  579. cityId = region;
  580. } else {
  581. if (_this.data.multiArray[1].length) {
  582. cityId = _this.data.multiArray[1][0].areaid
  583. }
  584. }
  585. _this.loadSchool(cityId)
  586. }
  587. _this.setData({
  588. multiArray: _this.data.multiArray,
  589. multiIndex: _this.data.multiIndex
  590. })
  591. }
  592. })
  593. },
  594. //获取学校
  595. loadSchool(cityId) {
  596. let _this = this;
  597. App._post_form('areainfo/Schoolinfo/' + cityId, '', null, function(res) {
  598. if (res.code === 0) {
  599. let school = []
  600. if (res.dictList.length <= 0) {
  601. school = []
  602. } else {
  603. let college = _this.data.u.college;
  604. school = res.dictList
  605. CityArray2 = school;
  606. if (college && _this.data.load === true) {
  607. for (let i = 0; i < CityArray2.length; i++) {
  608. if (college === CityArray2[i].itemcode) {
  609. _this.data.schIndex = i;
  610. break;
  611. }
  612. }
  613. }
  614. }
  615. _this.setData({
  616. schoolItem: school
  617. //schoolName: _this.data.schoolName?_this.data.schoolName:school[_this.data.schIndex].itemname
  618. //schIndex: _this.data.schIndex
  619. })
  620. }
  621. })
  622. },
  623. /**
  624. * 更新用户数据根据id
  625. */
  626. PushVipInfo() {
  627. wx.showLoading({
  628. title: '加载中...',
  629. })
  630. let _this = this;
  631. let id = util.getUserId();
  632. let parm = {
  633. id
  634. }
  635. App._post_form('member/apiSelectMeberInfo', 'application/json', JSON.stringify(parm),
  636. function(res) {
  637. if (res.code === 0) {
  638. wx.setStorageSync("USER", res.member);
  639. _this.loadUser();
  640. _this.loadSchool(res.member.region)
  641. }
  642. })
  643. },
  644. maskClose(e) {
  645. if (e.currentTarget.dataset) {
  646. let value = e.currentTarget.dataset.type;
  647. if (this.data.inputValue || this.data.checkboxValue.length) {
  648. if (value === "vipname") {
  649. this.setData({
  650. "u.vipname": this.data.inputValue
  651. })
  652. this.data.allData.vipname = this.data.inputValue
  653. } else if (value === "name") {
  654. this.setData({
  655. "u.name": this.data.inputValue
  656. })
  657. this.data.allData.name = this.data.inputValue
  658. } else if (value === "email") {
  659. let regex = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
  660. if (!regex.test(this.data.inputValue)) {
  661. wx.showToast({
  662. title: '请填写正确的邮箱!',
  663. icon: 'none'
  664. })
  665. return;
  666. }
  667. this.setData({
  668. "u.email": this.data.inputValue
  669. })
  670. this.data.allData.email = this.data.inputValue
  671. } else if (value === "height") {
  672. this.setData({
  673. "u.height": this.data.inputValue
  674. })
  675. this.data.allData.height = this.data.inputValue
  676. } else if (value === "dormitoryno") {
  677. this.setData({
  678. "u.dormitoryno": this.data.inputValue
  679. })
  680. this.data.allData.dormitoryno = this.data.inputValue
  681. } else if (value === "idcard") {
  682. let regex = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|[xX])$/;
  683. if (!regex.test(this.data.inputValue)) {
  684. wx.showToast({
  685. title: '请填写正确的身份证!',
  686. icon: 'none'
  687. })
  688. return;
  689. }
  690. this.setData({
  691. "u.idcard": this.data.inputValue
  692. })
  693. this.data.allData.idcard = this.data.inputValue
  694. } else if (value === "remarks") {
  695. this.setData({
  696. "u.remarks": this.data.inputValue
  697. })
  698. this.data.allData.remarks = this.data.inputValue
  699. } else if (value === "major") {
  700. this.setData({
  701. "u.major": this.data.inputValue
  702. })
  703. this.data.allData.major = this.data.inputValue
  704. } else if (value === "freetime") {
  705. if (this.data.checkboxValue.length) {
  706. let item = "";
  707. for (let i = 0; i < this.data.checkboxValue.length; i++) {
  708. item += this.data.checkboxValue[i] + ","
  709. }
  710. item = item.substring(0, item.length - 1);
  711. this.data.allData.freetime = item;
  712. this.changeTxt(this.data.checkTimeItems, this.data.allData.freetime, "freetime")
  713. }
  714. } else if (value === "skill") {
  715. if (this.data.checkboxValue.length) {
  716. let item = "";
  717. for (let i = 0; i < this.data.checkboxValue.length; i++) {
  718. item += this.data.checkboxValue[i] + ","
  719. }
  720. item = item.substring(0, item.length - 1);
  721. this.data.allData.skill = item;
  722. this.changeTxt(this.data.checkskillItems, this.data.allData.skill, "skill")
  723. }
  724. }
  725. }
  726. }
  727. this.setData({
  728. maskShow: false,
  729. })
  730. },
  731. checkboxChange: function(e) {
  732. this.data.checkboxValue = e.detail.value
  733. },
  734. bindKeyInput(e) {
  735. this.data.inputValue = e.detail.value;
  736. },
  737. updateInfo(e) {
  738. let _this = this;
  739. _this.data.checkboxValue = [];
  740. if (e.currentTarget.dataset) {
  741. let value = e.currentTarget.dataset;
  742. if (value.mode === "checkbox") {
  743. if (value.type === "freetime") {
  744. _this.setData({
  745. checkboxItems: _this.data.checkTimeItems
  746. })
  747. } else if (value.type === "skill") {
  748. _this.setData({
  749. checkboxItems: _this.data.checkskillItems
  750. })
  751. }
  752. }
  753. _this.setData({
  754. maskShow: true,
  755. maskTitle: value.title,
  756. maskInputPla: '输入' + value.title,
  757. maskInputMode: value.mode,
  758. type: value.type,
  759. inputValue: ''
  760. })
  761. }
  762. },
  763. changeTxt(valueItem, item, type) {
  764. item = item.split(",");
  765. if (item.length) {
  766. let v = "";
  767. for (let i = 0; i < item.length; i++) {
  768. for (let j = 0; j < valueItem.length; j++) {
  769. if (valueItem[j].itemcode == item[i]) {
  770. v += valueItem[j].itemname + ","
  771. }
  772. }
  773. }
  774. v = v.substring(0, v.length - 1);
  775. if (type === "freetime") {
  776. this.setData({
  777. checkboxTxt: v
  778. })
  779. } else if (type === "skill") {
  780. this.setData({
  781. checkboxText: v
  782. })
  783. }
  784. }
  785. },
  786. /**
  787. * 生命周期函数--监听页面加载
  788. */
  789. onLoad: function(options) {
  790. let _this = this;
  791. if (Object.keys(options).length > 0) {
  792. if (options.type === "no") {
  793. _this.data.nolink = false;
  794. } else {
  795. _this.data.nolink = true;
  796. }
  797. } else {
  798. _this.data.nolink = true;
  799. }
  800. if (util.UserLoginStatus()) {
  801. _this.loadUser();
  802. }
  803. this.loadVipSel();
  804. },
  805. /**
  806. * 生命周期函数--监听页面初次渲染完成
  807. */
  808. onReady: function() {
  809. wx.setNavigationBarTitle({
  810. title: '个人资料',
  811. })
  812. },
  813. /**
  814. * 生命周期函数--监听页面显示
  815. */
  816. onShow: function() {
  817. this.data.load = true;
  818. this.data.allData = {};
  819. },
  820. /**
  821. * 生命周期函数--监听页面隐藏
  822. */
  823. onHide: function() {},
  824. btnUpUserInfo() {
  825. let that = this;
  826. //必填校验
  827. if (that.data.u.name == null) {
  828. wx.showToast({
  829. title: '请填写真实姓名',
  830. icon: 'none'
  831. })
  832. return;
  833. }
  834. if (that.data.sexIndex == 0) {
  835. wx.showToast({
  836. title: '请选择性别',
  837. icon: 'none'
  838. })
  839. return;
  840. }
  841. // if (that.data.u.email == '') {
  842. // wx.showToast({
  843. // title: '请填写邮箱',
  844. // icon: 'none'
  845. // })
  846. // return;
  847. // }
  848. if (Object.keys(this.data.allData).length > 0) {
  849. this.data.allData.id = this.data.u.id;
  850. wx.showModal({
  851. title: '请注意',
  852. content: '您已修改资料,是否保存?',
  853. success: function(res) {
  854. if (res.confirm) {
  855. that.updateUserInfo()
  856. }
  857. }
  858. })
  859. } else {
  860. wx.showToast({
  861. title: '没有修改数据!',
  862. icon: 'none'
  863. })
  864. }
  865. },
  866. /**
  867. * 生命周期函数--监听页面卸载
  868. */
  869. onUnload: function() {
  870. },
  871. updateUserInfo() {
  872. let _this = this;
  873. App._post_form('member/apiUpdateMeberInfo',
  874. 'application/json',
  875. JSON.stringify(_this.data.allData),
  876. function(res) {
  877. if (res.code === 0) {
  878. // wx.showLoading({
  879. // title: '保存中...',
  880. // duration: 1000
  881. // })
  882. wx.showToast({
  883. title: '修改成功!',
  884. icon: 'none'
  885. })
  886. setTimeout(() =>{
  887. _this.PushVipInfo();
  888. if (_this.data.nolink === true) {
  889. wx.switchTab({
  890. url: '/pages/my/index/index'
  891. })
  892. } else if (_this.data.nolink === false) {
  893. wx.navigateBack({
  894. delta: 1
  895. })
  896. }
  897. },2000)
  898. }
  899. })
  900. },
  901. chooseSch() {
  902. const _this = this;
  903. _this.openSel();
  904. },
  905. schoolPickerChange(e) {
  906. this.setData({
  907. ['allData.college']: this.data.schoolItem[e.detail.value].itemcode,
  908. ['allData.collegeName']: this.data.schoolItem[e.detail.value].itemname
  909. })
  910. },
  911. /**
  912. * 打开下拉框
  913. */
  914. openSel() {
  915. this.setData({
  916. selectShow: true,
  917. })
  918. },
  919. /**
  920. * 关闭下拉框
  921. */
  922. closeSel() {
  923. this.setData({
  924. selectShow: false,
  925. vague: [],
  926. inputSch: ''
  927. })
  928. },
  929. ok() {
  930. this.closeSel();
  931. },
  932. /**
  933. * 页面相关事件处理函数--监听用户下拉动作
  934. */
  935. onPullDownRefresh: function() {
  936. },
  937. /**
  938. * 页面上拉触底事件的处理函数
  939. */
  940. onReachBottom: function() {
  941. },
  942. /**
  943. * 用户点击右上角分享
  944. */
  945. onShareAppMessage: function() {
  946. },
  947. schoolInput(e) {
  948. this.setData({
  949. ['allData.college']: e.detail.value
  950. })
  951. },
  952. loadVipSel() {
  953. let _this = this;
  954. App._post_form('wgfillinfo/apiSelectwgfillinfo', 'application/json',
  955. null,
  956. function(res) {
  957. if (res.code === 0) {
  958. _this.setData({
  959. isDev: res.wgFillInfo.isDev
  960. })
  961. }
  962. }
  963. )
  964. }
  965. })