editFamily.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. <template>
  2. <view class="" style="background-color: #FFFFFF;">
  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="number"></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;">
  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. //默认点击弹出拍照模态框的是人面上传操作,1:护照,2:入境,3:人面
  134. operaType:3,
  135. //人面上传模态框,上传照片或拍照
  136. list: [{
  137. text: '相册上传',
  138. }, {
  139. text: '拍照上传'
  140. }],
  141. show: false,
  142. //背景图
  143. bgsrc:'http://139.9.103.171:1888/img/image/camera1.png',
  144. bgWidth:350,
  145. bgHeight:320,
  146. //显示图
  147. imgWidth:540,
  148. imgHeight:400,
  149. //修改的住户id
  150. user_id: null,
  151. //姓名
  152. name: null,
  153. //电话号码
  154. tel: null,
  155. //住户类型
  156. defaultType:[0],
  157. typeLabel:'业主',
  158. typeShow: false,
  159. type: 0,
  160. typeArry: [
  161. {
  162. value: '0',
  163. label: '业主'
  164. },
  165. {
  166. value: '1',
  167. label: '成员'
  168. },
  169. {
  170. value: '2',
  171. label: '租户'
  172. }
  173. ],
  174. //国籍
  175. defaultNationality:[0],
  176. nationalityLabel:'中国大陆',
  177. nationalityShow: false,
  178. nationality: 0,
  179. nationalityName:'身份证',
  180. nationalityArry: [
  181. {
  182. value: '0',
  183. label: '中国大陆'
  184. },
  185. {
  186. value: '1',
  187. label: '中国香港/澳门'
  188. },
  189. {
  190. value: '2',
  191. label: '中国台湾'
  192. },
  193. {
  194. value: '3',
  195. label: '海外'
  196. }
  197. ],
  198. //身份证
  199. id_card: null,
  200. sex: "1",
  201. //护照照片
  202. passport_img_uri: null,
  203. //护照照片回显
  204. show_passport_img_uri: null,
  205. //入境证明
  206. entry_img_uri: null,
  207. //入境证明回显
  208. show_entry_img_uri: null,
  209. //人脸图片地址
  210. image_uri: null,
  211. //人脸回显
  212. show_image_uri: null,
  213. //图片的md5
  214. face_code: null,
  215. //图片的md5
  216. iconArray: [{
  217. "iconUrl": "http://139.9.103.171:1888/img/image/zd.png",
  218. "iconText": '不要遮挡',
  219. "index": 1
  220. }, {
  221. "iconUrl": "http://139.9.103.171:1888/img/image/mj.png",
  222. "iconText": '不戴墨镜',
  223. "index": 2
  224. }, {
  225. "iconUrl": "http://139.9.103.171:1888/img/image/zl.png",
  226. "iconText": '不能仰头俯拍',
  227. "index": 3
  228. }, {
  229. "iconUrl": "http://139.9.103.171:1888/img/image/cz.png",
  230. "iconText": '光线充足',
  231. "index": 4
  232. }, {
  233. "iconUrl": "http://139.9.103.171:1888/img/image/bg.png",
  234. "iconText": '浅色背景',
  235. "index": 5
  236. }, {
  237. "iconUrl": "http://139.9.103.171:1888/img/image/sh.png",
  238. "iconText": '物业审核生效',
  239. "index": 6
  240. }],
  241. room_name: ""
  242. };
  243. },
  244. onShow() {
  245. //获取当前页面的对象
  246. let currPage=this.$util.getPageCtx()
  247. if(!this.$isEmpty(currPage.data.image)){
  248. this.uploadImage(currPage.data.image)
  249. }
  250. },
  251. onLoad: function (options) {
  252. let that=this
  253. let user_id = options.user_id;
  254. let name = options.name;
  255. let tel = options.tel;
  256. let room_name = options.room_name;
  257. let type = options.type;
  258. let nationality = options.nationality;
  259. if (!nationality) {
  260. nationality = 0;
  261. }
  262. let nationalityName = '';
  263. if (nationality == 0) {
  264. nationalityName = '身份证';
  265. } else if (nationality == 1) {
  266. nationalityName = '港澳居民往来内地通行证';
  267. } else if (nationality == 2) {
  268. nationalityName = '台湾居民往来大陆通行证';
  269. } else if (nationality == 3) {
  270. nationalityName = '护照';
  271. }
  272. this.setData({
  273. nationality: nationality,
  274. nationalityName: nationalityName
  275. });
  276. let id_card = options.id_card;
  277. let sex = options.sex;
  278. let passport_img_uri = options.passport_img_uri ||null;
  279. let entry_img_uri = options.entry_img_uri || null;
  280. let image_uri = options.image_uri || null; //选中性别
  281. this.setData({
  282. user_id: user_id,
  283. name: name,
  284. tel: tel,
  285. room_name: room_name,
  286. type: type,
  287. nationality: nationality,
  288. id_card: id_card,
  289. sex: sex,
  290. show_image_uri: image_uri,
  291. show_passport_img_uri: passport_img_uri,
  292. show_entry_img_uri: entry_img_uri,
  293. });
  294. this.defaultType=[]
  295. this.defaultType.push(type)
  296. this.typeLabel=that.typeArry[type].label,
  297. this.defaultNationality=[]
  298. this.defaultNationality.push(nationality)
  299. this.nationalityLabel=that.nationalityArry[nationality].label
  300. },
  301. methods: {
  302. //点击模态框选项触发
  303. photoChecked(index){
  304. if (index==0) {
  305. //图片上传
  306. this.chooseImage()
  307. } else if(index==1){
  308. //拍照上传
  309. uni.navigateTo({
  310. url:"../../my-camera/my-camera"
  311. })
  312. }
  313. },
  314. typeConfirm(e) {
  315. this.type = 0;
  316. e.map((val, index) => {
  317. this.type=val.value
  318. this.typeLabel=val.label
  319. })
  320. },
  321. nationalityConfirm(e) {
  322. this.nationality = 0;
  323. e.map((val, index) => {
  324. this.nationality=val.value
  325. this.nationalityLabel=val.label
  326. if (this.nationality == 0) {
  327. this.nationalityName = '身份证';
  328. } else if (this.nationality == 1) {
  329. this.nationalityName = '港澳居民往来内地通行证';
  330. } else if (this.nationality == 2) {
  331. this.nationalityName = '台湾居民往来大陆通行证';
  332. } else if (this.nationality == 3) {
  333. this.nationalityName = '护照';
  334. }
  335. })
  336. },
  337. //点击上传图片事件
  338. chooseImage: function () {
  339. var that = this;
  340. uni.chooseImage({
  341. count: 1,
  342. //最多可以选择的图片张数,默认9
  343. sourceType: ['album', 'camera'],
  344. sizeType: ['compressed'],
  345. //可选择原图或压缩后的图片
  346. success: res => {
  347. let tempFilePaths = res.tempFilePaths;
  348. that.uploadImage(tempFilePaths[0])
  349. }
  350. });
  351. },
  352. /**上传图片
  353. * @param {Object} imgUrl 图片url
  354. */
  355. uploadImage(imgUrl){
  356. console.log("operatype: ",this.operaType);
  357. console.log("imgUrl",imgUrl)
  358. var that = this;
  359. //是否需要md5加密上传人面照
  360. let is_need_md5 = false;
  361. if (this.operaType == 3) {
  362. is_need_md5 = true;
  363. }
  364. uni.getFileSystemManager().readFile({
  365. filePath: imgUrl,
  366. //选择图片返回的相对路径
  367. encoding: 'base64',
  368. //编码格式
  369. success: res => {
  370. //成功的回调
  371. app.globalData.uploadBase64('data:image/jpeg;base64,' + res.data, is_need_md5, function (result) {
  372. if (that.operaType == 1) {
  373. that.setData({
  374. passport_img_uri: result.data.uri,
  375. show_passport_img_uri: imgUrl
  376. });
  377. } else if (that.operaType == 2) {
  378. that.setData({
  379. entry_img_uri: result.data.uri,
  380. show_entry_img_uri: imgUrl
  381. });
  382. } else if (that.operaType == 3) {
  383. that.setData({
  384. image_uri: result.data.uri,
  385. show_image_uri: imgUrl,
  386. face_code: result.data.md5Hex
  387. });
  388. }
  389. });
  390. }
  391. });
  392. },
  393. //添加家人
  394. editUser: function () {
  395. let that = this;
  396. let params = {};
  397. let user_id = that.user_id;
  398. params['user_id'] = user_id;
  399. let tel = that.tel;
  400. if (!tel) {
  401. app.globalData.autoFailHint("请填写手机");
  402. return;
  403. } //手机号码正则校验
  404. var telReg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
  405. if (!telReg.test(tel)) {
  406. app.globalData.autoFailHint("请填写正确手机号");
  407. return;
  408. }
  409. params['tel'] = tel;
  410. let type = that.type;
  411. params['type'] = type;
  412. let id_card = that.id_card;
  413. params['id_card'] = id_card; //业主身份时,身份证必填
  414. if (type == 0 && !id_card) {
  415. app.globalData.autoFailHint("住户类型是业主时,身份证必填");
  416. return;
  417. } //0 中国大陆 1 中国香港/澳门 2 中国台湾 3 海外
  418. let nationality = that.nationality;
  419. params['nationality'] = nationality;
  420. let passport_img_uri = that.passport_img_uri;
  421. let entry_img_uri = that.entry_img_uri;
  422. if (nationality == 3) {
  423. params['passport_img_uri'] = that.passport_img_uri;
  424. params['entry_img_uri'] = that.entry_img_uri;
  425. if (type == 0) {
  426. if (!passport_img_uri && !that.show_passport_img_uri) {
  427. app.globalData.autoFailHint("请上传护照图片");
  428. return;
  429. }
  430. if (!entry_img_uri && !that.show_entry_img_uri) {
  431. app.globalData.autoFailHint("请上传入境证明");
  432. return;
  433. }
  434. }
  435. }
  436. let image_uri = that.image_uri;
  437. let face_code = that.face_code;
  438. if (image_uri && face_code) {
  439. params['image_uri'] = that.image_uri;
  440. params['face_code'] = that.face_code;
  441. } //性别
  442. params['sex'] = that.sex; //添加了人脸
  443. params['member_id'] = app.globalData.member.id; //申请来源0-小程序添加 1-后台添加 2-后台导入 3-app添加
  444. params['create_type'] = '0';
  445. console.log(params)
  446. let operation = 'user/editUser';
  447. app.globalData.postRequest(params, operation, function (res) {
  448. //添加成功
  449. if (res.data.result_code == 1) {
  450. app.globalData.oneFailHint(res.data.result_msg, function () {
  451. uni.navigateBack({
  452. delta: 1 // 返回上一级页面。
  453. });
  454. });
  455. } else {
  456. app.globalData.oneFailHint(res.data.result_msg);
  457. }
  458. });
  459. }
  460. }
  461. };
  462. </script>
  463. <style scoped lang="scss">
  464. .form {
  465. padding:0 60rpx;
  466. background-color: #FFFFFF;
  467. }
  468. .local_city{
  469. padding: 30rpx 0;
  470. position:relative;
  471. background: #fff;
  472. }
  473. .local_city .changeCity{
  474. padding: 20rpx;
  475. position: absolute;
  476. right: 0rpx;
  477. top: 0;
  478. }
  479. .local_city .icon{
  480. padding: 20rpx;
  481. position: absolute;
  482. left: -0;
  483. top: 50%;
  484. transform: translate(0,-50%);
  485. font-size: 40rpx;
  486. }
  487. .local_city .local_city_info{
  488. padding-left: 40rpx;
  489. display:inline-block;
  490. }
  491. .form_group .upload {
  492. padding: 0 28rpx;
  493. font-size: 26rpx;
  494. background: $base-btn-color;
  495. color: #fff;
  496. border: none;
  497. }
  498. .upload_tips {
  499. font-size: 24rpx;
  500. }
  501. .upload_bg {
  502. position: relative;
  503. text-align: center;
  504. }
  505. .mb0 {
  506. padding-top: 40rpx;
  507. font-size: 28rpx;
  508. margin-bottom: 0;
  509. }
  510. .form_group .tips {
  511. margin-left: 50rpx;
  512. }
  513. .upload_bg .upload_bgImg {
  514. width: 540rpx;
  515. height: 400rpx;
  516. }
  517. .upload_bg .upload_btn {
  518. width: 120rpx;
  519. height: 120rpx;
  520. position: absolute;
  521. left: 50%;
  522. top: 50%;
  523. margin-left: -65rpx;
  524. margin-top: -60rpx;
  525. }
  526. .upload_bg .upload_btn image {
  527. width: 100%;
  528. height: 100%;
  529. }
  530. .upload_text {
  531. position: absolute;
  532. top: 70%;
  533. left: 50%;
  534. transform: translate(-50%, 0);
  535. color: $base-btn-color;
  536. }
  537. upload_bg {
  538. position: relative;
  539. }
  540. .upload_bg .upload_btn {
  541. width: 120rpx;
  542. height: 120rpx;
  543. position: absolute;
  544. left: 50%;
  545. top: 40%;
  546. margin-left: -65rpx;
  547. margin-top: -60rpx;
  548. }
  549. .upload_bg .upload_btn image {
  550. width: 100%;
  551. height: 100%;
  552. }
  553. .upload_text {
  554. position: absolute;
  555. top: 55%;
  556. width: 100%;
  557. color: $base-btn-color;
  558. }
  559. .img_content {
  560. margin-top: 20rpx;
  561. position: relative;
  562. text-align: center;
  563. }
  564. .img_content .upload_bgImg {
  565. width: 560rpx;
  566. height: 420rpx;
  567. max-height: 1;
  568. display: inline-block;
  569. border-radius: 20rpx;
  570. }
  571. .reUpload {
  572. height: 60rpx;
  573. line-height: 60rpx;
  574. text-align: right;
  575. color: #333;
  576. padding-right: 100rpx;
  577. font-size: 26rpx;
  578. }
  579. .img_content .img_icon {
  580. width: 40rpx;
  581. height: 40rpx;
  582. vertical-align: text-top;
  583. margin-right: 6rpx;
  584. border-radius: 20rpx;
  585. }
  586. .category {
  587. padding:20px 20rpx 0;
  588. overflow: auto;
  589. background-color: #FFF;
  590. text-align:center;
  591. }
  592. .category_item {
  593. width: 33.3%;
  594. float: left;
  595. margin-bottom: 40rpx;
  596. }
  597. .icon_wrap {
  598. width: 120rpx;
  599. margin: 0 auto;
  600. margin-bottom: 5px;
  601. }
  602. .index_icon {
  603. width: 60rpx;
  604. height: 60rpx;
  605. }
  606. .category_item_text {
  607. text-align: center;
  608. font-size: 24rpx;
  609. color: #999;
  610. }
  611. </style>