key1_beacon_xcx/pages/table-data/index.js
2023-11-24 22:54:48 +08:00

152 lines
2.4 KiB
JavaScript

import {
getTableDataDetails
} from '~/services/table-data/getTableDataDetails';
import {
follow
} from '~/services/table-data/follow';
import {
cancelfollow
} from '~/services/table-data/cancelfollow';
// pages/table-data/index.js
Page({
/**
* 页面的初始数据
*/
data: {
tableDataId: 0,
tableDataDetail: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
tableDataId:options.id
})
this.init()
// console.log(options.id);
},
init() {
this.details()
},
details() {
let params = {
tableDataId: this.data.tableDataId
}
getTableDataDetails(params).then((res) => {
if (res.code == 200) {
this.setData({
tableDataDetail: res.data,
});
console.log(this.data);
} else {}
});
},
toSubcribe() {
wx.navigateTo({
url: `/pages/usercenter/subscribe/index`,
});
},
toLink() {
var that = this;
wx.setClipboardData({
data: that.data.tableDataDetail.tableDataLink,
success(res) {
wx.showToast({
title: '复制成功',
})
}
})
},
// 关注
followFun() {
let params = {
tableDataGuid: this.data.tableDataDetail.tableDataGuid
}
follow(params).then((res) => {
if (res.code == 200) {
wx.showToast({
title: res.data,
})
setTimeout(() => {
this.init()
}, 1000);
} else {}
});
},
cancelFollow() {
let params = {
tableDataGuid: this.data.tableDataDetail.tableDataGuid
}
cancelfollow(params).then((res) => {
if (res.code == 200) {
wx.showToast({
title: res.data,
})
setTimeout(() => {
this.init()
}, 1000);
} else {}
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})