mine.vue 18 KB

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