Commit db5935e1 by liangyuhang

危机库

parent dc94002c
// app.js // app.js
App({ App({
onLaunch() { onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
}, },
globalData: { globalData: {
userInfo: null userInfo: null
......
{ {
"pages": [ "pages": [
"pages/index/index", "pages/index/index",
"pages/logs/logs",
"pages/report/report", "pages/report/report",
"pages/library/library", "pages/library/library",
"pages/usercenter/usercenter" "pages/usercenter/usercenter"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff", "navigationBarBackgroundColor": "#025FEA",
"navigationBarTitleText": "危机汇", "navigationBarTitleText": "危机汇",
"navigationBarTextStyle": "black" "navigationBarTextStyle": "white"
}, },
"tabBar": { "tabBar": {
"selectedColor":"#4551c2", "selectedColor":"#4551c2",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<!-- 横幅 --> <!-- 横幅 -->
<view class="banner" wx:if="{{banner}}"> <view class="banner" wx:if="{{banner}}">
<swiper style="height: 50rpx;" autoplay="true" vertical="true" circular="true"> <swiper style="height: 50rpx;" autoplay="true" vertical="true" circular="true">
<block wx:for="{{crisisDynamic}}"> <block wx:for="{{crisisDynamic}}" wx:key="index">
<swiper-item> <swiper-item>
<text>{{item.title}}</text> <text>{{item.title}}</text>
<view class="close" bindtap="closeBanner">X</view> <view class="close" bindtap="closeBanner">X</view>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</view> </view>
<!-- 锚点 --> <!-- 锚点 -->
<view class="anchor"> <view class="anchor">
<block wx:for="{{anchorList}}"> <block wx:for="{{anchorList}}" wx:key="index">
<view class="icon" bindtap="scrollToViewFn" data-id="{{item.id}}"> <view class="icon" bindtap="scrollToViewFn" data-id="{{item.id}}">
<image src="{{item.img}}"/> <image src="{{item.img}}"/>
<text class="text">{{item.text}}</text> <text class="text">{{item.text}}</text>
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<navigator url="/pages/library/library" open-type="switchTab" class="right">查看全部></navigator> <navigator url="/pages/library/library" open-type="switchTab" class="right">查看全部></navigator>
</view> </view>
<swiper indicator-dots="true" autoplay="true" class="carousel" circular="true"> <swiper indicator-dots="true" autoplay="true" class="carousel" circular="true">
<block wx:for="{{crisisDynamic}}"> <block wx:for="{{crisisDynamic}}" wx:key="index">
<swiper-item> <swiper-item>
<navigator url="https://crisis.zhiweidata.com/event/{{item.id}}"> <navigator url="https://crisis.zhiweidata.com/event/{{item.id}}">
<image class="dynamic_img" src="https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/首页/u22.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1" mode="scaleToFill" /> <image class="dynamic_img" src="https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/首页/u22.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1" mode="scaleToFill" />
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<text>危机占比</text> <text>危机占比</text>
<text>涉及品牌</text> <text>涉及品牌</text>
</view> </view>
<block wx:for="{{crisisField}}"> <block wx:for="{{crisisField}}" wx:key="index">
<view class="field-list"> <view class="field-list">
<view class="field-tag"> <view class="field-tag">
<text>{{item.tag}}</text> <text>{{item.tag}}</text>
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
<text class="title">危机复盘</text> <text class="title">危机复盘</text>
<text class="right">查看全部></text> <text class="right">查看全部></text>
</view> </view>
<block wx:for="{{crisisArticle}}"> <block wx:for="{{crisisArticle}}" wx:key="index">
<view class="article-list"> <view class="article-list">
<view class="article-title">{{item.title}}</view> <view class="article-title">{{item.title}}</view>
<view class="article-time">{{item.publishTime}}</view> <view class="article-time">{{item.publishTime}}</view>
......
// pages/library/library.js // pages/library/library.js
var http = require('../../utils/http')
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
conditions:[], eventList:[],
events:[] tabIndex:0,
conditions:[
{"name":"不限"},
{"name":"新消费"},
{"name":"互联网"},
{"name":"医疗"},
{"name":"汽车"}
// {"name":"全部"}
],
page:1,
size:10,
industry:'不限',
total:-1,
isloading:false
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
...@@ -27,9 +43,43 @@ Page({ ...@@ -27,9 +43,43 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
this.getEevntList();
},
switchTap(e){
var _index = e.currentTarget.dataset.index;
var _name = e.currentTarget.dataset.name;
// console.log("index:"+_index)
// console.log("name:"+_name)
this.setData({
tabIndex: _index,
industry:_name,
eventList:[]
})
this.getEevntList();
},
getEevntList(){
this.setData({
isloading:true
})
wx.showLoading({ wx.showLoading({
title: '加载中...', title: '加载中...',
}) })
http.getRequest('/events?page='+this.data.page+'&size='+this.data.size+'&industry='+this.data.industry).then(res=>{
if(res.data.code==200){
// console.log(res)
this.setData({
// eventList:res.data.data.list
// eventList:[...this.data.eventList,...res.data.data.list]
eventList:this.data.eventList.concat(res.data.data.list),
total:res.data.data.total
})
}
wx.hideLoading()
this.setData({
isloading:false
})
})
}, },
/** /**
...@@ -57,7 +107,18 @@ Page({ ...@@ -57,7 +107,18 @@ Page({
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function () {
if(this.data.page * this.data.size>=this.data.total){
//下一页无数据
return wx.showToast({
title: '没有下一页了!',
})
}
// 防止加载时刷新
if(this.data.isloading) return
this.setData({
page:this.data.page+1
})
this.getEevntList()
}, },
/** /**
......
<!--pages/library/library.wxml--> <!--pages/library/library.wxml-->
<text>pages/library/library.wxml</text> <view class="condition-con">
<block></block> <view class="condition-list">
\ No newline at end of file <block wx:for="{{conditions}}" wx:key="index">
<view class="condition {{tabIndex==index? 'active' : ''}}" data-index="{{index}}" data-name="{{item.name}}" bind:tap="switchTap" >
{{item.name}}
</view>
</block>
</view>
</view>
<view>
<block wx:for="{{eventList}}" wx:key="index">
<view class="list">
<view class="image-box">
<image src="https://crisis.zhiweidata.com/app/{{item.imgUrl}}" mode="aspectFill" lazy-load="true" />
</view>
<view class="r">
<text class="title">{{item.eventName}}</text>
<view class="score">公关指数:<text style="color:#F7815A">{{item.interveneScore}}</text></view>
<text class="brand">{{item.priBrand}}</text>
<text class="time">{{dateUtil.dateFormat(item.startTime,'yyyy.MM.dd')}}</text>
</view>
</view>
</block>
</view>
<wxs module="dateUtil" src="../../wxs/timeUtil.wxs"></wxs>
\ No newline at end of file
/* pages/library/library.wxss */ /* pages/library/library.wxss */
\ No newline at end of file /* 条件 */
.condition-con{
height: 80rpx;
background-color: #025FEA;
}
.condition-list{
display: flex;
padding: 0 30rpx;
line-height: 80rpx;
}
.condition{
width: 20vh;
text-align: center;
font-size: 30rpx;
color: rgba(255, 255, 255, 0.5);
}
.active{
position: relative;
font-size: 32rpx;
color: #fff;
}
.active::after {
position: absolute;
content: '';
height: 5rpx;
width: 50rpx;
left: 50%;
bottom: 5rpx;
background: #fff;
margin-left: -25rpx;
border-radius: 4rpx;
}
/* 列表 */
.list{
display: flex;
height: 150rpx;
margin: 20rpx;
border-bottom: 1px solid #e3e4e4;
}
.list .image-box{
width: 150rpx;
text-align:center;
}
.list .image-box image{
width: 120rpx;
height: 120rpx;
border-radius: 50%;
}
.r{
margin-left: 20rpx;
width: 100%;
position: relative;
}
.r .title{
font-weight: bold;
font-size: 30rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.r .score{
position: absolute;
font-size: 28rpx;
color: #A0A0A0;
top: 50rpx;
left: 0;
}
.r .brand{
position: absolute;
background-color: #E5EDFA;
font-size: 28rpx;
color: #0A63EA;
bottom: 15rpx;
left: 0;
}
.r .time{
position: absolute;
font-size: 28rpx;
color: #A0A0A0;
bottom: 15rpx;
right: 0;
}
// logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return {
date: util.formatTime(new Date(log)),
timeStamp: log
}
})
})
}
})
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}
\ No newline at end of file
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log.date}}</text>
</block>
</view>
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
...@@ -23,6 +23,12 @@ ...@@ -23,6 +23,12 @@
"pathName": "pages/usercenter/usercenter", "pathName": "pages/usercenter/usercenter",
"query": "", "query": "",
"scene": null "scene": null
},
{
"name": "危机库",
"pathName": "pages/library/library",
"query": "",
"scene": null
} }
] ]
} }
......
...@@ -25,13 +25,18 @@ function wxPromisify(fn) { ...@@ -25,13 +25,18 @@ function wxPromisify(fn) {
export const getRequest = (url, data) => { export const getRequest = (url, data) => {
var getRequest = wxPromisify(wx.request); var getRequest = wxPromisify(wx.request);
wx.showNavigationBarLoading() wx.showNavigationBarLoading()
// wx.showLoading({
// title: '加载中...',
// })
return getRequest({ return getRequest({
url: baseURL+url, url: baseURL+url,
method: 'GET', method: 'GET',
data: data, data: data,
header: { header: {
'Content-Type': 'application/json' 'Content-Type': 'application/json',
} 'token': wx.getStorageSync('token')
},
}) })
} }
...@@ -44,7 +49,8 @@ export const postRequest = (url, data) => { ...@@ -44,7 +49,8 @@ export const postRequest = (url, data) => {
method: 'POST', method: 'POST',
data: data, data: data,
header: { header: {
"content-type": "application/json" "content-type": "application/json",
'token': wx.getStorageSync('token')
}, },
}) })
} }
...@@ -58,7 +64,8 @@ export const putRequest = (url, data) => { ...@@ -58,7 +64,8 @@ export const putRequest = (url, data) => {
method: 'PUT', method: 'PUT',
data: data, data: data,
header: { header: {
"content-type": "application/json" "content-type": "application/json",
'token': wx.getStorageSync('token')
}, },
}) })
} }
...@@ -72,7 +79,8 @@ export const deleteRequest = (url, data) => { ...@@ -72,7 +79,8 @@ export const deleteRequest = (url, data) => {
method: 'PUT', method: 'PUT',
data: data, data: data,
header: { header: {
"content-type": "application/json" "content-type": "application/json",
'token': wx.getStorageSync('token')
}, },
}) })
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment