mine.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. <!-- 我的 -->
  2. <template>
  3. <view id="mine">
  4. <view class="top-max-big-box" v-if="pageType">
  5. <!--老师-->
  6. <view class="top-max-box-two" v-if="userType==1&&certification.auditStatus">
  7. <view class="user-img-box" @click="selectImage">
  8. <img v-if="userData.avatar" :src="userData.avatarUrl">
  9. <img v-else src="@/images/basicsModules/icon_01.png">
  10. <view>{{userData.avatar?'编辑':'未上传'}}</view>
  11. </view>
  12. <view class="name-box">
  13. <view>{{userData.userName}}</view>
  14. <view>{{userData.professional}}丨{{userData.deptName}}</view>
  15. </view>
  16. </view>
  17. <!--学生-->
  18. <view class="user-top-max-box-one" v-if="userType==2">
  19. <view class="back-posi"></view>
  20. <view class="top-max-box-one">
  21. <view class="user-img-box" @click="selectImage">
  22. <img v-if="userData.avatar" :src="userData.avatarUrl">
  23. <img v-else src="@/images/basicsModules/icon_01.png">
  24. <view>{{userData.avatar?'编辑':'未上传'}}</view>
  25. </view>
  26. <view class="name-box">
  27. <view class="name-box-min">
  28. <view>{{userData.userName}}</view>
  29. <view
  30. :class="userData.status == 2?'view-color-one':(userData.status == 3?'view-color-two':(userData.status == 1?'view-color-tree':''))">
  31. {{userData.status == 2?'负面清单':(userData.status == 3?'黑名单':(userData.status == 1?'正常':''))}}
  32. </view>
  33. </view>
  34. <view class="name-box-user">{{userData.professional}}丨{{userData.deptName}}</view>
  35. </view>
  36. </view>
  37. <view class="num-max-box">
  38. <view class="min-num-box" @click="goUserPage('none')">
  39. <view class="min-num-view color-one">{{creditScore}}</view>
  40. <view class="bottom-min-num-view">
  41. <img class="img-one" src="@/images/basicsModules/icon_wd_xyf.png">
  42. <view>信用分</view>
  43. </view>
  44. </view>
  45. <view class="null-p"></view>
  46. <view class="min-num-box" @click="goUserPage('none')">
  47. <view class="min-num-view color-two">{{bonusPoints}}</view>
  48. <view class="bottom-min-num-view">
  49. <img class="img-two" src="@/images/basicsModules/icon_wd_jlf.png">
  50. <view>奖励分</view>
  51. </view>
  52. </view>
  53. <view class="null-p"></view>
  54. <view class="min-num-box" @click="goUserPage(3)">
  55. <view class="min-num-view">扫一扫</view>
  56. <view class="bottom-min-num-view">
  57. <img class="img-two" src="@/images/basicsModules/icon_wd_dh.png">
  58. <view>兑换礼品</view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <mineConfigurationSlot v-for="(item,index) in mineConfigData" :key="index" :mineConfig="item">
  65. </mineConfigurationSlot>
  66. <view class="out-button" @click="clickOut">退出登录</view>
  67. <tab-bar></tab-bar>
  68. </view>
  69. </template>
  70. <script>
  71. import {
  72. config
  73. } from '@/api/request/config.js'
  74. import {
  75. logout,
  76. studentinfoFacemy,
  77. simpleInfo,
  78. getSafeWarnList,
  79. getMyPointsLogInfo,
  80. querySignature,
  81. fingerprintQuantity,
  82. fingerprintQueryList,
  83. systemAppletLayoutSelect
  84. } from '@/api/basicsModules/index.js'
  85. import {
  86. tabBar
  87. } from '@/component/tabBar.vue'
  88. import {
  89. mineConfigurationSlot
  90. } from '@/component/mineConfigurationSlot'
  91. import {
  92. getMineConfig
  93. } from '@/utils/mineConfig'
  94. export default {
  95. components: {
  96. tabBar,
  97. mineConfigurationSlot,
  98. },
  99. data() {
  100. return {
  101. mineConfigData: [],
  102. //页面状态
  103. pageType: false,
  104. //认证数据
  105. certification: {
  106. },
  107. userType: 0,
  108. userData: {
  109. deptName: "",
  110. professional: "",
  111. userName: "",
  112. },
  113. securityAlertNum: 0,
  114. adminSubCount: 0,
  115. wranDoCount: 0,
  116. //奖励分
  117. bonusPoints: 0,
  118. //信用分
  119. creditScore: 0,
  120. //用户签名
  121. signatureUrl: '',
  122. // 人脸
  123. ifFaceFeature: "",
  124. //签名
  125. isUpload: "",
  126. Quantity: 0, //指纹录取数量
  127. }
  128. },
  129. onLoad() {
  130. },
  131. onShow() {
  132. this.systemAppletLayoutSelect();
  133. if (uni.getStorageSync('token') && uni.getStorageSync('userId') && uni.getStorageSync('userType')) {
  134. this.userType = uni.getStorageSync('userType')
  135. this.studentinfoFacemy();
  136. this.simpleInfo();
  137. this.querySignature();
  138. } else {
  139. uni.removeStorageSync('token');
  140. uni.removeStorageSync('userId');
  141. uni.removeStorageSync('userType');
  142. uni.redirectTo({
  143. url: '/pages/login',
  144. });
  145. }
  146. },
  147. methods: {
  148. //获取菜单配置
  149. async systemAppletLayoutSelect() {
  150. const {
  151. data
  152. } = await systemAppletLayoutSelect({
  153. module: 'mine'
  154. })
  155. if (data.code == 200) {
  156. let list = JSON.parse(JSON.stringify(data.data))
  157. for (let i = 0; i < list.length; i++) {
  158. list[i].layout = JSON.parse(list[i].layout);
  159. }
  160. this.$set(this, 'mineConfigData', getMineConfig(list));
  161. console.log('mineConfigData', this.mineConfigData)
  162. }
  163. },
  164. //学生端-信用分/奖励分/扫一扫按钮
  165. goUserPage(type) {
  166. let self = this;
  167. if (type == 1) {
  168. uni.navigateTo({
  169. url: '/pages_student/mine/creditPoints',
  170. });
  171. } else if (type == 2) {
  172. uni.navigateTo({
  173. url: '/pages_student/mine/rewardPoints',
  174. });
  175. } else if (type == 3) {
  176. uni.scanCode({
  177. onlyFromCamera: true,
  178. success: function(res) {
  179. uni.navigateTo({
  180. url: '/pages_student/mine/codeSuccess?q=' + encodeURIComponent(JSON.stringify(res.result))
  181. });
  182. }
  183. });
  184. } else if (type == 'none') {
  185. uni.showToast({
  186. title: '暂未开放',
  187. icon: "none",
  188. mask: true,
  189. duration: 2000
  190. });
  191. }
  192. },
  193. //获取个人信息
  194. async simpleInfo() {
  195. const {
  196. data
  197. } = await simpleInfo();
  198. if (data.code == 200) {
  199. this.userData = data.data;
  200. this.userData.avatar = data.data.avatar;
  201. this.userData.avatarUrl = config.base_url + data.data.avatar;
  202. console.log(config.base_url)
  203. console.log(this.userData.avatarUrl)
  204. if (this.userType == 1) {
  205. this.getSafeWarnList();
  206. } else if (this.userType == 2) {
  207. //this.getMyPointsLogInfo();
  208. }
  209. if (data.data.count) {
  210. this.adminSubCount = data.data.count.adminSubCount;
  211. this.wranDoCount = data.data.count.wranDoCount;
  212. }
  213. this.pageType = true;
  214. }
  215. },
  216. //查询用户指纹录取数量
  217. async fingerprintQuantityFun() {
  218. let _this = this;
  219. const {
  220. data
  221. } = await fingerprintQuantity(uni.getStorageSync('userId'));
  222. if (data.code == 200) {
  223. _this.Quantity = data.data;
  224. }
  225. },
  226. //查询用户指纹录取数据
  227. async fingerprintClick() {
  228. let _this = this;
  229. const {
  230. data
  231. } = await fingerprintQueryList(uni.getStorageSync('userId'));
  232. if (data.code == 200) {
  233. uni.navigateTo({
  234. url: '/pages/fingerprint', //指纹信息
  235. });
  236. }
  237. },
  238. //查询用户电子签名
  239. async querySignature() {
  240. let _this = this;
  241. const {
  242. data
  243. } = await querySignature();
  244. if (data.code == 200) {
  245. _this.isUpload = data.data.isUpload;
  246. _this.signatureUrl = data.data.signature;
  247. }
  248. },
  249. //获取个人奖励分/信用分
  250. async getMyPointsLogInfo() {
  251. const {
  252. data
  253. } = await getMyPointsLogInfo();
  254. if (data.code == 200) {
  255. this.bonusPoints = data.data.bonusPoints;
  256. this.creditScore = data.data.creditScore;
  257. }
  258. },
  259. //获取报警信息列表
  260. async getSafeWarnList() {
  261. let obj = {
  262. pageNum: 1,
  263. pageSize: 1,
  264. count: 0,
  265. groupStatus: 1,
  266. };
  267. const {
  268. data
  269. } = await getSafeWarnList(obj);
  270. if (data.code == 200) {
  271. if (data.rows[0]) {
  272. this.securityAlertNum = data.rows[0].todayHappenCount;
  273. } else {
  274. this.securityAlertNum = 0;
  275. }
  276. }
  277. },
  278. //获取当前身份人脸验证状态与学生卡上传状态
  279. async studentinfoFacemy() {
  280. let obj = {
  281. studentsId: uni.getStorageSync('userId')
  282. }
  283. const {
  284. data
  285. } = await studentinfoFacemy(obj)
  286. if (data.code == 200) {
  287. this.certification = data.data;
  288. this.ifFaceFeature = data.data.ifFaceFeature;
  289. }
  290. },
  291. //退出按钮
  292. clickOut() {
  293. let self = this;
  294. uni.showModal({
  295. // title: '确认要退出吗?',
  296. content: '确认要退出吗',
  297. cancelColor: "#999",
  298. confirmColor: "#0183FA",
  299. success: function(res) {
  300. if (res.confirm) {
  301. self.logout();
  302. } else if (res.cancel) {}
  303. }
  304. });
  305. },
  306. //退出登录
  307. async logout() {
  308. uni.clearStorageSync();
  309. uni.redirectTo({
  310. url: '/pages/login/login',
  311. });
  312. // let self = this;
  313. // const {data} = await logout();
  314. // if(data.code == 200){
  315. // uni.removeStorageSync('token');
  316. // uni.removeStorageSync('userId');
  317. // uni.removeStorageSync('userType');
  318. // uni.redirectTo({
  319. // url: '/pages/login',
  320. // });
  321. // }
  322. },
  323. //页面跳转
  324. goPage(type) {
  325. if (type == 'pointsRecord') { //积分记录
  326. uni.navigateTo({
  327. url: '/pages_student/mine/pointsRecord',
  328. });
  329. } else if (type == 'faceImage') { //身份验证
  330. uni.navigateTo({
  331. url: '/pages/faceImage',
  332. });
  333. } else if (type == 'laboratory') {
  334. uni.navigateTo({
  335. url: '/pages_manage/workbench/laboratory/meLaboratory', //我的实验室
  336. });
  337. } else if (type == 'alarm') {
  338. uni.navigateTo({
  339. url: '/pages/earlyWarningManage/earlyWarningList', //安全警报
  340. });
  341. } else if (type == 'record') {
  342. uni.navigateTo({
  343. url: '/pages_manage/workbench/plan/planList', //预案执行记录
  344. });
  345. } else if (type == 'signature') {
  346. uni.navigateTo({
  347. url: '/pages_manage/workbench/signature/signature?item=' + this.signatureUrl, //电子签名
  348. });
  349. }
  350. },
  351. // 头像上传
  352. selectImage() {
  353. let self = this;
  354. wx.chooseImage({
  355. count: 1,
  356. sizeType: ["original", "compressed"],
  357. sourceType: ["album", "camera"],
  358. success: function(res) {
  359. let tempFilePaths = res.tempFilePaths[0];
  360. self.uploadImg(tempFilePaths);
  361. }
  362. });
  363. },
  364. async uploadImg(tempFilePaths) {
  365. var self = this;
  366. uni.showLoading({
  367. title: '上传中',
  368. mask: true
  369. });
  370. uni.uploadFile({
  371. url: config.base_url + '/base/file/upload', //仅为示例,非真实的接口地址
  372. header: {
  373. 'Authorization': uni.getStorageSync('token')
  374. },
  375. filePath: tempFilePaths,
  376. name: 'file',
  377. formData: {
  378. 'user': 'test'
  379. },
  380. success: (uploadFileRes) => {
  381. let res = JSON.parse(uploadFileRes.data);
  382. if (res.code == 200) {
  383. uni.navigateTo({
  384. url: '/pages/avatar?src=' + config.base_url + res.data.url, //预案执行记录
  385. });
  386. } else {
  387. uni.showToast({
  388. title: res.msg,
  389. icon: "none",
  390. mask: true,
  391. duration: 2000
  392. });
  393. }
  394. },
  395. fail: err => {},
  396. complete: () => {
  397. uni.hideLoading()
  398. }
  399. });
  400. },
  401. },
  402. }
  403. </script>
  404. <style lang="stylus" scoped>
  405. #mine {
  406. height: 100%;
  407. .top-max-big-box {
  408. /*background:#ffffff;*/
  409. .user-top-max-box-one {
  410. overflow hidden;
  411. background url("@/images/basicsModules/img_wd_bg.png") no-repeat;
  412. background-size: 100%;
  413. height: 350rpx;
  414. .top-max-box-one {
  415. background #fff;
  416. margin: 40rpx 40rpx 0;
  417. z-index: 1;
  418. height: 180rpx;
  419. border-top-right-radius 20rpx;
  420. border-top-left-radius 20rpx;
  421. display flex;
  422. overflow hidden;
  423. .user-img-box {
  424. height: 120rpx;
  425. width: 100rpx;
  426. margin: 30rpx 53rpx 0 22rpx;
  427. img {
  428. height: 100rpx;
  429. width: 100rpx;
  430. border-radius: 50%;
  431. }
  432. view {
  433. font-size: 22rpx;
  434. color: #666666;
  435. text-align center;
  436. line-height: 22rpx;
  437. margin-top: 10rpx;
  438. }
  439. }
  440. .name-box {
  441. margin-top: 30rpx;
  442. .name-box-min {
  443. display flex;
  444. overflow hidden;
  445. margin-bottom: 11rpx;
  446. view:nth-child(1) {
  447. height: 48rpx;
  448. line-height: 48rpx;
  449. font-size: 30rpx;
  450. color: #333;
  451. }
  452. view:nth-child(2) {
  453. height: 30rpx;
  454. line-height: 30rpx;
  455. font-size: 20rpx;
  456. padding: 0 20rpx;
  457. margin: 9rpx 0 9rpx 20rpx;
  458. }
  459. .view-color-one {
  460. background #FDD255;
  461. }
  462. .view-color-two {
  463. background #A2A2A2;
  464. }
  465. .view-color-tree {
  466. background #0183FA;
  467. }
  468. }
  469. .name-box-user {
  470. line-height: 41rpx;
  471. font-size: 22rpx;
  472. color: #333;
  473. }
  474. }
  475. }
  476. .num-max-box {
  477. width: 670rpx;
  478. background #fff;
  479. border-bottom-right-radius 20rpx;
  480. border-bottom-left-radius 20rpx;
  481. height: 130rpx;
  482. margin: 0 40rpx;
  483. display flex;
  484. .min-num-box {
  485. flex: 1;
  486. .min-num-view {
  487. margin-top: 30rpx;
  488. height: 30rpx;
  489. line-height: 30rpx;
  490. font-size: 22rpx;
  491. text-align center
  492. }
  493. .color-one {
  494. font-weight: 700;
  495. font-size: 26rpx;
  496. color: #2B99FE;
  497. }
  498. .color-two {
  499. font-weight: 700;
  500. font-size: 26rpx;
  501. color: #FDD255;
  502. }
  503. .bottom-min-num-view {
  504. display flex;
  505. margin-top: 20rpx;
  506. .img-one {
  507. width: 25rpx;
  508. height: 28rpx;
  509. margin: 0 10rpx 0 58rpx;
  510. }
  511. .img-two {
  512. width: 28rpx;
  513. height: 26rpx;
  514. margin: 0 10rpx 0 59rpx;
  515. }
  516. view {
  517. font-size: 22rpx;
  518. }
  519. }
  520. }
  521. }
  522. .null-p {
  523. background #dedede;
  524. height: 30rpx;
  525. width: 2rpx;
  526. margin: 50rpx 0 0;
  527. }
  528. }
  529. .top-max-box-two {
  530. background url("@/images/basicsModules/img_wd_bg.png");
  531. background-size: 100%;
  532. height: 245rpx;
  533. display flex;
  534. overflow hidden;
  535. .user-img-box {
  536. height: 120rpx;
  537. width: 100rpx;
  538. margin: 50rpx 53rpx 0 22rpx;
  539. img {
  540. height: 100rpx;
  541. width: 100rpx;
  542. border-radius: 50%;
  543. }
  544. view {
  545. font-size: 22rpx;
  546. color: #fff;
  547. text-align center;
  548. line-height: 22rpx;
  549. margin-top: 10rpx;
  550. }
  551. }
  552. .name-box {
  553. margin-top: 50rpx;
  554. view:nth-child(1) {
  555. line-height: 48rpx;
  556. margin-bottom: 11rpx;
  557. font-size: 30rpx;
  558. color: #fff;
  559. }
  560. view:nth-child(2) {
  561. line-height: 41rpx;
  562. font-size: 22rpx;
  563. color: #fff;
  564. }
  565. }
  566. }
  567. .button-max-big-box {
  568. background #fff;
  569. padding: 0 20rpx;
  570. margin-top: 30rpx;
  571. .button-max-box {
  572. height: 100rpx;
  573. display flex;
  574. border-top: 1rpx solid #e0e0e0;
  575. .left-img {
  576. height: 30rpx;
  577. width: 30rpx;
  578. margin: 34rpx 44rpx 0 0;
  579. }
  580. view {
  581. line-height: 100rpx;
  582. }
  583. view:nth-child(2) {
  584. flex: 1;
  585. color: #333333;
  586. font-size: 30rpx;
  587. }
  588. .right-img {
  589. height: 24rpx;
  590. width: 12rpx;
  591. margin: 39rpx 0 0 0;
  592. }
  593. .colorA {
  594. color: #E45656 !important;
  595. }
  596. .marginType {
  597. margin-right: 12rpx;
  598. }
  599. .view-three-one {
  600. width: 30rpx;
  601. height: 30rpx;
  602. text-align center;
  603. background #FF4552;
  604. border-radius: 50%;
  605. font-size: 20rpx;
  606. line-height: 30rpx;
  607. color: #fff;
  608. margin: 36rpx 20rpx;
  609. }
  610. .view-three-two {
  611. width: 30rpx;
  612. height: 30rpx;
  613. text-align center;
  614. border-radius: 50%;
  615. font-size: 20rpx;
  616. line-height: 30rpx;
  617. color: #999;
  618. margin: 36rpx 20rpx;
  619. }
  620. .view-three-type {
  621. width: 120rpx;
  622. text-align center;
  623. color: #CCCCCC;
  624. font-size: 26rpx;
  625. }
  626. }
  627. .button-max-box:nth-child(1) {
  628. border: none;
  629. }
  630. }
  631. }
  632. .out-button {
  633. position absolute;
  634. bottom: 140rpx;
  635. left: 25rpx;
  636. width: 700rpx;
  637. height: 100rpx;
  638. line-height: 100rpx;
  639. border-radius: 10rpx;
  640. text-align center;
  641. background #E0E0E0;
  642. color: #0183FA;
  643. font-size: 30rpx;
  644. margin: 0 auto;
  645. }
  646. }
  647. </style>