feat: 收益全额直入商城余额、存量结转与奖项名称全局规范化对齐
这个提交包含在:
@@ -18,8 +18,7 @@
|
||||
<view class="value-box ss-flex ss-col-bottom ss-row-center">
|
||||
<view class="value-text ss-line-1">{{ displayMadow }}</view>
|
||||
</view>
|
||||
<view class="sub-text">约¥{{ userInfo?.madow_value || '0.00' }}</view>
|
||||
<view class="menu-title ss-m-t-8">马豆</view>
|
||||
<view class="menu-title ss-m-t-16">马豆</view>
|
||||
</view>
|
||||
<view
|
||||
class="menu-item ss-flex-col ss-row-center ss-col-center"
|
||||
@@ -27,7 +26,7 @@
|
||||
>
|
||||
<view class="value-box ss-flex ss-col-bottom ss-row-center">
|
||||
<view class="value-text ss-line-1">{{ userInfo?.voucher_available || '0.00' }}</view>
|
||||
<view class="unit-text ss-m-l-6">元</view>
|
||||
<view class="unit-text ss-m-l-6">个</view>
|
||||
</view>
|
||||
<view class="menu-title ss-m-t-16">兑换券</view>
|
||||
</view>
|
||||
|
||||
@@ -75,8 +75,8 @@ const useProvider = (_provider = '') => {
|
||||
};
|
||||
|
||||
// 支付服务转发
|
||||
const pay = (payment, orderType, orderSN) => {
|
||||
return new Pay(payment, orderType, orderSN);
|
||||
const pay = (payment, orderType, orderSN, options = {}) => {
|
||||
return new Pay(payment, orderType, orderSN, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,10 +15,11 @@ import {
|
||||
*/
|
||||
|
||||
export default class SheepPay {
|
||||
constructor(payment, orderType, orderSN) {
|
||||
constructor(payment, orderType, orderSN, options = {}) {
|
||||
this.payment = payment;
|
||||
this.orderSN = orderSN;
|
||||
this.orderType = orderType;
|
||||
this.options = options || {};
|
||||
this.payAction();
|
||||
}
|
||||
|
||||
@@ -91,22 +92,31 @@ export default class SheepPay {
|
||||
order_sn: this.orderSN,
|
||||
payment: this.payment,
|
||||
};
|
||||
if (this.options && Number(this.options.money) > 0) {
|
||||
data.money = Number(this.options.money);
|
||||
}
|
||||
if (uni.getStorageSync('openid')) {
|
||||
data.openid = uni.getStorageSync('openid');
|
||||
}
|
||||
sheep.$api.pay.prepay(data).then((res) => {
|
||||
res.code === 1 && resolve(res);
|
||||
if (res.data === -1 && res.msg === 'miss_openid') {
|
||||
uni.showModal({
|
||||
title: '微信支付',
|
||||
content: '请先绑定微信再使用微信支付',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
sheep.$platform.useProvider('wechat').bind();
|
||||
}
|
||||
},
|
||||
});
|
||||
if (res && res.code === 1) {
|
||||
resolve(res);
|
||||
} else {
|
||||
if (res && res.data === -1 && res.msg === 'miss_openid') {
|
||||
uni.showModal({
|
||||
title: '微信支付',
|
||||
content: '请先绑定微信再使用微信支付',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
sheep.$platform.useProvider('wechat').bind();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
reject(res);
|
||||
}
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -114,51 +124,75 @@ export default class SheepPay {
|
||||
// 微信公众号JSSDK支付
|
||||
async wechatOfficialAccountPay() {
|
||||
let that = this;
|
||||
let {
|
||||
code,
|
||||
data,
|
||||
msg
|
||||
} = await this.prepay();
|
||||
if (code !== 1) {
|
||||
console.log('支付错误', msg);
|
||||
return;
|
||||
}
|
||||
$wxsdk.wxpay(data.pay_data, {
|
||||
success: () => {
|
||||
try {
|
||||
let {
|
||||
code,
|
||||
data,
|
||||
msg
|
||||
} = await this.prepay();
|
||||
if (code !== 1) {
|
||||
console.log('支付错误', msg);
|
||||
return;
|
||||
}
|
||||
if (!data?.pay_data) {
|
||||
that.payResult('success');
|
||||
},
|
||||
cancel: () => {
|
||||
sheep.$helper.toast('支付已手动取消');
|
||||
},
|
||||
fail: () => {
|
||||
that.payResult('fail');
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
$wxsdk.wxpay(data.pay_data, {
|
||||
success: () => {
|
||||
that.payResult('success');
|
||||
},
|
||||
cancel: () => {
|
||||
sheep.$helper.toast('支付已手动取消');
|
||||
},
|
||||
fail: () => {
|
||||
that.payResult('fail');
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.log('预支付未完成:', e);
|
||||
}
|
||||
}
|
||||
|
||||
//浏览器微信H5支付
|
||||
async wechatWapPay() {
|
||||
const {
|
||||
code,
|
||||
data
|
||||
} = await this.prepay();
|
||||
if (code === 1) {
|
||||
const redirect_url = `${getRootUrl()}pages/pay/result?orderSN=${this.orderSN}&payment=${this.payment
|
||||
}&orderType=${this.orderType}`;
|
||||
location.href = `${data.pay_data.h5_url}&redirect_url=${encodeURIComponent(redirect_url)}`;
|
||||
try {
|
||||
const {
|
||||
code,
|
||||
data
|
||||
} = await this.prepay();
|
||||
if (code === 1) {
|
||||
if (!data?.pay_data) {
|
||||
this.payResult('success');
|
||||
return;
|
||||
}
|
||||
const redirect_url = `${getRootUrl()}pages/pay/result?orderSN=${this.orderSN}&payment=${this.payment
|
||||
}&orderType=${this.orderType}`;
|
||||
location.href = `${data.pay_data.h5_url}&redirect_url=${encodeURIComponent(redirect_url)}`;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('预支付未完成:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 支付链接
|
||||
async redirectPay() {
|
||||
let {
|
||||
code,
|
||||
data
|
||||
} = await this.prepay();
|
||||
if (code === 1) {
|
||||
const redirect_url = `${getRootUrl()}pages/pay/result?orderSN=${this.orderSN}&payment=${this.payment
|
||||
}&orderType=${this.orderType}`;
|
||||
location.href = data.pay_data + encodeURIComponent(redirect_url);
|
||||
try {
|
||||
let {
|
||||
code,
|
||||
data
|
||||
} = await this.prepay();
|
||||
if (code === 1) {
|
||||
if (!data?.pay_data) {
|
||||
this.payResult('success');
|
||||
return;
|
||||
}
|
||||
const redirect_url = `${getRootUrl()}pages/pay/result?orderSN=${this.orderSN}&payment=${this.payment
|
||||
}&orderType=${this.orderType}`;
|
||||
location.href = data.pay_data + encodeURIComponent(redirect_url);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('预支付未完成:', e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,104 +201,145 @@ export default class SheepPay {
|
||||
// 微信小程序支付
|
||||
async wechatMiniProgramPay() {
|
||||
let that = this;
|
||||
let result = await this.prepay();
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
...result.data.pay_data,
|
||||
success: (res) => {
|
||||
try {
|
||||
let result = await this.prepay();
|
||||
if (result.code !== 1) return;
|
||||
if (!result.data?.pay_data) {
|
||||
that.payResult('success');
|
||||
},
|
||||
fail: (err) => {
|
||||
if (err.errMsg === 'requestPayment:fail cancel') {
|
||||
sheep.$helper.toast('支付已手动取消');
|
||||
} else {
|
||||
that.payResult('fail');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 余额支付
|
||||
async moneyPay() {
|
||||
const {
|
||||
code
|
||||
} = await this.prepay();
|
||||
code === 1 && this.payResult('success');
|
||||
}
|
||||
|
||||
// 货到付款
|
||||
async offlinePay() {
|
||||
const {
|
||||
code
|
||||
} = await this.prepay();
|
||||
code === 1 && this.payResult('success');
|
||||
}
|
||||
|
||||
// 支付宝复制链接支付
|
||||
async copyPayLink() {
|
||||
let that = this;
|
||||
let {
|
||||
code,
|
||||
data
|
||||
} = await this.prepay();
|
||||
if (code === 1) {
|
||||
// 引入showModal 点击确认 复制链接;
|
||||
uni.showModal({
|
||||
title: '支付宝支付',
|
||||
content: '复制链接到外部浏览器',
|
||||
confirmText: '复制链接',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
sheep.$helper.copyText(data.pay_data);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 支付宝支付
|
||||
async alipay() {
|
||||
let that = this;
|
||||
const {
|
||||
code,
|
||||
data
|
||||
} = await this.prepay();
|
||||
if (code === 1) {
|
||||
return;
|
||||
}
|
||||
uni.requestPayment({
|
||||
provider: 'alipay',
|
||||
orderInfo: data.pay_data, //支付宝订单数据
|
||||
provider: 'wxpay',
|
||||
...result.data.pay_data,
|
||||
success: (res) => {
|
||||
that.payResult('success');
|
||||
},
|
||||
fail: (err) => {
|
||||
if (err.errMsg === 'requestPayment:fail [paymentAlipay:62001]user cancel') {
|
||||
if (err.errMsg === 'requestPayment:fail cancel') {
|
||||
sheep.$helper.toast('支付已手动取消');
|
||||
} else {
|
||||
that.payResult('fail');
|
||||
}
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.log('预支付未完成:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 余额支付
|
||||
async moneyPay() {
|
||||
try {
|
||||
const {
|
||||
code
|
||||
} = await this.prepay();
|
||||
code === 1 && this.payResult('success');
|
||||
} catch (e) {
|
||||
console.log('余额支付未完成:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 货到付款
|
||||
async offlinePay() {
|
||||
try {
|
||||
const {
|
||||
code
|
||||
} = await this.prepay();
|
||||
code === 1 && this.payResult('success');
|
||||
} catch (e) {
|
||||
console.log('货到付款未完成:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 支付宝复制链接支付
|
||||
async copyPayLink() {
|
||||
let that = this;
|
||||
try {
|
||||
let {
|
||||
code,
|
||||
data
|
||||
} = await this.prepay();
|
||||
if (code === 1) {
|
||||
if (!data?.pay_data) {
|
||||
that.payResult('success');
|
||||
return;
|
||||
}
|
||||
// 引入showModal 点击确认 复制链接;
|
||||
uni.showModal({
|
||||
title: '支付宝支付',
|
||||
content: '复制链接到外部浏览器',
|
||||
confirmText: '复制链接',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
sheep.$helper.copyText(data.pay_data);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('复制支付链接未完成:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 支付宝支付
|
||||
async alipay() {
|
||||
let that = this;
|
||||
try {
|
||||
const {
|
||||
code,
|
||||
data
|
||||
} = await this.prepay();
|
||||
if (code === 1) {
|
||||
if (!data?.pay_data) {
|
||||
that.payResult('success');
|
||||
return;
|
||||
}
|
||||
uni.requestPayment({
|
||||
provider: 'alipay',
|
||||
orderInfo: data.pay_data, //支付宝订单数据
|
||||
success: (res) => {
|
||||
that.payResult('success');
|
||||
},
|
||||
fail: (err) => {
|
||||
if (err.errMsg === 'requestPayment:fail [paymentAlipay:62001]user cancel') {
|
||||
sheep.$helper.toast('支付已手动取消');
|
||||
} else {
|
||||
that.payResult('fail');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('支付宝预支付未完成:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 微信支付
|
||||
async wechatAppPay() {
|
||||
let that = this;
|
||||
let {
|
||||
code,
|
||||
data
|
||||
} = await this.prepay();
|
||||
if (code === 1) {
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
orderInfo: data.pay_data, //微信订单数据(官方说是string。实测为object)
|
||||
success: (res) => {
|
||||
try {
|
||||
let {
|
||||
code,
|
||||
data
|
||||
} = await this.prepay();
|
||||
if (code === 1) {
|
||||
if (!data?.pay_data) {
|
||||
that.payResult('success');
|
||||
},
|
||||
fail: (err) => {
|
||||
err.errMsg !== 'requestPayment:fail cancel' && that.payResult('fail');
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
orderInfo: data.pay_data, //微信订单数据(官方说是string。实测为object)
|
||||
success: (res) => {
|
||||
that.payResult('success');
|
||||
},
|
||||
fail: (err) => {
|
||||
err.errMsg !== 'requestPayment:fail cancel' && that.payResult('fail');
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('微信App预支付未完成:', e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ const defaultUserInfo = {
|
||||
madow: '', // 马豆数量
|
||||
madow_rate: '', // 马豆汇率
|
||||
madow_value: '', // 马豆约合
|
||||
show_madow_rate: 1, // 是否显示马豆市值
|
||||
voucher_available: '', // 可用兑换券
|
||||
active_30d: true, // 近 30 日是否有本人订单
|
||||
agent_form: false,
|
||||
|
||||
在新工单中引用
屏蔽一个用户