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