zx 3 years ago
commit 83b316d005

@ -54,7 +54,6 @@ function splitQueryParams(params, key) {
}();
App({
onLaunch: function () {
this.autoUpdate();
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())

@ -31,9 +31,6 @@ Component({
sType: 'Marketing'
}).then(res => {
wx.setStorageSync('newTime', res)
this.setData({
newTime: wx.getStorageSync('newTime')
})
resolve(true)
}).catch(() => {
reject(false)
@ -95,9 +92,11 @@ Component({
})
},
Rankdetail() {
this.getTimeData().then(() => {
wx.navigateTo({
url: "/pages/index/Salesranking/Salesranking"
})
})
},
//品牌排行
ranking() {
@ -106,8 +105,10 @@ Component({
// url: '/pages/mine/pages/bindUser/index'
// })
// } else {
wx.navigateTo({
url: "/pages/index/Salesranking/Brandranking/Brandranking"
this.getTimeData().then(() => {
wx.navigateTo({
url: "/pages/index/Salesranking/Brandranking/Brandranking"
})
})
// }
},
@ -118,9 +119,12 @@ Component({
// url: '/pages/mine/pages/bindUser/index'
// })
// } else {
wx.navigateTo({
url: "/pages/index/Salesranking/Salesranking"
this.getTimeData().then(() => {
wx.navigateTo({
url: "/pages/index/Salesranking/Salesranking"
})
})
// }
}

@ -1,5 +1,11 @@
// 地区分布
export default function pictographicOption(dRegion=[],dValue=[]){
export default function pictographicOption(dRegion = [], dValue = []) {
if(dRegion.length < 5) {
let n = 5 - dRegion.length;
for(let i = 0; i < n; i++) {
dRegion.push('')
}
}
return {
tooltip: {
trigger: "item",
@ -13,60 +19,61 @@ export default function pictographicOption(dRegion=[],dValue=[]){
extraCssText: "box-shadow: 0px 0px 10px 0px #3373CC;",
confine: true
},
xAxis: {
show:false,
type:'value'
},
yAxis:
{
data: dRegion,
inverse: true,
axisTick: { show: false },
axisLine: { show: false },
axisLabel: {
margin: 10,
color: '#333333',
fontSize: 12
}
},
grid: {
// top: 'center',
bottom:20,
height:186,
width:48,
left: 60,
},
series: [
{
itemStyle:{
normal:{
color:'#0084FF',
barBorderRadius:12
},
},
// current data
type: 'bar',
barWidth:10,
data:dValue,
label: {
show: true,
formatter: function (params) {
return (params.value).toFixed(1) + ' %';
},
// position: 'right',
// offset: [20, 0],
xAxis: {
show: false,
type: 'value'
},
yAxis:
{
data: dRegion,
axisTick: { show: false },
axisLine: { show: false },
inverse: true,
axisLabel: {
margin: 10,
color: '#333333',
fontSize: 12,
position:[60,-1]
},
fontSize: 12
}
},
grid: {
// top: 'center',
top: 'top',
bottom: 20,
height: 186,
width: 48,
left: 60,
},
series: [
{
itemStyle: {
normal: {
color: '#0084FF',
barBorderRadius: 12
},
},
// current data
type: 'bar',
barWidth: 10,
data: dValue,
label: {
show: true,
formatter: function (params) {
return (params.value).toFixed(1) + ' %';
},
// position: 'right',
// offset: [20, 0],
color: '#333333',
fontSize: 12,
position: [60, -1]
},
showBackground: true,
backgroundStyle: {
color: 'rgba(180, 180, 180, 0.2)'
},
markLine: {
symbol: 'none',
},
},
]
}
color: 'rgba(180, 180, 180, 0.2)'
},
markLine: {
symbol: 'none',
},
},
]
}
}

@ -33,11 +33,11 @@ export default function pictographicOption(dRegion = [], dValue = [], dSum = 0)
}
},
grid: {
top: '10%',
bottom: 20,
top: '10%',
bottom: 5,
height: 186,
width: 48,
left: 60,
left: 55,
},
series: [{
itemStyle: {

@ -36,9 +36,9 @@ export default function pictographicOption(dRegion = [], dValue = [], dSum = 0)
}
},
grid: {
height: 186,
width: '50%',
left: 'center',
height: 186,
left:'23%',
},
series: [{
itemStyle: {

@ -20,9 +20,18 @@ Component({
},
lifetimes: {
attached() {
wx.setStorageSync('sTimeType', '34');
wx.setStorageSync('sStartTime', '');
wx.setStorageSync('sEndTime', '');
let st = wx.getStorageSync('sTimeType')
if (st) {
let n = this.data.valList.findIndex(ele => ele == st);
this.setData({
intervalSel: n
})
} else {
wx.setStorageSync('sTimeType', 34);
wx.setStorageSync('sStartTime', '');
wx.setStorageSync('sEndTime', '');
}
}
},
methods: {

@ -52,7 +52,7 @@
<view class="area_box">
<view class="top-title">
<view style="width: 45%;">论坛正面话题对比</view>
<view style="width:50%;margin-right: 32rpx;">
<view style="width:50%;margin-right: 32rpx; ">
<van-tabs type="card" active="{{ positiveActive }}" color="#BBBBBB" bind:change="positiveChange">
<van-tab title="组一"></van-tab>
<van-tab title="组二" wx:if="{{bbsInfoData.length>2}}"></van-tab>
@ -61,7 +61,7 @@
</view>
</view>
<view wx:for="{{positive}}" wx:key="{{item.name}}">
<view style="margin-left: 32rpx;">{{item.name}}</view>
<view style="margin:10px 32rpx 0 32rpx">{{item.name}}</view>
<view style="width:686rpx;height:486rpx;margin-top: -50px;">
<c-echars showChart="{{showChart}}" canvasId="region-canvas1" chartId="regionbar1" chartOption="{{item.func}}" height="100%"></c-echars>
</view>
@ -80,7 +80,7 @@
</view>
</view>
<view wx:for="{{negative}}" wx:key="{{item.name}}">
<view style="margin-left: 32rpx;">{{item.name}}</view>
<view style="margin:10px 32rpx 0 32rpx">{{item.name}}</view>
<view style="width:686rpx;height:486rpx;margin-top: -50px;">
<c-echars showChart="{{showChart}}" canvasId="region-canvas1" chartId="regionbar1" chartOption="{{item.func}}" height="100%"></c-echars>
</view>

@ -94,5 +94,5 @@
height: 970rpx;
background:#ffffff;
border-radius: 8rpx;
padding-top:32rpx;
padding:32rpx 0;
}

@ -152,7 +152,6 @@ Component({
obj.func = pieOption(['#FF4852', '#FF6E25', '#FFBF00', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF'], i)
newData.push(obj)
}
console.log(newData);
this.setData({
weiboDist: newData
})
@ -193,11 +192,13 @@ Component({
newRes.push(obj)
}
newRes = newRes.map(ele => {
ele.func = [pictographicOption(ele.region.slice(0, 5), ele.value.slice(0, 5), ele.sum),
ele.func = [pictographicOption(ele.region.slice(0, 5), ele.value.slice(0, 5), ele.sum,),
pictographicOption(ele.region.slice(5, 10), ele.value.slice(5, 10), ele.sum)
]
return ele
})
console.log('ser',newRes)
this.setData({
area: newRes
})

@ -71,16 +71,15 @@
<view class="top-title">
<view style="width: 45%;">活跃用户信息</view>
</view>
<view wx:for="{{area}}">
<view style="margin-left:32rpx ;">事件一</view>
<view class="chart_box" style="margin-top: -100rpx;">
<view style="float:left;width:342rpx;height:486rpx;">
<view wx:for="{{area}}" wx:for-index='indedx'>
<view style="margin:10px 32rpx 0 32rpx">{{indedx==0?"事件一":"事件二"}}</view>
<view class="chart_box" style="margin-top:-60rpx;">
<view style="float:left;width:342rpx;height:400rpx;">
<c-echars showChart="{{showChart}}" canvasId="region-canvas1" chartId="regionbar1" chartOption="{{item.func[0]}}" height="100%"></c-echars>
</view>
<view style="float:right;width:342rpx;height:486rpx;">
<view style="float:right;width:342rpx;height:400rpx;">
<c-echars showChart="{{showChart}}" canvasId="region-canvas1" chartId="regionbar1" chartOption="{{item.func[1]}}" height="100%"></c-echars>
</view>
</view>
</view>
</view>

@ -1,7 +1,7 @@
.chart_box{
margin-top: 24rpx;
width: 686rpx;
height: 486rpx;
height: 400rpx;
padding-top:32rpx ;
background: white;
}
@ -70,10 +70,10 @@
.area_box{
margin-top: 24rpx;
width: 686rpx;
height: 970rpx;
height: 880rpx;
background:#ffffff;
border-radius: 8rpx;
padding-top:32rpx;
padding:32rpx 0;
}
.event_distribution{
height: 894rpx;

@ -61,9 +61,8 @@
</view>
</view>
<view wx:for="{{positive}}" wx:key="{{item.name}}">
<view style="margin-left: 32rpx;height: 30px;line-height: 30px;">{{item.name}}</view>
<!---->
<view style="width:686rpx;height:486rpx; margin: -50px 0 0px 0;padding-bottom: 20px; ">
<view style="margin-left: 32rpx;">{{item.name}}</view>
<view style="width:686rpx;height:470rpx; margin: -50px 0 0px 0;padding-bottom: 10px; ">
<c-echars showChart="{{showChart}}" canvasId="region-canvas1" chartId="regionbar1" chartOption="{{item.func}}" height="100%"></c-echars>
</view>
</view>
@ -82,7 +81,7 @@
</view>
<view wx:for="{{negative}}" wx:key="{{item.name}}">
<view style="margin-left: 32rpx;">{{item.name}}</view>
<view style="width:686rpx;height:486rpx;margin: -50px 0 0px 0;padding-bottom: 20px; ">
<view style="width:686rpx;height:470rpx;margin: -50px 0 0px 0;padding-bottom: 10px; ">
<c-echars showChart="{{showChart}}" canvasId="region-canvas1" chartId="regionbar1" chartOption="{{item.func}}" height="100%"></c-echars>
</view>
</view>

@ -95,12 +95,12 @@
</view>
</view>
<view wx:for="{{area}}">
<view style="margin-left:32rpx ;height: 40rpx;line-height: 40rpx;">{{item.name}}</view>
<view class="chart_box" style="margin-top: -100rpx;">
<view style="float:left;width:342rpx;height:486rpx;">
<view style="margin:10px 32rpx 0 32rpx">{{item.name}}</view>
<view class="chart_box1" style="margin-top: -60rpx;">
<view style="float:left;width:342rpx;height:400rpx;">
<c-echars showChart="{{showChart}}" canvasId="region-canvas1" chartId="regionbar1" chartOption="{{item.func[0]}}" height="100%"></c-echars>
</view>
<view style="float:right;width:342rpx;height:486rpx;">
<view style="float:right;width:342rpx;height:400rpx;">
<c-echars showChart="{{showChart}}" canvasId="region-canvas1" chartId="regionbar1" chartOption="{{item.func[1]}}" height="100%"></c-echars>
</view>

@ -5,6 +5,13 @@
padding:32rpx 0;
background: white;
}
.chart_box1{
margin-top: 24rpx;
width: 686rpx;
height: 400rpx;
padding:32rpx 0;
background: white;
}
.chart_box1{
margin-top: 24rpx;

@ -1 +1,47 @@
@import '../common/index.wxss';.van-tree-select{display:flex;font-size:var(--tree-select-font-size,14px);position:relative;-webkit-user-select:none;user-select:none}.van-tree-select__nav{--sidebar-padding:12px 8px 12px 12px;background-color:var(--tree-select-nav-background-color,#f7f8fa);flex:1}.van-tree-select__nav__inner{height:100%;width:100%!important}.van-tree-select__content{background-color:var(--tree-select-content-background-color,#fff);flex:2}.van-tree-select__item{font-weight:700;line-height:var(--tree-select-item-height,44px);padding:0 32px 0 var(--padding-md,16px);position:relative}.van-tree-select__item--active{color:var(--tree-select-item-active-color,#ee0a24)}.van-tree-select__item--disabled{color:var(--tree-select-item-disabled-color,#c8c9cc)}.van-tree-select__selected{position:absolute;right:var(--padding-md,16px);top:50%;transform:translateY(-50%)}
@import '../common/index.wxss';
.van-tree-select {
display: flex;
font-size: var(--tree-select-font-size, 14px);
position: relative;
-webkit-user-select: none;
user-select: none
}
.van-tree-select__nav {
--sidebar-padding: 12px 8px 12px 12px;
background-color: var(--tree-select-nav-background-color, #f7f8fa);
flex: 1
}
.van-tree-select__nav__inner {
height: 100%;
width: 100% !important
}
.van-tree-select__content {
background-color: var(--tree-select-content-background-color, #fff);
flex: 2
}
.van-tree-select__item {
font-weight: 700;
line-height: var(--tree-select-item-height, 44px);
padding: 0 32px 0 var(--padding-md, 16px);
position: relative
}
.van-tree-select__item--active {
color: var(--tree-select-item-active-color, #ee0a24)
}
.van-tree-select__item--disabled {
color: var(--tree-select-item-disabled-color, #c8c9cc)
}
.van-tree-select__selected {
position: absolute;
right: var(--padding-md, 16px);
top: 50%;
transform: translateY(-50%)
}

@ -10,13 +10,14 @@ let iPageIndex = 1 // 当前第几页,0代表第一页
let iPageSize = 20 //每页显示多少数据
Page({
data: {
nengtitle1: '全部级别',
nengtitle2: '全部价格',
nengtitle3: '全部能源',
active: 0,
end: moment().format("YYYY-MM"),
showChart: true,
// select: false,
grade_value1: "",
grade_value2: "",
grade_value3: "",
grade_value4: 0,
grades4: [{
text: '列表展示',
@ -39,7 +40,7 @@ Page({
//图表
// positiveOption:brokenLine(dName,dValue,dColor,data),
imageUrl: getApp().globalData.imageUrl,
date: wx.getStorageSync('newTime'),
date: '',
accountIndex: 0,
ranking: [],
accountIndex: 0,
@ -48,15 +49,14 @@ Page({
sEnergyType: '',
imageUrl: getApp().globalData.imageUrl,
mockData: [],
show1: false,
mainActiveIndex: 0,
mainActiveIndex2:0,
mainActiveIndex2: 0,
activeId: '',
activeId2: '',
//
ec: {
lazyLoad: true // 设置图表懒加载
},
showvalue:false,
},
// 标签切换点击事件
onChange(val) {
@ -173,8 +173,6 @@ Page({
},
//页面上拉触底事件的处理函数
onReachBottom: function () {
// console.log("上拉触底事件")
// console.log(iPageIndex)
let that = this
if (!that.data.loadMore) {
that.setData({
@ -207,7 +205,7 @@ Page({
}
obj.children.push(ol)
})
}
}
arr.push(obj)
})
this.setData({
@ -250,7 +248,7 @@ Page({
}
obj.children.push(ol)
})
}
}
arr.push(obj)
})
this.setData({
@ -266,33 +264,18 @@ Page({
this.data.builds = e.detail.val
}
},
// 按级别
mySelect1(e) {
iPageIndex = 1
iPageSize = 20
this.setData({
ranking: [],
sSpec: e.detail,
})
this.getTrend()
},
// 按价格
mySelect2(e) {
iPageIndex = 1
iPageSize = 20
this.setData({
ranking: [],
sPriceType: e.detail,
})
this.getTrend()
},
// 按能源
mySelect3(e) {
mySelect2({ detail }) {
iPageIndex = 1
iPageSize = 20
let n = 0;
if(detail) {
n = detail * 1;
}
this.setData({
ranking: [],
sEnergyType: e.detail,
sPriceType: this.data.grades2[n].value,
nengtitle2:this.data.grades2[n].text,
})
this.getTrend()
},
@ -303,7 +286,7 @@ Page({
this.setData({
ranking: [],
a: e.detail != 0,
showvalue:false
showvalue: false
})
this.getTrend()
},
@ -315,9 +298,9 @@ Page({
let dj = this.data.num % 2 == 0
this.setData({
ranking: [],
grade_value1: "",
grade_value2: "",
grade_value3: "",
nengtitle1: '全部级别',
nengtitle2: '全部价格',
nengtitle3: '全部能源',
sSpec: '',
sPriceType: '',
sEnergyType: '',
@ -393,6 +376,9 @@ Page({
*/
onShow() {
iPageIndex = 1;
this.setData({
date: wx.getStorageSync('newTime')
})
// this.getTabBar().init();
this.getData()
},
@ -404,52 +390,80 @@ Page({
})
},
// 树形结构父级点击
onClickNav({ detail = {} }) {
// 按能源
onClickNav({
detail = {}
}) {
this.setData({
mainActiveIndex: detail.index || 0,
mainActiveIndex: detail.index || 0,
});
let {grades3} = this.data;
if(!grades3[detail.index].children) {
let {
grades3
} = this.data;
if (!grades3[detail.index].children) {
this.setData({
ranking: [],
sEnergyType:grades3[detail.index].id || "",
sEnergyType: grades3[detail.index].id || "",
nengtitle3: grades3[detail.index].text,
})
this.selectComponent('#menuitem2').toggle(false);
this.getTrend()
}
}
},
onClickNav2({ detail = {} }) {
// 按级别
onClickNav2({
detail = {}
}) {
this.setData({
mainActiveIndex2: detail.index || 0,
mainActiveIndex2: detail.index || 0,
});
let {grades1} = this.data;
console.log('xds',grades1[detail.index])
if(!grades1[detail.index].children) {
let {
grades1
} = this.data;
if (!grades1[detail.index].children) {
this.setData({
ranking: [],
sSpec: grades1[detail.index].id || "",
nengtitle1: grades1[detail.index].text,
})
this.selectComponent('#menuitem1').toggle(false);
this.getTrend()
}
},
// 树形结构子级点击
// 按能源
onClickItem({
detail = {}
}) {
const activeId = this.data.activeId === detail.id ? null : detail.id;
let {
mainActiveIndex
} = this.data;
this.setData({
ranking: [],
activeId,
nengtitle3: detail.text,
sEnergyType: mainActiveIndex + "," + activeId,
// 树形结构子级点击
onClickItem({ detail = {} }) {
const activeId = this.data.activeId === detail.id ? null : detail.id;
let {mainActiveIndex} = this.data;
this.setData({
ranking: [],
sEnergyType: mainActiveIndex+","+activeId,
});
this.getTrend()
},
onClickItem2({ detail = {} }) {
const activeId = this.data.activeId === detail.id ? null : detail.id;
let {mainActiveIndex2} = this.data;
this.setData({
ranking: [],
sSpec: mainActiveIndex2+","+activeId,
});
this.getTrend()
},
});
this.selectComponent('#menuitem2').toggle(false);
this.getTrend()
},
// 按级别
onClickItem2({
detail = {}
}) {
const activeId2 = this.data.activeId2 === detail.id ? null : detail.id;
let {
mainActiveIndex2
} = this.data;
this.setData({
ranking: [],
activeId2,
nengtitle1: detail.text,
sSpec: mainActiveIndex2 + "," + activeId2,
});
this.selectComponent('#menuitem1').toggle(false);
this.getTrend()
},
})

@ -24,12 +24,12 @@
</scroll-view>
<view style="height: 60rpx;margin-top: 10px;">
<van-dropdown-menu custom-class="dropdown-menu" active-color="#027AFF;">
<van-dropdown-item value="{{ grade_value1 }}" title="全部级别">
<van-tree-select items="{{ grades1 }}" main-active-index="{{ mainActiveIndex2 }}" active-id="{{ activeId }}" bind:click-nav="onClickNav2" bind:click-item="onClickItem2"/>
<van-dropdown-item id="menuitem1" title="{{nengtitle1}}">
<van-tree-select items="{{ grades1 }}" main-active-index="{{ mainActiveIndex2 }}" active-id="{{ activeId2 }}" bind:click-nav="onClickNav2" bind:click-item="onClickItem2" />
</van-dropdown-item>
<van-dropdown-item value="{{ grade_value2 }}" options="{{ grades2 }}" bind:change="mySelect2" title="全部价格" />
<van-dropdown-item value="{{ grade_value3 }}" title="全部能源">
<van-tree-select items="{{ grades3 }}" main-active-index="{{ mainActiveIndex }}" active-id="{{ activeId }}" bind:click-nav="onClickNav" bind:click-item="onClickItem"/>
<van-dropdown-item value="{{ grade_value2 }}" options="{{ grades2 }}" bind:change="mySelect2" title="{{nengtitle2}}" />
<van-dropdown-item id="menuitem2" title="{{nengtitle3}}">
<van-tree-select items="{{ grades3 }}" main-active-index="{{ mainActiveIndex }}" active-id="{{ activeId }}" bind:click-nav="onClickNav" bind:click-item="onClickItem" />
</van-dropdown-item>
<van-dropdown-item value="{{ grade_value4 }}" options="{{ grades4 }}" bind:change="mySelect4" />
</van-dropdown-menu>

@ -2,13 +2,15 @@
.dropdown-menu {
box-shadow: 0 0 0 !important;
}
.detail-page {
position: relative;
position: relative;
}
.van-dropdown-menu__item{
border: 1px solid #F9F9F9;
position: relative;
margin:10rpx;
.van-dropdown-menu__item {
border: 1px solid #F9F9F9;
position: relative;
margin: 10rpx;
}
.menu-tabs .van-tabs__nav {
@ -283,13 +285,14 @@
}
/* 下拉内容 */
van-dropdown-item van-dropdown-item--down{
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
van-dropdown-item van-dropdown-item--down {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.select_box {
background-color: #fff;
/* padding: 0 20rpx; */
@ -341,8 +344,17 @@ van-dropdown-item van-dropdown-item--down{
text-align: center;
border-radius: 50rpx;
}
.jb-item{
.jb-item {
font-size: 20rpx;
height: 30px;
line-height: 30px;
}
.show {
display: none;
}
.is_show {
display: block;
}

@ -228,6 +228,7 @@ Page({
sStartTime: result.detail.sStartTime,
sEndTime: result.detail.sEndTime,
});
console.log('xs', result.detail.sTimeType)
this.getData();
},
toEventDetail(e) {
@ -333,7 +334,7 @@ Page({
sCrisis: wjList.join(',') || '',
sType: 'BrandData',
sField: JSON.stringify(sField), //导出字段
sFileName: "事件数据" + date, //文件名称
sFileName: this.data.fileName, //文件名称
sCheckedIds: this.data.result.join(',') || '', //数据id
iNum: this.data.result.length == 0 ? this.data.total : this.data.result.length, //导出条数
iTimeType: this.data.iTimeType, //0发布时间 1入库时间

@ -332,7 +332,7 @@ Component({
sCrisis: wjList.join(',') || '',
sType: 'BrandDataHot',
sField: JSON.stringify(sField), //导出字段
sFileName: "事件数据" + date, //文件名称
sFileName: this.data.fileName, //文件名称
sCheckedIds: this.data.result.join(',') || '', //数据id
iNum: this.data.result.length == 0 ? this.data.total : this.data.result.length, //导出条数
iTimeType: this.data.iTimeType, //0发布时间 1入库时间

@ -333,7 +333,7 @@ Page({
sCrisis: wjList.join(',') || '',
sType: 'BrandData',
sField: JSON.stringify(sField), //导出字段
sFileName: "事件数据" + date, //文件名称
sFileName: this.data.fileName, //文件名称
sCheckedIds: this.data.result.join(',') || '', //数据id
iNum: this.data.result.length == 0 ? this.data.total : this.data.result.length, //导出条数
iTimeType: this.data.iTimeType, //0发布时间 1入库时间

@ -427,7 +427,7 @@ Page({
sType: 'ZhuTiFenXiBl',
sGuid: this.data.Guid,
sField: JSON.stringify(sField), //导出字段
sFileName: "事件数据" + date, //文件名称
sFileName:this.data.fileName, //文件名称
sCheckedIds: this.data.result.join(',') || '', //数据id
iNum: this.data.result.length == 0 ? this.data.total : this.data.result.length, //导出条数
iTimeType: this.data.iTimeType, //0发布时间 1入库时间

@ -1,5 +1,5 @@
// index.js
const app = getApp()
Page({
data: {
imageUrl: getApp().globalData.imageUrl,
@ -7,7 +7,10 @@ Page({
statusBarHeight: 0,
nickName: "未登录",
avatarUrl: "",
btnShow: false
btnShow: false,
userName: '',
headImg: '',
fileList: []
},
onLoad: function () {
wx.getSystemInfo({
@ -23,19 +26,52 @@ Page({
this.getTabBar().init();
this.getUser();
},
// 上传头像的验证
beforeRead(event) {
const { file, callback } = event.detail;
callback(file.type === 'image');
},
// 上传图片
afterRead(event) {
const { file } = event.detail;
let url = file.url;
let base64 = wx.getFileSystemManager().readFileSync(url, "base64");
let unionID = wx.getStorageSync('unionID');
if(!unionID) {
return false;
}
let obj = {
action: 'updImg',
unionID: unionID,
base64: base64,
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
}
app.globalData.request(obj).then(res => {
let userInfo = wx.getStorageSync("userInfo");
userInfo.headImg = res;
wx.setStorageSync('userInfo', userInfo);
this.setData({
headImg: res
})
})
},
getUser() {
if(wx.getStorageSync("userInfo")) {
let userInfo = wx.getStorageSync("userInfo");
this.setData({
nickName: userInfo.nickName,
avatarUrl: userInfo.avatarUrl,
userName: userInfo.UserName,
headImg: userInfo.headImg,
btnShow: true
})
} else {
this.setData({
nickName: '',
avatarUrl: '',
btnShow: false
btnShow: false,
headImg: '',
userName: ''
})
}
},

@ -1,12 +1,14 @@
<view class="box" style="{{bgImage}}">
<!-- style="margin-top:{{statusBarHeight*2}}rpx" -->
<view class="mine_title">
<view class="title_left" style="margin-left: 32rpx;">
<view style="font-size:48rpx;font-weight:600;">{{nickName}}</view>
<view class="title_left">
<view style="font-size:48rpx;font-weight:600;">{{userName}}</view>
<view style="font-size:24rpx; color: #9b9999;margin-top: 24rpx;"> 欢迎您使⽤硕为思平台</view>
</view>
<view class="title_right" style="margin-right: 32rpx;">
<van-image round width="128rpx" height="128rpx" fit='cover' src="{{avatarUrl}}"/>
<view class="title_right">
<van-uploader file-list="{{ fileList }}" max-count="1" bind:before-read="beforeRead" bind:after-read="afterRead" deletable="{{false}}">
<van-image icon="photo" round width="128rpx" height="128rpx" fit='cover' src="{{headImg}}"/>
</van-uploader>
</view>
</view>
<view class="content">

@ -7,9 +7,9 @@
height: 330px;
}
.mine_title{
width: 100%;
width: calc(100% -64rpx);
display: flex;
padding-top: 208rpx;
padding: 208rpx 32rpx 0rpx 32rpx;
justify-content: space-between;
}

@ -41,7 +41,7 @@ Page({
},
onShow() {
let userInfo = wx.getStorageSync('userInfo');
if(userInfo) {
if (userInfo) {
this.setData({
userName: userInfo.UserName || userInfo.userName
})
@ -49,13 +49,22 @@ Page({
},
// 微信用户初始化
initData() {
let that = this;
return new Promise((resolve, reject) => {
this.getUserCode().then(() => {
this.getOpenidByCode().then(() => {
resolve(true)
}).catch(err => {
console.log(err)
})
wx.login({
success(res) {
that.setData({
code: res.code
})
that.getOpenidByCode().then(() => {
resolve(true)
}).catch(err => {
console.log(err)
})
},
fail() {
reject(false)
}
})
})
},
@ -145,11 +154,13 @@ Page({
const userInfo = Object.assign({}, res, {
nickName: this.data.nickName,
avatarUrl: this.data.avatarUrl,
userName: this.data.userName
userName: this.data.userName,
headImg: res.headImg
})
wx.setStorageSync('token', res.toKen);
wx.setStorageSync('userInfo', userInfo);
wx.setStorageSync('openid', this.data.openid);
wx.setStorageSync('unionID', this.data.unionID);
wx.navigateBack({
delta: 1
});
@ -158,11 +169,13 @@ Page({
let data = err.Data;
const userInfo = Object.assign({}, data, {
nickName: this.data.nickName,
avatarUrl: this.data.avatarUrl
avatarUrl: this.data.avatarUrl,
userName: this.data.userName,
})
wx.setStorageSync('token', data.toKen);
wx.setStorageSync('userInfo', userInfo);
wx.setStorageSync('openid', this.data.openid);
wx.setStorageSync('unionID', this.data.unionID);
wx.showModal({
title: '提示',
content: '登录成功,但未关注公众号。',
@ -186,20 +199,20 @@ Page({
})
},
//注册
register(){
register() {
wx.navigateTo({
url: '/pages/mine/pages/register/register',
url: '/pages/mine/pages/register/register',
})
},
handlerBack() {
if(this.data.isHome == 1) {
if (this.data.isHome == 1) {
wx.switchTab({
url: '/pages/index/index'
url: '/pages/index/index'
})
} else if(this.data.isHome == 3) {
} else if (this.data.isHome == 3) {
wx.switchTab({
url: '/pages/mine/index'
})
})
} else {
wx.navigateBack({
delta: 1

Loading…
Cancel
Save