From 6d9f522b3fc5a044e8c7aff0ec312229813a6c69 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Mon, 9 Sep 2019 11:08:55 +0800 Subject: [PATCH] share --- public/react/src/App.js | 6 +- public/react/src/common/educoder.js | 2 + public/react/src/common/util/ShareUtil.js | 78 +++++++++++++++++++++++ 3 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 public/react/src/common/util/ShareUtil.js diff --git a/public/react/src/App.js b/public/react/src/App.js index d156bc241..942316bde 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -327,11 +327,11 @@ class App extends Component { wx.ready(function () { console.log('wx is ready') var shareData = { - title: 'EduCoder', - desc: '创新源于实践', + title: 'EduCoder - 首页', + desc: 'Educoder是一个面向计算机类的互联网IT教育和实战平台,提供企业级工程实训,以实现工程化专业教学的自动化和智能化。高校和企业人员可以在此开展计算机实践性教学活动,将传统的知识传授和时兴的工程实战一体化。', link: currentUrl, imgUrl: window.__testImageUrl - || (currentUrl.endsWith('/') ? currentUrl : currentUrl + '/') + 'images/educoder/index/subject/subject15.jpg' + || (currentUrl.endsWith('/') ? currentUrl : currentUrl + '/') + 'react/build/images/share_logo_icon.jpg' }; wx.onMenuShareAppMessage(shareData);//分享给好友 diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js index 5b1d7ac28..356a2f370 100644 --- a/public/react/src/common/educoder.js +++ b/public/react/src/common/educoder.js @@ -20,6 +20,8 @@ export { markdownToHTML, uploadNameSizeSeperator, appendFileSizeToUploadFile, ap downloadFile, sortDirections } from './TextUtil' export { handleDateString, getNextHalfHourOfMoment,formatDuring } from './DateUtil' +export { configShareForIndex, configShareForPaths, configShareForShixuns, configShareForCourses, configShareForSinglePath, configShareForSingleShixun } from './util/ShareUtil' + export { isDev as isDev, isMobile } from './Env' export { toStore as toStore, fromStore as fromStore } from './Store' diff --git a/public/react/src/common/util/ShareUtil.js b/public/react/src/common/util/ShareUtil.js new file mode 100644 index 000000000..4886b81e4 --- /dev/null +++ b/public/react/src/common/util/ShareUtil.js @@ -0,0 +1,78 @@ +const host = window.location.host +function share(shareData) { + wx.onMenuShareAppMessage(shareData);//分享给好友 + wx.onMenuShareTimeline(shareData);//分享到朋友圈 + wx.onMenuShareQQ(shareData);//分享给手机QQ + wx.onMenuShareWeibo(shareData);//分享腾讯微博 + wx.onMenuShareQZone(shareData);//分享到QQ空间 +} +/** + 实践课程 平台提供涵盖基础入门、案例实践和创新应用的完整实训项目体系,通过由浅入深的实训路径,帮助学生快速提升实战能力。 + 实训项目 覆盖不同专业的IT实验和实训,每周更新,无需配置本机实验环境,随时随地开启企业级真实实训。 + 翻转课堂 自动评测实训任务,支持技能统计,提供教学活动分析报告,减轻教师和助教的辅导压力,免去作业发布和批改的困扰,实时了解学生学习情况,全面提升教师施教效率和水平。 + 单个课程和实训 获取课程/实训的简介 该课程或者实训展示的缩略图 + + */ +export function configShareForIndex () { + var shareData = { + title: 'EduCoder - 首页', + desc: 'Educoder是一个面向计算机类的互联网IT教育和实战平台,提供企业级工程实训,以实现工程化专业教学的自动化和智能化。高校和企业人员可以在此开展计算机实践性教学活动,将传统的知识传授和时兴的工程实战一体化。', + link: host, + imgUrl: window.__testImageUrl + || host + '/react/build/images/share_logo_icon.jpg' + }; + share(shareData) +} +export function configShareForPaths () { + var shareData = { + title: 'EduCoder - 实践课程', + desc: '平台提供涵盖基础入门、案例实践和创新应用的完整实训项目体系,通过由浅入深的实训路径,帮助学生快速提升实战能力。', + link: `${host}/paths`, + imgUrl: window.__testImageUrl + || host + '/react/build/images/share_logo_icon.jpg' + }; + share(shareData) +} +export function configShareForShixuns () { + var shareData = { + title: 'EduCoder - 实训项目', + desc: '覆盖不同专业的IT实验和实训,每周更新,无需配置本机实验环境,随时随地开启企业级真实实训。', + link: `${host}/shixuns`, + imgUrl: window.__testImageUrl + || host + '/react/build/images/share_logo_icon.jpg' + }; + share(shareData) +} +export function configShareForCourses () { + var shareData = { + title: 'EduCoder - 翻转课堂', + desc: '自动评测实训任务,支持技能统计,提供教学活动分析报告,减轻教师和助教的辅导压力,免去作业发布和批改的困扰,实时了解学生学习情况,全面提升教师施教效率和水平。', + link: `${host}/courses`, + imgUrl: window.__testImageUrl + || host + '/react/build/images/share_logo_icon.jpg' + }; + share(shareData) +} + +// detail +export function configShareForSinglePath (title, desc, path, imgUrl) { + var shareData = { + title: title, + desc: desc, + link: `${host}/${path}`, + imgUrl: imgUrl || window.__testImageUrl + || host + '/react/build/images/share_logo_icon.jpg' + }; + share(shareData) +} + +export function configShareForSingleShixun (title, desc, path, imgUrl) { + var shareData = { + title: title, + desc: desc, + link: `${host}/${path}`, + imgUrl: imgUrl || window.__testImageUrl + || host + '/react/build/images/share_logo_icon.jpg' + }; + share(shareData) +} \ No newline at end of file