add.vue 17 KB

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