杨磊
25 分钟以前 81a132f7b5d022e8d55dc1fefe2a7357f5bcbafa
src/views/personalCenter/activeCode.vue
@@ -7,7 +7,7 @@
        <el-input class="inputBox" v-model="activateCode" placeholder="请输入激活码">
          <template #append>
            <el-button
              style="background-color: #019e58; color: #fff"
              style="background-color: #144941; color: #fff"
              @click="userActiveCodeGet"
              :loading="loading"
              >激活</el-button
@@ -29,7 +29,7 @@
                    >使用激活码:<span>{{ item.code }}</span></span
                  >
                  <span class="createDate flex1"
                    >激活日期:{{ item.createDate ? item.createDate : "-" }}</span
                    >激活日期:{{ item.createDate ? item.createDate : '-' }}</span
                  >
                </div>
                <div class="listItemBox flex">
@@ -38,24 +38,17 @@
                      v-for="pItem in item.typeList"
                      :key="pItem.id"
                      class="listItem"
                      @click="
                        goBookDetails(pItem.id, pItem.name, pItem.defaultSaleMethodId)
                      "
                      @click="goBookDetails(pItem.id, pItem.name, pItem.defaultSaleMethodId)"
                    >
                      <div class="cover">
                        <img
                          :src="
                            pItem.icon ? getPublicImage(pItem.icon, '', '') : bookCover
                          "
                          alt=""
                        />
                        <!-- <div class="type" v-if="pItem.type">{{ pItem.type }}</div> -->
                        <img :src="pItem.icon ? pItem.icon : bookCover" alt="" />
                      </div>
                      <div class="info">
                        <div style="margin-bottom: 10px" v-if="pItem.type">
                        <div class="bookType" style="margin-bottom: 10px" v-if="pItem.type">
                          {{ pItem.type }}
                        </div>
                        <span :title="pItem.name">{{ pItem.name }}</span>
                        <span class="title" :title="pItem.name">{{ pItem.name }}</span>
                        <span class="author" v-if="pItem.author">{{ pItem.author }}</span>
                      </div>
                    </div>
                  </div>
@@ -86,113 +79,104 @@
</template>
<script setup lang="ts">
import { reactive, ref, onMounted, inject, watch } from "vue";
import moment from "moment";
import { getPublicImage } from "@/assets/js/middleGround/tool.js";
import { ElMessage } from "element-plus";
import { useBreadcrumbStore, useUserStore } from "@/store";
import { useRouter } from "vue-router";
import bookCover from "@/assets/images/personalCenter/book-cover.png";
const router = useRouter();
const crumbStore = useBreadcrumbStore();
const userStore = useUserStore();
const MG = inject("MG");
const activateCode = ref("");
const loading = ref(false);
let dataList = ref([]);
import { reactive, ref, onMounted, inject, watch } from 'vue'
import moment from 'moment'
import { getPublicImage } from '@/assets/js/middleGround/tool.js'
import { ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'
import bookCover from '@/assets/images/personalCenter/book-cover.png'
const router = useRouter()
const MG: any = inject('MG')
const activateCode = ref('')
const loading = ref(false)
let dataList = ref([])
let pages = reactive({
  page: 1,
  pageSize: 5,
  count: 0,
  loading: false,
});
})
// 使用激活码
const userActiveCodeGet = () => {
  loading.value = true;
  let lock = true;
  if (activateCode.value == "") {
  loading.value = true
  let lock = true
  if (activateCode.value == '') {
    ElMessage({
      type: "error",
      message: "请输入激活码!",
    });
    loading.value = false;
      type: 'error',
      message: '请输入激活码!',
    })
    loading.value = false
  } else {
    if (lock) {
      lock = false;
      lock = false
      MG.store
        .userActiveCode({
          code: activateCode.value,
        })
        .then((res) => {
          ElMessage({
            type: res == "激活成功" ? "success" : "error",
            type: res == '激活成功' ? 'success' : 'error',
            message: res,
          });
          activateCode.value = "";
          loading.value = false;
          getDataList();
          lock = true;
        });
          })
          activateCode.value = ''
          loading.value = false
          getDataList()
          lock = true
        })
    }
  }
};
}
function getDataList() {
  pages.loading = true;
  pages.loading = true
  MG.store
    .userActiveCodeList({
      start: (pages.page - 1) * pages.pageSize,
      size: pages.pageSize,
      sort: {
        type: "Desc",
        field: "CreateDate",
        type: 'Desc',
        field: 'CreateDate',
      },
      fields: {
        author: [],
      },
    })
    .then((res) => {
      let list: any[] = [];
      let list: any[] = []
      res.datas.forEach((item) => {
        item.createDate = moment(item.createDate).format("YYYY-MM-DD HH:mm:ss");
        item.typeList = [];
        item.saleMethodList.forEach(async (i) => {
        item.createDate = moment(item.createDate).format('YYYY-MM-DD HH:mm:ss')
        item.typeList = []
        item.saleMethodList.forEach(async (i, index) => {
          const author = item.productList[index]?.dataList?.find((citem) => {
            return citem.data.sequenceNum == '007EB8E7' && citem.data.value
          })?.data?.value
          const obj = {
            icon: item.productList[0]?.icon,
            id: item.productList[0]?.id,
            name: item.productList[0]?.name,
            type:
              i.type == "defaultSaleMethod"
                ? "电子书"
                : i.name.includes("-")
                ? i.name.split("-")[0]
                : i.name,
            defaultSaleMethodId: item.productList[0]?.defaultSaleMethodId,
          };
          let parentData = await MG.store.getProductBySaleMethod({ saleMethodId: i.id });
          if (parentData.storeLinks[0].storeRefCode == "jsek_digitalCourses") {
            obj.type = "数字课程";
            icon: getPublicImage(item.productList[index]?.icon, '', '150'),
            id: item.productList[index]?.id,
            name: item.productList[index]?.name,
            author,
            type: '数字教材',
            defaultSaleMethodId: item.productList[index]?.defaultSaleMethodId,
          }
          if (parentData.storeLinks[0].storeRefCode == "jsek_digitalTextbooks") {
            obj.type = "数字教材";
          }
          item.typeList.push(obj);
        });
        list.push(item);
      });
          item.typeList.push(obj)
        })
        list.push(item)
      })
      setTimeout(() => {
        dataList.value = list;
        pages.count = res.totalSize;
        pages.loading = false;
      }, 500);
        dataList.value = list
        pages.count = res.totalSize
        pages.loading = false
      }, 500)
    })
    .catch(() => {
      pages.loading = false;
    });
      pages.loading = false
    })
}
onMounted(() => {
  getDataList();
});
  getDataList()
})
// watch(
//   () => userStore.token,
@@ -202,92 +186,18 @@
// )
const handleCurrentChange = (val: number) => {
  pages.page = val;
  getDataList();
};
  pages.page = val
  getDataList()
}
// 跳转书本详情
const goBookDetails = async (id: number, name: string, defaultSaleMethodId: number) => {
  let parentData = await MG.store.getProductBySaleMethod({
    saleMethodId: defaultSaleMethodId,
  });
  console.log(parentData, 123);
  if (parentData.storeLinks[0].storeRefCode == "jsek_digitalCourses") {
    let crumbs = [
      {
        name,
        isCrumbs: true,
        type: "digitalCourses",
        path: "digitalCoursesDetails",
      },
    ];
    // 在全局数据中设置面包屑
    crumbStore.setCrumbs({
      type: "digitalCourses",
      data: crumbs,
      callback: (key: any) => {
        router.push({
          name: "digitalCoursesDetails",
          query: {
            crumbsKey: key,
            bookId: parentData.id,
            bookName: parentData.name,
            type: "digitalCourses",
          },
        });
      },
    });
  } else if (parentData.storeLinks[0].storeRefCode == "jsek_digitalTextbooks") {
    let crumbs = [
      {
        name,
        isCrumbs: true,
        type: "digitalTextbooks",
        path: "digitalTextbooksDetails",
      },
    ];
    // 在全局数据中设置面包屑
    crumbStore.setCrumbs({
      type: "digitalTextbooks",
      data: crumbs,
      callback: (key: any) => {
        router.push({
          name: "digitalTextbooksDetails",
          query: {
            crumbsKey: key,
            bookId: parentData.id,
            bookName: parentData.name,
            type: "digitalTextbooks",
          },
        });
      },
    });
  } else {
    let crumbs = [
      {
        name,
        isCrumbs: true,
        type: "bookService",
        path: "/bookService/details",
      },
    ];
    // 在全局数据中设置面包屑
    crumbStore.setCrumbs({
      type: "bookService",
      data: crumbs,
      callback: (key: any) => {
        router.push({
          name: "bookDetails",
          query: {
            crumbsKey: key,
            bookId: id,
            bookName: name,
            type: "bookService",
          },
        });
      },
    });
  }
};
  router.push({
    path: '/bookdetail',
    query: {
      bookId: id,
    },
  })
}
</script>
<style lang="less" scoped>
::v-deep(.activation) {
@@ -303,7 +213,9 @@
}
.tipTitle {
  font-family: Microsoft YaHei UI, Microsoft YaHei UI;
  font-family:
    Microsoft YaHei UI,
    Microsoft YaHei UI;
  font-weight: 400;
  font-size: 16px;
  color: #000000;
@@ -314,11 +226,14 @@
}
.stateBox {
  height: 47px;
  line-height: 47px;
  height: 40px;
  line-height: 40px;
  padding: 0 20px;
  border: 1px solid #edecec;
  background: #f3f3f3;
  background: #edf4f2;
  .flex1 span {
    color: #000;
  }
}
.listItemBox {
@@ -326,18 +241,28 @@
}
.listItem {
  width: 130px;
  cursor: pointer;
  box-sizing: border-box;
  float: left;
  position: relative;
  margin-right: 5%;
  margin-right: 3%;
  width: 185px;
  min-height: 258px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 8px 8px 8px 8px;
  border: 1px solid #dedede;
  padding: 20px 10px;
  box-sizing: border-box;
  margin-bottom: 20px;
  .cover {
    width: 100%;
    height: 180px;
    box-shadow: 0px 0px 20px 1px #ccc;
    width: 116px;
    height: 150px;
    border-radius: 0px 0px 0px 0px;
    border: 1px solid #019e58;
    position: relative;
    margin: auto;
    margin-bottom: 5px;
    img {
      width: 100%;
@@ -360,20 +285,45 @@
  }
  .info {
    height: 90px;
    padding: 15px 0;
    width: 100%;
    .bookType {
      position: absolute;
      top: 0;
      right: 0;
      width: 60px;
      height: 26px;
      text-align: center;
      font-size: 12px;
      line-height: 24px;
      font-weight: 400;
      color: #fff;
      border-radius: 0px 0px 0px 5px;
      background: linear-gradient(130deg, #019e58 0%, #144941 100%);
      border-radius: 0px 8px 0px 8px;
    }
    span {
      font-weight: bold;
      height: 45px;
      line-height: 22px;
      line-height: 25px;
      display: -webkit-box;
      margin-bottom: 5px;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      text-overflow: ellipsis;
      padding: 5px 0;
      box-sizing: border-box;
      text-align: center;
      font-family:
        Microsoft YaHei UI,
        Microsoft YaHei UI;
      font-size: 16px;
    }
    .title {
      font-weight: bold;
      color: #000000;
    }
    .author {
      font-weight: 400;
      color: #333333;
    }
  }
}