editFamily.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <template>
  2. <view class="" style="background-color: #FFFFFF;min-height: 100vh;">
  3. <view class="form" style="padding-top: 20rpx;">
  4. <u-form :border="true" ref="uForm">
  5. <u-form-item :required="true" label="姓名:" prop="name" label-width="150">
  6. <view style="background-color: #f6f6f6;padding: 0 20rpx;border-radius: 4rpx;">
  7. <u-input disabled :border="false" placeholder="姓名,必填" v-model="name" type="text"></u-input>
  8. </view>
  9. </u-form-item>
  10. <u-form-item :required="true" label="手机号:" prop="tel" label-width="150">
  11. <u-input :border="true" maxlength="11" placeholder="请输入11位手机号码" v-model="tel" type="number">
  12. </u-input>
  13. </u-form-item>
  14. <u-form-item :required="true" label="房间号:" prop="room_name" label-width="150">
  15. <view style="background-color: #f6f6f6;padding: 0 20rpx;border-radius: 4rpx;">
  16. <u-input disabled :border="false" placeholder="请输入房间号" v-model="room_name" type="text">
  17. </u-input>
  18. </view>
  19. </u-form-item>
  20. <u-form-item :required="true" label="住户类型:" prop="type" label-width="150">
  21. <view style="background-color: #f6f6f6;padding: 0 20rpx;border-radius: 4rpx;">
  22. <u-input disabled :border="false" placeholder="请选择住户类型" v-model="typeLabel" type="text">
  23. </u-input>
  24. </view>
  25. </u-form-item>
  26. <u-form-item :required="true" label="国籍:" prop="nationality" label-width="150">
  27. <view style="background-color: #f6f6f6;padding: 0 20rpx;border-radius: 4rpx;">
  28. <u-input disabled :border="false" placeholder="国籍" v-model="nationalityLabel" type="text">
  29. </u-input>
  30. </view>
  31. </u-form-item>
  32. <u-form-item label="证件类型:" prop="nationalityName" label-width="150">
  33. <view style="background-color: #f6f6f6;padding: 0 20rpx;border-radius: 4rpx;">
  34. <u-input disabled :border="false" placeholder="证件类型" v-model="nationalityName" type="text"></u-input>
  35. </view>
  36. </u-form-item>
  37. <u-form-item :required="type==0?true:false" label="证件号码" prop="id_card" label-width="150">
  38. <view style="background-color: #f6f6f6;padding: 0 20rpx;border-radius: 4rpx;">
  39. <u-input disabled :border="false" placeholder="身份证号" v-model="id_card" type="text"></u-input>
  40. </view>
  41. </u-form-item>
  42. <u-form-item :required="true" label="性别" prop="sex" label-width="150">
  43. <u-radio-group v-model="sex">
  44. <u-radio shape="circle" name="1">男</u-radio>
  45. <u-radio shape="circle" name="2">女</u-radio>
  46. </u-radio-group>
  47. </u-form-item>
  48. </u-form>
  49. </view>
  50. <view v-if="nationality==3" style="background-color: #FFFFFF;">
  51. <view class="form_group mb0" style="padding-left: 60rpx;">
  52. <view>
  53. <text class="sex">护照图片:</text>
  54. <text class="tips">(基本身份信息页)</text>
  55. </view>
  56. </view>
  57. <view @click="operaType=1;chooseImage()"
  58. style="margin: 30rpx 0 10rpx 0;display: flex;align-items: center;flex-direction: column;">
  59. <upload-img :width="$isEmpty(show_passport_img_uri)?bgWidth:imgWidth"
  60. :height="$isEmpty(show_passport_img_uri)?bgHeight:imgHeight" :currentImage="show_passport_img_uri"
  61. :bgsrc="bgsrc">
  62. </upload-img>
  63. <view class="" style="color: #59a5f0;">
  64. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  65. <text v-if="$isEmpty(show_passport_img_uri)">点击上传护照</text>
  66. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  67. </view>
  68. </view>
  69. </view>
  70. <view v-if="nationality==3" style="background-color: #FFFFFF;">
  71. <view class="form_group mb0" style="padding-left: 60rpx;">
  72. <view>
  73. <text class="sex">入境证明:</text>
  74. <text class="tips">(入镜盖章页)</text>
  75. </view>
  76. </view>
  77. <view @click="operaType=2;chooseImage()"
  78. style="margin: 30rpx 0 10rpx 0;display: flex;align-items: center;flex-direction: column;">
  79. <upload-img :width="$isEmpty(show_entry_img_uri)?bgWidth:imgWidth"
  80. :height="$isEmpty(show_entry_img_uri)?bgHeight:imgHeight" :currentImage="show_entry_img_uri"
  81. :bgsrc="bgsrc">
  82. </upload-img>
  83. <view class="" style="color: #59a5f0;">
  84. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  85. <text v-if="$isEmpty(show_entry_img_uri)">点击上传入境证明</text>
  86. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  87. </view>
  88. </view>
  89. </view>
  90. <view style="background-color: #FFFFFF;" v-if="vuex_appletType==1">
  91. <view class="form_group mb0" style="padding-left: 60rpx;">
  92. <view>
  93. <text class="sex">人脸:</text>
  94. <text class="tips">(人脸用于开门,请上传正脸图片)</text>
  95. </view>
  96. </view>
  97. <view @click="show=true;operaType=3"
  98. style="margin: 30rpx 0 10rpx 0;display: flex;align-items: center;flex-direction: column;">
  99. <upload-img :width="$isEmpty(show_image_uri)?bgWidth:imgWidth"
  100. :height="$isEmpty(show_image_uri)?bgHeight:imgHeight" :currentImage="show_image_uri" :bgsrc="bgsrc">
  101. </upload-img>
  102. <view class="" style="color: #59a5f0;">
  103. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  104. <text v-if="$isEmpty(show_image_uri)">点击上传人脸</text>
  105. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  106. </view>
  107. </view>
  108. <view class="category" style="padding-bottom: 140rpx;">
  109. <view v-for="(item, index) in iconArray" :key="index" class="category_item">
  110. <view class="category_item_wrap" :data-index="item.index">
  111. <view class="icon_wrap">
  112. <image :src="item.iconUrl" class="index_icon"></image>
  113. </view>
  114. <view class="category_item_text">
  115. <text>{{item.iconText}}</text>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. <u-action-sheet @click="photoChecked" z-index="999999" :list="list" v-model="show"></u-action-sheet>
  122. <u-select z-index="999999" mode="single-column" :default-value="defaultType" :list="typeArry" v-model="typeShow"
  123. @confirm="typeConfirm"></u-select>
  124. <u-select z-index="999999" mode="single-column" :default-value="nationality" :list="nationalityArry"
  125. v-model="nationalityShow" @confirm="nationalityConfirm"></u-select>
  126. <view @click="editUser" class=" footer-fixed ">
  127. <view class="cu-btn flex text-lg bg-red-btn" style="padding: 46rpx 0;">
  128. 确认修改
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. </template>
  134. <script>
  135. import uploadImg from '@/comps/uploadimg/uploadImg.vue'
  136. //获取app实例
  137. var app = getApp();
  138. export default {
  139. components: {
  140. uploadImg
  141. },
  142. data() {
  143. return {
  144. //操作类型,业主操作 0,其他
  145. operUserType: '',
  146. appletType: 0,
  147. //默认点击弹出拍照模态框的是人脸上传操作,1:护照,2:入境,3:人脸
  148. operaType: 3,
  149. //人脸上传模态框,上传照片或拍照
  150. list: [{
  151. text: '相册上传',
  152. }, {
  153. text: '拍照上传'
  154. }],
  155. show: false,
  156. //背景图
  157. bgsrc: 'https://szsq.nxzhsq.cn/community/miniofile/image/camera1.png',
  158. bgWidth: 350,
  159. bgHeight: 320,
  160. //显示图
  161. imgWidth: 540,
  162. imgHeight: 400,
  163. //修改的住户id
  164. user_id: null,
  165. //姓名
  166. name: null,
  167. //电话号码
  168. tel: null,
  169. //住户类型
  170. defaultType: [0],
  171. typeLabel: '业主',
  172. typeShow: false,
  173. type: 0,
  174. typeArry: [{
  175. value: '0',
  176. label: '业主'
  177. },
  178. {
  179. value: '1',
  180. label: '家属'
  181. },
  182. {
  183. value: '2',
  184. label: '租户'
  185. }
  186. ],
  187. //国籍
  188. defaultNationality: [0],
  189. nationalityLabel: '中国大陆',
  190. nationalityShow: false,
  191. nationality: 0,
  192. nationalityName: '身份证',
  193. nationalityArry: [{
  194. value: '0',
  195. label: '中国大陆'
  196. },
  197. {
  198. value: '1',
  199. label: '中国香港/澳门'
  200. },
  201. {
  202. value: '2',
  203. label: '中国台湾'
  204. },
  205. {
  206. value: '3',
  207. label: '海外'
  208. }
  209. ],
  210. //身份证
  211. id_card: null,
  212. sex: "1",
  213. //护照照片
  214. passport_img_uri: null,
  215. //护照照片回显
  216. show_passport_img_uri: null,
  217. //入境证明
  218. entry_img_uri: null,
  219. //入境证明回显
  220. show_entry_img_uri: null,
  221. //人脸图片地址
  222. image_uri: null,
  223. //人脸回显
  224. show_image_uri: null,
  225. //图片的md5
  226. face_code: null,
  227. //图片的md5
  228. iconArray: [{
  229. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/zd.png",
  230. "iconText": '不要遮挡',
  231. "index": 1
  232. }, {
  233. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/mj.png",
  234. "iconText": '不戴墨镜',
  235. "index": 2
  236. }, {
  237. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/zl.png",
  238. "iconText": '不能仰头俯拍',
  239. "index": 3
  240. }, {
  241. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/cz.png",
  242. "iconText": '光线充足',
  243. "index": 4
  244. }, {
  245. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/bg.png",
  246. "iconText": '浅色背景',
  247. "index": 5
  248. }, {
  249. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/sh.png",
  250. "iconText": '物业审核生效',
  251. "index": 6
  252. }],
  253. room_name: ""
  254. };
  255. },
  256. onShow() {
  257. this.appletType = uni.getStorageSync("appletType")
  258. console.log(this.appletType);
  259. //获取当前页面的对象
  260. let currPage = this.$util.getPageCtx()
  261. if (!this.$isEmpty(currPage.data.image)) {
  262. this.uploadImage(currPage.data.image)
  263. }
  264. },
  265. onLoad: function(options) {
  266. let that = this
  267. this.operUserType = options.operUserType
  268. let user_id = options.user_id;
  269. let name = options.name;
  270. let tel = options.tel;
  271. let room_name = options.room_name;
  272. let type = options.type;
  273. let nationality = options.nationality;
  274. if (!nationality) {
  275. nationality = 0;
  276. }
  277. let nationalityName = '';
  278. if (nationality == 0) {
  279. nationalityName = '身份证';
  280. } else if (nationality == 1) {
  281. nationalityName = '港澳居民往来内地通行证';
  282. } else if (nationality == 2) {
  283. nationalityName = '台湾居民往来大陆通行证';
  284. } else if (nationality == 3) {
  285. nationalityName = '护照';
  286. }
  287. this.setData({
  288. nationality: nationality,
  289. nationalityName: nationalityName
  290. });
  291. let id_card = options.id_card;
  292. let sex = options.sex;
  293. let passport_img_uri = options.passport_img_uri || null;
  294. let entry_img_uri = options.entry_img_uri || null;
  295. let image_uri = options.faceUrl || null; //选中性别
  296. this.setData({
  297. user_id: user_id,
  298. name: name,
  299. tel: tel,
  300. room_name: room_name,
  301. type: type,
  302. nationality: nationality,
  303. id_card: id_card,
  304. sex: sex,
  305. show_image_uri: image_uri,
  306. show_passport_img_uri: passport_img_uri,
  307. show_entry_img_uri: entry_img_uri,
  308. });
  309. this.defaultType = []
  310. this.defaultType.push(type)
  311. this.typeLabel = that.typeArry[type].label,
  312. this.defaultNationality = []
  313. this.defaultNationality.push(nationality)
  314. this.nationalityLabel = that.nationalityArry[nationality].label
  315. },
  316. methods: {
  317. //点击模态框选项触发
  318. photoChecked(index) {
  319. if (index == 0) {
  320. //图片上传
  321. this.chooseImage()
  322. } else if (index == 1) {
  323. //拍照上传
  324. uni.navigateTo({
  325. url: "../../my-camera/my-camera"
  326. })
  327. }
  328. },
  329. typeConfirm(e) {
  330. this.type = 0;
  331. e.map((val, index) => {
  332. this.type = val.value
  333. this.typeLabel = val.label
  334. })
  335. },
  336. nationalityConfirm(e) {
  337. this.nationality = 0;
  338. e.map((val, index) => {
  339. this.nationality = val.value
  340. this.nationalityLabel = val.label
  341. if (this.nationality == 0) {
  342. this.nationalityName = '身份证';
  343. } else if (this.nationality == 1) {
  344. this.nationalityName = '港澳居民往来内地通行证';
  345. } else if (this.nationality == 2) {
  346. this.nationalityName = '台湾居民往来大陆通行证';
  347. } else if (this.nationality == 3) {
  348. this.nationalityName = '护照';
  349. }
  350. })
  351. },
  352. //点击上传图片事件
  353. chooseImage: function() {
  354. var that = this;
  355. uni.chooseImage({
  356. count: 1,
  357. //最多可以选择的图片张数,默认9
  358. sourceType: ['album', 'camera'],
  359. sizeType: ['compressed'],
  360. //可选择原图或压缩后的图片
  361. success: res => {
  362. let tempFilePaths = res.tempFilePaths;
  363. that.uploadImage(tempFilePaths[0])
  364. }
  365. });
  366. },
  367. /**上传图片
  368. * @param {Object} imgUrl 图片url
  369. */
  370. uploadImage(imgUrl) {
  371. console.log("operatype: ", this.operaType);
  372. console.log("imgUrl", imgUrl)
  373. var that = this;
  374. //是否需要md5加密上传人脸照
  375. let is_need_md5 = false;
  376. if (this.operaType == 3) {
  377. is_need_md5 = true;
  378. }
  379. that.$http.uploadFile(imgUrl).then(res => {
  380. if (that.operaType == 1) {
  381. that.setData({
  382. passport_img_uri: res.data.data.link,
  383. show_passport_img_uri: imgUrl
  384. });
  385. } else if (that.operaType == 2) {
  386. that.setData({
  387. entry_img_uri: res.data.data.link,
  388. show_entry_img_uri: imgUrl
  389. });
  390. } else if (that.operaType == 3) {
  391. that.setData({
  392. image_uri: res.data.data.link,
  393. show_image_uri: imgUrl,
  394. face_code: res.data.data.imgMd5
  395. });
  396. }
  397. })
  398. },
  399. //添加家人
  400. editUser: function() {
  401. let that = this;
  402. let params = {};
  403. let user_id = that.user_id;
  404. params['user_id'] = user_id;
  405. let tel = that.tel;
  406. if (!tel) {
  407. app.globalData.autoFailHint("请填写手机");
  408. return;
  409. } //手机号码正则校验
  410. if (!this.$u.test.mobile(tel)) {
  411. app.globalData.autoFailHint("请填写正确手机号");
  412. return;
  413. }
  414. params['tel'] = tel;
  415. let type = that.type;
  416. params['type'] = type;
  417. let id_card = that.id_card;
  418. params['id_card'] = id_card; //业主身份时,身份证必填
  419. if (type == 0 && !id_card) {
  420. app.globalData.autoFailHint("住户类型是业主时,身份证必填");
  421. return;
  422. } //0 中国大陆 1 中国香港/澳门 2 中国台湾 3 海外
  423. if (!this.$isEmpty(id_card)) {
  424. //如果身份证号不为空,就校验身份证号
  425. if (!this.$u.test.idCard(id_card)) {
  426. app.globalData.autoFailHint("请输入正确的身份证号");
  427. return;
  428. }
  429. }
  430. let nationality = that.nationality;
  431. params['nationality'] = nationality;
  432. let passport_img_uri = that.passport_img_uri;
  433. let entry_img_uri = that.entry_img_uri;
  434. if (nationality == 3) {
  435. params['passportImgUri'] = that.passport_img_uri;
  436. params['entryImgUri'] = that.entry_img_uri;
  437. if (type == 0) {
  438. if (!passport_img_uri && !that.show_passport_img_uri) {
  439. app.globalData.autoFailHint("请上传护照图片");
  440. return;
  441. }
  442. if (!entry_img_uri && !that.show_entry_img_uri) {
  443. app.globalData.autoFailHint("请上传入境证明");
  444. return;
  445. }
  446. }
  447. }
  448. let image_uri = that.image_uri;
  449. let face_code = that.face_code;
  450. if (image_uri && face_code) {
  451. params['image_uri'] = that.image_uri;
  452. params['face_code'] = that.face_code;
  453. } //性别
  454. params['oper_user_type'] = that.operUserType
  455. params['sex'] = that.sex; //添加了人脸
  456. params['member_id'] = app.globalData.member.id; //申请来源0-小程序添加 1-后台添加 2-后台导入 3-app添加
  457. params['operatorName'] = app.globalData.member.name;
  458. params['create_type'] = '0';
  459. params['name'] = that.name;
  460. console.log(params)
  461. // let operation = 'user/editUser';
  462. that.$http.editFamily(params).then(res => {
  463. //添加成功
  464. if (res.data.result_code == 1) {
  465. app.globalData.oneFailHint(res.data.result_msg, function() {
  466. uni.navigateBack({
  467. delta: 1 // 返回上一级页面。
  468. });
  469. });
  470. } else {
  471. app.globalData.oneFailHint(res.data.result_msg);
  472. }
  473. });
  474. }
  475. }
  476. };
  477. </script>
  478. <style scoped lang="scss">
  479. .form {
  480. padding: 0 60rpx;
  481. background-color: #FFFFFF;
  482. }
  483. .local_city {
  484. padding: 30rpx 0;
  485. position: relative;
  486. background: #fff;
  487. }
  488. .local_city .changeCity {
  489. padding: 20rpx;
  490. position: absolute;
  491. right: 0rpx;
  492. top: 0;
  493. }
  494. .local_city .icon {
  495. padding: 20rpx;
  496. position: absolute;
  497. left: -0;
  498. top: 50%;
  499. transform: translate(0, -50%);
  500. font-size: 40rpx;
  501. }
  502. .local_city .local_city_info {
  503. padding-left: 40rpx;
  504. display: inline-block;
  505. }
  506. .form_group .upload {
  507. padding: 0 28rpx;
  508. font-size: 26rpx;
  509. background: $base-btn-color;
  510. color: #fff;
  511. border: none;
  512. }
  513. .upload_tips {
  514. font-size: 24rpx;
  515. }
  516. .upload_bg {
  517. position: relative;
  518. text-align: center;
  519. }
  520. .mb0 {
  521. padding-top: 40rpx;
  522. font-size: 28rpx;
  523. margin-bottom: 0;
  524. }
  525. .form_group .tips {
  526. margin-left: 50rpx;
  527. }
  528. .upload_bg .upload_bgImg {
  529. width: 540rpx;
  530. height: 400rpx;
  531. }
  532. .upload_bg .upload_btn {
  533. width: 120rpx;
  534. height: 120rpx;
  535. position: absolute;
  536. left: 50%;
  537. top: 50%;
  538. margin-left: -65rpx;
  539. margin-top: -60rpx;
  540. }
  541. .upload_bg .upload_btn image {
  542. width: 100%;
  543. height: 100%;
  544. }
  545. .upload_text {
  546. position: absolute;
  547. top: 70%;
  548. left: 50%;
  549. transform: translate(-50%, 0);
  550. color: $base-btn-color;
  551. }
  552. upload_bg {
  553. position: relative;
  554. }
  555. .upload_bg .upload_btn {
  556. width: 120rpx;
  557. height: 120rpx;
  558. position: absolute;
  559. left: 50%;
  560. top: 40%;
  561. margin-left: -65rpx;
  562. margin-top: -60rpx;
  563. }
  564. .upload_bg .upload_btn image {
  565. width: 100%;
  566. height: 100%;
  567. }
  568. .upload_text {
  569. position: absolute;
  570. top: 55%;
  571. width: 100%;
  572. color: $base-btn-color;
  573. }
  574. .img_content {
  575. margin-top: 20rpx;
  576. position: relative;
  577. text-align: center;
  578. }
  579. .img_content .upload_bgImg {
  580. width: 560rpx;
  581. height: 420rpx;
  582. max-height: 1;
  583. display: inline-block;
  584. border-radius: 20rpx;
  585. }
  586. .reUpload {
  587. height: 60rpx;
  588. line-height: 60rpx;
  589. text-align: right;
  590. color: #333;
  591. padding-right: 100rpx;
  592. font-size: 26rpx;
  593. }
  594. .img_content .img_icon {
  595. width: 40rpx;
  596. height: 40rpx;
  597. vertical-align: text-top;
  598. margin-right: 6rpx;
  599. border-radius: 20rpx;
  600. }
  601. .category {
  602. padding: 20px 20rpx 0;
  603. overflow: auto;
  604. background-color: #FFF;
  605. text-align: center;
  606. }
  607. .category_item {
  608. width: 33.3%;
  609. float: left;
  610. margin-bottom: 40rpx;
  611. }
  612. .icon_wrap {
  613. width: 120rpx;
  614. margin: 0 auto;
  615. margin-bottom: 5px;
  616. }
  617. .index_icon {
  618. width: 60rpx;
  619. height: 60rpx;
  620. }
  621. .category_item_text {
  622. text-align: center;
  623. font-size: 24rpx;
  624. color: #999;
  625. }
  626. </style>