支付
import React, { useState } from 'react' import QRCode from 'qrcode' export default function ceshi() { const [image,setImage] =useState(); const handleget =async ()=>{ const landingPageUrl = 'weixin:。。。。。。'; const qrcodeUrl = await QRCode.toDataURL(landingPageUrl); setImage(qrcodeUrl) } return ( <div> <img style={{width:"200px",height:"200px"}} src={image} alt="" /> <button onClick={handleget}>点击</button> </div> ) }
<template> <view class="tabnav"> <view class="tabnav-c"> <button @click="get()">点击</button> </view> <Tabbar :current="1"></Tabbar> </view> </template> <script lang="ts"> import { defineComponent } from 'vue' import Tabbar from '../tabnav/index.vue' export default defineComponent({ components: { Tabbar, }, setup() { const get = () => { uni.getProvider({ service: 'payment', success: function (res:any) { console.log('===================================='); console.log(res); console.log('===================================='); // if (res.provider.indexOf("alipay")) { // 支付宝支付功能可用 // 进行支付请求 uni.requestPayment({ provider: 'alipay', orderInfo: 'alipay_sdk=alipay-sdk-java-4.38.4.ALL&app_id=2021004109673258&biz_content=%7B%22out_trade_no%22%3A%2220230819%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22subject%22%3A%22%E6%B5%8B%E8%AF%95%E4%BA%A7%E5%93%81%22%2C%22total_amount%22%3A%220.01000000000000000020816681711721685132943093776702880859375%22%7D&charset=UTF-8&format=JSON&method=alipay.trade.app.pay&sign=Ef%2FFRPPU8qtBcMC1XJthcBOfvZhXauh4PsJX6m6AieUuGHpvXIFPbmVTj0cBL8DWHHL5OknrqVD3Gy0V9yC9n%2B4Q2RbfhMfhDT%2FHIOAITu4ygZqJ6VcwAPVQcc0vxppB8VYfOJvmorX%2BsaccYw24ZE7KBzX39%2Bl0zHTOdrV%2FC8Rqbqd2E5w2rrIxu4zxBzE4XcFhodIO7PvezKjX%2ByxS%2Fu9HRORapA%2F3GWbgZwcFSSztLVab%2FHPzEgmP4%2Bj6Vq12O7z%2FpRJwCFxXFzJYAh2KYKRwDwQfh4fojvtkWAKf9K5lPfXJLwz%2BRMNn1pemXCqH%2Fm1BdPYXbTBR2%2BjUCRynjQ%3D%3D&sign_type=RSA2×tamp=2023-08-18+11%3A19%3A32&version=1.0', success: function (res) { console.log('支付成功'); alert("支付成功") }, fail: function (err) { alert("支付失败") console.log('支付失败', err); } }) // } }, fail: function (err) { console.log('暂不支持支付宝支付'); alert('暂不支持支付宝支付') } }) } return { get } }, }) </script> <style scoped lang="scss"></style>
本文来自博客园,作者:zjxgdq,转载请注明原文链接:https://www.cnblogs.com/zjxzhj/p/17523221.html