Commit 5eaf8318 by liangyuhang

修改组件位置,添加刷新token,添加热点危机

parent 47d21696
// app.js // app.js
import {getRequest} from './utils/http'
App({ App({
onLaunch() { onLaunch() {
//每次打开小程序时刷新token
let openId = wx.getStorageSync('openId');
if(openId){
// console.log(openId)
getRequest('/mobile/refreshToken?openId='+openId).then(res=>{
if(res){
console.log("刷新token")
wx.setStorageSync('token', res.data.data.token)
}
})
}else{
wx.reLaunch({
url: '/pages/login/login',
})
}
}, },
globalData: { globalData: {
userInfo: null, // userInfo: null,
//是否开发环境 //是否开发环境
isDev:true isDev:true
} }
......
{ {
"component": true, "component": true,
"usingComponents": {} "usingComponents": {
"noList": "/components/noList/noList"
}
} }
\ No newline at end of file
<!--components/eventList/eventList.wxml--> <!--components/eventList/eventList.wxml-->
<block wx:for="{{eventList}}" wx:key="index"> <view wx:if="{{eventList.length>0}}">
<view class="list" bindtap="toEventDetail" data-id="{{item.id}}"> <block wx:for="{{eventList}}" wx:key="index">
<view class="image-box"> <view class="list" bindtap="toEventDetail" data-id="{{item.id}}">
<image src="https://crisis.zhiweidata.com/app/{{item.imgUrl}}" mode="aspectFill" lazy-load="true" /> <view class="image-box">
<image src="https://crisis.zhiweidata.com/app/{{item.imgUrl}}" mode="aspectFill" lazy-load="true" />
</view>
<view class="r">
<rich-text nodes="{{item.eventName}}" class="title"></rich-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> </view>
<view class="r"> </block>
<rich-text nodes="{{item.eventName}}" class="title"></rich-text> </view>
<view class="score">公关指数:<text style="color:#F7815A">{{item.interveneScore}}</text></view> <view wx:else>
<text class="brand">{{item.priBrand}}</text> <noList text="暂无数据"></noList>
<text class="time">{{dateUtil.dateFormat(item.startTime,'yyyy.MM.dd')}}</text> </view>
</view>
</view>
</block>
<wxs module="dateUtil" src="../../wxs/timeUtil.wxs"></wxs> <wxs module="dateUtil" src="../../wxs/timeUtil.wxs"></wxs>
// components/grade/grade.js
import * as echarts from "../ec-canvas/echarts"
const app = getApp()
Component({
observers: {
'crisisLevel': function (val) {
if (val) {
this.draw()
}
}
},
lifetimes: {
attached: function () {
this.echartsComponnet = this.selectComponent('#grade')
},
},
/**
* 组件的属性列表
*/
properties: {
crisisLevel:{
type: Number
}
},
/**
* 组件的初始数据
*/
data: {
// ec: {
// onInit: initChart
// }
ec: {
llazyLoadazy: true,
},
isDev:app.globalData.isDev
},
/**
* 组件的方法列表
*/
methods: {
draw () {
this.echartsComponnet.init((canvas, width, height, dpr) => {
let chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr //解决小程序视图模糊的问题,必写
})
canvas.setChart(chart)
chart.setOption(getOption(this.properties.crisisLevel*20))
return chart
})
}
}
})
// function initChart(canvas, width, height, dpr) {
// const chart = echarts.init(canvas, null, {
// width: width,
// height: height,
// devicePixelRatio: dpr // new
// });
// canvas.setChart(chart);
// var option = {
// series: [
// {
// type: 'gauge',
// startAngle: 180,
// endAngle: 0,
// min: 0,
// max: 100,
// splitNumber: 10,
// itemStyle: {
// color: '#58D9F9',
// shadowColor: 'rgba(0,138,255,0.45)',
// shadowBlur: 10,
// shadowOffsetX: 2,
// shadowOffsetY: 2
// },
// progress: {
// show: true,
// roundCap: true,
// width: 10
// },
// pointer: {
// icon: 'path://M2090.36389,615.30999 L2090.36389,615.30999 C2091.48372,615.30999 2092.40383,616.194028 2092.44859,617.312956 L2096.90698,728.755929 C2097.05155,732.369577 2094.2393,735.416212 2090.62566,735.56078 C2090.53845,735.564269 2090.45117,735.566014 2090.36389,735.566014 L2090.36389,735.566014 C2086.74736,735.566014 2083.81557,732.63423 2083.81557,729.017692 C2083.81557,728.930412 2083.81732,728.84314 2083.82081,728.755929 L2088.2792,617.312956 C2088.32396,616.194028 2089.24407,615.30999 2090.36389,615.30999 Z',
// length: '75%',
// width: 10,
// offsetCenter: [0, '5%']
// },
// axisLine: {
// roundCap: true,
// lineStyle: {
// width: 10
// }
// },
// axisTick: {
// splitNumber: 1,
// lineStyle: {
// width: 2,
// color: '#999'
// }
// },
// splitLine: {
// length: 5,
// lineStyle: {
// width: 3,
// color: '#999'
// }
// },
// axisLabel: {
// distance: 10,
// color: '#999',
// fontSize: 10
// },
// title: {
// show: false
// },
// detail: {
// width: '60%',
// lineHeight: 40,
// height: 180,
// borderRadius: 8,
// offsetCenter: [0, '35%'],
// valueAnimation: true,
// formatter: function (value) {
// return value;
// },
// rich: {
// value: {
// fontSize: 30,
// fontWeight: 'bolder',
// color: '#777'
// },
// unit: {
// fontSize: 10,
// color: '#999',
// padding: [0, 0, -20, 10]
// }
// }
// },
// data: [
// {
// value: 73.4
// }
// ]
// }
// ]
// };
// chart.setOption(option);
// return chart;
// }
function getOption(crisisLevel){
var option = {
series: [
{
type: 'gauge',
startAngle: 180,
endAngle: 0,
min: 0,
max: 100,
splitNumber: 10,
itemStyle: {
color: '#58D9F9',
shadowColor: 'rgba(0,138,255,0.45)',
shadowBlur: 10,
shadowOffsetX: 2,
shadowOffsetY: 2
},
progress: {
show: true,
roundCap: true,
width: 10
},
pointer: {
icon: 'path://M2090.36389,615.30999 L2090.36389,615.30999 C2091.48372,615.30999 2092.40383,616.194028 2092.44859,617.312956 L2096.90698,728.755929 C2097.05155,732.369577 2094.2393,735.416212 2090.62566,735.56078 C2090.53845,735.564269 2090.45117,735.566014 2090.36389,735.566014 L2090.36389,735.566014 C2086.74736,735.566014 2083.81557,732.63423 2083.81557,729.017692 C2083.81557,728.930412 2083.81732,728.84314 2083.82081,728.755929 L2088.2792,617.312956 C2088.32396,616.194028 2089.24407,615.30999 2090.36389,615.30999 Z',
length: '75%',
width: 10,
offsetCenter: [0, '5%']
},
axisLine: {
roundCap: true,
lineStyle: {
width: 10
}
},
axisTick: {
splitNumber: 1,
lineStyle: {
width: 2,
color: '#999'
}
},
splitLine: {
length: 5,
lineStyle: {
width: 3,
color: '#999'
}
},
axisLabel: {
distance: 15,
color: '#999',
fontSize: 10
},
title: {
show: false
},
detail: {
width: '60%',
lineHeight: 40,
height: 180,
borderRadius: 8,
offsetCenter: [0, '35%'],
valueAnimation: true,
formatter: function (value) {
return value;
},
rich: {
value: {
fontSize: 30,
fontWeight: 'bolder',
color: '#777'
},
unit: {
fontSize: 10,
color: '#999',
padding: [0, 0, -20, 10]
}
}
},
data: [
{
value: crisisLevel
}
]
}
]
};
return option;
}
// components/noList/noList.js
Component({
/**
* 组件的属性列表
*/
properties: {
text: String
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--components/noList/noList.wxml-->
<view class="container">
<image src="../../image/air.png"></image>
<view class="text">
<view>{{text}}</view>
</view>
</view>
/* components/noList/noList.wxss */
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
.container image {
width: 140rpx;
height: 140rpx;
}
.container .text {
margin-top: 30rpx;
font-size: 26rpx;
color: #999;
}
\ No newline at end of file
{ {
"component": true, "component": true,
"usingComponents": {} "usingComponents": {
"noList": "/components/noList/noList"
}
} }
\ No newline at end of file
<!--components/reportList.wxml--> <!--components/reportList.wxml-->
<block wx:for="{{reportList}}" wx:key="index"> <view wx:if="{{reportList.length>0}}">
<view class="list" bindtap="toUrl" data-url="https://crisis.zhiweidata.com/viewerpdf/{{item.id}}"> <block wx:for="{{reportList}}" wx:key="index">
<view class="image-box"> <view class="list" bindtap="toUrl" data-url="https://crisis.zhiweidata.com/viewerpdf/{{item.id}}">
<image src="https://crisis.zhiweidata.com/app/{{item.imgUrl}}" mode="aspectFill" lazy-load="true" /> <view class="image-box">
<image src="https://crisis.zhiweidata.com/app/{{item.imgUrl}}" mode="aspectFill" lazy-load="true" />
</view>
<view class="r">
<rich-text nodes="{{item.reportName}}" class="title"></rich-text>
<text class="brand">{{item.priBrand}}</text>
<text class="time">{{dateUtil.dateFormat(item.startTime,'yyyy.MM.dd')}}</text>
</view>
</view> </view>
<view class="r"> </block>
<rich-text nodes="{{item.reportName}}" class="title"></rich-text> </view>
<text class="brand">{{item.priBrand}}</text> <view wx:else>
<text class="time">{{dateUtil.dateFormat(item.startTime,'yyyy.MM.dd')}}</text> <noList text="暂无数据"></noList>
</view> </view>
</view>
</block>
<wxs module="dateUtil" src="../../wxs/timeUtil.wxs"></wxs> <wxs module="dateUtil" src="../../wxs/timeUtil.wxs"></wxs>
{ {
"usingComponents": { "usingComponents": {
"grade": "/components/grade/grade", "grade": "./grade/grade",
"pie": "/components/pie/pie", "pie": "./pie/pie",
"trends": "/components/trends/trends", "trends": "./trends/trends",
"venation": "./venations/venations" "venation": "./venations/venations"
} }
} }
\ No newline at end of file
// components/grade/grade.js
import * as echarts from "../../../components/ec-canvas/echarts"
const app = getApp()
Component({
observers: {
'crisisLevel': function (val) {
if (val) {
this.draw()
}
}
},
lifetimes: {
attached: function () {
this.echartsComponnet = this.selectComponent('#grade')
},
},
/**
* 组件的属性列表
*/
properties: {
crisisLevel:{
type: Number
}
},
/**
* 组件的初始数据
*/
data: {
// ec: {
// onInit: initChart
// }
ec: {
llazyLoadazy: true,
},
isDev:app.globalData.isDev
},
/**
* 组件的方法列表
*/
methods: {
draw () {
this.echartsComponnet.init((canvas, width, height, dpr) => {
let chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr //解决小程序视图模糊的问题,必写
})
chart.showLoading();
canvas.setChart(chart)
chart.setOption(getOption(this.properties.crisisLevel*20))
chart.hideLoading();
return chart
})
}
}
})
function getOption(crisisLevel){
var option = {
series: [
{
type: 'gauge',
startAngle: 180,
endAngle: 0,
min: 0,
max: 100,
splitNumber: 10,
itemStyle: {
color: '#58D9F9',
shadowColor: 'rgba(0,138,255,0.45)',
shadowBlur: 10,
shadowOffsetX: 2,
shadowOffsetY: 2
},
progress: {
show: true,
roundCap: true,
width: 10
},
pointer: {
icon: 'path://M2090.36389,615.30999 L2090.36389,615.30999 C2091.48372,615.30999 2092.40383,616.194028 2092.44859,617.312956 L2096.90698,728.755929 C2097.05155,732.369577 2094.2393,735.416212 2090.62566,735.56078 C2090.53845,735.564269 2090.45117,735.566014 2090.36389,735.566014 L2090.36389,735.566014 C2086.74736,735.566014 2083.81557,732.63423 2083.81557,729.017692 C2083.81557,728.930412 2083.81732,728.84314 2083.82081,728.755929 L2088.2792,617.312956 C2088.32396,616.194028 2089.24407,615.30999 2090.36389,615.30999 Z',
length: '75%',
width: 10,
offsetCenter: [0, '5%']
},
axisLine: {
roundCap: true,
lineStyle: {
width: 10
}
},
axisTick: {
splitNumber: 1,
lineStyle: {
width: 2,
color: '#999'
}
},
splitLine: {
length: 5,
lineStyle: {
width: 3,
color: '#999'
}
},
axisLabel: {
distance: 15,
color: '#999',
fontSize: 10
},
title: {
show: false
},
detail: {
width: '60%',
lineHeight: 40,
height: 180,
borderRadius: 8,
offsetCenter: [0, '35%'],
valueAnimation: true,
formatter: function (value) {
return value;
},
rich: {
value: {
fontSize: 30,
fontWeight: 'bolder',
color: '#777'
},
unit: {
fontSize: 10,
color: '#999',
padding: [0, 0, -20, 10]
}
}
},
data: [
{
value: crisisLevel
}
]
}
]
};
return option;
}
// components/trends/trends.js // components/trends/trends.js
import * as echarts from "../ec-canvas/echarts" import * as echarts from "../../../components/ec-canvas/echarts"
const app = getApp() const app = getApp()
Component({ Component({
...@@ -38,14 +38,57 @@ Component({ ...@@ -38,14 +38,57 @@ Component({
methods: { methods: {
draw () { draw () {
this.echartsComponnet.init((canvas, width, height, dpr) => { this.echartsComponnet.init((canvas, width, height, dpr) => {
let chart = echarts.init(canvas, null, { let chart = echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: dpr //解决小程序视图模糊的问题,必写 devicePixelRatio: dpr //解决小程序视图模糊的问题,必写
}) })
canvas.setChart(chart) chart.showLoading();
chart.setOption(getOption(this.properties.overView)) canvas.setChart(chart)
return chart chart.setOption(getOption(this.properties.overView))
chart.hideLoading();
// 默认高亮第一条数据和展示第一条数据的提示框
// chart.dispatchAction({
// type: 'showTip',
// seriesIndex: 0,
// dataIndex: 0
// });
chart.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: 0
});
chart.on('mouseover',(v) => {
console.log('mouseover')
if(v.dataIndex != 0){
chart.dispatchAction({
type: 'hideTip',
seriesIndex: 0,
dataIndex: 0
});
chart.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: 0
});
}
});
chart.on('mouseout',(v) => {
console.log('mouseout')
chart.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: 0
});
chart.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: 0
});
});
return chart
}) })
} }
} }
...@@ -84,10 +127,9 @@ function getOption(overView){ ...@@ -84,10 +127,9 @@ function getOption(overView){
show: false show: false
}, },
data: [ data: [
//TODO 先用总量吧 { value: overView.wxCount, name: '微信' },
{ value: overView.articleCount, name: '微信' }, { value: overView.wbCount, name: '微博' },
{ value: overView.articleCount, name: '微博' }, { value: overView.wmCount, name: '网媒' }
{ value: overView.articleCount, name: '网媒' }
] ]
} }
] ]
......
// components/trends/trends.js // components/trends/trends.js
import * as echarts from "../ec-canvas/echarts" import * as echarts from "../../../components/ec-canvas/echarts"
const moment = require('../../utils/moment.min.js') const moment = require('../../../utils/moment.min.js')
const app = getApp() const app = getApp()
Component({ Component({
...@@ -45,8 +45,10 @@ Component({ ...@@ -45,8 +45,10 @@ Component({
height: height, height: height,
devicePixelRatio: dpr //解决小程序视图模糊的问题,必写 devicePixelRatio: dpr //解决小程序视图模糊的问题,必写
}) })
chart.showLoading();
canvas.setChart(chart) canvas.setChart(chart)
chart.setOption(getOption(getList(this.properties.data,this.properties.timeType),this.properties.data.times)) chart.setOption(getOption(getList(this.properties.data,this.properties.timeType),this.properties.data.times))
chart.hideLoading();
return chart return chart
}) })
} }
......
...@@ -4,130 +4,136 @@ const app = getApp() ...@@ -4,130 +4,136 @@ const app = getApp()
var http = require('../../utils/http') var http = require('../../utils/http')
Page({ Page({
data: { data: {
crisisDynamic:[], crisisDynamic:[],
crisisField:[], crisisField:[],
crisisArticle:[], crisisArticle:[],
crisisReport:[], crisisReport:[],
showBanner:true, showBanner:true,
toView: 'banner', toView: 'banner',
anchorList:[ carouselIndex:0,
{ anchorList:[
id: 'dynamic', {
text: '危机动态', id: 'dynamic',
img: 'https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/%E9%A6%96%E9%A1%B5/u7.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1' text: '危机动态',
}, img: 'https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/%E9%A6%96%E9%A1%B5/u7.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1'
{ },
id: 'field', {
text: '聚焦领域', id: 'field',
img: 'https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/首页/u14.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1' text: '聚焦领域',
}, img: 'https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/首页/u14.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1'
{ },
id: 'article', {
text: '危机复盘', id: 'article',
img: 'https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/首页/u17.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1' text: '危机复盘',
}, img: 'https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/首页/u17.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1'
{ },
id: 'report', {
text: '危机报告', id: 'report',
img: 'https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/首页/u10.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1' text: '危机报告',
}, img: 'https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/首页/u10.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1'
], },
timeTypeList:[ ],
{name:'近1月',type:'month'}, timeTypeList:[
{name:'近2月',type:'twoMonth'}, {name:'近1月',type:'month'},
{name:'近1年',type:'year'}, {name:'近2月',type:'twoMonth'},
], {name:'近1年',type:'year'},
timeType:'year', ],
timeIndex:2 timeType:'year',
}, timeIndex:2
onLoad() { },
this.setCrisisDynamicData(); onLoad() {
this.setCrisisFieldData(); this.setCrisisDynamicData();
this.setCrisisArticleData(); this.setCrisisFieldData();
this.setCrisisReportData(); this.setCrisisArticleData();
}, this.setCrisisReportData();
setCrisisDynamicData(){ },
http.getRequest('/mobile/index/event/recently').then(res=>{ setCrisisDynamicData(){
if(res){ http.getRequest('/mobile/index/event/recently').then(res=>{
if(res){
this.setData({
crisisDynamic:res.data.data.list
})
}
})
},
setCrisisFieldData(){
http.getRequest('/mobile/index/focusIndustry?timeType='+this.data.timeType).then(res=>{
if(res){
this.setData({
crisisField:res.data.data
})
}
})
},
setCrisisArticleData(){
http.getRequest('/mobile/index/article/recently').then(res=>{
if(res){
this.setData({
crisisArticle:res.data.data
})
}
})
},
setCrisisReportData(){
http.getRequest('/mobile/index/report/recently?size=4').then(res=>{
if(res){
this.setData({
crisisReport:res.data.data
})
}
})
},
closeBanner(){
this.setData({ this.setData({
crisisDynamic:res.data.data.list showBanner: false
}) })
} },
}) scrollToViewFn(e){
}, var _id = e.currentTarget.dataset.id;
setCrisisFieldData(){
http.getRequest('/mobile/index/focusIndustry?timeType='+this.data.timeType).then(res=>{
console.log(res)
if(res){
this.setData({ this.setData({
crisisField:res.data.data toView: _id
}) })
} // console.log(this.data.toView)
}) },
}, refreshFieldData(e){
setCrisisArticleData(){ var _type = e.currentTarget.dataset.type;
http.getRequest('/mobile/index/article/recently').then(res=>{ var _index = e.currentTarget.dataset.index;
if(res){
this.setData({ this.setData({
crisisArticle:res.data.data timeType:_type,
}) timeIndex:_index
} })
}) this.setCrisisFieldData()
}, },
setCrisisReportData(){ // 跳转搜索页
http.getRequest('/mobile/index/report/recently?size=4').then(res=>{ toSearchPage: function () {
if(res){ wx.navigateTo({
url: '/pages/search-page/search-page',
})
},
//跳转事件详情页
toEventDetail(e){
var _eventId = e.currentTarget.dataset.id;
wx.navigateTo({
url: '/pages/event-detail/event-detail?eventId='+ _eventId,
})
},
//跳转文章链接
toArticleUrl(e){
var _url=e.currentTarget.dataset.url
// console.log(_url)
wx.navigateTo({
url: '/pages/out/out?url='+_url
})
},
// 修改轮播图index
changeIndex(e){
this.setData({ this.setData({
crisisReport:res.data.data carouselIndex:e.detail.current
}) })
} },
})
},
closeBanner(){
this.setData({
showBanner: false
})
},
scrollToViewFn(e){
var _id = e.currentTarget.dataset.id;
this.setData({
toView: _id
})
// console.log(this.data.toView)
},
refreshFieldData(e){
var _type = e.currentTarget.dataset.type;
var _index = e.currentTarget.dataset.index;
this.setData({
timeType:_type,
timeIndex:_index
})
this.setCrisisFieldData()
},
// 跳转搜索页
toSearchPage: function () {
wx.navigateTo({
url: '/pages/search-page/search-page',
})
},
//跳转事件详情页
toEventDetail(e){
var _eventId = e.currentTarget.dataset.id;
wx.navigateTo({
url: '/pages/event-detail/event-detail?eventId='+ _eventId,
})
},
//跳转文章链接
toArticleUrl(e){
var _url=e.currentTarget.dataset.url
console.log(_url)
wx.navigateTo({
url: '/pages/out/out?url='+_url
})
},
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function () {
......
...@@ -43,20 +43,21 @@ ...@@ -43,20 +43,21 @@
</view> </view>
<!-- 品牌 --> <!-- 品牌 -->
<!-- 轮播图 --> <!-- 轮播图 -->
<swiper indicator-dots="true" autoplay="true" class="carousel" circular="true"> <swiper indicator-dots="true" autoplay="true" class="carousel" current="{{carouselIndex}}" bindchange="changeIndex" circular="true" next-margin="50rpx" >
<block wx:for="{{crisisDynamic}}" wx:key="index"> <block wx:for="{{crisisDynamic}}" wx:key="index">
<swiper-item bindtap="toEventDetail" data-id="{{item.id}}"> <swiper-item bindtap="toEventDetail" data-id="{{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" lazy-load="true" /> <view class="content">
<image class="dynamic_img2" src="https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/%E9%A6%96%E9%A1%B5/u21.png?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1" mode="scaleToFill" lazy-load="true"/> <image class="dynamic_img {{carouselIndex == index ? 'active' : ''}}" src="https://d1icd6shlvmxi6.cloudfront.net/gsc/L5VHPP/e9/83/b8/e983b88902ca4085bcbc34d714ac6904/images/首页/u22.svg?pageId=794f4729-ba77-4770-92d6-71dfe84a18c1" mode="scaleToFill" lazy-load="true" />
<view class="dynamic_title">{{item.title}}</view> <view class="dynamic_title">{{item.title}}</view>
<view class="dynamic_level">{{item.crisisLevelZh}}风险</view> <view class="dynamic_level">{{item.crisisLevelZh}}风险</view>
<view class="dynamic_introduction">摘要:{{item.introduction}}</view> <view class="dynamic_introduction">摘要:{{item.introduction}}</view>
<view class="dynamic_tag"> <view class="dynamic_tag">
<view class="brand">{{item.priBrand}}</view> <view class="brand">{{item.priBrand}}</view>
<block wx:for="{{item.priCrisisTags}}" wx:key="index"> <block wx:for="{{item.priCrisisTags}}" wx:key="index">
<view class="crisis">{{item}}</view> <view class="crisis">{{item}}</view>
</block> </block>
</view> </view>
</view>
</swiper-item> </swiper-item>
</block> </block>
</swiper> </swiper>
......
...@@ -28,11 +28,12 @@ ...@@ -28,11 +28,12 @@
position: relative; position: relative;
height: 50rpx; height: 50rpx;
text-align: center; text-align: center;
vertical-align: middle;
background-color: #3F85EF; background-color: #3F85EF;
color: #fff; color: #fff;
} }
.banner text{ .banner text{
height: 50rpx;
line-height: 50rpx;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
...@@ -104,13 +105,31 @@ ...@@ -104,13 +105,31 @@
/* 危机动态 */ /* 危机动态 */
.carousel{ .carousel{
position: relative; position: relative;
padding: 0 30rpx; padding-left: 30rpx;
margin-top: 30rpx; margin-top: 30rpx;
height: 300rpx;
} }
.carousel .dynamic_img{ .carousel .content{
position: absolute; height: 100%;
border-radius: 5px; }
.carousel .content .active{
transform: scale(1);
} }
.carousel .dynamic_img{
position: absoulte;
width: 100%;
height: 100%;
border-radius: 10rpx;
transform: scale(0.9);
transition: all 0.4s;
}
.carousel .dynamic_img2{
width: 100%;
height: 100%;
border-radius: 10rpx;
transform: scale(0.9);
transition: all 0.4s;
}
.carousel .dynamic_title{ .carousel .dynamic_title{
position: absolute; position: absolute;
top: 50rpx; top: 50rpx;
......
...@@ -33,11 +33,12 @@ Page({ ...@@ -33,11 +33,12 @@ Page({
wx.hideLoading() wx.hideLoading()
if(res){ if(res){
console.log(res) console.log(res)
wx.setStorageSync('token', res.data.data.token) wx.setStorageSync('token', res.data.data.userInfo.token)
wx.setStorageSync('userName', res.data.data.userName) wx.setStorageSync('userName', res.data.data.userInfo.userName)
wx.setStorageSync('headUrl', res.data.data.headUrl) wx.setStorageSync('headUrl', res.data.data.userInfo.headUrl)
wx.setStorageSync('roleId', res.data.data.roleId) wx.setStorageSync('roleId', res.data.data.userInfo.roleId)
wx.setStorageSync('isLogin',true) wx.setStorageSync('isLogin',true)
wx.setStorageSync('openId',res.data.data.openId)
this.setData({ this.setData({
token:res.data.data.token, token:res.data.data.token,
userName:res.data.data.userName, userName:res.data.data.userName,
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<view class="container"> <view class="container">
<view class="userinfo"> <view class="userinfo">
<block wx:if="{{canIUseOpenData}}"> <block wx:if="{{canIUseOpenData}}">
<!-- TODO open-data能力好像被回收了 先放着 -->
<view class="userinfo-avatar" bindtap="bindViewTap"> <view class="userinfo-avatar" bindtap="bindViewTap">
<open-data type="userAvatarUrl"></open-data> <open-data type="userAvatarUrl"></open-data>
</view> </view>
...@@ -9,6 +10,5 @@ ...@@ -9,6 +10,5 @@
</block> </block>
</view> </view>
<button open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" class="login-btn">授权登录</button>
<button open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" class="login-btn">点此登录</button>
</view> </view>
// pages/search-page/search-page.js // pages/search-page/search-page.js
var http = require('../../utils/http')
Page({ Page({
/** /**
...@@ -6,15 +8,15 @@ Page({ ...@@ -6,15 +8,15 @@ Page({
*/ */
data: { data: {
keyword:'', keyword:'',
hotSearchList: [], historySearch: [],
historySearch: [] hotSearchList: []
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
}, },
/** /**
...@@ -28,13 +30,14 @@ Page({ ...@@ -28,13 +30,14 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
// 获取搜索历史
// 获取搜索历史 this.getHistorySearch();
this.getHistorySearch(); // 获取热点危机
this.getHotSearch();
}, },
//返回首页 //返回首页
cancel(){ cancel(){
wx.navigateBack({}) wx.navigateBack({})
}, },
//绑定输出内容 //绑定输出内容
getSearchInput(e){ getSearchInput(e){
...@@ -47,39 +50,65 @@ Page({ ...@@ -47,39 +50,65 @@ Page({
toSearchResult(){ toSearchResult(){
if (this.data.keyword.trim()) { if (this.data.keyword.trim()) {
// 记录搜索 // 记录搜索
let historySearch = wx.getStorageSync('historySearch') || []; let historySearch = wx.getStorageSync('historySearch') || [];
historySearch = historySearch.filter(item => item !== this.data.keyword) historySearch = historySearch.filter(item => item !== this.data.keyword)
historySearch.unshift(this.data.keyword); historySearch.unshift(this.data.keyword);
console.log(this.data.keyword) console.log(this.data.keyword)
if (historySearch.length>10){ if (historySearch.length>10){
historySearch.pop(); historySearch.pop();
} }
wx.setStorageSync('historySearch', historySearch); wx.setStorageSync('historySearch', historySearch);
// 跳转到搜索结果页 // 跳转到搜索结果页
wx.navigateTo({ wx.navigateTo({
url: '/pages/search-result/search-result?keyword=' + this.data.keyword, url: '/pages/search-result/search-result?keyword=' + this.data.keyword,
}) })
} }
}, },
// 获取搜索历史 // 获取搜索历史
getHistorySearch(){ getHistorySearch(){
this.setData({ this.setData({
historySearch:wx.getStorageSync('historySearch') historySearch:wx.getStorageSync('historySearch')
}); });
},
// 获取热点危机
getHotSearch(){
http.getRequest('/search/event/online-top5').then(res=>{
// console.log(res)
if(res){
this.setData({
hotSearchList:res.data.data
})
}
})
}, },
// 清除搜索历史 // 清除搜索历史
clearHistory(){ clearHistory(){
wx.removeStorageSync('historySearch'); var _this=this;
this.getHistorySearch(); wx.showModal({
content: '确认清除',
success (res) {
if (res.confirm) {
wx.removeStorageSync('historySearch');
_this.getHistorySearch();
}
}
})
}, },
//点击历史搜索 // 点击历史搜索
onHistorySearch(e){ onHistorySearch(e){
this.setData({ this.setData({
keyword: e.currentTarget.dataset.keyword keyword: e.currentTarget.dataset.keyword
}); });
this.toSearchResult() this.toSearchResult()
},
// 跳转事件详情页
toEventDetail(e){
let _eventId=e.currentTarget.dataset.id
wx.navigateTo({
url: '/pages/event-detail/event-detail?eventId='+ _eventId,
})
}, },
/** /**
......
...@@ -9,18 +9,6 @@ ...@@ -9,18 +9,6 @@
<text class='cancel' bindtap='cancel'>取消</text> <text class='cancel' bindtap='cancel'>取消</text>
</view> </view>
<!-- 热点危机 -->
<!-- <view class='hot-search'>
<view class='title'>
<text>热点危机</text>
<image src="../../image/riseSpeed.png"></image>
</view>
<view class='list'>
</view>
</view> -->
<!-- 历史搜索 --> <!-- 历史搜索 -->
<view class='history-search'> <view class='history-search'>
<view class='title'> <view class='title'>
...@@ -35,3 +23,17 @@ ...@@ -35,3 +23,17 @@
</view> </view>
</block> </block>
</view> </view>
<!-- 热点危机 -->
<view class='hot-search'>
<view class='title'>
<text>近期热点危机</text>
<image src="../../image/riseSpeed.png"></image>
</view>
<view class='list'>
<block wx:for="{{hotSearchList}}" wx:key='item'>
<text class='name' bindtap='toEventDetail' data-id="{{item.id}}">{{item.eventName}}</text>
</block>
</view>
</view>
...@@ -46,27 +46,6 @@ ...@@ -46,27 +46,6 @@
display: block; display: block;
} }
/* 热门搜索 */
.hot-search{
padding: 20rpx;
margin-top: 100rpx;
height: 100rpx;
}
.hot-search .title text{
font-size: 32rpx;
color: #333333;
font-weight: 600;
padding-right: 14rpx;
}
.hot-search .title image{
width: 32rpx;
height: 32rpx;
}
.hot-search .list{
height: 20rpx;
}
/* 历史搜索 */ /* 历史搜索 */
.history-search{ .history-search{
padding: 20rpx; padding: 20rpx;
...@@ -76,7 +55,7 @@ ...@@ -76,7 +55,7 @@
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
.history-search .title text{ .history-search .title text{
font-size: 32rpx; font-size: 30rpx;
color: #333333; color: #333333;
font-weight: 600; font-weight: 600;
padding-right: 14rpx; padding-right: 14rpx;
...@@ -85,8 +64,8 @@ ...@@ -85,8 +64,8 @@
float: right; float: right;
} }
.history-search .title .clear-history image{ .history-search .title .clear-history image{
width: 32rpx; width: 30rpx;
height: 32rpx; height: 30rpx;
} }
.history-search .list { .history-search .list {
overflow: hidden; overflow: hidden;
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,7 @@
max-width: 300rpx; max-width: 300rpx;
overflow: hidden; overflow: hidden;
float: left; float: left;
border-radius: 50rpx; border-radius: 5rpx;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
background-color: #f2f2f2; background-color: #f2f2f2;
...@@ -106,4 +85,40 @@ ...@@ -106,4 +85,40 @@
margin-right: 20rpx; margin-right: 20rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
padding: 10rpx 30rpx; padding: 10rpx 30rpx;
}
/* 热门搜索 */
.hot-search{
padding: 20rpx;
height: 100rpx;
}
.hot-search .title{
margin-bottom: 10rpx;
}
.hot-search .title text{
font-size: 30rpx;
color: #333333;
font-weight: 600;
padding-right: 14rpx;
}
.hot-search .title image{
width: 30rpx;
height: 30rpx;
}
.hot-search .list{
display: flex;
flex-wrap: wrap;
}
.hot-search .list .name{
width: 47%;
padding: 15rpx 0rpx;
font-size: 26rpx;
height: 30rpx;
line-height: 30rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.hot-search .list .name:nth-child(odd){
margin-right: 20rpx;
} }
\ No newline at end of file
...@@ -12,7 +12,7 @@ Page({ ...@@ -12,7 +12,7 @@ Page({
keyword:'', keyword:'',
type:1, type:1,
list:[], list:[],
total:-1 total:0
}, },
/** /**
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
<text class='cancel' bindtap='cancel'>取消</text> <text class='cancel' bindtap='cancel'>取消</text>
</view> </view>
<view class='tabs'> <view class='tabs'>
<text class="tab-item {{type==1?'active':''}}" bindtap='switchTap' data-type="1">危机</text> <text class="tab-item {{type==1?'active':''}}" bindtap='switchTap' data-type="1">危机<block wx:if="{{type==1}}">({{total}})</block></text>
<text class="tab-item {{type==2?'active':''}}" bindtap='switchTap' data-type="2">报告</text> <text class="tab-item {{type==2?'active':''}}" bindtap='switchTap' data-type="2">报告<block wx:if="{{type==2}}">({{total}})</block></text>
</view> </view>
</view> </view>
......
...@@ -12,58 +12,6 @@ Page({ ...@@ -12,58 +12,6 @@ Page({
headUrl:wx.getStorageSync('headUrl'), headUrl:wx.getStorageSync('headUrl'),
roleId:wx.getStorageSync('roleId') roleId:wx.getStorageSync('roleId')
}, },
// onGetPhoneNumber(e){
// console.log(e);
// console.log("encryptedData:"+e.detail.encryptedData);
// console.log("iv:"+e.detail.iv);
// },
onGetPhoneNumber(e){
wx.showLoading({
title: '正在登录...'
})
if (e.detail.iv) {
wx.login({
success: res => {
// console.log(res)
let data = {
encryptedData: e.detail.encryptedData,
iv: e.detail.iv,
code: res.code
}
http.postRequest('/mobile/login',data).then(res=>{
wx.hideLoading()
if(res){
console.log(res)
wx.setStorageSync('token', res.data.data.token)
wx.setStorageSync('userName', res.data.data.userName)
wx.setStorageSync('headUrl', res.data.data.headUrl)
wx.setStorageSync('roleId', res.data.data.roleId)
wx.setStorageSync('isLogin',true)
this.setData({
token:res.data.data.token,
userName:res.data.data.userName,
headUrl:res.data.data.headUrl,
roleId:res.data.data.roleId,
isLogin:true
})
}
})
},
fail: err => {
// console.log('登录失败!')
wx.showToast({
title: '登录失败!',
icon: 'none'
})
}
})
} else {
wx.showToast({
title: '您已拒绝授权',
icon: 'none'
})
}
},
getUserProfile(e){ getUserProfile(e){
wx.getUserProfile({ wx.getUserProfile({
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<image src="https://crisis.zhiweidata.com/static/avatar.png" lazy-load="true"></image> <image src="https://crisis.zhiweidata.com/static/avatar.png" lazy-load="true"></image>
</view> </view>
<text class="nickname">微信用户</text> <text class="nickname">微信用户</text>
<text class="level">请登录</text> <text class="level"> </text>
</view> </view>
</view> </view>
...@@ -54,9 +54,6 @@ ...@@ -54,9 +54,6 @@
<view wx:if="{{isLogin}}"> <view wx:if="{{isLogin}}">
<button class="logout-btn" bindtap="logout">退出登录</button> <button class="logout-btn" bindtap="logout">退出登录</button>
</view> </view>
<view wx:else>
<button open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" class="login-btn">点此登录</button>
</view>
</view> </view>
......
...@@ -5,11 +5,11 @@ const imgURL = baseURL+'/app/' ...@@ -5,11 +5,11 @@ const imgURL = baseURL+'/app/'
const request = function(url,options){ const request = function(url,options){
wx.getStorageSync('token') wx.getStorageSync('token')
let token = wx.getStorageSync('token') let token = wx.getStorageSync('token')
if(url!='/mobile/login' && !token){ // if(url!='/mobile/login' && !token){
wx.reLaunch({ // wx.reLaunch({
url: '/pages/login/login', // url: '/pages/login/login',
}) // })
} // }
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
wx.request({ wx.request({
url:baseURL+url, url:baseURL+url,
...@@ -20,32 +20,50 @@ const request = function(url,options){ ...@@ -20,32 +20,50 @@ const request = function(url,options){
'token': token 'token': token
}, },
success: (res) => { success: (res) => {
if (res) { if (res.data.code == 200) {
resolve(res) resolve(res)
} else { } else if(res.data.code == 401 || res.data.code == 402){
reject(res.data.message) //token过期或者账号在其他地方登录
reject()
wx.reLaunch({
url: '/pages/login/login',
})
} else if(res.data.code == 503){
reject()
wx.showToast({
title: '开通VIP后查看!',
icon: 'none'
})
} else if(res.data.code == 500){
reject()
wx.showToast({
title: '服务器出了点小差!',
icon: 'none'
})
} else {
reject(res.data.message)
wx.showToast({
title: res.data.message,
icon: 'none'
})
}
wx.hideNavigationBarLoading()
},
fail: (err) => {
reject(err)
wx.showToast({ wx.showToast({
title: res.data.message, title: '服务器出了点小差!',
icon: 'none' icon: 'none'
}) })
} wx.hideNavigationBarLoading()
wx.hideNavigationBarLoading() }
},
fail: (err) => {
reject(err)
wx.showToast({
title: '服务器出了点小差!',
icon: 'none'
})
wx.hideNavigationBarLoading()
}
}) })
}) })
} }
// get // get
export const getRequest = (url, data) => { export const getRequest = (url, data) => {
wx.showNavigationBarLoading() // wx.showNavigationBarLoading()
return request(url,{ return request(url,{
method:"GET", method:"GET",
data data
......
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