123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <template>
- <!-- pages/me.wxml -->
- <view class="uni-container">
- <view class="uni-header-logo">
- <img class="uni-header-image" :src="initInfo.headImg == null || initInfo.headImg == '' ? 'http://116.142.80.12:9000/10_03.png' : initInfo.headImg" />
- <span>{{initInfo.name == null || initInfo.name == '' ? initInfo.wechatName : initInfo.name}}</span>
- <text>{{initInfo.scoreNum}}</text>
- </view>
- <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
- <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="goDetailPage(index, item.id)">
- <text class="uni-panel-text">{{item.name}}</text>
- <text class="uni-panel-icon uni-icon" :class="item.open ? 'uni-panel-icon-on' : ''">{{item.pages ? '' : ''}}</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {getScore, getUserInfo} from '@/api/me/me.js'
- // pages/me.js
- export default {
- data() {
- return {
- initInfo:{
- userId: null,
- scoreNum: 0,
- wechatName: "微信用户",
- name: null,
- headImg: null,
- },
- list: [
- {
- id: 'me/meOperate',//id是文件路径
- name: '我的积分流水',
- open: false,
- pages: ['meOperate']
- },
- {
- id: 'wenba/wenba',
- name: '我的问答',
- open: false,
- pages: ['meOperate']
- }
- ]
- };
- },
- /**
- * 生命周期函数--监听页面加载
- */ onLoad(options) {},
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- this.userId = getApp().globalData.userId
- this.getUserInfoByUserId(this.userId)
- this.getScoreForMe(this.userId)
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {},
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {},
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {},
- methods: {
- goDetailPage(panel, e) {
- if (typeof e === 'string') {
- const url = '/pages/' + e
- if (this.hasLeftWin) {
- uni.reLaunch({
- url: url
- })
- } else {
- uni.navigateTo({
- url: url
- })
- }
- } else {
- if (this.hasLeftWin) {
- uni.reLaunch({
- url: e.url
- })
- } else {
- uni.navigateTo({
- url: e.url
- })
- }
- }
- },
- //获取用户信息:用户名称:头像
- getUserInfoByUserId(userId){
- getUserInfo(userId).then(res =>{
- this.initInfo.wechatName = res.data.wechatName;
- this.initInfo.name = res.data.name;
- this.initInfo.wechatName = res.data.wechatName;
- })
- },
- //获取当前积分
- getScoreForMe(userId){
- getScore(this.userId).then(res =>{
- this.initInfo.socreNum = res.data.scoreNum
- })
- }
- }
- };
- </script>
- <style>
- @import './me.css';
- </style>
|