add.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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"></u-input>
  10. </u-form-item>
  11. <u-form-item :required="true" label="房间号:" prop="roomLabel" label-width="150">
  12. <u-input :border="true" type="select" :select-open="roomShow" v-model="roomLabel" placeholder="请选择房间号" @click="roomShow = true"></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="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" value-name="id" label-name="name" :list="own_room_list" v-model="roomShow" @confirm="roomConfirm"></u-select>
  114. <u-select z-index="999999" mode="single-column" :list="typeArry" v-model="typeShow" @confirm="typeConfirm"></u-select>
  115. <u-select z-index="999999" mode="single-column" :list="nationalityArry" v-model="nationalityShow" @confirm="nationalityConfirm"></u-select>
  116. <view @click="addApplyUser" class=" footer-fixed" >
  117. <view class="cu-btn flex text-lg bg-red-btn" style="padding: 46rpx 0;">
  118. 提交添加
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. </template>
  124. <script>
  125. import uploadImg from '@/comps/uploadimg/uploadImg.vue'
  126. //获取app实例
  127. var app = getApp();
  128. export default {
  129. components:{
  130. uploadImg
  131. },
  132. data() {
  133. return {
  134. appletType:0,
  135. //默认点击弹出拍照模态框的是人脸上传操作,1:护照,2:入境,3:人脸
  136. operaType:3,
  137. //人脸上传模态框,上传照片或拍照
  138. list: [{
  139. text: '相册上传',
  140. }, {
  141. text: '拍照上传'
  142. }],
  143. show: false,
  144. //背景图
  145. bgsrc:'http://139.9.103.171:1888/img/image/camera1.png',
  146. bgWidth:350,
  147. bgHeight:320,
  148. //显示图
  149. imgWidth:540,
  150. imgHeight:400,
  151. roomLabel:'',
  152. roomShow:false,
  153. room_id: 0,
  154. own_room_list: null,
  155. //房间列表下标
  156. own_room_list_index: 0,
  157. //姓名
  158. name: null,
  159. //电话号码
  160. tel: null,
  161. //住户类型
  162. typeLabel:'业主',
  163. typeShow: false,
  164. type: 0,
  165. typeArry: [
  166. {
  167. value: '0',
  168. label: '业主'
  169. },
  170. {
  171. value: '1',
  172. label: '家属'
  173. },
  174. {
  175. value: '2',
  176. label: '租户'
  177. }
  178. ],
  179. //国籍
  180. nationalityLabel:'中国大陆',
  181. nationalityShow: false,
  182. nationality: 0,
  183. nationalityName:'身份证',
  184. nationalityArry: [
  185. {
  186. value: '0',
  187. label: '中国大陆'
  188. },
  189. {
  190. value: '1',
  191. label: '中国香港/澳门'
  192. },
  193. {
  194. value: '2',
  195. label: '中国台湾'
  196. },
  197. {
  198. value: '3',
  199. label: '海外'
  200. }
  201. ],
  202. //身份证
  203. id_card: null,
  204. sex: "1",
  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. //人脸回显
  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. };
  245. },
  246. onLoad: function (options) {
  247. var that = this;
  248. that.setData({
  249. own_room_list: app.globalData.own_room_list
  250. });
  251. },
  252. onShow() {
  253. this.appletType=uni.getStorageSync("appletType")
  254. //获取当前页面的对象
  255. let currPage=this.$util.getPageCtx()
  256. if(!this.$isEmpty(currPage.data.image)){
  257. this.uploadImage(currPage.data.image)
  258. }
  259. },
  260. methods: {
  261. //点击模态框选项触发
  262. photoChecked(index){
  263. if (index==0) {
  264. //图片上传
  265. this.chooseImage()
  266. } else if(index==1){
  267. //拍照上传
  268. uni.navigateTo({
  269. url:"../../my-camera/my-camera"
  270. })
  271. }
  272. },
  273. //点击上传图片事件
  274. chooseImage: function () {
  275. var that = this;
  276. uni.chooseImage({
  277. count: 1,
  278. //最多可以选择的图片张数,默认9
  279. sourceType: ['album', 'camera'],
  280. sizeType: ['compressed'],
  281. //可选择原图或压缩后的图片
  282. success: res => {
  283. let tempFilePaths = res.tempFilePaths;
  284. that.uploadImage(tempFilePaths[0])
  285. }
  286. });
  287. },
  288. /**上传图片
  289. * @param {Object} imgUrl 图片url
  290. */
  291. uploadImage(imgUrl){
  292. console.log("operatype: ",this.operaType);
  293. console.log("imgUrl",imgUrl)
  294. var that = this;
  295. //是否需要md5加密上传人脸照
  296. let is_need_md5 = false;
  297. if (this.operaType == 3) {
  298. is_need_md5 = true;
  299. }
  300. uni.getFileSystemManager().readFile({
  301. filePath: imgUrl,
  302. //选择图片返回的相对路径
  303. encoding: 'base64',
  304. //编码格式
  305. success: res => {
  306. //成功的回调
  307. app.globalData.uploadBase64('data:image/jpeg;base64,' + res.data, is_need_md5, function (result) {
  308. if (that.operaType == 1) {
  309. that.setData({
  310. passport_img_uri: result.data.uri,
  311. show_passport_img_uri: imgUrl
  312. });
  313. } else if (that.operaType == 2) {
  314. that.setData({
  315. entry_img_uri: result.data.uri,
  316. show_entry_img_uri: imgUrl
  317. });
  318. } else if (that.operaType == 3) {
  319. that.setData({
  320. image_uri: result.data.uri,
  321. show_image_uri: imgUrl,
  322. face_code: result.data.md5Hex
  323. });
  324. }
  325. });
  326. }
  327. });
  328. },
  329. roomConfirm(e) {
  330. this.room_id = 0;
  331. e.map((val, index) => {
  332. this.room_id=val.value
  333. this.roomLabel=val.label
  334. })
  335. },
  336. typeConfirm(e) {
  337. this.type = 0;
  338. e.map((val, index) => {
  339. this.type=val.value
  340. this.typeLabel=val.label
  341. })
  342. },
  343. nationalityConfirm(e) {
  344. this.nationality = 0;
  345. e.map((val, index) => {
  346. this.nationality=val.value
  347. this.nationalityLabel=val.label
  348. if (this.nationality == 0) {
  349. this.nationalityName = '身份证';
  350. } else if (this.nationality == 1) {
  351. this.nationalityName = '港澳居民往来内地通行证';
  352. } else if (this.nationality == 2) {
  353. this.nationalityName = '台湾居民往来大陆通行证';
  354. } else if (this.nationality == 3) {
  355. this.nationalityName = '护照';
  356. }
  357. })
  358. },
  359. //添加家人
  360. addApplyUser: function () {
  361. let that = this;
  362. let params = {};
  363. let name = that.name;
  364. if (!name) {
  365. app.globalData.autoFailHint("请填写名字");
  366. return;
  367. }
  368. params['name'] = name;
  369. let tel = that.tel;
  370. if (!tel) {
  371. app.globalData.autoFailHint("请填写手机");
  372. return;
  373. } //手机号码正则校验
  374. if (!this.$u.test.mobile(tel)) {
  375. app.globalData.autoFailHint("请填写正确手机号");
  376. return;
  377. }
  378. params['tel'] = tel;
  379. let room_id = that.own_room_list[that.own_room_list_index].id;
  380. if (!room_id) {
  381. app.globalData.autoFailHint("请选择房间号");
  382. return;
  383. }
  384. params['room_id'] = room_id;
  385. let type = that.type;
  386. params['type'] = type;
  387. let id_card = that.id_card;
  388. params['id_card'] = id_card; //业主身份时,身份证必填
  389. if (type == 0 && !id_card) {
  390. app.globalData.autoFailHint("住户类型是业主时,证件号码必填");
  391. return;
  392. } //0 中国大陆 1 中国香港/澳门 2 中国台湾 3 海外
  393. let nationality = that.nationality;
  394. params['nationality'] = nationality;
  395. let passport_img_uri = that.passport_img_uri;
  396. let entry_img_uri = that.entry_img_uri;
  397. if (nationality == 3) {
  398. params['passport_img_uri'] = that.passport_img_uri;
  399. params['entry_img_uri'] = that.entry_img_uri;
  400. if (type == 0) {
  401. if (!passport_img_uri) {
  402. app.globalData.autoFailHint("请上传护照图片");
  403. return;
  404. }
  405. if (!entry_img_uri) {
  406. app.globalData.autoFailHint("请上传入境证明");
  407. return;
  408. }
  409. }
  410. }
  411. let image_uri = that.image_uri;
  412. params['image_uri'] = that.image_uri;
  413. let face_code = that.face_code;
  414. params['face_code'] = that.face_code; //性别
  415. params['oper_user_type']=0 //操作类型,业主操作
  416. params['sex'] = that.sex;
  417. params['member_id'] = app.globalData.member.id;
  418. params['create_type'] = '0';//申请来源0-小程序添加 1-后台添加 2-后台导入 3-app添加
  419. params['record_type'] = '1'; ///申请的记录类型 0--认证类型 1--新增类型 2--编辑类型
  420. let operation = 'member/authentication';
  421. console.log(params)
  422. app.globalData.postRequest(params, operation, function (res) {
  423. //添加成功
  424. if (res.data.result_code == 1) {
  425. app.globalData.oneFailHint(res.data.result_msg, function () {
  426. uni.navigateBack({
  427. delta: 1 // 返回上一级页面。
  428. });
  429. });
  430. } else {
  431. app.globalData.oneFailHint(res.data.result_msg);
  432. }
  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>