<template>
	<view v-cloak>
		<u-button shape="circle" @click="submit" :disabled="disabled">立即支付</u-button>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				disabled: false,
				sweixin: null,
			}
		},
		onShow() {
			if (this.disabled) {
				uni.switchTab({
					url: '/wuye/index/index'
				});
			}
		},
		onLoad(item) {
			// #ifdef APP-PLUS  
			plus.share.getServices((s) => {
				let shares = {};
				for (let i = 0; i < s.length; i++) {
					let t = s[i];
					shares[t.id] = t;
				}
				let sweixin = shares['weixin'];
				this.sweixin = sweixin
				console.log(this.sweixin)
			}, function(e) {
				console.log("获取分享服务列表失败:" + e.message);
			});
			//#endif
		},
		methods: {
			submit() {
				this.disabled = true
				this.$u.post(this.postUrl, '业务参数')
					.then(res => {
						if (res.code === 0) {
							var data=res.data;
								this.sweixin ? this.sweixin.launchMiniProgram({
										path: `pages/orderDetail/orderDetail?${res.data}`, //  可带参数
										type: 0, //可取值: 0-正式版; 1-测试版; 2-体验版。 默认值为0。
										id: '小程序的原始id' //小程序的原始id
									},
									res => {
										uni.switchTab({
											url: '/wuye/index/index'
										});
									},
									err => {
										if (err.code == -8) {
											uni.showToast({
												title: "未安装微信客户端",
												duration: 2000
											});
											setTimeout(() => {
												uni.switchTab({
													url: '/wuye/index/index'
												});
											}, 2000)
											return
										} else {
											uni.switchTab({
												url: '/wuye/index/index'
											});
										}
									}
								) : plus.nativeUI.alert('当前环境不支持微信操作!');
								return
						} else {
							this.$msg(res.msg)
						}
					})
			}
		},
	}
</script>

<style lang="scss" scoped>
</style>

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐