uniapp支付页面模板

在这里插入图片描述

支付组件

<template>
	<view>
		<u-popup v-model="show" mode="bottom" :closeable="true" @close="close">
			<view class="plr-40">
				<view class="center ptb-30">选择支付方式</view>
				<u-radio-group v-model="value">
					<u-radio name="2" class="w100 bb ptb-30">
						微信支付
					</u-radio>
					<u-radio name="1" class="w100 ptb-30">
						余额支付
					</u-radio>
				</u-radio-group>
				<view class="ptb-50">
					<u-button type="primary" @click="pay">确定</u-button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {baseUrl} from '../common/http.js';
	export default {
		props: ['show','money'],
		data() {
			return {
				value: 2,//1=余额,2=微信
			};
		},
		created() {
			console.log(this.money);
		},
		methods: {
			close() {
				this.$emit('close')
			},
			pay() {
				
				if (this.value == 1) {
					this.$http('/addons/ddrive/user/service_pay', {
						type: this.value
					}, "POST").then(data => {
						uni.showToast({
							title: '支付成功'
						})
						this.close()
					})
				} else if (this.value == 2) {
					//微信支付
					this.$http('/addons/ddrive/user/service_pay', {
						type: this.value
					}, "POST").then(data => {
						console.log(data);
						let _this = this
						//data返回参数
						//{
						//	appid: "wxd5cdb23fa8a8a8a4"
						//	noncestr: "ElHzMeZUqs676yRK"
						//	package: "Sign=WXPay"
						//	partnerid: "1601210852"
						//	prepayid: "wx271544341817098433edb8b12397d20000"
						//	sign: "5E26B16FE8B6995D333F09A44A5C7EC3"
						//	timestamp: "1603784674"
						//}
						uni.requestPayment({
							provider: 'wxpay',
							orderInfo: data, //微信、支付宝订单数据
							success: function(res) {
								console.log('success:' + JSON.stringify(res));
								uni.showToast({
									title: '支付成功'
								})
								_this.close()
							},
							fail: function(err) {
								console.log('fail:' + JSON.stringify(err));
							}
						});
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	/deep/.u-primary-hover {
		background-color: $blue !important;
	}

	/deep/.u-radio {
		display: flex;
		flex-direction: row-reverse;
	}

	/deep/.u-radio-group {
		width: 100% !important;
	}

	/deep/.u-radio__label {
		width: 100%;
	}
</style>

  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是一个简单的支付页面模板的前端代码示例,使用uni-app框架: ```vue <template> <view class="pay-page"> <view class="pay-info"> <image class="pay-icon" src="../static/icon-pay.png" mode="aspectFit"></image> <text class="pay-amount">{{amount}}元</text> <text class="pay-description">{{description}}</text> </view> <view class="pay-methods"> <view class="pay-method" v-for="(method,index) in methods" :key="index" @click="selectMethod(index)"> <image class="pay-method-icon" :src="method.icon" mode="aspectFit"></image> <text class="pay-method-name">{{method.name}}</text> <image class="pay-method-check" v-if="selectedMethodIndex === index" src="../static/icon-checked.png" mode="aspectFit"></image> </view> </view> <view class="pay-button" @click="pay">确认支付</view> </view> </template> <script> export default { data() { return { amount: 10.00, // 支付金额 description: '购买会员', // 支付描述 methods: [ // 支付方式列表 { name: '微信支付', icon: '../static/icon-wechat.png' }, { name: '支付支付', icon: '../static/icon-alipay.png' }, ], selectedMethodIndex: 0, // 选中的支付方式 } }, methods: { selectMethod(index) { this.selectedMethodIndex = index }, pay() { // 调用支付服务接口进行支付 }, }, } </script> <style> .pay-page { display: flex; flex-direction: column; justify-content: center; align-items: center; } .pay-icon { width: 100px; height: 100px; margin-bottom: 20px; } .pay-amount { font-size: 30px; font-weight: bold; margin-bottom: 10px; } .pay-description { font-size: 16px; color: #999; margin-bottom: 30px; } .pay-methods { display: flex; flex-direction: column; align-items: stretch; margin-bottom: 30px; } .pay-method { display: flex; align-items: center; padding: 10px; border-radius: 5px; background-color: #f5f5f5; margin-bottom: 10px; } .pay-method-icon { width: 30px; height: 30px; margin-right: 10px; } .pay-method-name { font-size: 16px; color: #333; flex: 1; } .pay-method-check { width: 20px; height: 20px; } .pay-button { display: flex; justify-content: center; align-items: center; width: 200px; height: 50px; border-radius: 25px; background-color: #007aff; color: #fff; font-size: 18px; font-weight: bold; } </style> ``` 在这个示例中,我们使用了uni-app框架的模板语法,定义了一个支付页面组件,包含以下元素: - 支付信息:显示支付金额和描述 - 支付方式列表:包含多个支付方式,点击每个支付方式可以选择 - 确认支付按钮:点击后调用支付服务接口进行支付 你可以根据自己的需求对这个示例进行修改和扩展,添加更多的支付方式、支付参数等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小曲曲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值