A 分享朋友圈,添加收藏

master
educoder_weapp 4 years ago
parent bf9169a08d
commit 222e364f48

@ -85,7 +85,11 @@ const sceneDescMap = {
1146: "地理位置信息打开出行类小程序", 1146: "地理位置信息打开出行类小程序",
1148: "卡包-交通卡,打开小程序", 1148: "卡包-交通卡,打开小程序",
1150: "扫一扫商品条码结果页打开小程序", 1150: "扫一扫商品条码结果页打开小程序",
1153: '“识物”结果页打开小程序' 1153: '“识物”结果页打开小程序',
1154:'朋友圈内打开“单页模式”',
1155:'“单页模式”打开小程序',
1169:'发现栏小程序主入口,各个生活服务入口(例如快递服务、出行服务等)'
} }
function getFormatTime(date){ function getFormatTime(date){
date = date || new Date(); date = date || new Date();

@ -116,7 +116,7 @@ async function clearPageHistory({Time}){
const pageHistoryCollection = db.collection(collectionNameMap.pageHistory); const pageHistoryCollection = db.collection(collectionNameMap.pageHistory);
let res = await pageHistoryCollection.where({ let res = await pageHistoryCollection.where({
time: _lt(timeEnd) time: _.lt(timeEnd)
}).remove(); }).remove();
console.log("remove page History result: ", res); console.log("remove page History result: ", res);

@ -176,6 +176,42 @@ App({
}else }else
return true; return true;
}, },
addToFavorites({title, query, imageUrl}={}){
let db = wx.cloud.database();
let data = {
title,
imageUrl,
query,
scene: this.globalData.scene,
version: config.version,
time: db.serverDate()
}
db.collection("shareInfo").add({
type:"addToFavorites",
data
});
return {
title, query, imageUrl
}
},
shareTimeline({title, query, imageUrl}={}){
let db = wx.cloud.database();
let data = {
title,
imageUrl,
query,
scene: this.globalData.scene,
version: config.version,
time: db.serverDate()
}
db.collection("shareInfo").add({
type:"shareTimeline",
data
});
return {
title, query, imageUrl
}
},
shareApp({ imageUrl, path, title="EduCoder教学"}={}) { shareApp({ imageUrl, path, title="EduCoder教学"}={}) {
let db = wx.cloud.database(); let db = wx.cloud.database();
let shareInfo = { let shareInfo = {
@ -183,7 +219,7 @@ App({
imageUrl, imageUrl,
path path
} }
if (config.envVersion == 'release') { if (config.envVersion == 'release'&&!this.globalData.isCrawl) {
if (!path) { if (!path) {
let pages = getCurrentPages(); let pages = getCurrentPages();
let page = pages[pages.length - 1]; let page = pages[pages.length - 1];
@ -201,7 +237,8 @@ App({
time: db.serverDate() time: db.serverDate()
} }
console.log("upload", data); console.log("upload", data);
db.collection("shareAppInfo").add({ db.collection("shareInfo").add({
type:"shareAppMessage",
data data
}); });
} }
@ -210,7 +247,7 @@ App({
}); });
// 兼容finally // 兼容Promise.finally
if(!Promise.prototype.finally){ if(!Promise.prototype.finally){
Promise.prototype.finally = function (callback) { Promise.prototype.finally = function (callback) {
let P =this.constructor; let P =this.constructor;

@ -14,7 +14,8 @@
"pages/main/main", "pages/main/main",
"pages/findmore/findmore", "pages/findmore/findmore",
"pages/home/home", "pages/home/home",
"pages/tidings/tidings" "pages/tidings/tidings",
"competition/pages/competition/competition"
], ],
"subpackages": [ "subpackages": [
{ {
@ -183,5 +184,7 @@
}, },
"sitemapLocation": "sitemap.json", "sitemapLocation": "sitemap.json",
"themeLocation": "theme.json", "themeLocation": "theme.json",
"style": "v2" "lazyCodeLoading": "requiredComponents",
"style": "v2",
"debug":true
} }

@ -0,0 +1,15 @@
import apiConfig from "../js/apiConfig"
Object.assign(apiConfig,
{
competitions:{
common_header:{url:"{identifier}/*"},
competition_staff:{url:"{identifier}/*"},
competition_modules:{url:"{identifier}/*/{module_id}"},
}
})
export default apiConfig;

@ -0,0 +1,61 @@
import apiConfig from "../../apiConfig"
Page({
data: {
},
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
onShareTimeline:function(){
},
onShareAppMessage: function () {
}
})

@ -0,0 +1,2 @@
<!--miniprogram/competition/pages/competition/competition.wxml-->
<text>miniprogram/competition/pages/competition/competition.wxml</text>

@ -0,0 +1 @@
/* miniprogram/competition/pages/competition/competition.wxss */

@ -100,6 +100,7 @@ Page({
this.navBack({level}); this.navBack({level});
}, },
onLoad(){ onLoad(){
wx.showLoading({title:"加载中"});
app.cloudapi("reportPageHistory")({ app.cloudapi("reportPageHistory")({
page: this.route, page: this.route,
options: this.options, options: this.options,
@ -111,11 +112,14 @@ Page({
this.api("shixuns.repository")().then(res=>{ this.api("shixuns.repository")().then(res=>{
console.log(res); console.log(res);
this.setData(res); this.setData(res);
}) }).finally(()=>{
wx.hideLoading();
})
}).catch(e=>{ }).catch(e=>{
wx.showToast({ wx.showToast({
title: '获取失败',icon:"none" title: '获取失败',icon:"none"
}) });
wx.hideLoading();
}) })
}, },

@ -65,7 +65,7 @@ Page({
}).catch(e=>{ }).catch(e=>{
//app.showError(e); //app.showError(e);
var title = '提交失败'; var title = '提交失败';
//if(e.code==-2) //if(e.code==-2)//@todo: unknow error!
// title = '您未作答任何题'; // title = '您未作答任何题';
showToast({ showToast({
title, title,
@ -75,6 +75,7 @@ Page({
db.collection("data").add({ db.collection("data").add({
data: { data: {
name: "exercises.commit_exercise", name: "exercises.commit_exercise",
message:e.message,
e, e,
createdAt: db.serverDate() createdAt: db.serverDate()
} }

@ -97,6 +97,20 @@ Page({
return e; return e;
}) })
}, },
onAddToFavorites:function(){
let {subject} = this.data;
return app.addToFavorites({
title: "「实践课程」"+subject.name,
imageUrl: global.config.eduUrl + "/" + subject.cover
})
},
onShareTimeline:function(){
let {subject} = this.data;
return app.shareTimeline({
title: "「实践课程」"+subject.name,
imageUrl: global.config.eduUrl + "/" + subject.cover
})
},
onShareAppMessage: function () { onShareAppMessage: function () {
let {subject} = this.data; let {subject} = this.data;

@ -109,11 +109,25 @@ Page({
}) })
}).catch(e=>{ }).catch(e=>{
app.showError(e); app.showError(e);
wx.hideShareMenu();
}); });
this.pullChallenges().catch(e=>{ this.pullChallenges().catch(e=>{
}); });
}, },
onAddToFavorites:function(){
return app.addToFavorites({
title: "「实训项目」"+this.data.shixun.name,
imageUrl: global.config.eduImgDir+"avatars/Shixun/"+this.data.shixun.id
});
},
onShareTimeline:function(){
return app.shareTimeline({
title: "「实训项目」"+this.data.shixun.name,
imageUrl: global.config.eduImgDir+"avatars/Shixun/"+this.data.shixun.id
});
},
onShareAppMessage: function () { onShareAppMessage: function () {
return app.shareApp({ return app.shareApp({

@ -82,6 +82,6 @@
<view class="version-wrp"> <view class="version-wrp">
<view bindtap="enterGitrepo" bindlongpress="onTapVersion" class="git-repo"> <view bindtap="enterGitrepo" bindlongpress="onTapVersion" class="git-repo">
<iconfont class="icon" type="git" size="20" fontsize="14"/>参与开源贡献 {{version}} <iconfont class="icon" type="git" size="20" fontsize="14"/>点击参与开源 {{version}}
</view> </view>
</view> </view>

@ -82,10 +82,10 @@
"scene": null "scene": null
}, },
{ {
"id": 6, "id": 2,
"name": "course/pages/course/course", "name": "course/pages/course/course",
"pathName": "course/pages/course/course", "pathName": "course/pages/course/course",
"query": "course_id=7582&module_type=students", "query": "course_id=7845&module_type=students",
"scene": null "scene": null
}, },
{ {
@ -134,7 +134,7 @@
"id": 9, "id": 9,
"name": "markdown/shixun/shixun/shixun", "name": "markdown/shixun/shixun/shixun",
"pathName": "markdown/shixun/shixun/shixun", "pathName": "markdown/shixun/shixun/shixun",
"query": "identifier=8bu9zmjy", "query": "identifier=nyrk9xep",
"scene": 1000 "scene": 1000
}, },
{ {

Loading…
Cancel
Save