targetInfo.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. import WxValidate from '../../utils/WxValidate.js';
  2. const app = require('../../utils/util.js');
  3. const tool = require('../../utils/tool.js');
  4. Page({
  5. data: {
  6. form: {
  7. ageMin: '',
  8. ageMax: '',
  9. heightMin: '',
  10. heightMax: '',
  11. education: '',
  12. income: '',
  13. nativePlace: '',
  14. marriage: '',
  15. assetHouse: '',
  16. assetHouseArea: '',
  17. // assetHouseLoan: '',
  18. assetCar: '',
  19. assetCarValue: '',
  20. // assetCarLoan: '',
  21. constellation: '',
  22. workStatus: '',
  23. companyNature: '',
  24. parentAssets: '',
  25. composition: '',
  26. isCommon: '',
  27. id: ''
  28. },
  29. educationArr: [],
  30. incomeArr: [],
  31. nativePlaceArr: [],
  32. marriageArr: [],
  33. constellationArr: [],
  34. workStatusArr: [],
  35. assetHouseArr: ['咋的都行', '租房', '购房'],
  36. assetHouseAreaArr: [],
  37. // assetHouseLoanArr: ['有', '没有', '咋的都行'],
  38. assetCarArr: ['咋的都行', '有', '没有'],
  39. assetCarValueArr: [],
  40. // assetCarLoanArr: ['不行', '行', '咋的都行'],
  41. companyNatureArr: [],
  42. parentAssetsArr: [],
  43. compositionArr: [],
  44. isCommonArr: ['咋的都行','愿意', '不愿意',]
  45. },
  46. ageMinChange(e) {
  47. let ageMin = 'form.ageMin'
  48. this.setData({
  49. [ageMin]: e.detail.value
  50. })
  51. },
  52. ageMaxChange(e) {
  53. let ageMax = 'form.ageMax'
  54. this.setData({
  55. [ageMax]: e.detail.value
  56. })
  57. },
  58. heightMinChange(e) {
  59. let heightMin = 'form.heightMin'
  60. this.setData({
  61. [heightMin]: e.detail.value
  62. })
  63. },
  64. heightMaxChange(e) {
  65. let heightMax = 'form.heightMax'
  66. this.setData({
  67. [heightMax]: e.detail.value
  68. })
  69. },
  70. educationPicker(e) {
  71. let education = 'form.education'
  72. this.setData({
  73. educationLabel: this.data.educationArr[e.detail.value],
  74. [education]: this.data.educationArrValue[e.detail.value]
  75. })
  76. },
  77. incomePicker(e) {
  78. let income = 'form.income'
  79. this.setData({
  80. incomeLabel: this.data.incomeArr[e.detail.value],
  81. [income]: this.data.incomeArrValue[e.detail.value]
  82. })
  83. },
  84. nativePlacePicker(e) {
  85. let nativePlace = 'form.nativePlace';
  86. this.setData({
  87. nativePlaceLabel: this.data.nativePlaceArr[e.detail.value],
  88. [nativePlace]: this.data.nativePlaceArrValue[e.detail.value],
  89. })
  90. },
  91. marriageChange(e) {
  92. let marriage = 'form.marriage';
  93. this.setData({
  94. marriageLabel: this.data.marriageArr[e.detail.value],
  95. [marriage]: this.data.marriageArrValue[e.detail.value]
  96. })
  97. },
  98. assetHousePickerChange(e) {
  99. let assetHouse = 'form.assetHouse'
  100. this.setData({
  101. assetHouseLabel: this.data.assetHouseArr[e.detail.value],
  102. [assetHouse]: this.data.assetHouseArrValue[e.detail.value]
  103. })
  104. // let assetHouse = 'form.assetHouse';
  105. // this.setData({
  106. // assetHouseLabel: this.data.assetHouseArr[e.detail.value]
  107. // })
  108. // if (e.detail.value != 2) {
  109. // this.setData({
  110. // [assetHouse]: e.detail.value
  111. // })
  112. // }
  113. },
  114. assetHouseAreaPickerChange(e) {
  115. let assetHouseArea = 'form.assetHouseArea'
  116. this.setData({
  117. assetHouseAreaLabel: this.data.assetHouseAreaArr[e.detail.value],
  118. [assetHouseArea]: this.data.assetHouseAreaArrValue[e.detail.value]
  119. })
  120. },
  121. // assetHouseLoanPickerChange(e) {
  122. // let assetHouseLoan = 'form.assetHouseLoan';
  123. // this.setData({
  124. // assetHouseLoanLabel: this.data.assetHouseLoanArr[e.detail.value]
  125. // })
  126. // if (e.detail.value != 2) {
  127. // this.setData({
  128. // [assetHouseLoan]: e.detail.value
  129. // })
  130. // }
  131. // },
  132. assetCarPickerChange(e) {
  133. console.log(e.detail.value)
  134. console.log(this.data.assetCarArr[e.detail.value])
  135. let assetCar = 'form.assetCar';
  136. this.setData({
  137. assetCarLabel: this.data.assetCarArr[e.detail.value],
  138. [assetCar]: e.detail.value
  139. })
  140. // if (e.detail.value != 2) {
  141. // this.setData({
  142. // [assetCar]: e.detail.value
  143. // })
  144. // }
  145. },
  146. assetCarValuePickerChange(e) {
  147. let assetCarValue = 'form.assetCarValue'
  148. this.setData({
  149. assetCarValueLabel: this.data.assetCarValueArr[e.detail.value],
  150. [assetCarValue]: this.data.assetCarValueArrValue[e.detail.value]
  151. })
  152. },
  153. // assetCarLoanPickerChange(e) {
  154. // let assetCarLoan = 'form.assetCarLoan';
  155. // this.setData({
  156. // assetCarLoanLabel: this.data.assetCarLoanArr[e.detail.value]
  157. // })
  158. // if (e.detail.value != 2) {
  159. // this.setData({
  160. // [assetCarLoan]: e.detail.value
  161. // })
  162. // }
  163. // },
  164. constellationPicker(e) {
  165. console.log(e.detail.value)
  166. const items = this.data.constellationArr;
  167. const values = e.detail.value;
  168. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  169. items[i].checked = false
  170. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  171. if (items[i].value === values[j]) {
  172. items[i].checked = true
  173. break
  174. }
  175. }
  176. }
  177. let constellation = 'form.constellation'
  178. this.setData({
  179. constellationArr: this.data.constellationArr,
  180. [constellation]: e.detail.value
  181. })
  182. },
  183. workStatusChange(e) {
  184. console.log(e.detail.value)
  185. const items = this.data.workStatusArr;
  186. const values = e.detail.value;
  187. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  188. items[i].checked = false
  189. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  190. if (items[i].value === values[j]) {
  191. items[i].checked = true
  192. break
  193. }
  194. }
  195. }
  196. let workStatus = 'form.workStatus'
  197. this.setData({
  198. workStatusArr: this.data.workStatusArr,
  199. [workStatus]: e.detail.value
  200. })
  201. },
  202. companyNaturePicker: function (e) {
  203. // let companyNature = 'form.companyNature'
  204. // this.setData({
  205. // companyNatureLabel: this.data.companyNatureArr[e.detail.value],
  206. // [companyNature]: this.data.companyNatureArrValue[e.detail.value]
  207. // })
  208. console.log(e.detail.value)
  209. const items = this.data.companyNatureArr;
  210. const values = e.detail.value;
  211. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  212. items[i].checked = false
  213. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  214. if (items[i].value === values[j]) {
  215. items[i].checked = true
  216. break
  217. }
  218. }
  219. }
  220. let companyNature = 'form.companyNature'
  221. this.setData({
  222. companyNatureArr: this.data.companyNatureArr,
  223. [companyNature]: e.detail.value
  224. })
  225. },
  226. parentAssetsPicker(e) {
  227. let parentAssets = 'form.parentAssets'
  228. this.setData({
  229. parentAssetsLabel: this.data.parentAssetsArr[e.detail.value],
  230. [parentAssets]: this.data.parentAssetsArrValue[e.detail.value]
  231. })
  232. },
  233. compositionPicker(e) {
  234. let composition = 'form.composition'
  235. this.setData({
  236. [composition]: this.data.compositionArrValue[e.detail.value],
  237. compositionLabel: this.data.compositionArr[e.detail.value]
  238. })
  239. },
  240. isCommonPicker(e) {
  241. console.log(e)
  242. let isCommon = 'form.isCommon'
  243. this.setData({
  244. [isCommon]: e.detail.value,
  245. isCommonLabel: this.data.isCommonArr[e.detail.value]
  246. })
  247. },
  248. getInfos() {
  249. wx.showLoading();
  250. wx.request({
  251. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/standard',
  252. method: "get",
  253. success: (res) => {
  254. console.log(res, '我是获取的信息')
  255. let ageMin = 'form.ageMin';
  256. let ageMax = 'form.ageMax';
  257. let heightMin = 'form.heightMin';
  258. let heightMax = 'form.heightMax';
  259. let income = 'form.income';
  260. let nativePlace = 'form.nativePlace';
  261. let education = 'form.education';
  262. let marriage = 'form.marriage';
  263. let assetHouse = 'form.assetHouse';
  264. let assetHouseArea = 'form.assetHouseArea';
  265. // let assetHouseLoan = 'form.assetHouseLoan';
  266. let assetCar = 'form.assetCar';
  267. let assetCarValue = 'form.assetCarValue';
  268. // let assetCarLoan = 'form.assetCarLoan';
  269. let constellation = 'form.constellation';
  270. let workStatus = 'form.workStatus';
  271. let companyNature = 'form.companyNature';
  272. let composition = 'form.composition';
  273. let parentAssets = 'form.parentAssets';
  274. let isCommon = 'form.isCommon';
  275. let id = 'form.id'
  276. if (res.data.code == 0) {
  277. this.setData({
  278. [ageMin]: res.data.standard.ageMin,
  279. [ageMax]: res.data.standard.ageMax,
  280. [heightMin]: res.data.standard.heightMin,
  281. [heightMax]: res.data.standard.heightMax,
  282. // nativePlaceLabel: this.data.nativePlaceArr[res.data.standard.nativePlace],
  283. // [nativePlace]: res.data.standard.nativePlace,
  284. // marriageLabel: this.data.marriageArr[res.data.standard.marriage],
  285. // [marriage]: res.data.standard.marriage,
  286. // assetHouseLabel: this.data.assetHouseArr[res.data.standard.assetHouse],
  287. // [assetHouse]: res.data.standard.assetHouse,
  288. assetHouseAreaLabel: this.data.assetHouseAreaArr[res.data.standard.assetHouseArea],
  289. [assetHouseArea]: res.data.standard.assetHouseArea,
  290. // assetHouseLoanLabel: this.data.assetHouseLoanArr[res.data.standard.assetHouseLoan],
  291. // [assetHouseLoan]: res.data.standard.assetHouseLoan,
  292. assetCarLabel: this.data.assetCarArr[res.data.standard.assetCar],
  293. [assetCar]: res.data.standard.assetCar,
  294. // assetCarLoanLabel: this.data.assetCarLoanArr[res.data.standard.assetCarLoan],
  295. // [assetCarLoan]: res.data.standard.assetCarLoan,
  296. compositionLabel: this.data.compositionArr[res.data.standard.composition],
  297. [composition]: res.data.standard.composition,
  298. isCommonLabel: this.data.isCommonArr[res.data.standard.isCommon],
  299. [isCommon]: res.data.standard.isCommon,
  300. [id]: res.data.standard.id
  301. })
  302. }
  303. tool.formDetails('he_is_no').then(result => {
  304. this.setData({
  305. nativePlaceArr: ['咋的都行'].concat(result[0]),
  306. nativePlaceArrValue: ['0'].concat(result[1]),
  307. })
  308. if (res.data.code == 0) {
  309. for (let i = 0; i < ['0'].concat(result[1]).length; i++) {
  310. if (res.data.standard.nativePlace == ['0'].concat(result[1])[i]) {
  311. this.setData({
  312. nativePlaceLabel: ['咋的都行'].concat(result[0])[i],
  313. [nativePlace]: res.data.standard.nativePlace
  314. })
  315. }
  316. }
  317. }
  318. })
  319. tool.formDetails('he_divorce').then(result => {
  320. console.log(result)
  321. this.setData({
  322. marriageArr: ['咋的都行'].concat(result[0]),
  323. marriageArrValue: ['0'].concat(result[1]),
  324. })
  325. if (res.data.code == 0) {
  326. for (let i = 0; i < [''].concat(result[1]).length; i++) {
  327. if (res.data.standard.marriage == ['0'].concat(result[1])[i]) {
  328. this.setData({
  329. marriageLabel: ['咋的都行'].concat(result[0])[i],
  330. [marriage]: res.data.standard.marriage
  331. })
  332. }
  333. }
  334. }
  335. })
  336. tool.formDetails('he_education').then(result => {
  337. let oArr = [];
  338. for (let i = 0; i < result[0].length; i++) {
  339. oArr.push(result[0][i].concat('以上'))
  340. }
  341. this.setData({
  342. educationArr: ['咋的都行'].concat(oArr),
  343. educationArrValue: ['0'].concat(result[1]),
  344. })
  345. if (res.data.code == 0) {
  346. for (let i = 0; i < ['0'].concat(result[1]).length; i++) {
  347. if (res.data.standard.education == ['0'].concat(result[1])[i]) {
  348. this.setData({
  349. educationLabel: ['咋的都行'].concat(oArr)[i],
  350. [education]: res.data.standard.education
  351. })
  352. }
  353. }
  354. }
  355. })
  356. tool.formDetails('he_income').then(result => {
  357. this.setData({
  358. incomeArr: ['咋的都行'].concat(result[0]),
  359. incomeArrValue: ['0'].concat(result[1])
  360. })
  361. if (res.data.code == 0) {
  362. for (let i = 0; i < [''].concat(result[1]).length; i++) {
  363. if (res.data.standard.income == ['0'].concat(result[1])[i]) {
  364. this.setData({
  365. incomeLabel: ['咋的都行'].concat(result[0])[i],
  366. [income]: res.data.standard.income
  367. })
  368. }
  369. }
  370. }
  371. })
  372. tool.formDetails('he_asset_house').then(result => {
  373. this.setData({
  374. assetHouseArr: ['咋的都行'].concat(result[0]),
  375. assetHouseArrValue: ['0'].concat(result[1])
  376. })
  377. if (res.data.code == 0) {
  378. for (let i = 0; i < [''].concat(result[1]).length; i++) {
  379. if (res.data.standard.assetHouse == ['0'].concat(result[1])[i]) {
  380. this.setData({
  381. assetHouseLabel: ['咋的都行'].concat(result[0])[i],
  382. [assetHouse]: res.data.standard.assetHouse
  383. })
  384. }
  385. }
  386. }
  387. // if (res.data.code==0) {
  388. // for (let i = 0; i < result[0].length; i++) {
  389. // if (result[1][i] == res.data.info.assetHouse) {
  390. // this.setData({
  391. // assetHouseLabel: result[0][i],
  392. // [assetHouse]: result[1][i],
  393. // })
  394. // }
  395. // }
  396. // }
  397. })
  398. tool.formDetails('he_asset_house_area').then(result => {
  399. this.setData({
  400. assetHouseAreaArr: ['咋的都行'].concat(result[0]),
  401. assetHouseAreaArrValue: ['0'].concat(result[1])
  402. })
  403. if (res.data.code == 0) {
  404. for (let i = 0; i < [''].concat(result[1]).length; i++) {
  405. if (res.data.standard.assetHouseArea == ['0'].concat(result[1])[i]) {
  406. this.setData({
  407. assetHouseAreaLabel: ['咋的都行'].concat(result[0])[i],
  408. [assetHouseArea]: res.data.standard.assetHouseArea
  409. })
  410. }
  411. }
  412. }
  413. })
  414. tool.formDetails('he_asset_car_value').then(result => {
  415. this.setData({
  416. assetCarValueArr: ['咋的都行'].concat(result[0]),
  417. assetCarValueArrValue: ['0'].concat(result[1])
  418. })
  419. if (res.data.code == 0) {
  420. for (let i = 0; i < [''].concat(result[1]).length; i++) {
  421. if (res.data.standard.assetCarValue == ['0'].concat(result[1])[i]) {
  422. this.setData({
  423. assetCarValueLabel: ['咋的都行'].concat(result[0])[i],
  424. [assetCarValue]: res.data.standard.assetCarValue
  425. })
  426. }
  427. }
  428. }
  429. })
  430. tool.formDetails('he_astrology').then(result => {
  431. let constellationArr = result[0].map((item, index) => {
  432. return Object.assign({}, {
  433. 'name': item,
  434. 'value': item,
  435. 'checked': false
  436. })
  437. })
  438. console.log(result);
  439. if (res.data.code == 0 && res.data.standard.constellation) {
  440. let resComposition = res.data.standard.constellation.split(",");
  441. console.log(resComposition, '我是拆分完的星座值')
  442. let resCompositionIndexArr = [];
  443. for (let i = 0; i < resComposition.length; i++) {
  444. for (let j = 0; j < result[1].length; j++) {
  445. if (resComposition[i] == result[1][j]) {
  446. console.log(i)
  447. console.log(j)
  448. resCompositionIndexArr.push(j)
  449. }
  450. }
  451. }
  452. console.log(resCompositionIndexArr)
  453. let resCompositionLabel = [];
  454. for (let i = 0; i < resCompositionIndexArr.length; i++) {
  455. resCompositionLabel.push(result[0][resCompositionIndexArr[i]])
  456. }
  457. console.log(constellationArr)
  458. for (let i = 0; i < resCompositionLabel.length; i++) {
  459. for (let j = 0; j < constellationArr.length; j++) {
  460. if (resCompositionLabel[i] == constellationArr[j].name) {
  461. constellationArr[j].checked = true;
  462. }
  463. }
  464. }
  465. this.setData({
  466. [constellation]: resCompositionLabel
  467. })
  468. }
  469. this.setData({
  470. constellationArr: constellationArr,
  471. constellationArrLabel: result[0],
  472. constellationArrValue: result[1],
  473. })
  474. })
  475. tool.formDetails('he_work_status').then(result => {
  476. let workStatusArr = result[0].map((item, index) => {
  477. return Object.assign({}, {
  478. 'name': item,
  479. 'value': item,
  480. 'checked': false
  481. })
  482. })
  483. if (res.data.code == 0 && res.data.standard.workStatus) {
  484. let resWorkStatus = res.data.standard.workStatus.split(",");
  485. let resWorkStatusIndexArr = [];
  486. for (let i = 0; i < resWorkStatus.length; i++) {
  487. for (let j = 0; j < result[1].length; j++) {
  488. if (resWorkStatus[i] == result[1][j]) {
  489. resWorkStatusIndexArr.push(j)
  490. }
  491. }
  492. }
  493. let resWorkStatusLabel = [];
  494. for (let i = 0; i < resWorkStatusIndexArr.length; i++) {
  495. resWorkStatusLabel.push(result[0][resWorkStatusIndexArr[i]])
  496. }
  497. for (let i = 0; i < resWorkStatusLabel.length; i++) {
  498. for (let j = 0; j < workStatusArr.length; j++) {
  499. if (resWorkStatusLabel[i] == workStatusArr[j].value) {
  500. workStatusArr[j].checked = true;
  501. }
  502. }
  503. }
  504. this.setData({
  505. [workStatus]: resWorkStatusLabel
  506. })
  507. }
  508. this.setData({
  509. workStatusArr: workStatusArr,
  510. workStatusArrLabel: result[0],
  511. workStatusArrValue: result[1],
  512. })
  513. })
  514. tool.formDetails('he_company_nature').then(result => {
  515. let companyNatureArr = result[0].map((item, index) => {
  516. return Object.assign({}, {
  517. 'name': item,
  518. 'value': item,
  519. 'checked': false
  520. })
  521. })
  522. if (res.data.code == 0 && res.data.standard.companyNature) {
  523. let rescompanyNature = res.data.standard.companyNature.split(",");
  524. let recompanyNatureIndexArr = [];
  525. for (let i = 0; i < rescompanyNature.length; i++) {
  526. for (let j = 0; j < result[1].length; j++) {
  527. if (rescompanyNature[i] == result[1][j]) {
  528. recompanyNatureIndexArr.push(j)
  529. }
  530. }
  531. }
  532. let rescompanyNatureLabel = [];
  533. for (let i = 0; i < recompanyNatureIndexArr.length; i++) {
  534. rescompanyNatureLabel.push(result[0][recompanyNatureIndexArr[i]])
  535. }
  536. for (let i = 0; i < rescompanyNatureLabel.length; i++) {
  537. for (let j = 0; j < companyNatureArr.length; j++) {
  538. if (rescompanyNatureLabel[i] == companyNatureArr[j].value) {
  539. companyNatureArr[j].checked = true;
  540. }
  541. }
  542. }
  543. this.setData({
  544. [companyNature]: rescompanyNatureLabel
  545. })
  546. }
  547. this.setData({
  548. companyNatureArr: companyNatureArr,
  549. companyNatureArrLabel: result[0],
  550. companyNatureArrValue: result[1],
  551. })
  552. })
  553. tool.formDetails('he_composition_agree').then(result => {
  554. this.setData({
  555. compositionArr: ['咋的都行'].concat(result[0]),
  556. compositionArrValue: ['0'].concat(result[1])
  557. })
  558. if (res.data.code == 0) {
  559. for (let i = 0; i < [''].concat(result[1]).length; i++) {
  560. if (res.data.standard.composition == ['0'].concat(result[1])[i]) {
  561. this.setData({
  562. compositionLabel: ['咋的都行'].concat(result[0])[i],
  563. [composition]: res.data.standard.composition
  564. })
  565. }
  566. }
  567. }
  568. })
  569. tool.formDetails('he_parent_assets').then(result => {
  570. this.setData({
  571. parentAssetsArr: ['咋的都行'].concat(result[0]),
  572. parentAssetsArrValue: ['0'].concat(result[1])
  573. })
  574. if (res.data.code == 0) {
  575. for (let i = 0; i < [''].concat(result[1]).length; i++) {
  576. if (res.data.standard.parentAssets == ['0'].concat(result[1])[i]) {
  577. this.setData({
  578. parentAssetsLabel: ['咋的都行'].concat(result[0])[i],
  579. [parentAssets]: res.data.standard.parentAssets
  580. })
  581. }
  582. }
  583. }
  584. })
  585. },
  586. complete: () => {
  587. wx.hideLoading()
  588. }
  589. })
  590. },
  591. formSubmit(e) {
  592. const params = e.detail.value
  593. //校验表单
  594. if (!this.WxValidate.checkForm(params)) {
  595. const error = this.WxValidate.errorList[0]
  596. this.showModal(error)
  597. return false
  598. }
  599. let constellation = 'form.constellation'
  600. let workStatus = 'form.workStatus'
  601. let companyNature = 'form.companyNature'
  602. let indexArr = [];
  603. for (let i = 0; i < params.constellation.length; i++) {
  604. indexArr.push(this.data.constellationArrLabel.indexOf(params.constellation[i]))
  605. }
  606. let value = [];
  607. for (let i = 0; i < indexArr.length; i++) {
  608. value.push(this.data.constellationArrValue[indexArr[i]])
  609. }
  610. let str = '';
  611. for (let i = 0; i < value.length; i++) {
  612. str += value[i] + ','
  613. }
  614. let indexArr2 = [];
  615. for (let i = 0; i < params.workStatus.length; i++) {
  616. indexArr2.push(this.data.workStatusArrLabel.indexOf(params.workStatus[i]))
  617. }
  618. let value2 = [];
  619. for (let i = 0; i < indexArr2.length; i++) {
  620. value2.push(this.data.workStatusArrValue[indexArr2[i]])
  621. }
  622. let str2 = '';
  623. for (let i = 0; i < value2.length; i++) {
  624. str2 += value2[i] + ','
  625. }
  626. let indexArr3 = [];
  627. for (let i = 0; i < params.companyNature.length; i++) {
  628. indexArr3.push(this.data.companyNatureArrLabel.indexOf(params.companyNature[i]))
  629. }
  630. let value3 = [];
  631. for (let i = 0; i < indexArr3.length; i++) {
  632. value3.push(this.data.companyNatureArrValue[indexArr3[i]])
  633. }
  634. let str3 = '';
  635. for (let i = 0; i < value3.length; i++) {
  636. str3 += value3[i] + ','
  637. }
  638. this.setData({
  639. [constellation]: str.slice(0, str.length - 1),
  640. [workStatus]: str2.slice(0, str2.length - 1),
  641. [companyNature]: str3.slice(0, str3.length - 1)
  642. })
  643. console.log(this.data.form)
  644. wx.request({
  645. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/standard',
  646. method: "POST",
  647. header: {
  648. 'content-type': 'application/x-www-form-urlencoded',
  649. },
  650. data: this.data.form,
  651. success: (res) => {
  652. console.log(res)
  653. if (res.data.code == 0) {
  654. wx.showModal({
  655. title: '上传成功',
  656. showCancel: false,
  657. success(res) {
  658. if (res.confirm) {
  659. wx.redirectTo({
  660. url: '/pages/index/index',
  661. })
  662. }
  663. }
  664. });
  665. }
  666. }
  667. })
  668. },
  669. showModal(error) {
  670. wx.showModal({
  671. content: error.msg,
  672. showCancel: false,
  673. })
  674. },
  675. //验证函数
  676. initValidate() {
  677. const rules = {
  678. ageMin: {
  679. required: true
  680. },
  681. ageMax: {
  682. required: true
  683. },
  684. heightMin: {
  685. required: true
  686. },
  687. heightMax: {
  688. required: true
  689. },
  690. education: {
  691. required: true
  692. },
  693. income: {
  694. required: true
  695. },
  696. nativePlace: {
  697. required: true
  698. },
  699. marriage: {
  700. required: true
  701. },
  702. assetHouse: {
  703. required: true
  704. },
  705. // assetHouseArea: {
  706. // required: true
  707. // },
  708. assetCar: {
  709. required: true
  710. },
  711. // assetCarValue: {
  712. // required: true
  713. // },
  714. constellation: {
  715. required: true
  716. },
  717. workStatus: {
  718. required: true
  719. },
  720. companyNature: {
  721. required: true
  722. },
  723. parentAssets: {
  724. required: true
  725. },
  726. composition: {
  727. required: true
  728. },
  729. isCommon: {
  730. required: true
  731. }
  732. }
  733. const messages = {
  734. ageMin: {
  735. required: '请输入您能接受的最小年纪呦'
  736. },
  737. ageMax: {
  738. required: '请输入您能接受的最大年纪呦'
  739. },
  740. heightMin: {
  741. required: '请输入您能接受的最低身高呦'
  742. },
  743. heightMax: {
  744. required: '请输入您能接受的最高身高呦'
  745. },
  746. education: {
  747. required: '请输入您能接受的教育程度呦'
  748. },
  749. income: {
  750. required: '请选择您能接受的收入呦'
  751. },
  752. nativePlace: {
  753. required: '请选择本地或者外地呦'
  754. },
  755. marriage: {
  756. required: '请选择您能接受的婚姻状态呦'
  757. },
  758. assetHouse: {
  759. required: '请选择您可以接受的房子状态呦'
  760. },
  761. // assetHouseArea: {
  762. // required: '请选择您可以接受的房子面积呦'
  763. // },
  764. // assetHouseLoan: {
  765. // required: '请选择您可以接受的房子是否有贷款'
  766. // },
  767. assetCar: {
  768. required: '请选择您可以接受的车子状态呦'
  769. },
  770. // assetCarValue: {
  771. // required: '请选择您可以接受的车子价值呦'
  772. // },
  773. // assetCarLoan: {
  774. // required: '请选择您是否可以接受的车子有贷款'
  775. // },
  776. constellation: {
  777. required: '请选择您的优先选择星座呦'
  778. },
  779. workStatus: {
  780. required: '请选择您能接受的工作状态呦'
  781. },
  782. companyNature: {
  783. required: '请选择您能接受的单位性质呦'
  784. },
  785. parentAssets: {
  786. required: '请选择您能接受的父母经济状态呦'
  787. },
  788. composition: {
  789. required: '请选择您可以接受的家庭构成呦'
  790. },
  791. isCommon: {
  792. required: '请选择您是否接受与父母同住呦'
  793. }
  794. }
  795. this.WxValidate = new WxValidate(rules, messages)
  796. },
  797. async onLoad(options) {
  798. // tool.formDetails('he_composition_agree').then(result => {
  799. // console.log(result)
  800. // })
  801. this.initValidate()
  802. tool.openidStatus().then(result => {
  803. this.setData({
  804. openid: result[0],
  805. sessionkey: result[1]
  806. })
  807. // this.getForm();
  808. this.getInfos();
  809. })
  810. },
  811. /**
  812. * 生命周期函数--监听页面初次渲染完成
  813. */
  814. onReady: function () {
  815. },
  816. /**
  817. * 生命周期函数--监听页面显示
  818. */
  819. onShow: function () {
  820. },
  821. /**
  822. * 生命周期函数--监听页面隐藏
  823. */
  824. onHide: function () {
  825. },
  826. /**
  827. * 生命周期函数--监听页面卸载
  828. */
  829. onUnload: function () {
  830. },
  831. /**
  832. * 页面相关事件处理函数--监听用户下拉动作
  833. */
  834. onPullDownRefresh: function () {
  835. },
  836. /**
  837. * 页面上拉触底事件的处理函数
  838. */
  839. onReachBottom: function () {
  840. },
  841. /**
  842. * 用户点击右上角分享
  843. */
  844. onShareAppMessage: function () {
  845. }
  846. })