mine.vue 14 KB

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