APP微信支付

msb_beta
ch 3 years ago
parent f24f4c81cb
commit b5560a9435

4
.gitignore vendored

@ -4,5 +4,5 @@ env.js
node_moudel/ node_moudel/
package-lock.json package-lock.json
unpackage/dist/build/.automator/ unpackage/dist/build/.automator/
unpackage/dist/dev/ unpackage/dist/dev
unpackage/dist/cache/ unpackage/cache

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-04-28 16:30:54 * @Date: 2022-04-28 16:30:54
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-05 11:18:50 * @LastEditTime: 2022-05-06 20:58:31
* @Description: file content * @Description: file content
*/ */
@ -35,4 +35,11 @@ export const ApiPostWxH5Pay = (data) =>
* @param {*} data * @param {*} data
*/ */
export const ApiPostWxJsApiPay = (data) => export const ApiPostWxJsApiPay = (data) =>
ToAsyncAwait(MsbRequestTk.post(`${BASE_URL}/pay/wxPay/jsapi`, data)); ToAsyncAwait(MsbRequestTk.post(`${BASE_URL}/pay/wxPay/jsapi`, data));
/**
* 微信APP支付
* @param {*} data
*/
export const ApiPostWxAppPay = (data) =>
ToAsyncAwait(MsbRequestTk.post(`${BASE_URL}/pay/wxPay/app`, data));

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-03-22 16:52:28 * @Date: 2022-03-22 16:52:28
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-04-29 14:49:13 * @LastEditTime: 2022-05-06 21:06:14
* @Description: 所有工具类统一在这输出 * @Description: 所有工具类统一在这输出
*/ */
import * as util from './utils'; import * as util from './utils';

@ -0,0 +1,57 @@
/*
* @Author: ch
* @Date: 2022-05-06 15:33:55
* @LastEditors: ch
* @LastEditTime: 2022-05-06 21:02:39
* @Description: file content
*/
import { ApiPostWxH5Pay, ApiPostWxJsApiPay } from '@/common/api/wx';
import { Wxpay } from './wxpay';
export const pay = ({orderId, openId, payType})=>{
if(payType === 'wxpay'){
Wxpay({orderId, openId});
}
// #ifdef H5
if(openId) {
// 微信JSAPI
const {error, result} = await ApiPostWxJsApiPay({orderId,openId});
if(error){
uni.$u.toast(error.message);
return false;
}
/*
* 公众号id appId String(16) wx8888888888888888
时间戳 timeStamp String(32) 1414561699 当前的时间
随机字符串 nonceStr String(32) 5K8264ILTKCH16CQ2502SI8ZNMTM67VS 随机字符串不长于32位推荐随机数生成算法
订单详情扩展字符串 package String(128) prepay_id=123456789 统一下单接口返回的prepay_id参数值提交格式如prepay_id=***
签名方式 signType String(32) MD5 签名类型默认为MD5支持HMAC-SHA256和MD5注意此处需与统一下单的签名类型一致
签名 paySign String(64) C380BEC2BFD727A4B6845133519F3AD6 签名
*/
const par = result.dataInfo;
WeixinJSBridge.invoke('getBrandWCPayRequest', {
appId : par.appId,
timeStamp : par.timeStamp,
nonceStr : par.nonceStr,
package : par.packageValue,
signType : par.signType,
paySign : par.paySign
}, res => {
if(res.err_msg !== 'get_brand_wcpay_request:cancel'){
uni.navigateTo({
url : `/payResult?orderId=${orderId}&payType=wxjsapi`
});
}
})
}else{
// h5支付
const {error, result} = await ApiPostWxH5Pay({orderId});
if(error){
uni.$u.toast(error.message);
return false;
}
const redirect_url = decodeURIComponent(`https://you-app.mashibing.com/payResult?orderId=${orderId}&payType=wxh5`);
window.location.href = `${result.dataInfo.payUrl}&redirect_url=${redirect_url}`;
}
// #ednif
}

@ -2,13 +2,48 @@
* @Author: ch * @Author: ch
* @Date: 2022-04-29 14:26:10 * @Date: 2022-04-29 14:26:10
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-05 19:16:29 * @LastEditTime: 2022-05-06 21:23:48
* @Description: file content * @Description: file content
*/ */
import { ApiPostWxH5Pay, ApiPostWxJsApiPay } from '@/common/api/wx'; import { ApiPostWxH5Pay, ApiPostWxJsApiPay, ApiPostWxAppPay } from '@/common/api/wx';
export const Wxpay = async ({orderId,openId})=>{ export const Wxpay = async ({orderId,openId})=>{
// 有openId则表示在微信浏览器内
// #ifdef APP-PLUS
const {error, result} = await ApiPostWxAppPay({orderId});
if(error){
uni.$u.toast(error.message);
return false;
}
const par = result.dataInfo;
uni.requestPayment({
provider: 'wxpay',
orderInfo :{
"appid": par.appId, // 微信开放平台 - 应用 - AppId
"noncestr": par.nonceStr, // 随机字符串
"package": par.packageValue, // 固定值
"partnerid": par.partnerId, // 微信支付商户号
"prepayid": par.prepayId, // 统一下单订单号
"timestamp": par.timeStamp ,// 时间戳(单位:秒)
"sign": par.sign // 签名,这里用的 MD5 签名
},
success(res) {
uni.navigateTo({
url : `/payResult?orderId=${orderId}&payType=appWx`
});
},
fail(e) {
uni.navigateTo({
url : `/payResult?orderId=${orderId}&payType=appWx`
});
}
}).then(res => {
console.log('res',res);
})
// #endif
// #ifdef H5
// 有openId则判断在微信浏览器内
if(openId) { if(openId) {
// 微信JSAPI // 微信JSAPI
const {error, result} = await ApiPostWxJsApiPay({orderId,openId}); const {error, result} = await ApiPostWxJsApiPay({orderId,openId});
@ -16,14 +51,6 @@ export const Wxpay = async ({orderId,openId})=>{
uni.$u.toast(error.message); uni.$u.toast(error.message);
return false; return false;
} }
/*
* 公众号id appId String(16) wx8888888888888888
时间戳 timeStamp String(32) 1414561699 当前的时间
随机字符串 nonceStr String(32) 5K8264ILTKCH16CQ2502SI8ZNMTM67VS 随机字符串不长于32位推荐随机数生成算法
订单详情扩展字符串 package String(128) prepay_id=123456789 统一下单接口返回的prepay_id参数值提交格式如prepay_id=***
签名方式 signType String(32) MD5 签名类型默认为MD5支持HMAC-SHA256和MD5注意此处需与统一下单的签名类型一致
签名 paySign String(64) C380BEC2BFD727A4B6845133519F3AD6 签名
*/
const par = result.dataInfo; const par = result.dataInfo;
WeixinJSBridge.invoke('getBrandWCPayRequest', { WeixinJSBridge.invoke('getBrandWCPayRequest', {
appId : par.appId, appId : par.appId,
@ -49,4 +76,6 @@ export const Wxpay = async ({orderId,openId})=>{
const redirect_url = decodeURIComponent(`https://you-app.mashibing.com/payResult?orderId=${orderId}&payType=wxh5`); const redirect_url = decodeURIComponent(`https://you-app.mashibing.com/payResult?orderId=${orderId}&payType=wxh5`);
window.location.href = `${result.dataInfo.payUrl}&redirect_url=${redirect_url}`; window.location.href = `${result.dataInfo.payUrl}&redirect_url=${redirect_url}`;
} }
// #endif
} }

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-03-20 16:45:27 * @Date: 2022-03-20 16:45:27
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-05 10:45:33 * @LastEditTime: 2022-05-06 14:26:57
* @Description: file content * @Description: file content
--> -->
<template> <template>
@ -55,7 +55,7 @@ export default {
this.listData = this.listData.concat(res); this.listData = this.listData.concat(res);
// //
if(!res.length < this.params.length){ if(!res.length || res.length < this.params.length){
this.loadingStatus = 'nomore'; this.loadingStatus = 'nomore';
} }
}, },

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-04-07 17:22:44 * @Date: 2022-04-07 17:22:44
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-04-30 16:52:08 * @LastEditTime: 2022-05-06 22:23:01
* @Description: file content * @Description: file content
--> -->
@ -115,6 +115,12 @@ export default {
padding: 20rpx 20rpx 24rpx; padding: 20rpx 20rpx 24rpx;
line-height: 36rpx; line-height: 36rpx;
font-weight: bold; font-weight: bold;
overflow:hidden;
text-overflow:ellipsis;
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:2;
max-height: 96rpx;
&__indent{ &__indent{
text-indent: 76rpx; text-indent: 76rpx;
position: relative; position: relative;

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-03-24 11:30:55 * @Date: 2022-03-24 11:30:55
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-04-30 15:41:16 * @LastEditTime: 2022-05-06 22:19:03
* @Description: file content * @Description: file content
--> -->
<template> <template>
@ -33,7 +33,7 @@
<view class="sku-num--single-box"> <view class="sku-num--single-box">
<template> <template>
<text>数量</text> <text>数量</text>
<!-- <text class="sku-num--single">{{maxBuyNum}}</text> --> <text class="sku-num--single" v-if="goodsInfo.singleBuyLimit > 0">{{goodsInfo.singleBuyLimit}}</text>
</template> </template>
</view> </view>
<u-number-box :min="1" :max="maxBuyNum" button-size="40rpx" bgColor="#F5F6FA" <u-number-box :min="1" :max="maxBuyNum" button-size="40rpx" bgColor="#F5F6FA"

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-03-23 10:29:07 * @Date: 2022-03-23 10:29:07
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-05 10:45:44 * @LastEditTime: 2022-05-06 11:20:23
* @Description: file content * @Description: file content
--> -->
<template> <template>
@ -19,7 +19,7 @@
<!-- <view class="price">{{max.startingPrice}}</view> --> <!-- <view class="price">{{max.startingPrice}}</view> -->
<UiMoney class="price" :money="max.startingPrice" prefix></UiMoney> <UiMoney class="price" :money="max.startingPrice" prefix></UiMoney>
<view class="img-box"> <view class="img-box">
<image class="img" :src="max.recommendPicture"/> <image class="img" mode="aspectFit" :src="max.recommendPicture"/>
</view> </view>
</view> </view>
<view class="min" @click="$Router.push(`/goodsDetail?id=${minOne.id}`)"> <view class="min" @click="$Router.push(`/goodsDetail?id=${minOne.id}`)">
@ -36,7 +36,7 @@
<UiMoney class="price" :money="minOne.startingPrice" prefix></UiMoney> <UiMoney class="price" :money="minOne.startingPrice" prefix></UiMoney>
</view> </view>
<view class="img-box"> <view class="img-box">
<image class="img" :src="minOne.recommendPicture"/> <image class="img" mode="aspectFit" :src="minOne.recommendPicture"/>
</view> </view>
</view> </view>
</view> </view>
@ -54,7 +54,7 @@
<UiMoney class="price" :money="minTwo.startingPrice" prefix></UiMoney> <UiMoney class="price" :money="minTwo.startingPrice" prefix></UiMoney>
</view> </view>
<view class="img-box"> <view class="img-box">
<image class="img" :src="minTwo.recommendPicture"/> <image class="img" mode="aspectFit" :src="minTwo.recommendPicture"/>
</view> </view>
</view> </view>
</view> </view>
@ -122,7 +122,7 @@ export default {
font-size: 22rpx; font-size: 22rpx;
} }
.price{ .price{
margin: 20rpx 0 10rpx 20rpx; margin: 16rpx 0 0 20rpx;
} }
} }

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2019-08-22 19:41:20 * @Date: 2019-08-22 19:41:20
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-05 21:50:27 * @LastEditTime: 2022-05-06 15:29:41
* @Description: file content * @Description: file content
--> -->
<template> <template>
@ -109,7 +109,7 @@ export default {
async getRecommendedGoodsList(){ async getRecommendedGoodsList(){
const {error, result} = await ApiGetRecommendedGoodsList(); const {error, result} = await ApiGetRecommendedGoodsList();
if(result){ if(result){
this.recommendedGoodsList = result this.recommendedGoodsList = result;
} }
}, },

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-03-31 17:53:43 * @Date: 2022-03-31 17:53:43
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-04-24 11:09:37 * @LastEditTime: 2022-05-06 18:55:06
* @Description: file content * @Description: file content
--> -->
<template> <template>
@ -56,7 +56,7 @@ export default {
this.ctxCon = this.ctxData[refundStatus]; this.ctxCon = this.ctxData[refundStatus];
switch(refundStatus){ switch(refundStatus){
case 1 : case 1 :
this.ctxCon.tips = `您的申请已经提交,还剩${this.calcTimer(handleExpireTime)}`; this.ctxCon.tips = `您的申请已经提交,还剩${this.calcTimer(handleExpireTime.newData)}`;
break; break;
case 3 : case 3 :
this.ctxCon.tips = `还剩${this.calcTimer(returnExpireTime)}`; this.ctxCon.tips = `还剩${this.calcTimer(returnExpireTime)}`;
@ -77,8 +77,8 @@ export default {
* 计算距下个节点处理时间 * 计算距下个节点处理时间
*/ */
calcTimer (time){ calcTimer (time){
const expireTime = (new Date(time)).getTime(); const expireTime = (new Date(time.replace(/-/g,'/'))).getTime();
const curTime = (new Date(this.data.serverTime)).getTime(); const curTime = (new Date(this.data.serverTime.replace(/-/g,'/'))).getTime();
// const curTime = (new Date('2022-4-16 15:22:00')).getTime(); // const curTime = (new Date('2022-4-16 15:22:00')).getTime();
const minute = parseInt((expireTime - curTime) / 60000); const minute = parseInt((expireTime - curTime) / 60000);
const day = parseInt(Math.floor(minute / 1440)); const day = parseInt(Math.floor(minute / 1440));

Loading…
Cancel
Save