<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支付有偿有环境后端支持
【相关推荐】
JSAPI支付是用户在微信中打开商户的H5页面,商户在H5页面通过调用微信支付提供的JSAPI接口调起微信支付模块完成支付。应用场景有:
◆ 用户在微信公众账号内进入商家公众号,打开某个主页面,完成支付
◆ 用户的好友在朋友圈、聊天窗口等分享商家页面连接,用户点击链接打开商家页面,完成支付
◆ 将商户页面转换成二维码,用户扫描二维码后在微信浏览器中打开页面后完成支付