U 管理界面浏览历史支持筛选

master
educoder_weapp 5 years ago
parent 11478a31b2
commit f3cb7b10ed

@ -1,3 +1,7 @@
## v0.16.9
* A 管理界面浏览历史查看
* A 使用一些功能时登录校验
## v0.16.8
* A 支持填入微信个人信息
* F 使用用户名登录时账号判断错误而无法登录

@ -0,0 +1,30 @@
Component({
properties: {
data:Object
},
data: {
},
methods: {
onTapBody(){
let {options, page} = this.data.data;
let query = Object.keys(options).map(i=>`${i}=${options[i]}`).join("&");
let url = "/"+page + "?" + query;
console.log(url)
wx.navigateTo({
url
})
},
onTapKey(e){
let {currentTarget:{dataset:{key}}} = e;
console.log(e);
let data = this.data.data[key];
let detail = {[key]: data};
console.log(detail);
this.triggerEvent("condition", detail, {bubbles: true});
}
}
})

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

@ -0,0 +1,16 @@
<view class="history {{data.isCrawl?'crawl':''}}" bindtap="onTapBody">
<view class="header" >
<text>{{data.time_show}} </text> {{data.isCrawl?'爬虫访问':""}}
</view>
<view class="body">
<text data-key="page" catchtap="onTapKey">{{data.page_show}} </text>
<text data-key="options" catchtap="onTapKey"> {{data.options_show}}</text>
</view>
<view class="single-line" data-key="scene" catchtap="onTapKey">
{{data.scene}} {{data.sceneDesc}}
</view>
<view class="detail" data-key="openid" catchtap="onTapKey">
{{data.openid}}
</view>
</view>

@ -0,0 +1,19 @@
.history{
background: white;
padding: 12px;
border-radius: 8px;
}
.history.crawl{
border: 2px green solid;
}
.header,
.detail{
color: dimgray;
font-size: 12px;
}
.single-line{
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
}

@ -49,7 +49,17 @@ Page({
let {page,limit} = this.options;
let skip = (page-1)*limit;
console.log(skip, limit);
let res = await pageHistoryCollection.orderBy("time", "desc").skip(skip).limit(limit).get();
let query = pageHistoryCollection;
if(this.data.conditions){
query = query.where(this.data.conditions);
}
if(refresh){
query.count().then(res=>{
console.log(res);
this.setData({total: res.total});
})
}
let res = await query.orderBy("time", "desc").skip(skip).limit(limit).get();
let data = res.data.map(i=>{
i.time_show = getFormatDatetime(i.time);
i.options_show = JSON.stringify(i.options);
@ -77,6 +87,31 @@ Page({
})
})
},
onConditionChange(e){
let {detail} = e;
console.log(e);
console.log(detail);
let conditions = {...this.data.conditions, ...detail};
this.setData({conditions});
this.refresh({refresh:1})
.then(res=>{
wx.showToast({
title:"筛选成功"
})
})
},
deleteCondition(e){
console.log(e);
let {currentTarget:{dataset:{key}}} = e;
let conditions = this.data.conditions;
delete conditions[key];
this.setData({conditions});
this.refresh({refresh:1}).then(res=>{
wx.showToast({
title: '去除成功'
})
})
},
onReady: function () {
},
@ -94,6 +129,7 @@ Page({
},
onPullDownRefresh: function () {
this.conditions = null;
this.refresh({refresh:1});
},

@ -1,5 +1,7 @@
{
"usingComponents": {},
"usingComponents": {
"history-item":"./history-item/history-item"
},
"enablePullDownRefresh": true,
"onReachBottomDistance": 260,
"navigationBarTitleText": "访问记录"

@ -1,21 +1,15 @@
<view class="list">
<view class="history {{item.isCrawl?'crawl':''}}" wx:for="{{data}}" wx:key="_id">
<view class="header">
{{item.time_show}} {{item.isCrawl?'爬虫访问':""}}
</view>
<view class="body">
{{item.page_show}}
{{item.options_show}}
</view>
<view class="single-line">
{{item.scene}} {{item.sceneDesc}}
</view>
<view class="detail">
{{item.openid}}
<view class="top-sticky flex-row">
<view class="item" wx:for="{{conditions}}" data-key="{{index}}" bindtap="deleteCondition">
{{index}}
</view>
</view>
<view class="list">
<view class="history-item-wrp" wx:for="{{data}}" bindcondition="onConditionChange">
<history-item data="{{item}}"/>
</view>
</view>
<view class="sticky footer">
<button type="main" bindtap="subscribe">订阅({{total}})</button>
<view class="footer">
<button wx:if="{{false}}" type="main" bindtap="subscribe">订阅({{total}})</button>
<button type="main" bindtap="onPullDownRefresh">刷新({{total}})</button>
<button type="secondary" bindtap="deleteMine">删除我的</button>
</view>

@ -1,31 +1,31 @@
page{
height: 100%;
}
.list{
min-height: 100vh;
}
.history{
.top-sticky{
position: sticky;
top: 0;
overflow-x: scroll;
background: white;
padding: 12px;
margin: 10px;
border-radius: 8px;
}
.history.crawl{
border: 2px green solid;
}
.header,
.detail{
color: dimgray;
.top-sticky>.item{
margin: 4px;
padding: 4px 8px;
background: #00b0f0;
color: white;
font-size: 12px;
border-radius: 50px;
}
.list{
padding-bottom: 40px;
}
.history-item-wrp{
margin-bottom: 10px
}
.footer{
display: flex;
bottom: 0;
position: fixed;
}
.footer>button{
flex: 1;
border-radius: 0;
}
.sticky{
bottom: 0;
position: sticky;
}

@ -170,7 +170,7 @@ App({
content,
success:res=>{
if(res.confirm)
app.navigateTo({url:"{account}"})
this.navigateTo({url:"{account}"})
}
})
}

@ -1,6 +1,6 @@
const cloudDir = "cloud://educoder.6564-educoder-1300855313/";
let _version = "0.16.8";
let _version = "0.16.9";
/**
*/
let { miniProgram:{ envVersion="release", version=_version}={}} = wx.getAccountInfoSync();

@ -31,7 +31,7 @@
color: white;
font-size:13px;
border-radius: 5px;
padding: 17px 2px 11px 8px;
padding: 18px 3px 12px 8px;
position: relative;
overflow: hidden;
}

Loading…
Cancel
Save