mating_edit.html 16 KB

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