yangzj 2 anni fa
parent
commit
4a1fceae73
2 ha cambiato i file con 20 aggiunte e 23 eliminazioni
  1. 3 12
      pay.js
  2. 17 11
      wxapi.js

+ 3 - 12
pay.js

@@ -29,13 +29,13 @@ export default {
 	// 	});
 	// },
 	// 微信支付
-	wxPay(obj = {}) {
+	wxPay(obj = {}, url = '/client/pay/wechat', jumpUrl) {
 		uni.showLoading({
 			title: '支付中'
 		});
 		return new Promise(r => {
-			$http.post("/client/pay/wechat", obj)
-				then(res => {
+			$http.post(url, obj)
+				.then(res => {
 					// 区分包月支付和普通支付
 					if (res.data.needPay && !res.data.monthId) {
 						//#ifdef H5
@@ -62,15 +62,6 @@ export default {
 						}, 1500)
 					}
 				})
-			// $http.post("/client/pay/wechat", obj)
-			// 	.then(res => {
-			// 		//#ifdef H5
-			// 		$wxApi.JSAPI(res.data).then(r);
-			// 		//#endif
-			// 		this.payError(res);
-			// 	}).catch(err => {
-			// 		console.log('pay err', err);
-			// 	})
 		});
 	},
 	/**

+ 17 - 11
wxapi.js

@@ -12,7 +12,9 @@ import $http from "./uview-ui/libs/request"
 const href = location.href.split('#')[0];
 // const href = location.href.split("?")[0]
 
-import { config } from '@/common/config'
+import {
+	config
+} from '@/common/config'
 
 //系统域名url
 export default {
@@ -60,7 +62,9 @@ export default {
 				"chooseCard",
 				"openCard"
 			],
-			...(await $http.get(url,{url:href})).data,
+			...(await $http.get(url, {
+				url: href
+			})).data,
 			// ...(await uni.request(url,{url:href})).retBody,
 		});
 		wx.ready(e => {
@@ -74,15 +78,15 @@ export default {
 	},
 	hideMenu() {
 		wx.hideAllNonBaseMenuItem();
-		wx.hideMenuItems({		
-		    menuList: [
+		wx.hideMenuItems({
+			menuList: [
 				"menuItem:share:appMessage",
 				"menuItem:profile",
 				"menuItem:addContact",
 				"menuItem:dayMode",
 				"menuItem:nightMode",
 				"menuItem:share:timeline",
-				"menuItem:favorite"				
+				"menuItem:favorite"
 			] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3		
 		});
 	},
@@ -113,12 +117,13 @@ export default {
 		// 	search.push(`${key}=${value}`);
 		// }
 		// search = "?" + search.join("&");
-		
+
 		let afterEndUrl = config.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 = afterEndUrl + location.href.split('?')[0] + '?togetherId=' + data.togetherId + '/#/' + data.routeUrl
+
+		let fullUrl = afterEndUrl + location.href.split('?')[0] + '?togetherId=' + data.togetherId + '/#/' + data
+			.routeUrl
 		const shareInfo = {
 			title: data.nickname + '邀请你参与贵州省单株碳汇精准扶贫',
 			link: fullUrl,
@@ -130,7 +135,7 @@ export default {
 			fail(res) {},
 			...info
 		};
-		console.log('shareInfo',shareInfo,'fullUrl',fullUrl)
+		console.log('shareInfo', shareInfo, 'fullUrl', fullUrl)
 		//自定义“分享给朋友”及“分享到QQ”按钮的分享内容(1.4.0)
 		wx.updateAppMessageShareData(shareInfo);
 		//自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容(1.4.0)
@@ -140,12 +145,13 @@ export default {
 	JSAPI(res, jumpUrl) {
 		return new Promise(r => {
 			wx.chooseWXPay({
-				"timestamp": res.timeStamp, //时间戳,自1970年以来的秒数     
+				"appId": res.appId,
+				"timeStamp": res.timeStamp, //时间戳,自1970年以来的秒数     
 				"nonceStr": res.nonceStr, //随机串     
 				"package": res.packageValue,
 				"signType": res.signType, //微信签名方式:     
 				"paySign": res.paySign, //微信签名
-				success() {
+				success(data) {
 					r({
 						code: 0,
 						msg: "成功"