Browse Source

feat(提现): 实现微信商户转账提现功能

- 添加商户号配置和提现相关API接口
- 修改佣金显示字段为userInfo.recommendAmount
- 实现微信requestMerchantTransfer提现流程
- 添加提现记录页面状态显示和领取功能
- 调整提现金额验证规则为大于1的整数
pull/9/head
前端-胡立永 1 month ago
parent
commit
80040f273b
6 changed files with 175 additions and 20 deletions
  1. +22
    -0
      api/model/info.js
  2. +2
    -0
      config.js
  3. +1
    -1
      manifest.json
  4. +1
    -1
      pages_order/mine/partner.vue
  5. +53
    -2
      pages_order/mine/runningWater.vue
  6. +96
    -16
      pages_order/mine/withdraw.vue

+ 22
- 0
api/model/info.js View File

@ -54,6 +54,28 @@ const api = {
limit: 1000,
showLoading: true,
},
// 钱包-提现
cashout: {
url: '/amount/cashout',
method: 'POST',
auth: true,
limit: 1000,
showLoading: true,
},
// 钱包-领取提现金额
getMoney: {
url: '/amount/getMoney',
method: 'POST',
auth: true,
limit: 1000,
showLoading: true,
},
// 钱包-提现记录列表
queryCashoutLog: {
url: '/amount/queryCashoutLog',
method: 'GET',
auth: true,
},
// 获取地址列表带分页
getAddressPageList: {
url: '/info_common/getAddressPageList',


+ 2
- 0
config.js View File

@ -38,6 +38,8 @@ const defaultConfig = {
endpoint: 'oss-cn-shenzhen.aliyuncs.com',
}
},
//商户号
mchId : '1712378227',
}


+ 1
- 1
manifest.json View File

@ -1,6 +1,6 @@
{
"name" : "unapp模板",
"appid" : "__UNI__C572032",
"appid" : "__UNI__197A38F",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",


+ 1
- 1
pages_order/mine/partner.vue View File

@ -13,7 +13,7 @@
<view class="phone">{{ userInfo.phone }}</view>
<view class="flex account">
<view class="count">
<view><text class="count-unit">¥</text>{{ riceInfo.canWithdraw || 0 }}</view>
<view><text class="count-unit">¥</text>{{ userInfo.recommendAmount || 0 }}</view>
<view class="count-desc">推广佣金</view>
</view>
<button plain class="btn" @click="$utils.navigateTo('/pages_order/mine/withdraw')">去提现</button>


+ 53
- 2
pages_order/mine/runningWater.vue View File

@ -28,7 +28,10 @@
<view class="highlight">佣金提现</view>
<view>{{ item.createTime }}</view>
</view>
<view class="list-item-value">{{ `-${item.money}` }}</view>
<view class="list-item-value">{{ `-${item.amount}` }}</view>
<view class="uni-color-btn"
@click="withdraw(item)"
v-if="item.status == 0">领取</view>
</view>
</template>
<template v-else>
@ -48,7 +51,7 @@
selectedTime: new Date(),
x: ['+', '-', '-', '+'],
mixinsListApi: "getWaterPageList",
mixinsListApi: "queryCashoutLog",//getWaterPageList
beforeDate: new Date(), //
afterDate: new Date(), //
@ -96,6 +99,47 @@
// todo
console.log('--onTimeChange', e)
},
withdraw(item){
//
if (!wx.canIUse('requestMerchantTransfer')) {
wx.showModal({
content: '你的微信版本过低,请更新至最新版本。',
showCancel: false,
});
return
}
// API
wx.requestMerchantTransfer({
mchId: this.$config.mchId,
appId: wx.getAccountInfoSync().miniProgram.appId,
package: item.packageInfo,
success: (res) => {
uni.showToast({
title: '提现申请已提交',
icon: 'success'
})
this.$store.commit('getUserInfo')
this.$store.commit('getRiceInfo')
this.$api('getMoney', {
id : item.id,
}).then(res => {
this.getData()
})
},
fail: (res) => {
console.log('fail:', res);
uni.showToast({
title: '提现失败,请稍后再试',
icon: 'none'
})
},
complete: (res) => {
console.log('requestMerchantTransfer完成:', res);
}
});
},
}
}
</script>
@ -109,6 +153,13 @@
background-image: linear-gradient(#84A73F, #D8FF8F);
}
}
.uni-color-btn{
padding: 10rpx 20rpx;
margin: 0;
font-size: 26rpx;
margin-left: 20rpx;
}
.tools {
background-color: $uni-fg-color;


+ 96
- 16
pages_order/mine/withdraw.vue View File

@ -10,11 +10,11 @@
<image class="info-bg" src="../static/withdraw/bg.png"></image>
<view class="info-content">
<view class="label">佣金余额</view>
<view class="value">{{ riceInfo.canWithdraw || 0 }}</view>
<view class="label">佣金</view>
<view class="value">{{ userInfo.recommendAmount || 0 }}</view>
<view class="flex desc">
<!-- todo: 对接接口字段 -->
<view>{{ `累积提现:${123 || 0}` }}</view>
<view>{{ `累积提现:${userInfo.cashoutSum || 0}` }}</view>
<button plain class="btn" @click="toRunningWater">
<text>提现记录</text>
<image class="btn-icon" src="@/static/image/center/icon-arrow.png" mode="widthFix"></image>
@ -108,14 +108,20 @@
return
}
// todo
if (this.form.money < 300) {
if (this.form.money < 1) {
return uni.showToast({
title: '未满300元不可提现哦!',
title: '提现只能是整数必须大于1!',
icon: 'none'
})
}
// todo
// if (this.form.money < 300) {
// return uni.showToast({
// title: '300',
// icon: 'none'
// })
// }
let isOk = this.parameterVerification();
if (isOk && !isOk.auth) {
return uni.showToast({
@ -123,17 +129,91 @@
icon: 'none'
})
}
this.$api('recharge', this.form, res => {
if (res.code == 200) {
uni.showToast({
title: '提现成功',
icon: 'none'
})
this.$store.commit('getUserInfo')
this.$store.commit('getRiceInfo')
}
// this.$api('recharge', this.form, res => {
// if (res.code == 200) {
// uni.showToast({
// title: '',
// icon: 'none'
// })
// this.$store.commit('getUserInfo')
// this.$store.commit('getRiceInfo')
// }
// })
//
uni.showLoading({
title: '提交中...'
})
//
this.$api('cashout', { transferAmount: this.form.money, userName: this.form.name }, res => {
uni.hideLoading()
if (res.code === 200) {
//
if (res.result && res.result.state === 'WAIT_USER_CONFIRM' && res.result.packageInfo && res.result.outBillNo) {
//
if (!wx.canIUse('requestMerchantTransfer')) {
wx.showModal({
content: '你的微信版本过低,请更新至最新版本。',
showCancel: false,
});
return
}
let data = res.result
// API
wx.requestMerchantTransfer({
mchId: this.$config.mchId,
appId: wx.getAccountInfoSync().miniProgram.appId,
package: res.result.packageInfo,
success: (res) => {
uni.showToast({
title: '提现申请已提交',
icon: 'success'
})
this.form.money = ''
this.form.name = ''
this.$api('getMoney', {
id : data.outBillNo,
}).then(res => {
this.$store.commit('getUserInfo')
this.$store.commit('getRiceInfo')
})
},
fail: (res) => {
console.log('fail:', res);
uni.showToast({
title: '提现失败,请稍后再试',
icon: 'none'
})
},
complete: (res) => {
console.log('requestMerchantTransfer完成:', res);
}
});
} else {
uni.showToast({
title: '提现成功',
icon: 'success'
})
this.$store.commit('getUserInfo')
this.form.money = ''
this.form.name = ''
}
}else {
uni.showToast({
title: '提现只能是整数必须大于1!',
icon: 'none'
})
}
})
},
parameterVerification() { //
let {


Loading…
Cancel
Save