youmengting-dev
游梦婷 1 year ago
parent 1a3a5cc65f
commit e4a59746b6
  1. 41
      App.vue
  2. 174
      common/share.js
  3. 36
      pages/welcome/welcome.vue

@ -67,7 +67,8 @@
//
shareNum: 0,
//
isSelect: false
isSelect: false,
h5url:'',
},
@ -101,25 +102,27 @@
// #endif
// #ifdef H5
let that = this;
// that.globalData.url = 'https://hsgcs.dctpay.com/crest';
// that.globalData.v1url = 'https://hsgcs.dctpay.com/v1';
// that.globalData.payurl = 'https://gratia-pay.dctpay.com/crest';
// that.globalData.orderurl = 'https://hsgcs.dctpay.com/order';
// that.globalData.userurl = 'https://hsgcs.dctpay.com/user';
// that.globalData.brestUrl = 'https://hsgcs.dctpay.com/brest';
// that.globalData.imgUrl = 'https://hsgcs.dctpay.com/filesystem/';
// that.globalData.imageWxImg = 'https://hsgcs.dctpay.com/filesystem/wxApplets/';
// that.globalData.imageqrImg = 'https://hsgcs.dctpay.com/filesystem/temporary/';
that.globalData.h5url = "https://hsgcs.dctpay.com/hsgH5";
that.globalData.url = 'https://hsgcs.dctpay.com/crest';
that.globalData.v1url = 'https://hsgcs.dctpay.com/v1';
that.globalData.payurl = 'https://gratia-pay.dctpay.com/crest';
that.globalData.orderurl = 'https://hsgcs.dctpay.com/order';
that.globalData.userurl = 'https://hsgcs.dctpay.com/user';
that.globalData.brestUrl = 'https://hsgcs.dctpay.com/brest';
that.globalData.imgUrl = 'https://hsgcs.dctpay.com/filesystem/';
that.globalData.imageWxImg = 'https://hsgcs.dctpay.com/filesystem/wxApplets/';
that.globalData.imageqrImg = 'https://hsgcs.dctpay.com/filesystem/temporary/';
that.globalData.url = 'https://hsg.dctpay.com/crest';
that.globalData.v1url = 'https://hsg.dctpay.com/v1';
that.globalData.payurl = 'https://pay.dctpay.com/crest';
that.globalData.orderurl = 'https://hsg.dctpay.com/order';
that.globalData.userurl = 'https://hsg.dctpay.com/user';
that.globalData.brestUrl = 'https://hsg.dctpay.com/brest';
that.globalData.imgUrl = 'https://hsg.dctpay.com/filesystem/';
that.globalData.imageWxImg = 'https://hsg.dctpay.com/filesystem/wxApplets/';
that.globalData.imageqrImg = 'https://hsg.dctpay.com/filesystem/temporary/';
// that.globalData.h5url = "https://hsg.dctpay.com/hsgH5"
// that.globalData.url = 'https://hsg.dctpay.com/crest';
// that.globalData.v1url = 'https://hsg.dctpay.com/v1';
// that.globalData.payurl = 'https://pay.dctpay.com/crest';
// that.globalData.orderurl = 'https://hsg.dctpay.com/order';
// that.globalData.userurl = 'https://hsg.dctpay.com/user';
// that.globalData.brestUrl = 'https://hsg.dctpay.com/brest';
// that.globalData.imgUrl = 'https://hsg.dctpay.com/filesystem/';
// that.globalData.imageWxImg = 'https://hsg.dctpay.com/filesystem/wxApplets/';
// that.globalData.imageqrImg = 'https://hsg.dctpay.com/filesystem/temporary/';
uni.getStorage({
key: 'openId',
success(e) {

@ -1,35 +1,141 @@
export default{
data(){
return {
//设置默认的分享参数
//如果页面不设置share,就触发这个默认的分享
share:{
title:'嗨森逛',
path:'/pages/tabBar/home/home',
imageUrl:'',
desc:'',
content:''
}
}
},
onShareAppMessage(res) {
return {
title:this.share.title,
path:this.share.path,
imageUrl:this.share.imageUrl,
desc:this.share.desc,
content:this.share.content,
success(res){
uni.showToast({
title:'分享成功'
})
},
fail(res){
uni.showToast({
title:'分享失败',
icon:'none'
})
}
}
}
export default {
data() {
return {
//设置默认的分享参数
//如果页面不设置share,就触发这个默认的分享
share: {
title: '嗨森逛',
path: '/pages/tabBar/home/home',
imageUrl: '',
desc: '',
content: ''
},
}
},
methods: {
//分享
doShare() {
const app = getApp();
let that = this;
let theUrl = window.location.href;
that.shareLink = app.globalData.h5url+'?accountId=0000016&key=&code=' + theUrl.split('#')[1];
// console.log(theUrl.split('#')[0],decodeURIComponent(theUrl.split('#')[1]),theUrl,"theUrl",that.shareLink,"that.shareLink");
let datas = {
url: theUrl.split('#')[0]
}
/* https://hsg.dctpay.com/hsgH5/index.html?code=081Zb4ml2gamsb4L3nnl2UArrO1Zb4mc&state=1#/physical-merchants/classify/goods-search/goods-search?goodsLabel=%E9%9B%B6%E5%85%83%E8%B4%AD */
let api = require('../Utils/Api');
let wx = require('weixin-js-sdk');
api.verifyWx(datas).then(res => {
if (res.return_code == '000000') {
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: res.return_data.appId, // 必填,公众号的唯一标识
timestamp: res.return_data.timestamp, // 必填,生成签名的时间戳
nonceStr: res.return_data.nonceStr, // 必填,生成签名的随机串
signature: res.return_data.signature, // 必填,签名,见附录1
jsApiList: [
'onMenuShareAppMessage'
] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
});
/* configreadyconfig
config是一个客户端的异步操作所以如果需要在页面加载时就调用相关接口则须把相关接口放在ready函数中调用来确保正确执行
对于用户触发时才调用的接口则可以直接调用不需要放在ready函数中 */
wx.ready(function() { //需在用户可能点击分享按钮前就先调用
wx.onMenuShareAppMessage({
title: '嗨森逛分享', // 分享标题
desc: '', // 分享描述
link: that.shareLink, // 分享链接
imgUrl: 'https://hsg.dctpay.com/filesystem/wxApplets/logo.png', // 分享图标
success: function(res) {
// 支付成功后的回调函数
uni.showToast({
title: '分享成功',
duration: 2000,
icon: 'none'
})
},
cancel: function(r) {},
fail: function(res) {}
});
});
// wx.error(function(res) {
// console.log(res);
// // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
// });
} else {
uni.showToast({
title: res.return_msg,
duration: 2000,
icon: 'none'
})
}
})
},
//获取当前路由
getCurrentRouteYm() {
let currentRoutes = getCurrentPages(); // 获取当前打开过的页面路由数组
console.log(currentRoutes[currentRoutes.length - 1]);
let route = currentRoutes[currentRoutes.length - 1];
// let currentRoute = currentRoutes[currentRoutes.length - 1].route //获取当前页面路由
// let currentParam = currentRoutes[currentRoutes.length - 1].options; //获取路由参数
// // 拼接参数
// let param = [];
// for (let key in currentParam) {
// param.push(key + '=' + currentParam[key])
// }
// let currentPath = '/' + currentRoute;
// let currentQuery = param.join('&');
// if (currentQuery) currentPath += '?' + currentQuery;
// return {
// path: currentPath,
// query: currentQuery,
// }
return decodeURIComponent(route.$page.fullPath)
},
},
onLoad(){
this.$nextTick(()=>{
// #ifdef H5
this.doShare()
// #endif
})
},
/* 小程序分享 */
onShareAppMessage(res) {
this.share.path = this.getCurrentRouteYm();
// console.log(this.share.path, "this.share.path", res);
return {
title: this.share.title,
path: this.share.path,
imageUrl: this.share.imageUrl,
desc: this.share.desc,
content: this.share.content,
success(res) {
uni.showToast({
title: '分享成功'
})
},
fail(res) {
uni.showToast({
title: '分享失败',
icon: 'none'
})
}
}
}
}

@ -28,6 +28,7 @@
// #ifdef H5
var arr1 = window.location.href;
var arr2 = arr1.split('=');
if (arr2[1] != undefined && arr2[2] == '1#/') {
app.globalData.h5code = arr2[1];
uni.setStorage({
@ -78,6 +79,8 @@
// 0012
// 0013
// 0014
// 0016
if (app.globalData.accountType == '0000011&key' && app.globalData.h5code) {
uni.navigateTo({
url: '/pages/goods/externalCoupon/externalCoupon'
@ -97,6 +100,23 @@
})
return;
}
if(app.globalData.accountType == '0000016&key' && app.globalData.h5code){
const value = uni.getStorageSync('goUrl');
if(value == "/pages/tabBar/home/home" || value == "/pages/tabBar/category/category" || value == "/pages/tabBar/user/user"){
uni.switchTab({
url: value
})
return
}
uni.navigateTo({
url: value
})
return;
}
uni.switchTab({
url: '../tabBar/home/home'
})
@ -127,6 +147,16 @@
data: arr4[0]
})
}
if(arr1.indexOf("code") != -1){
let goUrl =arr1.slice(Number(arr1.indexOf("code"))+5) ;
uni.setStorage({
key: "goUrl",
data: decodeURIComponent(goUrl)
})
}
}
if (app.globalData.h5code) {
that.getH5AccessToken();
@ -199,8 +229,12 @@
})
},
jumpcdx() {
let str =encodeURIComponent(app.globalData.h5url+"/index.html#/")
// console.log(app.globalData.h5url,"11111",str,"str" );
location.href =
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa075e8509802f826&redirect_uri=https%3A%2F%2Fhsg.dctpay.com%2FhsgH5%2Findex.html%23%2F&response_type=code&scope=snsapi_base&state=1#wechat_redirect';
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa075e8509802f826&redirect_uri='+str+'&response_type=code&scope=snsapi_base&state=1#wechat_redirect';
},
}
}

Loading…
Cancel
Save