auth.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <template>
  2. <view class="">
  3. <view style="padding: 0 20rpx 20rpx;" v-if="appletStatus==1">
  4. <u-top-tips type="info" ref="uTips"></u-top-tips>
  5. <u-alert-tips :show="show" type="warning" title="审核意见" :close-able="true" :description="opinion"></u-alert-tips>
  6. <view class="auth">
  7. <text class="cuIcon-titles text-blue padding-right-10"></text>
  8. <text>个人信息认证</text>
  9. <view class="card">
  10. <u-form :model="model" ref="uForm" >
  11. <u-form-item :label-width="labelWidth" label="姓名" >
  12. <u-input placeholder="请输入姓名" v-model="model.realName" type="text"></u-input>
  13. </u-form-item>
  14. <u-form-item :label-width="labelWidth" label="性别" >
  15. <u-input type="select" :select-open="sexSelectShow" v-model="sexSelectList[sexSelectIndex].text" placeholder="请选择性别" @click="sexSelectShow = true"></u-input>
  16. </u-form-item>
  17. <u-form-item label="身份证号" :label-width="labelWidth">
  18. <u-input maxlength="18" placeholder="请输入身份证号" v-model="model.idcard" type="idcard"></u-input>
  19. </u-form-item>
  20. <u-form-item label="手机号码" :label-width="labelWidth">
  21. <u-input maxlength="11" placeholder="请输入手机号" v-model="model.phone" type="number"></u-input>
  22. </u-form-item>
  23. <u-form-item :border-bottom="false" label="脸部信息采集" :label-width="labelWidth"></u-form-item>
  24. </u-form>
  25. <view @click="faceSelectShow=true" class="flex justify-center padding-bottom-50">
  26. <view class=" ">
  27. <upload-img
  28. :width="$isEmpty(model.face)?350:560"
  29. :height="$isEmpty(model.face)?350:420"
  30. :currentImage="model.face"
  31. bgsrc="http://139.9.103.171:1888/miniofile/xlyq/face1.png"
  32. >
  33. </upload-img>
  34. <view class="text-center padding-top-20" style="color: #59a5f0;">
  35. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  36. <text v-if="$isEmpty(model.face)">点击上传人脸</text>
  37. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="auth">
  44. <text class="cuIcon-titles text-blue padding-right-10"></text>
  45. <text>企业信息认证</text>
  46. <view class="card">
  47. <u-form :model="model" ref="uForm" >
  48. <u-form-item :label-width="labelWidth" label="公司园区" >
  49. <u-input type="select" :select-open="ganderSelectShow" v-model="gander" placeholder="请选择工作园区" @click="ganderShow"></u-input>
  50. </u-form-item>
  51. <u-form-item :label-width="labelWidth" label="园区区域" >
  52. <u-input type="select" :select-open="residentialSelectShow" v-model="residential" placeholder="请选择园区区域" @click="residentialShow"></u-input>
  53. </u-form-item>
  54. <u-form-item :label-width="labelWidth" label="所属企业" >
  55. <u-input type="select" :select-open="companySelectShow" v-model="company" placeholder="请选择所属企业" @click="companyShow"></u-input>
  56. </u-form-item>
  57. </u-form>
  58. </view>
  59. </view>
  60. <view class="auth">
  61. <text class="cuIcon-titles text-blue padding-right-10"></text>
  62. <text>其他信息</text>
  63. <view class="card">
  64. <u-form :model="model" ref="uForm" >
  65. <u-form-item label-position="top" :border-bottom="false" :label-width="labelWidth" label="备注(可选)" >
  66. <u-input height="200" v-model="model.remarks" placeholder="填写备注信息" type="textarea" :border="border" />
  67. </u-form-item>
  68. <!-- <textarea value="" v-model="model.remarks" placeholder="填写备注信息" /> -->
  69. </u-form>
  70. </view>
  71. </view>
  72. <view class="auth flex justify-between">
  73. <view class="flex flex-direction">
  74. <view class="">
  75. <text class="cuIcon-noticefill text-blue padding-right-10"></text>
  76. <text>消息通知提醒</text>
  77. </view>
  78. <view class="padding-top-10 text-sm text-gray">
  79. <text>开启订阅后,认证审核通知将推送到您的微信上</text>
  80. </view>
  81. </view>
  82. <button v-if="subscribeShow" @click="subscribe" class="cu-btn sm round bg-blue">
  83. 订阅
  84. </button>
  85. <button v-else @opensetting="opensetting" open-type="openSetting"class="cu-btn sm round bg-blue">
  86. 订阅
  87. </button>
  88. </view>
  89. <button open-type="getUserInfo" @getuserinfo="submit" class="cu-btn bg-blue round flex" style="padding: 40rpx 0;margin-top: 40rpx;">
  90. <text v-text="operationType==0?'提交':'重新审核'"></text>
  91. </button>
  92. <!-- 性别 -->
  93. <u-picker v-model="sexSelectShow" @confirm="sexSelectCallback" :range="sexSelectList" range-key="text" mode="selector"></u-picker>
  94. <!-- 园区 -->
  95. <u-picker v-model="ganderSelectShow" @confirm="ganderSelectCallback" :range="ganderSelectList" range-key="agencyName" mode="selector"></u-picker>
  96. <!-- 区域 -->
  97. <u-picker v-model="residentialSelectShow" @confirm="residentialSelectCallback" :range="residentialSelectList" range-key="name" mode="selector"></u-picker>
  98. <!-- 企业 -->
  99. <u-popup border-radius="60" height="60%" mode="bottom" v-model="companySelectShow">
  100. <view class="fixed cu-bar search bg-white">
  101. <view class="search-form round">
  102. <text class="cuIcon-search"></text>
  103. <u-input style="width: 90%;" v-model="keyword" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
  104. </view>
  105. <!-- <view @click="fetchEnterpriseList" class="action">
  106. <button class="cu-btn bg-blue shadow-blur round">搜索</button>
  107. </view> -->
  108. </view>
  109. <scroll-view v-if="!$isEmpty(companySelectList)" @scrolltolower="scrolltolower" style="padding-top: 110rpx;height: 100%;" :scroll-y="true" >
  110. <view @click="companySelectCallback(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom" v-for="(item,index) in companySelectList" :key="index">
  111. <text>{{item.enterpriseName}}</text>
  112. </view>
  113. <u-divider v-if="flag" height="80">没有更多了</u-divider>
  114. </scroll-view>
  115. <u-empty v-else name="search"></u-empty>
  116. </u-popup>
  117. <!-- <u-picker v-model="companySelectShow" @confirm="companySelectCallback" :range="companySelectList" range-key="enterpriseName" mode="selector"></u-picker> -->
  118. <u-action-sheet @click="faceSelectCallback" z-index="999999" :list="faceSelectList" v-model="faceSelectShow"></u-action-sheet>
  119. </view>
  120. <view v-else>
  121. </view>
  122. </view>
  123. </template>
  124. <script>
  125. import uploadImg from '@/components/uploadimg/uploadImg.vue'
  126. let that;
  127. export default {
  128. components:{
  129. uploadImg
  130. },
  131. data() {
  132. return {
  133. //0 体验版 1正式版
  134. appletStatus:0,
  135. open:false,
  136. // 0:用户认证 1:重新审核
  137. operationType:0,
  138. phone:'',//当operationType为1时需要传过来
  139. opinion:'',//审核不通过时的审核意见
  140. show:false,//当有审核意见时才显示
  141. labelWidth:'200',
  142. model: {
  143. avatar:'',
  144. name:'',//昵称
  145. openId:'',
  146. realName: '',
  147. enterpriseId:'',
  148. enterpriseName:'',
  149. face:'',
  150. sex: '', //性别 1 男 2 女
  151. idcard:'',
  152. phone: '',
  153. remarks:''
  154. },
  155. //性别
  156. sexSelectList: [{text: '男',value:1},{text: '女',value:2}],
  157. sexSelectShow: false,
  158. sexSelectIndex:0,
  159. //园区
  160. gander:'',
  161. ganderSelectList: [],
  162. ganderSelectShow: false,
  163. ganderSelectIndex:0,
  164. //区域
  165. residential:'',
  166. residentialId:'',
  167. residentialSelectList: [],
  168. residentialSelectShow: false,
  169. residentialSelectIndex:0,
  170. //企业
  171. current:1,
  172. flag:false,
  173. keyword:'',
  174. company:'',
  175. companySelectList: [],
  176. companySelectShow: false,
  177. //上传人脸的方式
  178. faceSelectList: [{
  179. text: '相册上传',
  180. }, {
  181. text: '拍照上传'
  182. }],
  183. faceSelectShow:false,
  184. //验证码
  185. codeTips: '',
  186. subscribeShow:true,
  187. }
  188. },
  189. watch:{
  190. keyword(){
  191. let that=this
  192. //节流函数
  193. if (this.timer){
  194. clearTimeout(this.timer)//阻止setTimeout函数的执行
  195. }
  196. this.timer = setTimeout(() => {
  197. that.current=1
  198. that.companySelectList=[]
  199. that.fetchEnterpriseList(that.residentialId)
  200. }, 500)
  201. },
  202. },
  203. onShow() {
  204. this.handelAppletAudit()
  205. let currPage=this.getPageCtx()
  206. if (!this.$isEmpty(currPage.data.image)) {
  207. this.uploadFile(currPage.data.image)
  208. }
  209. },
  210. onLoad(options) {
  211. that=this
  212. let tempId=this.$tmplIds[0]
  213. wx.getSetting({
  214. withSubscriptions: true,
  215. success(res){
  216. if (res.subscriptionsSetting.itemSettings[tempId]=='accept') {
  217. that.subscribeShow=false
  218. }else{
  219. that.subscribeShow=true
  220. }
  221. }
  222. })
  223. if (!this.$isEmpty(options.operationType)) {
  224. this.operationType=options.operationType
  225. }
  226. this.fetchAgencyList()
  227. if (this.operationType==0) {
  228. //用户认证
  229. this.getOpenid()
  230. if (!this.$isEmpty(this.$Route.query.phone)) {
  231. this.model.phone=this.$Route.query.phone
  232. }
  233. }else{
  234. //用户重新审核
  235. this.phone=options.phone
  236. this.fetchUserInfo()
  237. }
  238. },
  239. methods: {
  240. handelAppletAudit(){
  241. this.appletStatus=uni.getStorageSync("appletStatus")
  242. if (this.appletStatus==1) {
  243. uni.setNavigationBarTitle({
  244. title:'员工认证'
  245. })
  246. }else{
  247. uni.setNavigationBarTitle({
  248. title:'待开发'
  249. })
  250. }
  251. },
  252. tip(){
  253. this.$showModel('认证审核通过后将通过微信服务通知您',false,'通知功能')
  254. },
  255. /**
  256. * 重新审核操作时,加载用户的认证信息
  257. */
  258. async fetchUserInfo(){
  259. if (this.$isEmpty(getApp().globalData.userInfo)) {
  260. let res=await this.$api.enterprisestaff.detail({phone:this.phone})
  261. this.model=res.data
  262. }else{
  263. this.model=getApp().globalData.userInfo
  264. }
  265. if (this.model.sex==2) {
  266. this.sexSelectIndex=1
  267. }
  268. this.opinion=this.model.opinion
  269. if (!this.$isEmpty(this.opinion)) {
  270. this.show=true
  271. }
  272. this.fetchResidentialList(this.model.agencyId)
  273. this.fetchEnterpriseList(this.model.residentialId)
  274. this.gander=this.model.agencyName
  275. this.residential=this.model.residentialName
  276. this.company=this.model.enterpriseName
  277. },
  278. /**
  279. * 获取openid
  280. */
  281. getOpenid(){
  282. uni.login({
  283. success: (res) => {
  284. let data={
  285. appId:this.$api.wxData.appId,
  286. jsCode:res.code,
  287. secret:this.$api.wxData.secret
  288. }
  289. this.$api.wxApi.getOpenId(data).then(res=>{
  290. let resData= JSON.parse(res.data)
  291. this.model.openId=resData.openid
  292. this.$cache.put('openid',resData.openid)
  293. })
  294. }
  295. })
  296. },
  297. /**
  298. * 订阅认证信息
  299. */
  300. subscribe(e){
  301. uni.requestSubscribeMessage({
  302. tmplIds: that.$tmplIds,
  303. success (res) {
  304. if (res.errMsg=='requestSubscribeMessage:ok') {
  305. //已授权
  306. that.subscribeShow=false
  307. }else{
  308. //未授权
  309. that.subscribeShow=true
  310. }
  311. },
  312. fail(err){
  313. that.subscribeShow=true
  314. console.error(err);
  315. }
  316. })
  317. },
  318. /**
  319. * 提交审核
  320. */
  321. submit(e){
  322. let userInfo=e.detail.userInfo
  323. if (this.$isEmpty(userInfo)&&this.operationType==0) {
  324. //认证操作才需要获取微信头像和昵称信息,修改操作不需要
  325. this.$refs.uTips.show({
  326. title: '认证失败,用户拒绝授权获取微信头像和昵称信息',
  327. type: 'error',
  328. duration: '3000'
  329. })
  330. return
  331. }
  332. this.model.avatar=userInfo.avatarUrl
  333. this.model.name=userInfo.nickName
  334. this.model.sex=this.sexSelectList[this.sexSelectIndex].value || 1
  335. if (this.$isEmpty(this.model.realName)) {
  336. this.$u.toast('请输入您的姓名')
  337. return
  338. }
  339. if (this.$isEmpty(this.model.idcard)) {
  340. this.$u.toast('请输入身份证号')
  341. return
  342. }
  343. if (!this.$u.test.idCard(this.model.idcard)) {
  344. this.$u.toast('请输入正确的身份证号')
  345. return
  346. }
  347. if (this.$isEmpty(this.model.phone)) {
  348. this.$u.toast('请输入手机号码')
  349. return
  350. }
  351. if (!this.$u.test.mobile(this.model.phone)) {
  352. this.$u.toast('请输入正确的手机号码')
  353. return
  354. }
  355. if (this.$isEmpty(this.model.face)) {
  356. this.$u.toast('请上传人脸信息')
  357. return
  358. }
  359. if (this.$isEmpty(this.model.enterpriseId)) {
  360. this.$u.toast('请选择所属企业')
  361. return
  362. }
  363. if (this.operationType==1) {
  364. //重新审核
  365. this.model.examine=0
  366. }
  367. this.model.createType=1 //1小程序认证方式 0:后台数据导入
  368. this.$api.enterprisestaff.submit(this.model).then(res=>{
  369. if (res.code==200) {
  370. if (this.operationType==0) {
  371. that.$showModel('提交成功,请耐心等待企业管理者审核',false).then(res=>{
  372. this.$Router.replaceAll({name:'login'})
  373. })
  374. }else{
  375. that.$showModel('操作成功',false).then(res=>{
  376. this.$Router.back()
  377. })
  378. }
  379. }else{
  380. this.$u.toast(res.msg)
  381. }
  382. })
  383. },
  384. //园区 begin
  385. /**
  386. * 显示园区
  387. */
  388. ganderShow(){
  389. this.ganderSelectShow=true
  390. },
  391. /**
  392. * 获取园区列表
  393. */
  394. fetchAgencyList(){
  395. this.$api.agency.page().then(res=>{
  396. this.ganderSelectList=res.data
  397. })
  398. },
  399. /**
  400. * 选择园区后的回调
  401. * @param {Object} e
  402. */
  403. ganderSelectCallback(e) {
  404. uni.hideKeyboard();
  405. //先重置区域和企业
  406. if (this.ganderSelectIndex!=e[0]) {
  407. this.resetResidential()
  408. this.resetEnterprise()
  409. }
  410. this.ganderSelectIndex=e[0]
  411. this.gander=this.ganderSelectList[this.ganderSelectIndex].agencyName
  412. this.model.agencyName=this.ganderSelectList[this.ganderSelectIndex].agencyName
  413. this.model.agencyId=this.ganderSelectList[this.ganderSelectIndex].id
  414. //加载区域
  415. this.fetchResidentialList(this.model.agencyId)
  416. },
  417. //园区 end
  418. //区域 begin
  419. /**
  420. * 重置区域数据
  421. * @param {Object}
  422. */
  423. resetResidential(){
  424. this.residentialSelectList=[]
  425. this.residential=''
  426. this.residentialSelectIndex=0
  427. this.model.residentialName=''
  428. this.model.residentialId=''
  429. },
  430. /**
  431. * 根据园区id获取区域列表
  432. */
  433. fetchResidentialList(agencyId){
  434. this.$api.residential.page({agencyId:agencyId,size:300}).then(res=>{
  435. this.residentialSelectList=res.data.records
  436. })
  437. },
  438. //显示区域
  439. residentialShow(){
  440. if (this.$isEmpty(this.gander)) {
  441. //未选择园区提示先选择园区
  442. this.$u.toast("请先选择园区")
  443. return
  444. }
  445. this.residentialSelectShow=true
  446. },
  447. /**
  448. * 选择区域的回调
  449. */
  450. residentialSelectCallback(e){
  451. uni.hideKeyboard();
  452. //先重置数据
  453. if (this.residentialSelectIndex!=e[0]) {
  454. this.resetEnterprise()
  455. }
  456. this.residentialSelectIndex=e[0]
  457. this.residential=this.residentialSelectList[this.residentialSelectIndex].name
  458. this.residentialId=this.residentialSelectList[this.residentialSelectIndex].id
  459. this.model.residentialName=this.residentialSelectList[this.residentialSelectIndex].name
  460. this.model.residentialId=this.residentialSelectList[this.residentialSelectIndex].id
  461. //加载区域下的企业
  462. this.fetchEnterpriseList(this.residentialId)
  463. },
  464. //区域 end
  465. //企业 begin
  466. /**
  467. * 重置企业数据
  468. */
  469. resetEnterprise(){
  470. this.companySelectList=[]
  471. this.current=1
  472. this.company=''
  473. this.model.enterpriseName=''
  474. this.model.enterpriseId=''
  475. },
  476. /**
  477. * 根据 区域id 获取 企业列表
  478. */
  479. fetchEnterpriseList(residentialId){
  480. let params={
  481. residentialId:residentialId,
  482. current:this.current,
  483. enterpriseName:this.keyword
  484. }
  485. this.$api.enterprise.page(params).then(res=>{
  486. this.companySelectList = [...this.companySelectList,...res.data.records]
  487. })
  488. },
  489. /**
  490. * @param {Object} 下拉加载更多企业
  491. */
  492. scrolltolower(e){
  493. if(this.companySelectList.length<this.current*10){
  494. this.flag=true
  495. return
  496. }else{
  497. this.current++
  498. this.fetchEnterpriseList(this.residentialId)
  499. }
  500. },
  501. /**
  502. * 显示企业
  503. */
  504. companyShow(){
  505. if (this.$isEmpty(this.residential)) {
  506. //未选择区域
  507. this.$u.toast("请选择区域")
  508. return
  509. }
  510. this.companySelectShow=true
  511. },
  512. //公司
  513. companySelectCallback(item) {
  514. this.model.enterpriseId=item.id
  515. this.model.enterpriseName=item.enterpriseName
  516. this.company=item.enterpriseName
  517. this.companySelectShow=false
  518. },
  519. //企业 end
  520. /**
  521. * 获取页面对象
  522. */
  523. getPageCtx(idx = 0){
  524. let pages = getCurrentPages()
  525. if (pages.length > 0) {
  526. return pages[pages.length - 1 - idx] || {}
  527. }
  528. return {}
  529. },
  530. //性别
  531. sexSelectCallback(e) {
  532. uni.hideKeyboard();
  533. this.sexSelectIndex=e[0]
  534. },
  535. faceSelectCallback(index){
  536. if (index==0) {
  537. //图片上传
  538. this.chooseImage()
  539. } else if(index==1){
  540. //拍照上传
  541. uni.navigateTo({
  542. url:'/pages/my-camera/my-camera'
  543. })
  544. }
  545. },
  546. //点击上传图片事件
  547. chooseImage: function () {
  548. uni.chooseImage({
  549. count: 1,
  550. //最多可以选择的图片张数,默认9
  551. sourceType: ['album', 'camera'],
  552. sizeType: ['compressed'],
  553. //可选择原图或压缩后的图片
  554. success: res => {
  555. that.uploadFile(res.tempFilePaths[0])
  556. }
  557. });
  558. },
  559. //处理照片,拍照上传和相册上传的共同处理方法
  560. uploadFile(imgUrl){
  561. this.$api.uploadFile.submit(imgUrl).then(res=>{
  562. that.model.face=res.data
  563. })
  564. },
  565. },
  566. /**打开设置页
  567. * 方法可以不实现,但是不可以不写
  568. */
  569. opensetting(){
  570. }
  571. }
  572. </script>
  573. <style lang="scss">
  574. page{
  575. background-color: #FFFFFF;
  576. }
  577. .auth{
  578. padding: 40rpx 10rpx;
  579. .card{
  580. margin-top: 20rpx;
  581. padding: 0 30rpx;
  582. box-sizing: border-box;
  583. border-radius: 12rpx;
  584. box-shadow: 0 -10rpx rgba(248, 248, 248,.9) ,0 10rpx rgba(248, 248, 248,.9) , -10rpx 0rpx rgba(248, 248, 248,.9) ,10rpx 0rpx rgba(248, 248, 248,.9);
  585. .item{
  586. padding:30rpx 0;
  587. display: flex;
  588. justify-content: space-between;
  589. }
  590. }
  591. }
  592. </style>