bzkf30 2 years ago
parent
commit
e37c66c850

+ 1 - 4
.eslintrc-auto-import.json

@@ -9,7 +9,6 @@
     "$toRef": true,
     "EffectScope": true,
     "REQUEST": true,
-    "client": true,
     "computed": true,
     "createApp": true,
     "customRef": true,
@@ -55,11 +54,11 @@
     "shallowReactive": true,
     "shallowReadonly": true,
     "shallowRef": true,
+    "store": true,
     "timestamp2string": true,
     "toRaw": true,
     "toRef": true,
     "toRefs": true,
-    "token": true,
     "triggerRef": true,
     "unref": true,
     "useAttrs": true,
@@ -68,8 +67,6 @@
     "useRoute": true,
     "useRouter": true,
     "useSlots": true,
-    "userId": true,
-    "userRoleId": true,
     "watch": true,
     "watchEffect": true,
     "watchPostEffect": true,

+ 32 - 0
src/pages/ysgc/api.js

@@ -22,4 +22,36 @@ export const ysgc_addEvaluate = (data = {}) =>
   request({
     url: '/ysgc/zp_evaluate/add',
     data: data
+  })
+
+//点赞
+export const jszp_like_add = (data = {}) =>
+  request({
+    url: '/ysgc/zp_like/add',
+    data: data
+  })
+
+export const jszp_like_del = (data = {}) =>
+  request({
+    url: '/ysgc/zp_like/delete',
+    data: data
+  })
+
+//收藏
+export const jszp_fav_add = (data = {}) =>
+  request({
+    url: '/ysgc/zp_fav/add',
+    data: data
+  })
+
+export const jszp_fav_del = (data = {}) =>
+  request({
+    url: '/ysgc/zp_fav/delete',
+    data: data
+  })
+
+export const user_detail = (data = {}) =>
+  request({
+    url: '/user/main/detail',
+    data: data
   })

+ 113 - 9
src/pages/ysgc/detail.vue

@@ -15,6 +15,10 @@
         </div>
       </div>
     </div>
+    <div class="flex items-center space-x-4 px-3 userDiv">
+      <van-image :src="getFullUrl(createUser.user_avatar)" />
+      {{createUser.user_realname}}
+    </div>
 
     <div class="swiperContent m-2">
       <van-swipe class="mb-5">
@@ -26,7 +30,7 @@
 
     <div class="commentDiv px-5">
       <div class="flex justify-between items-center my-5">
-        <van-rate class="my-2" v-model="star" color="#ffd21e" void-icon="star" void-color="#eee" size="16px" allow-half :readonly="disabled" />
+        <van-rate class="my-2" v-model="star" color="#ffd21e" void-icon="star" void-color="#eee" size="16px" :readonly="disabled" />
         <van-button round type="success" size="small" :disabled="disabled" @click="handleComment">评价</van-button>
       </div>
       <div>
@@ -45,7 +49,7 @@
 
 <script setup>
 import { getFullUrl } from '~/utils/helper';
-import { ysgc_detail, ysgc_evaluate_list, ysgc_addEvaluate } from "./api.js";
+import { ysgc_detail, ysgc_evaluate_list, ysgc_addEvaluate, jszp_like_add, jszp_like_del, jszp_fav_add, jszp_fav_del, user_detail } from "./api.js";
 import userInfo from '~/store/index';
 import { useRouter } from 'vue-router';
 const router = useRouter();
@@ -55,6 +59,7 @@ const imageData = ref([]);
 const star = ref(0);
 const evaluateData = ref([]);
 const disabled = ref(false);
+const createUser = ref({});
 
 const onClickLeft = () => history.back();
 
@@ -65,7 +70,12 @@ function initDetailData() {
     if (res.code == 1) {
       detailInfo.value = res.data.one_info;
       imageData.value = detailInfo.value.file_list;
-      console.log(detailInfo.value)
+
+      user_detail({ user_id: detailInfo.value.create_user_id }).then((res1) => {
+        if (res1.code == 1) {
+          createUser.value = res1.data.one_info;
+        }
+      })
     }
   })
 }
@@ -86,18 +96,101 @@ function initEvaluateData() {
 
 const handleComment = () => {
   let obj = {
-    yze_user_realname: user.user_realname,
-    yze_star: this.pjInfo.yze_star,
-    yz_id: id,
-    yze_id: this.pjInfo.yze_id,
+    ysgc_zp_evaluate: {
+      yze_user_realname: userInfo.user_realname,
+      yze_star: star.value,
+      yz_id: parentId.value,
+    }
   }
   ysgc_addEvaluate(obj).then((res) => {
     if (res.code == 1) {
-      evaluateData.value = res.data.page_data;
-      disabled.value = res.template.check_myexist == 1 ? true : false;
+      initEvaluateData();
+      star.value = "";
     }
   })
 }
+
+const handleFinger = () => {
+  if (detailInfo.value.is_like == 1) {//0:关 1:开
+    //去掉赞
+    let transObj = {
+      yz_id: parentId.value,
+    };
+    jszp_like_del(transObj)
+      .then((res) => {
+        if (res.code == "1") {
+          detailInfo.value.yz_like_num--;
+          detailInfo.value.is_like = 0;
+          showSuccessToast(res.msg);
+        } else {
+          showFailToast(res.msg);
+        }
+      })
+      .catch((error) => {
+        console.log(error);
+      });
+  } else {
+    let transObj = {
+      ysgc_zp_like: {
+        yz_id: parentId.value,
+      },
+    };
+    jszp_like_add(transObj)
+      .then((res) => {
+        if (res.code == "1") {
+          detailInfo.value.yz_like_num++;
+          detailInfo.value.is_like = 1;
+          showSuccessToast(res.msg);
+        } else {
+          showFailToast(res.msg);
+        }
+      })
+      .catch((error) => {
+        console.log(error);
+      });
+  }
+}
+
+const handleLoveIcon = () => {
+  if (detailInfo.value.is_fav == 1) {
+    //去掉收藏
+    let transObj = {
+      yz_id: parentId.value,
+    };
+    jszp_fav_del(transObj)
+      .then((res) => {
+        if (res.code == "1") {
+          detailInfo.value.yz_fav_num--;
+          detailInfo.value.is_fav = 0;
+          showSuccessToast(res.msg);
+        } else {
+          showFailToast(res.msg);
+        }
+      })
+      .catch((error) => {
+        console.log(error);
+      });
+  } else {
+    let transObj = {
+      ysgc_zp_fav: {
+        yz_id: parentId.value,
+      },
+    };
+    jszp_fav_add(transObj)
+      .then((res) => {
+        if (res.code == "1") {
+          detailInfo.value.yz_fav_num++;
+          detailInfo.value.is_fav = 1;
+          showSuccessToast(res.msg);
+        } else {
+          showFailToast(res.msg);
+        }
+      })
+      .catch((error) => {
+        console.log(error);
+      });
+  }
+}
 </script>
 
 <style lang="scss" scoped>
@@ -118,6 +211,17 @@ const handleComment = () => {
       height: 100%;
     }
   }
+  .userDiv {
+    font-size: 13px;
+    .van-image {
+      width: 26px;
+      height: 26px;
+      margin-right: 10px;
+      :deep(img) {
+        border-radius: 50%;
+      }
+    }
+  }
   .commentDiv {
     .van-button--round {
       width: 80px;

+ 4 - 0
src/pages/ysgc/index.vue

@@ -15,6 +15,8 @@
 
     <van-search v-model="keyword" shape="round" placeholder="搜索你要看的内容" @search="handleSearch" />
 
+    <!-- <jszp :Plist="listData"></jszp> -->
+
     <van-empty v-if="listData.length==0 && !loading" description="无数据" />
     <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
       <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="initData" class="grid grid-cols-2">
@@ -41,6 +43,7 @@
 </template>
 
 <script setup>
+import jszp from "./jszp.vue"
 import { getFullUrl } from '~/utils/helper';
 import { ysgc_list } from "./api.js";
 import { useRouter } from 'vue-router';
@@ -70,6 +73,7 @@ const handleSearch = () => {
 const total = ref(0);
 const limit = ref(12);
 const currentPage = ref(1);
+initData();
 function initData() {
   if (refreshing.value) {
     listData.value = [];

+ 335 - 0
src/pages/ysgc/jszp.vue

@@ -0,0 +1,335 @@
+<template>
+  <div class="flow">
+    <div class="flow_lie" v-for="v in imgList()" :key="v">
+      <div class="w_img" v-for="img in v.a" :key="img">
+        <!-- <router-link to="/ysgc_detail"> -->
+        <div class="fallimgItem img">
+          <img ref="allImage" :src="img.yz_img" alt="" @click="toJsDetail(img.yz_id)" />
+        </div>
+        <div class="des">
+          <p class="name">{{img.yz_name}}</p>
+          <div class="author">
+            <!-- <el-avatar style="width: 24px; height: 24px; border-radius: 50%; margin-right: 5px;" :size=" 16" :src="getAvatarUrl(img.user_id)" /> -->
+            <el-avatar :size="16" :src="getAvatarUrl(userMsg.user_id)" />
+            <!-- <img src="@/assets/img/zhjy/img_11.png" alt="" /> -->
+            <span class="author_name">{{img.yz_author_name}}</span>
+            <div class="rate">
+              <!-- <img v-for="star in Number(img.yz_star_num)" :key="star" src="../../assets/ysgc/star.png" alt="" /> -->
+            </div>
+          </div>
+
+        </div>
+        <!-- </router-link> -->
+        <div class="dataShow">
+
+          <div class="baseInfoPart">
+            <!-- <img src="/kczy/fingerIcon.png" alt=""> -->
+            <span>{{img.yz_like_num}}</span>
+          </div>
+          <div class="baseInfoPart">
+            <!-- <img src="/kczy/cellectIcon.png" alt=""> -->
+            <span>{{img.yz_fav_num}}</span>
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+  <script>
+import { getFullUrl, getAvatarUrl } from '@/utils/helper';
+export default {
+  props: ["Plist"],
+  watch: {
+    Plist: {
+      immediate: true,
+      handler(val) {
+        console.log(val)
+      }
+    }
+  },
+  data() {
+    return {
+      screenWidth: document.body.clientWidth,
+      col: 2,
+      list: [],
+      categoryId: "",
+      type: 1,
+      https: window.GLOBAL_CONFIG.api,
+      userMsg: {},
+    };
+  },
+  created() { },
+  mounted() {
+    this.getUser();
+    // 监听屏幕宽度变化
+    window.onresize = () =>
+      (() => {
+        this.screenWidth = document.body.clientWidth;
+      })();
+    //this.imgList()
+  },
+  watch: {
+    screenWidth(val) {
+      this.screenWidth = val;
+      if (this.screenWidth < 1480) {
+        this.col = 4;
+        console.log("小于1480,col=", this.col);
+      } else {
+        this.col = 5;
+        console.log("不小于1480,col=", this.col);
+      }
+    }
+  },
+  methods: {
+    // 获取用户信息
+    getUser() {
+      // var locData = window.localStorage.getItem("userInfo");
+      // var user_id = JSON.parse(locData).user_id; //老师的role_id
+      // let data = {
+      //   user_id: user_id,
+      // };
+      // user_info(data).then((res) => {
+      //   this.userMsg = res.data;
+      // });
+    },
+    //教师作品详情
+    toJsDetail(id) {
+      this.$router.push({ name: "ysgc_jsDetail", params: { id: id } });
+    },
+    // 瀑布流
+    imgList() {
+      if (this.Plist?.length !== 0) {
+        const res = [];
+        for (let i = 0; i < this.col; i++) {
+          res.push({
+            h: 0,
+            a: [],
+          });
+        }
+        this.Plist.forEach((img, index) => {
+          let i = index % this.col;
+          let obj = res[i];
+          let imgs;
+          if (!document.getElementById("imgsId")) {
+            imgs = document.createElement("img");
+            imgs.id = "imgsId";
+          } else {
+            imgs = document.getElementById("imgsId");
+          }
+          imgs.src = img.img;
+          img.h = imgs.height + Math.random();
+          img.w = imgs.width;
+          for (let i = 1; i < res.length; i++) {
+            if (res[i].h < obj.h) {
+              obj = res[i];
+            }
+          }
+          // 存储图片数据
+          obj.a.push(img);
+          // 计算图片缩放后的高度,并记录
+          const height = (img.h * 454) / img.w;
+          obj.h += height;
+        });
+        return res;
+      }
+    },
+  },
+};
+</script>
+  
+<style lang="scss" scoped>
+.dataShow {
+  position: absolute;
+  right: 0;
+  top: 0;
+  z-index: 13;
+  width: 164px;
+  height: 32px;
+  line-height: 32px;
+  background: rgba(0, 0, 0, 0.5);
+  border-bottom-left-radius: 12px;
+  border-top-right-radius: 12px;
+  display: flex;
+  padding-left: 5px;
+
+  .baseInfoPart {
+    width: 50%;
+    height: 32px;
+    line-height: 32px;
+    box-sizing: border-box;
+    margin-left: 4px;
+    img {
+      display: inline-block;
+      vertical-align: middle;
+      padding-bottom: 6px;
+    }
+    span {
+      font-size: 14px;
+      font-weight: 400;
+      text-align: left;
+      color: #ffffff;
+      margin-left: 5px;
+      vertical-align: top;
+    }
+  }
+}
+.flow {
+  width: 100%;
+
+  .flow_lie {
+    height: 1000px;
+    width: 50%;
+    padding: 0 10px;
+    // margin-right: 18px;
+
+    display: inline-block;
+    .w_img {
+      position: relative;
+
+      .des {
+        position: absolute;
+        bottom: 0;
+        left: 0;
+        width: 100%;
+        height: 80px;
+        padding: 8px;
+        box-sizing: border-box;
+        .name {
+          font-size: 16px;
+          color: #000;
+          line-height: 26px;
+          font-family: PingFangSC, PingFangSC-Regular;
+          word-wrap: break-word;
+          text-overflow: ellipsis;
+          display: -webkit-box;
+          -webkit-box-orient: vertical;
+          -webkit-line-clamp: 1;
+          overflow: hidden;
+        }
+        .author {
+          width: 100%;
+          margin-top: 8px;
+          display: flex;
+          position: relative;
+          //border: 1px solid red;
+          img {
+            width: 24px;
+            height: 24px;
+            border-radius: 50%;
+            margin-right: 5px;
+          }
+          .author_name {
+            font-size: 14px;
+            font-family: PingFangSC, PingFangSC-Medium;
+            color: #050026;
+          }
+          .rate {
+            // border: 1px solid red;
+            display: flex;
+            margin: 11px 0;
+            position: absolute;
+            right: 0px;
+            top: -7px;
+            img {
+              width: 15px;
+              height: 15px;
+              margin-right: 6px;
+            }
+          }
+        }
+      }
+    }
+  }
+}
+
+.fallimgItem {
+  width: 100%;
+  //position: relative;
+  margin: 20px 0;
+  // min-width: 315px;
+  padding-bottom: 80px;
+  border-radius: 12px;
+  box-shadow: 0px 10px 24px 0px rgba(161, 153, 168, 0.18);
+  img {
+    width: 100%;
+    height: 100%;
+    display: block;
+    border-radius: 12px;
+    cursor: pointer;
+  }
+  // .img_mask {
+  //   width: 100%;
+  //   height: 100%;
+  //   border-radius: 15px;
+  //   position: absolute;
+  //   left: 0;
+  //   top: 0;
+  //   background-color: rgba(0, 0, 0, 0.4);
+  //   padding: 20px 10px;
+  //   box-sizing: border-box;
+  //   opacity: 0;
+  //   transition: 0.5s linear;
+  //   .img_mask_top {
+  //     width: 100%;
+  //     height: 50px;
+  //     display: flex;
+  //     justify-content: flex-end;
+  //     .heart,
+  //     .car {
+  //       float: right;
+  //       width: 50px;
+  //       height: 50px;
+  //       background-color: rgba(0, 0, 0, 0.6);
+  //       border-radius: 5px;
+  //       line-height: 50px;
+  //       margin-right: 20px;
+  //       text-align: center;
+  //       i {
+  //         color: #fff;
+  //         font-size: 25px;
+  //       }
+  //     }
+  // }
+  // .author {
+  //   width: 93%;
+  //   color: hsla(0, 0%, 100%, 0.8);
+  //   display: flex;
+  //   justify-content: space-between;
+  //   position: absolute;
+  //   left: 10px;
+  //   bottom: 20px;
+  //   opacity: 1 important;
+  //   line-height: 36px;
+  //   font-size: 28px;
+  //   .left {
+  //     display: flex;
+  //     position: relative;
+  //     .img1 {
+  //       width: 36px;
+  //       height: 36px;
+  //       border-radius: 50%;
+  //       vertical-align: middle;
+  //     }
+  //     .user_name {
+  //       color: hsla(0, 0%, 100%, 0.8);
+  //       font-size: 16px;
+  //       font-weight: 100;
+  //       margin-left: 16px;
+  //       vertical-align: middle;
+  //     }
+  //   }
+  //   .left:hover .avatar_imgItem {
+  //     display: block !important;
+  //   }
+  //   .score {
+  //     font-weight: 100;
+  //   }
+  // }
+  // }
+}
+.fallimgItem:hover .img_mask {
+  // display: block;
+  opacity: 1;
+}
+</style>
+  

File diff suppressed because it is too large
+ 60 - 51
src/store/index.ts


+ 1 - 1
src/utils/request.ts

@@ -22,7 +22,7 @@ _request.interceptors.request.use(
       config.data = Object.assign(
         {
           token,
-          client: 'web',
+          client: 'h5',
           api: 'json',
           site: "tyyx",
           issubmit: (config.url?.endsWith('add') || config.url?.endsWith('edit')) ? '1' : undefined,

+ 1 - 0
vite.config.ts

@@ -10,6 +10,7 @@ import IconsResolver from 'unplugin-icons/resolver'
 
 // https://vitejs.dev/config/
 export default defineConfig({
+  base: '/new/',
   resolve: {
     alias: {
       '@': path.resolve(__dirname, 'src'),