F 课堂邀请页面小程序码获取失败 F 每日签到完后按钮没有变灰

master
educoder_weapp 4 years ago
parent ffbea46001
commit 80b7d665e4

@ -1,3 +1,7 @@
## v0.19.2
* F 课堂邀请页面小程序码获取失败
* F 每日签到完后按钮没有变灰
## v0.19.1 ## v0.19.1
* U 个人中心界面优化 * U 个人中心界面优化
* U 主题色加深 * U 主题色加深

@ -137,36 +137,10 @@ exports.main = async (event, context) => {
sceneDesc: sceneDescMap[data.scene], sceneDesc: sceneDescMap[data.scene],
time: now, time: now,
timestamp: Date.now(), timestamp: Date.now(),
openid: wxContext.OPENID openid: wxContext.OPENID,
_openid: wxContext.OPENID
} }
}); });
try{
console.log(sceneDescMap[data.scene].slice(0,31),now.toLocaleTimeString());
let result = await cloud.openapi.subscribeMessage.send({
touser: 'oqugK431bepFwW6TGrHpQTerPkI0',
page: 'admin/pages/page_history/page_history',
lang: 'zh_CN',
templateId: 'atZ4ZFfGIPxTiFGTCtkwvnfqjBA-fM7o1p5OiJQA_0Y',
miniprogramState: 'trial',
data: {
character_string1:{
value:"pageHistory" //服务器
},
character_string2:{
value: (data.route||data.page).match(/\/([^\/]*$)/)[1] //数据类型
},
thing4:{
value:sceneDescMap[data.scene].slice(0,20) //添加内容
},
date3:{
value:getFormatTime(now)
}
}
})
console.log(result);
}catch(e){
console.error(e);
}
return res; return res;
} }

@ -19,7 +19,9 @@ const collectionNameMap = {
const PagePathMap = { const PagePathMap = {
shixun:"markdown/shixun/shixun/shixun", shixun:"markdown/shixun/shixun/shixun",
path:"markdown/path/path/path" path:"markdown/path/path/path",
mooc_case:"markdown/mooc_case/mooc_case/mooc_case",
competition:"markdown/competition/competition/competition"
} }
@ -40,75 +42,48 @@ exports.main = async (event, context) => {
} }
} }
async function submitPages({Time}){ async function submitPage({route, timeStart, timeEnd}){
console.log("start submitPages");
const db = cloud.database(); const db = cloud.database();
const _ = db.command; const _ = db.command;
const pageHistoryCollection = db.collection(collectionNameMap.pageHistory); const pageHistoryCollection = db.collection(collectionNameMap.pageHistory);
let shixunPath = PagePathMap.shixun; let data = await pageHistoryCollection.aggregate()
let pathPath = PagePathMap.path; .match({
let timeEnd = new Date(Time); page: route,
let timeStart = new Date(timeEnd.getTime() - config.submitPagesGapDay*milliSecondsPerDay);
let shixunResult = await pageHistoryCollection.where({
page: shixunPath,
status: 200, status: 200,
isCrawl: false, isCrawl: false,
time: _.lt(timeEnd).and(_.gte(timeStart)) time: _.lt(timeEnd).and(_.gte(timeStart))
}).get(); })
.group({
_id:"$options"
})
.end();
let pathResult = await pageHistoryCollection.where({ if(data.list.length==0)
page: pathPath, return "empty history: " + route;
status: 200, let pages = data.list.map(i=>{
isCrawl: false, let query = Object.keys(i._id).map(k=>`${k}=${i._id[k]}`).join("&");
time:_.lt(timeEnd).and(_.gte(timeStart))
}).get();
let shixunQueries = shixunResult.data.reduce(function(arr, v){
var query = Object.keys(v.options).map(k=>`${k}=${v.options[k]}`).join("&");
if(arr.indexOf(query)==-1)
arr.push(query);
return arr
},[]);
let pathQueries = pathResult.data.reduce(function(arr, v){
var query = Object.keys(v.options).map(k=>`${k}=${v.options[k]}`).join("&");
if(arr.indexOf(query)==-1)
arr.push(query);
return arr
},[]);
console.info("shixunQueries", shixunQueries.length, shixunQueries);
console.info("pathQueries", pathQueries.length, pathQueries);
if(shixunQueries.length>0){
var pages = shixunQueries.map(i=>{
return { return {
path: shixunPath, path: route,
query: i query
} }
}); })
var res = await cloud.openapi.search.submitPages({pages}); let res = await cloud.openapi.search.submitPages({pages});
console.log("submit shixun pages",pages.length, res); console.log("submit pages success", route, pages.length, res, pages);
console.info("arguments", pages); return "submit success: " + route + " " + pages.length;
}else{ }
console.warn("no shixun history");
} async function submitPages({Time}){
if(pathQueries.length>0){ let timeEnd = new Date(Time);
var pages = pathQueries.map(i=>{ let timeStart = new Date(timeEnd.getTime() - config.submitPagesGapDay*milliSecondsPerDay);
return { // pages to be submitted
path: pathPath, let routes = [
query: i "shixun", "path", "mooc_case", "competition"
} ]
}); let promises = routes.map(i=>{
var res = await cloud.openapi.search.submitPages({pages}); return submitPage({route: PagePathMap[i], timeStart, timeEnd})
console.log("submit path pages success", pages.length, res); })
console.info("arguments", pages); return Promise.all(promises)
}else{
console.warn("no path history");
}
return {code:0, message:"success"};
} }
async function clearPageHistory({Time}){ async function clearPageHistory({Time}){

@ -1,4 +1,5 @@
<navigator class="item-container" hover-class="none" url="/markdown/competition/competition/competition?identifier={{data.identifier}}"> <navigator class="item-container" hover-class="none"
url="/markdown/competition/competition/competition?identifier={{data.identifier}}">
<view class="image-wrp" catchtap="previewImage"> <view class="image-wrp" catchtap="previewImage">
<image class="item-image" lazy-load mode="heightFix" src="{{eduUrl}}/{{data.image}}"></image> <image class="item-image" lazy-load mode="heightFix" src="{{eduUrl}}/{{data.image}}"></image>
</view> </view>

@ -0,0 +1,23 @@
// components/home-notice/home-notice.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

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

@ -0,0 +1,2 @@
<!--components/home-notice/home-notice.wxml-->
<text>components/home-notice/home-notice.wxml</text>

@ -0,0 +1 @@
/* components/home-notice/home-notice.wxss */

@ -1,6 +1,6 @@
const cloudDir = "cloud://educoder.6564-educoder-1300855313/"; const cloudDir = "cloud://educoder.6564-educoder-1300855313/";
let _version = "0.19.1"; let _version = "0.19.2";
let { miniProgram:{ envVersion="release", version=_version}={}} = wx.getAccountInfoSync(); let { miniProgram:{ envVersion="release", version=_version}={}} = wx.getAccountInfoSync();
version = version||_version; version = version||_version;
@ -19,7 +19,7 @@ export function switchEnv(env) {
} }
else if (env == "trial") { else if (env == "trial") {
eduUrl = trialUrl; eduUrl = trialUrl;
config.version = "体验版 " + version; config.version = version+" 体验版";
} }
else { else {
eduUrl = releaseUrl; eduUrl = releaseUrl;

@ -17,6 +17,7 @@ Page({
eduImgDir:global.config.eduImgDir eduImgDir:global.config.eduImgDir
}, },
onImgLoad(e){ onImgLoad(e){
console.log("imageload", e);
this.setData({code_loaded:1}); this.setData({code_loaded:1});
}, },
onImgError(e){ onImgError(e){
@ -24,8 +25,14 @@ Page({
let scene = this.getScene(); let scene = this.getScene();
wx.cloud.callFunction({ name: "openapi", data: { name:"wxacode.getUnlimited", data:{page, scene}}}) wx.cloud.callFunction({ name: "openapi", data: { name:"wxacode.getUnlimited", data:{page, scene}}})
.then(res=>{ .then(res=>{
this.setData({invite_code_url:""}); let t = new Date().getTime();
this.setData({invite_code_url: res.result.fileID||res.result}) wx.cloud.getTempFileURL({
fileList:[res.result.fileID],
success:res=>{
console.log(res)
this.setData({invite_code_url: res.fileList[0].tempFileURL+"?t="+t})
}
})
}); });
}, },
login:function(){ login:function(){
@ -119,6 +126,9 @@ Page({
if(this.data.status==-1) if(this.data.status==-1)
this.pull_course() this.pull_course()
}, },
onReady(){
app.reportPageHistory();
},
onShareAppMessage(){ onShareAppMessage(){
let {course} = this.data; let {course} = this.data;
return app.shareApp({ return app.shareApp({

@ -79,15 +79,7 @@ Page({
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
title:"实践课程-"+res[0].name title:"实践课程-"+res[0].name
}) })
app.cloudapi("reportPageHistory")({ app.reportPageHistory()
page: this.route,
options: this.options,
status: 200,
scene: app.globalData.scene
}).catch(e=>{
global.realTimeLog.error("report history error", e);
wx.reportMonitor('2', 1);
})
return res; return res;
}).catch(e=>{ }).catch(e=>{
if(e.code==403) if(e.code==403)

@ -98,15 +98,7 @@ Page({
let current = cateTypes[cate_type]; let current = cateTypes[cate_type];
this.setData({identifier, current}); this.setData({identifier, current});
this.pullShixun().then(res=>{ this.pullShixun().then(res=>{
app.cloudapi("reportPageHistory")({ app.reportPageHistory();
page: this.route,
options: this.options,
status: 200,
scene: app.globalData.scene
}).catch(e=>{
global.realTimeLog.error("report history error", e);
wx.reportMonitor('2', 1);
})
}).catch(e=>{ }).catch(e=>{
app.showError(e); app.showError(e);
wx.hideShareMenu(); wx.hideShareMenu();

@ -1,4 +1,5 @@
<navigator class="item-container" hover-class="none" url="/markdown/mooc_case/mooc_case/mooc_case?mooc_case_id={{data.id}}"> <navigator class="item-container" hover-class="none"
url="/markdown/mooc_case/mooc_case/mooc_case?mooc_case_id={{data.id}}">
<image class="item-image" lazy-load mode="aspectFill" src="{{eduUrl}}{{data.cover_url||default_cover}}"></image> <image class="item-image" lazy-load mode="aspectFill" src="{{eduUrl}}{{data.cover_url||default_cover}}"></image>
<view class="item-detail"> <view class="item-detail">
<view>{{data.title}}<text wx:for="{{data.tags}}" class="tag {{item.id==1?'award':''}}">{{item.name}}</text></view> <view>{{data.title}}<text wx:for="{{data.tags}}" class="tag {{item.id==1?'award':''}}">{{item.name}}</text></view>

@ -180,7 +180,7 @@ Page({
data: this.data.auto_attendance, data: this.data.auto_attendance,
}); });
}, },
updateGold({gold, duration}){ updateGold({gold, duration=2500}){
let {grade} = this.data.user; let {grade} = this.data.user;
if(grade >= gold) if(grade >= gold)
return console.log(new Date().getTime()) return console.log(new Date().getTime())
@ -199,12 +199,28 @@ Page({
attendance({ show = 1 }={}) { attendance({ show = 1 }={}) {
if(!app.checkLogin({content:"您需要登陆后才能签到获取金币"})) if(!app.checkLogin({content:"您需要登陆后才能签到获取金币"}))
return; return;
if(this.data.user.attendance_signed){
if(show)
wx.showToast({
title: '您已经签到过了',icon:"none"
});
return;
}
app.api("users.attendance")() app.api("users.attendance")()
.then(res => { .then(res => {
res.message = "签到成功"; res.message = "签到成功";
if (show) if (show)
app.showMsg(res); app.showMsg(res);
let {grade} = res; let {grade} = res;
var db = wx.cloud.database();
db.collection("res").add({
data:{
...res,
name: "users.attendance",
createAt: db.serverDate()
}
})
this.setData({"user.attendance_signed": true});
this.updateGold({gold: grade}) this.updateGold({gold: grade})
}).catch(e=>{ }).catch(e=>{
if(show) if(show)

@ -29,10 +29,10 @@
</view> </view>
<view class="flex-col experience-item"> <view class="flex-col experience-item">
<view class="key" bindtap="attendance">金币</view> <view class="key attendance" bindtap="attendance">金币</view>
<view class="value" bindtap="attendance"> <view class="value attendance" bindtap="attendance">
{{user.grade||0}} {{user.grade||0}}
<iconfont type="qiandao" color="{{user.attendance_signed?'#ffffff77':'#FEB532'}}" /> <iconfont class="attendance-icon" type="qiandao" color="{{user.attendance_signed?'#ffffff77':'#FEB532'}}" />
</view> </view>
</view> </view>
</view> </view>
@ -136,8 +136,9 @@
<iconfont class="icon" color="#0080f0" type="kefu" size="21" />小程序客服 <iconfont class="icon" color="#0080f0" type="kefu" size="21" />小程序客服
<iconfont type="jinru" color="lightgrey" size="15" class="enter"></iconfont> <iconfont type="jinru" color="lightgrey" size="15" class="enter"></iconfont>
</button> </button>
<navigator class="nav gap" url="/setting/pages/setting/setting"> <navigator bindlongpress="onTapVersion" class="nav gap" url="/setting/pages/setting/setting">
<iconfont type="shezhi" color="#0080f0" class="icon" size="21"/>设置 <iconfont type="shezhi" color="#0080f0" class="icon" size="21"/>设置
<text class="tip">v{{version}}</text>
<iconfont type="jinru" color="lightgrey" size="15" class="enter"/> <iconfont type="jinru" color="lightgrey" size="15" class="enter"/>
</navigator> </navigator>
<!--navigator url="/markdown/account/about/about" class="nav about gap"> <!--navigator url="/markdown/account/about/about" class="nav about gap">
@ -157,7 +158,7 @@
</view> </view>
<view class="version-wrp"> <view class="version-wrp">
<view bindtap="enterGitrepo" bindlongpress="onTapVersion" class="git-repo"> <view bindtap="enterGitrepo" class="git-repo">
<iconfont class="icon" type="git" size="20" fontsize="14"/>点击参与开源 {{version}} <iconfont class="icon" type="git" size="14"/>参与开源
</view> </view>
</view> </view>

@ -67,6 +67,9 @@
.experience-item>.value{ .experience-item>.value{
font-size: 15px; font-size: 15px;
} }
.attendance-icon{
transition: all 0.6s ease;
}
/*经验展示结束*/ /*经验展示结束*/
@ -93,7 +96,7 @@
width: 100%; width: 100%;
height: 50%; height: 50%;
z-index: -100; z-index: -100;
border-radius: 0 0 24% 24%; border-radius: 0 0 20% 20%;
} }
.whitebox{ .whitebox{
width: 94%; width: 94%;
@ -102,7 +105,7 @@
justify-content: space-between; justify-content: space-between;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: #e0e0e0 0px 0px 5px; box-shadow: #e0e0e0 0px 0px 5px;
padding: 25rpx 0rpx; padding: 24rpx 0rpx;
} }
.box_context{ .box_context{
display: flex; display: flex;

@ -1,6 +1,22 @@
{ {
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [ "rules": [
{
"action":"allow",
"page":"markdown/mooc_case/mooc_case",
"params":[
"mooc_case_id"
],
"matching":"inclusive"
},
{
"action":"allow",
"page":"markdown/competition/competition",
"params":[
"identifier"
],
"matching":"inclusive"
},
{ {
"action":"allow", "action":"allow",
"page":"markdown/path/path/path", "page":"markdown/path/path/path",

@ -225,7 +225,7 @@
"id": 22, "id": 22,
"name": "course_invite", "name": "course_invite",
"pathName": "course/pages/course_invite/course_invite", "pathName": "course/pages/course_invite/course_invite",
"query": "course_id=7845", "query": "course_id=8275",
"scene": null "scene": null
}, },
{ {

Loading…
Cancel
Save