add.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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="name" :list="own_room_list"
  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_id: 0,
  158. own_room_list: null,
  159. //房间列表下标
  160. own_room_list_index: 0,
  161. //姓名
  162. name: null,
  163. //电话号码
  164. tel: null,
  165. //住户类型
  166. typeLabel: '业主',
  167. typeShow: false,
  168. type: 0,
  169. typeArry: [{
  170. value: '0',
  171. label: '业主'
  172. },
  173. {
  174. value: '1',
  175. label: '家属'
  176. },
  177. {
  178. value: '2',
  179. label: '租户'
  180. }
  181. ],
  182. //国籍
  183. nationalityLabel: '中国大陆',
  184. nationalityShow: false,
  185. nationality: 0,
  186. nationalityName: '身份证',
  187. nationalityArry: [{
  188. value: '0',
  189. label: '中国大陆'
  190. },
  191. {
  192. value: '1',
  193. label: '中国香港/澳门'
  194. },
  195. {
  196. value: '2',
  197. label: '中国台湾'
  198. },
  199. {
  200. value: '3',
  201. label: '海外'
  202. }
  203. ],
  204. //身份证
  205. id_card: null,
  206. sex: "1",
  207. passport_img_uri: null,
  208. //护照照片
  209. show_passport_img_uri: null,
  210. //护照照片回显
  211. entry_img_uri: null,
  212. //入境证明
  213. show_entry_img_uri: null,
  214. //入境证明回显
  215. image_uri: null,
  216. //人脸图片地址
  217. show_image_uri: null,
  218. //人脸回显
  219. face_code: null,
  220. //图片的md5
  221. iconArray: [{
  222. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/zd.png",
  223. "iconText": '不要遮挡',
  224. "index": 1
  225. }, {
  226. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/mj.png",
  227. "iconText": '不戴墨镜',
  228. "index": 2
  229. }, {
  230. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/zl.png",
  231. "iconText": '不能仰头俯拍',
  232. "index": 3
  233. }, {
  234. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/cz.png",
  235. "iconText": '光线充足',
  236. "index": 4
  237. }, {
  238. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/bg.png",
  239. "iconText": '浅色背景',
  240. "index": 5
  241. }, {
  242. "iconUrl": "https://szsq.nxzhsq.cn/community/miniofile/image/sh.png",
  243. "iconText": '物业审核生效',
  244. "index": 6
  245. }]
  246. };
  247. },
  248. onLoad: function(options) {
  249. var that = this;
  250. that.setData({
  251. own_room_list: app.globalData.own_room_list
  252. });
  253. },
  254. onShow() {
  255. this.appletType = uni.getStorageSync("appletType")
  256. //获取当前页面的对象
  257. let currPage = this.$util.getPageCtx()
  258. if (!this.$isEmpty(currPage.data.image)) {
  259. this.uploadImage(currPage.data.image)
  260. }
  261. },
  262. methods: {
  263. //点击模态框选项触发
  264. photoChecked(index) {
  265. if (index == 0) {
  266. //图片上传
  267. this.chooseImage()
  268. } else if (index == 1) {
  269. //拍照上传
  270. uni.navigateTo({
  271. url: "../../my-camera/my-camera"
  272. })
  273. }
  274. },
  275. //点击上传图片事件
  276. chooseImage: function() {
  277. var that = this;
  278. uni.chooseImage({
  279. count: 1,
  280. //最多可以选择的图片张数,默认9
  281. sourceType: ['album', 'camera'],
  282. sizeType: ['compressed'],
  283. //可选择原图或压缩后的图片
  284. success: res => {
  285. let tempFilePaths = res.tempFilePaths;
  286. that.uploadImage(tempFilePaths[0])
  287. }
  288. });
  289. },
  290. /**上传图片
  291. * @param {Object} imgUrl 图片url
  292. */
  293. uploadImage(imgUrl) {
  294. console.log("operatype: ", this.operaType);
  295. console.log("imgUrl", 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.room_id = 0;
  325. e.map((val, index) => {
  326. this.room_id = val.value
  327. this.roomLabel = val.label
  328. })
  329. },
  330. typeConfirm(e) {
  331. this.type = 0;
  332. e.map((val, index) => {
  333. this.type = val.value
  334. this.typeLabel = val.label
  335. })
  336. },
  337. nationalityConfirm(e) {
  338. this.nationality = 0;
  339. e.map((val, index) => {
  340. this.nationality = val.value
  341. this.nationalityLabel = val.label
  342. if (this.nationality == 0) {
  343. this.nationalityName = '身份证';
  344. } else if (this.nationality == 1) {
  345. this.nationalityName = '港澳居民往来内地通行证';
  346. } else if (this.nationality == 2) {
  347. this.nationalityName = '台湾居民往来大陆通行证';
  348. } else if (this.nationality == 3) {
  349. this.nationalityName = '护照';
  350. }
  351. })
  352. },
  353. //添加家人
  354. async addApplyUser() {
  355. let that = this;
  356. let params = {};
  357. let name = that.name;
  358. if (!name) {
  359. app.globalData.autoFailHint("请填写名字");
  360. return;
  361. }
  362. params['name'] = name;
  363. let tel = that.tel;
  364. if (tel && !this.$u.test.mobile(tel)) {
  365. app.globalData.autoFailHint("请填写正确手机号");
  366. return;
  367. }
  368. params['phone'] = tel;
  369. let room_id = that.own_room_list[that.own_room_list_index].id;
  370. if (!room_id) {
  371. app.globalData.autoFailHint("请选择房间号");
  372. return;
  373. }
  374. params['room_id'] = room_id;
  375. let type = that.type;
  376. params['type'] = type;
  377. let id_card = that.id_card;
  378. params['id_card'] = id_card; //业主身份时,身份证必填
  379. //0 中国大陆 1 中国香港/澳门 2 中国台湾 3 海外
  380. if (!this.$isEmpty(id_card)) {
  381. //如果身份证号不为空,就校验身份证号
  382. if (!this.$u.test.idCard(id_card)) {
  383. app.globalData.autoFailHint("请输入正确的身份证号");
  384. return;
  385. }
  386. }
  387. let nationality = that.nationality;
  388. params['nationality'] = nationality;
  389. let passport_img_uri = that.passport_img_uri;
  390. let entry_img_uri = that.entry_img_uri;
  391. if (nationality == 3) {
  392. params['passport_img_uri'] = that.passport_img_uri;
  393. params['entry_img_uri'] = that.entry_img_uri;
  394. if (type == 0) {
  395. if (!passport_img_uri) {
  396. app.globalData.autoFailHint("请上传护照图片");
  397. return;
  398. }
  399. if (!entry_img_uri) {
  400. app.globalData.autoFailHint("请上传入境证明");
  401. return;
  402. }
  403. }
  404. }
  405. let image_uri = that.image_uri;
  406. if (this.$isEmpty(image_uri) && this.vuex_appletType == 1) {
  407. //微信小程序通过审核时,开放人脸模块
  408. this.$u.toast('请上传人脸')
  409. return
  410. }
  411. params['face_url'] = that.image_uri;
  412. let face_code = that.face_code;
  413. params['face_code'] = that.face_code; //性别
  414. params['oper_user_type'] = 0 //操作类型,业主操作
  415. params['sex'] = that.sex;
  416. params['member_id'] = app.globalData.member.id;
  417. params['operatorName'] = app.globalData.member.name;
  418. params['create_type'] = '0'; //申请来源0-小程序添加 1-后台添加 2-后台导入 3-app添加
  419. params['record_type'] = '1'; ///申请的记录类型 0--认证类型 1--新增类型 2--编辑类型
  420. // let operation = 'member/authentication';
  421. this.$dialog.showLoading('请等待...')
  422. let res=await that.$http.authentication(params)
  423. uni.hideLoading()
  424. //添加成功
  425. if (res.data.result_code == 1) {
  426. app.globalData.oneFailHint(res.data.result_msg, function() {
  427. uni.navigateBack({
  428. delta: 1 // 返回上一级页面。
  429. });
  430. });
  431. } else {
  432. app.globalData.oneFailHint(res.data.result_msg);
  433. }
  434. }
  435. }
  436. };
  437. </script>
  438. <style scoped lang="scss">
  439. .form {
  440. padding: 0 60rpx;
  441. background-color: #FFFFFF;
  442. }
  443. .local_city {
  444. padding: 30rpx 0;
  445. position: relative;
  446. background: #fff;
  447. }
  448. .local_city .changeCity {
  449. padding: 20rpx;
  450. position: absolute;
  451. right: 0rpx;
  452. top: 0;
  453. }
  454. .local_city .icon {
  455. padding: 20rpx;
  456. position: absolute;
  457. left: -0;
  458. top: 50%;
  459. transform: translate(0, -50%);
  460. font-size: 40rpx;
  461. }
  462. .local_city .local_city_info {
  463. padding-left: 40rpx;
  464. display: inline-block;
  465. }
  466. .form_group .upload {
  467. padding: 0 28rpx;
  468. font-size: 26rpx;
  469. background: $base-btn-color;
  470. color: #fff;
  471. border: none;
  472. }
  473. .upload_tips {
  474. font-size: 24rpx;
  475. }
  476. .upload_bg {
  477. position: relative;
  478. text-align: center;
  479. }
  480. .mb0 {
  481. padding-top: 40rpx;
  482. font-size: 28rpx;
  483. margin-bottom: 0;
  484. }
  485. .form_group .tips {
  486. margin-left: 50rpx;
  487. }
  488. .upload_bg .upload_bgImg {
  489. width: 540rpx;
  490. height: 400rpx;
  491. }
  492. .upload_bg .upload_btn {
  493. width: 120rpx;
  494. height: 120rpx;
  495. position: absolute;
  496. left: 50%;
  497. top: 50%;
  498. margin-left: -65rpx;
  499. margin-top: -60rpx;
  500. }
  501. .upload_bg .upload_btn image {
  502. width: 100%;
  503. height: 100%;
  504. }
  505. .upload_text {
  506. position: absolute;
  507. top: 70%;
  508. left: 50%;
  509. transform: translate(-50%, 0);
  510. color: $base-btn-color;
  511. }
  512. upload_bg {
  513. position: relative;
  514. }
  515. .upload_bg .upload_btn {
  516. width: 120rpx;
  517. height: 120rpx;
  518. position: absolute;
  519. left: 50%;
  520. top: 40%;
  521. margin-left: -65rpx;
  522. margin-top: -60rpx;
  523. }
  524. .upload_bg .upload_btn image {
  525. width: 100%;
  526. height: 100%;
  527. }
  528. .upload_text {
  529. position: absolute;
  530. top: 55%;
  531. width: 100%;
  532. color: $base-btn-color;
  533. }
  534. .img_content {
  535. margin-top: 20rpx;
  536. position: relative;
  537. text-align: center;
  538. }
  539. .img_content .upload_bgImg {
  540. width: 560rpx;
  541. height: 420rpx;
  542. max-height: 1;
  543. display: inline-block;
  544. border-radius: 20rpx;
  545. }
  546. .reUpload {
  547. height: 60rpx;
  548. line-height: 60rpx;
  549. text-align: right;
  550. color: #333;
  551. padding-right: 100rpx;
  552. font-size: 26rpx;
  553. }
  554. .img_content .img_icon {
  555. width: 40rpx;
  556. height: 40rpx;
  557. vertical-align: text-top;
  558. margin-right: 6rpx;
  559. border-radius: 20rpx;
  560. }
  561. .category {
  562. padding: 20px 20rpx 0;
  563. overflow: auto;
  564. background-color: #FFF;
  565. text-align: center;
  566. }
  567. .category_item {
  568. width: 33.3%;
  569. float: left;
  570. margin-bottom: 40rpx;
  571. }
  572. .icon_wrap {
  573. width: 120rpx;
  574. margin: 0 auto;
  575. margin-bottom: 5px;
  576. }
  577. .index_icon {
  578. width: 60rpx;
  579. height: 60rpx;
  580. }
  581. .category_item_text {
  582. text-align: center;
  583. font-size: 24rpx;
  584. color: #999;
  585. }
  586. </style>