me.vue 2.7 KB

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