You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.2 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<script setup>
import DraggableButton from "@/pages/components/goHome.vue";
/**
* name
* usersa0ChunLuyu
* date2024年9月11日 19:24:50
*/
import { ref } from "vue";
import { $api, $response } from "@/api";
import { onShow } from "@dcloudio/uni-app";
import { useStore } from "@/store";
const $store = useStore();
let couponList = ref([]);
let yytjInfo = ref({});
const mountedAction = () => {
yytjInfo.value = $store.getYytjInfo();
GetPersonIntegralSaveMoneyCouponInfo();
};
const GetPersonIntegralSaveMoneyCouponInfo = async () => {
const response = await $api("GetPersonIntegralSaveMoneyCouponInfo", {
person_id: $store.getUser()?.person_id,
});
$response(response, () => {
couponList.value = response.data.coupon_list;
});
};
const selectCoupon = (item) => {
yytjInfo.value.couponId = item.id;
yytjInfo.value.couponPrice = item.price;
$store.setYytjInfo(yytjInfo.value);
uni.navigateBack({ delta: 1 });
};
const noSelectCoupon = () => {
yytjInfo.value.couponId = "";
yytjInfo.value.couponPrice = "";
$store.setYytjInfo(yytjInfo.value);
};
const config_ref = ref(null);
const configRef = (e) => {
if (!config_ref.value) {
config_ref.value = e;
mountedAction();
}
};
onShow(() => {
if (!!config_ref.value) {
mountedAction();
}
});
</script>
<template>
<DraggableButton />
<view>
<view v-if="!!$store.config">
<view :ref="configRef"></view>
</view>
</view>
<view class="px-20rpx py-10rpx box-border">
<view
class="px-10rpx py-30rpx box-border bg-#fff shadow-[0rpx_0rpx_10rpx_0rpx_rgba(0,0,0,0.04)] rounded-15rpx"
>
<view
v-for="(item, index) in couponList"
:key="index"
class="mb-20rpx flex"
@click="selectCoupon(item)"
>
<view class="min-w-200rpx max-w-200rpx h-170rpx yhq1 center flex-col">
<view>
<text class="text-#fff text-24rpx">¥</text>
<text class="text-#fff text-50rpx">{{ item.price }}</text>
</view>
<text class="text-#fff text-22rpx">{{ item.desc }}</text>
</view>
<view
class="grow box-border b-1 b-l-0 b-#E5E5E5 b-solid rounded-r-15rpx flex between"
>
<view
class="grow px-30rpx py-25rpx box-border flex-col between h-full items-start b-0 b-r-1 b-#E5E5E5 b-solid"
>
<text class="text-28rpx text-#B38933">{{ item.title }}</text>
<text class="text-20rpx text-#7C7C7C">{{
item.date_range?.join(" ")
}}</text>
</view>
<view
v-if="yytjInfo.couponId != item.id"
class="max-w-60rpx h-full min-w-60rpx text-#B38933 rounded-r-15rpx text-25rpx center mx-0"
>
<br /><br />使<br />
</view>
<view
v-else
@click.stop="noSelectCoupon()"
class="max-w-60rpx h-full min-w-60rpx text-#fff rounded-r-15rpx bg-#B38933 text-25rpx center mx-0"
>
<br /><br />使<br />
</view>
</view>
</view>
</view>
</view>
</template>
<style scoped>
.yhq1 {
background-image: url("@/static/assets/slices/yhq1.png");
background-size: 100% 100%;
}
</style>