Spaces:
Running
Running
File size: 3,920 Bytes
e3bbdaf 4d8fa85 e850ec0 4d8fa85 e3bbdaf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | <template>
<view class="container">
<view class="card">
<view class="card-title">表单交互演示</view>
<view class="form-item">
<text class="label">输入内容:</text>
<input class="input" v-model="inputValue" placeholder="请输入内容" />
</view>
<view class="form-item">
<text class="label">当前输入:</text>
<text class="value">{{ inputValue || '暂无内容' }}</text>
</view>
<button class="primary-btn" @tap="handleSubmit">提交数据</button>
</view>
<view class="card">
<view class="card-title">条件编译演示</view>
<view class="platform-box">
<!-- #ifdef MP-WEIXIN -->
<view class="platform-tag weixin">当前处于:微信小程序</view>
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<view class="platform-tag alipay">当前处于:支付宝小程序</view>
<!-- #endif -->
<!-- #ifdef H5 -->
<view class="platform-tag h5">当前处于:H5 网页</view>
<!-- #endif -->
<view class="desc">这里使用了 UniApp 的条件编译功能,不同平台会显示不同的内容。</view>
</view>
</view>
<view class="card">
<view class="card-title">交互反馈演示</view>
<view class="btn-group">
<button class="btn" @tap="showToast">显示提示</button>
<button class="btn" @tap="showLoading">显示加载</button>
<button class="btn" @tap="showModal">显示弹窗</button>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const inputValue = ref('')
const handleSubmit = () => {
if (!inputValue.value) {
uni.showToast({ title: '请输入内容', icon: 'none' })
return
}
uni.showToast({ title: '提交成功', icon: 'success' })
}
const showToast = () => {
uni.showToast({ title: '这是一个提示信息' })
}
const showLoading = () => {
uni.showLoading({ title: '加载中...' })
setTimeout(() => {
uni.hideLoading()
}, 2000)
}
const showModal = () => {
uni.showModal({
title: '温馨提示',
content: '这是一个自定义弹窗内容,用于确认用户操作。',
confirmText: '确定',
cancelText: '取消'
})
}
</script>
<style lang="scss">
.container {
padding: 30rpx;
background-color: #f8f8f8;
min-height: 100vh;
/* #ifdef H5 */
padding-top: 50px;
min-height: calc(100vh - 100px);
/* #endif */
}
.card {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.05);
.card-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 30rpx;
padding-left: 20rpx;
border-left: 8rpx solid #1890ff;
}
}
.form-item {
display: flex;
align-items: center;
margin-bottom: 30rpx;
.label {
font-size: 28rpx;
color: #666;
width: 160rpx;
}
.input {
flex: 1;
height: 80rpx;
border: 1rpx solid #ddd;
border-radius: 8rpx;
padding: 0 20rpx;
font-size: 28rpx;
}
.value {
font-size: 28rpx;
color: #1890ff;
}
}
.primary-btn {
background-color: #1890ff;
color: #fff;
font-size: 30rpx;
border-radius: 8rpx;
height: 80rpx;
line-height: 80rpx;
}
.platform-box {
.platform-tag {
padding: 20rpx;
border-radius: 8rpx;
color: #fff;
font-size: 28rpx;
text-align: center;
margin-bottom: 20rpx;
&.weixin { background-color: #07c160; }
&.alipay { background-color: #1677ff; }
&.h5 { background-color: #ff4d4f; }
}
.desc {
font-size: 24rpx;
color: #999;
line-height: 1.6;
}
}
.btn-group {
display: flex;
flex-direction: column;
gap: 20rpx;
.btn {
font-size: 28rpx;
background-color: #f5f5f5;
color: #333;
border: none;
&::after { border: none; }
}
}
</style>
|