Commit 9034a2a3 authored by 郑秀明's avatar 郑秀明

微信分享增加postData,企点客服增加兼容判断

parent 04829869
// 微信分享 公共方法 // 微信分享 公共方法
var jweixin = require('jweixin-module'); // var jweixin = require('jweixin-module');
export default { export default {
// 是否在微信中 // 是否在微信中
...@@ -22,7 +22,7 @@ export default { ...@@ -22,7 +22,7 @@ export default {
success: (res) => { success: (res) => {
const { data } = res; const { data } = res;
if(data.code === 0){ if(data.code === 0){
jweixin.config({ jWeixin.config({
debug: false, debug: false,
appId: data.data.appId, appId: data.data.appId,
timestamp: data.data.timestamp, timestamp: data.data.timestamp,
...@@ -59,7 +59,7 @@ export default { ...@@ -59,7 +59,7 @@ export default {
} }
//每次都需要重新初始化配置,才可以进行分享 //每次都需要重新初始化配置,才可以进行分享
this.initJssdkShare(function(){ this.initJssdkShare(function(){
jweixin.ready(function() { jWeixin.ready(function() {
var shareData = { var shareData = {
title: data && data.title ? data.title : '谛宝多多商城', title: data && data.title ? data.title : '谛宝多多商城',
desc: data && data.desc ? data.desc : '宠物行业一站式B2B采购平台', desc: data && data.desc ? data.desc : '宠物行业一站式B2B采购平台',
...@@ -72,14 +72,35 @@ export default { ...@@ -72,14 +72,35 @@ export default {
cancel: function(res) {} cancel: function(res) {}
}; };
//分享给朋友接口 //分享给朋友接口
jweixin.onMenuShareAppMessage(shareData); jWeixin.onMenuShareAppMessage(shareData);
//分享到朋友圈接口 //分享到朋友圈接口
jweixin.onMenuShareTimeline(shareData); jWeixin.onMenuShareTimeline(shareData);
// 分享到QQ // 分享到QQ
jweixin.onMenuShareQQ(shareData); jWeixin.onMenuShareQQ(shareData);
// 分享到微博 // 分享到微博
jweixin.onMenuShareWeibo(shareData); jWeixin.onMenuShareWeibo(shareData);
}); });
}, url); }, url);
},
// 向小程序发送分享的数据
postData: function(t){
// imgUrl: image || 'https://dbc-static.oss-cn-beijing.aliyuncs.com/wx/logo.jpg'
const postData = {
link: window.location.href,
title: t
}
jWeixin.miniProgram.postMessage({ data: JSON.stringify(postData) });
},
isMini: function(){
jWeixin.miniProgram.getEnv(function (res) {
//获取当前环境
if(res.miniprogram){
// true 在微信小程序中
return true;
}else{
// false 在微信公众号里
return false;
}
});
} }
} }
\ No newline at end of file
...@@ -22,8 +22,9 @@ ...@@ -22,8 +22,9 @@
<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" /> <link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script> <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="https://dbc-static.oss-cn-beijing.aliyuncs.com/dbc-shop/lib/draggabilly.min.js"></script> <script src="https://dbc-static.oss-cn-beijing.aliyuncs.com/dbc-shop/lib/draggabilly.min.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<!-- WPA start --> <!-- WPA start -->
<script id="qd28857712162361a518c852fc82fde1e5eab730ba68" src="https://wp.qiye.qq.com/qidian/2885771216/2361a518c852fc82fde1e5eab730ba68" charset="utf-8" async defer></script> <!-- <script id="qd28857712162361a518c852fc82fde1e5eab730ba68" src="https://wp.qiye.qq.com/qidian/2885771216/2361a518c852fc82fde1e5eab730ba68" charset="utf-8" async defer ></script> -->
<!-- WPA end --> <!-- WPA end -->
</head> </head>
<body> <body>
...@@ -31,7 +32,7 @@ ...@@ -31,7 +32,7 @@
<strong>Please enable JavaScript to continue.</strong> <strong>Please enable JavaScript to continue.</strong>
</noscript> </noscript>
<div id="app"></div> <div id="app"></div>
<div class='draggable is-pointer-down is-dragging' id='qidian_dom'><span></span></div> <div class="draggable is-pointer-down is-dragging" id="qidian_dom" style="display: none;"><span></span></div>
<script> <script>
var _hmt = _hmt || []; var _hmt = _hmt || [];
(function() { (function() {
...@@ -40,6 +41,38 @@ ...@@ -40,6 +41,38 @@
var s = document.getElementsByTagName("script")[0]; var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s); s.parentNode.insertBefore(hm, s);
})(); })();
const ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/micromessenger/i) == 'micromessenger') {
isMiniProgram();
} else {
const dom = document.getElementById('qidian_dom');
dom.style.display = 'block';
const script_dom = document.createElement('script');
script_dom.src = "https://wp.qiye.qq.com/qidian/2885771216/2361a518c852fc82fde1e5eab730ba68";
script_dom.language = 'javascript';
script_dom.id = 'qd28857712162361a518c852fc82fde1e5eab730ba68';
script_dom.type = 'text/javascript';
const head = document.getElementsByTagName('head').item(0);//这个是往本页面动态加载js脚本
head.appendChild(script_dom);
}
function isMiniProgram(){
jWeixin.miniProgram.getEnv(function (res) {
//获取当前环境
const dom = document.getElementById('qidian_dom');
if(res.miniprogram){
dom.style.display = 'none';
}else{
dom.style.display = 'block';
const script_dom = document.createElement('script');
script_dom.src = "https://wp.qiye.qq.com/qidian/2885771216/2361a518c852fc82fde1e5eab730ba68";
script_dom.language = 'javascript';
script_dom.id = 'qd28857712162361a518c852fc82fde1e5eab730ba68';
script_dom.type = 'text/javascript';
const head = document.getElementsByTagName('head').item(0);//这个是往本页面动态加载js脚本
head.appendChild(script_dom);
}
});
}
var $draggable = $('.draggable').draggabilly({ var $draggable = $('.draggable').draggabilly({
containment: true containment: true
......
...@@ -13,9 +13,10 @@ import { ...@@ -13,9 +13,10 @@ import {
// 微信分享公共接口 // 微信分享公共接口
// #ifdef H5 // #ifdef H5
import wechat from './common/wechat.js'; import wechat from './common/wechat.js';
if (wechat.isWechat()) { Vue.prototype.$wechat = wechat;
Vue.prototype.$wechat = wechat; // if (wechat.isWechat() || wechat.isMini()) {
} // Vue.prototype.$wechat = wechat;
// }
// #endif // #endif
Vue.config.productionTip = false; Vue.config.productionTip = false;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "shop_mobile_uni", "name": "shop_mobile_uni",
"appid": "__UNI__F904656", "appid": "__UNI__F904656",
"description": "", "description": "",
"versionName": "1.0.13", "versionName": "1.0.15",
"versionCode": "100", "versionCode": "100",
"transformPx": false, "transformPx": false,
"app-plus": { "app-plus": {
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
"mode": "history", "mode": "history",
"base": "/uni" "base": "/uni"
}, },
"publicPath": "https://dbc-static.oss-cn-beijing.aliyuncs.com/dbc-shop/uni/prod/1.0.13/", "publicPath": "https://dbc-static.oss-cn-beijing.aliyuncs.com/dbc-shop/uni/test/1.0.15/",
"optimization": { "optimization": {
"treeShaking": { "treeShaking": {
"enable": true "enable": true
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
if (this.$wechat && this.$wechat.isWechat()) { if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()}); this.$wechat.share({titie: this.$getNavigationBarTitle()});
} }
this.postData();
// #endif // #endif
}, },
onPullDownRefresh() { onPullDownRefresh() {
...@@ -97,6 +98,20 @@ ...@@ -97,6 +98,20 @@
goBack() { goBack() {
this.$backup(); this.$backup();
}, },
// 向小程序发送数据
postData(){
jWeixin.miniProgram.getEnv(function (res) {
//获取当前环境
if(res.miniprogram){
// this.$wechat.postData('谛宝多多商城-首页');
const postData = {
link: window.location.href,
title: '谛宝多多商城-首页'
}
jWeixin.miniProgram.postMessage({ data: JSON.stringify(postData) });
}
});
},
getData(params) { getData(params) {
uni.request({ uni.request({
url: '/uni/api/credit_goods/get_credit_second_goods', url: '/uni/api/credit_goods/get_credit_second_goods',
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
if (this.$wechat && this.$wechat.isWechat()) { if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()}); this.$wechat.share({titie: this.$getNavigationBarTitle()});
} }
this.postData();
// #endif // #endif
}, },
onPullDownRefresh() { onPullDownRefresh() {
...@@ -97,6 +98,20 @@ ...@@ -97,6 +98,20 @@
goBack() { goBack() {
this.$backup(); this.$backup();
}, },
// 向小程序发送数据
postData(){
jWeixin.miniProgram.getEnv(function (res) {
//获取当前环境
if(res.miniprogram){
// this.$wechat.postData('谛宝多多商城-首页');
const postData = {
link: window.location.href,
title: '谛宝多多商城'
}
jWeixin.miniProgram.postMessage({ data: JSON.stringify(postData) });
}
});
},
getData(params) { getData(params) {
uni.request({ uni.request({
url: '/uni/api/credit_goods/get_credit_all_goods', url: '/uni/api/credit_goods/get_credit_all_goods',
......
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
if (this.$wechat && this.$wechat.isWechat()) { if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()}); this.$wechat.share({titie: this.$getNavigationBarTitle()});
} }
this.postData();
// #endif // #endif
}, },
methods: { methods: {
...@@ -161,6 +162,20 @@ ...@@ -161,6 +162,20 @@
backHome(){ backHome(){
this.$jump('/pages/home/home', 2); this.$jump('/pages/home/home', 2);
}, },
// 向小程序发送数据
postData(){
jWeixin.miniProgram.getEnv(function (res) {
//获取当前环境
if(res.miniprogram){
// this.$wechat.postData('谛宝多多商城-首页');
const postData = {
link: window.location.href,
title: '谛宝多多商城'
}
jWeixin.miniProgram.postMessage({ data: JSON.stringify(postData) });
}
});
},
navigate(url) { navigate(url) {
uni.navigateTo({ uni.navigateTo({
url: url url: url
......
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
if (this.$wechat && this.$wechat.isWechat()) { if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()}); this.$wechat.share({titie: this.$getNavigationBarTitle()});
} }
this.postData();
// #endif // #endif
}, },
onPageScroll() { onPageScroll() {
...@@ -120,6 +121,20 @@ ...@@ -120,6 +121,20 @@
this.$jump(`${origin}/mobile/index.php?app=coupon&act=view&id=${this.COUPON_ID}`); this.$jump(`${origin}/mobile/index.php?app=coupon&act=view&id=${this.COUPON_ID}`);
this.$refs.popup.close(); this.$refs.popup.close();
}, },
// 向小程序发送数据
postData(){
jWeixin.miniProgram.getEnv(function (res) {
//获取当前环境
if(res.miniprogram){
// this.$wechat.postData('谛宝多多商城-首页');
const postData = {
link: window.location.href,
title: '谛宝多多商城-首页'
}
jWeixin.miniProgram.postMessage({ data: JSON.stringify(postData) });
}
});
},
get_coupon(reg_time){ get_coupon(reg_time){
// 打开广告弹窗 // 打开广告弹窗
const timestamp = new Date('2020/05/19 00:00:00').getTime() / 1000; const timestamp = new Date('2020/05/19 00:00:00').getTime() / 1000;
......
...@@ -122,6 +122,7 @@ ...@@ -122,6 +122,7 @@
if (this.$wechat && this.$wechat.isWechat()) { if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()}); this.$wechat.share({titie: this.$getNavigationBarTitle()});
} }
this.postData();
// #endif // #endif
}, },
components: { components: {
...@@ -136,6 +137,20 @@ ...@@ -136,6 +137,20 @@
search() { search() {
window.location.href = `${php}app=search&act=index&keyword=${this.keyword}` window.location.href = `${php}app=search&act=index&keyword=${this.keyword}`
}, },
// 向小程序发送数据
postData(){
jWeixin.miniProgram.getEnv(function (res) {
//获取当前环境
if(res.miniprogram){
// this.$wechat.postData('谛宝多多商城-首页');
const postData = {
link: window.location.href,
title: '谛宝多多商城'
}
jWeixin.miniProgram.postMessage({ data: JSON.stringify(postData) });
}
});
},
changeCurrent(index) { changeCurrent(index) {
this.current = index; this.current = index;
}, },
......
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
if (this.$wechat && this.$wechat.isWechat()) { if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()}); this.$wechat.share({titie: this.$getNavigationBarTitle()});
} }
this.postData();
// #endif // #endif
this.param = {...this.param, ...option}; this.param = {...this.param, ...option};
this.searchVal = option.keyword; this.searchVal = option.keyword;
...@@ -138,6 +139,20 @@ ...@@ -138,6 +139,20 @@
url: '/pages/home/home' url: '/pages/home/home'
}) })
}, },
// 向小程序发送数据
postData(){
jWeixin.miniProgram.getEnv(function (res) {
//获取当前环境
if(res.miniprogram){
// this.$wechat.postData('谛宝多多商城-首页');
const postData = {
link: window.location.href,
title: '谛宝多多商城'
}
jWeixin.miniProgram.postMessage({ data: JSON.stringify(postData) });
}
});
},
// 加入购物车 // 加入购物车
addCart(spec_id, quantity) { addCart(spec_id, quantity) {
this.$addCart(spec_id, quantity, this.isLogin); this.$addCart(spec_id, quantity, this.isLogin);
......
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