teacherMine.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <view class="teacherMine">
  3. <!-- 背景渐变色 -->
  4. <view class="back-img-box"></view>
  5. <!-- 信息面板 -->
  6. <view class="user-info-box">
  7. <view class="left-img-box">
  8. <img v-if="userData.avatar" class="avatar-img" :src="userData.avatar">
  9. <img v-else class="avatar-img" src="@/pages/images/icon_01.png">
  10. <img class="edit-img" src="@/pages/images/newImage/icon_wd_bj@1x.png">
  11. </view>
  12. <view class="right-name-box">
  13. <view class="right-name-top-box">
  14. <view>{{userData.userName}}</view>
  15. </view>
  16. <view class="right-name-bottom-box">{{userData.deptName}}</view>
  17. </view>
  18. </view>
  19. <!-- 信用分面板 -->
  20. <view class="points-max-box">
  21. <view class="points-big-box">
  22. <view class="num-p colorA">{{creditScore?creditScore:'-'}}</view>
  23. <view class="img-box">
  24. <img src="@/pages/images/newImage/icon_wd_xyf@1x.png">
  25. <view>信用分</view>
  26. </view>
  27. </view>
  28. <view class="border-null-p"></view>
  29. <view class="points-big-box">
  30. <view class="num-p colorB">{{bonusPoints?bonusPoints:'-'}}</view>
  31. <view class="img-box">
  32. <img src="@/pages/images/newImage/icon_wd_jlf@1x.png">
  33. <view>奖励分</view>
  34. </view>
  35. </view>
  36. <view class="border-null-p"></view>
  37. <view class="points-big-box" @click="scanCode()">
  38. <view class="num-p colorC">扫一扫</view>
  39. <view class="img-box">
  40. <img style="margin-left:30rpx;" src="@/pages/images/newImage/icon_wd_dh@1x.png">
  41. <view>积分兑换</view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 按钮部分 -->
  46. <view class="button-max-big-box">
  47. <view class="button-big-box" @click="goPage('riskEarlyWarning')">
  48. <img class="left-img" src="@/pages/images/newImage/icon_wd_fxyj@1x.png">
  49. <view class="left-text-p">风险预警</view>
  50. <view class="right-text-p"></view>
  51. <img class="right-img" src="@/pages/images/newImage/icon_wd_gd@1x.png">
  52. </view>
  53. <view class="button-big-box" @click="goPage('entryAndExitRecord')">
  54. <img class="left-img" src="@/pages/images/newImage/icon_wd_jcjl.png">
  55. <view class="left-text-p">进出记录</view>
  56. <view class="right-text-p"></view>
  57. <img class="right-img" src="@/pages/images/newImage/icon_wd_gd@1x.png">
  58. </view>
  59. </view>
  60. <view class="button-max-big-box">
  61. <view class="button-big-box" @click="goPage('accessControlAuthorization')">
  62. <img class="left-img" src="@/pages/images/newImage/icon_wd_mjsq@1x.png">
  63. <view class="left-text-p">门禁授权</view>
  64. <view class="right-text-p"></view>
  65. <img class="right-img" src="@/pages/images/newImage/icon_wd_gd@1x.png">
  66. </view>
  67. </view>
  68. <view class="button-max-big-box">
  69. <view class="button-big-box" @click="goPage('identityAuthentication')">
  70. <img class="left-img" src="@/pages/images/newImage/icon_wd_sfyz@1x.png">
  71. <view class="left-text-p">身份验证</view>
  72. <view class="right-text-p"></view>
  73. <img class="right-img" src="@/pages/images/newImage/icon_wd_gd@1x.png">
  74. </view>
  75. <view class="button-big-box" @click="goPage('electronicSignature')">
  76. <img class="left-img" src="@/pages/images/newImage/icon_wd_dzqm@1x.png">
  77. <view class="left-text-p">电子签名</view>
  78. <view class="right-text-p" :class="isUpload?'color-D':''" >{{!isUpload?'未上传':'已上传'}}</view>
  79. <img class="right-img" src="@/pages/images/newImage/icon_wd_gd@1x.png">
  80. </view>
  81. </view>
  82. <view class="out-button" @click="clickOut">退出登录</view>
  83. <tab-bar></tab-bar>
  84. </view>
  85. </template>
  86. <script>
  87. import {
  88. config
  89. } from '@/api/request/config.js'
  90. import {
  91. logout,
  92. systemUserProfile,
  93. studentinfoFacemy,
  94. examPointsRecordGetMyPointsLogInfo,
  95. } from '@/pages/api/index.js'
  96. import {
  97. querySignature,
  98. } from '@/pages_basics/api/index.js'
  99. import {
  100. pageRestrictVerify
  101. } from '@/utils/index'
  102. import {
  103. tabBar
  104. } from '@/pages/component/tabBar.vue'
  105. export default {
  106. name: "teacherMine",
  107. components: {
  108. tabBar,
  109. },
  110. data() {
  111. return {
  112. userData: {},
  113. bonusPoints: null,
  114. creditScore: null,
  115. ifFaceFeature: false,
  116. isUpload: false,
  117. signatureUrl: '',
  118. }
  119. },
  120. created() {
  121. },
  122. mounted() {
  123. this.systemUserProfile();
  124. this.studentinfoFacemy();
  125. this.querySignature();
  126. this.examPointsRecordGetMyPointsLogInfo();
  127. },
  128. methods: {
  129. //查询用户电子签名
  130. async querySignature() {
  131. let self = this;
  132. const {
  133. data
  134. } = await querySignature();
  135. if (data.code == 200) {
  136. self.isUpload = data.data.isUpload;
  137. self.signatureUrl = data.data.signature;
  138. }
  139. },
  140. scanCode() {
  141. uni.scanCode({
  142. onlyFromCamera: true,
  143. success: function(res) {
  144. if (res.result.indexOf('mid') != -1 &&
  145. res.result.indexOf('sid') != -1 &&
  146. res.result.indexOf('pid') != -1 &&
  147. res.result.indexOf('pri') != -1) {
  148. uni.navigateTo({
  149. url: '/pages_student/views/integralManage/codeSuccess?q=' +
  150. encodeURIComponent(JSON.stringify(res.result))
  151. });
  152. } else {
  153. uni.showToast({
  154. title: '请扫描正确的二维码',
  155. icon: "none",
  156. mask: true,
  157. duration: 2000
  158. });
  159. }
  160. }
  161. });
  162. },
  163. goPage(type) {
  164. if (!type) {
  165. uni.showToast({
  166. title: '暂未开放',
  167. icon: "none",
  168. mask: true,
  169. duration: 2000
  170. });
  171. return
  172. }
  173. if (!pageRestrictVerify(type)) {
  174. uni.showToast({
  175. title: '没有相关权限,请联系管理员',
  176. icon: "none",
  177. mask: true,
  178. duration: 2000
  179. });
  180. return
  181. }
  182. if (type == 'riskEarlyWarning') {
  183. //风险预警
  184. uni.navigateTo({
  185. url: "/pages_basics/views/earlyWarningManage/earlyWarningList",
  186. });
  187. } else if (type == 'entryAndExitRecord') {
  188. //进出记录
  189. uni.navigateTo({
  190. url: "/pages_basics/views/record/index",
  191. });
  192. } else if (type == 'accessControlAuthorization') {
  193. //门禁授权
  194. uni.navigateTo({
  195. url: "/pages_manage/views/accessControl/empowerOpen",
  196. });
  197. } else if (type == 'identityAuthentication') {
  198. //身份验证
  199. uni.navigateTo({
  200. url: "/pages_basics/views/faceImage",
  201. });
  202. } else if (type == 'electronicSignature') {
  203. //电子签名
  204. uni.navigateTo({
  205. url: "/pages_basics/views/signature/signature?item="+this.signatureUrl,//电子签名
  206. });
  207. }
  208. },
  209. //获取个人信息
  210. async systemUserProfile() {
  211. const {
  212. data
  213. } = await systemUserProfile();
  214. if (data.code == 200) {
  215. this.$set(this, 'userData', data.data)
  216. uni.setStorageSync('faceImg', data.data.faceImg);
  217. }
  218. },
  219. //查询学生-信用分/奖励分
  220. async examPointsRecordGetMyPointsLogInfo() {
  221. const {
  222. data
  223. } = await examPointsRecordGetMyPointsLogInfo();
  224. if (data.code == 200) {
  225. this.bonusPoints = data.data.bonusPoints;
  226. this.creditScore = data.data.creditScore;
  227. }
  228. },
  229. //获取当前身份人脸验证状态与学生卡上传状态
  230. async studentinfoFacemy() {
  231. let obj = {
  232. studentsId: uni.getStorageSync('userId')
  233. }
  234. const {
  235. data
  236. } = await studentinfoFacemy(obj)
  237. if (data.code == 200) {
  238. this.certification = data.data;
  239. this.ifFaceFeature = data.data.ifFaceFeature;
  240. }
  241. },
  242. //退出按钮
  243. clickOut() {
  244. let self = this;
  245. uni.showModal({
  246. // title: '确认要退出吗?',
  247. content: '确认要退出吗',
  248. cancelColor: "#999",
  249. confirmColor: "#0183FA",
  250. success: function(res) {
  251. if (res.confirm) {
  252. self.logout();
  253. } else if (res.cancel) {}
  254. }
  255. });
  256. },
  257. //退出登录
  258. async logout() {
  259. let self = this;
  260. const {
  261. data
  262. } = await logout();
  263. if (data.code == 200) {
  264. uni.removeStorageSync('token');
  265. uni.removeStorageSync('userId');
  266. uni.removeStorageSync('userType');
  267. uni.redirectTo({
  268. url: '/pages/views/login/login',
  269. });
  270. }
  271. },
  272. // 头像上传
  273. selectImage() {
  274. let self = this;
  275. wx.chooseImage({
  276. count: 1,
  277. sizeType: ["original", "compressed"],
  278. sourceType: ["album", "camera"],
  279. success: function(res) {
  280. let tempFilePaths = res.tempFilePaths[0];
  281. self.uploadImg(tempFilePaths);
  282. }
  283. });
  284. },
  285. async uploadImg(tempFilePaths) {
  286. var self = this;
  287. uni.showLoading({
  288. title: '上传中',
  289. mask: true
  290. });
  291. uni.uploadFile({
  292. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  293. header: {
  294. 'Authorization': uni.getStorageSync('token')
  295. },
  296. filePath: tempFilePaths,
  297. name: 'file',
  298. formData: {
  299. 'user': 'test'
  300. },
  301. success: (uploadFileRes) => {
  302. let res = JSON.parse(uploadFileRes.data);
  303. if (res.code == 200) {
  304. uni.navigateTo({
  305. url: '/pages_basics/views/avatar?src=' + config.base_url + res.data
  306. .url,
  307. });
  308. } else {
  309. uni.showToast({
  310. title: res.msg,
  311. icon: "none",
  312. mask: true,
  313. duration: 2000
  314. });
  315. }
  316. },
  317. fail: err => {},
  318. complete: () => {
  319. uni.hideLoading()
  320. }
  321. });
  322. },
  323. }
  324. }
  325. </script>
  326. <style lang="stylus" scoped>
  327. .teacherMine {
  328. flex: 1;
  329. display: flex;
  330. flex-direction: column;
  331. overflow: hidden;
  332. .back-img-box {
  333. z-index: 0;
  334. position: absolute;
  335. top: 0;
  336. left: 0;
  337. width: 750rpx;
  338. height: 291rpx;
  339. background: linear-gradient(180deg, rgba(1, 131, 250, 1) 0%, rgba(255, 255, 255, 0) 100%);
  340. }
  341. .user-info-box {
  342. z-index: 10;
  343. margin: 39rpx 24rpx 0;
  344. display: flex;
  345. .left-img-box {
  346. width: 132rpx;
  347. height: 132rpx;
  348. position: relative;
  349. margin-right: 22rpx;
  350. .avatar-img {
  351. position: absolute;
  352. top: 6rpx;
  353. left: 6rpx;
  354. width: 116rpx;
  355. height: 116rpx;
  356. border-radius: 50%;
  357. border: 2rpx solid #fff;
  358. }
  359. .edit-img {
  360. z-index: 5;
  361. position: absolute;
  362. right: 0;
  363. bottom: 6rpx;
  364. width: 40rpx;
  365. height: 40rpx;
  366. }
  367. }
  368. .right-name-box {
  369. padding-top: 6rpx;
  370. .right-name-top-box {
  371. display: flex;
  372. view:nth-child(1) {
  373. height: 68rpx;
  374. line-height: 62rpx;
  375. font-size: 32rpx;
  376. color: #fff;
  377. }
  378. view:nth-child(2) {
  379. margin-top: 14rpx;
  380. margin-left: 30rpx;
  381. width: 120rpx;
  382. height: 40rpx;
  383. line-height: 40rpx;
  384. background: #FF8C00;
  385. border-radius: 50rpx;
  386. font-size: 24rpx;
  387. color: #fff;
  388. text-align: center;
  389. }
  390. }
  391. .right-name-bottom-box {
  392. height: 50rpx;
  393. line-height: 50rpx;
  394. font-size: 28rpx;
  395. color: #fff;
  396. }
  397. }
  398. }
  399. .points-max-box {
  400. z-index: 10;
  401. width: 690rpx;
  402. height: 160rpx;
  403. background: #FFFFFF;
  404. border-radius: 20rpx;
  405. margin: 38rpx 30rpx 0;
  406. display: flex;
  407. .points-big-box {
  408. flex: 1;
  409. .num-p {
  410. margin: 39rpx 0 19rpx 0;
  411. text-align: center;
  412. font-size: 28rpx;
  413. line-height: 39rpx;
  414. }
  415. .img-box {
  416. display: flex;
  417. img {
  418. width: 30rpx;
  419. height: 30rpx;
  420. display: block;
  421. margin: 0 20rpx 0 42rpx;
  422. }
  423. view {
  424. color: #333333;
  425. line-height: 30rpx;
  426. font-size: 28rpx;
  427. }
  428. }
  429. .colorA {
  430. color: #0183FA;
  431. }
  432. .colorB {
  433. color: #26C736;
  434. }
  435. .colorC {
  436. color: #333333;
  437. }
  438. }
  439. .border-null-p {
  440. width: 1rpx;
  441. height: 40rpx;
  442. margin: 60rpx 0 0;
  443. background-color: #e0e0e0;
  444. }
  445. }
  446. .button-max-big-box {
  447. background-color: #fff;
  448. border-radius: 20rpx;
  449. margin: 20rpx 30rpx 0;
  450. .button-big-box:nth-child(1) {
  451. border-top: none;
  452. }
  453. .button-big-box {
  454. border-top: 1px solid #E0E0E0;
  455. display: flex;
  456. padding: 0 30rpx 0 26rpx;
  457. .left-img {
  458. display: block;
  459. width: 36rpx;
  460. height: 36rpx;
  461. margin-top: 25rpx;
  462. margin-right: 21rpx;
  463. }
  464. .left-text-p {
  465. flex: 1;
  466. front-size: 30rpx;
  467. line-height: 40rpx;
  468. margin: 20rpx 0;
  469. }
  470. .right-text-p {
  471. front-size: 30rpx;
  472. line-height: 40rpx;
  473. margin: 20rpx 0;
  474. }
  475. .right-img {
  476. display: block;
  477. width: 30rpx;
  478. height: 30rpx;
  479. margin-top: 28rpx;
  480. }
  481. }
  482. .color-D{
  483. color:#0183FA!important;
  484. }
  485. }
  486. .out-button {
  487. position absolute;
  488. bottom: 140rpx;
  489. left: 75rpx;
  490. width: 600rpx;
  491. height: 80rpx;
  492. line-height: 80rpx;
  493. border-radius: 100rpx;
  494. text-align center;
  495. background #0183FA;
  496. color: #ffffff;
  497. font-size: 30rpx;
  498. margin: 0 auto;
  499. }
  500. }
  501. </style>