diff --git a/app.js b/app.js index f5e989e..0525b41 100644 --- a/app.js +++ b/app.js @@ -1,45 +1,48 @@ //app.js App({ - onLaunch: function () { - // 展示本地存储能力 - var logs = wx.getStorageSync('logs') || [] - logs.unshift(Date.now()) - wx.setStorageSync('logs', logs) - const systemInfo = wx.getSystemInfoSync(); //获取系统信息 - const menuInfo = wx.getMenuButtonBoundingClientRect(); // 获取胶囊按钮的信息 - this.globalData.menuHeight = menuInfo.height; // 获取胶囊按钮的高 - this.globalData.statusBarHeight = systemInfo.statusBarHeight; // 获取状态栏的高 - this.globalData.menuRight = menuInfo.right; // 获取胶囊按钮的距离屏幕最右边的距离(此处用于设置导航栏左侧距离屏幕的距离) - this.globalData.navBarHeight = (menuInfo.top - systemInfo.statusBarHeight) * 2 + menuInfo.height; // 计算出导航栏的高度 - }, - globalData: { - imageUrl: "https://cdn.sws010.com/wxapp/images", - navBarHeight: 0, // 导航栏高度 - menuHeight: 0, //胶囊按钮 高度 - statusBarHeight: 0, //状态栏高度 - menuRight: 0, //胶囊按钮 距离屏幕右边的距离 - request: function (prarms) { - return new Promise((resolve, reject) => { - wx.request({ - url: 'http://cloud.sws010.com/api/v7.ashx', - data: { - version: "1", - ...prarms - }, - method: 'get', - success: function (res) { - //接口实际返回的内容在res.data中 - if (res.data.Code == 1) { - resolve(res.data.Data); - } else { - reject(res.data) - } - }, - fail: function (err) { - reject(err); - } - }) - }) + onLaunch: function () { + // 展示本地存储能力 + var logs = wx.getStorageSync('logs') || [] + logs.unshift(Date.now()) + wx.setStorageSync('logs', logs) + const systemInfo = wx.getSystemInfoSync(); //获取系统信息 + const menuInfo = wx.getMenuButtonBoundingClientRect(); // 获取胶囊按钮的信息 + this.globalData.menuHeight = menuInfo.height; // 获取胶囊按钮的高 + this.globalData.statusBarHeight = systemInfo.statusBarHeight; // 获取状态栏的高 + this.globalData.menuRight = menuInfo.right; // 获取胶囊按钮的距离屏幕最右边的距离(此处用于设置导航栏左侧距离屏幕的距离) + this.globalData.navBarHeight = (menuInfo.top - systemInfo.statusBarHeight) * 2 + menuInfo.height; // 计算出导航栏的高度 + }, + globalData: { + imageUrl: "https://cdn.sws010.com/wxapp/images", + navBarHeight: 0, // 导航栏高度 + menuHeight: 0, //胶囊按钮 高度 + statusBarHeight: 0, //状态栏高度 + menuRight: 0, //胶囊按钮 距离屏幕右边的距离 + request: function (prarms, callback) { + return new Promise((resolve, reject) => { + wx.request({ + url: 'http://cloud.sws010.com/api/v7.ashx', + data: { + version: "1", + ...prarms + }, + method: 'get', + success: function (res) { + //接口实际返回的内容在res.data中 + if (res.data.Code == 1) { + if (typeof callback === 'function') { + callback(res.data); + } + resolve(res.data.Data); + } else { + reject(res.data) + } + }, + fail: function (err) { + reject(err); + } + }) + }) + } } - } }) \ No newline at end of file diff --git a/components/option/pieOption.js b/components/option/pieOption.js index c0079b5..e4fd34b 100644 --- a/components/option/pieOption.js +++ b/components/option/pieOption.js @@ -1,5 +1,5 @@ // 饼图 -export default function pieOption(color=[],data=[]){ +export default function pieOption(color=[],data=[],){ return{ tooltip: { trigger: 'item' @@ -18,11 +18,10 @@ export default function pieOption(color=[],data=[]){ { // bottom:68, // right:6, - // name:['女性','男性'], + // name: name, type: 'pie', radius: ['66', '40'], avoidLabelOverlap: false, - itemStyle: { // borderRadius: 10, borderColor: '#fff', @@ -30,15 +29,15 @@ export default function pieOption(color=[],data=[]){ }, // 点击弹出提示位置 label: { - show: true, + show: false, position: 'center' }, color:color, //点击弹出提示样式 emphasis: { - label: { + label: { show: true, - fontSize: '10', + fontSize: '40', fontWeight: 'bold' } }, diff --git a/pages/detail/index.js b/pages/detail/index.js index c4945f1..c17e02f 100644 --- a/pages/detail/index.js +++ b/pages/detail/index.js @@ -1,4 +1,6 @@ const app = getApp(); +let iPageIndex = 1 // 当前第几页,0代表第一页 +let iPageSize = 10 //每页显示多少数据 Page({ data: { imageUrl: getApp().globalData.imageUrl, @@ -7,40 +9,126 @@ Page({ user_author: "", sourcetime: "", title: "", - content: "" + content: "", + affections: "", + crisis: "", + ssim: "", + dataList: [], //放置返回数据的数组 + loadMore: false, //"上拉加载"的变量,默认false,隐藏 + loadAll: false, //“没有数据”的变量,默认false,隐藏 + totalNum: 0 }, onLoad() { wx.setNavigationBarTitle({ title: '详情' }) let pages = getCurrentPages(); - let currentPage = pages[pages.length-1] - let options = currentPage.options + let currentPage = pages[pages.length - 1] + let options = currentPage.options this.setData({ id: options.id }) }, onShow() { - this.getData() + this.getData().then(() => { + this.getLikeData() + }) + }, + //页面上拉触底事件的处理函数 + onReachBottom: function () { + console.log("上拉触底事件") + let that = this + if (!that.data.loadMore) { + that.setData({ + loadMore: true, //加载中 + loadAll: false //是否加载完所有数据 + }); + //加载更多,这里做下延时加载 + that.getLikeData(); + } + }, + searchScrollLower() { + this.getLikeData(); }, getData() { - app.globalData.request({ - action: 'getDataById', + return new Promise((resolve, reject) => { + app.globalData.request({ + action: 'getDataById', + sId: this.data.id, + sType: 'ZhuTiFenXiBl', + token: wx.getStorageSync('token') || 't%2BrswgjvzGM=' + }).then(res => { + let arr = res || []; + if (arr.length > 0) { + let data = arr[0]; + this.setData({ + source: data._source.source, + user_author: data._source.user_author, + sourcetime: data._source.sourcetime, + title: data._source.title, + content: data._source.content, + affections: data._source.affections, + crisis: data._source.crisis, + ssim: data._source.ssim + }) + } + resolve(true) + }).catch(() => { + reject(false) + }) + }) + }, + getLikeData() { + let sTimeType = wx.getStorageSync('sTimeType') || 34; + let sStartTime = ""; + let sEndTime = ""; + if (sTimeType == 4) { + sStartTime = wx.getStorageSync('sStartTime') || ''; + sEndTime = wx.getStorageSync('sEndTime') || ''; + } + let obj = { + action: "getSimilarityData", sId: this.data.id, - sType: 'ZhuTiFenXiBl', - token: wx.getStorageSync('token') || 't%2BrswgjvzGM=' + sSsim: this.data.sSsim, + sType: "ZhuTiFenXiBl", + iPageIndex: iPageIndex, + iPageSize: iPageSize, + token: wx.getStorageSync('token') || 't%2BrswgjvzGM=', + sTimeType: sTimeType, + sStartTime: sStartTime, + sEndTime: sEndTime + } + //第一次加载数据 + if (iPageIndex == 1) { + this.setData({ + loadMore: true, //把"上拉加载"的变量设为true,显示 + loadAll: false //把“没有数据”设为false,隐藏 + }) + } + app.globalData.request(obj, (database) => { + this.setData({ + totalNum: database.totalNum + }) }).then(res => { - let arr = res || []; - if(arr.length > 0) { - let data = arr[0]; - console.log(data) + if (res && res.length > 0) { + iPageIndex++; + //把新请求到的数据添加到dataList里 + let list = this.data.dataList.concat(res); + this.setData({ + dataList: list, //获取数据数组 + loadMore: false //把"上拉加载"的变量设为false,显示 + }); + if (res.length < pageSize) { + this.setData({ + loadMore: false, //隐藏加载中。。 + loadAll: true //所有数据都加载完了 + }); + } + } else { this.setData({ - source: data._source.source, - user_author: data._source.user_author, - sourcetime: data._source.sourcetime, - title: data._source.title, - content: data._source.content - }) + loadAll: true, //把“没有数据”设为true,显示 + loadMore: false //把"上拉加载"的变量设为false,隐藏 + }); } }) } diff --git a/pages/detail/index.wxml b/pages/detail/index.wxml index e5469c0..8ea2317 100644 --- a/pages/detail/index.wxml +++ b/pages/detail/index.wxml @@ -2,8 +2,13 @@ - - 正面 + + 正面 + 负面 + 中性 + 低级危机 + 中级危机 + 高级危机 @@ -37,24 +42,28 @@ 相似信息 - 共计23条相似数据 + 共计{{totalNum}}条相似数据 - - - - 2022-04-29 23:02:01 + + + + + 2022-04-29 23:02:01 + + + 正面 + - - 正面 + + 谁说国产没有高性能SUV这3款国产SUV + + + 来源:百度百家 + 作者:无心 - - 谁说国产没有高性能SUV这3款国产SUV - - - 来源:百度百家 - 作者:无心 - - + + + \ No newline at end of file diff --git a/pages/detail/index.wxss b/pages/detail/index.wxss index 75c4e84..a7d4aec 100644 --- a/pages/detail/index.wxss +++ b/pages/detail/index.wxss @@ -70,6 +70,7 @@ left: 0px; bottom: 53px; } + .d-top-cp-d4 { position: absolute; display: flex; @@ -78,9 +79,11 @@ height: 50px; bottom: 0px; } + .d-top-cp-d4-dd1 { margin-top: 8px; } + .b-c-top-bm { position: absolute; width: 100%; @@ -91,9 +94,11 @@ border-top-left-radius: 20px; border-top-right-radius: 20px; } + .bc-cont { padding: 0px 13px 10px 15px; } + .bc-c-d1 { background-color: #fff; padding: 16px; @@ -101,28 +106,41 @@ color: #333333; line-height: 1.6; } + .bc-c-d2 { display: flex; justify-content: flex-start; align-items: center; margin-top: 16px; } + .bc-c-d3 { position: relative; background-color: #fff; padding: 16px; margin-top: 8px; } + .bc-c-d3-dd1 { display: flex; justify-content: space-between; } + .bc-c-d3-dd2 { color: #333333; margin-top: 12px; } + .bc-c-d3-dd3 { display: flex; justify-content: flex-start; margin-top: 12px; +} + +.loading { + position: relative; + bottom: 5rpx; + padding: 10rpx; + text-align: center; + font-size: 12px; } \ No newline at end of file diff --git a/pages/index/Salesranking/Salesranking.js b/pages/index/Salesranking/Salesranking.js index 726abaa..4d5a79b 100644 --- a/pages/index/Salesranking/Salesranking.js +++ b/pages/index/Salesranking/Salesranking.js @@ -1,4 +1,5 @@ // pages/index/Salesranking/Salesranking.js +const app = getApp(); Page({ data: { active: 0, diff --git a/pages/index/total/tatal.js b/pages/index/total/tatal.js index 42dccc9..6485166 100644 --- a/pages/index/total/tatal.js +++ b/pages/index/total/tatal.js @@ -1,93 +1,220 @@ // pages/index/total/tatal.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - content:[ - { - time: '2022-04-29 23:00:00', - title: '谁说国产没有高性能SUV这3款国产SUV配2.0T发动机,星途凌云换个运动轮胎妥妥的6秒3最快6...', - author: '明哥飞扬', - media:'新浪微博' - }, - { - time: '2022-04-29 23:00:00', - title: '星途凌云S上市传播分析:评论中毒 奇瑞车为何如此招黑?', - author: '明哥飞扬', - media:'新浪微博' - }, - { - time: '2022-04-29 23:00:00', - title: 'MG5天蝎座上市传播分析:评论区疑似闹“水灾', - author: '明哥飞扬', - media:'新浪微博' - }, - { - time: '2022-04-29 23:00:00', - title: '谁说国产没有高性能SUV这3款国产SUV配2.0T发动机,星途凌云换个运动轮胎妥妥的6秒3最快6...', - author: '明哥飞扬', - media:'新浪微博' - }, +const app =getApp(); +// Page({ + +// /** +// * 页面的初始数据 +// */ +// data: { +// content:[ +// { +// time: '2022-04-29 23:00:00', +// title: '谁说国产没有高性能SUV这3款国产SUV配2.0T发动机,星途凌云换个运动轮胎妥妥的6秒3最快6...', +// author: '明哥飞扬', +// media:'新浪微博' +// }, +// { +// time: '2022-04-29 23:00:00', +// title: '星途凌云S上市传播分析:评论中毒 奇瑞车为何如此招黑?', +// author: '明哥飞扬', +// media:'新浪微博' +// }, +// { +// time: '2022-04-29 23:00:00', +// title: 'MG5天蝎座上市传播分析:评论区疑似闹“水灾', +// author: '明哥飞扬', +// media:'新浪微博' +// }, +// { +// time: '2022-04-29 23:00:00', +// title: '谁说国产没有高性能SUV这3款国产SUV配2.0T发动机,星途凌云换个运动轮胎妥妥的6秒3最快6...', +// author: '明哥飞扬', +// media:'新浪微博' +// }, - ] - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - +// ] + +// }, + +// /** +// * 生命周期函数--监听页面加载 +// */ +// onLoad(options) { + +// }, + +// /** +// * 生命周期函数--监听页面初次渲染完成 +// */ +// onReady() { + +// }, + +// /** +// * 生命周期函数--监听页面显示 +// */ +// onShow() { + +// }, + +// /** +// * 生命周期函数--监听页面隐藏 +// */ +// onHide() { + +// }, + +// /** +// * 生命周期函数--监听页面卸载 +// */ +// onUnload() { + +// }, + +// /** +// * 页面相关事件处理函数--监听用户下拉动作 +// */ +// onPullDownRefresh() { + +// }, + +// /** +// * 页面上拉触底事件的处理函数 +// */ +// onReachBottom() { + +// }, + +// /** +// * 用户点击右上角分享 +// */ +// onShareAppMessage() { + +// } +// }) +Component({ + data: { + content: {}, + }, + methods: { + // modalChoose(e) { + // let id = e.currentTarget.dataset.id; //获取点击的id + // app.globalData.request({ + // action: 'getUserSeriesName', + // token: 't%2BrswgjvzGM=', + // sBrandName: id + // }).then(res => { + // this.setData({ + // modalList: res, + // popShow: true, + // currentBrand: id, + // }) + // }); + // }, + // handlerSearch(value) { + // let keyword = value.detail; + // app.globalData.request({ + // action: 'getQueryrSeriesName', + // token: 't%2BrswgjvzGM=', + // queryname: keyword + // }).then(res => { + // //图片少了.png后缀 + // let arr = [] + // for (let i = 65; i <= 90; i++) { + // arr.push({ + // name: String.fromCharCode(i), + // data: [] + // }); + // } + // for(let i of res){ + // for(let j of arr){ + // if(i.firstword == j.name){ + // let obj = { + // brandname: i.name, + // img: i.img+'.png', + // data: i.data, + // firstword: i.firstword + // } + // j.data.push(obj) + // } + // } + // }; + // this.setData({ + // brandList: arr + // }); + // }); + // }, + // toModalInsight(value) { + // let id = value.target.dataset.id; + // wx.setStorageSync('sSeriesName', id); + // // wx.navigateTo({ + // // url: "/pages/insight/pages/modalInsight/index" + // // }) + // }, + // onClose() { + // this.setData({ + // popShow: false + // }) + // } + }, + lifetimes: { + attached() { + let sTimeType = wx.getStorageSync("sTimeType") || 34; + let sStartTime = wx.getStorageSync("sStartTime") || ''; + let sEndTime = wx.getStorageSync("sEndTime") || ''; + this.getData(sTimeType, sStartTime, sEndTime); } + +}, +methods: { + // 时间 + changeTime(e){ + let sTimeType = e.detail.sTimeType; + let sStartTime = e.detail.sStartTime; + let sEndTime = e.detail.sEndTime; + this.getData(sTimeType, sStartTime, sEndTime); + }, + getData(sTimeType, sStartTime, sEndTime){ + wx.showToast({ + title: '加载中', + icon: 'loading', + duration: 300000 + }) + let key = ele.key + app.globalData.request({ + action: 'getHomeList0528', + sType: 'Home', + sTimeType:sTimeType, + sStartTime:sStartTime, + sEndTime:sEndTime, + sQuDao:key +}).then(res => { + const data= res; + const _source = [] + +// for (let i = 0 ;i{ + // let obj = { + // sourcetime:data._source.sourcetime, + // title:data._source.title, + // user_author:data._source.user_author, + // source:data._source.source + // } + // _source.push(obj) + // }) + + this.setData({ + content:data._source + + }); + console.log('9999',data) + // console.log('9999',arr) +}); + setTimeout(() =>{ + wx.hideToast(); + },500) + }, +}, }) \ No newline at end of file diff --git a/pages/index/total/tatal.wxml b/pages/index/total/tatal.wxml index 417fafb..9e070fd 100644 --- a/pages/index/total/tatal.wxml +++ b/pages/index/total/tatal.wxml @@ -1,14 +1,14 @@ - + - {{item.time}} + {{content.sourcetime}} - {{item.title}} + {{content.title}} - 作者:{{item.author}} + 作者:{{content.user_author}} - 媒体:{{item.media}} + 媒体:{{content.source}}