myCompany.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. <template>
  2. <view class="my-company-page flex flex-direction">
  3. <!-- 自定义导航栏 -->
  4. <nav-bar title="我的公司" color="#fff"></nav-bar>
  5. <!-- 头部渐变背景区域 -->
  6. <view class="header-section">
  7. <!-- 插画区域 -->
  8. <view class="illustration-area">
  9. <image src="/static/images/gongsi.svg" class="company-illustration" mode="aspectFit" />
  10. </view>
  11. </view>
  12. <template v-if="!loading">
  13. <!-- 管理员端 -->
  14. <view class="admin-container" v-if="isAdmin">
  15. <view class="company-name">{{ companyInfo.companyAllName }}</view>
  16. <view class="buttons flex">
  17. <view class="button" @click="showLeaveModal = true">离开公司</view>
  18. <view class="button" @click="showChangeModal = true">变更账号</view>
  19. </view>
  20. <view class="list-wrapper">
  21. <scroll-view scroll-y="true" class="scroll-view">
  22. <view class="list">
  23. <view class="list-title">账号审核列表</view>
  24. <view class="account-item" v-for="(item, index) in auditList" :key="index">
  25. <view class="account-info flex justify-between">
  26. <view class="account-info-l">
  27. <view class="title flex align-center">
  28. <text>{{ item.userName }}/{{ item.phone }}</text>
  29. <view class="badge" v-if="item.isAdmin">管理员</view>
  30. </view>
  31. <view class="sub-title">提交时间:{{ item.createTime }}</view>
  32. <view class="sub-title">{{ item.hrPosition || '--' }}</view>
  33. </view>
  34. <view class="status-text" :class="getStatusClass(item.status)" @click="handleAudit(item)">{{ item.status | statusText }}</view>
  35. </view>
  36. <view class="bottom-button" v-if="item.status == 2" @click="changeSelectAccount(item)">变更账号</view>
  37. </view>
  38. </view>
  39. </scroll-view>
  40. </view>
  41. </view>
  42. <!-- 非管理员端 -->
  43. <view class="un-admin-container" v-else>
  44. <view class="company-name">{{ companyInfo.companyAllName }}</view>
  45. <view class="content-wrapper">
  46. <view class="info-list">
  47. <view class="info-item">
  48. <text>公司规模</text>
  49. <text>{{ companyInfo.companyPeople || '--' }}</text>
  50. </view>
  51. <view class="info-item">
  52. <text>融资阶段</text>
  53. <text>{{ companyInfo.companyDevelop || '--' }}</text>
  54. </view>
  55. <view class="info-item">
  56. <text>所属行业</text>
  57. <text>{{ companyInfo.companyScope || '--' }}</text>
  58. </view>
  59. </view>
  60. <view class="buttons">
  61. <view class="button plain" @click="showLeaveModal = true">离开公司</view>
  62. <view class="button primary" @click="showChangeModal = true">变更账号</view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <!-- 审核 -->
  68. <c-modal
  69. :value="showAuditModal"
  70. :maskCloseAble="true"
  71. title="审核"
  72. cancel-button-text="拒绝"
  73. confirm-button-text="通过"
  74. @cancel="handleRejest"
  75. @confirm="handlePass"
  76. @close="handleCloseModal"
  77. >
  78. <view class="audit-modal">
  79. <view>请审核账号是否为您公司的员工</view>
  80. <view class="account-info flex">
  81. <view class="account-info-l">
  82. <view class="title flex align-center">
  83. <text>{{ currentAuditItem.userName }} / {{ currentAuditItem.phone }}</text>
  84. </view>
  85. <view class="sub-title">提交时间:{{ currentAuditItem.createTime }}</view>
  86. <view class="sub-title">{{ currentAuditItem.hrPosition }}</view>
  87. </view>
  88. </view>
  89. <view class="check-bar flex align-center">
  90. <u-checkbox v-model="auditChecked" label-size="24">通过并设置为管理员</u-checkbox>
  91. <view class="tip">仅能设置2个管理员</view>
  92. </view>
  93. </view>
  94. </c-modal>
  95. <!-- 离开公司 -->
  96. <c-modal
  97. :value="showLeaveModal"
  98. :maskCloseAble="true"
  99. title="温馨提示"
  100. cancel-button-text="确定离开"
  101. confirm-button-text="去变更"
  102. @cancel="handleLeave"
  103. @confirm="handleChange"
  104. @close="handleCloseModal"
  105. >
  106. <view class="audit-modal">
  107. <view>您是企业的超级管理员</view>
  108. <view>如若需要保留数据请取消,并变更账号</view>
  109. <view>如您确定离开公司,公司及其相关所有数据均会删除,请确认!</view>
  110. </view>
  111. </c-modal>
  112. <!-- 变更账号 -->
  113. <c-modal
  114. :value="showChangeModal"
  115. title="请填写您需要变更的账号"
  116. @cancel="showChangeModal = false"
  117. @confirm="submitChangeAccount"
  118. >
  119. <view class="input-wrapper" style="margin-top: 30px">
  120. <input v-model="phoneNum" type="number" placeholder="请输入要变更的手机号码" maxlength="11" placeholder-class="placeholder" />
  121. </view>
  122. <view class="input-wrapper flex align-center justify-between" style="margin-bottom: 30px;">
  123. <input v-model="verifyCode" type="number" placeholder="输入验证码" maxlength="6" class="verify-input" placeholder-class="placeholder" />
  124. <view class="verify-btn" @click="getVerifyCode">{{ disabled ? `${countdown}s` : '获取验证码' }}</view>
  125. </view>
  126. </c-modal>
  127. </view>
  128. </template>
  129. <script>
  130. import navBar from '@/components/nav-bar/index.vue'
  131. import cModal from '@/components/c-modal.vue'
  132. import { logoutJP } from '@/utils/login'
  133. export default {
  134. components: {
  135. navBar,
  136. cModal
  137. },
  138. data() {
  139. return {
  140. companyInfo: {
  141. isNo: true,
  142. },
  143. isAdmin: false,
  144. companyId: '',
  145. loading: false,
  146. showAuditModal: false,
  147. auditChecked: false, // 是否设置成管理员
  148. showLeaveModal: false,
  149. auditList: [],
  150. updating: false,
  151. currentAuditItem: {}, // 当前被审核人
  152. showChangeModal: false, // 变更弹窗
  153. disabled: false,
  154. timer: null,
  155. countdown: 60,
  156. getting: false,
  157. verifyCode: '',
  158. phoneNum: '', // 输入手机号
  159. changePhoneNum: '', // 被变更手机号
  160. userPhoneNum: '', // 当前登录人手机号
  161. };
  162. },
  163. filters: {
  164. statusText(status) {
  165. switch (status) {
  166. case 1:
  167. return '请审核'
  168. case 2:
  169. return '已通过'
  170. case 3:
  171. return '已拒绝'
  172. default:
  173. return ''
  174. }
  175. }
  176. },
  177. watch: {
  178. showAuditModal(nValue) {
  179. if (!nValue) {
  180. this.auditChecked = false
  181. }
  182. },
  183. showChangeModal(nValue) {
  184. if (!nValue) {
  185. // 关闭弹窗时清除选择的手机号
  186. this.changePhoneNum = ''
  187. this.verifyCode = ''
  188. this.phoneNum = ''
  189. this.clearCountdownTimer()
  190. }
  191. }
  192. },
  193. onLoad() {
  194. // /app/user/selectUserById
  195. this.getCompanyStatus()
  196. },
  197. onUnload() {
  198. this.clearCountdownTimer()
  199. },
  200. methods: {
  201. getStatusClass(status) {
  202. switch (status) {
  203. case 1:
  204. return 'btn'; // 待审核
  205. case 2:
  206. return ''; // 已通过
  207. case 3:
  208. return 'info'; // 已拒绝
  209. default:
  210. return '';
  211. }
  212. },
  213. getCompanyStatus() {
  214. uni.showLoading({ title: '加载中' })
  215. this.loading = true
  216. this.$Request.get("/app/company/selectCompanyByUserId")
  217. .then((res) => {
  218. this.loading = false
  219. uni.hideLoading()
  220. if (res.code == 0 && res.data) {
  221. this.companyInfo = res.data
  222. this.companyId = res.data.companyId
  223. this.userPhoneNum = res.data.phone
  224. this.auditList = res.data.companyUserVos || []
  225. if (res.data.companyUser?.isAdmin == 1) {
  226. this.isAdmin = true
  227. }
  228. } else {
  229. this.companyInfo = {
  230. isNo: true,
  231. };
  232. }
  233. }).catch(err => {
  234. this.loading = false
  235. uni.hideLoading()
  236. });
  237. },
  238. // 审核账号
  239. handleAudit(item) {
  240. if (item.status != 1) return
  241. this.showAuditModal = true
  242. this.currentAuditItem = item
  243. },
  244. handleCloseModal() {
  245. this.showAuditModal = false
  246. this.showLeaveModal = false
  247. },
  248. // 审核账号
  249. auditAccount(status) {
  250. if (this.updating) return
  251. this.updating = true
  252. uni.showLoading({ title: '处理中' })
  253. this.$Request.getT('/app/company/auditCompanyUser', {
  254. companyId: this.companyId,
  255. auditedUserId: this.currentAuditItem.userId,
  256. isAdmin: this.auditChecked ? 1: 0,
  257. status
  258. }).then(res => {
  259. if (res.code == 0) {
  260. this.$queue.showToast('操作成功')
  261. this.showAuditModal = false
  262. this.getCompanyStatus()
  263. } else {
  264. this.$queue.showToast(res.msg || '操作成功')
  265. }
  266. this.updating = false
  267. uni.hideLoading()
  268. }).catch(() => {
  269. this.$queue.showToast('失败了,请重试')
  270. this.updating = false
  271. uni.hideLoading()
  272. })
  273. },
  274. // 审核拒绝
  275. handleRejest() {
  276. this.auditAccount(3)
  277. },
  278. // 审核通过
  279. handlePass() {
  280. this.auditAccount(2)
  281. },
  282. // 确定离开
  283. handleLeave() {
  284. if (this.updating) return
  285. this.updating = true
  286. uni.showLoading({ title: '处理中' })
  287. this.$Request.getT('/app/company/deleteCompany', {
  288. companyId: this.companyId
  289. }).then(res => {
  290. if (res.code == 0) {
  291. this.showLeaveModal = false
  292. this.logout()
  293. } else {
  294. this.$queue.showToast(res.msg || '出错了,请稍后再试')
  295. }
  296. this.updating = false
  297. uni.hideLoading()
  298. }).catch(() => {
  299. this.$queue.showToast('出错了,请稍后再试')
  300. this.updating = false
  301. uni.hideLoading()
  302. })
  303. // /sqx_fast/app/company/deleteCompany
  304. },
  305. // 去变更
  306. handleChange() {
  307. this.showLeaveModal = false
  308. this.showChangeModal = true
  309. },
  310. // 获取验证码
  311. getVerifyCode() {
  312. if (!this.phoneNum) {
  313. uni.showToast({
  314. title: '请输入手机号',
  315. icon: 'none'
  316. })
  317. return
  318. }
  319. if (!/^1[3-9]\d{9}$/.test(this.phoneNum)) {
  320. uni.showToast({
  321. title: '请输入正确的手机号',
  322. icon: 'none'
  323. })
  324. return
  325. }
  326. if (this.disabled || this.getting) return
  327. uni.showLoading({ title: '正在发送验证码' })
  328. this.getting = true
  329. this.$Request
  330. .getT('/app/Login/sendMsg/' + this.phoneNum + '/bind')
  331. .then((res) => {
  332. if (res.code === 0) {
  333. this.startCountdown()
  334. } else {
  335. uni.showModal({
  336. showCancel: false,
  337. title: '短信发送失败',
  338. content: res.msg ? res.msg : '请一分钟后再获取验证码',
  339. });
  340. }
  341. })
  342. .finally(() => {
  343. this.getting = false
  344. uni.hideLoading();
  345. })
  346. },
  347. startCountdown() {
  348. this.disabled = true
  349. this.timer = setInterval(() => {
  350. this.countdown--
  351. if (this.countdown <= 0) {
  352. this.clearCountdownTimer()
  353. }
  354. }, 1000)
  355. },
  356. clearCountdownTimer() {
  357. if (this.timer) {
  358. clearInterval(this.timer)
  359. this.timer = null // 重置定时器实例
  360. this.countdown = 60
  361. this.disabled = false
  362. }
  363. },
  364. // 变更选择的账号
  365. changeSelectAccount(item) {
  366. this.changePhoneNum = item.phone
  367. this.showChangeModal = true
  368. },
  369. // 提交变更
  370. submitChangeAccount() {
  371. if (this.updating) return
  372. this.updating = true
  373. if (!this.phoneNum) {
  374. uni.showToast({
  375. title: '请输入手机号',
  376. icon: 'none'
  377. })
  378. return
  379. }
  380. if (!this.verifyCode) {
  381. uni.showToast({
  382. title: '请输入验证码',
  383. icon: 'none'
  384. })
  385. return
  386. }
  387. uni.showLoading({ title: '处理中' })
  388. this.$Request.postJson('/app/company/giveCompany', {
  389. phone: this.changePhoneNum || this.userPhoneNum,
  390. msg: this.verifyCode,
  391. givePhone: this.phoneNum
  392. }).then(res => {
  393. if (res.code == 0) {
  394. this.showChangeModal = false
  395. this.logout()
  396. } else {
  397. this.$queue.showToast(res.msg || '出错了,请稍后再试')
  398. }
  399. }).finally(() => {
  400. uni.hideLoading()
  401. this.updating = false
  402. })
  403. },
  404. logout() {
  405. uni.showToast({
  406. title: '操作成功',
  407. icon: 'none',
  408. })
  409. setTimeout(() => {
  410. // 退出极光推送
  411. logoutJP(() => {
  412. this.$queue.toLogin()
  413. this.$queue.logout()
  414. })
  415. }, 1500)
  416. }
  417. }
  418. }
  419. </script>
  420. <style lang="scss" scoped>
  421. .my-company-page {
  422. display: flex;
  423. flex-direction: column;
  424. height: 100vh;
  425. background: linear-gradient(90.00deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  426. background-size: 100% 40%;
  427. background-position: center top;
  428. background-repeat: no-repeat;
  429. font-family: DM Sans;
  430. font-style: Regular;
  431. }
  432. /* 头部区域 */
  433. .header-section {
  434. text-align: center;
  435. }
  436. .illustration-area {
  437. .company-illustration {
  438. display: block;
  439. width: 280rpx;
  440. height: 180rpx;
  441. margin: 0 auto;
  442. }
  443. }
  444. // 管理员端
  445. .admin-container {
  446. flex: 1;
  447. .company-name {
  448. font-weight: 500;
  449. line-height: 44rpx;
  450. color: #fff;
  451. text-align: center;
  452. margin: 20rpx 40rpx;
  453. }
  454. .buttons {
  455. padding: 0 40rpx 28rpx;
  456. gap: 20rpx;
  457. .button {
  458. flex: 1;
  459. height: 80rpx;
  460. border-radius: 40rpx;
  461. background: rgba(255, 255, 255, 0.2);
  462. font-size: 32rpx;
  463. font-weight: 400;
  464. text-align: center;
  465. color: #fff;
  466. line-height: 80rpx;
  467. }
  468. }
  469. .list-wrapper {
  470. border-radius: 20rpx 20rpx 0 0;
  471. background-color: #fff;
  472. }
  473. .scroll-view {
  474. height: calc(100vh - 470rpx);
  475. overflow-y: auto;
  476. }
  477. .list {
  478. padding: 40rpx;
  479. .list-title {
  480. font-size: 32rpx;
  481. font-weight: 500;
  482. line-height: 56rpx;
  483. color: rgba(51, 51, 51, 1);
  484. }
  485. .account-item {
  486. padding: 32rpx 32rpx 28rpx 0;
  487. .title {
  488. color: rgba(51, 51, 51, 1);
  489. font-size: 30rpx;
  490. font-weight: 400;
  491. line-height: 44rpx;
  492. .badge {
  493. box-sizing: border-box;
  494. border: 1px solid rgba(1, 107, 246, 1);
  495. border-radius: 3px;
  496. background: rgba(1, 107, 246, 0.1);
  497. font-size: 20rpx;
  498. font-weight: 400;
  499. line-height: 24rpx;
  500. color: rgba(1, 107, 246, 1);
  501. margin-left: 16rpx;
  502. padding: 6rpx 12rpx;
  503. }
  504. }
  505. .sub-title {
  506. color: rgba(153, 153, 153, 1);
  507. font-size: 24rpx;
  508. font-weight: 400;
  509. line-height: 28rpx;
  510. margin-top: 10rpx;
  511. }
  512. .status-text {
  513. height: 54rpx;
  514. padding: 12rpx 24rpx;
  515. border-radius: 30rpx;
  516. font-size: 24rpx;
  517. font-weight: 400;
  518. line-height: 28rpx;
  519. color: rgba(1, 107, 246, 1);
  520. box-sizing: border-box;
  521. &.info {
  522. color: rgba(153, 153, 153, 1);
  523. }
  524. &.btn {
  525. color: #fff;
  526. background-color: #016BF6;
  527. }
  528. }
  529. .bottom-button {
  530. height: 44rpx;
  531. text-align: center;
  532. border-radius: 2px;
  533. background: rgba(1, 107, 246, 0.1);
  534. font-size: 24rpx;
  535. line-height: 44rpx;
  536. color: rgba(1, 107, 246, 1);
  537. margin-top: 10rpx;
  538. }
  539. }
  540. }
  541. }
  542. // 非管理员端
  543. .un-admin-container {
  544. .company-name {
  545. margin: 40rpx 40rpx 60rpx;
  546. color: rgba(255, 255, 255, 1);
  547. font-size: 28rpx;
  548. font-weight: 500;
  549. line-height: 44rpx;
  550. text-align: center;
  551. }
  552. .content-wrapper {
  553. border-radius: 20rpx 20rpx 0 0;
  554. background-color: #fff;
  555. padding: 52rpx 76rpx;
  556. .info-list {
  557. .info-item {
  558. color: rgba(153, 153, 153, 1);
  559. font-size: 24rpx;
  560. font-weight: 400;
  561. line-height: 32rpx;
  562. margin-bottom: 12rpx;
  563. text {
  564. padding-right: 48rpx;
  565. }
  566. }
  567. }
  568. .buttons {
  569. margin-top: 40rpx;
  570. .button {
  571. width: 100%;
  572. height: 40px;
  573. box-sizing: border-box;
  574. border: 1px solid rgba(1, 107, 246, 1);
  575. border-radius: 40px;
  576. background: rgba(255, 255, 255, 1);
  577. text-align: center;
  578. line-height: 38px;
  579. font-size: 16px;
  580. font-weight: 400;
  581. margin-bottom: 40rpx;
  582. &.plain {
  583. color: rgba(1, 107, 246, 1);
  584. }
  585. &.primary {
  586. color: #fff;
  587. background: rgba(1, 107, 246, 1);
  588. }
  589. }
  590. }
  591. }
  592. }
  593. // 审核弹窗
  594. .audit-modal {
  595. min-height: 180rpx;
  596. .title {
  597. color: rgba(51, 51, 51, 1);
  598. font-size: 30rpx;
  599. font-weight: 400;
  600. line-height: 44rpx;
  601. margin-top: 48rpx;
  602. .badge {
  603. box-sizing: border-box;
  604. border: 1px solid rgba(1, 107, 246, 1);
  605. border-radius: 3px;
  606. background: rgba(1, 107, 246, 0.1);
  607. font-size: 20rpx;
  608. font-weight: 400;
  609. line-height: 24rpx;
  610. color: rgba(1, 107, 246, 1);
  611. margin-left: 16rpx;
  612. padding: 6rpx 12rpx;
  613. }
  614. }
  615. .sub-title {
  616. color: rgba(153, 153, 153, 1);
  617. font-size: 24rpx;
  618. font-weight: 400;
  619. line-height: 28rpx;
  620. margin-top: 10rpx;
  621. }
  622. .check-bar {
  623. font-size: 24rpx;
  624. margin-top: 50rpx;
  625. ::v-deep .u-checkbox__label {
  626. margin-right: 20rpx;
  627. }
  628. .tip {
  629. padding-bottom: 5px;
  630. }
  631. }
  632. }
  633. // 更换账号弹窗
  634. .input-wrapper {
  635. box-sizing: border-box;
  636. border: 1px solid rgba(242, 242, 242, 1);
  637. border-radius: 6px;
  638. background: rgba(250, 250, 250, 1);
  639. margin-bottom: 16rpx;
  640. padding: 10rpx 24rpx;
  641. font-size: 28rpx;
  642. line-height: 60rpx;
  643. input {
  644. height: 60rpx;
  645. font-size: 28rpx;
  646. color: #1f2c37;
  647. }
  648. .placeholder {
  649. color: rgba(158, 161, 168, 1);
  650. }
  651. .verify-input {
  652. width: 300rpx;
  653. }
  654. .verify-btn {
  655. color: rgba(1, 107, 246, 1);
  656. }
  657. }
  658. </style>