targetInfo.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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. assetArea: '',
  17. assetHouseLoan: '',
  18. assetCar: '',
  19. assetCarValue: '',
  20. assetCarLoan: '',
  21. constellation: '',
  22. workStatus: '',
  23. companyNature: '',
  24. parents: '',
  25. composition: '',
  26. isCommen: ''
  27. },
  28. heightArr: [
  29. '都行',
  30. '150-155',
  31. '155-160',
  32. '160-165',
  33. '165-170',
  34. '170-175',
  35. '175-185',
  36. '185-190'
  37. ],
  38. educationArr: ["都行", "初中", "中专", "高中", "大专", "本科", "硕士", "博士"],
  39. incomeArr: ["挣不挣都行", "2000-5000", "5000-10000", "10000-20000", "20000以上"],
  40. nativePlaceArr: ['咋的都行', '本地', '外地'],
  41. marriageArr: [
  42. ["不行", "行"],
  43. []
  44. ],
  45. constellationArr: [{
  46. name: '不限',
  47. value: '不限',
  48. checked: true
  49. },
  50. {
  51. name: '白羊座',
  52. value: '白羊座',
  53. checked: false
  54. },
  55. {
  56. name: '金牛座',
  57. value: '金牛座',
  58. checked: false
  59. },
  60. {
  61. name: '双子座',
  62. value: '双子座',
  63. checked: false
  64. },
  65. {
  66. name: '巨蟹座',
  67. value: '巨蟹座',
  68. checked: false
  69. },
  70. {
  71. name: '狮子座',
  72. value: '狮子座',
  73. checked: false
  74. },
  75. {
  76. name: '处女座',
  77. value: '处女座',
  78. checked: false
  79. },
  80. {
  81. name: '天秤座',
  82. value: '天秤座',
  83. checked: false
  84. },
  85. {
  86. name: '天蝎座',
  87. value: '天蝎座',
  88. checked: false
  89. },
  90. {
  91. name: '射手座',
  92. value: '射手座',
  93. checked: false
  94. },
  95. {
  96. name: '摩羯座',
  97. value: '摩羯座',
  98. checked: false
  99. },
  100. {
  101. name: '水瓶座',
  102. value: '水瓶座',
  103. checked: false
  104. },
  105. {
  106. name: '双鱼座',
  107. value: '双鱼座',
  108. checked: false
  109. }
  110. ],
  111. // 工作时间自由、朝九晚五、偶尔加班、经常加班、偶尔出差、经常出差、常有应酬
  112. workStatusArr: [{
  113. name: '工作时间自由',
  114. value: '工作时间自由',
  115. checked: true
  116. },
  117. {
  118. name: '朝九晚五',
  119. value: '朝九晚五',
  120. checked: false
  121. }, {
  122. name: '偶尔加班',
  123. value: '偶尔加班',
  124. checked: false
  125. }, {
  126. name: '经常加班',
  127. value: '经常加班',
  128. checked: false
  129. },
  130. {
  131. name: '偶尔出差',
  132. value: '偶尔出差',
  133. checked: false
  134. }, {
  135. name: '经常出差',
  136. value: '经常出差',
  137. checked: false
  138. }, {
  139. name: '常有应酬',
  140. value: '常有应酬',
  141. checked: false
  142. }
  143. ],
  144. assetHouseArr: ['租房', '购房'],
  145. assetAreaArr: ['80平以下', '80-120平', '120平以上'],
  146. assetHouseLoanArr: ['有', '没有'],
  147. assetCarArr: ['有', '没有'],
  148. assetCarValueArr: ['10万以下', '10-20万', '20-30万', '30-40万', '40-50万', '50-60万', '60-70万', '70-80万', '80-90万', '90-100万', '100万以上'],
  149. assetCarLoanArr: ['有贷款', '无贷款'],
  150. companyNatureArr: ['政府机关', '事业单位', '外企企业', '世界500强', '上市公司', '国有企业', '私营企业', '个体'],
  151. parentsArr: ['均有退休金', '均无退休金', '父亲有退休金', '母亲有退休金'],
  152. compositionArr: ['老几都行', '必须独苗一根'],
  153. isCommenArr: ['愿意', '不愿意']
  154. },
  155. educationPicker(e) {
  156. let education = 'form.education'
  157. this.setData({
  158. [education]: this.data.educationArr[e.detail.value]
  159. })
  160. },
  161. incomePicker(e) {
  162. let income = 'form.income'
  163. this.setData({
  164. [income]: this.data.incomeArr[e.detail.value]
  165. })
  166. },
  167. nativePlacePicker(e) {
  168. let nativePlace = 'form.nativePlace'
  169. this.setData({
  170. [nativePlace]: this.data.nativePlaceArr[e.detail.value]
  171. })
  172. },
  173. marriageChange(e) {
  174. let marriage = 'form.marriage'
  175. this.setData({
  176. [marriage]: [this.data.marriageArr[0][e.detail.value[0]], this.data.marriageArr[1][e.detail.value[1]]]
  177. })
  178. this.setData({
  179. marriagemultiIndex: e.detail.value
  180. })
  181. },
  182. marriagePickerColumnChange(e) {
  183. console.log(e)
  184. if (e.detail.column == 0 && e.detail.value == 1) {
  185. this.setData({
  186. marriageArr: [
  187. ["行", "不行"],
  188. ["有小祖宗不行", "有小祖宗也行"]
  189. ]
  190. })
  191. }
  192. if (e.detail.column == 0 && e.detail.value == 0) {
  193. this.setData({
  194. marriageArr: [
  195. ["行", "不行"],
  196. []
  197. ]
  198. })
  199. }
  200. },
  201. assetHousePickerChange(e) {
  202. console.log(e)
  203. let assetHouse = 'form.assetHouse'
  204. this.setData({
  205. [assetHouse]: this.data.assetHouseArr[e.detail.value]
  206. })
  207. },
  208. assetAreaPickerChange(e) {
  209. console.log(e)
  210. let assetArea = 'form.assetArea'
  211. this.setData({
  212. [assetArea]: this.data.assetAreaArr[e.detail.value]
  213. })
  214. },
  215. assetHouseLoanPickerChange(e) {
  216. console.log(e)
  217. let assetHouseLoan = 'form.assetHouseLoan'
  218. this.setData({
  219. [assetHouseLoan]: this.data.assetHouseLoanArr[e.detail.value]
  220. })
  221. },
  222. assetCarPickerChange(e) {
  223. console.log(e)
  224. let assetCar = 'form.assetCar'
  225. this.setData({
  226. [assetCar]: this.data.assetCarArr[e.detail.value]
  227. })
  228. },
  229. assetCarValuePickerChange(e) {
  230. console.log(e)
  231. let assetCarValue = 'form.assetCarValue'
  232. this.setData({
  233. [assetCarValue]: this.data.assetCarValueArr[e.detail.value]
  234. })
  235. },
  236. assetCarLoanPickerChange(e) {
  237. console.log(e)
  238. let assetCarLoan = 'form.assetCarLoan'
  239. this.setData({
  240. [assetCarLoan]: this.data.assetCarLoanArr[e.detail.value]
  241. })
  242. },
  243. constellationPicker(e) {
  244. console.log(e.detail.value)
  245. const items = this.data.constellationArr;
  246. const values = e.detail.value;
  247. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  248. items[i].checked = false
  249. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  250. if (items[i].value === values[j]) {
  251. items[i].checked = true
  252. break
  253. }
  254. }
  255. }
  256. this.setData({
  257. constellationArr: this.data.constellationArr
  258. })
  259. let constellation = 'form.constellation'
  260. this.setData({
  261. [constellation]: e.detail.value
  262. })
  263. },
  264. workStatusChange(e) {
  265. console.log(e.detail.value)
  266. const items = this.data.workStatusArr;
  267. const values = e.detail.value;
  268. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  269. items[i].checked = false
  270. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  271. if (items[i].value === values[j]) {
  272. items[i].checked = true
  273. break
  274. }
  275. }
  276. }
  277. this.setData({
  278. workStatusArr: this.data.workStatusArr
  279. })
  280. let workStatus = 'form. workStatus'
  281. this.setData({
  282. [workStatus]: e.detail.value
  283. })
  284. },
  285. companyNaturePicker: function (e) {
  286. let companyNature = 'form.companyNature'
  287. this.setData({
  288. [companyNature]: this.data.companyNatureArr[e.detail.value]
  289. })
  290. },
  291. parentsPicker(e) {
  292. let parents = 'form.parents'
  293. this.setData({
  294. [parents]: this.data.parentsArr[e.detail.value]
  295. })
  296. },
  297. compositionPicker(e) {
  298. let composition = 'form.composition'
  299. this.setData({
  300. [composition]: this.data.compositionArr[e.detail.value]
  301. })
  302. },
  303. isCommenPicker(e) {
  304. let isCommen = 'form.isCommen'
  305. this.setData({
  306. [isCommen]: this.data.isCommenArr[e.detail.value]
  307. })
  308. },
  309. formSubmit(e) {
  310. const params = e.detail.value
  311. //校验表单
  312. if (!this.WxValidate.checkForm(params)) {
  313. const error = this.WxValidate.errorList[0]
  314. this.showModal(error)
  315. return false
  316. }
  317. wx.switchTab({
  318. url: '/pages/index/index',
  319. })
  320. },
  321. showModal(error) {
  322. wx.showModal({
  323. content: error.msg,
  324. showCancel: false,
  325. })
  326. },
  327. //验证函数
  328. initValidate() {
  329. const rules = {
  330. ageMin: {
  331. required: true
  332. },
  333. ageMax:{
  334. required: true
  335. },
  336. heightMin:{
  337. required: true
  338. },
  339. heightMax:{
  340. required: true
  341. },
  342. education:{
  343. required: true
  344. },
  345. income:{
  346. required: true
  347. },
  348. nativePlace:{
  349. required: true
  350. },
  351. marriage:{
  352. required: true
  353. },
  354. assetHouse:{
  355. required: true
  356. },
  357. assetArea:{
  358. required: true
  359. },
  360. assetHouseLoan:{
  361. required: true
  362. },
  363. assetCar:{
  364. required: true
  365. },
  366. assetCarValue:{
  367. required: true
  368. },
  369. assetCarLoan:{
  370. required: true
  371. },
  372. constellation:{
  373. required: true
  374. },
  375. workStatus:{
  376. required: true
  377. },
  378. companyNature:{
  379. required: true
  380. },
  381. parents:{
  382. required: true
  383. },
  384. composition:{
  385. required: true
  386. },
  387. isCommen: {
  388. required: true
  389. }
  390. }
  391. const messages = {
  392. ageMin: {
  393. required: '请输入您能接受的最小年纪'
  394. },
  395. ageMax:{
  396. required: '请输入您能接受的最大年纪'
  397. },
  398. heightMin:{
  399. required: '请输入您能接受的最低身高'
  400. },
  401. heightMax:{
  402. required: '请输入您能接受的最高身高'
  403. },
  404. education:{
  405. required: '请输入您能接受的教育程度'
  406. },
  407. income:{
  408. required: '请选择您能接受的收入'
  409. },
  410. nativePlace:{
  411. required: '请选择本地或者外地'
  412. },
  413. marriage:{
  414. required: '请选择您能接受的婚姻状态'
  415. },
  416. assetHouse:{
  417. required: '请选择您可以接受的房子状态'
  418. },
  419. assetArea:{
  420. required: '请选择您可以接受的房子面积'
  421. },
  422. assetHouseLoan:{
  423. required: '请选择您可以接受的房子是否有贷款'
  424. },
  425. assetCar:{
  426. required: '请选择您可以接受的车子状态'
  427. },
  428. assetCarValue:{
  429. required: '请选择您可以接受的车子价值'
  430. },
  431. assetCarLoan:{
  432. required: '请选择您是否可以接受的车子有贷款'
  433. },
  434. constellation:{
  435. required: '请选择您的优先选择星座'
  436. },
  437. workStatus:{
  438. required: '请选择您能接受的工作状态'
  439. },
  440. companyNature:{
  441. required: '请选择您能接受的单位性质'
  442. },
  443. parents:{
  444. required: '请选择您能接受的父母状态'
  445. },
  446. composition:{
  447. required: '请选择您可以接受的家庭构成'
  448. },
  449. isCommen: {
  450. required: '请选择您是否接受与父母同住'
  451. }
  452. }
  453. this.WxValidate = new WxValidate(rules, messages)
  454. },
  455. async onLoad (options) {
  456. this.initValidate()
  457. const getOpenid = await tool.openidStatus();
  458. this.setData({
  459. openid: getOpenid[0],
  460. sessionkey: getOpenid[1]
  461. })
  462. },
  463. /**
  464. * 生命周期函数--监听页面初次渲染完成
  465. */
  466. onReady: function () {
  467. },
  468. /**
  469. * 生命周期函数--监听页面显示
  470. */
  471. onShow: function () {
  472. },
  473. /**
  474. * 生命周期函数--监听页面隐藏
  475. */
  476. onHide: function () {
  477. },
  478. /**
  479. * 生命周期函数--监听页面卸载
  480. */
  481. onUnload: function () {
  482. },
  483. /**
  484. * 页面相关事件处理函数--监听用户下拉动作
  485. */
  486. onPullDownRefresh: function () {
  487. },
  488. /**
  489. * 页面上拉触底事件的处理函数
  490. */
  491. onReachBottom: function () {
  492. },
  493. /**
  494. * 用户点击右上角分享
  495. */
  496. onShareAppMessage: function () {
  497. }
  498. })