<template>
	<view>
		<view :style="{marginTop:navH}"></view>
		<view class="btn" @click="wxpay()">下单11</view>
	</view>
</template>

<script>
	export default {
		name: 'test',
		data() {
			return {
				navH: getApp().globalData.navHeight,
				url: 'http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400'
			}
		},
		methods: {
			wxpay() {
				this.$https.post('/youngee/c/api/t/wxpay/pay', {
					amount: 1,
					description: "测试商品",
				}).then(res => {
					console.log(res)
					let data = res.data.data
					wx.requestPayment({
						"timeStamp": data.time_stamp,
						"nonceStr": data.nonce_str,
						"package": data.package,
						"signType": "RSA",
						"paySign": data.pay_sign,
						"success": function(res) {
							// 支付成功时执行
							console.log("支付成功: ", res.errMsg)
						},
						"fail": function(res) {
							// 调起失败或取消支付时执行
							console.log("支付失败: ", res.errMsg)
						},
						"complete": function(res) {
							// 成功或失败都会执行
							console.log("支付结束: ", res.errMsg)
						}
					})
				})
			}
		}
	}
</script>