import tool from '../../../utils/tool' import scoreApi from "../../../api/scoreApi" import userArticleApi from "../../../api/userArticleApi" Page({ data: { total: [ { value: 0, category: '我的积分', path: '/pages/subpages/scoreLog/scoreLog' }, { value: 0, category: '下载记录', path: '/pages/subpages/downloadLog/downloadLog' }, { value: 0, category: '收藏记录', path: '/pages/subpages/collectionLog/collectionLog' } ], funcList: [ { name:'每日签到', path: '每日签到', icon: 'thumb-circle-o', color: '#04D17A' }, { name:'积分兑换', path: '/pages/subpages/member/member', icon: 'diamond', color: '#F7E031' }, { name:'使用说明', path: '/pages/subpages/instruct/instruct', icon: 'notes', color: '#FC6760' }, { name:'关于我们', path: '/pages/subpages/aboutus/aboutus', icon: 'friends', color: '#6650F6' } ], userInfo: {}, memberLevel: null, paymentShow: false, paymentCode: null }, leaveFor(e){ const path = e.currentTarget.dataset.path if (path==="赞赏支持") { this.setData({paymentShow:true}) } else if (path==="每日签到") { scoreApi.signIn().then((res)=>{ if (res.code===200) { wx.showToast({ title: res.msg, icon: 'none' }) this.onLoad() } }) } else{ wx.navigateTo({ url: path }) } }, onLoad(){ const userInfo = tool.data.get('USER_INFO') const userMemberInfo = tool.data.get('USER_MEMBER_INFO') const clientConfig = tool.data.get('CLIENT_CONFIG') this.setData({ userInfo, memberLevel: userMemberInfo ? userMemberInfo.level : null, paymentCode: clientConfig.CLIENT_PAYMENT_CODE[0].thumbUrl }) scoreApi.getUserScore().then(res=>{ this.setData({ 'total[0].value': res.data }) }) userArticleApi.userArticleTotal().then(res=>{ this.setData({ 'total[1].value': res.data.downloadSum, 'total[2].value': res.data.collectionSum, }) }) }, })