profile.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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. required
  28. v-model="form.realname"
  29. label="真实姓名"
  30. placeholder="请输入真实姓名"
  31. ></van-field>
  32. <van-field
  33. required
  34. v-model="form.mobile"
  35. label="电话"
  36. placeholder="请输入电话号码"
  37. ></van-field>
  38. <van-field
  39. v-model="form.sex == 1 ? '男' : '女'"
  40. label="性别"
  41. placeholder="性别"
  42. disabled
  43. ></van-field>
  44. <!--生日-->
  45. <van-field
  46. required
  47. readonly
  48. clickable
  49. :value="form.birthday"
  50. label="生日"
  51. placeholder="点击选择生日"
  52. @click="showBirthday = true"
  53. ></van-field>
  54. <van-popup position="bottom" v-model="showBirthday">
  55. <van-datetime-picker
  56. title="生日"
  57. :value="new Date(form.birthday)"
  58. type="date"
  59. :min-date="minDate"
  60. @confirm="onBirthdayConfirm"
  61. @cancel="showBirthday = false"
  62. ></van-datetime-picker>
  63. </van-popup>
  64. <!--身高-->
  65. <van-field
  66. required
  67. readonly
  68. clickable
  69. :value="form_high"
  70. label="身高"
  71. placeholder="请选择身高(CM)"
  72. @click="showHigh = true"
  73. ></van-field>
  74. <van-popup position="bottom" v-model="showHigh">
  75. <van-picker
  76. title="身高"
  77. show-toolbar
  78. :columns="high"
  79. @confirm="onHighConfirm"
  80. @cancel="showHigh = false"
  81. ></van-picker>
  82. </van-popup>
  83. <!--体重-->
  84. <van-field
  85. required
  86. readonly
  87. clickable
  88. :value="form_weight"
  89. label="体重"
  90. placeholder="请选择体重(KG)"
  91. @click="showWeight = true"
  92. ></van-field>
  93. <van-popup position="bottom" v-model="showWeight">
  94. <van-picker
  95. title="体重"
  96. show-toolbar
  97. :columns="weight"
  98. @confirm="onWeightConfirm"
  99. @cancel="showWeight = false"
  100. ></van-picker>
  101. </van-popup>
  102. <!--学历-->
  103. <van-field
  104. required
  105. readonly
  106. clickable
  107. :value="form.education"
  108. label="学历"
  109. placeholder="点击选择学历"
  110. @click="showEducation = true"
  111. ></van-field>
  112. <van-popup position="bottom" v-model="showEducation">
  113. <van-picker
  114. title="学历"
  115. show-toolbar
  116. :columns="education"
  117. @confirm="onEducationConfirm"
  118. @cancel="showEducation = false"
  119. ></van-picker>
  120. </van-popup>
  121. <!--年收入-->
  122. <van-field
  123. required
  124. readonly
  125. clickable
  126. :value="form.income"
  127. label="年收入"
  128. placeholder="点击选择年收入"
  129. @click="showIncome = true"
  130. ></van-field>
  131. <van-popup position="bottom" v-model="showIncome">
  132. <van-picker
  133. title="年收入"
  134. show-toolbar
  135. :columns="income"
  136. @confirm="onIncomeConfirm"
  137. @cancel="showIncome = false"
  138. ></van-picker>
  139. </van-popup>
  140. <!--工作单位和职务-->
  141. <van-field
  142. required
  143. v-model="form.company"
  144. label="工作单位"
  145. placeholder="请输入工作单位"
  146. ></van-field>
  147. <van-field
  148. required
  149. v-model="form.job"
  150. label="职务"
  151. placeholder="请输入职务"
  152. ></van-field>
  153. <!--身份类型-->
  154. <van-field
  155. required
  156. clickable
  157. :value="form.id_type"
  158. label="身份类型"
  159. placeholder="点击选择身份类型"
  160. @click="showIdType = true"
  161. ></van-field>
  162. <van-popup position="bottom" v-model="showIdType">
  163. <van-picker
  164. title="身份类型"
  165. show-toolbar
  166. :columns="idType"
  167. @confirm="onIdTypeConfirm"
  168. @cancel="showIdType = false"
  169. ></van-picker>
  170. </van-popup>
  171. <!--家庭成员-->
  172. <van-field required name="form.family" label="家庭成员">
  173. <template #input>
  174. <van-row :gutter="10">
  175. <van-col span="8" v-for="(item) in family">
  176. <div :class="{btn_search_item:true,active: in_array(item,form.family)}"
  177. @click="selectFamily(item)">
  178. {{item}}
  179. <van-icon v-if="in_array(item,form.family)"
  180. class="iconfont icon-gouxuan-youxiajiaogouxuan btn_search_icon text-pink"></van-icon>
  181. </div>
  182. </van-col>
  183. </van-row>
  184. </template>
  185. </van-field>
  186. <!--籍贯-->
  187. <van-field
  188. required
  189. v-model="form.native"
  190. label="籍贯"
  191. placeholder="请输入籍贯"
  192. ></van-field>
  193. <!--民族-->
  194. <van-field
  195. readonly
  196. clickable
  197. :value="form.nation"
  198. label="民族"
  199. placeholder="点击选择民族"
  200. @click="showNation = true"
  201. ></van-field>
  202. <van-popup position="bottom" v-model="showNation">
  203. <van-picker
  204. title="民族"
  205. show-toolbar
  206. :columns="nation"
  207. @confirm="onNationConfirm"
  208. @cancel="showNation = false"
  209. ></van-picker>
  210. </van-popup>
  211. <!--兴趣爱好-->
  212. <van-field
  213. v-model="form.hobby"
  214. autosize
  215. label="兴趣爱好"
  216. type="textarea"
  217. placeholder="请输入兴趣爱好"
  218. ></van-field>
  219. <h3 class="fz16 mb10 pt20 plr12">工作生活</h3>
  220. <!--房车,与父母同住-->
  221. <van-field
  222. readonly
  223. clickable
  224. :value="tinyint[form.have_house]"
  225. label="是否有房"
  226. placeholder="点击选择是否有房"
  227. @click="showHaveHouse = true"
  228. ></van-field>
  229. <van-popup position="bottom" v-model="showHaveHouse">
  230. <van-picker
  231. title="是否有房"
  232. show-toolbar
  233. :columns="tinyint"
  234. @confirm="onHaveHouseConfirm"
  235. @cancel="showHaveHouse = false"
  236. ></van-picker>
  237. </van-popup>
  238. <van-field
  239. readonly
  240. clickable
  241. :value="tinyint[form.have_car]"
  242. label="是否有车"
  243. placeholder="点击选择是否有车"
  244. @click="showHaveCar = true"
  245. ></van-field>
  246. <van-popup position="bottom" v-model="showHaveCar">
  247. <van-picker
  248. title="是否有车"
  249. show-toolbar
  250. :columns="tinyint"
  251. @confirm="onHaveCarConfirm"
  252. @cancel="showHaveCar = false"
  253. ></van-picker>
  254. </van-popup>
  255. <van-field
  256. readonly
  257. clickable
  258. :value="tinyint[form.with_parent_live]"
  259. label="婚后是否愿意与父母同住"
  260. placeholder="点击选择"
  261. @click="showWithParentLive = true"
  262. ></van-field>
  263. <van-popup position="bottom" v-model="showWithParentLive">
  264. <van-picker
  265. title="婚后是否愿意与父母同住"
  266. show-toolbar
  267. :columns="tinyint"
  268. @confirm="onWithParentLiveConfirm"
  269. @cancel="showWithParentLive = false"
  270. ></van-picker>
  271. </van-popup>
  272. <!--是否吸烟-->
  273. <van-field
  274. readonly
  275. clickable
  276. :value="form.smoke"
  277. label="是否吸烟"
  278. placeholder="点击选择是否吸烟"
  279. @click="showSmoke = true"
  280. ></van-field>
  281. <van-popup position="bottom" v-model="showSmoke">
  282. <van-picker
  283. title="是否吸烟"
  284. show-toolbar
  285. :columns="smoke"
  286. @confirm="onSmokeConfirm"
  287. @cancel="showSmoke = false"
  288. ></van-picker>
  289. </van-popup>
  290. <!--是否喝酒-->
  291. <van-field
  292. readonly
  293. clickable
  294. :value="form.drink"
  295. label="是否喝酒"
  296. placeholder="点击选择是否喝酒"
  297. @click="showDrink = true"
  298. ></van-field>
  299. <van-popup position="bottom" v-model="showDrink">
  300. <van-picker
  301. title="是否喝酒"
  302. show-toolbar
  303. :columns="drink"
  304. @confirm="onDrinkConfirm"
  305. @cancel="showDrink = false"
  306. ></van-picker>
  307. </van-popup>
  308. <div class="split-block"></div>
  309. <h3 class="fz16 mb10 pt20 plr12">其他</h3>
  310. <van-cell center title="是否显示足迹">
  311. <template #right-icon>
  312. <van-switch v-model="form.show_footmark" size="24" :active-value="1" :inactive-value="2" active-color="#FF589B"></van-switch>
  313. </template>
  314. </van-cell>
  315. </block>
  316. <block name="script">
  317. <script>
  318. new Vue({
  319. el: '#app',
  320. data() {
  321. return {
  322. form: {$user},
  323. showBirthday: false,
  324. minDate: new Date(1920, 0, 1),
  325. showHigh: false,
  326. high: {$high},
  327. showWeight: false,
  328. weight: {$weight},
  329. showEducation: false,
  330. education: {$education},
  331. showIncome: false,
  332. income: {$income},
  333. showIdType: false,
  334. idType: {$id_type},
  335. showNation: false,
  336. nation: {$nation},
  337. showSmoke: false,
  338. smoke: {$smoke},
  339. showDrink: false,
  340. drink: {$drink},
  341. family: {$family},
  342. showHaveHouse: false,
  343. showHaveCar: false,
  344. showWithParentLive: false,
  345. tinyint: {$tinyint},
  346. };
  347. },
  348. methods: {
  349. in_array(search,array){
  350. for(var i in array){
  351. if(array[i] == search){
  352. return true;
  353. }
  354. }
  355. return false;
  356. },
  357. onBack() {
  358. history.back();
  359. },
  360. onSubmit() {
  361. if (this.form.username == '') {
  362. this.$toast('请输入用户名');
  363. return false;
  364. }
  365. if (this.form.realname == '') {
  366. this.$toast('请输入真实姓名');
  367. return false;
  368. }
  369. if (this.form.mobile == '') {
  370. this.$toast('请输入电话号码');
  371. return false;
  372. }
  373. if (this.form.birthday == '1970-01-01') {
  374. this.$toast('请选择正确的生日');
  375. return false;
  376. }
  377. if (this.form.education == '') {
  378. this.$toast('请选择学历');
  379. return false;
  380. }
  381. if (this.form.id_type == '') {
  382. this.$toast('请选择身份类型');
  383. return false;
  384. }
  385. if (this.form.income == '') {
  386. this.$toast('请选择年收入');
  387. return false;
  388. }
  389. if (this.form.company == '') {
  390. this.$toast('请输入工作单位');
  391. return false;
  392. }
  393. if (this.form.job == '') {
  394. this.$toast('请输入职务');
  395. return false;
  396. }
  397. if (this.form.family.length == 0) {
  398. this.$toast('请选择家庭成员');
  399. return false;
  400. }
  401. if (this.form.native == '') {
  402. this.$toast('请输入籍贯');
  403. return false;
  404. }
  405. $.post("{:url('profilePost')}", this.form, function (json) {
  406. history.back();
  407. }, 'json');
  408. },onBirthdayConfirm(date) {
  409. let year = date.getFullYear();
  410. let month = date.getMonth() + 1;
  411. if (month < 10) {
  412. month = "0" + month;
  413. }
  414. let day = date.getDate();
  415. if (day < 10) {
  416. day = "0" + day;
  417. }
  418. this.form.birthday = `${year}-${month}-${day}`;
  419. this.showBirthday = false;
  420. },
  421. onHighConfirm(value) {
  422. this.form.high = value == '保密' ? 0 : value;
  423. this.showHigh = false;
  424. },
  425. onWeightConfirm(value) {
  426. this.form.weight = value == '保密' ? 0 : value;
  427. this.showWeight = false;
  428. },
  429. onEducationConfirm(value) {
  430. this.form.education = value;
  431. this.showEducation = false;
  432. },
  433. onIncomeConfirm(value) {
  434. this.form.income = value;
  435. this.showIncome = false;
  436. },
  437. onNationConfirm(value) {
  438. this.form.nation = value;
  439. this.showNation = false;
  440. },
  441. onIdTypeConfirm(value) {
  442. this.form.id_type = value;
  443. this.showIdType = false;
  444. },
  445. onHaveHouseConfirm(value,index) {
  446. this.form.have_house = index;
  447. this.showHaveHouse = false;
  448. },
  449. onHaveCarConfirm(value,index) {
  450. this.form.have_car = index;
  451. this.showHaveCar = false;
  452. },
  453. onWithParentLiveConfirm(value,index) {
  454. this.form.with_parent_live = index;
  455. this.showWithParentLive = false;
  456. },
  457. onSmokeConfirm(value) {
  458. this.form.smoke = value;
  459. this.showSmoke = false;
  460. },
  461. onDrinkConfirm(value) {
  462. this.form.drink = value;
  463. this.showDrink = false;
  464. },
  465. removeByVal(arrylist , val) {
  466. for(var i = 0; i < arrylist .length; i++) {
  467. if(arrylist[i] == val) {
  468. arrylist .splice(i, 1);
  469. break;
  470. }
  471. }
  472. },
  473. selectFamily(value) {
  474. if (this.in_array(value,this.form.family)) {
  475. this.removeByVal(this.form.family,value);
  476. } else {
  477. this.form.family.push(value);
  478. }
  479. },
  480. },
  481. computed: {
  482. form_high() {
  483. return this.form.high ? this.form.high + 'CM' : '保密';
  484. },
  485. form_weight() {
  486. return this.form.weight ? this.form.weight + 'KG' : '保密';
  487. },
  488. },
  489. });
  490. </script>
  491. </block>