index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. <template>
  2. <div class="app-container">
  3. <header>
  4. <!-- <img :src="userInfos.avatar" alt="" /> -->
  5. <van-image class="mr10" width="100px" height="100px" round :src="userInfos.avatar" />
  6. <div class="content">
  7. <p class="bold">
  8. <van-text-ellipsis :content="`${userInfos.nickName}(信用分:${userInfos.creditScore})`" />
  9. <van-icon name="setting" size="20" @click="onRouterPush('/user/edit')" />
  10. </p>
  11. <p class="flex justify-between">
  12. <van-text-ellipsis :content="userInfos.pgName" />
  13. </p>
  14. <p>
  15. <van-text-ellipsis :content="userInfos.deptName" />
  16. </p>
  17. </div>
  18. </header>
  19. <div class="main">
  20. <!-- <ul class="links">
  21. <li @click="onRouterPush('/training')">培训通知</li>
  22. <li>我的报名</li>
  23. <li>我的学习</li>
  24. <li>我的考试</li>
  25. </ul> -->
  26. <!-- <ul>
  27. <li>使用指引</li>
  28. <li>安全积分:{{ userInfos.creditScore }}分</li>
  29. </ul> -->
  30. <div class="card">
  31. <h4>经费统计</h4>
  32. <ul class="nav">
  33. <!-- <li>
  34. <span>123,000</span>
  35. <p>账户余额(¥)</p>
  36. </li> -->
  37. <li @click="onRouterPush('/my-cash-flow')">
  38. <span>{{ billInfo.totalFlowCount }}</span>
  39. <p>费用流水</p>
  40. </li>
  41. <li>
  42. <span>{{ billInfo.currentMonthFee }}</span>
  43. <p>本月支出</p>
  44. </li>
  45. <li>
  46. <span>{{ billInfo.totalFee }}</span>
  47. <p>累计支出</p>
  48. </li>
  49. </ul>
  50. </div>
  51. <div class="card" @click="showOperatingGuidelines">
  52. <h4>平台入室操作指引</h4>
  53. </div>
  54. <div class="card">
  55. <van-cell v-auth="'instr_open'" title="打开设备" is-link @click="openInst" />
  56. <van-cell v-auth="'instr_close'" title="关闭设备" is-link @click="closeInst" />
  57. </div>
  58. </div>
  59. <footer>
  60. <!-- <wx-open-subscribe template="-pVpM6TH1oz1cZntEhGzQjmMMODF9tLLzh_1yjjWYSk" @success="handleSubscribe">
  61. <component :is="'script'" type="text/wxtag-template">
  62. <button class="w100 ">订阅</button>
  63. </component>
  64. </wx-open-subscribe> -->
  65. <van-button class="w100 mt10" color="#1cb4fd" plain @click="onRouterPush('/user/password')">
  66. 修改密码
  67. </van-button>
  68. <van-button class="w100 mt10" @click="signOut" type="primary">
  69. 切换账号
  70. </van-button>
  71. </footer>
  72. <van-popup position="bottom" v-model:show="showPopup" :style="{ padding: '20px' }">
  73. <div class="operation-guide">
  74. <div class="guide-header">
  75. <h3>操作指引</h3>
  76. <van-icon name="cross" @click="showPopup = false" />
  77. </div>
  78. <div class="steps-container">
  79. <div v-for="(item, index) in handleStepList" :key="item.step" class="step-item"
  80. :class="{ 'last-step': index === handleStepList.length - 1 }">
  81. <div class="step-number-wrapper">
  82. <div class="step-number">{{ item.step }}</div>
  83. <div v-if="index < handleStepList.length - 1" class="step-line"></div>
  84. </div>
  85. <div class="step-content">
  86. <h4 class="step-title">{{ item.title }}</h4>
  87. <p class="step-desc">{{ item.desc }}</p>
  88. <!-- <van-button
  89. v-if="item.btn"
  90. size="small"
  91. type="primary"
  92. class="step-btn"
  93. @click="handleStepAction(item)"
  94. >
  95. {{ item.btn }}
  96. </van-button> -->
  97. </div>
  98. </div>
  99. </div>
  100. <div class="guide-footer">
  101. <van-icon name="info-o" />
  102. <span>请按照步骤顺序完成操作</span>
  103. </div>
  104. </div>
  105. </van-popup>
  106. </div>
  107. </template>
  108. <script lang="ts" setup>
  109. import { ref, onMounted } from 'vue'
  110. import { storeToRefs } from 'pinia'
  111. import to from 'await-to-js'
  112. import { showConfirmDialog, showDialog, showToast } from 'vant'
  113. import { useRouter } from 'vue-router'
  114. import { useUserInfo } from '/@/stores/userInfo'
  115. import { Local, Session } from '/@/utils/storage'
  116. import { useBillApi } from '/@/api/instr/finance/bill'
  117. import { useLoginApi } from '/@/api/login'
  118. import { scanCodeWxUrl, InstSwitchType } from '/@/constants/pageConstants'
  119. import wx from 'weixin-js-sdk'
  120. const billApi = useBillApi()
  121. const loginApi = useLoginApi()
  122. const router = useRouter()
  123. const storesUseUserInfo = useUserInfo()
  124. const { userInfos, openId } = storeToRefs(storesUseUserInfo)
  125. const showPopup = ref<boolean>(false)
  126. const billInfo = ref<{
  127. totalFlowCount: number
  128. currentMonthFee: number
  129. totalFee: number
  130. }>({
  131. totalFlowCount: 0,
  132. currentMonthFee: 0,
  133. totalFee: 0,
  134. })
  135. const handleStepList = ref([
  136. {
  137. title: '第一步:入室培训和考试',
  138. desc: '请先完成入室培训,掌握必要的安全操作知识和实验室规章制度,并通过考试',
  139. btn: '培训报名',
  140. step: 1,
  141. },
  142. {
  143. title: '第二步:提交入室申请',
  144. desc: '完成入室培训考核合格后,在入室管理里面提交入室申请,等待平台管理员审核',
  145. btn: '前往提交',
  146. step: 2,
  147. },
  148. // {
  149. // title: '第三步:上传入室资料',
  150. // desc: '整理相关凭证并将入室资料上传到系统中',
  151. // step: 3,
  152. // },
  153. {
  154. title: '第三步:等待审核和房间分配',
  155. desc: '由平台管理老师进行审核并分配细胞房或分配分子储物柜,收到审核通过的通知后,即可在申请的时段进入细胞房或分子室进行实验',
  156. step: 3,
  157. },
  158. ])
  159. const onRouterPush = (val: string) => {
  160. router.push(val)
  161. }
  162. const signOut = () => {
  163. showConfirmDialog({
  164. message: '确认切换账号?',
  165. }).then(async () => {
  166. // 先解绑微信
  167. const [unbindErr]: ToResponse = await to(
  168. loginApi.WeChatUnBindOpenId()
  169. )
  170. // 解绑失败则终止流程
  171. if (unbindErr) {
  172. showToast('解绑失败,请重试')
  173. return
  174. }
  175. // 调用退出登录接口
  176. const [err]: ToResponse = await to(loginApi.signOut())
  177. if (err) {
  178. showToast('退出登录失败,请重试')
  179. return
  180. }
  181. // 清理所有本地缓存
  182. Local.clear()
  183. Session.clear()
  184. // 重置用户信息
  185. storesUseUserInfo.resetUserInfo()
  186. // 关闭窗口
  187. wx.closeWindow()
  188. // 跳转登录重新走授权
  189. // router.replace('/login')
  190. })
  191. }
  192. const handleSubscribe = (errMsg: any, subscribeDetails: any) => {
  193. console.log(errMsg, subscribeDetails)
  194. }
  195. const showOperatingGuidelines = () => {
  196. showPopup.value = true
  197. }
  198. const handleStepAction = (item: any) => {
  199. // Implementation of handleStepAction
  200. }
  201. const checkPermi = (perms: string[]) => {
  202. const list = userInfos.value?.authBtnList || []
  203. return perms.some((p) => list.includes(p))
  204. }
  205. const openInst = () => {
  206. const url = scanCodeWxUrl('START_RUN', InstSwitchType.OPEN)
  207. window.location.href = url
  208. }
  209. const closeInst = () => {
  210. const url = scanCodeWxUrl('END_RUN', InstSwitchType.CLOSE)
  211. window.location.href = url
  212. }
  213. // 获取个人账单信息
  214. const getBillInfo = async () => {
  215. const [err, res]: ToResponse = await to(billApi.getMyOrderTotal())
  216. if (err) return
  217. billInfo.value = res?.data
  218. }
  219. onMounted(() => {
  220. getBillInfo()
  221. })
  222. </script>
  223. <style lang="scss" scoped>
  224. .app-container {
  225. display: flex;
  226. flex-direction: column;
  227. header {
  228. background-color: #1c9bfd;
  229. color: #fff;
  230. padding: 10px;
  231. border-radius: 8px;
  232. margin-top: 10px;
  233. display: flex;
  234. .content {
  235. flex: 1;
  236. display: flex;
  237. flex-direction: column;
  238. justify-content: space-around;
  239. overflow: hidden;
  240. .bold {
  241. display: flex;
  242. align-items: center;
  243. font-weight: bold;
  244. // flex-wrap: nowrap;
  245. white-space: nowrap;
  246. .van-text-ellipsis {
  247. flex: 1;
  248. }
  249. }
  250. }
  251. }
  252. .main {
  253. flex: 1;
  254. overflow-y: auto;
  255. >ul {
  256. display: flex;
  257. height: 60px;
  258. margin-top: 10px;
  259. li {
  260. flex: 1;
  261. background: #fff;
  262. color: #333;
  263. display: flex;
  264. align-items: center;
  265. justify-content: center;
  266. border-radius: 4px;
  267. &+li {
  268. margin-left: 10px;
  269. }
  270. }
  271. &.links {
  272. li {
  273. color: #fff;
  274. background: #5eb7fc;
  275. &:nth-child(2) {
  276. background: #fd9c5e;
  277. }
  278. &:nth-child(3) {
  279. background: #53e3a7;
  280. }
  281. &:nth-child(4) {
  282. background: #888ac3;
  283. }
  284. }
  285. }
  286. }
  287. .card {
  288. margin-top: 10px;
  289. border-radius: 4px;
  290. background-color: #fff;
  291. padding: 10px;
  292. h4 {
  293. height: 18px;
  294. line-height: 18px;
  295. &::before {
  296. display: inline-block;
  297. content: '';
  298. width: 3px;
  299. height: 18px;
  300. background-color: #1c9bfd;
  301. margin-right: 4px;
  302. vertical-align: middle;
  303. }
  304. }
  305. .nav {
  306. display: flex;
  307. margin: 10px 0;
  308. flex-wrap: wrap;
  309. justify-content: space-between;
  310. li {
  311. flex: 0 0 25%;
  312. display: flex;
  313. flex-direction: column;
  314. align-items: center;
  315. justify-content: center;
  316. span {
  317. font-size: 20px;
  318. }
  319. p {
  320. margin-top: 4px;
  321. }
  322. &:nth-child(n + 5) {
  323. margin-top: 10px;
  324. }
  325. }
  326. }
  327. }
  328. }
  329. footer {
  330. flex: 0 0 44px;
  331. margin-bottom: 20px;
  332. }
  333. }
  334. :deep(.van-popup--bottom) {
  335. padding: 20px !important;
  336. }
  337. .operation-guide {
  338. max-height: 70vh;
  339. overflow-y: auto;
  340. .guide-header {
  341. display: flex;
  342. justify-content: space-between;
  343. align-items: center;
  344. margin-bottom: 20px;
  345. padding-bottom: 15px;
  346. border-bottom: 1px solid #eee;
  347. h3 {
  348. margin: 0;
  349. font-size: 18px;
  350. font-weight: 600;
  351. color: #333;
  352. }
  353. .van-icon {
  354. font-size: 18px;
  355. color: #999;
  356. cursor: pointer;
  357. &:hover {
  358. color: #666;
  359. }
  360. }
  361. }
  362. .steps-container {
  363. .step-item {
  364. display: flex;
  365. margin-bottom: 20px;
  366. &.last-step {
  367. margin-bottom: 0;
  368. }
  369. .step-number-wrapper {
  370. position: relative;
  371. margin-right: 15px;
  372. display: flex;
  373. flex-direction: column;
  374. align-items: center;
  375. .step-number {
  376. width: 32px;
  377. height: 32px;
  378. background: linear-gradient(135deg, #1c9bfd, #5eb7fc);
  379. color: white;
  380. border-radius: 50%;
  381. display: flex;
  382. align-items: center;
  383. justify-content: center;
  384. font-weight: 600;
  385. font-size: 14px;
  386. box-shadow: 0 2px 8px rgba(28, 155, 253, 0.3);
  387. }
  388. .step-line {
  389. width: 2px;
  390. height: 40px;
  391. background: linear-gradient(to bottom, #1c9bfd, #e0e0e0);
  392. margin-top: 8px;
  393. }
  394. }
  395. .step-content {
  396. flex: 1;
  397. padding-top: 2px;
  398. .step-title {
  399. margin: 0 0 8px 0;
  400. font-size: 16px;
  401. font-weight: 600;
  402. color: #333;
  403. line-height: 1.4;
  404. }
  405. .step-desc {
  406. margin: 0 0 12px 0;
  407. font-size: 14px;
  408. color: #666;
  409. line-height: 1.5;
  410. }
  411. .step-btn {
  412. border-radius: 20px;
  413. padding: 8px 16px;
  414. font-size: 12px;
  415. background: linear-gradient(135deg, #1c9bfd, #5eb7fc);
  416. border: none;
  417. box-shadow: 0 2px 8px rgba(28, 155, 253, 0.3);
  418. &:active {
  419. transform: translateY(1px);
  420. }
  421. }
  422. }
  423. }
  424. }
  425. .guide-footer {
  426. display: flex;
  427. align-items: center;
  428. justify-content: center;
  429. margin-top: 20px;
  430. padding: 15px;
  431. background: #f8f9fa;
  432. border-radius: 8px;
  433. .van-icon {
  434. margin-right: 6px;
  435. color: #1c9bfd;
  436. font-size: 16px;
  437. }
  438. span {
  439. font-size: 13px;
  440. color: #666;
  441. }
  442. }
  443. }
  444. </style>