editFamily.vue 18 KB

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