personInfoDetail.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  1. import WxValidate from '../../utils/WxValidate.js';
  2. const app = require('../../utils/util.js');
  3. const request = require('../../utils/request.js');
  4. const COS = require('../../utils/cos.js');
  5. const tool = require('../../utils/tool.js');
  6. Page({
  7. data: {
  8. form: {
  9. tel: '',
  10. height: '',
  11. weight: '',
  12. education: '',
  13. income: '',
  14. marriage: '',
  15. children: '',
  16. assetHouse: '',
  17. assetHouseArea: '',
  18. assetHouseLoan: '',
  19. assetCar: '',
  20. assetCarValue: '',
  21. assetCarLoan: '',
  22. isCommon: '',
  23. controlTime: '',
  24. workStatus: '',
  25. companyNature: '',
  26. company: '',
  27. parents: '',
  28. fatherWork: '',
  29. matherWork: '',
  30. parentAssets: '',
  31. composition: '',
  32. motionState: '',
  33. hobby: ''
  34. },
  35. heightArr: [],
  36. weightArr: [],
  37. educationArr: [],
  38. incomeArr: [],
  39. marriageList: [],
  40. childrenArr: [],
  41. assetHouseArr: [],
  42. assetAreaArr: [],
  43. assetHouseLoanArr: [],
  44. assetCarArr: [],
  45. assetCarValueArr: [],
  46. assetCarLoanArr: [],
  47. isCommonArr: ['没有', '一起'],
  48. controlTimeArr: [],
  49. workStatusArr: [],
  50. companyNatureArr: [],
  51. parentsArr: [],
  52. fatherWorkArr: [],
  53. matherWorkArr: [],
  54. parentAssetsArr: [],
  55. compositionArr: [],
  56. motionStateArr: [],
  57. hobbyArr: []
  58. },
  59. phoneChange(e) {
  60. let tel = 'form.tel'
  61. this.setData({
  62. [tel]: e.detail.value
  63. })
  64. },
  65. heightPicker(e) {
  66. let height = 'form.height'
  67. this.setData({
  68. heightLabel: this.data.heightArr[e.detail.value],
  69. [height]: this.data.heightArrValue[e.detail.value]
  70. })
  71. },
  72. weightPicker(e) {
  73. let weight = 'form.weight'
  74. this.setData({
  75. weightLabel: this.data.weightArr[e.detail.value],
  76. [weight]: this.data.weightArrValue[e.detail.value]
  77. })
  78. },
  79. educationPicker(e) {
  80. let education = 'form.education'
  81. this.setData({
  82. educationLabel: this.data.educationArr[e.detail.value],
  83. [education]: this.data.educationArrValue[e.detail.value]
  84. })
  85. },
  86. incomePicker(e) {
  87. let income = 'form.income'
  88. this.setData({
  89. incomeLabel: this.data.incomeArr[e.detail.value],
  90. [income]: this.data.incomeArrValue[e.detail.value]
  91. })
  92. },
  93. marriageChange(e) {
  94. let marriage = 'form.marriage'
  95. this.setData({
  96. marriageLabel: this.data.marriageList[e.detail.value],
  97. [marriage]: this.data.marriageListValue[e.detail.value]
  98. })
  99. },
  100. childrenChange(e) {
  101. let children = 'form.children'
  102. this.setData({
  103. childrenLabel: this.data.childrenArr[e.detail.value],
  104. [children]: this.data.childrenArrValue[e.detail.value]
  105. })
  106. },
  107. assetHousePickerChange(e) {
  108. console.log(e)
  109. let assetHouse = 'form.assetHouse'
  110. this.setData({
  111. assetHouseLabel: this.data.assetHouseArr[e.detail.value],
  112. [assetHouse]: this.data.assetHouseArrValue[e.detail.value]
  113. })
  114. },
  115. assetAreaPickerChange(e) {
  116. console.log(e)
  117. let assetHouseArea = 'form.assetHouseArea'
  118. this.setData({
  119. assetAreaLabel: this.data.assetAreaArr[e.detail.value],
  120. [assetHouseArea]: this.data.assetAreaArrValue[e.detail.value]
  121. })
  122. },
  123. assetHouseLoanPickerChange(e) {
  124. console.log(this.data.assetHouseLoanArr)
  125. console.log(this.data.assetHouseLoanArrValue)
  126. let assetHouseLoan = 'form.assetHouseLoan'
  127. this.setData({
  128. assetHouseLoanLabel: this.data.assetHouseLoanArr[e.detail.value],
  129. [assetHouseLoan]: this.data.assetHouseLoanArrValue[e.detail.value]
  130. })
  131. },
  132. assetCarPickerChange(e) {
  133. console.log(e)
  134. let assetCar = 'form.assetCar'
  135. this.setData({
  136. assetCarLabel: this.data.assetCarArr[e.detail.value],
  137. [assetCar]: this.data.assetCarArrValue[e.detail.value]
  138. })
  139. },
  140. assetCarValuePickerChange(e) {
  141. console.log(e)
  142. let assetCarValue = 'form.assetCarValue'
  143. this.setData({
  144. assetCarValueLabel: this.data.assetCarValueArr[e.detail.value],
  145. [assetCarValue]: this.data.assetCarValueArrValue[e.detail.value]
  146. })
  147. },
  148. assetCarLoanPickerChange(e) {
  149. console.log(e)
  150. let assetCarLoan = 'form.assetCarLoan'
  151. this.setData({
  152. assetCarLoanLabel: this.data.assetCarLoanArr[e.detail.value],
  153. [assetCarLoan]: this.data.assetCarLoanArrValue[e.detail.value]
  154. })
  155. },
  156. isCommonChange(e) {
  157. let isCommon = 'form.isCommon'
  158. this.setData({
  159. [isCommon]: e.detail.value,
  160. isCommonLabel: this.data.isCommonArr[e.detail.value],
  161. })
  162. },
  163. controlTimeChange(e) {
  164. const items = this.data.controlTimeArr;
  165. const values = e.detail.value;
  166. let controlTime = 'form.controlTime'
  167. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  168. items[i].checked = false
  169. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  170. if (items[i].value === values[j]) {
  171. items[i].checked = true
  172. break
  173. }
  174. }
  175. }
  176. this.setData({
  177. controlTimeArr: this.data.controlTimeArr,
  178. [controlTime]: e.detail.value
  179. })
  180. },
  181. workStatusChange(e) {
  182. console.log(e.detail.value)
  183. const items = this.data.workStatusArr;
  184. const values = e.detail.value;
  185. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  186. items[i].checked = false
  187. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  188. if (items[i].value === values[j]) {
  189. items[i].checked = true
  190. break
  191. }
  192. }
  193. }
  194. let workStatus = 'form.workStatus'
  195. this.setData({
  196. [workStatus]: e.detail.value,
  197. workStatusArr: this.data.workStatusArr
  198. })
  199. },
  200. companyNaturePicker(e) {
  201. let companyNature = 'form.companyNature'
  202. this.setData({
  203. companyNatureLabel: this.data.companyNatureArr[e.detail.value],
  204. [companyNature]: this.data.companyNatureArrValue[e.detail.value]
  205. })
  206. },
  207. companyChange(e) {
  208. let company = 'form.company'
  209. this.setData({
  210. [company]: e.detail.value
  211. })
  212. },
  213. parentsPicker(e) {
  214. let parents = 'form.parents'
  215. this.setData({
  216. parentsLabel: this.data.parentsArr[e.detail.value],
  217. [parents]: this.data.parentsArrValue[e.detail.value]
  218. })
  219. },
  220. fatherworkPicker(e) {
  221. let fatherWork = 'form.fatherWork'
  222. this.setData({
  223. fatherWorkLabel: this.data.fatherWorkArr[e.detail.value],
  224. [fatherWork]: this.data.fatherWorkArrValue[e.detail.value]
  225. })
  226. },
  227. matherworkPicker(e) {
  228. let matherWork = 'form.matherWork'
  229. this.setData({
  230. matherWorkLabel: this.data.matherWorkArr[e.detail.value],
  231. [matherWork]: this.data.matherWorkArrValue[e.detail.value]
  232. })
  233. },
  234. parentAssetsPicker(e) {
  235. let parentAssets = 'form.parentAssets'
  236. this.setData({
  237. parentAssetsLabel: this.data.parentAssetsArr[e.detail.value],
  238. [parentAssets]: this.data.parentAssetsArrValue[e.detail.value]
  239. })
  240. },
  241. compositionChange(e) {
  242. console.log(e.detail.value)
  243. const items = this.data.compositionArr;
  244. const values = e.detail.value;
  245. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  246. items[i].checked = false
  247. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  248. if (items[i].value === values[j]) {
  249. items[i].checked = true
  250. break
  251. }
  252. }
  253. }
  254. let composition = 'form.composition'
  255. this.setData({
  256. compositionArr: this.data.compositionArr,
  257. [composition]: e.detail.value
  258. })
  259. },
  260. figurePicker(e) {
  261. let motionState = 'form.motionState'
  262. this.setData({
  263. motionStateLabel: this.data.motionStateArr[e.detail.value],
  264. [motionState]: this.data.motionStateArrValue[e.detail.value]
  265. })
  266. },
  267. hobbyChange(e) {
  268. console.log(e.detail.value)
  269. const items = this.data.hobbyArr;
  270. const values = e.detail.value;
  271. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  272. items[i].checked = false
  273. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  274. if (items[i].value === values[j]) {
  275. items[i].checked = true
  276. break
  277. }
  278. }
  279. }
  280. console.log(this.data.hobbyArrLabel)
  281. let indexArr = [];
  282. for (let i = 0; i < e.detail.value.length; i++) {
  283. indexArr.push(this.data.hobbyArrLabel.indexOf(e.detail.value[i]))
  284. }
  285. let value = [];
  286. for (let i = 0; i < indexArr.length; i++) {
  287. value.push(this.data.hobbyArrValue[indexArr[i]])
  288. }
  289. let str = '';
  290. for (let i = 0; i < value.length; i++) {
  291. str += value[i] + ','
  292. }
  293. let hobby = 'form.hobby'
  294. this.setData({
  295. hobbyArr: this.data.hobbyArr,
  296. [hobby]: str.slice(0, str.length - 1)
  297. // [hobby]: e.detail.value
  298. })
  299. },
  300. // 获取手机号
  301. // getPhoneNumber(e) {
  302. // tool.isLogin().then(res => {
  303. // console.log(res)
  304. // if (e.detail.errMsg == "getPhoneNumber:ok") {
  305. // wx.request({
  306. // url: app.globalData.publicUrl + '/wx/user/wxbfa171fdd4000e03/phone',
  307. // header: {
  308. // 'content-type': 'application/x-www-form-urlencoded',
  309. // },
  310. // data: {
  311. // sessionKey: this.data.sessionkey,
  312. // signature: res.signature,
  313. // rawData: res.rawData,
  314. // encryptedData: e.detail.encryptedData,
  315. // iv: e.detail.iv
  316. // },
  317. // method: "POST",
  318. // success: (res) => {
  319. // console.log(res, '我是解析的手号');
  320. // let tel = 'form.tel'
  321. // if (res.data.phoneNumber) {
  322. // this.setData({
  323. // [tel]: res.data.phoneNumber
  324. // })
  325. // } else {
  326. // this.setData({
  327. // [tel]: 0
  328. // })
  329. // }
  330. // }
  331. // })
  332. // }
  333. // }).catch(err => {
  334. // wx.showModal({
  335. // title: '您还未登录',
  336. // showCancel: false,
  337. // success(res) {
  338. // if (res.confirm) {
  339. // wx.redirectTo({
  340. // url: '/pages/personal/personal',
  341. // })
  342. // }
  343. // }
  344. // });
  345. // })
  346. // },
  347. getInfos() {
  348. wx.showLoading();
  349. wx.request({
  350. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/info',
  351. method: "get",
  352. success: (res) => {
  353. console.log(res, '我是获取的信息')
  354. let tel = 'form.tel'
  355. let height = 'form.height'
  356. let weight = 'form.weight'
  357. let education = 'form.education'
  358. let income = 'form.income'
  359. let marriage = 'form.marriage'
  360. let children = 'form.children'
  361. let assetHouse = 'form.assetHouse'
  362. let assetHouseArea = 'form.assetHouseArea'
  363. let assetHouseLoan = 'form.assetHouseLoan'
  364. let assetCar = 'form.assetCar'
  365. let assetCarValue = 'form.assetCarValue'
  366. let assetCarLoan = 'form.assetCarLoan'
  367. let isCommon = 'form.isCommon'
  368. let controlTime = 'form.controlTime'
  369. let workStatus = 'form.workStatus'
  370. let companyNature = 'form.companyNature'
  371. let company = 'form.company'
  372. let parents = 'form.parents'
  373. let fatherWork = 'form.fatherWork'
  374. let matherWork = 'form.matherWork'
  375. let parentAssets = 'form.parentAssets'
  376. let composition = 'form.composition'
  377. let motionState = 'form.motionState'
  378. let hobby = 'form.hobby'
  379. tool.formDetails('he_body_height').then(result => {
  380. this.setData({
  381. heightArr: result[0],
  382. heightArrValue: result[1]
  383. })
  384. if (res.data.code == 0) {
  385. for (let i = 0; i < result[0].length; i++) {
  386. if (result[1][i] == res.data.info.height) {
  387. this.setData({
  388. heightLabel: result[0][i],
  389. [height]: result[1][i],
  390. })
  391. }
  392. }
  393. }
  394. })
  395. tool.formDetails('he_body_weight').then(result => {
  396. this.setData({
  397. weightArr: result[0],
  398. weightArrValue: result[1]
  399. })
  400. if (res.data.code == 0) {
  401. for (let i = 0; i < result[0].length; i++) {
  402. if (result[1][i] == res.data.info.weight) {
  403. this.setData({
  404. weightLabel: result[0][i],
  405. [weight]: result[1][i],
  406. })
  407. }
  408. }
  409. }
  410. })
  411. tool.formDetails('he_education').then(result => {
  412. this.setData({
  413. educationArr: result[0],
  414. educationArrValue: result[1]
  415. })
  416. if (res.data.code == 0) {
  417. for (let i = 0; i < result[0].length; i++) {
  418. if (result[1][i] == res.data.info.education) {
  419. this.setData({
  420. educationLabel: result[0][i],
  421. [education]: result[1][i],
  422. })
  423. }
  424. }
  425. }
  426. })
  427. tool.formDetails('he_income').then(result => {
  428. this.setData({
  429. incomeArr: result[0],
  430. incomeArrValue: result[1]
  431. })
  432. if (res.data.code == 0) {
  433. for (let i = 0; i < result[0].length; i++) {
  434. if (result[1][i] == res.data.info.income) {
  435. this.setData({
  436. incomeLabel: result[0][i],
  437. [income]: result[1][i],
  438. })
  439. }
  440. }
  441. }
  442. })
  443. tool.formDetails('he_marriage').then(result => {
  444. this.setData({
  445. marriageList: result[0],
  446. marriageListValue: result[1]
  447. })
  448. if (res.data.code == 0) {
  449. for (let i = 0; i < result[0].length; i++) {
  450. if (result[1][i] == res.data.info.marriage) {
  451. this.setData({
  452. marriageLabel: result[0][i],
  453. [marriage]: result[1][i]
  454. })
  455. }
  456. }
  457. }
  458. })
  459. tool.formDetails('he_children').then(result => {
  460. this.setData({
  461. childrenArr: result[0],
  462. childrenArrValue: result[1]
  463. })
  464. if (res.data.code == 0) {
  465. for (let i = 0; i < result[0].length; i++) {
  466. if (result[1][i] == res.data.info.children) {
  467. this.setData({
  468. childrenLabel: result[0][i],
  469. [children]: result[1][i]
  470. })
  471. }
  472. }
  473. }
  474. })
  475. tool.formDetails('he_asset_house').then(result => {
  476. this.setData({
  477. assetHouseArr: result[0],
  478. assetHouseArrValue: result[1]
  479. })
  480. if (res.data.code == 0) {
  481. for (let i = 0; i < result[0].length; i++) {
  482. if (result[1][i] == res.data.info.assetHouse) {
  483. this.setData({
  484. assetHouseLabel: result[0][i],
  485. [assetHouse]: result[1][i],
  486. })
  487. }
  488. }
  489. }
  490. })
  491. tool.formDetails('he_asset_house_area').then(result => {
  492. this.setData({
  493. assetAreaArr: result[0],
  494. assetAreaArrValue: result[1]
  495. })
  496. if (res.data.code == 0) {
  497. for (let i = 0; i < result[0].length; i++) {
  498. if (result[1][i] == res.data.info.assetHouseArea) {
  499. this.setData({
  500. assetAreaLabel: result[0][i],
  501. [assetHouseArea]: result[1][i],
  502. })
  503. }
  504. }
  505. }
  506. })
  507. tool.formDetails('he_asset_house_loan').then(result => {
  508. this.setData({
  509. assetHouseLoanArr: result[0],
  510. assetHouseLoanArrValue: result[1]
  511. })
  512. if (res.data.code == 0) {
  513. for (let i = 0; i < result[0].length; i++) {
  514. if (result[1][i] == res.data.info.assetHouseLoan) {
  515. this.setData({
  516. assetHouseLoanLabel: result[0][i],
  517. [assetHouseLoan]: result[1][i],
  518. })
  519. }
  520. }
  521. }
  522. })
  523. tool.formDetails('he_asset_car').then(result => {
  524. this.setData({
  525. assetCarArr: result[0],
  526. assetCarArrValue: result[1]
  527. })
  528. if (res.data.code == 0) {
  529. for (let i = 0; i < result[0].length; i++) {
  530. if (result[1][i] == res.data.info.assetCar) {
  531. this.setData({
  532. assetCarLabel: result[0][i],
  533. [assetCar]: result[1][i],
  534. })
  535. }
  536. }
  537. }
  538. })
  539. tool.formDetails('he_asset_car_value').then(result => {
  540. this.setData({
  541. assetCarValueArr: result[0],
  542. assetCarValueArrValue: result[1]
  543. })
  544. if (res.data.code == 0) {
  545. for (let i = 0; i < result[0].length; i++) {
  546. if (result[1][i] == res.data.info.assetCarValue) {
  547. this.setData({
  548. assetCarValueLabel: result[0][i],
  549. [assetCarValue]: result[1][i],
  550. })
  551. }
  552. }
  553. }
  554. })
  555. tool.formDetails('he_asset_car_loan').then(result => {
  556. this.setData({
  557. assetCarLoanArr: result[0],
  558. assetCarLoanArrValue: result[1]
  559. })
  560. if (res.data.code == 0) {
  561. for (let i = 0; i < result[0].length; i++) {
  562. if (result[1][i] == res.data.info.assetCarLoan) {
  563. this.setData({
  564. assetCarLoanLabel: result[0][i],
  565. [assetCarLoan]: result[1][i],
  566. })
  567. }
  568. }
  569. }
  570. })
  571. tool.formDetails('he_control_time').then(result => {
  572. let controlTimeArr = result[0].map((item, index) => {
  573. return Object.assign({}, {
  574. 'name': item,
  575. 'value': item,
  576. 'checked': false
  577. })
  578. })
  579. if (res.data.code == 0 && res.data.info.controlTime) {
  580. let resControlTime = res.data.info.controlTime.split(",");
  581. let resControlTimeIndexArr = [];
  582. for (let i = 0; i < resControlTime.length; i++) {
  583. for (let j = 0; j < result[1].length; j++) {
  584. if (resControlTime[i] == result[1][j]) {
  585. resControlTimeIndexArr.push(j)
  586. }
  587. }
  588. }
  589. let resControlTimeLabel = [];
  590. for (let i = 0; i < resControlTimeIndexArr.length; i++) {
  591. resControlTimeLabel.push(result[0][resControlTimeIndexArr[i]])
  592. }
  593. for (let i = 0; i < resControlTimeLabel.length; i++) {
  594. for (let j = 0; j < controlTimeArr.length; j++) {
  595. if (resControlTimeLabel[i] == controlTimeArr[j].value) {
  596. controlTimeArr[j].checked = true;
  597. }
  598. }
  599. }
  600. this.setData({
  601. [controlTime]: resControlTimeLabel
  602. })
  603. }
  604. this.setData({
  605. controlTimeArr: controlTimeArr,
  606. controlTimeArrLabel: result[0],
  607. controlTimeArrValue: result[1],
  608. })
  609. console.log(this.data.controlTimeArr, '1111111111111')
  610. })
  611. tool.formDetails('he_work_status').then(result => {
  612. let workStatusArr = result[0].map((item, index) => {
  613. return Object.assign({}, {
  614. 'name': item,
  615. 'value': item,
  616. 'checked': false
  617. })
  618. })
  619. if (res.data.code == 0 && res.data.info.workStatus) {
  620. let resWorkStatus = res.data.info.workStatus.split(",");
  621. let resWorkStatusIndexArr = [];
  622. for (let i = 0; i < resWorkStatus.length; i++) {
  623. for (let j = 0; j < result[1].length; j++) {
  624. if (resWorkStatus[i] == result[1][j]) {
  625. resWorkStatusIndexArr.push(j)
  626. }
  627. }
  628. }
  629. let resWorkStatusLabel = [];
  630. for (let i = 0; i < resWorkStatusIndexArr.length; i++) {
  631. resWorkStatusLabel.push(result[0][resWorkStatusIndexArr[i]])
  632. }
  633. for (let i = 0; i < resWorkStatusLabel.length; i++) {
  634. for (let j = 0; j< workStatusArr.length; j++) {
  635. if (resWorkStatusLabel[i] == workStatusArr[j].value) {
  636. workStatusArr[j].checked = true;
  637. }
  638. }
  639. }
  640. this.setData({
  641. [workStatus]: resWorkStatusLabel
  642. })
  643. }
  644. this.setData({
  645. workStatusArr: workStatusArr,
  646. workStatusArrLabel: result[0],
  647. workStatusArrValue: result[1]
  648. })
  649. })
  650. tool.formDetails('he_company_nature').then(result => {
  651. if (res.data.code == 0) {
  652. for (let i = 0; i < result[0].length; i++) {
  653. if (result[1][i] == res.data.info.companyNature) {
  654. this.setData({
  655. companyNatureLabel: result[0][i],
  656. [companyNature]: result[1][i]
  657. })
  658. }
  659. }
  660. }
  661. if (res.data.code == 0) {
  662. for (let i = 0; i < result[0].length; i++) {
  663. if (result[1][i] == res.data.info.fatherWork) {
  664. this.setData({
  665. fatherWorkLabel: result[0][i],
  666. [fatherWork]: result[1][i]
  667. })
  668. }
  669. }
  670. }
  671. if (res.data.code == 0) {
  672. for (let i = 0; i < result[0].length; i++) {
  673. if (result[1][i] == res.data.info.matherWork) {
  674. this.setData({
  675. matherWorkLabel: result[0][i],
  676. [matherWork]: result[1][i]
  677. })
  678. }
  679. }
  680. }
  681. this.setData({
  682. companyNatureArr: result[0],
  683. companyNatureArrValue: result[1],
  684. fatherWorkArr: result[0],
  685. fatherWorkArrValue: result[1],
  686. matherWorkArr: result[0],
  687. matherWorkArrValue: result[1]
  688. })
  689. })
  690. if (res.data.code == 0) {
  691. this.setData({
  692. [tel]: res.data.info.tel,
  693. [company]: res.data.info.company,
  694. [hobby]: res.data.info.hobby,
  695. [isCommon]: res.data.info.isCommon,
  696. isCommonLabel: this.data.isCommonArr[res.data.info.isCommon],
  697. })
  698. }
  699. tool.formDetails('he_parents').then(result => {
  700. this.setData({
  701. parentsArr: result[0],
  702. parentsArrValue: result[1]
  703. })
  704. if (res.data.code == 0) {
  705. for (let i = 0; i < result[0].length; i++) {
  706. if (result[1][i] == res.data.info.parents) {
  707. this.setData({
  708. parentsLabel: result[0][i],
  709. [parents]: result[1][i],
  710. })
  711. }
  712. }
  713. }
  714. })
  715. tool.formDetails('he_parent_assets').then(result => {
  716. this.setData({
  717. parentAssetsArr: result[0],
  718. parentAssetsArrValue: result[1]
  719. })
  720. if (res.data.code == 0) {
  721. for (let i = 0; i < result[0].length; i++) {
  722. if (result[1][i] == res.data.info.parentAssets) {
  723. this.setData({
  724. parentAssetsLabel: result[0][i],
  725. [parentAssets]: result[1][i],
  726. })
  727. }
  728. }
  729. }
  730. })
  731. tool.formDetails('he_composition').then(result => {
  732. let compositionArr = result[0].map((item, index) => {
  733. return Object.assign({}, {
  734. 'name': item,
  735. 'value': item,
  736. 'checked': false
  737. })
  738. })
  739. if (res.data.code == 0 && res.data.info.composition) {
  740. let resComposition = res.data.info.composition.split(",");
  741. let resCompositionIndexArr = [];
  742. for (let i = 0; i < resComposition.length; i++) {
  743. for (let j = 0; j < result[1].length; j++) {
  744. if (resComposition[i] == result[1][j]) {
  745. resCompositionIndexArr.push(j)
  746. }
  747. }
  748. }
  749. let resCompositionLabel = [];
  750. for (let i = 0; i < resCompositionIndexArr.length; i++) {
  751. resCompositionLabel.push(result[0][resCompositionIndexArr[i]])
  752. }
  753. for (let i = 0; i < resCompositionLabel.length; i++) {
  754. for (let j = 0; j < compositionArr.length; j++) {
  755. if (resCompositionLabel[i] == compositionArr[j].value) {
  756. compositionArr[j].checked = true;
  757. }
  758. }
  759. }
  760. this.setData({
  761. [composition]: resCompositionLabel
  762. })
  763. }
  764. this.setData({
  765. compositionArr: compositionArr,
  766. compositionArrLabel: result[0],
  767. compositionArrValue: result[1],
  768. })
  769. })
  770. tool.formDetails('he_sports').then(result => {
  771. console.log(result)
  772. this.setData({
  773. motionStateArr: result[0],
  774. motionStateArrValue: result[1]
  775. })
  776. if (res.data.code == 0) {
  777. for (let i = 0; i < result[0].length; i++) {
  778. if (result[1][i] == res.data.info.motionState) {
  779. console.log(i)
  780. this.setData({
  781. motionStateLabel: result[0][i],
  782. [motionState]: result[1][i],
  783. })
  784. }
  785. }
  786. }
  787. })
  788. tool.formDetails('he_hobby').then(result => {
  789. let hobbyArr = result[0].map((item, index) => {
  790. return Object.assign({}, {
  791. 'name': item,
  792. 'value': item,
  793. 'checked': false
  794. })
  795. })
  796. if (res.data.code == 0 && res.data.info.hobby) {
  797. let reshobby = res.data.info.hobby.split(",");
  798. let reshobbyIndexArr = [];
  799. for (let i = 0; i < reshobby.length; i++) {
  800. for (let j = 0; j < result[1].length; j++) {
  801. if (reshobby[i] == result[1][j]) {
  802. reshobbyIndexArr.push(j)
  803. }
  804. }
  805. }
  806. let reshobbyLabel = [];
  807. for (let i = 0; i < reshobbyIndexArr.length; i++) {
  808. reshobbyLabel.push(result[0][reshobbyIndexArr[i]])
  809. }
  810. for (let i = 0; i < reshobbyLabel.length; i++) {
  811. for (let j = 0; j < hobbyArr.length; j++) {
  812. if (reshobbyLabel[i] == hobbyArr[j].value) {
  813. hobbyArr[j].checked = true;
  814. }
  815. }
  816. }
  817. this.setData({
  818. [hobby]: reshobbyLabel
  819. })
  820. }
  821. this.setData({
  822. hobbyArr: hobbyArr,
  823. hobbyArrLabel: result[0],
  824. hobbyArrValue: result[1]
  825. })
  826. })
  827. },
  828. complete: () => {
  829. wx.hideLoading()
  830. }
  831. })
  832. },
  833. // 提交
  834. formSubmit(e) {
  835. console.log(e)
  836. console.log(this.data.HobbyLabel)
  837. const params = e.detail.value
  838. let controlTime = 'form.controlTime';
  839. let workStatus = 'form.workStatus';
  840. let composition = 'form.composition'
  841. let indexArr = [];
  842. for (let i = 0; i < params.controlTime.length; i++) {
  843. indexArr.push(this.data.controlTimeArrLabel.indexOf(params.controlTime[i]))
  844. }
  845. let value = [];
  846. for (let i = 0; i < indexArr.length; i++) {
  847. value.push(this.data.controlTimeArrValue[indexArr[i]])
  848. }
  849. let str = '';
  850. for (let i = 0; i < value.length; i++) {
  851. str += value[i] + ','
  852. }
  853. let indexArr2 = [];
  854. for (let i = 0; i < params.workStatus.length; i++) {
  855. indexArr2.push(this.data.workStatusArrLabel.indexOf(params.workStatus[i]))
  856. }
  857. let value2 = [];
  858. for (let i = 0; i < indexArr2.length; i++) {
  859. value2.push(this.data.workStatusArrValue[indexArr2[i]])
  860. }
  861. let str2 = '';
  862. for (let i = 0; i < value2.length; i++) {
  863. str2 += value2[i] + ','
  864. }
  865. console.log(this.data.compositionArrLabel)
  866. let indexArr3 = [];
  867. for (let i = 0; i < params.composition.length; i++) {
  868. indexArr3.push(this.data.compositionArrLabel.indexOf(params.composition[i]))
  869. }
  870. let value3 = [];
  871. for (let i = 0; i < indexArr3.length; i++) {
  872. value3.push(this.data.compositionArrValue[indexArr3[i]])
  873. }
  874. let str3 = '';
  875. for (let i = 0; i < value3.length; i++) {
  876. str3 += value3[i] + ','
  877. }
  878. this.setData({
  879. [controlTime]: str.slice(0, str.length - 1),
  880. [workStatus]: str2.slice(0, str2.length - 1),
  881. [composition]: str3.slice(0, str3.length - 1),
  882. // [hobby]: str4.slice(0, str4.length - 1)
  883. })
  884. console.log(this.data.form)
  885. //校验表单
  886. if (!this.WxValidate.checkForm(params)) {
  887. const error = this.WxValidate.errorList[0]
  888. this.showModal(error)
  889. return false
  890. }
  891. wx.request({
  892. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/info',
  893. method: "POST",
  894. header: {
  895. 'content-type': 'application/x-www-form-urlencoded',
  896. },
  897. data: this.data.form,
  898. success: (res) => {
  899. console.log(res)
  900. if (res.data.code == 0) {
  901. wx.showModal({
  902. title: '上传成功',
  903. showCancel: false,
  904. success:(res)=> {
  905. if (res.confirm) {
  906. if(this.data.targetStatus){
  907. wx.redirectTo({
  908. url: '/pages/index/index',
  909. })
  910. }else{
  911. wx.redirectTo({
  912. url: '/pages/targetInfo/targetInfo',
  913. })
  914. }
  915. }
  916. }
  917. });
  918. }
  919. }
  920. })
  921. },
  922. //报错
  923. showModal(error) {
  924. wx.showModal({
  925. content: error.msg,
  926. showCancel: false,
  927. })
  928. },
  929. //验证函数
  930. initValidate() {
  931. const rules = {
  932. tel: {
  933. required: false
  934. },
  935. height: {
  936. required: true
  937. },
  938. weight: {
  939. required: true
  940. },
  941. education: {
  942. required: true
  943. },
  944. income: {
  945. required: true
  946. },
  947. marriage: {
  948. required: true
  949. },
  950. children: {
  951. required: true
  952. },
  953. assetHouse: {
  954. required: true
  955. },
  956. // assetHouseArea: {
  957. // required: true
  958. // },
  959. // assetHouseLoan: {
  960. // required: true
  961. // },
  962. assetCar: {
  963. required: true
  964. },
  965. // assetCarValue: {
  966. // required: true
  967. // },
  968. // assetCarLoan: {
  969. // required: true
  970. // },
  971. isCommon: {
  972. required: true
  973. },
  974. controlTime: {
  975. required: true
  976. },
  977. workStatus: {
  978. required: true
  979. },
  980. companyNature: {
  981. required: true
  982. },
  983. company: {
  984. required: true
  985. },
  986. parents: {
  987. required: true
  988. },
  989. composition: {
  990. required: true
  991. },
  992. motionState: {
  993. required: true
  994. },
  995. hobby: {
  996. required: true
  997. }
  998. // photoUrl: {
  999. // required: true
  1000. // }
  1001. }
  1002. const messages = {
  1003. tel: {
  1004. required: '请输入联系方式呦'
  1005. },
  1006. height: {
  1007. required: '请选择身高呦'
  1008. },
  1009. weight: {
  1010. required: '请选择体重呦'
  1011. },
  1012. education: {
  1013. required: '请选择教育程度呦'
  1014. },
  1015. income: {
  1016. required: '请选择收入呦'
  1017. },
  1018. marriage: {
  1019. required: '请选择婚姻状态呦'
  1020. },
  1021. children: {
  1022. required: '请选择您有没有孩子呦'
  1023. },
  1024. assetHouse: {
  1025. required: '请选择是否买房子呦'
  1026. },
  1027. // assetHouseArea: {
  1028. // required: '请选择房子多大面积'
  1029. // },
  1030. // assetHouseLoan: {
  1031. // required: '请选择房子贷款了没'
  1032. // },
  1033. assetCar: {
  1034. required: '请选择车子情况呦'
  1035. },
  1036. // assetCarValue: {
  1037. // required: '请选择车子的价值'
  1038. // },
  1039. // assetCarLoan: {
  1040. // required: '请选择车子贷款了没'
  1041. // },
  1042. isCommon: {
  1043. required: '请选择是否与父母同住呦'
  1044. },
  1045. controlTime: {
  1046. required: '请选择您的空闲时间呦'
  1047. },
  1048. workStatus: {
  1049. required: '请选择您的工作状态呦'
  1050. },
  1051. companyNature: {
  1052. required: '请选择您的单位性质呦'
  1053. },
  1054. company: {
  1055. required: '请输入您的单位具体名称呦'
  1056. },
  1057. parents: {
  1058. required: '请选择您的父母情况呦'
  1059. },
  1060. composition: {
  1061. required: '请选择有没有兄弟姐妹呦'
  1062. },
  1063. motionState: {
  1064. required: '请选择您是否喜欢运动呦'
  1065. },
  1066. hobby: {
  1067. required: '请选择您的爱好呦'
  1068. }
  1069. // photoUrl: {
  1070. // required: '请上传您的照片'
  1071. // }
  1072. }
  1073. this.WxValidate = new WxValidate(rules, messages)
  1074. },
  1075. async onLoad(options) {
  1076. this.initValidate();
  1077. tool.openidStatus().then(result => {
  1078. this.setData({
  1079. openid: result[0],
  1080. sessionkey: result[1]
  1081. })
  1082. this.getInfos();
  1083. tool.isFinishTargetInfo().then(res => {
  1084. console.log(res)
  1085. this.setData({
  1086. targetStatus: true
  1087. })
  1088. }).catch(err=>{
  1089. console.log(err)
  1090. this.setData({
  1091. targetStatus: false
  1092. })
  1093. })
  1094. })
  1095. },
  1096. // 上传头像
  1097. uploadPhoto() {
  1098. wx.chooseImage({
  1099. count: 1,
  1100. sizeType: ['original', 'compressed'],
  1101. sourceType: ['', 'camera'],
  1102. success: (res) => {
  1103. console.log(res)
  1104. let path = res.tempFilePaths[0];
  1105. console.log(path)
  1106. this.setData({
  1107. carWin_img: path
  1108. })
  1109. this.toCos();
  1110. }
  1111. })
  1112. },
  1113. // 传cos
  1114. toCos() {
  1115. var Bucket = 'yuehe-1257653330';
  1116. var Region = 'ap-beijing';
  1117. var ForcePathStyle = false;
  1118. var prefix = 'https://' + Bucket + '.cos.' + Region + '.myqcloud.com/';
  1119. if (ForcePathStyle) {
  1120. prefix = 'https://cos.' + Region + '.myqcloud.com/' + Bucket + '/';
  1121. }
  1122. var stsCache;
  1123. var getCredentials = (callback) => {
  1124. if (stsCache && Date.now() / 1000 + 30 < stsCache.expiredTime) {
  1125. callback(data.credentials);
  1126. return;
  1127. }
  1128. wx.request({
  1129. method: 'POST',
  1130. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/getCosSts',
  1131. // dataType: 'json',
  1132. success: function (result) {
  1133. console.log(result, '222222222222')
  1134. var credentials = result.data.credential.credentials;
  1135. if (credentials) {
  1136. stsCache = result.data.credential
  1137. } else {
  1138. wx.hideLoading()
  1139. wx.showModal({
  1140. title: '临时密钥获取失败',
  1141. content: JSON.stringify(data),
  1142. showCancel: false
  1143. });
  1144. }
  1145. callback(stsCache && stsCache.credentials);
  1146. },
  1147. error: function (err) {
  1148. wx.hideLoading()
  1149. wx.showModal({
  1150. title: '临时密钥获取失败',
  1151. content: JSON.stringify(err),
  1152. showCancel: false
  1153. });
  1154. }
  1155. });
  1156. };
  1157. // 计算签名
  1158. var getAuthorization = function (options, callback) {
  1159. getCredentials(function (credentials) {
  1160. callback({
  1161. XCosSecurityToken: credentials.sessionToken,
  1162. Authorization: COS({
  1163. SecretId: credentials.tmpSecretId,
  1164. SecretKey: credentials.tmpSecretKey,
  1165. Method: options.Method,
  1166. Pathname: options.Pathname,
  1167. })
  1168. });
  1169. });
  1170. };
  1171. // 上传文件
  1172. var Key = this.data.carWin_img.substr(this.data.carWin_img.lastIndexOf('/') + 1); // 这里指定上传的文件名
  1173. var signPathname = '/';
  1174. if (ForcePathStyle) {
  1175. signPathname = '/' + Bucket + '/';
  1176. }
  1177. getAuthorization({
  1178. Method: 'POST',
  1179. Pathname: signPathname
  1180. }, (AuthData) => {
  1181. var requestTask = wx.uploadFile({
  1182. url: prefix,
  1183. name: 'file',
  1184. filePath: this.data.carWin_img,
  1185. formData: {
  1186. 'key': "face/" + Key,
  1187. 'success_action_status': 200,
  1188. 'Signature': AuthData.Authorization,
  1189. 'x-cos-security-token': AuthData.XCosSecurityToken,
  1190. 'Content-Type': '',
  1191. },
  1192. success: (res) => {
  1193. console.log(res.header.Location)
  1194. let photoUrl = 'form.photoUrl'
  1195. this.setData({
  1196. [photoUrl]: res.header.Location
  1197. })
  1198. // this.tj(params, res.header.Location)
  1199. },
  1200. fail: function () {
  1201. wx.hideLoading()
  1202. wx.showModal({
  1203. title: '上传失败',
  1204. showCancel: false
  1205. });
  1206. }
  1207. });
  1208. requestTask.onProgressUpdate(function (res) {
  1209. console.log('进度:', res.progress);
  1210. });
  1211. });
  1212. }
  1213. })