me.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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',//id是文件路径
  33. name: '我的积分流水',
  34. open: false,
  35. },
  36. {
  37. id: 'wenba/wenba',
  38. name: '我的问答',
  39. open: false,
  40. },
  41. {
  42. id: 'me/nameAuthentication',
  43. name: '实名认证',
  44. open: false,
  45. },
  46. {
  47. id: 'me/officialAuthentication',
  48. name: '官方认证',
  49. open: false,
  50. },
  51. {
  52. id: 'matters/matters',
  53. name: '我的事项',
  54. open: false,
  55. }
  56. ]
  57. };
  58. },
  59. /**
  60. * 生命周期函数--监听页面加载
  61. */ onLoad(options) {},
  62. /**
  63. * 生命周期函数--监听页面初次渲染完成
  64. */
  65. onReady() {
  66. this.userId = getApp().globalData.userId
  67. this.getUserInfoByUserId(this.userId)
  68. this.getScoreForMe(this.userId)
  69. },
  70. /**
  71. * 生命周期函数--监听页面显示
  72. */
  73. onShow() {},
  74. /**
  75. * 生命周期函数--监听页面隐藏
  76. */
  77. onHide() {},
  78. /**
  79. * 生命周期函数--监听页面卸载
  80. */
  81. onUnload() {},
  82. /**
  83. * 页面相关事件处理函数--监听用户下拉动作
  84. */
  85. onPullDownRefresh() {},
  86. /**
  87. * 页面上拉触底事件的处理函数
  88. */
  89. onReachBottom() {},
  90. /**
  91. * 用户点击右上角分享
  92. */
  93. onShareAppMessage() {},
  94. methods: {
  95. goDetailPage(e) {
  96. const url = '/pages/' + e
  97. uni.navigateTo({
  98. url: url
  99. })
  100. },
  101. //获取用户信息:用户名称:头像
  102. getUserInfoByUserId(userId){
  103. getUserInfo(userId).then(res =>{
  104. this.initInfo.wechatName = res.data.wechatName;
  105. this.initInfo.name = res.data.name;
  106. this.initInfo.wechatName = res.data.wechatName;
  107. })
  108. },
  109. //获取当前积分
  110. getScoreForMe(userId){
  111. getScore(this.userId).then(res =>{
  112. this.initInfo.scoreNum = res.data.scoreNum
  113. })
  114. }
  115. }
  116. };
  117. </script>
  118. <style>
  119. @import './me.css';
  120. </style>