Commit 5eaf8318 by liangyuhang

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

parent 47d21696
// app.js
import {getRequest} from './utils/http'
App({
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: {
userInfo: null,
// userInfo: null,
//是否开发环境
isDev:true
}
......
{
"component": true,
"usingComponents": {}
"usingComponents": {
"noList": "/components/noList/noList"
}
}
\ No newline at end of file
<!--components/eventList/eventList.wxml-->
<block wx:for="{{eventList}}" wx:key="index">
<view wx:if="{{eventList.length>0}}">
<block wx:for="{{eventList}}" wx:key="index">
<view class="list" bindtap="toEventDetail" data-id="{{item.id}}">
<view class="image-box">
<image src="https://crisis.zhiweidata.com/app/{{item.imgUrl}}" mode="aspectFill" lazy-load="true" />
......@@ -11,6 +12,11 @@
<text class="time">{{dateUtil.dateFormat(item.startTime,'yyyy.MM.dd')}}</text>
</view>
</view>
</block>
</block>
</view>
<view wx:else>
<noList text="暂无数据"></noList>
</view>
<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,
"usingComponents": {}
"usingComponents": {
"noList": "/components/noList/noList"
}
}
\ No newline at end of file
<!--components/reportList.wxml-->
<block wx:for="{{reportList}}" wx:key="index">
<view wx:if="{{reportList.length>0}}">
<block wx:for="{{reportList}}" wx:key="index">
<view class="list" bindtap="toUrl" data-url="https://crisis.zhiweidata.com/viewerpdf/{{item.id}}">
<view class="image-box">
<image src="https://crisis.zhiweidata.com/app/{{item.imgUrl}}" mode="aspectFill" lazy-load="true" />
......@@ -10,7 +11,11 @@
<text class="time">{{dateUtil.dateFormat(item.startTime,'yyyy.MM.dd')}}</text>
</view>
</view>
</block>
</block>
</view>
<view wx:else>
<noList text="暂无数据"></noList>
</view>
<wxs module="dateUtil" src="../../wxs/timeUtil.wxs"></wxs>
{
"usingComponents": {
"grade": "/components/grade/grade",
"pie": "/components/pie/pie",
"trends": "/components/trends/trends",
"grade": "./grade/grade",
"pie": "./pie/pie",
"trends": "./trends/trends",
"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
import * as echarts from "../ec-canvas/echarts"
import * as echarts from "../../../components/ec-canvas/echarts"
const app = getApp()
Component({
......@@ -43,8 +43,51 @@ Component({
height: height,
devicePixelRatio: dpr //解决小程序视图模糊的问题,必写
})
chart.showLoading();
canvas.setChart(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){
show: false
},
data: [
//TODO 先用总量吧
{ value: overView.articleCount, name: '微信' },
{ value: overView.articleCount, name: '微博' },
{ value: overView.articleCount, name: '网媒' }
{ value: overView.wxCount, name: '微信' },
{ value: overView.wbCount, name: '微博' },
{ value: overView.wmCount, name: '网媒' }
]
}
]
......
// components/trends/trends.js
import * as echarts from "../ec-canvas/echarts"
const moment = require('../../utils/moment.min.js')
import * as echarts from "../../../components/ec-canvas/echarts"
const moment = require('../../../utils/moment.min.js')
const app = getApp()
Component({
......@@ -45,8 +45,10 @@ Component({
height: height,
devicePixelRatio: dpr //解决小程序视图模糊的问题,必写
})
chart.showLoading();
canvas.setChart(chart)
chart.setOption(getOption(getList(this.properties.data,this.properties.timeType),this.properties.data.times))
chart.hideLoading();
return chart
})
}
......
......@@ -11,6 +11,7 @@ Page({
crisisReport:[],
showBanner:true,
toView: 'banner',
carouselIndex:0,
anchorList:[
{
id: 'dynamic',
......@@ -58,7 +59,6 @@ Page({
},
setCrisisFieldData(){
http.getRequest('/mobile/index/focusIndustry?timeType='+this.data.timeType).then(res=>{
console.log(res)
if(res){
this.setData({
crisisField:res.data.data
......@@ -121,11 +121,17 @@ Page({
//跳转文章链接
toArticleUrl(e){
var _url=e.currentTarget.dataset.url
console.log(_url)
// console.log(_url)
wx.navigateTo({
url: '/pages/out/out?url='+_url
})
},
// 修改轮播图index
changeIndex(e){
this.setData({
carouselIndex:e.detail.current
})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
......
......@@ -43,11 +43,11 @@
</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">
<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" />
<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"/>
<view class="content">
<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_level">{{item.crisisLevelZh}}风险</view>
<view class="dynamic_introduction">摘要:{{item.introduction}}</view>
......@@ -57,6 +57,7 @@
<view class="crisis">{{item}}</view>
</block>
</view>
</view>
</swiper-item>
</block>
</swiper>
......
......@@ -28,11 +28,12 @@
position: relative;
height: 50rpx;
text-align: center;
vertical-align: middle;
background-color: #3F85EF;
color: #fff;
}
.banner text{
height: 50rpx;
line-height: 50rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
......@@ -104,13 +105,31 @@
/* 危机动态 */
.carousel{
position: relative;
padding: 0 30rpx;
padding-left: 30rpx;
margin-top: 30rpx;
height: 300rpx;
}
.carousel .content{
height: 100%;
}
.carousel .content .active{
transform: scale(1);
}
.carousel .dynamic_img{
position: absolute;
border-radius: 5px;
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{
position: absolute;
top: 50rpx;
......
......@@ -33,11 +33,12 @@ Page({
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('token', res.data.data.userInfo.token)
wx.setStorageSync('userName', res.data.data.userInfo.userName)
wx.setStorageSync('headUrl', res.data.data.userInfo.headUrl)
wx.setStorageSync('roleId', res.data.data.userInfo.roleId)
wx.setStorageSync('isLogin',true)
wx.setStorageSync('openId',res.data.data.openId)
this.setData({
token:res.data.data.token,
userName:res.data.data.userName,
......
......@@ -2,6 +2,7 @@
<view class="container">
<view class="userinfo">
<block wx:if="{{canIUseOpenData}}">
<!-- TODO open-data能力好像被回收了 先放着 -->
<view class="userinfo-avatar" bindtap="bindViewTap">
<open-data type="userAvatarUrl"></open-data>
</view>
......@@ -9,6 +10,5 @@
</block>
</view>
<button open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" class="login-btn">点此登录</button>
<button open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" class="login-btn">授权登录</button>
</view>
// pages/search-page/search-page.js
var http = require('../../utils/http')
Page({
/**
......@@ -6,8 +8,8 @@ Page({
*/
data: {
keyword:'',
hotSearchList: [],
historySearch: []
historySearch: [],
hotSearchList: []
},
/**
......@@ -28,9 +30,10 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
// 获取搜索历史
this.getHistorySearch();
// 获取热点危机
this.getHotSearch();
},
//返回首页
cancel(){
......@@ -69,18 +72,44 @@ Page({
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(){
var _this=this;
wx.showModal({
content: '确认清除',
success (res) {
if (res.confirm) {
wx.removeStorageSync('historySearch');
this.getHistorySearch();
_this.getHistorySearch();
}
}
})
},
//点击历史搜索
// 点击历史搜索
onHistorySearch(e){
this.setData({
keyword: e.currentTarget.dataset.keyword
});
this.toSearchResult()
},
// 跳转事件详情页
toEventDetail(e){
let _eventId=e.currentTarget.dataset.id
wx.navigateTo({
url: '/pages/event-detail/event-detail?eventId='+ _eventId,
})
},
/**
* 生命周期函数--监听页面隐藏
......
......@@ -9,18 +9,6 @@
<text class='cancel' bindtap='cancel'>取消</text>
</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='title'>
......@@ -35,3 +23,17 @@
</view>
</block>
</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 @@
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{
padding: 20rpx;
......@@ -76,7 +55,7 @@
margin-bottom: 20rpx;
}
.history-search .title text{
font-size: 32rpx;
font-size: 30rpx;
color: #333333;
font-weight: 600;
padding-right: 14rpx;
......@@ -85,8 +64,8 @@
float: right;
}
.history-search .title .clear-history image{
width: 32rpx;
height: 32rpx;
width: 30rpx;
height: 30rpx;
}
.history-search .list {
overflow: hidden;
......@@ -98,7 +77,7 @@
max-width: 300rpx;
overflow: hidden;
float: left;
border-radius: 50rpx;
border-radius: 5rpx;
white-space: nowrap;
text-overflow: ellipsis;
background-color: #f2f2f2;
......@@ -107,3 +86,39 @@
margin-bottom: 20rpx;
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({
keyword:'',
type:1,
list:[],
total:-1
total:0
},
/**
......
......@@ -11,8 +11,8 @@
<text class='cancel' bindtap='cancel'>取消</text>
</view>
<view class='tabs'>
<text class="tab-item {{type==1?'active':''}}" bindtap='switchTap' data-type="1">危机</text>
<text class="tab-item {{type==2?'active':''}}" bindtap='switchTap' data-type="2">报告</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">报告<block wx:if="{{type==2}}">({{total}})</block></text>
</view>
</view>
......
......@@ -12,58 +12,6 @@ Page({
headUrl:wx.getStorageSync('headUrl'),
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){
wx.getUserProfile({
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
......
......@@ -24,7 +24,7 @@
<image src="https://crisis.zhiweidata.com/static/avatar.png" lazy-load="true"></image>
</view>
<text class="nickname">微信用户</text>
<text class="level">请登录</text>
<text class="level"> </text>
</view>
</view>
......@@ -54,9 +54,6 @@
<view wx:if="{{isLogin}}">
<button class="logout-btn" bindtap="logout">退出登录</button>
</view>
<view wx:else>
<button open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" class="login-btn">点此登录</button>
</view>
</view>
......
......@@ -5,11 +5,11 @@ const imgURL = baseURL+'/app/'
const request = function(url,options){
wx.getStorageSync('token')
let token = wx.getStorageSync('token')
if(url!='/mobile/login' && !token){
wx.reLaunch({
url: '/pages/login/login',
})
}
// if(url!='/mobile/login' && !token){
// wx.reLaunch({
// url: '/pages/login/login',
// })
// }
return new Promise((resolve,reject)=>{
wx.request({
url:baseURL+url,
......@@ -20,8 +20,26 @@ const request = function(url,options){
'token': token
},
success: (res) => {
if (res) {
if (res.data.code == 200) {
resolve(res)
} else if(res.data.code == 401 || res.data.code == 402){
//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({
......@@ -45,7 +63,7 @@ const request = function(url,options){
// get
export const getRequest = (url, data) => {
wx.showNavigationBarLoading()
// wx.showNavigationBarLoading()
return request(url,{
method:"GET",
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