auth.vue 15 KB

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