addFamily.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. <template>
  2. <view class="container edit_wrap">
  3. <form>
  4. <view class="form_group">
  5. <text class="red">*</text>
  6. <text class="sex">姓名:</text>
  7. <input name="data_name" @input="nameFun" placeholder="请与身份证保持一致" placeholder-class="placeholder_style" type="text" value class="placeholder_style">
  8. </input>
  9. </view>
  10. <view class="form_group">
  11. <text class="red">*</text>
  12. <text class="sex">手机号:</text>
  13. <input name="data_name" @input="telFun" placeholder="请输入11位手机号码" placeholder-class="placeholder_style" type="text" value class="placeholder_style">
  14. </input>
  15. </view>
  16. <view class="form_group">
  17. <text class="red">*</text>
  18. <text class="sex">房间号:</text>
  19. <view class="ar_picker" style="background:#fff">
  20. <view class="ar_picker_wrap">
  21. <picker @change="bindRoomIdChange" :value="own_room_list_index" :range="own_room_list" :range-key="'name'">
  22. <view>
  23. <text>{{own_room_list[own_room_list_index].name}}</text>
  24. </view>
  25. </picker>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="form_group">
  30. <text class="red">*</text>
  31. <text class="sex">住户类型:</text>
  32. <view class="ar_picker" style="background:#fff">
  33. <view class="ar_picker_wrap">
  34. <picker @change="typeChange" :value="type" :range="typeArray">
  35. <view>
  36. <text>{{typeArray[type]}}</text>
  37. </view>
  38. </picker>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="form_group">
  43. <text class="red">*</text>
  44. <text class="sex">国籍:</text>
  45. <view class="ar_picker" style="background:#fff">
  46. <view class="ar_picker_wrap">
  47. <picker @change="nationalityChange" :value="nationality" :range="nationalityArray">
  48. <view>
  49. <text>{{nationalityArray[nationality]}}</text>
  50. </view>
  51. </picker>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="form_group">
  56. <text class="sex">证件类型:</text>
  57. <input :value="nationalityName" disabled="true" placeholder-class="placeholder_style" type="text" class="placeholder_style">
  58. </input>
  59. </view>
  60. <view class="form_group">
  61. <text class="sex">证件号码:</text>
  62. <input @input="id_cardFun" name="data_name" placeholder="住户类型是业主时,必填" placeholder-class="placeholder_style" type="text" value class="placeholder_style">
  63. </input>
  64. </view>
  65. <view class="form_group">
  66. <text class="sex">性别:</text>
  67. <radio-group class="item-right radio-group" @change="sexChange">
  68. <label v-for="(item, index) in sexArray" :key="index" class="radio">
  69. <radio :value="item.sex" :checked="item.checked"></radio>{{item.name}}
  70. </label>
  71. </radio-group>
  72. </view>
  73. <view v-if="nationality==3">
  74. <view class="form_group mb0">
  75. <view>
  76. <text class="red">*</text>
  77. <text class="sex">护照图片:</text>
  78. <text class="tips">(基本身份信息页)</text>
  79. </view>
  80. </view>
  81. <view class>
  82. <view class="upload_bg img_content">
  83. <image :src="show_passport_img_uri==null?'http://139.9.103.171:1888/img/image/face_bg.png':show_passport_img_uri" class="upload_bgImg" mode="aspectFit"></image>
  84. <view v-if="show_passport_img_uri==null" @tap="chooseImage" data-index="1">
  85. <view class="upload_btn">
  86. <image src="http://139.9.103.171:1888/img/image/upload_btn.png"></image>
  87. </view>
  88. <view class="upload_text">
  89. <text>点击上传照片</text>
  90. </view>
  91. </view>
  92. <view v-if="show_passport_img_uri!=null" @tap="chooseImage" class="reUpload" data-index="1">
  93. <image src="http://139.9.103.171:1888/img/image/picture.png" class="img_icon"></image>
  94. <text>重新上传</text>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <view v-if="nationality==3">
  100. <view class="form_group mb0">
  101. <view>
  102. <text class="red">*</text>
  103. <text class="sex">入境证明:</text>
  104. <text class="tips">(入镜盖章页)</text>
  105. </view>
  106. </view>
  107. <view class>
  108. <view class="upload_bg img_content">
  109. <image :src="show_entry_img_uri==null?'../../../image/face_bg.png':show_entry_img_uri" class="upload_bgImg" mode="aspectFit"></image>
  110. <view v-if="show_entry_img_uri==null" @tap="chooseImage" data-index="2">
  111. <view class="upload_btn">
  112. <image src="http://139.9.103.171:1888/img/image/upload_btn.png"></image>
  113. </view>
  114. <view class="upload_text">
  115. <text>点击上传照片</text>
  116. </view>
  117. </view>
  118. <view v-if="show_entry_img_uri!=null" @tap="chooseImage" class="reUpload" data-index="2">
  119. <image src="http://139.9.103.171:1888/img/image/picture.png" class="img_icon"></image>
  120. <text>重新上传</text>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. <view class="" v-if="appletType==1">
  126. <view class="form_group mb0">
  127. <view>
  128. <text class="red">*</text>
  129. <text class="sex">人脸:</text>
  130. <text class="tips">(人脸用于开门,请上传正脸图片)</text>
  131. </view>
  132. </view>
  133. <view class >
  134. <view class="upload_bg img_content">
  135. <image :src="show_image_uri==null?'../../../image/face_bg.png':show_image_uri" class="upload_bgImg" mode="aspectFit"></image>
  136. <view v-if="show_image_uri==null" @tap="chooseImage" data-index="3">
  137. <view class="upload_btn">
  138. <image src="http://139.9.103.171:1888/img/image/upload_btn.png"></image>
  139. </view>
  140. <view class="upload_text">
  141. <text>点击上传人脸</text>
  142. </view>
  143. </view>
  144. <view v-if="show_image_uri!=null" @tap="chooseImage" class="reUpload" data-index="3">
  145. <image src="http://139.9.103.171:1888/img/image/picture.png" class="img_icon"></image>
  146. <text>重新上传</text>
  147. </view>
  148. </view>
  149. <view class="category">
  150. <view v-for="(item, index) in iconArray" :key="index" class="category_item">
  151. <view class="category_item_wrap" @tap="top" :data-index="item.index">
  152. <view class="icon_wrap">
  153. <image :src="item.iconUrl" class="index_icon"></image>
  154. </view>
  155. <view class="category_item_text">
  156. <text>{{item.iconText}}</text>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. </form>
  164. <view class="submit_btn">
  165. <button class="ar_btn" @tap="addApplyUser">提交添加</button>
  166. </view>
  167. </view>
  168. </template>
  169. <script>
  170. //获取app实例
  171. var app = getApp();
  172. export default {
  173. data() {
  174. return {
  175. appletType:0,
  176. name: null,
  177. //姓名
  178. tel: null,
  179. //电话号码
  180. own_room_list: null,
  181. //房间列表下标
  182. own_room_list_index: 0,
  183. typeArray: ['业主', '家属', '租户'],
  184. type: 0,
  185. nationalityArray: ['中国大陆', '中国香港/澳门', '中国台湾', '海外'],
  186. nationality: 0,
  187. nationalityName: '身份证',
  188. id_card: null,
  189. //身份证
  190. sexArray: [{
  191. name: '男',
  192. checked: true,
  193. sex: "1"
  194. }, {
  195. name: '女',
  196. checked: false,
  197. sex: "2"
  198. }],
  199. sex: "1",
  200. passport_img_uri: null,
  201. //护照照片
  202. show_passport_img_uri: null,
  203. //护照照片回显
  204. entry_img_uri: null,
  205. //入境证明
  206. show_entry_img_uri: null,
  207. //入境证明回显
  208. image_uri: null,
  209. //人脸图片地址
  210. show_image_uri: null,
  211. //人脸回显
  212. face_code: null,
  213. //图片的md5
  214. iconArray: [{
  215. "iconUrl": "http://139.9.103.171:1888/img/image/zd.png",
  216. "iconText": '不要遮挡',
  217. "index": 1
  218. }, {
  219. "iconUrl": "http://139.9.103.171:1888/img/image/mj.png",
  220. "iconText": '不戴墨镜',
  221. "index": 2
  222. }, {
  223. "iconUrl": "http://139.9.103.171:1888/img/image/zl.png",
  224. "iconText": '不能仰头俯拍',
  225. "index": 3
  226. }, {
  227. "iconUrl": "http://139.9.103.171:1888/img/image/cz.png",
  228. "iconText": '光线充足',
  229. "index": 4
  230. }, {
  231. "iconUrl": "http://139.9.103.171:1888/img/image/bg.png",
  232. "iconText": '浅色背景',
  233. "index": 5
  234. }, {
  235. "iconUrl": "http://139.9.103.171:1888/img/image/sh.png",
  236. "iconText": '物业审核生效',
  237. "index": 6
  238. }]
  239. };
  240. },
  241. components: {},
  242. props: {},
  243. onShow() {
  244. this.appletType=uni.getStorageSync("appletType")
  245. },
  246. /**
  247. * 生命周期函数--监听页面加载
  248. */
  249. onLoad: function (options) {
  250. var that = this;
  251. that.setData({
  252. own_room_list: app.globalData.own_room_list
  253. });
  254. },
  255. methods: {
  256. //获取input的标签值
  257. nameFun: function (e) {
  258. this.setData({
  259. name: e.detail.value
  260. });
  261. },
  262. telFun: function (e) {
  263. this.setData({
  264. tel: e.detail.value
  265. });
  266. },
  267. id_cardFun: function (e) {
  268. this.setData({
  269. id_card: e.detail.value
  270. });
  271. },
  272. // 住户类型
  273. typeChange: function (e) {
  274. this.setData({
  275. type: e.detail.value
  276. });
  277. },
  278. // 类别选择
  279. roomIdChange: function (e) {
  280. this.setData({
  281. own_room_list_index: e.detail.value
  282. });
  283. },
  284. //性别
  285. sexChange: function (enent) {
  286. this.setData({
  287. sex: enent.detail.value
  288. });
  289. },
  290. // 国籍
  291. nationalityChange: function (e) {
  292. let nationality = e.detail.value;
  293. let nationalityName = '';
  294. if (nationality == 0) {
  295. nationalityName = '身份证';
  296. } else if (nationality == 1) {
  297. nationalityName = '港澳居民往来内地通行证';
  298. } else if (nationality == 2) {
  299. nationalityName = '台湾居民往来大陆通行证';
  300. } else if (nationality == 3) {
  301. nationalityName = '护照';
  302. }
  303. this.setData({
  304. nationality: nationality,
  305. nationalityName: nationalityName
  306. });
  307. },
  308. //点击上传图片事件
  309. chooseImage: function (event) {
  310. var that = this;
  311. let index = event.currentTarget.dataset.index;
  312. let is_need_md5 = false;
  313. if (index == 3) {
  314. is_need_md5 = true;
  315. }
  316. uni.chooseImage({
  317. count: 1,
  318. //最多可以选择的图片张数,默认9
  319. sourceType: ['album', 'camera'],
  320. sizeType: ['compressed'],
  321. //可选择原图或压缩后的图片
  322. success: res => {
  323. let tempFilePaths = res.tempFilePaths;
  324. uni.getFileSystemManager().readFile({
  325. filePath: res.tempFilePaths[0],
  326. //选择图片返回的相对路径
  327. encoding: 'base64',
  328. //编码格式
  329. success: res => {
  330. //成功的回调
  331. app.globalData.uploadBase64('data:image/jpeg;base64,' + res.data, is_need_md5, function (result) {
  332. if (index == 1) {
  333. that.setData({
  334. passport_img_uri: result.data.uri,
  335. show_passport_img_uri: tempFilePaths[0]
  336. });
  337. } else if (index == 2) {
  338. that.setData({
  339. entry_img_uri: result.data.uri,
  340. show_entry_img_uri: tempFilePaths[0]
  341. });
  342. } else if (index == 3) {
  343. that.setData({
  344. image_uri: result.data.uri,
  345. show_image_uri: tempFilePaths[0],
  346. face_code: result.data.md5Hex
  347. });
  348. }
  349. });
  350. }
  351. });
  352. }
  353. });
  354. },
  355. //添加家人
  356. addApplyUser: function () {
  357. let that = this;
  358. let params = {};
  359. let name = that.name;
  360. if (!name) {
  361. app.globalData.autoFailHint("请填写名字");
  362. return;
  363. }
  364. params['name'] = name;
  365. let tel = that.tel;
  366. if (!tel) {
  367. app.globalData.autoFailHint("请填写手机");
  368. return;
  369. } //手机号码正则校验
  370. if (!this.$u.test.mobile(tel)) {
  371. app.globalData.autoFailHint("请填写正确手机号");
  372. return;
  373. }
  374. params['tel'] = tel;
  375. let room_id = that.own_room_list[that.own_room_list_index].id;
  376. if (!room_id) {
  377. app.globalData.autoFailHint("请选择房间号");
  378. return;
  379. }
  380. params['room_id'] = room_id;
  381. let type = that.type;
  382. params['type'] = type;
  383. let id_card = that.id_card;
  384. params['id_card'] = id_card; //业主身份时,身份证必填
  385. console.log(params)
  386. return
  387. if (type == 0 && !id_card) {
  388. app.globalData.autoFailHint("住户类型是业主时,证件号码必填");
  389. return;
  390. } //0 中国大陆 1 中国香港/澳门 2 中国台湾 3 海外
  391. let nationality = that.nationality;
  392. params['nationality'] = nationality;
  393. let passport_img_uri = that.passport_img_uri;
  394. let entry_img_uri = that.entry_img_uri;
  395. if (nationality == 3) {
  396. params['passport_img_uri'] = that.passport_img_uri;
  397. params['entry_img_uri'] = that.entry_img_uri;
  398. if (type == 0) {
  399. if (!passport_img_uri) {
  400. app.globalData.autoFailHint("请上传护照图片");
  401. return;
  402. }
  403. if (!entry_img_uri) {
  404. app.globalData.autoFailHint("请上传入境证明");
  405. return;
  406. }
  407. }
  408. }
  409. let image_uri = that.image_uri;
  410. params['image_uri'] = that.image_uri;
  411. let face_code = that.face_code;
  412. params['face_code'] = that.face_code; //性别
  413. params['sex'] = that.sex;
  414. params['member_id'] = app.globalData.member.id; //申请来源0-小程序添加 1-后台添加 2-后台导入 3-app添加
  415. params['create_type'] = '0'; ///申请的记录类型 0--认证类型 1--新增类型 2--编辑类型
  416. params['record_type'] = '1';
  417. let operation = 'member/authentication';
  418. app.globalData.postRequest(params, operation, function (res) {
  419. //添加成功
  420. if (res.data.result_code == 1) {
  421. app.globalData.oneFailHint(res.data.result_msg, function () {
  422. uni.navigateBack({
  423. delta: 1 // 返回上一级页面。
  424. });
  425. });
  426. } else {
  427. app.globalData.oneFailHint(res.data.result_msg);
  428. }
  429. });
  430. }
  431. }
  432. };
  433. </script>
  434. <style lang="scss">
  435. page{
  436. overflow-y: scroll;
  437. background: #fff;
  438. }
  439. .edit_wrap {
  440. background-color: #FFFFFF;
  441. font-size: 30rpx;
  442. padding: 0rpx 20rpx 120rpx;
  443. color: #333;
  444. }
  445. .form_group {
  446. display: flex;
  447. flex-direction: row;
  448. justify-content: space-between;
  449. margin: 20rpx 20rpx;
  450. line-height: 80rpx;
  451. position: relative;
  452. font-size: 26rpx;
  453. }
  454. .form_group .red {
  455. color: red;
  456. position: absolute;
  457. left: 0;
  458. }
  459. .form_group text.sex {
  460. margin-left: 15px;
  461. text-align: left;
  462. }
  463. .form_group .radio-group {
  464. text-align: left;
  465. width: 500rpx;
  466. }
  467. .form_group .radio-group .radio {
  468. margin-right: 60rpx;
  469. }
  470. .form_group input, .form_group picker {
  471. border: 1px solid #ddd;
  472. border-radius: 8rpx;
  473. height: 80rpx;
  474. line-height: 80rpx;
  475. padding: 0rpx 20rpx;
  476. color: #333;
  477. width: 460rpx;
  478. }
  479. .form_group button {
  480. font-size: 30rpx;
  481. height: 80rpx;
  482. line-height: 80rpx;
  483. border: 1px dotted #fff;
  484. background: white;
  485. padding: 0rpx;
  486. margin: 0rpx;
  487. outline: none;
  488. color: #000;
  489. }
  490. .placeholder_style {
  491. font-family: '微软雅黑';
  492. color: #adadad;
  493. }
  494. .save_btn {
  495. width: 600rpx;
  496. background: #d24a58;
  497. font-size: 32rpx;
  498. color: #fff;
  499. border-radius: 0rpx;
  500. margin: 40rpx 0rpx 10rpx;
  501. }
  502. /* 自定义 radio 样式 */
  503. radio {
  504. width: 38rpx;
  505. }
  506. radio .wx-radio-input {
  507. border-radius: 50%;
  508. width: 28rpx;
  509. height: 28rpx;
  510. }
  511. /* 选中后的样式 (可根据设计稿需求自己修改) */
  512. radio .wx-radio-input.wx-radio-input-checked::before {
  513. border-radius: 50%;
  514. width: 44rpx;
  515. height: 44rpx;
  516. line-height: 44rpx;
  517. text-align: center;
  518. font-size: 26rpx; /* 对勾大小 26rpx */
  519. color: #fff; /* 对勾颜色 */
  520. background: $base-btn-color;
  521. border-color: $base-btn-color;
  522. }
  523. .form_group .upload {
  524. padding: 0 28rpx;
  525. font-size: 26rpx;
  526. background: $base-btn-color;
  527. color: #fff;
  528. border: none;
  529. }
  530. .upload_tips {
  531. font-size: 24rpx;
  532. }
  533. .upload_bg {
  534. position: relative;
  535. text-align: center;
  536. }
  537. .mb0 {
  538. margin-bottom: 0;
  539. }
  540. .form_group .tips {
  541. margin-left: 50rpx;
  542. }
  543. .upload_bg .upload_bgImg {
  544. width: 540rpx;
  545. height: 400rpx;
  546. }
  547. .upload_bg .upload_btn {
  548. width: 120rpx;
  549. height: 120rpx;
  550. position: absolute;
  551. left: 50%;
  552. top: 50%;
  553. margin-left: -65rpx;
  554. margin-top: -60rpx;
  555. }
  556. .upload_bg .upload_btn image {
  557. width: 100%;
  558. height: 100%;
  559. }
  560. .upload_text {
  561. position: absolute;
  562. top: 70%;
  563. left: 50%;
  564. transform: translate(-50%, 0);
  565. color: $base-btn-color;
  566. }
  567. .upload_bg{
  568. position: relative;
  569. text-align: center;
  570. }
  571. .upload_bg .upload_btn{
  572. width: 120rpx;
  573. height: 120rpx;
  574. position: absolute;
  575. left: 50%;
  576. top: 40%;
  577. margin-left: -65rpx;
  578. margin-top: -60rpx;
  579. }
  580. .upload_bg .upload_btn image{
  581. width: 100%;
  582. height: 100%;
  583. }
  584. .upload_text{
  585. position: absolute;
  586. top: 55%;
  587. width:100%;
  588. color:$base-btn-color;
  589. }
  590. .img_content .upload_bgImg{
  591. display: inline-block;
  592. }
  593. .reUpload{
  594. height: 60rpx;
  595. line-height: 60rpx;
  596. text-align:right;
  597. color: #333;
  598. padding-right: 100rpx;
  599. }
  600. .img_content .img_icon{
  601. width: 40rpx;
  602. height: 40rpx;
  603. vertical-align: text-top;
  604. margin-right: 6rpx;
  605. border-radius: 20rpx;
  606. }
  607. .category {
  608. padding:20px 20rpx 0;
  609. overflow: auto;
  610. background-color: #FFF;
  611. text-align:center;
  612. }
  613. .category_item {
  614. width: 33.3%;
  615. float: left;
  616. margin-bottom: 40rpx;
  617. }
  618. .icon_wrap {
  619. width: 120rpx;
  620. margin: 0 auto;
  621. margin-bottom: 5px;
  622. }
  623. .index_icon {
  624. width: 60rpx;
  625. height: 60rpx;
  626. }
  627. .category_item_text {
  628. text-align: center;
  629. font-size: 24rpx;
  630. color: #999;
  631. }
  632. </style>