123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- // pages/home/home.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- activityList: ["第一季", "第二季"],
- select: "1",
- pageName: "话题",
- tableHead: [],
- tabList: [],
- tablelist: [],
- type: 0,
- title: "",
- jsonURL: "",
- imgURL: "",
- indexNum: 0,
- isShow: false,
- isUpdata: false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- this.getData();
- wx.setStorageSync('nextTime', 0)
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.setData({
- isShow: true
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- this.setData({
- isShow: false
- })
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- // onUnload: function () {
- // // 返回时触发
- // },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () { },
- getData: function (data) {
- const _this = this;
- wx.request({
- url: app.baseUrl + '/overview',
- success: function (res) {
- if (res.statusCode === 200) {
- const tablelist = (res.data || [])
- const tab = tablelist.map((v, i) => {
- v.child_list = (v.child_list || []).map((val, o) => {
- return {
- name: val,
- type: o,
- // worldURL: app.baseUrl + '/data/' + jsonName + ".json",
- // worldImgURL: app.baseUrl + '/data/' + img + ".png"
- worldImgURL: v.word_cloud_url
- }
- })
- return {
- childList: v.child_list,
- name: v.topic_name,
- type: v.topic_id,
- isUpdate: v.is_update,
- // worldURL: app.baseUrl + '/data/' + jsonName + ".json",
- // worldImgURL: v.word_cloud_url ? v.word_cloud_url : img ? app.baseUrl + '/data/' + img + ".png" : ""
- worldImgURL: v.word_cloud_url
- }
- })
- if (_this.data.select === "0")
- tab.unshift({
- name: "话题对比",
- type: -1
- })
- const setD = {
- tabList: tab,
- tablelist
- }
- !_this.data.type && (setD.type = tab[0].type);
- !_this.data.title && (setD.title = tab[0].name);
- _this.setData(setD)
- } else _this.setData({
- error: '请重启后查看'
- })
- },
- data,
- fail: function (err) {
- this.setData({
- error: '数据错误'
- })
- },
- complete: function (res) {
- }
- })
- },
- changeBar: function (type) {
- if (type.detail.title === this.data.title) return;
- this.setData({
- type: type.detail.type,
- title: type.detail.title,
- jsonURL: type.detail.worldURL || "",
- imgURL: type.detail.worldImgURL || "",
- indexNum: type.detail.index || 0,
- isUpdata: type.detail.isUpdata
- })
- },
- bindPickerChange(r) {
- console.log(r.detail.value)
- this.setData({
- select: r.detail.value
- }, () => {
- this.getData()
- })
- }
- })
|