add.vue 17 KB

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