|
@@ -1,40 +1,43 @@
|
|
|
<script setup lang='ts'>
|
|
<script setup lang='ts'>
|
|
|
-import { ref, onMounted } from 'vue'
|
|
|
|
|
|
|
+import { ref, computed, onMounted } from 'vue'
|
|
|
import { exchangeCode } from '@/services/user'
|
|
import { exchangeCode } from '@/services/user'
|
|
|
import { dict } from '@/.cool/store'
|
|
import { dict } from '@/.cool/store'
|
|
|
-import { user, router } from '@/.cool'
|
|
|
|
|
|
|
+import { user, parse, userInfo } from '@/.cool'
|
|
|
|
|
+import { type SubjectFeeRecord, fetchSubjectFeeRecord } from '@/services/subject/record'
|
|
|
import { useUi } from "@/uni_modules/cool-ui";
|
|
import { useUi } from "@/uni_modules/cool-ui";
|
|
|
-import { fetchSubjectFeeRecord } from '@/services/subject/record'
|
|
|
|
|
|
|
|
|
|
-const recordList = ref<any[]>([])
|
|
|
|
|
|
|
+const recordList = ref<SubjectFeeRecord[]>([])
|
|
|
const ui = useUi();
|
|
const ui = useUi();
|
|
|
const code = ref<string>('')
|
|
const code = ref<string>('')
|
|
|
const loading = ref<boolean>(false)
|
|
const loading = ref<boolean>(false)
|
|
|
|
|
+
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
- if (!user.info.value?.userInfo) {
|
|
|
|
|
|
|
+ if (userInfo.value == null) {
|
|
|
user.logout()
|
|
user.logout()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
fetchSubjectFeeRecord({
|
|
fetchSubjectFeeRecord({
|
|
|
- createdUserId: user.info.value?.userInfo.userId
|
|
|
|
|
|
|
+ createdUserId: userInfo.value.userInfo.userId
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
recordList.value = res
|
|
recordList.value = res
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
async function handleExchange() {
|
|
async function handleExchange() {
|
|
|
-
|
|
|
|
|
- if (!code.value) {
|
|
|
|
|
|
|
+ if (code.value == "" || code.value == null) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '请输入兑换码',
|
|
title: '请输入兑换码',
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- loading.value = true
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
+ const subject = dict.getValueByLabelMapByType('index_subject_id')
|
|
|
|
|
+ console.log(subject)
|
|
|
|
|
+ const id = subject['物理'] as string
|
|
|
|
|
+ loading.value = true
|
|
|
await exchangeCode({
|
|
await exchangeCode({
|
|
|
exchangeCode: code.value,
|
|
exchangeCode: code.value,
|
|
|
- subjectId: dict.getValueByLabelMapByType('index_subject_id')['物理'],
|
|
|
|
|
|
|
+ subjectId: id,
|
|
|
})
|
|
})
|
|
|
await user.get()
|
|
await user.get()
|
|
|
ui.showConfirm({
|
|
ui.showConfirm({
|
|
@@ -46,7 +49,7 @@ async function handleExchange() {
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
loading.value = false
|
|
loading.value = false
|
|
|
- } catch (err: any) {
|
|
|
|
|
|
|
+ } catch (err: Error) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: err.message,
|
|
title: err.message,
|
|
|
icon: 'error'
|
|
icon: 'error'
|
|
@@ -56,60 +59,74 @@ async function handleExchange() {
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
<template>
|
|
<template>
|
|
|
- <view class="content" v-if="user.info.value?.userInfo && user.info.value?.userInfo?.memberLevel === 'default'">
|
|
|
|
|
- <view class="text-[30px] font-bold">
|
|
|
|
|
- 兑换码
|
|
|
|
|
|
|
+ <view class="cc">
|
|
|
|
|
+ <view class="cont2" v-if="userInfo != null && userInfo?.userInfo?.memberLevel != 'default'">
|
|
|
|
|
+ <image src="https://oss.xiaoxiongcode.com/static/home/6293.png" mode="scaleToFill" lazy-load alt=""
|
|
|
|
|
+ class="w-full h-full object-cover absolute top-0 left-0 z-[1]" />
|
|
|
|
|
+ <view class="relative z-[2] w-full h-full pt-[70rpx] px-[50rpx] pr-[56rpx]">
|
|
|
|
|
+ <cl-row :gutter="12">
|
|
|
|
|
+ <cl-col :span="8" :pt="{
|
|
|
|
|
+ className: 'bg-[#FDE6BD]',
|
|
|
|
|
+ }">
|
|
|
|
|
+ <text class="text-[16rpx] font-bold py-[5rpx] text-center text-[#A57138]">课程名称</text>
|
|
|
|
|
+ </cl-col>
|
|
|
|
|
+ <cl-col :span="8" :pt="{
|
|
|
|
|
+ className: 'bg-[#FDE6BD]',
|
|
|
|
|
+ }">
|
|
|
|
|
+ <text class="text-[16rpx] font-bold py-[5rpx] text-center text-[#A57138]">兑换时间</text>
|
|
|
|
|
+ </cl-col>
|
|
|
|
|
+ <cl-col :span="8" :pt="{
|
|
|
|
|
+ className: 'bg-[#FDE6BD]',
|
|
|
|
|
+ }">
|
|
|
|
|
+ <text class="text-[16rpx] font-bold py-[5rpx] text-center text-[#A57138]">到期时间</text>
|
|
|
|
|
+ </cl-col>
|
|
|
|
|
+ </cl-row>
|
|
|
|
|
+ <cl-row :gutter="12" v-for="item in recordList" :key="item.id as string" :pt="{
|
|
|
|
|
+ className: 'border-b-[1rpx] border-[#FFE9C0] border-solid align-center',
|
|
|
|
|
+ }">
|
|
|
|
|
+ <cl-col :span="8">
|
|
|
|
|
+ <text class="text-[14rpx] font-bold py-[5rpx] text-center text-[#333]">{{ item.mainTitle }}</text>
|
|
|
|
|
+ </cl-col>
|
|
|
|
|
+ <cl-col :span="8">
|
|
|
|
|
+ <text class="text-[14rpx] font-bold py-[5rpx] text-center text-[#333]">{{ item.createdTime }}</text>
|
|
|
|
|
+ </cl-col>
|
|
|
|
|
+ <cl-col :span="8">
|
|
|
|
|
+ <text class="text-[14rpx] font-bold py-[5rpx] text-center text-[#333]">{{ item.updateTime }}</text>
|
|
|
|
|
+ </cl-col>
|
|
|
|
|
+ </cl-row>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
</view>
|
|
</view>
|
|
|
- <cl-input v-model="code" :pt="{
|
|
|
|
|
- className: '!h-[40px] ',
|
|
|
|
|
- }" placeholder="请输入兑换码"></cl-input>
|
|
|
|
|
- <cl-button type="warn" :pt="{
|
|
|
|
|
- className: 'text-[18px] w-[140px] rounded-full text-black text-center check to-pink-500 py-[5px] ',
|
|
|
|
|
- }" @tap="handleExchange()" :loading="loading">兑换</cl-button>
|
|
|
|
|
|
|
+ <view class="cont" v-else>
|
|
|
|
|
+ <image src="https://oss.xiaoxiongcode.com/static/home/6292.png" mode="widthFix" lazy-load alt=""
|
|
|
|
|
+ class="w-full h-full object-cover absolute top-0 left-0 z-[1]" />
|
|
|
|
|
|
|
|
- </view>
|
|
|
|
|
- <view class="content2" v-else>
|
|
|
|
|
- <view v-for="item in recordList" :key="item" class="box flex flex-row items-center gap-2">
|
|
|
|
|
- <view class="h-full">
|
|
|
|
|
- <image src="https://oss.xiaoxiongcode.com/static/个人中心/图层 13.png" mode="heightFix" class=" h-full" />
|
|
|
|
|
- </view>
|
|
|
|
|
- <view class="flex flex-col justify-around h-full">
|
|
|
|
|
- <view class="text-[5vh] font-bold text-[#FC500F]">
|
|
|
|
|
- {{ item.mainTitle }}
|
|
|
|
|
- </view>
|
|
|
|
|
- <view class="text-[3vh] text-[#999]">
|
|
|
|
|
- 兑换时间:{{ item.createdTime }}
|
|
|
|
|
- </view>
|
|
|
|
|
- <view class="text-[3vh] text-[#999]">
|
|
|
|
|
- 到期时间:{{ item.updateTime }}
|
|
|
|
|
- </view>
|
|
|
|
|
- </view>
|
|
|
|
|
|
|
+ <text class="text-[30px] font-bold relative z-[2] pb-[20rpx]">
|
|
|
|
|
+ —— 兑换码 ——
|
|
|
|
|
+ </text>
|
|
|
|
|
+ <cl-input v-model="code" :pt="{
|
|
|
|
|
+ className: '!h-[40px] relative z-[2] w-[200rpx]',
|
|
|
|
|
+ }" placeholder="请输入兑换码">
|
|
|
|
|
+ <template #append>
|
|
|
|
|
+ <cl-button type="primary" :pt="{
|
|
|
|
|
+ className: 'text-[18px] w-[100px] scale-[1.1] transform translate-x-[3rpx]',
|
|
|
|
|
+ }" @tap="handleExchange()" :loading="loading">兑换</cl-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </cl-input>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
-.content {
|
|
|
|
|
- @apply absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-black w-[120vh] border-[3px] border-[#fff] border-solid rounded-[30px] px-10 py-4 h-[44vh] flex items-center justify-center gap-4 bg-white;
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-.content2 {
|
|
|
|
|
- @apply absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2;
|
|
|
|
|
- overflow: hidden;
|
|
|
|
|
- border-radius: 10px;
|
|
|
|
|
|
|
+.cc {
|
|
|
|
|
+ @apply w-full flex items-center justify-center;
|
|
|
|
|
+ height: calc(97vh - 85px);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-.box {
|
|
|
|
|
- width: 120vh;
|
|
|
|
|
- // 宽高比3/1
|
|
|
|
|
- aspect-ratio: 4 / 1;
|
|
|
|
|
- padding: 5px;
|
|
|
|
|
- border-radius: 10px;
|
|
|
|
|
- background: linear-gradient(0deg, #FFFBF7 0%, #FFE0CC 100%);
|
|
|
|
|
- box-shadow: 3px 6px 4px 0px rgba(239, 103, 36, 0.48);
|
|
|
|
|
|
|
+.cont {
|
|
|
|
|
+ @apply mx-auto mt-[10rpx] text-black w-[420rpx] rounded-[30px] px-10 h-[270rpx] flex items-center justify-center pb-[20rpx] relative;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-.check {
|
|
|
|
|
- background: linear-gradient(0deg, #FBD00E 0%, #FBEC92 100%);
|
|
|
|
|
|
|
+.cont2 {
|
|
|
|
|
+ @apply w-[600rpx] h-[250rpx] relative;
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|