auth.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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" ></u-input>
  19. </u-form-item>
  20. <u-form-item label="手机号码" :label-width="labelWidth">
  21. <u-input maxlength="11" disabled 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. /**
  253. * 重新审核操作时,加载用户的认证信息
  254. */
  255. async fetchUserInfo(){
  256. if (this.$isEmpty(getApp().globalData.userInfo)) {
  257. let res=await this.$api.enterprisestaff.page({phone:this.phone})
  258. this.model=res.data.records[0]
  259. }else{
  260. this.model=getApp().globalData.userInfo
  261. }
  262. if (this.model.sex==2) {
  263. this.sexSelectIndex=1
  264. }
  265. this.opinion=this.model.opinion
  266. if (!this.$isEmpty(this.opinion)) {
  267. this.show=true
  268. }
  269. this.fetchResidentialList(this.model.agencyId)
  270. this.fetchEnterpriseList(this.model.residentialId)
  271. this.gander=this.model.agencyName
  272. this.residential=this.model.residentialName
  273. this.company=this.model.enterpriseName
  274. },
  275. /**
  276. * 获取openid
  277. */
  278. getOpenid(){
  279. uni.login({
  280. success: (res) => {
  281. let data={
  282. appId:this.$api.wxData.appId,
  283. jsCode:res.code,
  284. secret:this.$api.wxData.secret
  285. }
  286. this.$api.wxApi.getOpenId(data).then(res=>{
  287. let resData= JSON.parse(res.data)
  288. this.model.openId=resData.openid
  289. this.$cache.put('openid',resData.openid)
  290. })
  291. }
  292. })
  293. },
  294. /**
  295. * 订阅认证信息
  296. */
  297. subscribe(e){
  298. uni.requestSubscribeMessage({
  299. tmplIds: that.$tmplIds,
  300. success (res) {
  301. if (res.errMsg=='requestSubscribeMessage:ok') {
  302. //已授权
  303. that.subscribeShow=false
  304. }else{
  305. //未授权
  306. that.subscribeShow=true
  307. }
  308. },
  309. fail(err){
  310. that.subscribeShow=true
  311. console.error(err);
  312. }
  313. })
  314. },
  315. /**
  316. * 提交审核
  317. */
  318. submit(e){
  319. let userInfo=e.detail.userInfo
  320. if (this.$isEmpty(userInfo)&&this.operationType==0) {
  321. //认证操作才需要获取微信头像和昵称信息,修改操作不需要
  322. this.$refs.uTips.show({
  323. title: '认证失败,用户拒绝授权获取微信头像和昵称信息',
  324. type: 'error',
  325. duration: '3000'
  326. })
  327. return
  328. }
  329. this.model.avatar=userInfo.avatarUrl
  330. this.model.name=userInfo.nickName
  331. this.model.sex=this.sexSelectList[this.sexSelectIndex].value || 1
  332. if (this.$isEmpty(this.model.realName)) {
  333. this.$u.toast('请输入您的姓名')
  334. return
  335. }
  336. if (this.$isEmpty(this.model.idcard)) {
  337. this.$u.toast('请输入身份证号')
  338. return
  339. }
  340. if (!this.$u.test.idCard(this.model.idcard)) {
  341. this.$u.toast('请输入正确的身份证号')
  342. return
  343. }
  344. if (this.$isEmpty(this.model.phone)) {
  345. this.$u.toast('请输入手机号码')
  346. return
  347. }
  348. if (!this.$u.test.mobile(this.model.phone)) {
  349. this.$u.toast('请输入正确的手机号码')
  350. return
  351. }
  352. if (this.$isEmpty(this.model.face)) {
  353. this.$u.toast('请上传人脸信息')
  354. return
  355. }
  356. if (this.$isEmpty(this.model.enterpriseId)) {
  357. this.$u.toast('请选择所属企业')
  358. return
  359. }
  360. if (this.operationType==1) {
  361. //重新审核
  362. this.model.examine=0
  363. }
  364. this.model.createType=1 //1小程序认证方式 0:后台数据导入
  365. this.$api.enterprisestaff.submit(this.model).then(res=>{
  366. if (res.code==200) {
  367. if (this.operationType==0) {
  368. that.$showModel('提交成功,请耐心等待企业管理者审核',false).then(res=>{
  369. this.$Router.replaceAll({name:'login'})
  370. })
  371. }else{
  372. that.$showModel('操作成功',false).then(res=>{
  373. this.$Router.back()
  374. })
  375. }
  376. }else{
  377. this.$u.toast(res.msg)
  378. }
  379. })
  380. },
  381. //园区 begin
  382. /**
  383. * 显示园区
  384. */
  385. ganderShow(){
  386. this.ganderSelectShow=true
  387. },
  388. /**
  389. * 获取园区列表
  390. */
  391. fetchAgencyList(){
  392. this.$api.agency.page().then(res=>{
  393. this.ganderSelectList=res.data
  394. })
  395. },
  396. /**
  397. * 选择园区后的回调
  398. * @param {Object} e
  399. */
  400. ganderSelectCallback(e) {
  401. uni.hideKeyboard();
  402. //先重置区域和企业
  403. if (this.ganderSelectIndex!=e[0]) {
  404. this.resetResidential()
  405. this.resetEnterprise()
  406. }
  407. this.ganderSelectIndex=e[0]
  408. this.gander=this.ganderSelectList[this.ganderSelectIndex].agencyName
  409. this.model.agencyName=this.ganderSelectList[this.ganderSelectIndex].agencyName
  410. this.model.agencyId=this.ganderSelectList[this.ganderSelectIndex].id
  411. //加载区域
  412. this.fetchResidentialList(this.model.agencyId)
  413. },
  414. //园区 end
  415. //区域 begin
  416. /**
  417. * 重置区域数据
  418. * @param {Object}
  419. */
  420. resetResidential(){
  421. this.residentialSelectList=[]
  422. this.residential=''
  423. this.residentialSelectIndex=0
  424. this.model.residentialName=''
  425. this.model.residentialId=''
  426. },
  427. /**
  428. * 根据园区id获取区域列表
  429. */
  430. fetchResidentialList(agencyId){
  431. this.$api.residential.page({agencyId:agencyId,size:300}).then(res=>{
  432. this.residentialSelectList=res.data.records
  433. })
  434. },
  435. //显示区域
  436. residentialShow(){
  437. if (this.$isEmpty(this.gander)) {
  438. //未选择园区提示先选择园区
  439. this.$u.toast("请先选择园区")
  440. return
  441. }
  442. this.residentialSelectShow=true
  443. },
  444. /**
  445. * 选择区域的回调
  446. */
  447. residentialSelectCallback(e){
  448. uni.hideKeyboard();
  449. //先重置数据
  450. if (this.residentialSelectIndex!=e[0]) {
  451. this.resetEnterprise()
  452. }
  453. this.residentialSelectIndex=e[0]
  454. this.residential=this.residentialSelectList[this.residentialSelectIndex].name
  455. this.residentialId=this.residentialSelectList[this.residentialSelectIndex].id
  456. this.model.residentialName=this.residentialSelectList[this.residentialSelectIndex].name
  457. this.model.residentialId=this.residentialSelectList[this.residentialSelectIndex].id
  458. //加载区域下的企业
  459. this.fetchEnterpriseList(this.residentialId)
  460. },
  461. //区域 end
  462. //企业 begin
  463. /**
  464. * 重置企业数据
  465. */
  466. resetEnterprise(){
  467. this.companySelectList=[]
  468. this.current=1
  469. this.company=''
  470. this.model.enterpriseName=''
  471. this.model.enterpriseId=''
  472. },
  473. /**
  474. * 根据 区域id 获取 企业列表
  475. */
  476. fetchEnterpriseList(residentialId){
  477. let params={
  478. residentialId:residentialId,
  479. current:this.current,
  480. enterpriseName:this.keyword
  481. }
  482. this.$api.enterprise.page(params).then(res=>{
  483. this.companySelectList = [...this.companySelectList,...res.data.records]
  484. })
  485. },
  486. /**
  487. * @param {Object} 下拉加载更多企业
  488. */
  489. scrolltolower(e){
  490. if(this.companySelectList.length<this.current*10){
  491. this.flag=true
  492. return
  493. }else{
  494. this.current++
  495. this.fetchEnterpriseList(this.residentialId)
  496. }
  497. },
  498. /**
  499. * 显示企业
  500. */
  501. companyShow(){
  502. if (this.$isEmpty(this.residential)) {
  503. //未选择区域
  504. this.$u.toast("请选择区域")
  505. return
  506. }
  507. this.companySelectShow=true
  508. },
  509. //公司
  510. companySelectCallback(item) {
  511. this.model.enterpriseId=item.id
  512. this.model.enterpriseName=item.enterpriseName
  513. this.company=item.enterpriseName
  514. this.companySelectShow=false
  515. },
  516. //企业 end
  517. /**
  518. * 获取页面对象
  519. */
  520. getPageCtx(idx = 0){
  521. let pages = getCurrentPages()
  522. if (pages.length > 0) {
  523. return pages[pages.length - 1 - idx] || {}
  524. }
  525. return {}
  526. },
  527. //性别
  528. sexSelectCallback(e) {
  529. uni.hideKeyboard();
  530. this.sexSelectIndex=e[0]
  531. },
  532. faceSelectCallback(index){
  533. if (index==0) {
  534. //图片上传
  535. this.chooseImage()
  536. } else if(index==1){
  537. //拍照上传
  538. uni.navigateTo({
  539. url:'/pages/my-camera/my-camera'
  540. })
  541. }
  542. },
  543. //点击上传图片事件
  544. chooseImage: function () {
  545. uni.chooseImage({
  546. count: 1,
  547. //最多可以选择的图片张数,默认9
  548. sourceType: ['album', 'camera'],
  549. sizeType: ['compressed'],
  550. //可选择原图或压缩后的图片
  551. success: res => {
  552. that.uploadFile(res.tempFilePaths[0])
  553. }
  554. });
  555. },
  556. //处理照片,拍照上传和相册上传的共同处理方法
  557. uploadFile(imgUrl){
  558. this.$api.uploadFile.submit(imgUrl).then(res=>{
  559. that.model.face=res.data
  560. })
  561. },
  562. },
  563. /**打开设置页
  564. * 方法可以不实现,但是不可以不写
  565. */
  566. opensetting(){
  567. }
  568. }
  569. </script>
  570. <style lang="scss">
  571. page{
  572. background-color: #FFFFFF;
  573. }
  574. .auth{
  575. padding: 40rpx 10rpx;
  576. .card{
  577. margin-top: 20rpx;
  578. padding: 0 30rpx;
  579. box-sizing: border-box;
  580. border-radius: 12rpx;
  581. 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);
  582. .item{
  583. padding:30rpx 0;
  584. display: flex;
  585. justify-content: space-between;
  586. }
  587. }
  588. }
  589. </style>