Răsfoiți Sursa

观看次数

yaoyao 1 lună în urmă
părinte
comite
5656e7d7d9
2 a modificat fișierele cu 331 adăugiri și 0 ștergeri
  1. 8 0
      src/api/award/awardList.js
  2. 323 0
      src/views/advertisement/userNumList.vue

+ 8 - 0
src/api/award/awardList.js

@@ -196,4 +196,12 @@ export function delSystem(data) {
     method: 'post',
     data: data
   })
+}
+// 用户广告次数
+export function getAllUserWatchCount(data) {
+  return request({
+    url: '/advertising/getAllUserWatchCount',
+    method: 'post',
+    data: data
+  })
 }

+ 323 - 0
src/views/advertisement/userNumList.vue

@@ -0,0 +1,323 @@
+<template>
+  <div class="app-container">
+    <!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
+      <el-form-item label="奖品名称" prop="awardName">
+        <el-input
+          v-model="queryParams.awardName"
+          placeholder="请输入奖品名称"
+          clearable
+          style="width: 240px"
+        />
+      </el-form-item>
+      
+      <el-form-item label="奖品类型" prop="awardType">
+        <el-select
+          v-model="queryParams.awardType"
+          placeholder="奖品类型"
+          clearable
+          style="width: 240px"
+        >
+          <el-option
+            v-for="dict in awardTypeList"
+            :key="dict.id"
+            :label="dict.typeName"
+            :value="dict.id"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form> -->
+    <el-row :gutter="10" class="mb8">
+      <!-- <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+        >新增</el-button>
+      </el-col> -->
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="awwardList">
+      <el-table-column label="用户id" prop="userId" :show-overflow-tooltip="true" align="center" />
+      <el-table-column label="用户今日观看次数" prop="watchCount" align="center" />
+      <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope" v-if="scope.row.roleId !== 1">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+          >删除</el-button>
+        </template>
+      </el-table-column> -->
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 添加或修改对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+        <el-form-item label="奖品名称" prop="awardName">
+          <el-input v-model="form.awardName" placeholder="请输入奖品名称" />
+        </el-form-item>
+        <el-form-item label="奖品数量" prop="awardNum">
+          <el-input v-model="form.awardNum" placeholder="请输入奖品数量" />
+        </el-form-item>
+        <el-form-item label="奖品图片" prop="awardPhotoUrl">
+          <ImageUpload :limit="1" :uploadType="'jiangpin'" @input="getPhotoUrl" :value="'upload/jiangpin/2024/07/23/0d981173ea918ea619554a389ebe058c.jpg'"></ImageUpload>
+        </el-form-item>
+        <el-form-item label="奖品类型" prop="awardType">
+          <el-select
+            v-model="form.awardType"
+            placeholder="奖品类型"
+            clearable
+            style="width: 240px"
+            @change="changeAwardType"
+          >
+            <el-option
+              v-for="dict in awardTypeList"
+              :key="dict.id"
+              :label="dict.typeName"
+              :value="dict.id"
+            />
+          </el-select>
+        </el-form-item>
+        <div v-for="(item, index) in typeAttr" :key="index" style="margin-bottom: 10px;">
+          <el-form-item :label="item.attrName">
+            <el-input v-model="item.value" placeholder="请输入"/>
+          </el-form-item>
+        </div>
+        <el-form-item label="生效日期" prop="effectiveDate">
+          <el-date-picker
+            v-model="form.effectiveDate"
+            type="datetime"
+            value-format="yyyy-MM-dd HH:mm:ss"
+            placeholder="生效日期">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="失效日期" prop="expiryDate">
+          <el-date-picker
+            v-model="form.expiryDate"
+            type="datetime"
+            value-format="yyyy-MM-dd HH:mm:ss"
+            placeholder="失效日期">
+          </el-date-picker>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+
+    
+    <el-dialog :visible.sync="dialogVisible" title="预览" width="800" append-to-body >
+      <img :src="dialogImageUrl" style="display: block; max-width: 100%; margin: 0 auto"/>
+    </el-dialog>
+    
+  </div>
+</template>
+
+<script>
+import {
+  getAllUserWatchCount,
+  addAwardt,
+  delAward,
+  upAward,
+  getAwardTypeList
+} from "@/api/award/awardList"
+
+import imageUpload from "../../components/ImageUpload/index.vue";
+
+export default {
+  name: "Role",
+  components: {
+    imageUpload
+  },
+  dicts: ['award_type'],
+  data() {
+    return {
+      dialogVisible: false,
+      dialogImageUrl: '',
+      baseUrl: process.env.VUE_APP_BASE_API + '/',
+      // 遮罩层
+      loading: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      awwardList: [],
+      title: "",
+      open: false,
+      // 日期范围
+      dateRange: [],
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+        awardName: [
+          { required: true, message: "奖品名称不能为空", trigger: "blur" }
+        ],
+        awardNum: [
+          { required: true, message: "奖品数量不能为空", trigger: "blur" }
+        ],
+        awardType: [
+          { required: true, message: "奖品类型不能为空", trigger: "blur" }
+        ]
+      },
+      awardTypeList: [],  // 奖品种类列表
+      typeAttr: [],
+    };
+  },
+  created() {
+    this.getList();
+    this.getAwardList()
+  },
+  methods: {
+    changeAwardType(data) {
+      this.awardTypeList.forEach((val) => {
+        if (data == val.id) {
+          this.typeAttr = val.typeAttr
+        }
+      })
+    },
+    getPhotoUrl(data) {
+      this.form.awardPhotoUrl = data
+    },
+    getAwardList() {
+      getAwardTypeList({
+        pageNum: 1,
+        pageSize: 100,
+      }).then((res) => {
+        this.awardTypeList = res.data.records
+      })
+    },
+    /** 查询列表 */
+    getList() {
+      this.loading = true;
+      getAllUserWatchCount(this.queryParams).then((res) => {
+        this.queryParams.pageNum = res.data.current
+        this.total = res.data.total
+        this.awwardList = res.data.records
+        this.loading = false;
+      })
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.typeAttr = []
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {};
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.dateRange = [];
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.title = "添加奖品";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      this.form = {...row}
+      this.changeAwardType(this.form.awardType)
+      if (this.form.awardAttr) {
+        this.typeAttr.map((val) => {
+          val.value = this.form.awardAttr[val.attrKey]
+        })
+      }
+      this.open = true;
+      this.title = "修改奖品";
+    },
+    /** 提交按钮 */
+    submitForm: function() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          let award_attr = {}
+          this.typeAttr.forEach((val) => {
+            award_attr[val.attrKey] = val.value
+          })
+          // this.form.awardAttr = JSON.stringify(award_attr)
+          this.form.awardAttr = award_attr
+          if (this.form.id) {
+            upAward(this.form).then((res) => {
+              this.$message.success(res.msg)
+              this.open = false;
+              this.getList();
+            })
+          } 
+          else {
+            addAwardt(this.form).then(response => {
+              this.$modal.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const awardName = row.awardName
+      this.$confirm('是否确认名称为"' + awardName + '"的抽奖活动?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          delAward({id: row.id}).then((res) => {
+            if (res.code == 200) {
+              this.$message.success(res.msg)
+              this.getList()
+            } else {
+              this.$message.error(res.msg)
+            }
+          })
+        }).catch(() => {
+          this.$message.info('已取消删除')
+        });
+    },
+    // 预览
+    handlePictureCardPreview(file) {
+      this.dialogImageUrl = file;
+      this.dialogVisible = true;
+    },
+  }
+};
+</script>