mine.vue 13 KB

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