myData.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044
  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. console.log('_this.data.u==>?', _this.data.u)
  434. if (_this.data.u.sex) {
  435. let sex = _this.data.u.sex;
  436. console.log('sex==>?', sex)
  437. console.log(gender)
  438. if (gender.length) {
  439. for (let i = 0; i < gender.length; i++) {
  440. if (gender[i].itemcode === sex) {
  441. sexI = i;
  442. }
  443. }
  444. }
  445. }
  446. console.log('sexI==>?', sexI)
  447. _this.setData({
  448. sexArray: gender,
  449. sexIndex: sexI
  450. })
  451. }
  452. })
  453. /**
  454. * 体重
  455. */
  456. App._post_form('bizcatelog/apiSelectBizcatelog/WEIGHTTYPE', '', null, function (res) {
  457. if (res.code === 0) {
  458. let weight = res.dictList
  459. let all = {
  460. itemcode: "",
  461. itemname: "全部"
  462. }
  463. weight.unshift(all)
  464. if (_this.data.u.weighttype) {
  465. if (weight.length) {
  466. for (let i = 0; i < weight.length; i++) {
  467. if (_this.data.u.weighttype === weight[i].itemcode) {
  468. _this.data.weightIndex = i;
  469. break;
  470. }
  471. }
  472. }
  473. }
  474. _this.setData({
  475. weightItem: weight,
  476. weightIndex: _this.data.weightIndex
  477. })
  478. }
  479. })
  480. /**
  481. * 健康证
  482. */
  483. App._post_form('bizcatelog/apiSelectBizcatelog/YF', '', null, function (res) {
  484. if (res.code === 0) {
  485. let healthy = res.dictList
  486. if (_this.data.u.ishealth) {
  487. let health = _this.data.u.ishealth;
  488. if (healthy.length) {
  489. for (let i = 0; i < healthy.length; i++) {
  490. if (healthy[i].itemcode === health) {
  491. _this.data.isHealthyIndex = i;
  492. break;
  493. }
  494. }
  495. }
  496. }
  497. _this.setData({
  498. isHealthy: healthy,
  499. isHealthyIndex: _this.data.isHealthyIndex
  500. })
  501. }
  502. })
  503. /***空闲时间*/
  504. App._post_form('bizcatelog/apiSelectBizcatelog/FREETIME', '', null, function (res) {
  505. if (res.code === 0) {
  506. let FREETIME = res.dictList
  507. if (FREETIME.length) {
  508. _this.data.checkTimeItems = FREETIME;
  509. if (_this.data.u.freetime) {
  510. _this.changeTxt(_this.data.checkTimeItems, _this.data.u.freetime, "freetime")
  511. }
  512. }
  513. }
  514. })
  515. /*** 技能 */
  516. App._post_form('bizcatelog/apiSelectBizcatelog/skill', '', null, function (res) {
  517. if (res.code === 0) {
  518. let skill = res.dictList
  519. if (skill.length) {
  520. _this.data.checkskillItems = skill;
  521. //加载技能
  522. if (_this.data.u.skill) {
  523. _this.changeTxt(_this.data.checkskillItems, _this.data.u.skill, "skill")
  524. }
  525. }
  526. }
  527. })
  528. },
  529. /**
  530. * 加载省份
  531. */
  532. searchProvince() {
  533. let _this = this;
  534. let proId = '';
  535. let prov = '';
  536. App._post_form('areainfo/province', '', null, function (res) {
  537. if (res.code === 0) {
  538. let provice = res.list
  539. _this.data.multiArray[0] = provice;
  540. CityArray0 = provice;
  541. if (_this.data.u.region) {
  542. prov = _this.data.u.province;
  543. if (CityArray0.length) {
  544. for (let i = 0; i < CityArray0.length; i++) {
  545. if (CityArray0[i].areaid === prov) {
  546. _this.data.multiIndex[0] = i;
  547. break;
  548. }
  549. }
  550. }
  551. }
  552. if (prov && _this.data.load === true) {
  553. proId = prov
  554. } else {
  555. //根据默认省,获取默认市
  556. if (_this.data.multiArray[0].length) {
  557. proId = _this.data.multiArray[0][0].areaid;
  558. }
  559. }
  560. _this.loadCity(proId)
  561. }
  562. })
  563. },
  564. //获取市级
  565. loadCity(cid) {
  566. let _this = this;
  567. App._post_form('areainfo/city/' + cid, '', null, function (res) {
  568. if (res.code === 0) {
  569. let city = res.list;
  570. _this.data.multiArray[1] = city;
  571. CityArray1 = city;
  572. if (_this.data.u.region) {
  573. let region = _this.data.u.region;
  574. if (CityArray1.length) {
  575. for (let i = 0; i < CityArray1.length; i++) {
  576. if (CityArray1[i].areaid === region) {
  577. _this.data.multiIndex[1] = i;
  578. break;
  579. }
  580. }
  581. }
  582. let cityId = '';
  583. if (region && _this.data.load === true) {
  584. cityId = region;
  585. } else {
  586. if (_this.data.multiArray[1].length) {
  587. cityId = _this.data.multiArray[1][0].areaid
  588. }
  589. }
  590. _this.loadSchool(cityId)
  591. }
  592. _this.setData({
  593. multiArray: _this.data.multiArray,
  594. multiIndex: _this.data.multiIndex
  595. })
  596. }
  597. })
  598. },
  599. //获取学校
  600. loadSchool(cityId) {
  601. let _this = this;
  602. App._post_form('areainfo/Schoolinfo/' + cityId, '', null, function (res) {
  603. if (res.code === 0) {
  604. let school = []
  605. if (res.dictList.length <= 0) {
  606. school = []
  607. } else {
  608. let college = _this.data.u.college;
  609. school = res.dictList
  610. CityArray2 = school;
  611. if (college && _this.data.load === true) {
  612. for (let i = 0; i < CityArray2.length; i++) {
  613. if (college === CityArray2[i].itemcode) {
  614. _this.data.schIndex = i;
  615. break;
  616. }
  617. }
  618. }
  619. }
  620. _this.setData({
  621. schoolItem: school
  622. //schoolName: _this.data.schoolName?_this.data.schoolName:school[_this.data.schIndex].itemname
  623. //schIndex: _this.data.schIndex
  624. })
  625. }
  626. })
  627. },
  628. /**
  629. * 更新用户数据根据id
  630. */
  631. PushVipInfo() {
  632. wx.showLoading({
  633. title: '加载中...',
  634. })
  635. let _this = this;
  636. let id = util.getUserId();
  637. let parm = {
  638. id
  639. }
  640. App._post_form('member/apiSelectMeberInfo', 'application/json', JSON.stringify(parm),
  641. function (res) {
  642. if (res.code === 0) {
  643. wx.setStorageSync("USER", res.member);
  644. _this.loadUser();
  645. _this.loadSchool(res.member.region)
  646. }
  647. })
  648. },
  649. maskClose(e) {
  650. if (e.currentTarget.dataset) {
  651. let value = e.currentTarget.dataset.type;
  652. if (this.data.inputValue || this.data.checkboxValue.length) {
  653. if (value === "vipname") {
  654. this.setData({
  655. "u.vipname": this.data.inputValue
  656. })
  657. this.data.allData.vipname = this.data.inputValue
  658. } else if (value === "name") {
  659. this.setData({
  660. "u.name": this.data.inputValue
  661. })
  662. this.data.allData.name = this.data.inputValue
  663. } else if (value === "email") {
  664. let regex = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
  665. if (!regex.test(this.data.inputValue)) {
  666. wx.showToast({
  667. title: '请填写正确的邮箱!',
  668. icon: 'none'
  669. })
  670. return;
  671. }
  672. this.setData({
  673. "u.email": this.data.inputValue
  674. })
  675. this.data.allData.email = this.data.inputValue
  676. } else if (value === "height") {
  677. this.setData({
  678. "u.height": this.data.inputValue
  679. })
  680. this.data.allData.height = this.data.inputValue
  681. } else if (value === "dormitoryno") {
  682. this.setData({
  683. "u.dormitoryno": this.data.inputValue
  684. })
  685. this.data.allData.dormitoryno = this.data.inputValue
  686. } else if (value === "idcard") {
  687. 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])$/;
  688. if (!regex.test(this.data.inputValue)) {
  689. wx.showToast({
  690. title: '请填写正确的身份证!',
  691. icon: 'none'
  692. })
  693. return;
  694. }
  695. this.setData({
  696. "u.idcard": this.data.inputValue
  697. })
  698. this.data.allData.idcard = this.data.inputValue
  699. } else if (value === "remarks") {
  700. this.setData({
  701. "u.remarks": this.data.inputValue
  702. })
  703. this.data.allData.remarks = this.data.inputValue
  704. } else if (value === "major") {
  705. this.setData({
  706. "u.major": this.data.inputValue
  707. })
  708. this.data.allData.major = this.data.inputValue
  709. } else if (value === "freetime") {
  710. if (this.data.checkboxValue.length) {
  711. let item = "";
  712. for (let i = 0; i < this.data.checkboxValue.length; i++) {
  713. item += this.data.checkboxValue[i] + ","
  714. }
  715. item = item.substring(0, item.length - 1);
  716. this.data.allData.freetime = item;
  717. this.changeTxt(this.data.checkTimeItems, this.data.allData.freetime, "freetime")
  718. }
  719. } else if (value === "skill") {
  720. if (this.data.checkboxValue.length) {
  721. let item = "";
  722. for (let i = 0; i < this.data.checkboxValue.length; i++) {
  723. item += this.data.checkboxValue[i] + ","
  724. }
  725. item = item.substring(0, item.length - 1);
  726. this.data.allData.skill = item;
  727. this.changeTxt(this.data.checkskillItems, this.data.allData.skill, "skill")
  728. }
  729. }
  730. }
  731. }
  732. this.setData({
  733. maskShow: false,
  734. })
  735. },
  736. checkboxChange: function (e) {
  737. this.data.checkboxValue = e.detail.value
  738. },
  739. bindKeyInput(e) {
  740. this.data.inputValue = e.detail.value;
  741. },
  742. updateInfo(e) {
  743. let _this = this;
  744. _this.data.checkboxValue = [];
  745. if (e.currentTarget.dataset) {
  746. let value = e.currentTarget.dataset;
  747. if (value.mode === "checkbox") {
  748. if (value.type === "freetime") {
  749. _this.setData({
  750. checkboxItems: _this.data.checkTimeItems
  751. })
  752. } else if (value.type === "skill") {
  753. _this.setData({
  754. checkboxItems: _this.data.checkskillItems
  755. })
  756. }
  757. }
  758. _this.setData({
  759. maskShow: true,
  760. maskTitle: value.title,
  761. maskInputPla: '输入' + value.title,
  762. maskInputMode: value.mode,
  763. type: value.type,
  764. inputValue: ''
  765. })
  766. }
  767. },
  768. changeTxt(valueItem, item, type) {
  769. item = item.split(",");
  770. if (item.length) {
  771. let v = "";
  772. for (let i = 0; i < item.length; i++) {
  773. for (let j = 0; j < valueItem.length; j++) {
  774. if (valueItem[j].itemcode == item[i]) {
  775. v += valueItem[j].itemname + ","
  776. }
  777. }
  778. }
  779. v = v.substring(0, v.length - 1);
  780. if (type === "freetime") {
  781. this.setData({
  782. checkboxTxt: v
  783. })
  784. } else if (type === "skill") {
  785. this.setData({
  786. checkboxText: v
  787. })
  788. }
  789. }
  790. },
  791. btnCancel() {
  792. wx.navigateBack();
  793. },
  794. /**
  795. * 生命周期函数--监听页面加载
  796. */
  797. onLoad: function (options) {
  798. let _this = this;
  799. if (Object.keys(options).length > 0) {
  800. if (options.type === "no") {
  801. _this.data.nolink = false;
  802. } else {
  803. _this.data.nolink = true;
  804. }
  805. } else {
  806. _this.data.nolink = true;
  807. }
  808. if (util.UserLoginStatus()) {
  809. _this.loadUser();
  810. }
  811. this.loadVipSel();
  812. this.getNum();
  813. },
  814. /**
  815. * 生命周期函数--监听页面初次渲染完成
  816. */
  817. onReady: function () {
  818. wx.setNavigationBarTitle({
  819. title: '个人资料',
  820. })
  821. },
  822. /**
  823. * 生命周期函数--监听页面显示
  824. */
  825. onShow: function () {
  826. this.data.load = true;
  827. this.data.allData = {};
  828. },
  829. /**
  830. * 生命周期函数--监听页面隐藏
  831. */
  832. onHide: function () { },
  833. btnUpUserInfo() {
  834. let that = this;
  835. //必填校验
  836. if (that.data.u.name == null) {
  837. wx.showToast({
  838. title: '请填写真实姓名',
  839. icon: 'none'
  840. })
  841. return;
  842. }
  843. if (that.data.sexIndex == 0) {
  844. wx.showToast({
  845. title: '请选择性别',
  846. icon: 'none'
  847. })
  848. return;
  849. }
  850. // if (that.data.u.email == '') {
  851. // wx.showToast({
  852. // title: '请填写邮箱',
  853. // icon: 'none'
  854. // })
  855. // return;
  856. // }
  857. if (Object.keys(this.data.allData).length > 0) {
  858. this.data.allData.id = this.data.u.id;
  859. wx.showModal({
  860. title: '请注意',
  861. content: '您已修改资料,是否保存?',
  862. success: function (res) {
  863. if (res.confirm) {
  864. that.updateUserInfo()
  865. }
  866. }
  867. })
  868. } else {
  869. wx.showToast({
  870. title: '没有修改数据!',
  871. icon: 'none'
  872. })
  873. }
  874. },
  875. /**
  876. * 生命周期函数--监听页面卸载
  877. */
  878. onUnload: function () {
  879. },
  880. updateUserInfo() {
  881. let _this = this;
  882. App._post_form('member/apiUpdateMeberInfo',
  883. 'application/json',
  884. JSON.stringify(_this.data.allData),
  885. function (res) {
  886. if (res.code === 0) {
  887. // wx.showLoading({
  888. // title: '保存中...',
  889. // duration: 1000
  890. // })
  891. wx.showToast({
  892. title: '修改成功!',
  893. icon: 'none'
  894. })
  895. setTimeout(() => {
  896. _this.PushVipInfo();
  897. that.getNum();
  898. if (_this.data.nolink === true) {
  899. wx.switchTab({
  900. url: '/pages/my/index/index'
  901. })
  902. } else if (_this.data.nolink === false) {
  903. wx.navigateBack({
  904. delta: 1
  905. })
  906. }
  907. }, 2000)
  908. }
  909. })
  910. },
  911. chooseSch() {
  912. const _this = this;
  913. _this.openSel();
  914. },
  915. schoolPickerChange(e) {
  916. this.setData({
  917. ['allData.college']: this.data.schoolItem[e.detail.value].itemcode,
  918. ['allData.collegeName']: this.data.schoolItem[e.detail.value].itemname
  919. })
  920. },
  921. /**
  922. * 打开下拉框
  923. */
  924. openSel() {
  925. this.setData({
  926. selectShow: true,
  927. })
  928. },
  929. /**
  930. * 关闭下拉框
  931. */
  932. closeSel() {
  933. this.setData({
  934. selectShow: false,
  935. vague: [],
  936. inputSch: ''
  937. })
  938. },
  939. ok() {
  940. this.closeSel();
  941. },
  942. /**
  943. * 页面相关事件处理函数--监听用户下拉动作
  944. */
  945. onPullDownRefresh: function () {
  946. },
  947. /**
  948. * 页面上拉触底事件的处理函数
  949. */
  950. onReachBottom: function () {
  951. },
  952. /**
  953. * 用户点击右上角分享
  954. */
  955. onShareAppMessage: function () {
  956. },
  957. schoolInput(e) {
  958. this.setData({
  959. ['allData.college']: e.detail.value
  960. })
  961. },
  962. loadVipSel() {
  963. let _this = this;
  964. App._post_form('wgfillinfo/apiSelectwgfillinfo', 'application/json',
  965. null,
  966. function (res) {
  967. if (res.code === 0) {
  968. _this.setData({
  969. isDev: res.wgFillInfo.isDev
  970. })
  971. }
  972. }
  973. )
  974. },
  975. // 获取已填写的会员信息个数
  976. getNum() {
  977. let id = util.getUserId();
  978. let _this = this;
  979. App._get('member/completeNum/' + id, {}, res => {
  980. console.log(res);
  981. if (res.code === 0) {
  982. this.setData({
  983. formNum: res.data || 0
  984. })
  985. }
  986. }, err => { }, complete => {
  987. })
  988. },
  989. })