mating_edit.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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. </style>
  10. </block>
  11. <block name="body">
  12. <!--头部-->
  13. <van-nav-bar
  14. class="bg-pink"
  15. fixed="true"
  16. left-text="返回"
  17. left-arrow
  18. @click-left="onBack"
  19. >
  20. <template #title>
  21. <span style="color:white;">择偶要求</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
  81. readonly
  82. clickable
  83. :value="form.native"
  84. label="籍贯"
  85. placeholder="点击选择籍贯"
  86. @click="showNative = true"
  87. ></van-field>
  88. <van-popup position="bottom" v-model="showNative">
  89. <van-picker
  90. title="籍贯"
  91. show-toolbar
  92. :columns="native"
  93. @confirm="onNativeConfirm"
  94. @cancel="showNative = false"
  95. ></van-picker>
  96. </van-popup>
  97. <!--学历-->
  98. <van-field
  99. readonly
  100. clickable
  101. :value="form.education"
  102. label="学历"
  103. placeholder="点击选择学历"
  104. @click="showEducation = true"
  105. ></van-field>
  106. <van-popup position="bottom" v-model="showEducation">
  107. <van-picker
  108. title="学历"
  109. show-toolbar
  110. :columns="education"
  111. @confirm="onEducationConfirm"
  112. @cancel="showEducation = false"
  113. ></van-picker>
  114. </van-popup>
  115. <!--年收入-->
  116. <van-field
  117. readonly
  118. clickable
  119. :value="form.income"
  120. label="年收入"
  121. placeholder="点击选择年收入"
  122. @click="showIncome = true"
  123. ></van-field>
  124. <van-popup position="bottom" v-model="showIncome">
  125. <van-picker
  126. title="年收入"
  127. show-toolbar
  128. :columns="income"
  129. @confirm="onIncomeConfirm"
  130. @cancel="showIncome = false"
  131. ></van-picker>
  132. </van-popup>
  133. <van-field
  134. readonly
  135. clickable
  136. :value="tinyint[form.have_house]"
  137. label="是否有房"
  138. placeholder="点击选择是否有房"
  139. @click="showHaveHouse = true"
  140. ></van-field>
  141. <van-popup position="bottom" v-model="showHaveHouse">
  142. <van-picker
  143. title="是否有房"
  144. show-toolbar
  145. :columns="tinyint"
  146. @confirm="onHaveHouseConfirm"
  147. @cancel="showHaveHouse = false"
  148. ></van-picker>
  149. </van-popup>
  150. <van-field
  151. readonly
  152. clickable
  153. :value="tinyint[form.have_car]"
  154. label="是否有车"
  155. placeholder="点击选择是否有车"
  156. @click="showHaveCar = true"
  157. ></van-field>
  158. <van-popup position="bottom" v-model="showHaveCar">
  159. <van-picker
  160. title="是否有车"
  161. show-toolbar
  162. :columns="tinyint"
  163. @confirm="onHaveCarConfirm"
  164. @cancel="showHaveCar = false"
  165. ></van-picker>
  166. </van-popup>
  167. <van-field
  168. readonly
  169. clickable
  170. :value="tinyint[form.with_parent_live]"
  171. label="婚后是否愿意与父母同住"
  172. placeholder="点击选择"
  173. @click="showWithParentLive = true"
  174. ></van-field>
  175. <van-popup position="bottom" v-model="showWithParentLive">
  176. <van-picker
  177. title="婚后是否愿意与父母同住"
  178. show-toolbar
  179. :columns="tinyint"
  180. @confirm="onWithParentLiveConfirm"
  181. @cancel="showWithParentLive = false"
  182. ></van-picker>
  183. </van-popup>
  184. <!--是否吸烟-->
  185. <van-field
  186. readonly
  187. clickable
  188. :value="form.smoke"
  189. label="是否吸烟"
  190. placeholder="点击选择是否吸烟"
  191. @click="showSmoke = true"
  192. ></van-field>
  193. <van-popup position="bottom" v-model="showSmoke">
  194. <van-picker
  195. title="是否吸烟"
  196. show-toolbar
  197. :columns="smoke"
  198. @confirm="onSmokeConfirm"
  199. @cancel="showSmoke = false"
  200. ></van-picker>
  201. </van-popup>
  202. <!--是否喝酒-->
  203. <van-field
  204. readonly
  205. clickable
  206. :value="form.drink"
  207. label="是否喝酒"
  208. placeholder="点击选择是否喝酒"
  209. @click="showDrink = true"
  210. ></van-field>
  211. <van-popup position="bottom" v-model="showDrink">
  212. <van-picker
  213. title="是否喝酒"
  214. show-toolbar
  215. :columns="drink"
  216. @confirm="onDrinkConfirm"
  217. @cancel="showDrink = false"
  218. ></van-picker>
  219. </van-popup>
  220. <div style="padding:16px;">
  221. <van-button block class="bg-pink" @click="onSubmit">完成</van-button>
  222. </div>
  223. </block>
  224. <block name="script">
  225. <script>
  226. new Vue({
  227. el: '#app',
  228. data() {
  229. return {
  230. form: {$mating},
  231. showAge: false,
  232. showHigh: false,
  233. showWeight: false,
  234. showMarry: false,
  235. showEducation: false,
  236. education: {$education},
  237. showNative: false,
  238. native: {$native},
  239. showIncome: false,
  240. income: {$income},
  241. tinyint: {$tinyint},
  242. showSmoke: false,
  243. smoke: {$smoke},
  244. showDrink: false,
  245. drink: {$drink},
  246. showHaveHouse: false,
  247. showHaveCar: false,
  248. showWithParentLive: false,
  249. };
  250. },
  251. methods: {
  252. onBack() {
  253. history.back();
  254. },
  255. onSubmit() {
  256. $.post("{:url('matingAddPost')}", this.form, function (json) {
  257. location.href = '{:url("matchmaker/index/index")}';
  258. }, 'json');
  259. },
  260. onEducationConfirm(value) {
  261. this.form.education = value;
  262. this.showEducation = false;
  263. },
  264. onNativeConfirm(value) {
  265. this.form.native = value;
  266. this.showNative = false;
  267. },
  268. onPikerConfirm(key, value) {
  269. let upperKey = key.slice(0, 1).toUpperCase() + key.slice(1)
  270. this.form[key] = value;
  271. this[`show${upperKey}`] = false;
  272. },
  273. onMultiPikerConfirm(key, value) {
  274. if (value[1] < value[0]) {
  275. this.$toast('第二个值不能比第一个值小');
  276. return false;
  277. }
  278. this.form[`min_${key}`] = value[0] === '不限' ? 0 : value[0];
  279. this.form[`max_${key}`] = value[1] === '不限' ? 0 : value[1];
  280. let upperKey = key.slice(0, 1).toUpperCase() + key.slice(1);
  281. this[`show${upperKey}`] = false;
  282. },
  283. //多列选择器
  284. getColumns(min,min_value,max,max_value){
  285. let min_default = this.findKey(min, min_value);
  286. if (min_default === undefined) {
  287. min_default = 0;
  288. }
  289. let max_default = this.findKey(max, max_value);
  290. if (max_default === undefined) {
  291. max_default = 0;
  292. }
  293. return [
  294. {
  295. values: min,
  296. default: min_default,
  297. },
  298. {
  299. values: max,
  300. default: max_default,
  301. },
  302. ];
  303. },
  304. //多列选择器值
  305. getColumnsValue(min,max,ext) {
  306. if (min === '' || max === '') {
  307. return '';
  308. }
  309. if (min === 0 && max === 0) {
  310. return '不限';
  311. }
  312. let min_ext = min + ext;
  313. if (min === 0) {
  314. min_ext = '不限';
  315. }
  316. let max_ext = max + ext;
  317. if (max === 0) {
  318. max_ext = '不限';
  319. }
  320. return `${min_ext}-${max_ext}`;
  321. },
  322. //找键
  323. findKey(obj, value, compare = (a, b) => a === b) {
  324. return Object.keys(obj).find(k => compare(obj[k], value))
  325. },
  326. onIncomeConfirm(value) {
  327. this.form.income = value;
  328. this.showIncome = false;
  329. },
  330. onHaveHouseConfirm(value,index) {
  331. this.form.have_house = index;
  332. this.showHaveHouse = false;
  333. },
  334. onHaveCarConfirm(value,index) {
  335. this.form.have_car = index;
  336. this.showHaveCar = false;
  337. },
  338. onWithParentLiveConfirm(value,index) {
  339. this.form.with_parent_live = index;
  340. this.showWithParentLive = false;
  341. },
  342. onSmokeConfirm(value) {
  343. this.form.smoke = value;
  344. this.showSmoke = false;
  345. },
  346. onDrinkConfirm(value) {
  347. this.form.drink = value;
  348. this.showDrink = false;
  349. },
  350. },
  351. computed: {
  352. //年龄
  353. age() {
  354. return this.getColumns({$min_age},this.form.min_age,{$max_age},this.form.max_age);
  355. },
  356. form_age() {
  357. return this.getColumnsValue(this.form.min_age,this.form.max_age,'岁');
  358. },
  359. //身高
  360. high() {
  361. return this.getColumns({$min_high},this.form.min_high,{$max_high},this.form.max_high);
  362. },
  363. form_high() {
  364. return this.getColumnsValue(this.form.min_high,this.form.max_high,'CM');
  365. },
  366. //体重
  367. weight() {
  368. return this.getColumns({$min_weight},this.form.min_weight,{$max_weight},this.form.max_weight);
  369. },
  370. form_weight() {
  371. return this.getColumnsValue(this.form.min_weight,this.form.max_weight,'KG');
  372. },
  373. }
  374. });
  375. </script>
  376. </block>