diff --git a/config/routes.rb b/config/routes.rb index 5a9b749b8..e92440ae7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -776,6 +776,10 @@ Rails.application.routes.draw do end post 'callbacks/aliyun_vod', to: 'callbacks/aliyun_vods#create' + + namespace :wechats do + resource :js_sdk_signature, only: [:create] + end end namespace :admins do @@ -884,10 +888,6 @@ Rails.application.routes.draw do end end - namespace :wechats do - resource :js_sdk_signature, only: [:create] - end - #git 认证回调 match 'gitauth/*url', to: 'gits#auth', via: :all diff --git a/public/javascripts/wx/jweixin-1.3.0.js b/public/javascripts/wx/jweixin-1.3.0.js new file mode 100644 index 000000000..d06d2c362 --- /dev/null +++ b/public/javascripts/wx/jweixin-1.3.0.js @@ -0,0 +1 @@ +!function(e,n){"function"==typeof define&&(define.amd||define.cmd)?define(function(){return n(e)}):n(e,!0)}(this,function(e,n){function i(n,i,t){e.WeixinJSBridge?WeixinJSBridge.invoke(n,o(i),function(e){c(n,e,t)}):u(n,t)}function t(n,i,t){e.WeixinJSBridge?WeixinJSBridge.on(n,function(e){t&&t.trigger&&t.trigger(e),c(n,e,i)}):t?u(n,t):u(n,i)}function o(e){return e=e||{},e.appId=C.appId,e.verifyAppId=C.appId,e.verifySignType="sha1",e.verifyTimestamp=C.timestamp+"",e.verifyNonceStr=C.nonceStr,e.verifySignature=C.signature,e}function r(e){return{timeStamp:e.timestamp+"",nonceStr:e.nonceStr,package:e.package,paySign:e.paySign,signType:e.signType||"SHA1"}}function a(e){return e.postalCode=e.addressPostalCode,delete e.addressPostalCode,e.provinceName=e.proviceFirstStageName,delete e.proviceFirstStageName,e.cityName=e.addressCitySecondStageName,delete e.addressCitySecondStageName,e.countryName=e.addressCountiesThirdStageName,delete e.addressCountiesThirdStageName,e.detailInfo=e.addressDetailInfo,delete e.addressDetailInfo,e}function c(e,n,i){"openEnterpriseChat"==e&&(n.errCode=n.err_code),delete n.err_code,delete n.err_desc,delete n.err_detail;var t=n.errMsg;t||(t=n.err_msg,delete n.err_msg,t=s(e,t),n.errMsg=t),(i=i||{})._complete&&(i._complete(n),delete i._complete),t=n.errMsg||"",C.debug&&!i.isInnerInvoke&&alert(JSON.stringify(n));var o=t.indexOf(":");switch(t.substring(o+1)){case"ok":i.success&&i.success(n);break;case"cancel":i.cancel&&i.cancel(n);break;default:i.fail&&i.fail(n)}i.complete&&i.complete(n)}function s(e,n){var i=e,t=v[i];t&&(i=t);var o="ok";if(n){var r=n.indexOf(":");"confirm"==(o=n.substring(r+1))&&(o="ok"),"failed"==o&&(o="fail"),-1!=o.indexOf("failed_")&&(o=o.substring(7)),-1!=o.indexOf("fail_")&&(o=o.substring(5)),"access denied"!=(o=(o=o.replace(/_/g," ")).toLowerCase())&&"no permission to execute"!=o||(o="permission denied"),"config"==i&&"function not exist"==o&&(o="ok"),""==o&&(o="fail")}return n=i+":"+o}function d(e){if(e){for(var n=0,i=e.length;n0){var n=e.split("?")[0],i=e.split("?")[1];return n+=".html",void 0!==i?n+"?"+i:n}}if(!e.jWeixin){var h={config:"preVerifyJSAPI",onMenuShareTimeline:"menu:share:timeline",onMenuShareAppMessage:"menu:share:appmessage",onMenuShareQQ:"menu:share:qq",onMenuShareWeibo:"menu:share:weiboApp",onMenuShareQZone:"menu:share:QZone",previewImage:"imagePreview",getLocation:"geoLocation",openProductSpecificView:"openProductViewWithPid",addCard:"batchAddCard",openCard:"batchViewCard",chooseWXPay:"getBrandWCPayRequest",openEnterpriseRedPacket:"getRecevieBizHongBaoRequest",startSearchBeacons:"startMonitoringBeacons",stopSearchBeacons:"stopMonitoringBeacons",onSearchBeacons:"onBeaconsInRange",consumeAndShareCard:"consumedShareCard",openAddress:"editAddress"},v=function(){var e={};for(var n in h)e[h[n]]=n;return e}(),S=e.document,I=S.title,y=navigator.userAgent.toLowerCase(),_=navigator.platform.toLowerCase(),w=!(!_.match("mac")&&!_.match("win")),T=-1!=y.indexOf("wxdebugger"),k=-1!=y.indexOf("micromessenger"),M=-1!=y.indexOf("android"),P=-1!=y.indexOf("iphone")||-1!=y.indexOf("ipad"),x=function(){var e=y.match(/micromessenger\/(\d+\.\d+\.\d+)/)||y.match(/micromessenger\/(\d+\.\d+)/);return e?e[1]:""}(),V={initStartTime:p(),initEndTime:0,preVerifyStartTime:0,preVerifyEndTime:0},A={version:1,appId:"",initTime:0,preVerifyTime:0,networkType:"",isPreVerifyOk:1,systemType:P?1:M?2:-1,clientVersion:x,url:encodeURIComponent(location.href)},C={},L={_completes:[]},B={state:0,data:{}};f(function(){V.initEndTime=p()});var O=!1,N=[],b={config:function(e){C=e,u("config",e);var n=!1!==C.check;f(function(){if(n)i(h.config,{verifyJsApiList:d(C.jsApiList)},function(){L._complete=function(e){V.preVerifyEndTime=p(),B.state=1,B.data=e},L.success=function(e){A.isPreVerifyOk=0},L.fail=function(e){L._fail?L._fail(e):B.state=-1};var e=L._completes;return e.push(function(){l()}),L.complete=function(n){for(var i=0,t=e.length;i0){var n=N.shift();wx.getLocalImgData(n)}},e))):N.push(e)},getNetworkType:function(e){var n=function(e){var n=e.errMsg;e.errMsg="getNetworkType:ok";var i=e.subtype;if(delete e.subtype,i)e.networkType=i;else{var t=n.indexOf(":"),o=n.substring(t+1);switch(o){case"wifi":case"edge":case"wwan":e.networkType=o;break;default:e.errMsg="getNetworkType:fail"}}return e};i("getNetworkType",{},(e._complete=function(e){e=n(e)},e))},openLocation:function(e){i("openLocation",{latitude:e.latitude,longitude:e.longitude,name:e.name||"",address:e.address||"",scale:e.scale||28,infoUrl:e.infoUrl||""},e)},getLocation:function(e){e=e||{},i(h.getLocation,{type:e.type||"wgs84"},(e._complete=function(e){delete e.type},e))},hideOptionMenu:function(e){i("hideOptionMenu",{},e)},showOptionMenu:function(e){i("showOptionMenu",{},e)},closeWindow:function(e){i("closeWindow",{},e=e||{})},hideMenuItems:function(e){i("hideMenuItems",{menuList:e.menuList},e)},showMenuItems:function(e){i("showMenuItems",{menuList:e.menuList},e)},hideAllNonBaseMenuItem:function(e){i("hideAllNonBaseMenuItem",{},e)},showAllNonBaseMenuItem:function(e){i("showAllNonBaseMenuItem",{},e)},scanQRCode:function(e){i("scanQRCode",{needResult:(e=e||{}).needResult||0,scanType:e.scanType||["qrCode","barCode"]},(e._complete=function(e){if(P){var n=e.resultStr;if(n){var i=JSON.parse(n);e.resultStr=i&&i.scan_code&&i.scan_code.scan_result}}},e))},openAddress:function(e){i(h.openAddress,{},(e._complete=function(e){e=a(e)},e))},openProductSpecificView:function(e){i(h.openProductSpecificView,{pid:e.productId,view_type:e.viewType||0,ext_info:e.extInfo},e)},addCard:function(e){for(var n=e.cardList,t=[],o=0,r=n.length;oEduCoder diff --git a/public/react/src/App.js b/public/react/src/App.js index eae3630cc..f49ebed12 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -292,7 +292,58 @@ class App extends Component { mydisplay:true, }) }; + initWXShare = () => { + if (window.wx) { + const wx = window.wx + const url = '/wechats/js_sdk_signature.json' + axios.post(url, { + url: 'http://pre-newweb.educoder.net', + }).then((response) => { + const data = response.data; + wx.config({ + debug: false, + appId: data.appid, + timestamp: data.timestamp, + nonceStr: data.nonceStr, + signature: data.signature, + jsApiList: [ + 'onMenuShareTimeline',// + 'onMenuShareAppMessage', + 'onMenuShareQQ', + 'onMenuShareWeibo', + 'onMenuShareQZone' + + ] + }); + wx.ready(function () { + var shareData = { + title: '这是是分享标题', + desc: '这是是摘要', + link: 'http://pre-newweb.educoder.net', + imgUrl: 'http://pre-newweb.educoder.net/images/educoder/index/subject/subject15.jpg' + }; + + wx.onMenuShareAppMessage(shareData);//分享给好友 + wx.onMenuShareTimeline(shareData);//分享到朋友圈 + wx.onMenuShareQQ(shareData);//分享给手机QQ + wx.onMenuShareWeibo(shareData);//分享腾讯微博 + wx.onMenuShareQZone(shareData);//分享到QQ空间 + + + + }); + wx.error(function (res) { + //alert(res.errMsg);//错误提示 + + }); + }).catch((error) => { + console.log(error) + }) + } + } componentDidMount() { + + // force an update if the URL changes history.listen(() => { this.forceUpdate() @@ -302,7 +353,7 @@ class App extends Component { }); initAxiosInterceptors(this.props) - + this.initWXShare() // // axios.interceptors.response.use((response) => { // // console.log("response"+response); diff --git a/public/react/src/common/Env.js b/public/react/src/common/Env.js index bdd4584f4..283e82c48 100644 --- a/public/react/src/common/Env.js +++ b/public/react/src/common/Env.js @@ -1,3 +1,6 @@ export function isDev() { return window.location.port === "3007"; -} \ No newline at end of file +} + +// const isMobile +export const isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase())); \ No newline at end of file diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js index 1d7c66dbb..5b1d7ac28 100644 --- a/public/react/src/common/educoder.js +++ b/public/react/src/common/educoder.js @@ -20,8 +20,7 @@ export { markdownToHTML, uploadNameSizeSeperator, appendFileSizeToUploadFile, ap downloadFile, sortDirections } from './TextUtil' export { handleDateString, getNextHalfHourOfMoment,formatDuring } from './DateUtil' - -export { isDev as isDev } from './Env' +export { isDev as isDev, isMobile } from './Env' export { toStore as toStore, fromStore as fromStore } from './Store' diff --git a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js index d8927b8d7..15f57f130 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js @@ -625,7 +625,7 @@ class CoursesBanner extends Component { ) : ""} - {this.props.isStudent()? this.exitclass()} > 退出课堂 :""} diff --git a/public/react/src/modules/courses/graduation/topics/index.js b/public/react/src/modules/courses/graduation/topics/index.js index b5be57564..ef4257e2e 100644 --- a/public/react/src/modules/courses/graduation/topics/index.js +++ b/public/react/src/modules/courses/graduation/topics/index.js @@ -58,7 +58,7 @@ class Boards extends Component{ let {pageSize}=this.state; const cid = this.props.match.params.coursesId - let url = `/courses/${cid}/graduation_topics.json?limit=`+pageSize + let url = `/courses/${cid}/graduation_topics.json?limit=${pageSize}` if(searchValue!=""){ url+="&search="+searchValue } @@ -68,7 +68,17 @@ class Boards extends Component{ if(status!="" && status != "all"){ url+="&status="+status; } - axios.get(url).then((response) => { + url=encodeURI(url);//IE11传参为乱码(search) + axios.get(url + // ,{ + // params:{ + // search:encodeURI(searchValue), + // page:page, + // status:status, + // limit:pageSize + // } + // } + ).then((response) => { if (response.status == 200 && response.status) { this.setState({ data:response.data, diff --git a/public/react/src/modules/courses/members/modal/AddStudentModal.js b/public/react/src/modules/courses/members/modal/AddStudentModal.js index de95bc741..cf7583a51 100644 --- a/public/react/src/modules/courses/members/modal/AddStudentModal.js +++ b/public/react/src/modules/courses/members/modal/AddStudentModal.js @@ -29,7 +29,7 @@ class AddStudentModal extends Component{ const { name, school_name } = this.state let url = `/courses/${courseId}/search_users.json?page=${page}&limit=${pageCount}&school_name=${school_name || ''}&name=${name || ''}` this.setState({ loading: true }) - axios.get(url) + axios.get(encodeURI(url)) .then((response) => { if (!response.data.users || response.data.users.length == 0) { this.setState({ diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index ee1f1dacb..70b1e3bd6 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -377,7 +377,7 @@ class studentsList extends Component{ if(searchValue!=""){ url+='&search='+searchValue; } - const result = await axios.get(url) + const result = await axios.get(encodeURI(url)) // axios.get((url)).then((result)=>{ if (result.data.teacher_list) { this.setState({ diff --git a/public/react/src/modules/courses/poll/Poll.js b/public/react/src/modules/courses/poll/Poll.js index b395b2bd2..288ac6f2c 100644 --- a/public/react/src/modules/courses/poll/Poll.js +++ b/public/react/src/modules/courses/poll/Poll.js @@ -116,6 +116,7 @@ class Poll extends Component{ if(search!=""&&search!=undefined){ url+="&search="+search } + url=encodeURI(url);//IE11传参为乱码(search) axios.get(url).then((result)=>{ if(result){ this.setState({ diff --git a/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js b/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js index d1bf6e1f0..f3c9d514b 100644 --- a/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js +++ b/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js @@ -160,7 +160,7 @@ class DetailCardsEditAndAdd extends Component{ url+="&type="+id; } - axios.get(url).then((result)=>{ + axios.get(encodeURI(url)).then((result)=>{ if(result.status===200){ this.setState({ ChooseShixunList:result.data, @@ -322,7 +322,7 @@ class DetailCardsEditAndAdd extends Component{ if(type!=0){ url+="&type="+type; } - axios.get(url).then((result)=>{ + axios.get(encodeURI(url)).then((result)=>{ if(result.status===200){ let list =result.data.shixun_list; diff --git a/public/react/src/modules/tpm/TPMBanner.js b/public/react/src/modules/tpm/TPMBanner.js index 0009e1f98..997786db2 100644 --- a/public/react/src/modules/tpm/TPMBanner.js +++ b/public/react/src/modules/tpm/TPMBanner.js @@ -205,7 +205,7 @@ class TPMBanner extends Component { SenttotheSearch=(value)=>{ let id = this.props.match.params.shixunId; let url="/shixuns/" + id +"/search_user_courses.json?search="+value; - axios.get(url, { + axios.get(encodeURI(url), { params: { page:1, limit:10