myData.js 22 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  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. 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. 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. if (_this.data.nolink === true) {
  894. wx.switchTab({
  895. url: '/pages/my/index/index'
  896. })
  897. } else if (_this.data.nolink === false) {
  898. wx.navigateBack({
  899. delta: 1
  900. })
  901. }
  902. }, 2000)
  903. }
  904. })
  905. },
  906. chooseSch() {
  907. const _this = this;
  908. _this.openSel();
  909. },
  910. schoolPickerChange(e) {
  911. this.setData({
  912. ['allData.college']: this.data.schoolItem[e.detail.value].itemcode,
  913. ['allData.collegeName']: this.data.schoolItem[e.detail.value].itemname
  914. })
  915. },
  916. /**
  917. * 打开下拉框
  918. */
  919. openSel() {
  920. this.setData({
  921. selectShow: true,
  922. })
  923. },
  924. /**
  925. * 关闭下拉框
  926. */
  927. closeSel() {
  928. this.setData({
  929. selectShow: false,
  930. vague: [],
  931. inputSch: ''
  932. })
  933. },
  934. ok() {
  935. this.closeSel();
  936. },
  937. /**
  938. * 页面相关事件处理函数--监听用户下拉动作
  939. */
  940. onPullDownRefresh: function () {
  941. },
  942. /**
  943. * 页面上拉触底事件的处理函数
  944. */
  945. onReachBottom: function () {
  946. },
  947. /**
  948. * 用户点击右上角分享
  949. */
  950. onShareAppMessage: function () {
  951. },
  952. schoolInput(e) {
  953. this.setData({
  954. ['allData.college']: e.detail.value
  955. })
  956. },
  957. loadVipSel() {
  958. let _this = this;
  959. App._post_form('wgfillinfo/apiSelectwgfillinfo', 'application/json',
  960. null,
  961. function (res) {
  962. if (res.code === 0) {
  963. _this.setData({
  964. isDev: res.wgFillInfo.isDev
  965. })
  966. }
  967. }
  968. )
  969. },
  970. // 获取已填写的会员信息个数
  971. getNum() {
  972. let id = util.getUserId();
  973. let _this = this;
  974. App._get('member/completeNum/' + id, 'application/json',
  975. null,
  976. function (res) {
  977. if (res.code === 0) {
  978. _this.setData({
  979. formNum: res.data || 0
  980. })
  981. }
  982. }
  983. )
  984. },
  985. })