myData.js 22 KB

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