myData.js 22 KB

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