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

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

parent 04829869
// 微信分享 公共方法
var jweixin = require('jweixin-module');
// var jweixin = require('jweixin-module');
export default {
// 是否在微信中
......@@ -22,7 +22,7 @@ export default {
success: (res) => {
const { data } = res;
if(data.code === 0){
jweixin.config({
jWeixin.config({
debug: false,
appId: data.data.appId,
timestamp: data.data.timestamp,
......@@ -59,7 +59,7 @@ export default {
}
//每次都需要重新初始化配置,才可以进行分享
this.initJssdkShare(function(){
jweixin.ready(function() {
jWeixin.ready(function() {
var shareData = {
title: data && data.title ? data.title : '谛宝多多商城',
desc: data && data.desc ? data.desc : '宠物行业一站式B2B采购平台',
......@@ -72,14 +72,35 @@ export default {
cancel: function(res) {}
};
//分享给朋友接口
jweixin.onMenuShareAppMessage(shareData);
jWeixin.onMenuShareAppMessage(shareData);
//分享到朋友圈接口
jweixin.onMenuShareTimeline(shareData);
jWeixin.onMenuShareTimeline(shareData);
// 分享到QQ
jweixin.onMenuShareQQ(shareData);
jWeixin.onMenuShareQQ(shareData);
// 分享到微博
jweixin.onMenuShareWeibo(shareData);
jWeixin.onMenuShareWeibo(shareData);
});
}, 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 @@
<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://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 -->
<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 -->
</head>
<body>
......@@ -31,7 +32,7 @@
<strong>Please enable JavaScript to continue.</strong>
</noscript>
<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>
var _hmt = _hmt || [];
(function() {
......@@ -40,7 +41,39 @@
var s = document.getElementsByTagName("script")[0];
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({
containment: true
});
......
......@@ -12,10 +12,11 @@ import {
// 微信分享公共接口
// #ifdef H5
import wechat from './common/wechat.js';
if (wechat.isWechat()) {
Vue.prototype.$wechat = wechat;
}
import wechat from './common/wechat.js';
Vue.prototype.$wechat = wechat;
// if (wechat.isWechat() || wechat.isMini()) {
// Vue.prototype.$wechat = wechat;
// }
// #endif
Vue.config.productionTip = false;
......
......@@ -2,7 +2,7 @@
"name": "shop_mobile_uni",
"appid": "__UNI__F904656",
"description": "",
"versionName": "1.0.13",
"versionName": "1.0.15",
"versionCode": "100",
"transformPx": false,
"app-plus": {
......@@ -51,7 +51,7 @@
"mode": "history",
"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": {
"treeShaking": {
"enable": true
......
......@@ -75,6 +75,7 @@
if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()});
}
this.postData();
// #endif
},
onPullDownRefresh() {
......@@ -97,6 +98,20 @@
goBack() {
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) {
uni.request({
url: '/uni/api/credit_goods/get_credit_second_goods',
......
......@@ -75,6 +75,7 @@
if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()});
}
this.postData();
// #endif
},
onPullDownRefresh() {
......@@ -97,6 +98,20 @@
goBack() {
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) {
uni.request({
url: '/uni/api/credit_goods/get_credit_all_goods',
......
......@@ -98,6 +98,7 @@
if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()});
}
this.postData();
// #endif
},
methods: {
......@@ -161,6 +162,20 @@
backHome(){
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) {
uni.navigateTo({
url: url
......
......@@ -70,6 +70,7 @@
if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()});
}
this.postData();
// #endif
},
onPageScroll() {
......@@ -120,6 +121,20 @@
this.$jump(`${origin}/mobile/index.php?app=coupon&act=view&id=${this.COUPON_ID}`);
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){
// 打开广告弹窗
const timestamp = new Date('2020/05/19 00:00:00').getTime() / 1000;
......
......@@ -122,6 +122,7 @@
if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()});
}
this.postData();
// #endif
},
components: {
......@@ -136,6 +137,20 @@
search() {
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) {
this.current = index;
},
......
......@@ -111,6 +111,7 @@
if (this.$wechat && this.$wechat.isWechat()) {
this.$wechat.share({titie: this.$getNavigationBarTitle()});
}
this.postData();
// #endif
this.param = {...this.param, ...option};
this.searchVal = option.keyword;
......@@ -138,6 +139,20 @@
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) {
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