me.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <!-- pages/me.wxml -->
  3. <view class="uni-container">
  4. <view class="uni-header-logo">
  5. <img class="uni-header-image" :src="initInfo.headImg == null || initInfo.headImg == '' ? 'http://116.142.80.12:9000/10_03.png' : initInfo.headImg" />
  6. <span>{{initInfo.name == null || initInfo.name == '' ? initInfo.wechatName : initInfo.name}}</span>
  7. <text>{{initInfo.scoreNum}}</text>
  8. </view>
  9. <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
  10. <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="goDetailPage(item.id)">
  11. <text class="uni-panel-text">{{item.name}}</text>
  12. <text class="uni-panel-icon uni-icon" :class="item.open ? 'uni-panel-icon-on' : ''">{{item.pages ? '&#xe581;' : '&#xe470;'}}</text>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import {getScore, getUserInfo} from '@/api/me/me.js'
  19. // pages/me.js
  20. export default {
  21. data() {
  22. return {
  23. initInfo:{
  24. userId: null,
  25. scoreNum: 0,
  26. wechatName: "微信用户",
  27. name: null,
  28. headImg: null,
  29. },
  30. list: [
  31. {
  32. id: 'me/meOperate/meOperate',//id是文件路径
  33. name: '我的积分流水',
  34. open: false,
  35. },
  36. {
  37. id: 'demo/wenba/wenba',
  38. name: '我的问答',
  39. open: false,
  40. },
  41. {
  42. id: 'me/nameAuthentication/nameAuthentication',
  43. name: '实名认证',
  44. open: false,
  45. },
  46. {
  47. id: 'me/officialAuthentication/officialAuthentication',
  48. name: '官方认证',
  49. open: false,
  50. },
  51. {
  52. id: 'matters/matters',
  53. name: '我的事项',
  54. open: false,
  55. },
  56. {
  57. id: 'me/myPayKnow/myPayKnow',
  58. name: '我的付费知识',
  59. open: false,
  60. }
  61. ]
  62. };
  63. },
  64. /**
  65. * 生命周期函数--监听页面加载
  66. */ onLoad(options) {},
  67. /**
  68. * 生命周期函数--监听页面初次渲染完成
  69. */
  70. onReady() {
  71. this.userId = getApp().globalData.userId
  72. this.getUserInfoByUserId(this.userId)
  73. this.getScoreForMe(this.userId)
  74. },
  75. /**
  76. * 生命周期函数--监听页面显示
  77. */
  78. onShow() {},
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide() {},
  83. /**
  84. * 生命周期函数--监听页面卸载
  85. */
  86. onUnload() {},
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh() {},
  91. /**
  92. * 页面上拉触底事件的处理函数
  93. */
  94. onReachBottom() {},
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage() {},
  99. methods: {
  100. goDetailPage(e) {
  101. const url = '/pages/' + e
  102. uni.navigateTo({
  103. url: url
  104. })
  105. },
  106. //获取用户信息:用户名称:头像
  107. getUserInfoByUserId(userId){
  108. getUserInfo(userId).then(res =>{
  109. this.initInfo.wechatName = res.data.wechatName;
  110. this.initInfo.name = res.data.name;
  111. this.initInfo.headImg = res.data.headImg;
  112. })
  113. },
  114. //获取当前积分
  115. getScoreForMe(userId){
  116. getScore(this.userId).then(res =>{
  117. this.initInfo.scoreNum = res.data.scoreNum
  118. })
  119. }
  120. }
  121. };
  122. </script>
  123. <style>
  124. @import './me.css';
  125. </style>