me.vue 2.6 KB

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