mating_add.html 15 KB

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