vue3 微信jsapi支付


<script setup lang="ts">
import { onMounted } from 'vue'
import wx from 'weixin-js-sdk'
wx.config({
    // debug: false, // 开启调试模式
    // appId: config.appId, // 必填,公众号的唯一标识
    // timestamp: config.timestamp, // 必填,生成签名的时间戳
    // nonceStr: config.nonceStr, // 必填,生成签名的随机串
    // signature: config.signature, // 必填,签名
    jsApiList: [
        'onMenuShareTimeline', // 分享到朋友圈
        'onMenuShareAppMessage' // 分享给朋友
        // ...其他需要使用的JS接口列表
    ] // 必填,需要使用的JS接口列表
})
wx.ready(function () {
    // 在这里调用微信相关的API
    console.log(11)
})
function wxreany() {
    console.log('微信JSSDK初始化失败')
    wx.error(function (res: any) {
        console.log('微信JSSDK初始化失败:' + res.errMsg)
    })
}

wx.error(function (res: any) {
    console.log('微信JSSDK初始化失败:' + res.errMsg)
})
onMounted(() => {
    wxreany()
    console.log(wx)
})
</script>

<template>
    <div class="page">
        <div>
            <button>支付</button>
        </div>
        <div>
            <button>下单</button>
        </div>
    </div>
</template>

<style lang="less" scoped>
.page {
    width: 100%;
    height: 100%;
}
</style>

我需要做一个H5页面在微信内JSAPI支付有偿有环境后端支持

【相关推荐】



  • 这篇文章:vue 编写H5页面在公众号外部获取手机本地坐标经纬度 也许能够解决你的问题,你可以看下
  • 除此之外, 这篇博客: vue接入微信jsapi支付中的 在h5中接入微信jsapi支付 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:

    JSAPI支付是用户在微信中打开商户的H5页面,商户在H5页面通过调用微信支付提供的JSAPI接口调起微信支付模块完成支付。应用场景有:

    ◆ 用户在微信公众账号内进入商家公众号,打开某个主页面,完成支付
    ◆ 用户的好友在朋友圈、聊天窗口等分享商家页面连接,用户点击链接打开商家页面,完成支付
    ◆ 将商户页面转换成二维码,用户扫描二维码后在微信浏览器中打开页面后完成支付


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^