user.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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" mode=""></image></view>
  8. <view class="font">
  9. <view class="name">{{ userInfo.nickname }}</view>
  10. <view class="banzhuren">顾问:李丹 12012502360</view>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="navBar flex">
  15. <view class="left" @click="nav('/pages/course/course')">
  16. <image src="../../static/img/userLeft.png"></image>
  17. <view class="centent">
  18. <view class="title">待上课程</view>
  19. <view class="text">待完成数</view>
  20. <view class="number">{{dai}}<text>个</text></view>
  21. </view>
  22. </view>
  23. <view class="right" @click="nav('/pages/course/courseWan')">
  24. <image src="../../static/img/userRight.png"></image>
  25. <view class="centent">
  26. <view class="title">完成课程</view>
  27. <view class="text">总完成数</view>
  28. <view class="number">{{wan}}<text>个</text></view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="system">
  33. <view class="item flex" @click="nav('/pages/user/userInfo')">
  34. <image class="img" src="../../static/img/aboutMy.png"></image>
  35. <view class="item-text">我的资料</view>
  36. <image class="return" src="../../static/img/return.png" ></image>
  37. </view>
  38. <view class="item flex">
  39. <image class="img" src="../../static/img/userAbout.png"></image>
  40. <view class="item-text">关于我们</view>
  41. <image class="return" src="../../static/img/return.png" ></image>
  42. </view>
  43. <view class="item flex">
  44. <image class="img" src="../../static/img/aboutSet.png"></image>
  45. <view class="item-text">设置</view>
  46. <image class="return" src="../../static/img/return.png" ></image>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import { getCourse } from '@/api/course.js'
  53. import { mapState, mapMutations } from 'vuex';
  54. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  55. import { getUserInfo,} from '@/api/user.js';
  56. export default {
  57. computed: {
  58. ...mapState(['hasLogin', 'userInfo', 'baseURL', 'urlFile'])
  59. },
  60. data() {
  61. return {
  62. dai: '0',//待上课程
  63. wan: '0',//完成课程
  64. }
  65. },
  66. onShow() {
  67. // 判断是否已经登录
  68. if (this.hasLogin) {
  69. console.log(this.userInfo)
  70. this.loadBaseData();
  71. }else{
  72. uni.showModal({
  73. title: '登录',
  74. content: '您未登录,是否马上登陆?',
  75. success: e => {
  76. console.log(e)
  77. if (e.confirm) {
  78. console.log("1111")
  79. interceptor();
  80. }
  81. },
  82. fail: e => {
  83. console.log(e);
  84. }
  85. });
  86. return;
  87. }
  88. },
  89. methods: {
  90. ...mapMutations( ['setUserInfo', 'setOrderInfo']),
  91. loadBaseData() {
  92. getUserInfo({})
  93. .then(({ data }) => {
  94. if (data.store_switch == '1') {
  95. this.showBox = true;
  96. }
  97. this.setUserInfo(data);
  98. })
  99. .catch(e => {
  100. console.log(e);
  101. });
  102. getCourse({})
  103. .then(e => {
  104. this.dai = e.data.count;
  105. })
  106. .catch(e => {
  107. console.log(e);
  108. });
  109. },
  110. navT(){
  111. if (!this.hasLogin) {
  112. uni.showModal({
  113. title: '登录',
  114. content: '您未登录,是否马上登陆?',
  115. success: e => {
  116. console.log(e)
  117. if (e.confirm) {
  118. console.log("1111")
  119. interceptor();
  120. }
  121. },
  122. fail: e => {
  123. console.log(e);
  124. }
  125. });
  126. return;
  127. }else{
  128. uni.switchTab({
  129. url: '/pages/index/index'
  130. })
  131. }
  132. },
  133. nav(url){
  134. if (!this.hasLogin) {
  135. uni.showModal({
  136. title: '登录',
  137. content: '您未登录,是否马上登陆?',
  138. success: e => {
  139. if (e.confirm) {
  140. interceptor();
  141. }
  142. },
  143. fail: e => {
  144. console.log(e);
  145. }
  146. });
  147. return;
  148. }else{
  149. uni.navigateTo({
  150. url: url
  151. })
  152. }
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss">
  158. page,
  159. .center {
  160. width: 100%;
  161. height: 100%;
  162. background-color: #f8f8f8;
  163. }
  164. .top{
  165. position: relative;
  166. width: 100%;
  167. height: 474rpx;
  168. .bg {
  169. position: absolute;
  170. top: 0;
  171. left: 0;
  172. width: 100%;
  173. height: 100%;
  174. }
  175. .title {
  176. padding-left: 38rpx;
  177. padding-top: 20rpx;
  178. font-size: 48rpx;
  179. font-weight: 500;
  180. color: #111111;
  181. }
  182. .user {
  183. justify-content: flex-start;
  184. margin-top: 35rpx;
  185. padding-left: 36rpx;
  186. .toux {
  187. width: 136rpx;
  188. height: 136rpx;
  189. background: #FFFFFF;
  190. border-radius: 50%;
  191. image {
  192. width: 136rpx;
  193. height: 136rpx;
  194. border-radius: 50%;
  195. }
  196. }
  197. .font {
  198. height: 136rpx;
  199. padding-top: 14rpx;
  200. padding-left: 30rpx;
  201. .name {
  202. font-size: 36rpx;
  203. font-weight: bold;
  204. color: #000000;
  205. }
  206. .banzhuren {
  207. margin-top: 14rpx;
  208. font-size: 26rpx;
  209. font-weight: 500;
  210. color: #8E8E8E;
  211. }
  212. }
  213. }
  214. }
  215. .navBar{
  216. margin-top: -100rpx;
  217. padding: 18rpx;
  218. width: 100%;
  219. .left {
  220. position: relative;
  221. width: 50%;
  222. height: 250rpx;
  223. image {
  224. height: 100%;
  225. width: 100%;
  226. }
  227. }
  228. .right {
  229. position: relative;
  230. width: 50%;
  231. height: 250rpx;
  232. image {
  233. height: 100%;
  234. width: 100%;
  235. }
  236. }
  237. }
  238. .centent {
  239. position: absolute;
  240. top: 0;
  241. left: 0;
  242. padding-left: 56rpx;
  243. padding-top: 52rpx;
  244. .title {
  245. font-size: 32rpx;
  246. font-weight: bold;
  247. color: #333333;
  248. }
  249. .text {
  250. margin-top: 10rpx;
  251. font-size: 24rpx;
  252. font-weight: bold;
  253. color: #8E8E8E;
  254. }
  255. .number {
  256. font-size: 44rpx;
  257. font-weight: bold;
  258. color: #1CC7C7;
  259. text-shadow: 0px 2px 24px rgba(28, 199, 199, 0.4);
  260. margin-top: 20rpx;
  261. text {
  262. font-size: 28rpx;
  263. }
  264. }
  265. }
  266. .system {
  267. width: 90%;
  268. margin: 0 auto;
  269. padding-top: 10rpx;
  270. background: #FFFFFF;
  271. box-shadow: 0px 2rpx 24rpx 0rpx rgba(0, 0, 0, 0.06);
  272. border-radius: 20rpx;
  273. .item {
  274. height: 112rpx;
  275. padding: 44rpx 36rpx 36rpx 40rpx;
  276. .img {
  277. height: 36rpx;
  278. width: 36rpx;
  279. }
  280. .item-text {
  281. width: 85%;
  282. text-align: left;
  283. font-size: 32rpx;
  284. font-weight: 500;
  285. color: #555555;
  286. line-height: 36rpx;
  287. }
  288. .return {
  289. width: 14rpx;
  290. height: 26rpx;
  291. }
  292. }
  293. }
  294. </style>