targetInfo.js 12 KB

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