|
@@ -1,15 +1,199 @@
|
|
|
<template>
|
|
|
<div class="pa-3 white">
|
|
|
- <el-empty></el-empty>
|
|
|
+ <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
|
|
|
+ <m-card :body-style="{ padding: '0px' }" v-loading="loading">
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <span>兑换列表</span>
|
|
|
+ <div class="tools">
|
|
|
+ <span class="mr-3">
|
|
|
+ 已使用积分:<span class="text-link" @click="onHistory">{{ itemData.canUsedScore ?? 0 }}</span>
|
|
|
+ </span>
|
|
|
+ <span>
|
|
|
+ 可用积分:{{ itemData.canUsed ?? 0 }}
|
|
|
+ </span>
|
|
|
+ <!-- <m-button type="orange" @click="onHistory">兑换记录</m-button> -->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="6" v-for="item in items" :key="item.scoreProductId" class="pa-3">
|
|
|
+ <el-card :body-style="{ padding: '0px' }" shadow="hover" :class="item.remainingQuantity <= 0 ? 'cardDisabled' : ''">
|
|
|
+ <div class="d-flex align-center justify-center font-36 text-orange">
|
|
|
+ <span class="mdi mdi-gift"></span>
|
|
|
+ </div>
|
|
|
+ <div class="text-center pa-3">
|
|
|
+ <div>{{ item.productName }}</div>
|
|
|
+ <div class="font-12" style="color: grey">{{ item.productDescription }}</div>
|
|
|
+ <el-tag size="small" type="orange" class="ma-3">{{ item.productScore }}积分</el-tag>
|
|
|
+ <div>
|
|
|
+ <span v-if="item.remainingQuantity <= 0" class="font-14" style="color: grey;">已兑换完</span>
|
|
|
+ <m-button v-else type="primary" text size="mini" @click="onExchange(item)">我要兑换 (剩余{{ item.remainingQuantity }})</m-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <div class="pa-3 text-center">
|
|
|
+ <m-pagination
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ :current-page="pageInfo.current"
|
|
|
+ :page-size="pageInfo.size"
|
|
|
+ :total="total"
|
|
|
+ >
|
|
|
+ </m-pagination>
|
|
|
+ </div>
|
|
|
+ </m-card>
|
|
|
+ <AccumulatePointsMotivateHistory ref="accumulatePointsMotivateHistoryRefs"></AccumulatePointsMotivateHistory>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import AccumulatePointsMotivateHistory from './accumulatePointsMotivateHistory.vue'
|
|
|
+import {
|
|
|
+ getAccumulatePointProduct,
|
|
|
+ exchangeAccumulatePointProduct,
|
|
|
+ getAccumulatePoint
|
|
|
+} from '@/api/accumulatePoint'
|
|
|
export default {
|
|
|
- name: 'accumulatePointsMotivate'
|
|
|
+ name: 'accumulatePointsMotivate',
|
|
|
+ components: {
|
|
|
+ AccumulatePointsMotivateHistory
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ searchItems: [
|
|
|
+ {
|
|
|
+ label: '名称',
|
|
|
+ prop: 'productName',
|
|
|
+ type: 'input',
|
|
|
+ options: {
|
|
|
+ placeholder: '请输入名称'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ searchValues: {
|
|
|
+ productName: null
|
|
|
+ },
|
|
|
+ pageInfo: {
|
|
|
+ current: 1,
|
|
|
+ size: 12
|
|
|
+ },
|
|
|
+ total: 0,
|
|
|
+ orders: [
|
|
|
+ {
|
|
|
+ asc: false,
|
|
|
+ column: 'create_date'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ items: [],
|
|
|
+ loading: false,
|
|
|
+ itemData: {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.getDetails()
|
|
|
+ this.onInit()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async onInit () {
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ const { data } = await getAccumulatePointProduct({
|
|
|
+ page: {
|
|
|
+ ...this.pageInfo,
|
|
|
+ orders: this.orders
|
|
|
+ },
|
|
|
+ entity: {
|
|
|
+ ...this.searchValues
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.items = data.records
|
|
|
+ this.total = data.total
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getDetails () {
|
|
|
+ try {
|
|
|
+ const { data } = await getAccumulatePoint({})
|
|
|
+ this.itemData = data.entity
|
|
|
+ this.itemData.canUsed = this.itemData.score - this.itemData.canUsedScore
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleCurrentChange (index) {
|
|
|
+ this.pageInfo.current = index
|
|
|
+ this.onInit()
|
|
|
+ },
|
|
|
+ onHistory () {
|
|
|
+ this.$refs.accumulatePointsMotivateHistoryRefs.open()
|
|
|
+ },
|
|
|
+ onSearch () {
|
|
|
+ this.pageInfo.current = 1
|
|
|
+ this.onInit()
|
|
|
+ },
|
|
|
+ onExchange (item) {
|
|
|
+ if (item.remainingQuantity <= 0) {
|
|
|
+ this.$message.error('该商品已兑换完')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$confirm(`确认兑换${item.productName}吗?`).then(async () => {
|
|
|
+ try {
|
|
|
+ await exchangeAccumulatePointProduct({
|
|
|
+ scoreProductId: item.scoreProductId,
|
|
|
+ num: 1
|
|
|
+ })
|
|
|
+ this.$message.success('兑换成功')
|
|
|
+ this.onInit()
|
|
|
+ } catch (error) {
|
|
|
+ this.$snackbar.error(error)
|
|
|
+ }
|
|
|
+ }).catch(_ => {})
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
+.tools {
|
|
|
+ float: right;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ height: 60px;
|
|
|
+ ::v-deep .el-button {
|
|
|
+ padding: 9px 15px;
|
|
|
+ font-size: 12px;
|
|
|
+ border-radius: 3px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.clearfix:before,
|
|
|
+.clearfix:after {
|
|
|
+ display: table;
|
|
|
+ content: "";
|
|
|
+}
|
|
|
+.clearfix:after {
|
|
|
+ clear: both
|
|
|
+}
|
|
|
+::v-deep .el-card__header {
|
|
|
+ padding-top: 0;
|
|
|
+ padding-bottom: 0;
|
|
|
+ height: 60px;
|
|
|
+ line-height: 60px;
|
|
|
+}
|
|
|
|
|
|
+.cardDisabled {
|
|
|
+ position: relative;
|
|
|
+ &::after {
|
|
|
+ content: "";
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background-color: rgba(141, 141, 141, .2);
|
|
|
+ z-index: 1;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|