Browse Source

...添加微信支付

yuxingxing 2 years ago
parent
commit
b15860b7b0
4 changed files with 22 additions and 24 deletions
  1. 6 0
      api/home.js
  2. 13 21
      components/payment/index.vue
  3. 2 2
      config/app.js
  4. 1 1
      pages/goods/order_list/index.vue

+ 6 - 0
api/home.js

@@ -116,3 +116,9 @@ export function postBeforeCheck(data) {
 export function postOrderSubmit(data) {
 	return request.post("v1/re/order/submit",data);
 }
+
+// jspai下单API
+export function postJsapiPay(data) {
+	let url = "?openid="+data.openId + "&outTradeNo="+data.outTradeNo
+	return request.post("v1/wxPay/v3/jsapiPay"+url,data);
+}

+ 13 - 21
components/payment/index.vue

@@ -34,6 +34,9 @@ import {
 	OPENID
 } from '@/config/cache';
 import Cache from '@/utils/cache';
+import {
+	postJsapiPay
+} from '@/api/home.js';
 import {
 	orderPay
 } from '@/api/order.js';
@@ -133,35 +136,24 @@ export default {
 					complete: () => { }
 				});
 			}
-			orderPay({
+			postJsapiPay({
 				openId: Cache.get(OPENID),
-				orderId: that.order_id,
-				client: "WX_MINI",
-				paytype: paytype,
-				type: that.friendPay ? 1 : 0,
-				// #ifdef MP 
-				'from': 'routine',
-				// #endif
+				outTradeNo: that.order_id,
 			}).then(res => {
-				let jsConfig = res.data.result.jsConfig;
 				switch (paytype) {
 					case 'weixin':
-						if (res.data.result === undefined) return that.$util.Tips({
+						if (res.data === undefined) return that.$util.Tips({
 							title: that.$t(`缺少支付参数`)
 						});
 						// #ifdef MP
-						let mp_pay_name = ''
-						if (uni.requestOrderPayment) {
-							mp_pay_name = 'requestOrderPayment'
-						} else {
-							mp_pay_name = 'requestPayment'
-						}
+						let mp_pay_name = 'requestPayment'
 						uni[mp_pay_name]({
-							timeStamp: jsConfig.timestamp,
-							nonceStr: jsConfig.nonceStr,
-							package: jsConfig.package,
-							signType: jsConfig.signType,
-							paySign: jsConfig.paySign,
+							provider: 'wxpay',
+							timeStamp: res.data.timestamp + '',
+							nonceStr: res.data.noncestr,
+							package: res.data.prepayid,
+							signType: 'MD5',
+							paySign: res.data.sign,
 							success: function (res) {
 								uni.hideLoading();
 								return that.$util.Tips({

+ 2 - 2
config/app.js

@@ -2,8 +2,8 @@ module.exports = {
 	// 小程序配置
 	// #ifdef MP || APP-PLUS
 	// 请求域名 格式: https://您的域名
-	HTTP_REQUEST_URL: `https://www.gzzhsckj.com`,
-	// HTTP_REQUEST_URL: `http://wine.gzzzyd.com`,
+	// HTTP_REQUEST_URL: `https://www.gzzhsckj.com`,
+	HTTP_REQUEST_URL: `http://wine.gzzzyd.com`,
 	// HTTP_REQUEST_URL: `v4.crmeb.net`,
 	// #endif
 	

+ 1 - 1
pages/goods/order_list/index.vue

@@ -87,7 +87,7 @@
 							@click="cancelOrder(index, item.id)">{{ $t(`取消订单`) }}</view>
 						<view class="bnt cancelBnt" v-if="item.payFlag == 2 || item.payFlag == 3"
 							@click="refundOrder(index, item.id)">{{ $t(`申请退款`) }}</view>
-						<view class="bnt bg-color" v-if="item.payFlag == 1" @click="goPay(item.totalFee, item.id)">
+						<view class="bnt bg-color" v-if="item.payFlag == 1" @click="goPay(item.totalFee, item.outTradeNo)">
 							{{ $t(`立即支付`) }}</view>
 						<!-- <view class="bnt bg-color" v-else-if="item.payFlag == 3"
 							@click="goOrderDetails(item.order_id)">去评价</view> -->