Commit 6cc8b45d by 姜雷

添加支付调试页面

parent dad5c835
{
"name": "wx-school-app-public",
"version": "1.0.9",
"version": "1.0.10",
"private": true,
"description": "",
"scripts": {
......
......@@ -27,6 +27,7 @@ class App extends Component {
'pages/scanEnter/scanEnter',
'pages/index/index',
'pages/pay/pay',
'pages/stringPay/stringPay',
],
window: {
backgroundTextStyle: 'light',
......
.stringPay {
padding: 20px;
.stringPay-input {
width: 100%;
height: 600px;
border: 1px solid #eee;
margin-bottom: 50px;
}
}
import './stringPay.scss';
import Taro, { Component, useState, useCallback } from '@tarojs/taro';
import { View, Button, Textarea } from '@tarojs/components';
class stringPay extends Component {
render() {
const [value, setValue] = useState('');
const inputHandle = useCallback(
e => {
setValue(e.detail.value);
},
[setValue],
);
const payHandle = () => {
console.log(value);
if (value) {
const payData = JSON.parse(value);
Taro.requestPayment({
timeStamp: payData.timeStamp.toString(),
nonceStr: payData.nonceStr,
package: payData.package,
signType: payData.signType,
paySign: payData.paySign,
}).then(res => {
console.log(res);
Taro.showToast({
title: '支付成功!',
icon: 'success',
mask: true,
});
setValue('');
});
}
};
return (
<View className='stringPay'>
<Textarea
className='stringPay-input'
value={value}
onInput={inputHandle}></Textarea>
<Button onClick={payHandle}>支付</Button>
</View>
);
}
}
export default stringPay;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment