user.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <view class="center">
  3. <view class="top">
  4. <image class="bg" src="../../static/img/userBg.png"></image>
  5. <view class="title">我的</view>
  6. <view class="user flex">
  7. <view class="toux"><image :src="userInfo.avatar || '/static/error/missing-face.png'" mode=""></image></view>
  8. <view class="font">
  9. <view class="name">{{ userInfo.real_name || '游客' }}</view>
  10. <view class="banzhuren">顾问:{{ guwen || 'null' }}</view>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="navBar ">
  15. <image class="navBg" src="../../static/img/user.png"></image>
  16. <view class="navBox flex">
  17. <view class="main">
  18. <view class="font">已上课时</view>
  19. <view class="num">{{ achieve || 0 }}</view>
  20. </view>
  21. <view class="xian"></view>
  22. <view class="main">
  23. <view class="font">总课时</view>
  24. <view class="num">{{ all || 0 }}</view>
  25. </view>
  26. <view class="xian"></view>
  27. <view class="main">
  28. <view class="font">赠送课时</view>
  29. <view class="num">{{ gift || 0 }}</view>
  30. </view>
  31. <view class="xian"></view>
  32. <view class="main">
  33. <view class="font">请假课时</view>
  34. <view class="num">{{ leave || 0 }}</view>
  35. </view>
  36. </view>
  37. <!-- <view class="left" @click="nav('/pages/leave/leaveClass')">
  38. <image src="../../static/img/userLeft.png"></image>
  39. <view class="centent">
  40. <view class="title">待上课程</view>
  41. <view class="text">待完成数</view>
  42. <view class="number">{{dai}}<text>个</text></view>
  43. </view>
  44. </view>
  45. <view class="right" @click="nav('/pages/course/courseWan')">
  46. <image src="../../static/img/userRight.png"></image>
  47. <view class="centent">
  48. <view class="title">完成课程</view>
  49. <view class="text">总完成数</view>
  50. <view class="number">{{wan}}<text>个</text></view>
  51. </view>
  52. </view> -->
  53. </view>
  54. <view class="system">
  55. <view class="item flex" @click="nav('/pages/user/userInfo')">
  56. <image class="img" src="../../static/img/aboutMy.png"></image>
  57. <view class="item-text">我的资料</view>
  58. <image class="return" src="../../static/img/return.png"></image>
  59. </view>
  60. <view class="item flex" @click="nav('/pages/user/about')">
  61. <image class="img" src="../../static/img/userAbout.png"></image>
  62. <view class="item-text">关于我们</view>
  63. <image class="return" src="../../static/img/return.png"></image>
  64. </view>
  65. <view class="item flex" @click="nav('/pages/public/set')">
  66. <image class="img" src="../../static/img/aboutSet.png"></image>
  67. <view class="item-text">设置</view>
  68. <image class="return" src="../../static/img/return.png"></image>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import { getCourse } from '@/api/course.js';
  75. import { mapState, mapMutations } from 'vuex';
  76. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  77. import { getUserInfo, my } from '@/api/user.js';
  78. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  79. export default {
  80. components: {
  81. uniLoadMore
  82. },
  83. computed: {
  84. ...mapState(['hasLogin', 'userInfo', 'baseURL', 'urlFile'])
  85. },
  86. data() {
  87. return {
  88. all: '', //总课时
  89. achieve: '', //完成课时
  90. leave: '', //请假课时
  91. gift: '', //赠送课时
  92. guwen: ''
  93. };
  94. },
  95. onShow() {
  96. console.log(this.hasLogin);
  97. // 判断是否已经登录
  98. if (this.hasLogin) {
  99. console.log(this.userInfo);
  100. this.loadBaseData();
  101. } else {
  102. uni.showModal({
  103. title: '登录',
  104. content: '您未登录,是否马上登陆?',
  105. success: e => {
  106. console.log(e);
  107. if (e.confirm) {
  108. console.log('1111');
  109. interceptor();
  110. }
  111. },
  112. fail: e => {
  113. console.log(e);
  114. }
  115. });
  116. return;
  117. }
  118. },
  119. methods: {
  120. ...mapMutations(['setUserInfo']),
  121. loadBaseData() {
  122. getUserInfo({})
  123. .then(({ data }) => {
  124. this.setUserInfo(data);
  125. })
  126. .catch(e => {
  127. console.log(e);
  128. });
  129. my({}).then(({ data }) => {
  130. console.log(data,"123456");
  131. this.guwen = data.adviser_name;
  132. this.all = data.sum_class;
  133. this.leave = data.leave;
  134. this.gift = data.give_class;
  135. this.achieve = data.in_class;
  136. });
  137. getCourse({})
  138. .then(e => {
  139. this.dai = e.data.count;
  140. })
  141. .catch(e => {
  142. console.log(e);
  143. });
  144. },
  145. navT() {
  146. if (!this.hasLogin) {
  147. uni.showModal({
  148. title: '登录',
  149. content: '您未登录,是否马上登陆?',
  150. success: e => {
  151. console.log(e);
  152. if (e.confirm) {
  153. console.log('1111');
  154. interceptor();
  155. }
  156. },
  157. fail: e => {
  158. console.log(e);
  159. }
  160. });
  161. return;
  162. } else {
  163. uni.switchTab({
  164. url: '/pages/index/index'
  165. });
  166. }
  167. },
  168. nav(url) {
  169. if (!this.hasLogin) {
  170. uni.showModal({
  171. title: '登录',
  172. content: '您未登录,是否马上登陆?',
  173. success: e => {
  174. if (e.confirm) {
  175. interceptor();
  176. }
  177. },
  178. fail: e => {
  179. console.log(e);
  180. }
  181. });
  182. return;
  183. } else {
  184. uni.navigateTo({
  185. url: url
  186. });
  187. }
  188. }
  189. }
  190. };
  191. </script>
  192. <style lang="scss">
  193. page,
  194. .center {
  195. width: 100%;
  196. height: 100%;
  197. background-color: #f8f8f8;
  198. }
  199. .top {
  200. position: relative;
  201. width: 100%;
  202. height: 474rpx;
  203. .bg {
  204. position: absolute;
  205. top: 0;
  206. left: 0;
  207. width: 100%;
  208. height: 100%;
  209. }
  210. .title {
  211. padding-left: 38rpx;
  212. padding-top: 20rpx;
  213. font-size: 48rpx;
  214. font-weight: 500;
  215. color: #111111;
  216. }
  217. .user {
  218. justify-content: flex-start;
  219. margin-top: 35rpx;
  220. padding-left: 36rpx;
  221. .toux {
  222. width: 136rpx;
  223. height: 136rpx;
  224. background: #ffffff;
  225. border-radius: 50%;
  226. image {
  227. width: 136rpx;
  228. height: 136rpx;
  229. border-radius: 50%;
  230. }
  231. }
  232. .font {
  233. height: 136rpx;
  234. padding-top: 14rpx;
  235. padding-left: 30rpx;
  236. .name {
  237. font-size: 36rpx;
  238. font-weight: bold;
  239. color: #000000;
  240. }
  241. .banzhuren {
  242. margin-top: 14rpx;
  243. font-size: 26rpx;
  244. font-weight: 500;
  245. color: #8e8e8e;
  246. }
  247. }
  248. }
  249. }
  250. .navBar {
  251. margin-top: -100rpx;
  252. padding: 18rpx;
  253. width: 100%;
  254. height: 250rpx;
  255. position: relative;
  256. .navBg {
  257. position: absolute;
  258. top: 0;
  259. left: 0;
  260. width: 100%;
  261. height: 100%;
  262. }
  263. .navBox {
  264. position: relative;
  265. z-index: 3;
  266. width: 100%;
  267. justify-content: flex-start;
  268. .main {
  269. flex: 1;
  270. padding: 50rpx 30rpx;
  271. display: flex;
  272. flex-direction: column;
  273. .font {
  274. margin: 0 auto;
  275. font-size: 26rpx;
  276. font-family: PingFang SC;
  277. font-weight: 500;
  278. color: #ffffff;
  279. }
  280. .num {
  281. margin: 0 auto;
  282. margin-top: 24rpx;
  283. font-size: 40rpx;
  284. font-family: PingFang SC;
  285. font-weight: bold;
  286. color: #ffffff;
  287. text-shadow: 0px 2rpx 24rpx rgba(28, 199, 199, 0.4);
  288. }
  289. }
  290. .xian {
  291. width: 2rpx;
  292. height: 80rpx;
  293. background: #ffffff;
  294. // opacity: 0.12;
  295. }
  296. }
  297. // .left {
  298. // position: relative;
  299. // width: 50%;
  300. // height: 250rpx;
  301. // image {
  302. // height: 100%;
  303. // width: 100%;
  304. // }
  305. // }
  306. // .right {
  307. // position: relative;
  308. // width: 50%;
  309. // height: 250rpx;
  310. // image {
  311. // height: 100%;
  312. // width: 100%;
  313. // }
  314. // }
  315. }
  316. .centent {
  317. position: absolute;
  318. top: 0;
  319. left: 0;
  320. padding-left: 56rpx;
  321. padding-top: 52rpx;
  322. .title {
  323. font-size: 32rpx;
  324. font-weight: bold;
  325. color: #333333;
  326. }
  327. .text {
  328. margin-top: 10rpx;
  329. font-size: 24rpx;
  330. font-weight: bold;
  331. color: #8e8e8e;
  332. }
  333. .number {
  334. font-size: 44rpx;
  335. font-weight: bold;
  336. color: #1cc7c7;
  337. text-shadow: 0px 2px 24px rgba(28, 199, 199, 0.4);
  338. margin-top: 20rpx;
  339. text {
  340. font-size: 28rpx;
  341. }
  342. }
  343. }
  344. .system {
  345. width: 90%;
  346. margin: 0 auto;
  347. padding-top: 10rpx;
  348. background: #ffffff;
  349. box-shadow: 0px 2rpx 24rpx 0rpx rgba(0, 0, 0, 0.06);
  350. border-radius: 20rpx;
  351. .item {
  352. height: 112rpx;
  353. padding: 44rpx 36rpx 36rpx 40rpx;
  354. .img {
  355. height: 36rpx;
  356. width: 36rpx;
  357. }
  358. .item-text {
  359. width: 85%;
  360. text-align: left;
  361. font-size: 32rpx;
  362. font-weight: 500;
  363. color: #555555;
  364. line-height: 36rpx;
  365. }
  366. .return {
  367. width: 14rpx;
  368. height: 26rpx;
  369. }
  370. }
  371. }
  372. </style>