feat:转账

This commit is contained in:
dzc committed 2025-12-31 17:20:36 +08:00
1 parent a280a3a396
commit f157e521e1
8 files changed
+252 -25

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ SHOPRO_VERSION=v2.4.1
SHOPRO_API_PATH=/app-api
# 后端接口 - 测试环境(通过 process.env.NODE_ENV == development)
# SHOPRO_DEV_BASE_URL=http://192.168.68.52:48083
# SHOPRO_DEV_BASE_URL=http://127.0.0.1:48083
# SHOPRO_DEV_BASE_URL = https://chatapi.zianxin.com
SHOPRO_DEV_BASE_URL=https://dzc001.fy.takin.cc
+5 -11
View File
@@ -281,16 +281,8 @@
<div class="download-btn" id="downloadButton" style="visibility: visible;" onclick="download()">
<div class="download-btn-real">下载安装</div>
</div>
<!-- <div id="footer" class="pc footer pc-footer">
<div class="footer-container">
<p id='company1'>Copyright©2025 &nbsp;开发者:浙江资安信信息科技有限公司 &nbsp;&nbsp;|&nbsp;&nbsp;版本号:&nbsp;安卓1.0.0 &nbsp;</p>
<p>更新时间:&nbsp;2025年12月12日</p>
</div>
</div> -->
<div id="footer" class="msite footer msite-footer">
<div class="footer-container">
<p id='company2'>Copyright©2025 &nbsp;开发者:浙江资安信信息科技有限公司 &nbsp;&nbsp;|&nbsp;&nbsp;版本号:&nbsp;1.0.0 &nbsp;
</p>
<p>更新时间:&nbsp;2025年12月12日</p>
</div>
</div>
@@ -333,7 +325,7 @@
client = judgeClient()
if (client == 'android') {
const ua = navigator.userAgent
var src = 'https://down.newroad.top/%E7%BC%98%E9%81%87%E5%9C%88_v5.9.6.apk';
var src = 'http://hch5.zianxin.com/荷塘月色.apk';
var form = document.createElement('form');
form.action = src;
document.getElementsByTagName('body')[0].appendChild(form);
@@ -341,7 +333,8 @@
return
}
if (client == 'ios') {
window.open("https://apps.apple.com/cn/app/id6444849074", "_self")
// window.open("https://apps.apple.com/cn/app/id6444849074", "_self")
alert("暂不支持")
}
}
@@ -352,7 +345,8 @@
return;
}
if (isInitSuccess && client == 'ios') {
ShareTrace.download();
// ShareTrace.download();
alert("暂不支持")
} else {
//如果初始化失败建议自己指定下载地址,虽然不能获取安装参数但是不会影响用户的下载
_download()
+26
View File
@@ -152,6 +152,18 @@
],
// #ifdef MP-WEIXIN
"subPackages": [
{
"root": "pages/login",
"pages": [
{
"path": "login",
"style": {
"navigationBarTitleText": "登录",
"navigationStyle": "custom"
}
}
]
},
{
"root": "pages/profile",
"pages": [
@@ -222,6 +234,13 @@
"navigationBarTitleText": "提现",
"navigationStyle": "custom"
}
},
{
"path": "pages/withraw-record",
"style": {
"navigationBarTitleText": "提现",
"navigationStyle": "custom"
}
}
]
}
@@ -502,6 +521,13 @@
"navigationBarTitleText": "提现",
"navigationStyle": "custom"
}
},
{
"path": "pages/withraw-record",
"style": {
"navigationBarTitleText": "提现",
"navigationStyle": "custom"
}
}
]
}
+34 -2
View File
@@ -98,6 +98,7 @@
<wd-message-box />
<wd-message-box selector="bind-wechat" />
<wd-message-box selector="bind-wechat-confirm" />
<wd-message-box selector="jump-wechat" />
</wd-config-provider>
</template>
@@ -111,8 +112,10 @@ import BrokerageApi from '@/sheep/api/trade/brokerage';
import TradeConfigApi from '@/sheep/api/trade/config.js';
import { useMessage } from '@/uni_modules/wot-design-uni';
import useBindWechat from "@/sheep/hooks/use-bind-wechat"
import { jumpToWechatMiniProgram } from '@/sheep/util/wechat-tool';
const message = useMessage();
const jumpWechatMessage = useMessage('jump-wechat');
const userInfo = computed(() => sheep.$store('user')?.userInfo ?? null);
const isLogin = computed(() => sheep.$store('user').isLogin && state.loginInfoStorage != null);
@@ -147,7 +150,7 @@ const data = {
title: '邀请好友',
icon: 'icon-tianjiahaoyou',
bgColor: '#a4e55a',
path: '',
path: '/pages/wechat/pages/inviter/index',
},
],
};
@@ -191,7 +194,9 @@ const { bindWechatNum, open: openBindWechat } = useBindWechat(() => {
onLoad(async () => {
// #ifdef MP-WEIXIN
await sheep.$platform.useProvider('wechat').bind();
if (isLogin.value) {
await sheep.$platform.useProvider('wechat').bind();
}
// #endif
})
@@ -320,7 +325,34 @@ const doTx = async () => {
openBindWechat(state.wechatNum)
return;
}
// #ifdef MP-WEIXIN
uni.navigateTo({ url: '/pages/wechat/pages/withdraw' })
// #endif
// TODO 由于是到账到微信,所以必须跳转到微信小程序
// #ifndef MP-WEIXIN
jumpWechatMessage.confirm({
msg: '由于是到账到微信,所以必须跳转到微信小程序',
title: '',
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(async () => {
try {
const url = await jumpToWechatMiniProgram('home', {});
if (!url) {
uni.showToast({ title: '获取小程序短链失败', icon: 'none' });
throw new Error('获取小程序短链失败');
}
// #ifdef H5
window.location.href = url
// #endif
// #ifdef APP-PLUS
plus.runtime.openURL(url)
// #endif
} catch (error) {
console.log('|跳转微信小程序|,意外的错误error:', error);
}
})
// #endif
}
const authDialog = () => {
+5
View File
@@ -58,6 +58,11 @@ onShow(async () => {
state.loginInfoStorage = uni.getStorageSync('loginInfo') ?? null
});
const doLogin = () => {
sheep.$store('user').logout();
uni.reLaunch({ url: '/pages/login/login' });
}
const doLogout = () => {
message
.confirm({
+39 -10
View File
@@ -2,9 +2,20 @@
<wd-config-provider theme="dark">
<wd-navbar :title="pageType == 'yj' ? '分销提现' : '礼物提现'" safeAreaInsetTop :bordered="false">
<template #left>
<navigator open-type="navigateBack" hover-class="navigator-hover">
<uni-icons type="back" size="30" color="#D29E52"></uni-icons>
</navigator>
<view class="flex items-center">
<navigator open-type="navigateBack" hover-class="navigator-hover">
<uni-icons type="back" size="30" color="#D29E52"></uni-icons>
</navigator>
<!-- #ifdef MP-WEIXIN -->
<navigator url="/pages/wechat/pages/withraw-record" open-type="navigate"
hover-class="navigator-hover">
<view
class="flex items-center rounded-full h-44rpx bg-color-theme py-1 px-2 text-black text-sm">
历史记录
</view>
</navigator>
<!-- #endif -->
</view>
</template>
</wd-navbar>
<view class="bg-color-dark rounded-12rpx px-4 py-3 mx-20rpx mt-30rpx">
@@ -96,25 +107,43 @@ onShow(() => {
// 提现
const doTx = async () => {
uni.showLoading({ title: '提现中...', mask: true })
uni.showLoading({ title: '申请提现中...', mask: true })
const isValidate = await txValidate()
if (!isValidate) {
uni.hideLoading()
return
}
try {
const price = Number(state.price) * 100
const data = {
// 3:微信;5:微信零钱;
type: 5,
price: Number(state.price) * 100,
accountNo: state.wechatNum
price: price,
accountNo: state.wechatNum,
channelExtras: {
sceneId: '1005',
sceneReportInfos: [
{
"info_type": "活动名称",
"info_content": "佣金提现"
},
{
"info_type": "奖励说明",
"info_content": `提现${fen2yuanSimple(price)}元`
},
]
}
}
const { code } = await BrokerageApi.createBrokerageWithdraw(data);
if (code !== 0) {
uni.showToast({ title: '提现失败', icon: "none" })
throw new Error('提现失败')
const { code: createCode, data: createData } = await BrokerageApi.createBrokerageWithdraw(data);
if (createCode !== 0) {
uni.hideLoading()
uni.showToast({ title: '申请提现失败', icon: "none" })
throw new Error('申请提现失败')
}
uni.hideLoading()
uni.showToast({ title: '申请提现成功', icon: "success" })
} catch (error) {
uni.hideLoading()
console.log("|提现|,意外的错误error:", error);
}
}
+109
View File
@@ -0,0 +1,109 @@
<template>
<wd-config-provider theme="dark">
<wd-navbar title="提现历史记录" safeAreaInsetTop :bordered="false">
<template #left>
<navigator open-type="navigateBack" hover-class="navigator-hover">
<uni-icons type="back" size="30" color="#D29E52"></uni-icons>
</navigator>
</template>
</wd-navbar>
<scroll-list style="height: calc(100dvh - 44px - 50px)" :loadMoreStatus="loadMoreStatus" @refresh="refreshList"
@loadMore="listLoadMore">
<view class="flex-col justify-center bg-[#1E1E1E] rounded-lg mx-20rpx px-30rpx py-30rpx mb-20rpx"
v-for="(v, i) in listData" :key="v.id">
<view class="flex justify-between items-center mb-10rpx">
<text class="text-white text-base font-bold">{{ v.typeName }}</text>
<text class="text-[#D29E52] text-lg font-bold">{{ fen2yuan(v.price) }} 元</text>
</view>
<view class="flex justify-between items-center">
<text class="text-[#999999] text-xs">
{{ formatDate(v.createTime) }}
</text>
{{ v.status }}
<button v-if="v.status === 10 && v.type === 5 && v.payTransferId > 0"
class="m-0 text-xs bg-[#D29E52] text-black px-3 py-1 rounded-full"
@tap="onRequestMerchantTransfer(v)">
确认收款
</button>
<view v-else class="text-xs px-2 py-0.5 rounded" :class="{
'text-[#409eff] bg-[#409eff]/10': v.status === 0,
'text-[#ff9900] bg-[#ff9900]/10': v.status === 10,
'text-[#19be6b] bg-[#19be6b]/10': v.status === 11,
'text-[#fa3534] bg-[#fa3534]/10': [20, 21].includes(v.status)
}">
{{ v.statusName }}
</view>
</view>
</view>
</scroll-list>
</wd-config-provider>
</template>
<script setup lang="ts">
import { onLoad, onShow } from '@dcloudio/uni-app';
// @ts-ignore
import { fen2yuan, fen2yuanSimple } from '@/sheep/hooks/useGoods';
// @ts-ignore
import { formatDate } from '@/sheep/helper/utils';
// @ts-ignore
import BrokerageApi from '@/sheep/api/trade/brokerage';
// @ts-ignore
import PayTransferApi from '@/sheep/api/pay/transfer';
import ScrollList from '@/sheep/components/scroll-list/scroll-list.vue';
import useScroll from '@/sheep/hooks/use-scroll';
import { requestMerchantTransfer } from "@/sheep/util/wechat-tool"
const { listData, loadMoreStatus, refreshList, listLoadMore } = useScroll(
BrokerageApi.getBrokerageWithdrawPage,
);
onShow(() => {
refreshList();
});
const onRequestMerchantTransfer = async (item: any) => {
// 获取提现详情
const { code: withdrawCode, data: withdrawData } = await BrokerageApi.getBrokerageWithdraw(item.id);
if (withdrawCode !== 0) {
uni.hideLoading()
uni.showToast({ title: '获取提现详情失败', icon: "none" })
throw new Error('获取提现详情失败')
}
if (withdrawData.status === 11) {
uni.showToast({ title: '该提现单已确认收款', icon: "none" })
return;
}
if (!withdrawData.transferChannelMchId || !withdrawData.transferChannelPackageInfo) {
uni.showToast({ title: '提现信息异常,请稍后再试', icon: "none" })
return;
}
// 调用微信确认收款
const payTransferId = withdrawData.payTransferId;
requestMerchantTransfer(
withdrawData.transferChannelMchId,
withdrawData.transferChannelPackageInfo,
async (res: any) => {
if (res.result !== 'success') {
uni.showToast({ title: res.errMsg, icon: "success" })
return;
}
// 同步转账单状态
try {
const syncTransferResult = await PayTransferApi.syncTransfer(payTransferId);
console.log('syncTransferResult 结果', syncTransferResult);
} catch (e) {
console.error('syncTransferResult 异常', e);
}
// 查询提现单最新状态
const { data } = await BrokerageApi.getBrokerageWithdraw(item.id);
if (data && data.status !== 11) {
uni.showToast({ title: '确认收款成功,但数据存在延迟,请以实际【微信支付】到账为准', icon: "none" })
return;
}
},
(err: any) => {
console.error('微信获取佣金失败error:', err);
}
)
}
</script>
+33 -1
View File
@@ -16,7 +16,7 @@ const paramsToQuery = (params) => {
};
export const jumpToWechatMiniProgram = async (
action: 'recharge' | 'openVip',
action: 'recharge' | 'openVip' | 'home',
params: Record<string, any>,
) => {
let path = '';
@@ -27,6 +27,9 @@ export const jumpToWechatMiniProgram = async (
if (action === 'openVip') {
path = 'pages/profile/apply-vip';
}
if (action === 'home') {
path = 'pages/wechat-tabbar/index';
}
if (!isEmpty(params)) {
_params = paramsToQuery(params);
console.log('|跳转微信小程序|参数_params:', _params);
@@ -42,3 +45,32 @@ export const jumpToWechatMiniProgram = async (
console.log('|获取小程序短链|意外的错误error:', error);
}
};
// 商家转账用户确认模式下,拉起页面请求用户确认收款 Transfer
export function requestMerchantTransfer(mchId, packageInfo, successCallback, failCallback) {
if (!uni.canIUse('requestMerchantTransfer')) {
uni.showModal({
content: '你的微信版本过低,请更新至最新版本。',
showCancel: false,
});
return;
}
uni.requestMerchantTransfer({
mchId: mchId,
appId: uni.getAccountInfoSync().miniProgram.appId,
package: packageInfo,
success: (res) => {
// res.err_msg 将在页面展示成功后返回应用时返回 ok,并不代表付款成功
console.log('success:', res);
successCallback && successCallback(res);
},
fail: (res) => {
console.log('fail:', res);
uni.showToast({
title: res.errMsg,
icon: 'none',
});
failCallback && failCallback(res);
},
});
}