mine.vue 16 KB

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