mine.vue 18 KB

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