Commit 883f858c authored by zhangyanni's avatar zhangyanni

测试小程序分享

parent cf7fee4f
......@@ -29,6 +29,7 @@
background-color: #A2A3B7;
}
</style>
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js" type="text/javascript"></script>
<script type="text/javascript">
// H5 plus事件处理
function plusReady() {
......@@ -74,11 +75,6 @@
})
( window, document, "script", "1652422665091079" );
}
if(location.href.indexOf('activitydetail')>-1||location.href.indexOf('phoneRequireDetail')>-1||location.href.indexOf('projectdetails')>-1){
var scriptVal = document.getElementsByTagName("script")[0],jsSrc = document.createElement("script");
jsSrc.src = "https://res.wx.qq.com/open/js/jweixin-1.3.2.js";
scriptVal.parentNode.insertBefore( jsSrc, scriptVal )
}
</script>
</head>
......
......@@ -22,8 +22,10 @@ import zhLang from "./common/lang/zh";
import enLang from './common/lang/en';
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import wx from 'weixin-jsapi';
promise.polyfill();
Vue.prototype.$md5 = md5
Vue.prototype.wx = wx
Vue.prototype.Base64 = require('js-base64').Base64
Vue.use(vueSwiper);
Vue.use(Element);
......@@ -163,7 +165,7 @@ router.beforeEach((to, from, next) => {
}
}
if(window.sessionStorage.getItem("userInfo") ==null){
if(to.name == 'dashboard'||to.name=='indexView'|| to.name == 'login' || to.name == 'mobileLoginCmpt'|| to.name == 'emailLoginCmpt'|| to.name == 'mobileRegisterCmpt'|| to.name == 'emailRegisterCmpt'||to.name=='completeInfoCmpt'|| to.name == 'successCmpt'||to.name=='findPasswordCmpt'||to.name=='modifyPasswordCmpt'||to.name=='passSuccessCmpt'||to.name=='indexView'||to.name=="mobileIndex"||to.name=="mobileLogin"||to.name=="loginByPhone"||to.name=="loginByEmail"||to.name=="mobileRegister"||to.name=="registerComplete"||to.name=="shareRequire"||to.name=="shareProject"||to.name=="knowledgeList"||to.name=="knowledgeDetail"||to.name=='vip'||to.name=='vipList'||to.name=='loadEmail'||to.name=='openEmail'||to.name=="viewRequire"||to.name=="phoneBusinessList"||to.name=="phoneBusinessDetail"||to.name=="phoneRequireDetail"||to.name=="bigBusinessList"||to.name=="bigBusinessDetail"||to.name=="requireDetail"||to.name=="mixSearch"||to.name=="activitylist"||to.name=="activitydetail"||to.name=="activitySearchResult"||to.name=="applyForProject"||to.name=='wechatLogin'||to.name=='newPage'||to.name=='bindAccount'||to.name=='videoPreload'){
if(to.name == 'dashboard'||to.name=='indexView'|| to.name == 'login' || to.name == 'mobileLoginCmpt'|| to.name == 'emailLoginCmpt'|| to.name == 'mobileRegisterCmpt'|| to.name == 'emailRegisterCmpt'||to.name=='completeInfoCmpt'|| to.name == 'successCmpt'||to.name=='findPasswordCmpt'||to.name=='modifyPasswordCmpt'||to.name=='passSuccessCmpt'||to.name=='indexView'||to.name=="mobileIndex"||to.name=="mobileLogin"||to.name=="loginByPhone"||to.name=="loginByEmail"||to.name=="mobileRegister"||to.name=="registerComplete"||to.name=="shareRequire"||to.name=="shareProject"||to.name=="knowledgeList"||to.name=="knowledgeDetail"||to.name=='vip'||to.name=='vipList'||to.name=='loadEmail'||to.name=='openEmail'||to.name=="viewRequire"||to.name=="phoneBusinessList"||to.name=="phoneBusinessDetail"||to.name=="phoneRequireDetail"||to.name=="bigBusinessList"||to.name=="bigBusinessDetail"||to.name=="requireDetail"||to.name=="mixSearch"||to.name=="activitylist"||to.name=="activitydetail"||to.name=="activitySearchResult"||to.name=="applyForProject"||to.name=='wechatLogin'||to.name=='newPage'||to.name=='bindAccount'){
} else{
if(to.path == '/questionfill'||to.path == '/casedetailschild'||to.path == '/lndustryfocuschild'||to.path == '/successfulcasechild'||to.path == '/projectdetails'||to.path == '/seeprojectlist'||to.path == '/projectlist'||to.path == '/viewproject'||to.path == '/templateMobile1'||to.path == '/knowledge'||to.path == '/knowledgedetails'||to.path == '/termserviceed'||to.path == '/privacypolicyed'||to.path == '/contactused'||to.path == '/aboutused'||to.path == '/casedetailsed'||to.path == '/lndustryfocused'||to.path == '/successfulcaseed'||to.path == '/usehelped'||to.path == '/useHelp'||to.path == '/reminder'||to.path == '/contactus' ||to.path == '/privacypolicy' ||to.path == '/termservice' ||to.path == '/casedetails' ||to.path == '/successfulcase' ||to.path == '/lndustryfocus' ||to.path == '/aboutus'||to.path=='/applicationnotice' ){
......
......@@ -59,6 +59,9 @@
<img src="../../../assets/jiantou.gif" alt="">
<p>点击右上角</p>
</div>
<div class="wechatShare" v-if="miniPopupVisible" @click="miniPopupVisible = false">
<minishareCmpt :detailInfo="detailInfo" @showDialogVisible="showDialogVisible"></minishareCmpt>
</div>
</div>
</template>
<script>
......@@ -68,10 +71,9 @@
import qrCmpt from '../../../components/common/qrcodeCmpt';
import publicFunc from '../../../common/public';
import shareCmpt from '../../../components/shareCmpt';
import wx from 'weixin-jsapi';
import minishareCmpt from '../../../components/miniShareCmpt';
import api from './api';
import {Toast,Popup} from 'mint-ui';
// import wxsdk from 'weixin-js-sdk';
export default {
name: "detail",
components:{
......@@ -79,7 +81,8 @@
applyCmpt,
applyProCmpt,
qrCmpt,
shareCmpt
shareCmpt,
minishareCmpt
},
data(){
return {
......@@ -92,11 +95,17 @@
disabledFlag:0,
popupVisible:false,
dialogVisible:false,
miniPopupVisible:false,
config:{}
}
},
methods:{
showDialogVisible(){
this.dialogVisible = true;
},
handleApply(){
let that = this;
let params= this.$route.query.id,arrVal = [];
......@@ -193,7 +202,6 @@
this.detailInfo.channelStartTime = this.detailInfo.channelStartTime.split(":")[0]+":"+this.detailInfo.channelStartTime.split(":")[1];
this.detailInfo.channelEndTime = this.detailInfo.channelEndTime.split(":")[0]+":"+this.detailInfo.channelEndTime.split(":")[1];
this.detailInfo.activityEndTime = this.detailInfo.activityEndTime.split(":")[0]+":"+this.detailInfo.activityEndTime.split(":")[1];
}else{
this.$toast(res.msg);
}
......@@ -206,6 +214,7 @@
handleOpreation(){
var ua = navigator.userAgent.toLowerCase(),that = this;
if(ua.match(/MicroMessenger/i)=="micromessenger") {
alert("分享啦");
that.shareFunc();
} else {
......@@ -308,6 +317,7 @@
})
})
alert(JSON.stringify(wx));
}else{
this.$toast(res.msg);
}
......@@ -317,22 +327,32 @@
},
shareFunc(){
var that = this;
alert("hahahahah 来分享")
this.detailInfo.shareTitle = this.detailInfo.channelTitle;
this.detailInfo.url = document.location.href;
this.dialogVisible = true;
this.popupVisible = false;
wx.ready(function(){
wx.miniProgram.getEnv((res)=>{
if(res.miniprogram){
wx.miniProgram.postMessage({
data: that.detailInfo
})
// true代表在小程序里
// 是否是微信小程序
var userAgent = navigator.userAgent;
var isMini = /miniProgram/i.test(userAgent);
if(isMini){
// this.dialogVisible = false;
// this.miniPopupVisible = true;
wx.miniProgram.postMessage({
data: {
title: "您的好友邀请您参与"+that.detailInfo.channelTitle,
desc: that.detailInfo.channelTitle,
imageUrl:that.detailInfo.channelPic,
path: '/pages/sharepage/sharepage?shareUrl=' + JSON.stringify({url: encodeURIComponent(document.location.href)}) //重点,share.js是小程序的页面中,从分享进入的h5的落地页
}
})
});
wx.miniProgram.navigateBack({delta: 1})
}else{
this.dialogVisible = true;
this.popupVisible = false;
}
})
},
//二维码
......@@ -351,12 +371,16 @@
},
mounted(){
created(){
this.getDetailInfo();
if(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)=="micromessenger") {
this.configFunc();
}
},
mounted(){
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment