|
@@ -1,184 +0,0 @@
|
|
|
-//引入微信jssdk
|
|
|
-const wx = require('@/js_sdk/jweixin-1.4.0.js')
|
|
|
-
|
|
|
-//配置注册url
|
|
|
-const url = '/wechat/h5/getJsapiTicket';
|
|
|
-
|
|
|
-//http方法
|
|
|
-import $http from './utils/axios.js'
|
|
|
-
|
|
|
-//系统域名url
|
|
|
-const href = location.href.split('#')[0];
|
|
|
-// const href = location.href.split("?")[0]
|
|
|
-
|
|
|
-import { commonConfig } from './common/config'
|
|
|
-
|
|
|
-//系统域名url
|
|
|
-export default {
|
|
|
- ...wx,
|
|
|
- isOk: false,
|
|
|
- async config() {
|
|
|
- wx.config({
|
|
|
- debug: false,
|
|
|
- jsApiList: [
|
|
|
- "updateAppMessageShareData",
|
|
|
- "updateTimelineShareData",
|
|
|
- "onMenuShareTimeline",
|
|
|
- "onMenuShareAppMessage",
|
|
|
- "onMenuShareQQ",
|
|
|
- "onMenuShareWeibo",
|
|
|
- "onMenuShareQZone",
|
|
|
- "startRecord",
|
|
|
- "stopRecord",
|
|
|
- "onVoiceRecordEnd",
|
|
|
- "playVoice",
|
|
|
- "pauseVoice",
|
|
|
- "stopVoice",
|
|
|
- "onVoicePlayEnd",
|
|
|
- "uploadVoice",
|
|
|
- "downloadVoice",
|
|
|
- "chooseImage",
|
|
|
- "previewImage",
|
|
|
- "uploadImage",
|
|
|
- "downloadImage",
|
|
|
- "translateVoice",
|
|
|
- "getNetworkType",
|
|
|
- "openLocation",
|
|
|
- "getLocation",
|
|
|
- "hideOptionMenu",
|
|
|
- "showOptionMenu",
|
|
|
- "hideMenuItems",
|
|
|
- "showMenuItems",
|
|
|
- "hideAllNonBaseMenuItem",
|
|
|
- "showAllNonBaseMenuItem",
|
|
|
- "closeWindow",
|
|
|
- "scanQRCode",
|
|
|
- "chooseWXPay",
|
|
|
- "openProductSpecificView",
|
|
|
- "addCard",
|
|
|
- "chooseCard",
|
|
|
- "openCard"
|
|
|
- ],
|
|
|
- // ...(await $http.get(url,{url:href})).retBody,
|
|
|
- });
|
|
|
- wx.ready(e => {
|
|
|
- /**
|
|
|
- * 默认分享内容
|
|
|
- */
|
|
|
- let shareParams = {
|
|
|
- nickname:null,
|
|
|
- desc:null,
|
|
|
- togetherId:null,
|
|
|
- routeUrl:null
|
|
|
- }
|
|
|
- this.share(shareParams)
|
|
|
-
|
|
|
- this.isOk = true;
|
|
|
- // this.hideMenu();
|
|
|
- });
|
|
|
- wx.error(e => {
|
|
|
- console.log("失败")
|
|
|
- this.isOk = false;
|
|
|
- });
|
|
|
- },
|
|
|
- hideMenu() {
|
|
|
- wx.hideAllNonBaseMenuItem();
|
|
|
- wx.hideMenuItems({
|
|
|
- menuList: [
|
|
|
- "menuItem:share:appMessage",
|
|
|
- "menuItem:profile",
|
|
|
- "menuItem:addContact",
|
|
|
- "menuItem:dayMode",
|
|
|
- "menuItem:nightMode",
|
|
|
- "menuItem:share:timeline",
|
|
|
- "menuItem:favorite"
|
|
|
- ] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
|
|
|
- });
|
|
|
- },
|
|
|
- showMenu() {
|
|
|
- wx.showMenuItems({
|
|
|
- menuList: [
|
|
|
- "menuItem:share:appMessage",
|
|
|
- "menuItem:profile",
|
|
|
- "menuItem:addContact",
|
|
|
- "menuItem:dayMode",
|
|
|
- "menuItem:nightMode",
|
|
|
- "menuItem:share:timeline",
|
|
|
- "menuItem:favorite"
|
|
|
- ] // 要显示的菜单项,所有menu项见附录3
|
|
|
- });
|
|
|
- },
|
|
|
- /**
|
|
|
- * 分享配置
|
|
|
- * @param {Object} info
|
|
|
- */
|
|
|
- share(data = {}, info = {}) {
|
|
|
- //添加链接时间戳
|
|
|
- // data.v = new Date().getTime();
|
|
|
- // console.log("shareData",data)
|
|
|
- // let search = [];
|
|
|
- // for (const [key, value] of Object.entries(data)) {
|
|
|
- // // search.push(`${key}=${encodeURIComponent(value)}`);
|
|
|
- // search.push(`${key}=${value}`);
|
|
|
- // }
|
|
|
- // search = "?" + search.join("&");
|
|
|
-
|
|
|
- let afterEndUrl = commonConfig.afterEndUrl;
|
|
|
- // let afterEndUrl = 'http://tanhui.hongweisoft.com/api/wechat/h5/authorize?returnUrl='
|
|
|
- // let afterEndUrl = 'http://gzhjt.gzsdzth.com/api/wechat/h5/authorize?returnUrl='
|
|
|
-
|
|
|
- let fullUrl= '';
|
|
|
- if(data.togetherId&&data.routeUrl){
|
|
|
- fullUrl = afterEndUrl + location.href.split('?')[0] + '?togetherId=' + data.togetherId + '/#/' + data.routeUrl
|
|
|
- }else{
|
|
|
- fullUrl = afterEndUrl + location.href.split('?')[0]
|
|
|
- };
|
|
|
- let shareInfo = {
|
|
|
- title: data.nickname?data.nickname + '邀请你参与贵州省单株碳汇平台':'贵州省单株碳汇平台',
|
|
|
- link: fullUrl,
|
|
|
- desc: data.desc||"购买碳汇,你我同行",
|
|
|
- imgUrl: href + "/static/logo.png",
|
|
|
- trigger(res) {},
|
|
|
- success(res) {},
|
|
|
- cancel(res) {},
|
|
|
- fail(res) {},
|
|
|
- ...info
|
|
|
- };
|
|
|
- console.log('shareInfo',shareInfo,'fullUrl',fullUrl)
|
|
|
- //自定义“分享给朋友”及“分享到QQ”按钮的分享内容(1.4.0)
|
|
|
- wx.updateAppMessageShareData(shareInfo);
|
|
|
- //自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容(1.4.0)
|
|
|
- wx.updateTimelineShareData(shareInfo);
|
|
|
- },
|
|
|
- //拉起微信浏览器端支付
|
|
|
- JSAPI(res) {
|
|
|
- return new Promise(r => {
|
|
|
- wx.chooseWXPay({
|
|
|
- "timestamp": res.timeStamp, //时间戳,自1970年以来的秒数
|
|
|
- "nonceStr": res.nonceStr, //随机串
|
|
|
- "package": res.packageValue,
|
|
|
- "signType": res.signType, //微信签名方式:
|
|
|
- "paySign": res.paySign, //微信签名
|
|
|
- success() {
|
|
|
- r({
|
|
|
- code: 0,
|
|
|
- msg: "成功"
|
|
|
- });
|
|
|
- },
|
|
|
- cancel() {
|
|
|
- r({
|
|
|
- code: 1,
|
|
|
- msg: "取消"
|
|
|
- });
|
|
|
- },
|
|
|
- fail(err) {
|
|
|
- console.log('支付失败',err.errMsg.split(':')[1]);
|
|
|
- r({
|
|
|
- code: 2,
|
|
|
- msg: err.errMsg.split(':')[1]
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
-}
|