initial commit: giftlaw ni xue fa wo you li - natural resources session

This commit is contained in:
lcj
2026-09-03 10:12:08 +08:00
commit dac4260d73
239 changed files with 48949 additions and 0 deletions
+376
View File
@@ -0,0 +1,376 @@
<template>
<view class="content">
<view class="page-header">
<text class="header-back" @tap="goBack">‹</text>
<text class="header-title">兑奖</text>
</view>
<view class="page-wrap">
<view class="prize-card">
<view class="prize-title">{{ prizeText }}</view>
<view class="prize-box" v-if="prizeOptions.length === 0 && prizeImages.length > 0">
<image class="prize-main-img" :src="prizeImages[0]" mode="widthFix"></image>
<text class="prize-desc" v-if="prizeContent">{{ prizeContent }}</text>
</view>
<view class="prize-options" v-if="prizeOptions.length > 0">
<text class="field-label">请选择奖品(5选1)</text>
<view class="prize-grid">
<view class="prize-grid-item" v-for="(opt, oi) in prizeOptions" :key="oi"
:class="{ active: selectedOption === opt.key }"
@tap="selectOption(opt)">
<view class="prize-grid-img-wrap">
<image class="prize-grid-img" :src="opt.images[0]" mode="aspectFill"></image>
<view class="prize-grid-mark" :class="{ checked: selectedOption === opt.key }">
<text v-if="selectedOption === opt.key">✓</text>
</view>
</view>
<view class="prize-grid-name-row">
<text class="prize-grid-name">{{ opt.name }}</text>
</view>
</view>
</view>
</view>
</view>
<view class="form-card">
<view class="form-field">
<text class="field-label">姓名</text>
<input class="field-input" v-model="userName" placeholder="请输入姓名" placeholder-class="input-placeholder" />
</view>
<view class="form-field">
<text class="field-label">手机号码</text>
<view class="field-value-static">{{ userPhone }}</view>
</view>
<view class="form-field">
<text class="field-label">身份证号码</text>
<input class="field-input" v-model="idCard" placeholder="请输入身份证号码" placeholder-class="input-placeholder" />
</view>
</view>
<button class="submit-btn" @tap="submitRedeem">确认兑奖</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
level: 0,
period: '',
prizeText: '',
prizeContent: '',
prizeImages: [],
prizeOptions: [],
selectedOption: '',
userName: '',
userPhone: '',
idCard: ''
}
},
onLoad(options) {
this.level = Number(options.level) || 0
this.period = options.period || ''
this.userName = uni.getStorageSync('userNameGift') || ''
this.userPhone = uni.getStorageSync('userPhoneGift') || ''
if (this.level === 1) {
this.prizeText = '恭喜您中了一等奖'
this.prizeContent = '2026学法有礼一等奖'
this.prizeImages = ['https://aliyunoss.hn12301.net/learnlaw/gift_cztk.png']
} else if (this.level === 2) {
this.prizeText = '恭喜您中了二等奖'
this.prizeOptions = [
{ key: 'prize_option1', name: '永州卡', prize_type: 18, images: ['https://aliyunoss.hn12301.net/learnlaw/gift_yzk.png'] },
{ key: 'prize_option2', name: '郴州卡', prize_type: 19, images: ['https://aliyunoss.hn12301.net/learnlaw/gift_czk.png'] },
{ key: 'prize_option3', name: '怀化卡', prize_type: 20, images: ['https://aliyunoss.hn12301.net/learnlaw/gift_hhk.png'] },
{ key: 'prize_option4', name: '邵阳卡', prize_type: 21, images: ['https://aliyunoss.hn12301.net/learnlaw/gift_syk.png'] },
{ key: 'prize_option5', name: '益阳卡', prize_type: 22, images: ['https://aliyunoss.hn12301.net/learnlaw/gift_yyk.png'] }
]
} else if (this.level === 3) {
this.prizeText = '恭喜您中了三等奖'
this.prizeContent = '2026学法有礼三等奖'
this.prizeImages = ['https://aliyunoss.hn12301.net/learnlaw/gift_jxxxk.png']
} else {
this.prizeText = '恭喜您中奖'
}
},
methods: {
goBack() {
uni.navigateBack()
},
selectOption(opt) {
this.selectedOption = opt.key
},
submitRedeem() {
if (!this.userName) {
uni.showToast({ title: '请输入姓名', icon: 'none' })
return
}
if (this.prizeOptions.length > 0 && !this.selectedOption) {
uni.showToast({ title: '请选择奖品', icon: 'none' })
return
}
if (!this.idCard) {
uni.showToast({ title: '请输入身份证号码', icon: 'none' })
return
}
if (!/^\d{15}$|^\d{17}[\dXx]$/.test(this.idCard)) {
uni.showToast({ title: '身份证号码格式不正确', icon: 'none' })
return
}
let prizeType = null
if (this.level === 1) {
prizeType = 17
} else if (this.level === 2) {
const opt = this.prizeOptions.find(o => o.key === this.selectedOption)
prizeType = opt ? opt.prize_type : null
} else if (this.level === 3) {
prizeType = 23
}
this.$u.api.exchangePrize({
wenjuan_id: 1003,
period: this.period,
win_level: this.level,
user_id: uni.getStorageSync('userIdGift'),
prize_type: prizeType,
user_name: this.userName,
user_card_num: this.idCard,
address: ''
}).then(res => {
if (res.code === 0) {
uni.showToast({ title: '兑奖成功', icon: 'none' })
setTimeout(() => {
uni.navigateBack()
}, 1200)
} else {
uni.showToast({ title: res.msg || '兑奖失败', icon: 'none' })
}
}).catch(() => {
uni.showToast({ title: '网络异常', icon: 'none' })
})
}
}
}
</script>
<style lang="scss">
page {
background-color: #F5F5F5;
}
.content {
position: relative;
display: flex;
flex-direction: column;
min-height: 100vh;
min-height: 100dvh;
}
.page-header {
display: flex;
align-items: center;
padding: 20rpx 30rpx;
background: linear-gradient(135deg, #FD5401, #FF7A3D);
flex-shrink: 0;
}
.header-back {
font-size: 48rpx;
color: #fff;
line-height: 1;
margin-right: 16rpx;
padding: 0 10rpx;
}
.header-title {
font-size: 30rpx;
font-weight: 600;
color: #fff;
flex: 1;
}
.page-wrap {
padding: 24rpx 24rpx 60rpx;
box-sizing: border-box;
}
.prize-card {
background: #fff;
border-radius: 20rpx;
padding: 30rpx 24rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
margin-bottom: 24rpx;
}
.prize-title {
font-size: 32rpx;
font-weight: 700;
color: #333;
text-align: center;
margin-bottom: 24rpx;
}
.prize-box {
background: linear-gradient(135deg, #FDF6E8 0%, #FEF3E0 100%);
border: 2rpx solid #F5E3C8;
border-radius: 20rpx;
padding: 30rpx 24rpx 24rpx;
text-align: center;
position: relative;
overflow: hidden;
}
.prize-box::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 6rpx;
background: linear-gradient(to right, #FD5401, #E0B866, #FD5401);
}
.prize-main-img {
width: 400rpx;
border-radius: 12rpx;
}
.prize-desc {
font-size: 24rpx;
color: #8B6A3E;
display: block;
margin-top: 16rpx;
line-height: 1.6;
font-weight: 500;
text-align: center;
}
.prize-options {
margin-top: 8rpx;
}
.prize-grid {
display: flex;
flex-wrap: wrap;
}
.prize-grid-item {
width: 319rpx;
box-sizing: border-box;
border: 2rpx solid #eee;
border-radius: 14rpx;
background: #FEFCF8;
overflow: hidden;
margin-right: 16rpx;
margin-bottom: 16rpx;
}
.prize-grid-item:nth-child(2n) {
margin-right: 0;
}
.prize-grid-item.active {
border-color: #FD5401;
background: #FFF4EC;
box-shadow: 0 4rpx 12rpx rgba(253, 84, 1, 0.15);
}
.prize-grid-img-wrap {
position: relative;
width: 100%;
height: 210rpx;
}
.prize-grid-img {
width: 100%;
height: 100%;
}
.prize-grid-mark {
position: absolute;
top: 12rpx;
right: 12rpx;
width: 40rpx;
height: 40rpx;
line-height: 36rpx;
text-align: center;
border-radius: 50%;
background: rgba(255, 255, 255, 0.9);
border: 2rpx solid #ccc;
color: #fff;
font-size: 24rpx;
font-weight: 700;
box-sizing: border-box;
}
.prize-grid-mark.checked {
background: #FD5401;
border-color: #FD5401;
box-shadow: 0 2rpx 8rpx rgba(253, 84, 1, 0.4);
}
.prize-grid-name-row {
display: flex;
align-items: center;
justify-content: center;
padding: 16rpx 10rpx;
}
.prize-grid-name {
font-size: 26rpx;
color: #333;
font-weight: 600;
}
.form-card {
background: #fff;
border-radius: 20rpx;
padding: 10rpx 24rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
margin-bottom: 30rpx;
}
.form-field {
padding: 20rpx 0;
border-bottom: 1rpx solid #f5f5f5;
}
.form-field:last-child {
border-bottom: none;
}
.field-label {
font-size: 26rpx;
color: #666;
display: block;
margin-bottom: 10rpx;
}
.field-value-static {
font-size: 28rpx;
color: #333;
font-weight: 500;
padding: 8rpx 0;
}
.field-input {
font-size: 28rpx;
color: #333;
padding: 8rpx 0;
width: 100%;
}
.input-placeholder {
color: #ccc;
}
.submit-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
background: linear-gradient(135deg, #FD5401, #FF7A3D);
color: #fff;
font-size: 32rpx;
font-weight: 600;
border: none;
border-radius: 44rpx;
box-shadow: 0 4rpx 16rpx rgba(253, 84, 1, 0.4);
}
</style>