mating_edit.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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. <div style="padding:16px;">
  240. <van-button block class="bg-pink" @click="onSubmit">完成</van-button>
  241. </div>
  242. </block>
  243. <block name="script">
  244. <script>
  245. new Vue({
  246. el: '#app',
  247. data() {
  248. return {
  249. form: {$mating},
  250. showAge: false,
  251. showHigh: false,
  252. showWeight: false,
  253. showMarry: false,
  254. showEducation: false,
  255. education: {$education},
  256. showNative: false,
  257. native: {$native},
  258. showIncome: false,
  259. income: {$income},
  260. tinyint: {$tinyint},
  261. showSmoke: false,
  262. smoke: {$smoke},
  263. showDrink: false,
  264. drink: {$drink},
  265. showHaveHouse: false,
  266. showHaveCar: false,
  267. showWithParentLive: false,
  268. animal: {$animal},
  269. };
  270. },
  271. methods: {
  272. onBack() {
  273. history.back();
  274. },
  275. onSubmit() {
  276. $.post("{:url('matingAddPost')}", this.form, function (json) {
  277. location.href = '{:url("matchmaker/index/index")}';
  278. }, 'json');
  279. },
  280. onEducationConfirm(value) {
  281. this.form.education = value;
  282. this.showEducation = false;
  283. },
  284. onNativeConfirm(value) {
  285. this.form.native = value;
  286. this.showNative = false;
  287. },
  288. onPikerConfirm(key, value) {
  289. let upperKey = key.slice(0, 1).toUpperCase() + key.slice(1)
  290. this.form[key] = value;
  291. this[`show${upperKey}`] = false;
  292. },
  293. onMultiPikerConfirm(key, value) {
  294. if (value[1] < value[0]) {
  295. this.$toast('第二个值不能比第一个值小');
  296. return false;
  297. }
  298. this.form[`min_${key}`] = value[0] === '不限' ? 0 : value[0];
  299. this.form[`max_${key}`] = value[1] === '不限' ? 0 : value[1];
  300. let upperKey = key.slice(0, 1).toUpperCase() + key.slice(1);
  301. this[`show${upperKey}`] = false;
  302. },
  303. //多列选择器
  304. getColumns(min,min_value,max,max_value){
  305. let min_default = this.findKey(min, min_value);
  306. if (min_default === undefined) {
  307. min_default = 0;
  308. }
  309. let max_default = this.findKey(max, max_value);
  310. if (max_default === undefined) {
  311. max_default = 0;
  312. }
  313. return [
  314. {
  315. values: min,
  316. default: min_default,
  317. },
  318. {
  319. values: max,
  320. default: max_default,
  321. },
  322. ];
  323. },
  324. //多列选择器值
  325. getColumnsValue(min,max,ext) {
  326. if (min === '' || max === '') {
  327. return '';
  328. }
  329. if (min === 0 && max === 0) {
  330. return '不限';
  331. }
  332. let min_ext = min + ext;
  333. if (min === 0) {
  334. min_ext = '不限';
  335. }
  336. let max_ext = max + ext;
  337. if (max === 0) {
  338. max_ext = '不限';
  339. }
  340. return `${min_ext}-${max_ext}`;
  341. },
  342. //找键
  343. findKey(obj, value, compare = (a, b) => a === b) {
  344. return Object.keys(obj).find(k => compare(obj[k], value))
  345. },
  346. onIncomeConfirm(value) {
  347. this.form.income = value;
  348. this.showIncome = false;
  349. },
  350. onHaveHouseConfirm(value,index) {
  351. this.form.have_house = index;
  352. this.showHaveHouse = false;
  353. },
  354. onHaveCarConfirm(value,index) {
  355. this.form.have_car = index;
  356. this.showHaveCar = false;
  357. },
  358. onWithParentLiveConfirm(value,index) {
  359. this.form.with_parent_live = index;
  360. this.showWithParentLive = false;
  361. },
  362. onSmokeConfirm(value) {
  363. this.form.smoke = value;
  364. this.showSmoke = false;
  365. },
  366. onDrinkConfirm(value) {
  367. this.form.drink = value;
  368. this.showDrink = false;
  369. },
  370. selectAnimal(value) {
  371. if (this.in_array(value,this.form.animal)) {
  372. this.removeByVal(this.form.animal,value);
  373. } else {
  374. this.form.animal.push(value);
  375. }
  376. },
  377. in_array(search,array){
  378. for(var i in array){
  379. if(array[i] == search){
  380. return true;
  381. }
  382. }
  383. return false;
  384. },
  385. removeByVal(arrylist , val) {
  386. for(var i = 0; i < arrylist .length; i++) {
  387. if(arrylist[i] == val) {
  388. arrylist .splice(i, 1);
  389. break;
  390. }
  391. }
  392. },
  393. },
  394. computed: {
  395. //年龄
  396. age() {
  397. return this.getColumns({$min_age},this.form.min_age,{$max_age},this.form.max_age);
  398. },
  399. form_age() {
  400. return this.getColumnsValue(this.form.min_age,this.form.max_age,'岁');
  401. },
  402. //身高
  403. high() {
  404. return this.getColumns({$min_high},this.form.min_high,{$max_high},this.form.max_high);
  405. },
  406. form_high() {
  407. return this.getColumnsValue(this.form.min_high,this.form.max_high,'CM');
  408. },
  409. //体重
  410. weight() {
  411. return this.getColumns({$min_weight},this.form.min_weight,{$max_weight},this.form.max_weight);
  412. },
  413. form_weight() {
  414. return this.getColumnsValue(this.form.min_weight,this.form.max_weight,'KG');
  415. },
  416. }
  417. });
  418. </script>
  419. </block>