123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- // pages/today/today.js
- const app = getApp()
- import * as echarts from '../../ec-canvas/echarts';
- const $api = require('../../utils/api.js').API;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- datas:{},
- user_id:'',
- matchlist:[],
- fans:0,
- followers:0,
- is_follow:0,
- is_black:0,
- age:0,
- is_auth_user:1,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- user_id: options.user_id,
- })
- wx.getStorage({
- key: 'userInfo',
- success: res => {
- this.setData({
- is_auth_user:res.data.id != this.data.user_id,
- })
- }
- })
-
- if(options.type){
- wx.setNavigationBarTitle({
- title: '我的主页',
- })
- }
- this.getUserData(options.user_id)
- this.getUserMatch(options.user_id)
- },
- getUserData(user_id){
- var data = {}
- data.user_id = user_id
- var year = new Date().getFullYear()
- $api.getUserInfo(data).then(res=>{
-
- this.setData({
- datas:res.data.data,
- age:res.data.data.join_time?(year - res.data.data.join_time):0,
- is_follow:res.data.data.is_follow,
- is_black:res.data.data.is_black,
- })
- })
- },
- getUserMatch(user_id){
- var data = {}
- data.user_id = user_id
- $api.getUserMatch(data).then(res=>{
- this.setData({
- matchlist:res.data.data.list,
- })
- })
- },
- // 拉黑
- black(){
- $api.blackUser({ black_user_id: this.data.user_id}).then(res=>{
- wx.showToast({
- title: '已拉黑'
- })
- this.setData({
- is_black: 1
- })
- })
- },
- // 取消拉黑
- cancelBlack(){
- $api.cancelBlack({ black_user_id: this.data.user_id}).then(res=>{
- wx.showToast({
- title: '已取消'
- })
- this.setData({
- is_black: 0
- })
- })
- },
- // 关注 取消
- followPlayer(e){
- let action = e.target.dataset.action;
- $api.follow({ follow_id: this.data.user_id, action:action}).then(res=>{
- wx.showToast({
- title: action?'取消成功':'已关注',
- })
- this.setData({
- is_follow: !this.data.is_follow
- })
- app.globalData.follow=1
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getUserData(this.data.user_id)
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|