Bladeren bron

创建兑换码

natasha 1 jaar geleden
bovenliggende
commit
34457ec35a

BIN
src/assets/baozhi1.png


BIN
src/assets/baozhi2.png


BIN
src/assets/kecheng1.png


BIN
src/assets/kecheng2.png


BIN
src/assets/kecheng3.png


BIN
src/assets/nodata.png


+ 5 - 0
src/icons/svg/Check.svg

@@ -0,0 +1,5 @@
+<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="Check (&#230;&#160;&#161;&#233;&#170;&#140;)">
+<path id="Union" fill-rule="evenodd" clip-rule="evenodd" d="M12.8505 2.90037C13.0209 3.07163 13.0202 3.34864 12.849 3.51908L5.22919 11.1024C5.05851 11.2723 4.78264 11.2723 4.61196 11.1024L1.14841 7.65544C0.977151 7.485 0.976487 7.20799 1.14693 7.03673C1.31738 6.86546 1.59438 6.8648 1.76565 7.03524L4.92057 10.1751L12.2317 2.89888C12.403 2.72844 12.68 2.7291 12.8505 2.90037Z" fill="currentColor" fill-opacity="0.96"/>
+</g>
+</svg>

+ 15 - 0
src/router/index.js

@@ -189,6 +189,21 @@ export const constantRoutes = [{
         component: () =>
             import ('@/views/cdkey_manage/index.vue')
     },
+    {
+        path: '/createCdkey',
+        component: () =>
+            import ('@/views/cdkey_manage/CreateCdkey.vue')
+    },
+    {
+        path: '/addGoods',
+        component: () =>
+            import ('@/views/cdkey_manage/AddGoods.vue')
+    },
+    {
+        path: '/checkGoods',
+        component: () =>
+            import ('@/views/cdkey_manage/CheckGoods.vue')
+    },
     // 404 page must be placed at the end !!!
     { path: '*', redirect: '/', hidden: true }
 ]

+ 705 - 0
src/views/cdkey_manage/AddGoods.vue

@@ -0,0 +1,705 @@
+<template>
+  <div class="manage-root add-goods">
+    <Header/>
+    <breadcrumb :breadcrumbList="breadcrumbList" class="breadcrumb-box"></breadcrumb>
+    <div class="manage-root-contain" v-loading="tableLoading">
+        <div class="common-title-box">
+            <h3>添加兑换内容 <span style="color:rgba(255, 20, 20, 1)" v-if="checkGoodsList.length>0">已选{{checkGoodsList.length}}</span></h3>
+            <div class="btn-box">
+                <el-button @click="$router.go(-1)" size="small">取消</el-button>
+                <el-button type="primary" @click="handleChooseGoods" size="small" :loading="loading"><svg-icon icon-class="Check" style="margin-right:8px"></svg-icon>完成</el-button>
+            </div>
+        </div>
+        <div class="filt-box">
+            <div class="filt-item">
+                <label>类型</label>
+                <ul>
+                    <li :class="[items.value===itemType?'active':'']" v-for="(items,indexs) in typeSelectList" :key="indexs" @click="itemType=items.value;getList(1)">
+                        <i v-if="items.value===itemType" class="el-icon-success"></i>
+                        {{items.label}}
+                    </li>
+                </ul>
+            </div>
+            <template v-if="itemType==='kecheng'">
+                <div class="filt-item">
+                    <label>学段</label>
+                    <ul>
+                        <li :class="[items.study_phase===courseForm.studyValue?'active':'',courseForm.categoryValue==='ZB'?'not-allow':'']" v-for="(items,indexs) in studyList" :key="indexs" @click="handleClick('courseForm','studyValue',items.study_phase)">
+                            <i v-if="items.study_phase===courseForm.studyValue" class="el-icon-success"></i>
+                            {{items.study_phase_name}}
+                        </li>
+                    </ul>
+                </div>
+                <div class="filt-item">
+                    <label>类别</label>
+                    <ul>
+                        <li :class="[itemt.value===courseForm.categoryValue?'active':'']" v-for="(itemt,indext) in categoryList" :key="indext" @click="handleClick('courseForm','categoryValue',itemt.value)">
+                            <i v-if="itemt.value===courseForm.categoryValue" class="el-icon-success"></i>
+                            {{itemt.label}}
+                        </li>
+                    </ul>
+                </div>
+            </template>
+            <template v-else-if="itemType==='baozhi'">
+                <div class="filt-item">
+                    <label>年份</label>
+                    <ul>
+                        <li :class="[itemy.value===baozhiForm.yearValue?'active':'']" v-for="(itemy,indexy) in yearList" :key="indexy" @click="handleClick('baozhiForm','yearValue',itemy.value)">
+                            <i v-if="itemy.value===baozhiForm.yearValue" class="el-icon-success"></i>
+                            {{itemy.label}}
+                        </li>
+                    </ul>
+                </div>
+                <div class="filt-item">
+                    <label>学段</label>
+                    <ul>
+                        <li :class="[items.study_phase===baozhiForm.studyValue?'active':'']" v-for="(items,indexs) in baozhiStudyList" :key="indexs" @click="handleClick('baozhiForm','studyValue',items.study_phase,items.study_phase_name)">
+                            <i v-if="items.study_phase===baozhiForm.studyValue" class="el-icon-success"></i>
+                            {{items.study_phase_name}}
+                        </li>
+                    </ul>
+                </div>
+                <div class="filt-item">
+                    <label>类型</label>
+                    <ul>
+                        <li :class="[itemt.value===baozhiForm.typeValue?'active':'']" v-for="(itemt,indext) in typeList" :key="indext" @click="handleClick('baozhiForm','typeValue',itemt.value)">
+                            <i v-if="itemt.value===baozhiForm.typeValue" class="el-icon-success"></i>
+                            {{itemt.label}}
+                        </li>
+                    </ul>
+                </div>
+            </template>
+            <template v-if="itemType==='jingdu'">
+                <div class="filt-item">
+                    <label>主题</label>
+                    <ul>
+                        <li :class="[itemy.value===jingduForm.categoryValue?'active':'']" v-for="(itemy,indexy) in themeList" :key="indexy" @click="handleClick('jingduForm','categoryValue',itemy.value)">
+                            <i v-if="itemy.value===baozhiForm.categoryValue" class="el-icon-success"></i>
+                            {{itemy.label}}
+                        </li>
+                    </ul>
+                </div>
+                <div class="filt-item">
+                    <label>学段</label>
+                    <ul>
+                        <li :class="[items.study_phase===jingduForm.studyValue?'active':'']" v-for="(items,indexs) in jingduStudyList" :key="indexs" @click="handleClick('jingduForm','studyValue',items.study_phase,items.study_phase_name)">
+                            <i v-if="items.study_phase===jingduForm.studyValue" class="el-icon-success"></i>
+                            {{items.study_phase_name}}
+                        </li>
+                    </ul>
+                </div>
+            </template>
+            <div class="filt-item">
+                <label>搜索</label>
+                <el-input placeholder="搜索" v-model="searchValue" maxlength="20">
+                    <el-button slot="append" icon="el-icon-search" @click="getList(1)"></el-button>
+                </el-input>
+            </div>
+        </div>
+        <ul class="item-box">
+            <li v-for="(itemC,indexC) in tableData" :key="indexC" @click="changeSelectGoods(itemC)">
+                <el-image
+                    class="image"
+                    :src="itemC.cover_image_url?itemC.cover_image_url:itemC.goods_type===2?require('../../assets/baozhi'+(Math.floor(Math.random()*2)+1)+'.png'):require('../../assets/kecheng'+(Math.floor(Math.random()*3)+1)+'.png')"
+                    :fit="'cover'">
+                </el-image>
+                <el-checkbox v-model="itemC.check" @change="changeSelectGoods(itemC)">{{itemC.name}}</el-checkbox>
+            </li>
+        </ul>
+        <div class="nodata" v-if="total_count===0">
+            <img src="../../assets/nodata.png" />
+            <p>找不到文件</p>
+        </div>
+        <!-- <el-pagination
+            background
+            :current-page="currentPages"
+            :page-size="page_capacitys"
+            :page-sizes="[8, 16, 24, 32, 40]"
+            :total="total_count"
+            layout="total, prev, pager, next, sizes, jumper"
+            @size-change="(val)=>handleSizeChange(val,'page_capacitys','currentPages')"
+            @current-change="(val)=>handleCurrentChange(val,'currentPages')"
+            v-if="total_count>0&&(courseForm.categoryValue==='ZB'||itemType==='jingdu')"
+        /> -->
+        <el-pagination
+            background
+            :current-page="currentPage"
+            :page-size="page_capacity"
+            :page-sizes="[9, 18, 27, 36, 45, 54]"
+            :total="total_count"
+            layout="total, prev, pager, next, sizes, jumper"
+            @size-change="(val)=>handleSizeChange(val,'page_capacity','currentPage')"
+            @current-change="(val)=>handleCurrentChange(val,'currentPage')"
+            v-else-if="total_count>0"
+        />
+    </div>
+  </div>
+</template>
+
+<script>
+//这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
+//例如:import 《组件名称》from ‘《组件路径》';
+import Header from "../../components/Header.vue";
+import Breadcrumb from '../../components/Breadcrumb.vue';
+import { getLogin } from "@/api/ajax";
+import { mapState } from 'vuex'; 
+
+export default {
+  //import引入的组件需要注入到对象中才能使用
+  components: { Header, Breadcrumb },
+  props: {},
+  data() {
+    //这里存放数据
+    return {
+        breadcrumbList:[
+            {
+                icon:'barcode-line',
+                url:'',
+                text:''
+            },
+            {
+                icon:'',
+                url:'',
+                notLink: true,
+                text:'兑换码管理'
+            },
+            {
+                icon:'',
+                url:'',
+                text:'创建兑换码'
+            },
+            {
+                icon:'',
+                url:'',
+                text:'添加内容'
+            }
+        ],
+        pageLoading: false,
+        tableData:[],
+        tableHeight: "", // 表格高度
+        total_count: 0,
+        loading: false,
+        tableLoading: false,
+        itemType: 'baozhi',
+        typeSelectList: [
+            {
+                label: '报纸',
+                value: 'baozhi'
+            },
+            {
+                label: '精读',
+                value: 'jingdu'
+            },
+            {
+                label: '课程',
+                value: 'kecheng'
+            }
+        ],
+        yearList:[
+            {
+                value: -1,
+                label: '全部'
+            }
+        ],
+        studyList:[
+            {
+                study_phase: -1,
+                study_phase_name: '全部'
+            }
+        ],
+        baozhiStudyList:[],
+        categoryList:[
+            {
+                value: 'LB',
+                label: '录播'
+            },
+            {
+                value: 'ZB',
+                label: '直播'
+            },
+        ],
+        typeList:[
+            {
+                value: 0,
+                label: '单本'
+            },
+            {
+                value: 1,
+                label: '专辑'
+            },
+        ],
+        courseForm:{
+            studyValue: -1,
+            categoryValue: 'LB'
+        },
+        baozhiForm:{
+            yearValue: -1,
+            studyValue: -1,
+            typeValue: 0,
+        },
+        jingduForm:{
+            studyValue: 11,
+            categoryValue: ''
+        },
+        searchValue: '',
+        page_capacity: 18, 
+        currentPage: 1,
+        currentPages: 1,
+        page_capacitys: 8, // 每页条数
+        themeList:[],
+        jingduStudyList: [
+            {
+                study_phase: 11,
+                study_phase_name: '小学'
+            },
+            {
+                study_phase: 21,
+                study_phase_name: '初一'
+            },
+            {
+                study_phase: 22,
+                study_phase_name: '初二'
+            },
+            {
+                study_phase: 23,
+                study_phase_name: '初三'
+            }
+        ],
+        checkGoodsList:[],
+        checkGoodsIdList: []
+    }
+  },
+  //计算属性 类似于data概念
+  computed: {
+  },
+  //监控data中数据变化
+  watch: {},
+  //方法集合
+  methods: {
+    changeSelectGoods(item){
+        if(this.checkGoodsIdList.indexOf(item.goods_id)>-1){
+            this.checkGoodsIdList.splice(this.checkGoodsIdList.indexOf(item.goods_id),1)
+            this.checkGoodsList.splice(this.checkGoodsIdList.indexOf(item.goods_id),1)
+            item.check = false
+        }else{
+            this.checkGoodsIdList.push(item.goods_id)
+            this.checkGoodsList.push({
+                goods_id: item.goods_id,
+                goods_type: item.goods_type
+            })
+            item.check = true
+        }
+    },
+    getList(val){
+        this.tableLoading = true
+        if(val){
+            this.pageNumber = val
+        }
+        let MethodName = "/ShopServer/Manager/GoodsQuery/PageQueryCourseList"
+        let data = {
+            page_capacity:this.page_capacity,
+            cur_page: this.currentPage,
+            search_content: this.searchValue.trim(),
+        }
+        if(this.itemType==='baozhi'){
+            MethodName = "/ShopServer/Manager/GoodsQuery/PageQueryIssueList"
+            data.year_label = this.baozhiForm.yearValue
+            data.study_phase = this.baozhiForm.studyValue
+            data.comb_flag = this.baozhiForm.typeValue==1?null:this.baozhiForm.typeValue
+            data.album_flag = this.baozhiForm.typeValue==0?null:this.baozhiForm.typeValue
+            getLogin(MethodName, data)
+            .then((res) => {
+                this.tableLoading = false
+                if(res.status===1){
+                    res.issue_list.forEach(item => {
+                        item.goods_type = 2
+                        item.goods_id = item.id
+                        item.check = this.checkGoodsIdList.indexOf(item.id)>-1?true:false
+                    });
+                    this.tableData = res.issue_list
+                    this.total_count = res.total_count
+                }
+            })
+            .catch(() => {
+                this.tableLoading = false
+            }); 
+        }else if(this.itemType==='kecheng'){
+            data.course_type = this.courseForm.categoryValue,
+            data.study_phase = this.courseForm.studyValue
+            getLogin(MethodName, data)
+            .then((res) => {
+                this.tableLoading = false
+                if(res.status===1){
+                    res.course_list.forEach(item => {
+                        item.goods_type = this.courseForm.categoryValue==='ZB'?1:0
+                        item.goods_id = item.id
+                        item.check = this.checkGoodsIdList.indexOf(item.id)>-1?true:false
+                    });
+                    this.tableData = res.course_list
+                    this.total_count = res.total_count
+                }
+            })
+            .catch(() => {
+                this.tableLoading = false
+            }); 
+        }else if(this.itemType==='jingdu'){
+            MethodName = "/ShopServer/Manager/GoodsQuery/PageQueryIreadArticleList"
+            data.label = this.jingduForm.categoryValue
+            data.study_phase = this.jingduForm.studyValue
+            getLogin(MethodName, data)
+            .then((res) => {
+                this.tableLoading = false
+                if(res.status===1){
+                    res.iread_article_list.forEach(item => {
+                        item.goods_type = 3
+                        item.goods_id = item.id
+                        item.check = this.checkGoodsIdList.indexOf(item.id)>-1?true:false
+                    });
+                    this.tableData = res.iread_article_list
+                    this.total_count = res.total_count
+                }
+            })
+            .catch(() => {
+                this.tableLoading = false
+            });
+        }
+    },
+    //计算table高度(动态设置table高度)
+    getTableHeight() {
+      let tableH = 320; //距离页面下方的高度
+      let tableHeightDetil = window.innerHeight - tableH;
+      if (tableHeightDetil <= 320) {
+        this.tableHeight = 320;
+      } else {
+        this.tableHeight = window.innerHeight - tableH;
+      }
+    },
+    handleSizeChange(val,type,page) {
+        this[type] = val
+        this[page] = 1;
+        this.getList()
+    },
+    handleCurrentChange(val,type) {
+        this[type] = val
+        this.getList()
+    },
+    // 去掉前后空格
+    handleTrim(form,fild){
+        this[form][fild] = this[form][fild].trim()
+    },
+    handleClick(form,file,value,name){
+        if(form==='courseForm'&&file==='categoryValue'&&value==='ZB'){
+            this.courseForm.studyValue = -1
+        }else if(form==='courseForm'&&file==='categoryValue'&&value==='LB'){
+            this.courseForm.studyValue = window.localStorage.getItem("courseFormstudyValue")?window.localStorage.getItem("courseFormstudyValue")*1:-1
+        }
+        if(form==='courseForm'&&file==='studyValue'&&this.courseForm.categoryValue==='ZB'){
+            return false
+        }
+        this[form][file] = value
+        this.currentPage = 1;
+        this.currentPages = 1
+        this.getList()
+    },
+    // 提交表单
+    handleChooseGoods(){
+        this.loading = true
+        let MethodName = "/ShopServer/Manager/DiscountCodeManager/AddGoodsToDiscountCode";
+        let data = {
+            discount_code_id: window.localStorage.getItem('cdKeyId')?window.localStorage.getItem('cdKeyId'):'',
+            goods_list: this.checkGoodsList,
+        }
+        getLogin(MethodName, data)
+        .then((res) => {
+            this.loading = false
+            if(res.status===1){
+                this.$router.go(-1)
+            }
+        }).catch((res) =>{
+            this.loading = false
+        })
+    },
+    // 学段列表
+    getStudyList(){
+        let MethodName = "/OrgServer/DictManager/GetStudyPhaseList"
+        getLogin(MethodName, {})
+        .then((res) => {
+            if(res.status===1){
+                let studyList = [
+                        {
+                            study_phase: -1,
+                            study_phase_name: '全部'
+                        }
+                    ]
+                this.studyList = studyList.concat(res.study_phase_list)
+                this.baozhiStudyList = res.study_phase_list
+                this.baozhiForm.studyValue = window.localStorage.getItem("baozhiFormstudyValue")?window.localStorage.getItem("baozhiFormstudyValue")*1:res.study_phase_list[0]?res.study_phase_list[0].study_phase:-1
+                if(this.itemType==='baozhi'){
+                    this.titleName = window.localStorage.getItem("baozhiFormstudyValueName")?window.localStorage.getItem("baozhiFormstudyValueName"):res.study_phase_list[0]?res.study_phase_list[0].study_phase_name:''
+                }else if(this.itemType==='jingdu'){
+                    this.titleName = window.localStorage.getItem("jingduFormstudyValueName")?window.localStorage.getItem("jingduFormstudyValueName"):res.study_phase_list[0]?res.study_phase_list[0].study_phase_name:''
+                }else if(this.itemType==='kecheng'){
+                    this.titleName = window.localStorage.getItem("courseFormstudyValueName")?window.localStorage.getItem("courseFormstudyValueName"):res.study_phase_list[0]?res.study_phase_list[0].study_phase_name:''
+                }
+                
+            }
+        })
+        .catch(() => {
+            
+        }); 
+    },
+    // 获取年份列表
+    getYearList(){
+        this.yearList = [
+            {
+                value: -1,
+                label: '全部'
+            }
+        ]
+        let yearList = []
+        let MethodName = "/ShopServer/Client/ShopHomeQuery/GetIssueYearLabelList"
+        getLogin(MethodName, {})
+        .then((res) => {
+            if(res.status===1){
+                res.year_label_list.forEach(nowYear => {
+                    let obj = {
+                        value: nowYear,
+                        label: nowYear
+                    }
+                    yearList.push(obj)
+                })
+                this.yearList = this.yearList.concat(yearList)
+            }
+        })
+        .catch(() => {
+            this.loading = false
+        });
+        
+    },
+    getLabelList(){
+        this.themeList = [
+            {
+                value: '',
+                label: '全部'
+            }
+        ]
+        let yearList = []
+        let MethodName = "/ShopServer/Manager/GoodsQuery/GetIreadArticleLabelList"
+        getLogin(MethodName, {})
+        .then((res) => {
+            if(res.status===1){
+                res.label_list.forEach(nowYear => {
+                    let obj = {
+                        value: nowYear,
+                        label: nowYear
+                    }
+                    yearList.push(obj)
+                })
+                this.themeList = this.themeList.concat(yearList)
+            }
+        })
+        .catch(() => {
+            this.loading = false
+        });
+    }
+  },
+  //生命周期 - 创建完成(可以访问当前this实例)
+  created() {
+    this.getTableHeight()
+    this.getStudyList()
+    this.getYearList()
+    this.getLabelList()
+    this.getList()
+  },
+  //生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {
+    let _this = this
+    let input = document.querySelector('input');
+    input.addEventListener('keyup', function(event) {
+        // 判断是否按下回车键
+        if (event.keyCode === 13) {
+            // 回车键被按下,执行你想要的操作
+            _this.getList(1)
+        }
+    });
+  },
+  //生命周期-创建之前
+  beforeCreated() { },
+  //生命周期-挂载之前
+  beforeMount() { },
+  //生命周期-更新之前
+  beforUpdate() { },
+  //生命周期-更新之后
+  updated() { },
+  //生命周期-销毁之前
+  beforeDestory() { },
+  //生命周期-销毁完成
+  destoryed() { },
+  //如果页面有keep-alive缓存功能,这个函数会触发
+  activated() { }
+}
+</script>
+<style lang="scss" scoped>
+/* @import url(); 引入css类 */
+.breadcrumb-box{
+    width: 1408px;
+    margin: 0 auto;
+    position: initial;
+}
+.manage-root-contain{
+    width: 1408px;
+    height: calc(100vh - 120px);
+    overflow: auto;
+    margin: 0 auto;
+    border-radius: 4px;
+    background: #FFF;
+    padding: 24px;
+    display: block;
+    .common-title-box{
+        width: 100%;
+        .el-icon-arrow-left{
+            font-weight: 500;
+            margin-right: 8px;
+            cursor: pointer;
+        }
+    }
+    .filt-box{
+        margin: 24px 0;
+    }
+    .filt-item{
+        display: flex;
+        margin-bottom: 8px;
+        label{
+            width: 52px;
+            font-weight: 400;
+            font-size: 16px;
+            line-height: 32px;
+            color: #2F3742;
+            flex-shrink: 0;
+        }
+        ul{
+            list-style: none;
+            display: flex;
+            flex-flow: wrap;
+            padding: 0;
+            margin: 0;
+            li{
+                margin: 0 8px 16px 0;
+                background: #F2F3F5;
+                border-radius: 2px;
+                padding: 3px 11px;
+                font-weight: 500;
+                font-size: 16px;
+                line-height: 24px;
+                color: #2F3742;
+                cursor: pointer;
+                border: 1px solid #F2F3F5;
+                height: 32px;
+                box-sizing: border-box;
+                display: flex;
+                align-items: center;
+                &:hover{
+                    color: #165DFF;
+                }
+                &.not-allow{
+                    cursor: not-allowed;
+                    background: #F2F3F5;
+                    color: #C1C5CD;
+                }
+                &.active{
+                    color: #165DFF;
+                    border-color: #165DFF;
+                    background: #FFFFFF;
+                    .el-icon-success{
+                        margin-right: 4px;
+                        font-size: 12px;
+                        margin-top: 2px;
+                    }
+                }
+                &.not-allow.active{
+                    color: #CEDCFE;
+                    border-color: #CEDCFE;
+                }
+            }
+        }
+        .el-input{
+            width: 240px;
+            height: 32px;
+            background: #F2F3F5;
+            border-radius: 2px;
+        }
+    }
+}
+.item-box{
+    padding: 0 0 0 40px;
+    margin: 0;
+    list-style: none;
+    display: flex;
+    flex-flow: wrap;
+    li{
+        width: 120px;
+        margin: 12px;
+        .image{
+            width: 120px;
+            height: 168px;
+        }
+        .el-checkbox{
+            width: 120px;
+            display: flex;
+        }
+    }
+}
+.nodata {
+    text-align: center;
+    img {
+        width: 329px;
+    }
+    p {
+        color: #A8A8A8;
+        font-size: 14px;
+        font-weight: 400;
+        line-height: 22px;
+        margin: 30px 0;
+    }
+}
+</style>
+<style lang="scss">
+.filt-box{
+    input{
+        height: 32px;
+        line-height: 32px;
+        background: #F2F3F5;
+        border: none;
+    }
+    .el-input__icon{
+        line-height: 32px;
+        cursor: pointer;
+        color: #4E5969 !important;
+    }
+    .el-input-group__append{
+        background: #F2F3F5;
+        border: none;
+    }
+    .el-button{
+        padding: 9px 12px;
+    }
+}
+.add-goods{
+    .item-box{
+        .el-checkbox{
+            padding: 12px 0;
+            .el-checkbox__inner{
+                margin-top: 5px;
+            }
+            .el-checkbox__label{
+                width: 100px;
+                white-space: normal;
+                color:#2F3742;
+                font-size: 14px;
+                font-weight: 400;
+                line-height: 22px; 
+            }
+        }
+    }
+}
+</style>

+ 492 - 0
src/views/cdkey_manage/CheckGoods.vue

@@ -0,0 +1,492 @@
+<template>
+  <div class="manage-root check-goods">
+    <Header />
+    <div class="manage-root-contain">
+        <nav-menu class="manage-root-contain-left" :activeMenuIndex="activeMenuIndex"></nav-menu>
+        <div class="manage-root-contain-right personnel-manage-right" v-if="info">
+            <breadcrumb :breadcrumbList="breadcrumbList" class="breadcrumb-box"></breadcrumb>
+            <div class="personal-inner">
+                <div class="common-title-box">
+                    <h3>{{info.name}} 兑换码:<span class="code" :id="'copy-'+info.code">{{info.code}}</span><svg-icon icon-class="copy" class="copy" @click="CopyToClipboard('copy-'+info.code)"></svg-icon></h3>
+                    <div class="btn-box">
+                        到期日期:{{info.end_date}}
+                    </div>
+                </div>
+                <div class="tabs">
+                    <a :class="[tabsIndex===0?'active':'']" @click="handleChangeTabs(0)">包含内容 {{info.goods_count}}</a>
+                    <a :class="[tabsIndex===1?'active':'']" @click="handleChangeTabs(1)">使用记录 {{info.person_count_use}}/{{info.person_count_max}}</a>
+                </div>
+                <div class="filt-item" v-if="tabsIndex===1">
+                    <el-input placeholder="搜索" v-model="searchInput" maxlength="20">
+                        <el-button slot="append" icon="el-icon-search" @click="getList(1)"></el-button>
+                    </el-input>
+                </div>
+                <template v-if="tabsIndex===0">
+                    <el-table
+                        class="search-table"
+                        :data="tableData"
+                        style="width: 100%"
+                        @sort-change="handleSort"
+                        :default-sort = dataSort
+                        :max-height="tableHeight"
+                        v-loading="tableLoading">
+                        <el-table-column
+                            type="index"
+                            label="#"
+                            sortable
+                            width="54"
+                            :index="(pageNumber-1)*pageSize+1">
+                        </el-table-column>
+                        <el-table-column
+                            prop="goods_name"
+                            label="名称"
+                            sortable="custom">
+                        </el-table-column>
+                        <el-table-column
+                            prop="goods_type"
+                            label="类型"
+                            sortable="custom"
+                            width="200" >
+                            <template slot-scope="scope">
+                                <span class="items-type" :style="{background:goodsTypeListCss[scope.row.goods_type]?goodsTypeListCss[scope.row.goods_type].bg:'', color:goodsTypeListCss[scope.row.goods_type]?goodsTypeListCss[scope.row.goods_type].color:''}">{{scope.row.goods_type_name}}</span>
+                            </template>
+                        </el-table-column>
+                        <el-table-column
+                            prop="goods_study_phase_name"
+                            label="学段"
+                            sortable="custom"
+                            width="200">
+                        </el-table-column>
+                    </el-table>
+                    <el-pagination
+                        key="pagination"
+                        background
+                        @size-change="(val)=>handleSizeChange(val,'pageSize','pageNumber')"
+                        @current-change="(val)=>handleCurrentChange(val,'pageNumber')"
+                        :current-page="pageNumber"
+                        :page-sizes="[10, 20, 30, 40]"
+                        :page-size="pageSize"
+                        layout="total, prev, pager, next, sizes, jumper"
+                        :total="total_count">
+                    </el-pagination>
+                </template>
+                <template v-if="tabsIndex===1">
+                    <el-table
+                        class="search-table"
+                        :data="tableData"
+                        style="width: 100%"
+                        @sort-change="handleSort"
+                        :default-sort = dataSort
+                        :max-height="tableHeight"
+                        v-loading="tableLoading">
+                        <el-table-column
+                            type="index"
+                            label="#"
+                            sortable
+                            width="54"
+                            :index="(pageNumber-1)*pageSize+1">
+                        </el-table-column>
+                        <el-table-column
+                            prop="person_name"
+                            label="用户名"
+                            sortable="custom">
+                        </el-table-column>
+                        <el-table-column
+                            prop="person_org_name"
+                            label="机构"
+                            sortable="custom">
+                        </el-table-column>
+                        <el-table-column
+                            prop="use_time"
+                            label="激活时间"
+                            sortable="custom">
+                        </el-table-column>
+                    </el-table>
+                    <el-pagination
+                        background
+                        key="auditpagination"
+                        @size-change="(val)=>handleSizeChange(val,'pageSizes','pageNumbers')"
+                        @current-change="(val)=>handleCurrentChange(val,'pageNumbers')"
+                        :current-page="pageNumbers"
+                        :page-sizes="[10, 20, 30, 40]"
+                        :page-size="pageSizes"
+                        layout="total, prev, pager, next, sizes, jumper"
+                        :total="total_count">
+                    </el-pagination>
+                </template>
+            </div>
+        </div>
+    </div>
+  </div>
+</template>
+
+<script>
+//这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
+//例如:import 《组件名称》from ‘《组件路径》';
+import Header from "../../components/Header.vue";
+import NavMenu from "../../components/NavMenu.vue"
+import Breadcrumb from '../../components/Breadcrumb.vue';
+import { getLogin } from "@/api/ajax";
+
+export default {
+  //import引入的组件需要注入到对象中才能使用
+  components: { Header, NavMenu, Breadcrumb },
+  props: {},
+  data() {
+    //这里存放数据
+    return {
+        activeMenuIndex: "cdkey_manage",
+        breadcrumbList:[
+            {
+                icon:'barcode-line',
+                url:'',
+                text:''
+            },
+            {
+                icon:'',
+                url:'',
+                text:'兑换码管理'
+            },
+            {
+                icon:'',
+                url:'',
+                text:'兑换码详情'
+            }
+        ],
+        searchInput: '',
+        tableData:[
+            // {
+            //     id:'1',
+            //     userName:'admin',
+            //     realName:'超级管理员',
+            //     sex:'0',
+            //     type:'0', // 0 管理员 1 平台管理员 2 内容管理员 3 财务管理员 4 兑换码管理员
+            //     email:'d.dkemi@kqtdgbo.tj',
+            //     phone:'13082684216',
+            //     status:'1',
+            //     data:'2018-02-03',
+            //     img:''
+            // }
+        ],
+        pageSize: 10, 
+        pageNumber: 1,
+        pageSizes: 10, 
+        pageNumbers: 1,
+        tableHeight: "", // 表格高度
+        total_count: 0,
+        dataSort: {},
+        tableLoading: false,
+        tabsIndex: 0,
+        info: null,
+        goodsTypeListCss:{
+            2:{
+                text:'报纸',
+                color:'#165DFF',
+                bg:'#E8F7FF'
+            },
+            // '2':{
+            //     text:'画刊',
+            //     color:'#F53F3F',
+            //     bg:'#FFECE8'
+            // },
+            '3':{
+                text:'精读',
+                color:'#0FC6C2',
+                bg:'#E8FFFB'
+            },
+            0:{
+                text:'课程',
+                color:'#722ED1',
+                bg:'#F5E8FF'
+            },
+            1:{
+                text:'课程',
+                color:'#722ED1',
+                bg:'#F5E8FF'
+            },
+            10:{
+                text:'课程',
+                color:'#722ED1',
+                bg:'#F5E8FF'
+            },
+            // '5':{
+            //     text:'报纸专辑',
+            //     color:'#165DFF',
+            //     bg:'#E8F7FF'
+            // },
+            // '6':{
+            //     text:'画刊专辑',
+            //     color:'#F53F3F',
+            //     bg:'#FFECE8'
+            // }
+        },
+    }
+  },
+  //计算属性 类似于data概念
+  computed: {
+  },
+  //监控data中数据变化
+  watch: {},
+  //方法集合
+  methods: {
+    handleChangeTabs(value){
+        this.tabsIndex = value
+        if(value===1){
+            let _this = this
+            let input = document.querySelector('input');
+            input.addEventListener('keyup', function(event) {
+                // 判断是否按下回车键
+                if (event.keyCode === 13) {
+                    // 回车键被按下,执行你想要的操作
+                    _this.getList(1)
+                }
+            });
+        }
+        // this.pageNumber = 1
+        this.getList()
+    },
+    handleSort(value){
+        let dataSort = {
+            prop: value.prop,
+            order: value.order
+        }
+        this.dataSort = dataSort
+        this.getList()
+    },
+    handleSizeChange(val,type,page) {
+        this[type] = val
+        this[page] = 1
+        this.getList()
+    },
+    handleCurrentChange(val,type) {
+        this[type] = val
+        this.getList()
+    },
+    // 查询列表
+    getList(page){
+        this.tableLoading = true
+        if(page){
+            if(this.tabsIndex===0){
+                this.pageNumber = page
+            }else{
+                this.pageNumbers = page
+            }
+        }
+        let MethodName = "/ShopServer/Manager/DiscountCodeManager/PageQueryDiscountCodeGoodsList";
+        if(this.tabsIndex===1){
+            MethodName = "/ShopServer/Manager/DiscountCodeManager/PageQueryDiscountCodeUsePersonList"
+        }
+        let order_column_list = []
+        if(this.dataSort != {}){
+            if(this.dataSort.order=='descending'){
+                order_column_list = [this.dataSort.prop + ':desc']
+            }else if(this.dataSort.order=='ascending'){
+                // 升序不传值
+                order_column_list = [this.dataSort.prop]
+            }else{
+                order_column_list = ['create_time:desc']
+            }
+        }else{
+            order_column_list = ['create_time:desc']
+        }
+        let data = {
+            content:this.searchInput.trim(),
+            page_capacity:this.tabsIndex===0?this.pageSize:this.pageSizes,
+            cur_page:this.tabsIndex===0?this.pageNumber:this.pageNumbers,
+            order_column_list: order_column_list,
+            discount_code_id: this.$route.query.id?this.$route.query.id:''
+        }
+        getLogin(MethodName, data)
+        .then((res) => {
+            this.tableLoading = false
+            if(res.status===1){
+                this.info = res.discount_code_info
+                this.tableData = res.goods_list?res.goods_list:res.person_list
+                this.total_count = res.total_count
+            }
+        })
+        .catch(() => {
+            this.tableLoading = false
+        });
+    },
+    //计算table高度(动态设置table高度)
+    getTableHeight() {
+      let tableH = 370; //距离页面下方的高度
+      let tableHeightDetil = window.innerHeight - tableH;
+      if (tableHeightDetil <= 300) {
+        this.tableHeight = 300;
+      } else {
+        this.tableHeight = window.innerHeight - tableH;
+      }
+    },
+    CopyToClipboard(element) {
+      var doc = document,
+        text = doc.getElementById(element),
+        range,
+        selection;
+      if (doc.body.createTextRange) {
+        range = doc.body.createTextRange();
+        range.moveToElementText(text);
+        range.select();
+      } else if (window.getSelection) {
+        selection = window.getSelection();
+        range = doc.createRange();
+        range.selectNodeContents(text);
+        selection.removeAllRanges();
+        selection.addRange(range);
+      }
+      document.execCommand("copy");
+      this.$message({
+        message: "复制成功",
+        type: "success",
+      });
+      window.getSelection().removeAllRanges();
+    },
+  },
+  //生命周期 - 创建完成(可以访问当前this实例)
+  created() {
+    this.getTableHeight();
+    this.getList()
+  },
+  //生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {
+    
+  },
+  //生命周期-创建之前
+  beforeCreated() { },
+  //生命周期-挂载之前
+  beforeMount() { },
+  //生命周期-更新之前
+  beforUpdate() { },
+  //生命周期-更新之后
+  updated() { },
+  //生命周期-销毁之前
+  beforeDestory() { },
+  //生命周期-销毁完成
+  destoryed() { },
+  //如果页面有keep-alive缓存功能,这个函数会触发
+  activated() { }
+}
+</script>
+<style lang="scss" scoped>
+/* @import url(); 引入css类 */
+.tabs{
+    display: flex;
+    padding: 16px 0;
+    a{
+        font-size: 14px;
+        line-height: 22px;
+        color: #4E5969;
+        border-radius: 100px;
+        padding: 5px 16px;
+        margin-right: 12px;
+        &:hover{
+            background: #F2F3F5;
+        }
+        &.active{
+            background: #F2F3F5;
+            font-weight: 500;
+            color: #165DFF;
+        }
+    }
+}
+.items-type{
+    padding: 1px 8px;
+    font-weight: 500;
+    font-size: 14px;
+    line-height: 22px;
+    border-radius: 2px;
+}
+.filt-item{
+    display: flex;
+    margin-bottom: 8px;
+    label{
+        width: 52px;
+        font-weight: 400;
+        font-size: 16px;
+        line-height: 32px;
+        color: #2F3742;
+        flex-shrink: 0;
+    }
+    ul{
+        list-style: none;
+        display: flex;
+        flex-flow: wrap;
+        padding: 0;
+        margin: 0;
+        li{
+            margin: 0 8px 16px 0;
+            background: #F2F3F5;
+            border-radius: 2px;
+            padding: 3px 11px;
+            font-weight: 500;
+            font-size: 16px;
+            line-height: 24px;
+            color: #2F3742;
+            cursor: pointer;
+            border: 1px solid #F2F3F5;
+            height: 32px;
+            box-sizing: border-box;
+            display: flex;
+            align-items: center;
+            &:hover{
+                color: #165DFF;
+            }
+            &.not-allow{
+                cursor: not-allowed;
+                background: #F2F3F5;
+                color: #C1C5CD;
+            }
+            &.active{
+                color: #165DFF;
+                border-color: #165DFF;
+                background: #FFFFFF;
+                .el-icon-success{
+                    margin-right: 4px;
+                    font-size: 12px;
+                    margin-top: 2px;
+                }
+            }
+            &.not-allow.active{
+                color: #CEDCFE;
+                border-color: #CEDCFE;
+            }
+        }
+    }
+    .el-input{
+        width: 240px;
+        height: 32px;
+        background: #F2F3F5;
+        border-radius: 2px;
+    }
+}
+.copy{
+    color: rgba(78, 89, 105, 1);
+    margin-left: 8px;
+    cursor: pointer;
+}
+</style>
+<style lang="scss">
+.check-goods{
+    .filt-item{
+        input{
+            height: 32px;
+            line-height: 32px;
+            background: #F2F3F5;
+            border: none;
+        }
+        .el-input__icon{
+            line-height: 32px;
+            cursor: pointer;
+            color: #4E5969 !important;
+        }
+        .el-input-group__append{
+            background: #F2F3F5;
+            border: none;
+        }
+        .el-button{
+            padding: 9px 12px;
+        }
+    }
+}
+</style>

+ 554 - 0
src/views/cdkey_manage/CreateCdkey.vue

@@ -0,0 +1,554 @@
+<template>
+  <div class="manage-root cdkey-create">
+    <Header />
+    <div class="manage-root-contain">
+        <nav-menu class="manage-root-contain-left" :activeMenuIndex="activeMenuIndex"></nav-menu>
+        <div class="manage-root-contain-right">
+            <breadcrumb :breadcrumbList="breadcrumbList" class="breadcrumb-box"></breadcrumb>
+            <div class="create-top">
+                <div class="common-title-box">
+                    <h3>{{id?'编辑兑换码':'创建兑换码'}}</h3>
+                    <div class="btn-box" v-if="id||!id&&stepIndex!==2">
+                        <el-button size="small" :disabled="true">上一步</el-button>
+                        <el-button type="primary" size="small" @click="handleStep('+')" :disabled="stepIndex===2" :loading="loading">下一步</el-button>
+                    </div>
+                </div>
+                <el-steps :active="stepIndex" align-center>
+                    <el-step title="基本信息" description="填写兑换码基本信息">
+                        <svg-icon icon-class="dot" slot="icon" class="svg-dot"></svg-icon>
+                    </el-step>
+                    <el-step :title="id?'编辑兑换内容':'添加兑换内容'" description="为兑换码添加内容">
+                        <svg-icon icon-class="dot" slot="icon" class="svg-dot"></svg-icon>
+                    </el-step>
+                    <el-step :title="id?'完成编辑':'完成创建'" :description="id?'兑换码编辑完成':'兑换码创建完成'">
+                        <svg-icon icon-class="dot" slot="icon" class="svg-dot"></svg-icon>
+                    </el-step>
+                </el-steps>
+            </div>
+            <div class="create-bottom">
+                <el-form :model="organizeForm" :rules="rulesOrganize" ref="organizeForm" label-width="100px" class="registerForm" v-if="stepIndex===0">
+                    <el-form-item label="兑换码名称" prop="name">
+                        <el-input v-model="organizeForm.name" placeholder="请输入兑换码名称" @blur="handleTrim('organizeForm','name')" maxlength="20"></el-input>
+                        <p class="tips">不超过20个字</p>
+                    </el-form-item>
+                    <el-form-item label="可使用人数" prop="person_count_max" class="price-box">
+                        <el-input-number v-model="organizeForm.person_count_max" @change="handleChange" :min="0" :max="500" size="small" class="personal-ceil"></el-input-number>
+                        <span class="append">人</span>
+                        <p class="tips">最多不超过 500 次</p>
+                    </el-form-item>
+                    <el-form-item label="有效期" prop="valid_day_count" class="validity-box">
+                        <el-input placeholder="请输入内容" v-model="organizeForm.valid_day_count" type="number" :min="1" maxlength="20">
+                            <template slot="append">天</template>
+                        </el-input>
+                    </el-form-item>
+                    <el-form-item label="备注" prop="momo">
+                        <el-input
+                            type="textarea"
+                            :rows="4"
+                            placeholder="请输入"
+                            v-model="organizeForm.momo"
+                            maxlength="200"
+                            show-word-limit>
+                        </el-input>
+                    </el-form-item>
+                </el-form>
+                <div v-if="stepIndex===1">
+                    <div class="issue-top">
+                        <h4 class="issue-top-left">
+                            内容列表
+                        </h4>
+                        <el-button type="primary" size="small" @click="addGoods">添加内容</el-button>
+                    </div>
+                    <el-table
+                        class="search-table"
+                        :data="tableData"
+                        style="width: 100%"
+                        @sort-change="handleSort"
+                        :default-sort = dataSort
+                        :max-height="tableHeight"
+                        v-loading="tableLoading">
+                        <el-table-column
+                            type="index"
+                            label="#"
+                            sortable
+                            width="54"
+                            :index="(pageNumber-1)*pageSize+1">
+                        </el-table-column>
+                        <el-table-column
+                            prop="goods_name"
+                            label="名称"
+                            sortable="custom">
+                        </el-table-column>
+                        <el-table-column
+                            prop="goods_type"
+                            label="类型"
+                            sortable="custom"
+                            width="150" >
+                            <template slot-scope="scope">
+                                <span class="items-type" :style="{background:goodsTypeListCss[scope.row.goods_type]?goodsTypeListCss[scope.row.goods_type].bg:'', color:goodsTypeListCss[scope.row.goods_type]?goodsTypeListCss[scope.row.goods_type].color:''}">{{scope.row.goods_type_name}}</span>
+                            </template>
+                        </el-table-column>
+                        <el-table-column
+                            prop="goods_study_phase_name"
+                            label="学段"
+                            sortable="custom"
+                            width="120">
+                        </el-table-column>
+                        <el-table-column
+                            fixed="right"
+                            label="操作"
+                            width="180">
+                            <template slot-scope="scope">
+                                <el-button
+                                    @click.native.prevent="handleDelete(scope.row, scope.$index)"
+                                    type="text"
+                                    size="small"
+                                    class="red-btn">
+                                    删除
+                                </el-button>
+                            </template>
+                        </el-table-column>
+                    </el-table>
+                    <el-pagination
+                        background
+                        @size-change="handleSizeChange"
+                        @current-change="handleCurrentChange"
+                        :current-page="pageNumber"
+                        :page-sizes="[10, 20, 30, 40]"
+                        :page-size="pageSize"
+                        layout="total, prev, pager, next, sizes, jumper"
+                        :total="total_count">
+                    </el-pagination>
+                </div>
+                <div v-if="stepIndex===2">
+                    <el-result icon="success" :subTitle="id?'兑换码编辑成功':'兑换码创建成功'">
+                        <template slot="extra">
+                            <el-button size="small" @click="handleback">返回列表</el-button>
+                            <el-button type="primary" size="small" @click="handleCreate">继续创建</el-button>
+                        </template>
+                    </el-result>
+                </div>
+            </div>
+        </div>
+    </div>
+  </div>
+</template>
+
+<script>
+//这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
+//例如:import 《组件名称》from ‘《组件路径》';
+import Header from "../../components/Header.vue";
+import NavMenu from "../../components/NavMenu.vue"
+import Breadcrumb from '../../components/Breadcrumb.vue';
+import { getLogin } from "@/api/ajax";
+
+export default {
+  //import引入的组件需要注入到对象中才能使用
+  components: { Header, NavMenu, Breadcrumb },
+  props: {},
+  data() {
+    //这里存放数据
+    const validateValidity = (rule, value, callback) => {
+        if (value === '') {
+            callback(new Error('请输入有效期'));
+        } else {
+            if (value<1) {
+                callback(new Error('请输入有效期'));
+            } else {
+                callback();
+            }
+        }
+    };
+    return {
+        goodsTypeListCss:{
+            2:{
+                text:'报纸',
+                color:'#165DFF',
+                bg:'#E8F7FF'
+            },
+            // '2':{
+            //     text:'画刊',
+            //     color:'#F53F3F',
+            //     bg:'#FFECE8'
+            // },
+            '3':{
+                text:'精读',
+                color:'#0FC6C2',
+                bg:'#E8FFFB'
+            },
+            0:{
+                text:'课程',
+                color:'#722ED1',
+                bg:'#F5E8FF'
+            },
+            1:{
+                text:'课程',
+                color:'#722ED1',
+                bg:'#F5E8FF'
+            },
+            10:{
+                text:'课程',
+                color:'#722ED1',
+                bg:'#F5E8FF'
+            },
+            // '5':{
+            //     text:'报纸专辑',
+            //     color:'#165DFF',
+            //     bg:'#E8F7FF'
+            // },
+            // '6':{
+            //     text:'画刊专辑',
+            //     color:'#F53F3F',
+            //     bg:'#FFECE8'
+            // }
+        },
+        activeMenuIndex: "cdkey_manage",
+        breadcrumbList:[
+            {
+                icon:'barcode-line',
+                url:'',
+                text:''
+            },
+            {
+                icon:'',
+                url:'',
+                text:'兑换码管理'
+            }
+        ],
+        id:this.$route.query.id?this.$route.query.id:'',
+        organizeForm:{
+            name: '',
+            person_count_max: 50,
+            valid_day_count: 30,
+            momo: ''
+        },
+        rulesOrganize:{
+            name:[
+                { required: true, message: '请输入兑换码名称', trigger: 'blur' },
+                { max: 20, message: '兑换码名称最多20位', trigger:'change' },
+            ],
+            person_count_max:[
+                { required: true, message: '请输入可使用人数', trigger: 'blur' }
+            ],
+            valid_day_count:[
+                { required: true, validator: validateValidity, trigger: 'blur' }
+            ],
+        },
+        stepIndex:window.localStorage.getItem('cdKeyId')?1:0, // 步骤索引
+        loading: false,
+        cdKeyId: window.localStorage.getItem('cdKeyId')?window.localStorage.getItem('cdKeyId'):'',
+        tableLoading: false,
+        pageSize: 10, 
+        pageNumber: 1,
+        tableHeight: "", // 表格高度
+        total_count: 0,
+        dataSort: {},
+        tableData: []
+    }
+  },
+  //计算属性 类似于data概念
+  computed: {
+    
+  },
+  //监控data中数据变化
+  watch: {
+    
+  },
+  //方法集合
+  methods: {
+    // 删除
+    handleDelete(row){
+        this.$confirm('确定删除吗?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+            let Mname = "/ShopServer/Manager/DiscountCodeManager/DeleteGoodsFromDiscountCode";
+            let data = {
+                discount_code_id: this.cdKeyId,
+                goods_type: row.goods_type,
+                goods_id: row.goods_id
+            };
+            getLogin(Mname, data).then(res => {
+                this.$message({
+                    type: 'success',
+                    message: '删除成功!'
+                });
+                this.getGoodsList()
+            });
+        }).catch(() => {
+               
+        });
+    },
+    handleSizeChange(val) {
+        this.pageSize = val
+        this.pageNumber = 1
+        this.getGoodsList()
+    },
+    handleCurrentChange(val) {
+        this.pageNumber = val
+        this.getGoodsList()
+    },
+    handleSort(value){
+        let dataSort = {
+            prop: value.prop,
+            order: value.order
+        }
+        this.dataSort = dataSort
+        this.getGoodsList()
+    },
+    // 上一步下一步
+    handleStep(type){
+        if(type=='-'){
+            // if(this.stepIndex>0) this.stepIndex--
+        }else{
+            if(this.stepIndex===0) {
+                this.$refs['organizeForm'].validate((valid) => {
+                    if (valid) {
+                        this.handleCreateCdkey()
+                    } else {
+                        return false;
+                    }
+                });
+            }else if(this.stepIndex===1){
+                this.stepIndex++
+            }
+        }
+    },
+    changeIcon(flag){
+        this[flag] = !this[flag]
+    },
+    // 返回列表
+    handleback(){
+        localStorage.setItem("pageNumber",1)
+        this.$router.push({
+            path: "/cdkey_manage",
+            query: {
+                
+            },
+        });
+    },
+    //继续创建
+    handleCreate(){
+        window.localStorage.removeItem('cdKeyId')
+        this.$router.replace('/createCdkey')
+        location.reload()
+    },
+    handleChange(value) {
+        // console.log(value)
+    },
+    handleCreateCdkey(){
+        this.loading = true
+        let MethodName = "/ShopServer/Manager/DiscountCodeManager/CreateDiscountCode";
+        let form = this.organizeForm
+        let data = form
+        getLogin(MethodName, data)
+        .then((res) => {
+            this.loading = false
+            if(res.status===1){
+               this.cdKeyId = res.id
+               this.stepIndex++
+               window.localStorage.removeItem('cdKeyId')
+               this.getGoodsList()
+            }
+        })
+        .catch(() => {
+            this.loading = false
+        });
+    },
+    // 去掉前后空格
+    handleTrim(form,fild){
+        this[form][fild] = this[form][fild].trim()
+    },
+    getGoodsList(){
+        this.tableLoading = true
+        let MethodName = "/ShopServer/Manager/DiscountCodeManager/PageQueryDiscountCodeGoodsList";
+        let order_column_list = []
+        if(this.dataSort != {}){
+            if(this.dataSort.order=='descending'){
+                order_column_list = [this.dataSort.prop + ':desc']
+            }else if(this.dataSort.order=='ascending'){
+                // 升序不传值
+                order_column_list = [this.dataSort.prop]
+            }else{
+                order_column_list = ['create_time:desc']
+            }
+        }else{
+            order_column_list = ['create_time:desc']
+        }
+        let data = {
+            discount_code_id: this.cdKeyId,
+            page_capacity:this.pageSize,
+            cur_page:this.pageNumber,
+            order_column_list: order_column_list
+        }
+        getLogin(MethodName, data)
+        .then((res) => {
+            this.tableLoading = false
+            if(res.status===1){
+               this.tableData = res.goods_list
+               this.total_count = res.total_count
+            }
+        })
+        .catch(() => {
+            this.tableLoading = false
+        });
+    },
+    // 添加商品
+    addGoods(){
+        window.localStorage.setItem('cdKeyId',this.cdKeyId)
+        this.$router.push({
+            path:'/addGoods'
+        })
+    },
+    //计算table高度(动态设置table高度)
+    getTableHeight() {
+      let tableH = 460; //距离页面下方的高度
+      let tableHeightDetil = window.innerHeight - tableH;
+      if (tableHeightDetil <= 300) {
+        this.tableHeight = 300;
+      } else {
+        this.tableHeight = window.innerHeight - tableH;
+      }
+    },
+  },
+  //生命周期 - 创建完成(可以访问当前this实例)
+  created() {
+    let obj = {
+        icon:'',
+        url:'',
+        text:'创建兑换码'
+    }
+    if(this.id){
+        obj.text = '编辑兑换码'
+        // this.getCourseInfo()
+    }
+    this.breadcrumbList.push(obj)
+    this.getTableHeight()
+    if(this.stepIndex===1){
+        this.getGoodsList()
+    }
+  },
+  //生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {
+
+  },
+  //生命周期-创建之前
+  beforeCreated() { },
+  //生命周期-挂载之前
+  beforeMount() { },
+  //生命周期-更新之前
+  beforUpdate() { },
+  //生命周期-更新之后
+  updated() { },
+  //生命周期-销毁之前
+  beforeDestory() { },
+  //生命周期-销毁完成
+  destoryed() { },
+  //如果页面有keep-alive缓存功能,这个函数会触发
+  activated() { }
+}
+</script>
+<style lang="scss" scoped>
+/* @import url(); 引入css类 */
+.create-top{
+    background: #FFFFFF;
+    border-radius: 4px;
+    padding: 24px;
+    .common-title-box{
+        margin-bottom: 4px;
+    }
+}
+.create-bottom{
+    padding: 40px 40px;
+    margin-top: 16px;
+    background: #FFFFFF;
+    border-radius: 4px;
+    height: calc(100vh - 292px);
+    overflow: auto;
+    .tips{
+        margin: 0;
+        color: #86909C;
+        font-size: 12px;
+        line-height: 20px;
+    }
+    .issue-top{
+        display: flex;
+        justify-content: space-between;
+        margin-bottom: 8px;
+        &-left{
+            margin: 0;
+            color: #1D2129;
+            font-size: 20px;
+            font-weight: 500;
+            line-height: 28px;
+            span{
+                margin-left: 4px;
+                color: #86909C;
+                font-size: 14px;
+                font-weight: 400;
+                line-height: 22px;
+            }
+        }
+    }
+}
+.items-type{
+    padding: 1px 8px;
+    font-weight: 500;
+    font-size: 14px;
+    line-height: 22px;
+    border-radius: 2px;
+}
+</style>
+
+<style lang="scss">
+.cdkey-create{
+    .personal-ceil{
+        width: 200px;
+        .el-input__inner{
+            width: 200px;
+            padding: 0 60px;
+        }
+    }
+    .el-range-input{
+        background: #F2F3F5;
+    }
+    .el-tag{
+        background: #fff;
+    }
+    .validity-box{
+        width: 350px;
+        .el-input-group{
+            width: 250px;
+        }
+        .el-input-group__append{
+            border: none;
+            border-left: 1px solid #E5E6EB;
+            background: #F2F3F5;
+        }
+    }   
+    .price-box{
+        width: 300px;
+        display: inline-block;
+        .el-form-item__content{
+            position: relative;
+            .prepend,.append{
+                position: absolute;
+                left: 44px;
+                font-size: 14px;
+                line-height: 22px;
+                color: #1D2129;
+                line-height: 34px;
+            }
+            .append{
+                left: 142px;
+            }
+        }
+    }
+}
+.el-date-picker__editor-wrap{
+    .el-input, .el-textarea{
+        width: auto;
+    }
+}
+</style>

+ 7 - 8
src/views/cdkey_manage/index.vue

@@ -9,7 +9,7 @@
                 <div class="common-title-box">
                     <h3>兑换码列表</h3>
                     <div class="btn-box">
-                        <el-button type="primary" size="small" @click="handleEdit()">创建用户</el-button>
+                        <el-button type="primary" size="small" @click="createCdkey">创建兑换码</el-button>
                     </div>
                 </div>
                 <div class="search-box">
@@ -69,7 +69,7 @@
                         prop="code"
                         label="兑换码"
                         sortable="custom"
-                        width="160">
+                        width="170">
                     </el-table-column>
                     <el-table-column
                         prop="type"
@@ -296,6 +296,10 @@ export default {
   watch: {},
   //方法集合
   methods: {
+    createCdkey(){
+        window.localStorage.removeItem('cdKeyId')
+        this.$router.push({path: '/createCdkey'})
+    },
     handleSort(value){
         let dataSort = {
             prop: value.prop,
@@ -387,17 +391,12 @@ export default {
         window.localStorage.setItem('pageNumber',this.pageNumber)
         if(row&&row.id){
             this.$router.push({
-                path: "/editPerson",
+                path: "/checkGoods",
                 query: {
                     id: row?row.id:''
                 },
             });
-        }else{
-            this.$router.push({
-                path: "/createPerson"
-            });
         }
-        
     },
     // 停用 启用
     handleUp(row, index) {