cond.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <extend name="public@base"/>
  2. <block name="css">
  3. <style>
  4. .van-row {width:100%;}
  5. .btn_search_item{background:#f2f6ff;display:inline-block;border-radius:5px;line-height:35px;height:35px;text-align:center;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;position:relative;font-size:13px;width:100%;color:#666;margin-bottom:10px;}
  6. .btn_search_item.active{color:var(--pink);background:#fff7fa;}
  7. .btn_search_icon{position:absolute;bottom:-3px;right:-3px;font-size:30px;}
  8. </style>
  9. </block>
  10. <block name="body">
  11. <!--头部-->
  12. <van-nav-bar
  13. left-text="返回"
  14. right-text="完成"
  15. left-arrow
  16. @click-left="onBack"
  17. @click-right="onSubmit"
  18. fixed="true"
  19. >
  20. <template #title>
  21. <span>择偶要求</span>
  22. </template>
  23. </van-nav-bar>
  24. <div style="width:100%;height:46px;"></div>
  25. <!--年龄-->
  26. <van-field
  27. readonly
  28. clickable
  29. :value="form_age"
  30. label="年龄"
  31. placeholder="点击选择年龄"
  32. @click="showAge = true"
  33. ></van-field>
  34. <van-popup position="bottom" v-model="showAge">
  35. <van-picker
  36. title="年龄"
  37. show-toolbar
  38. :columns="age"
  39. @confirm="onMultiPikerConfirm('age',$event)"
  40. @cancel="showAge = false"
  41. ></van-picker>
  42. </van-popup>
  43. <!--身高-->
  44. <van-field
  45. readonly
  46. clickable
  47. :value="form_high"
  48. label="身高"
  49. placeholder="点击选择身高"
  50. @click="showHigh = true"
  51. ></van-field>
  52. <van-popup position="bottom" v-model="showHigh">
  53. <van-picker
  54. title="身高"
  55. show-toolbar
  56. :columns="high"
  57. @confirm="onMultiPikerConfirm('high',$event)"
  58. @cancel="showHigh = false"
  59. ></van-picker>
  60. </van-popup>
  61. <!--体重-->
  62. <van-field
  63. readonly
  64. clickable
  65. :value="form_weight"
  66. label="体重"
  67. placeholder="点击选择体重"
  68. @click="showWeight = true"
  69. ></van-field>
  70. <van-popup position="bottom" v-model="showWeight">
  71. <van-picker
  72. title="体重"
  73. show-toolbar
  74. :columns="weight"
  75. @confirm="onMultiPikerConfirm('weight',$event)"
  76. @cancel="showWeight = false"
  77. ></van-picker>
  78. </van-popup>
  79. <!--无意愿生肖-->
  80. <van-field name="form.family" label="无意愿生肖">
  81. <template #input>
  82. <van-row :gutter="10">
  83. <van-col span="8" v-for="(item) in animal">
  84. <div :class="{btn_search_item:true,active: in_array(item,form.animal)}"
  85. @click="selectAnimal(item)">
  86. {{item}}
  87. <van-icon v-if="in_array(item,form.animal)"
  88. class="iconfont icon-gouxuan-youxiajiaogouxuan btn_search_icon text-pink"></van-icon>
  89. </div>
  90. </van-col>
  91. </van-row>
  92. </template>
  93. </van-field>
  94. <!--籍贯-->
  95. <van-field
  96. readonly
  97. clickable
  98. :value="form.native"
  99. label="籍贯"
  100. placeholder="点击选择籍贯"
  101. @click="showNative = true"
  102. ></van-field>
  103. <van-popup position="bottom" v-model="showNative">
  104. <van-picker
  105. title="籍贯"
  106. show-toolbar
  107. :columns="native"
  108. @confirm="onNativeConfirm"
  109. @cancel="showNative = false"
  110. ></van-picker>
  111. </van-popup>
  112. <!--学历-->
  113. <van-field
  114. readonly
  115. clickable
  116. :value="form.education"
  117. label="学历"
  118. placeholder="点击选择学历"
  119. @click="showEducation = true"
  120. ></van-field>
  121. <van-popup position="bottom" v-model="showEducation">
  122. <van-picker
  123. title="学历"
  124. show-toolbar
  125. :columns="education"
  126. @confirm="onEducationConfirm"
  127. @cancel="showEducation = false"
  128. ></van-picker>
  129. </van-popup>
  130. <!--年收入-->
  131. <van-field
  132. readonly
  133. clickable
  134. :value="form.income"
  135. label="年收入"
  136. placeholder="点击选择年收入"
  137. @click="showIncome = true"
  138. ></van-field>
  139. <van-popup position="bottom" v-model="showIncome">
  140. <van-picker
  141. title="年收入"
  142. show-toolbar
  143. :columns="income"
  144. @confirm="onIncomeConfirm"
  145. @cancel="showIncome = false"
  146. ></van-picker>
  147. </van-popup>
  148. <!--身份类型-->
  149. <van-field
  150. readonly
  151. clickable
  152. :value="form.id_type"
  153. label="身份类型"
  154. placeholder="点击选择身份类型"
  155. @click="showIdType = true"
  156. ></van-field>
  157. <van-popup position="bottom" v-model="showIdType">
  158. <van-picker
  159. title="身份类型"
  160. show-toolbar
  161. :columns="idType"
  162. @confirm="onIdTypeConfirm"
  163. @cancel="showIdType = false"
  164. ></van-picker>
  165. </van-popup>
  166. <van-field
  167. readonly
  168. clickable
  169. :value="tinyint[form.have_house]"
  170. label="是否有房"
  171. placeholder="点击选择是否有房"
  172. @click="showHaveHouse = true"
  173. ></van-field>
  174. <van-popup position="bottom" v-model="showHaveHouse">
  175. <van-picker
  176. title="是否有房"
  177. show-toolbar
  178. :columns="tinyint"
  179. @confirm="onHaveHouseConfirm"
  180. @cancel="showHaveHouse = false"
  181. ></van-picker>
  182. </van-popup>
  183. <van-field
  184. readonly
  185. clickable
  186. :value="tinyint[form.have_car]"
  187. label="是否有车"
  188. placeholder="点击选择是否有车"
  189. @click="showHaveCar = true"
  190. ></van-field>
  191. <van-popup position="bottom" v-model="showHaveCar">
  192. <van-picker
  193. title="是否有车"
  194. show-toolbar
  195. :columns="tinyint"
  196. @confirm="onHaveCarConfirm"
  197. @cancel="showHaveCar = false"
  198. ></van-picker>
  199. </van-popup>
  200. <van-field
  201. readonly
  202. clickable
  203. :value="tinyint[form.with_parent_live]"
  204. label="婚后是否愿意与父母同住"
  205. placeholder="点击选择"
  206. @click="showWithParentLive = true"
  207. ></van-field>
  208. <van-popup position="bottom" v-model="showWithParentLive">
  209. <van-picker
  210. title="婚后是否愿意与父母同住"
  211. show-toolbar
  212. :columns="tinyint"
  213. @confirm="onWithParentLiveConfirm"
  214. @cancel="showWithParentLive = false"
  215. ></van-picker>
  216. </van-popup>
  217. <!--是否吸烟-->
  218. <van-field
  219. readonly
  220. clickable
  221. :value="form.smoke"
  222. label="是否吸烟"
  223. placeholder="点击选择是否吸烟"
  224. @click="showSmoke = true"
  225. ></van-field>
  226. <van-popup position="bottom" v-model="showSmoke">
  227. <van-picker
  228. title="是否吸烟"
  229. show-toolbar
  230. :columns="smoke"
  231. @confirm="onSmokeConfirm"
  232. @cancel="showSmoke = false"
  233. ></van-picker>
  234. </van-popup>
  235. <!--是否喝酒-->
  236. <van-field
  237. readonly
  238. clickable
  239. :value="form.drink"
  240. label="是否喝酒"
  241. placeholder="点击选择是否喝酒"
  242. @click="showDrink = true"
  243. ></van-field>
  244. <van-popup position="bottom" v-model="showDrink">
  245. <van-picker
  246. title="是否喝酒"
  247. show-toolbar
  248. :columns="drink"
  249. @confirm="onDrinkConfirm"
  250. @cancel="showDrink = false"
  251. ></van-picker>
  252. </van-popup>
  253. <van-field
  254. readonly
  255. clickable
  256. :value="tinyint[form.want_birth]"
  257. label="是否要求生育"
  258. placeholder="点击选择"
  259. @click="showWantBirth = true"
  260. ></van-field>
  261. <van-popup position="bottom" v-model="showWantBirth">
  262. <van-picker
  263. title="是否要求生育"
  264. show-toolbar
  265. :columns="tinyint"
  266. @confirm="onWantBirthConfirm"
  267. @cancel="showWantBirth = false"
  268. ></van-picker>
  269. </van-popup>
  270. </block>
  271. <block name="script">
  272. <script>
  273. new Vue({
  274. el: '#app',
  275. data() {
  276. return {
  277. form: {$mating},
  278. showAge: false,
  279. showHigh: false,
  280. showWeight: false,
  281. showMarry: false,
  282. showEducation: false,
  283. education: {$education},
  284. showNative: false,
  285. native: {$native},
  286. showIdType: false,
  287. idType: {$id_type},
  288. showIncome: false,
  289. income: {$income},
  290. tinyint: {$tinyint},
  291. showSmoke: false,
  292. smoke: {$smoke},
  293. showDrink: false,
  294. drink: {$drink},
  295. showHaveHouse: false,
  296. showHaveCar: false,
  297. showWithParentLive: false,
  298. animal: {$animal},
  299. showWantBirth: false,
  300. };
  301. },
  302. methods: {
  303. onBack() {
  304. history.back();
  305. },
  306. onSubmit() {
  307. $.post("{:url('condPost')}", this.form, function (json) {
  308. history.back();
  309. }, 'json');
  310. },
  311. onEducationConfirm(value) {
  312. this.form.education = value;
  313. this.showEducation = false;
  314. },
  315. onNativeConfirm(value) {
  316. this.form.native = value;
  317. this.showNative = false;
  318. },
  319. onPikerConfirm(key, value) {
  320. let upperKey = key.slice(0, 1).toUpperCase() + key.slice(1)
  321. this.form[key] = value;
  322. this[`show${upperKey}`] = false;
  323. },
  324. onMultiPikerConfirm(key, value) {
  325. if (value[1] < value[0]) {
  326. this.$toast('第二个值不能比第一个值小');
  327. return false;
  328. }
  329. this.form[`min_${key}`] = value[0] === '不限' ? 0 : value[0];
  330. this.form[`max_${key}`] = value[1] === '不限' ? 0 : value[1];
  331. let upperKey = key.slice(0, 1).toUpperCase() + key.slice(1);
  332. this[`show${upperKey}`] = false;
  333. },
  334. //多列选择器
  335. getColumns(min,min_value,max,max_value){
  336. let min_default = this.findKey(min, min_value);
  337. if (min_default === undefined) {
  338. min_default = 0;
  339. }
  340. let max_default = this.findKey(max, max_value);
  341. if (max_default === undefined) {
  342. max_default = 0;
  343. }
  344. return [
  345. {
  346. values: min,
  347. default: min_default,
  348. },
  349. {
  350. values: max,
  351. default: max_default,
  352. },
  353. ];
  354. },
  355. //多列选择器值
  356. getColumnsValue(min,max,ext) {
  357. if (min === '' || max === '') {
  358. return '';
  359. }
  360. if (min === 0 && max === 0) {
  361. return '不限';
  362. }
  363. let min_ext = min + ext;
  364. if (min === 0) {
  365. min_ext = '不限';
  366. }
  367. let max_ext = max + ext;
  368. if (max === 0) {
  369. max_ext = '不限';
  370. }
  371. return `${min_ext}-${max_ext}`;
  372. },
  373. //找键
  374. findKey(obj, value, compare = (a, b) => a === b) {
  375. return Object.keys(obj).find(k => compare(obj[k], value))
  376. },
  377. onIdTypeConfirm(value) {
  378. this.form.id_type = value;
  379. this.showIdType = false;
  380. },
  381. onIncomeConfirm(value) {
  382. this.form.income = value;
  383. this.showIncome = false;
  384. },
  385. onHaveHouseConfirm(value,index) {
  386. this.form.have_house = index;
  387. this.showHaveHouse = false;
  388. },
  389. onHaveCarConfirm(value,index) {
  390. this.form.have_car = index;
  391. this.showHaveCar = false;
  392. },
  393. onWithParentLiveConfirm(value,index) {
  394. this.form.with_parent_live = index;
  395. this.showWithParentLive = false;
  396. },
  397. onSmokeConfirm(value) {
  398. this.form.smoke = value;
  399. this.showSmoke = false;
  400. },
  401. onDrinkConfirm(value) {
  402. this.form.drink = value;
  403. this.showDrink = false;
  404. },
  405. onWantBirthConfirm(value,index){
  406. this.form.want_birth = index;
  407. this.showWantBirth = false;
  408. },
  409. selectAnimal(value) {
  410. if (this.in_array(value,this.form.animal)) {
  411. this.removeByVal(this.form.animal,value);
  412. } else {
  413. this.form.animal.push(value);
  414. }
  415. },
  416. in_array(search,array){
  417. for(var i in array){
  418. if(array[i] == search){
  419. return true;
  420. }
  421. }
  422. return false;
  423. },
  424. removeByVal(arrylist , val) {
  425. for(var i = 0; i < arrylist .length; i++) {
  426. if(arrylist[i] == val) {
  427. arrylist .splice(i, 1);
  428. break;
  429. }
  430. }
  431. },
  432. },
  433. computed: {
  434. //年龄
  435. age() {
  436. return this.getColumns({$min_age},this.form.min_age,{$max_age},this.form.max_age);
  437. },
  438. form_age() {
  439. return this.getColumnsValue(this.form.min_age,this.form.max_age,'岁');
  440. },
  441. //身高
  442. high() {
  443. return this.getColumns({$min_high},this.form.min_high,{$max_high},this.form.max_high);
  444. },
  445. form_high() {
  446. return this.getColumnsValue(this.form.min_high,this.form.max_high,'CM');
  447. },
  448. //体重
  449. weight() {
  450. return this.getColumns({$min_weight},this.form.min_weight,{$max_weight},this.form.max_weight);
  451. },
  452. form_weight() {
  453. return this.getColumnsValue(this.form.min_weight,this.form.max_weight,'KG');
  454. },
  455. }
  456. });
  457. </script>
  458. </block>