index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div class="peraonal">
  3. <Header
  4. :headerBg="'#fff'"
  5. :headerBorder="'#5C5C5C'"
  6. :userBg="'rgba(0, 0, 0, 0.24)'"
  7. :type="'black'"
  8. :touxiang="newTouxiang"
  9. />
  10. <div class="main">
  11. <ul class="main-left">
  12. <li v-for="(itemM,indexM) in menuList" :key="indexM" :class="[menuType===itemM.type?'active':'']" @click="handleChangeMenu(itemM.type)">
  13. <svg-icon :icon-class="itemM.icon"></svg-icon>
  14. <span>{{itemM.label}}</span>
  15. </li>
  16. </ul>
  17. <div class="main-right">
  18. <!-- 个人中心 -->
  19. <personal-info v-if="menuType==='user'"></personal-info>
  20. <!-- 收藏夹 -->
  21. <collect v-if="menuType==='like'"></collect>
  22. <!-- 兑换码 -->
  23. <conversion-code v-if="menuType==='duihuanma'"></conversion-code>
  24. <!-- 我的分享 -->
  25. <my-share :data="myShare.data" v-if="menuType==='share'"></my-share>
  26. <!-- 我的订单 -->
  27. <order-list :data="myShare.data" v-if="menuType==='order'"></order-list>
  28. <!-- 个人设置 -->
  29. <setting v-if="menuType==='setting'" @changeTouxiang="changeTouxiang"></setting>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  36. //例如:import 《组件名称》from ‘《组件路径》';
  37. import Header from "../../components/Header.vue";
  38. import PersonalInfo from "./components/PersonalInfo.vue"
  39. import MyShare from "./components/MyShare.vue"
  40. import ConversionCode from "./components/ConversionCode.vue"
  41. import Collect from "./components/Collect.vue"
  42. import OrderList from "./components/OrderList.vue"
  43. import Setting from "./components/Setting.vue"
  44. export default {
  45. //import引入的组件需要注入到对象中才能使用
  46. components: { Header, PersonalInfo, MyShare, ConversionCode, Collect, OrderList, Setting},
  47. props: {},
  48. data() {
  49. //这里存放数据
  50. return {
  51. menuList:[
  52. {
  53. icon: 'read-record',
  54. label: '我的阅读记录',
  55. type: 'user'
  56. },
  57. {
  58. icon: 'like-line',
  59. label: '我的收藏',
  60. type: 'like'
  61. },
  62. {
  63. icon: 'duihuanma',
  64. label: '我的兑换码',
  65. type: 'duihuanma'
  66. },
  67. {
  68. icon: 'share-box-line',
  69. label: '我的分享',
  70. type: 'share'
  71. },
  72. {
  73. icon: 'order-personal',
  74. label: '订单管理',
  75. type: 'order'
  76. },
  77. {
  78. icon: 'setting',
  79. label: '个人设置',
  80. type: 'setting'
  81. }
  82. ],
  83. menuType: this.$route.query.type?decodeURIComponent(this.$route.query.type):'user', // 菜单类型
  84. personalInfo: {
  85. name:'张平方',
  86. school:'北京市第二中学',
  87. class:'3年1班',
  88. avatar: require('../../assets/avatar.png'),
  89. totalArticle: '416', // 共阅读文章
  90. totalTime: '237', // 累计阅读时长
  91. totalWords: '4621', // 共阅读词数
  92. totalLength: '23768' //累计阅读长度
  93. },
  94. myShare:{
  95. data:[
  96. {
  97. number:'461',
  98. title:'Making room for the pet boom',
  99. study:'高一',
  100. source:'第865期',
  101. useTimes:'1',
  102. totalTimes:'3',
  103. deadline:'2021.3.12 15:23',
  104. status:'sharing'
  105. },
  106. {
  107. number:'460',
  108. title:'KEY NOTIONS IN 2023 GOVERNMENT WORK REPORT',
  109. study:'高一',
  110. source:'第865期',
  111. useTimes:'3',
  112. totalTimes:'3',
  113. deadline:'2021.3.12 15:23',
  114. status:'ended'
  115. },
  116. {
  117. number:'459',
  118. title:'每日一练',
  119. study:'高一',
  120. source:'第865期',
  121. useTimes:'2',
  122. totalTimes:'3',
  123. deadline:'2021.3.12 15:23',
  124. status:'sharing'
  125. },
  126. {
  127. number:'458',
  128. title:'JUST ASK 成长不烦恼 ',
  129. study:'高一',
  130. source:'第865期',
  131. useTimes:'0',
  132. totalTimes:'3',
  133. deadline:'2021.3.12 15:23',
  134. status:'sharing'
  135. },
  136. ]
  137. },
  138. newTouxiang: ''
  139. }
  140. },
  141. //计算属性 类似于data概念
  142. computed: {},
  143. //监控data中数据变化
  144. watch: {
  145. '$route': {
  146. handler(val, oldVal) {
  147. const _this = this;
  148. if (val) {
  149. if(this.$route.query.type){
  150. _this.menuType = decodeURIComponent(this.$route.query.type)
  151. }else{
  152. _this.menuType = 'user'
  153. }
  154. }
  155. },
  156. // 深度观察监听
  157. deep: true,
  158. },
  159. },
  160. //方法集合
  161. methods: {
  162. // 切换菜单
  163. handleChangeMenu(value){
  164. this.menuType = value
  165. this.$router.push({
  166. path: '/peraonal',
  167. query: {
  168. headerConfig: this.$route.query.headerConfig,
  169. type:encodeURIComponent(value)
  170. },
  171. });
  172. },
  173. changeTouxiang(img){
  174. this.newTouxiang = img
  175. }
  176. },
  177. //生命周期 - 创建完成(可以访问当前this实例)
  178. created() {
  179. },
  180. //生命周期 - 挂载完成(可以访问DOM元素)
  181. mounted() {
  182. },
  183. //生命周期-创建之前
  184. beforeCreated() { },
  185. //生命周期-挂载之前
  186. beforeMount() { },
  187. //生命周期-更新之前
  188. beforUpdate() { },
  189. //生命周期-更新之后
  190. updated() { },
  191. //生命周期-销毁之前
  192. beforeDestory() { },
  193. //生命周期-销毁完成
  194. destoryed() { },
  195. //如果页面有keep-alive缓存功能,这个函数会触发
  196. activated() { }
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. /* @import url(); 引入css类 */
  201. .peraonal{
  202. min-height: calc(100vh - 64px);
  203. }
  204. .main{
  205. background: #F7F8FA;
  206. height: calc(100vh - 64px);
  207. display: flex;
  208. ul{
  209. margin: 0;
  210. background: #FFFFFF;
  211. padding: 8px;
  212. width: 200px;
  213. list-style: none;
  214. flex-shrink: 0;
  215. li{
  216. margin-bottom: 4px;
  217. padding: 9px 12px;
  218. display: flex;
  219. align-items: center;
  220. border-radius: 2px;
  221. cursor: pointer;
  222. .svg-icon{
  223. width: 14px;
  224. height: 14px;
  225. color: #4E5969;
  226. }
  227. span{
  228. padding-left: 16px;
  229. font-size: 14px;
  230. line-height: 22px;
  231. color: #4E5969;
  232. }
  233. &:hover{
  234. background: #F2F3F5;
  235. }
  236. &.active{
  237. background: #F2F3F5;
  238. .svg-icon,span{
  239. color: #165DFF;
  240. font-weight: 500;
  241. }
  242. }
  243. }
  244. }
  245. &-right{
  246. flex: 1;
  247. margin: 16px;
  248. overflow: auto; // 订单管理的表格
  249. }
  250. }
  251. </style>