| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 |
- <!-- -->
- <template>
- <div
- class="help_box"
- :style="'height:' + fullHeight + 'px'"
- v-loading="loading"
- element-loading-text="拼命加载中"
- >
- <!-- 头部信息 -->
- <div class="help_box-head">
- <img
- src="../../assets/image/new/30.png"
- @click="goBack()"
- alt=""
- class="help_box-head-img"
- />
- <div class="help_box-headBox">
- <img
- preview="1"
- v-lazy="'http://192.168.1.8:8002/' + img"
- alt=""
- class="help_box-headImg"
- />
- </div>
- </div>
- <!-- 主内容 -->
- <mescroll-vue
- ref="mescroll"
- class="home_box_mescroll"
- :down="mescrollDown"
- :up="mescrollUp"
- @init="mescrollInit"
- >
- <div class="help_box-main">
- <!-- 标题 -->
- <div class="navlist">
- <ul>
- <li
- class="navli"
- v-for="(item, index) in navList"
- :class="{ activeT: nowIndex === index }"
- @click="tabClick(index)"
- :key="index"
- >
- <div class="navliVal">{{ item.name }}</div>
- </li>
- </ul>
- </div>
- <!-- 相应内容 -->
- <div class="swiper-container swiper_con" style="background: #f7f8fc">
- <div class="swiper-wrapper">
- <!-- 交流 -->
- <div class="swiper-slide" ref="viewBox">
- <ul class="help_box-main-ulA" v-if="interflowShow">
- <li
- class="help_box-main-listA"
- v-for="(item, index) in this.interflowDat"
- :key="index"
- @click="
- interflowDetails(
- $event,
- item.id,
- item.visit_num,
- item.replys,
- item.like,
- item.like_num
- )
- "
- >
- <!-- 用户信息 -->
- <div class="help_box-main-listA-userBox">
- <img
- preview="1"
- v-lazy="'http://192.168.1.8:8002/' + item.photo"
- alt
- class="help_box-main-listA-userBox-img"
- />
- <div class="help_box-main-listA-userBox-txt">
- <div class="help_box-main-listA-userBox-name">
- {{
- item.user_remark == null
- ? item.username
- : item.user_remark
- }}
- <!-- <div class="help_box-main-listA-userBox-name-del">删除</div> -->
- <img
- src="../../assets/image/new/32.png"
- @click="delData(item.id)"
- alt=""
- class="help_box-main-listA-userBox-name-del"
- />
- </div>
- <div class="help_box-main-listA-userBox-time">
- {{ item.time }}
- </div>
- </div>
- </div>
- <!-- 交流内容-文字 -->
- <div class="help_box-main-listA-writing">
- {{ item.problem }}
- </div>
- <!-- 交流图片 -->
- <div class="help_box-main-listA-image">
- <ul class="help_box-main-listA-image-ul">
- <li
- class="help_box-main-listA-image-list"
- v-for="itemA in item.img"
- :key="itemA"
- @click="imgShow(itemA)"
- preview="1"
- >
- <img
- v-lazy="'http://192.168.1.8:8002/' + itemA"
- alt
- class="help_box-main-listA-imageList"
- />
- </li>
- </ul>
- </div>
- <!-- 交流数据的查看评论点赞 -->
- <div class="help_box-main-listA-operation">
- <ul class="help_box-main-listA-operation-ul">
- <li class="help_box-main-listA-operation-list">
- <img
- src="../../assets/image/new/8.png"
- alt
- class="help_box-main-listA-operation-listImg"
- />
- <div class="help_box-main-listA-operation-listNum">
- {{ item.visit_num }}
- </div>
- </li>
- <li class="help_box-main-listA-operation-list">
- <img
- src="../../assets/image/new/10.png"
- alt
- class="help_box-main-listA-operation-listImg"
- />
- <div class="help_box-main-listA-operation-listNum">
- {{ item.reply_num }}
- </div>
- </li>
- <li class="help_box-main-listA-operation-list">
- <!-- 未点赞 -->
- <img
- @click.stop="like(item.id, index)"
- v-if="item.exist === '0'"
- src="../../assets/image/new/3.png"
- alt
- class="help_box-main-listA-operation-listImg"
- />
- <!-- 点赞了 -->
- <img
- v-else
- @click.stop="noLike(item.id, index)"
- src="../../assets/image/new/23.png"
- alt
- class="help_box-main-listA-operation-listImg"
- />
- <div class="help_box-main-listA-operation-listNum">
- {{ item.like_num }}
- </div>
- </li>
- </ul>
- </div>
- </li>
- </ul>
- <!-- 暂空判断 -->
- <div class="collect_judge" id="empty" v-else>
- <img
- src="../../assets/image/wu.png"
- alt
- class="collect_judge_img"
- />
- <div class="collect_judge_text">抱歉,暂无鉴定</div>
- </div>
- </div>
- <!-- 鉴定 -->
- <div class="swiper-slide">
- <ul class="help_box-main-authenticateUl" v-if="interflowShow">
- <li
- class="help_box-main-authenticateList"
- v-for="(itemA, index) in interflowDat"
- :key="index"
- @click="authenticateDetails($event, itemA.id)"
- >
- <!-- 删除 -->
- <img
- src="../../assets/image/new/33.png"
- @click="delData(itemA.id)"
- alt=""
- class="help_box-main-authenticateList-imgDel"
- />
- <div class="help_box-main-authenticateList-box1">
- <img
- preview="1"
- v-lazy="'http://192.168.1.8:8002/' + itemA.img[0]"
- alt
- class="help_box-main-authenticateList-box1-img"
- />
- <div class="help_box-main-authenticateList-box1-txt">
- {{ itemA.problem }}
- </div>
- </div>
- <div class="help_box-main-authenticateList-box2">
- <div class="help_box-main-authenticateList-box3">
- <img
- preview="1"
- v-lazy="'http://192.168.1.8:8002/' + itemA.photo"
- alt
- class="help_box-main-authenticateList-box3-img"
- />
- <div class="help_box-main-authenticateList-box3-name">
- {{
- itemA.user_remark == "" || itemA.user_remark == null
- ? itemA.username
- : itemA.user_remark
- }}
- </div>
- </div>
- <img
- src="../../assets/image/new/10.png"
- alt
- class="help_box-main-authenticateList-box4-img"
- />
- </div>
- </li>
- </ul>
- <!-- 暂空判断 -->
- <div class="collect_judge" id="empty" v-else>
- <img
- src="../../assets/image/wu.png"
- alt
- class="collect_judge_img"
- />
- <div class="collect_judge_text">抱歉,暂无鉴定</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </mescroll-vue>
- </div>
- </template>
- <script>
- // 引入mescroll的vue组件
- import MescrollVue from "mescroll.js/mescroll.vue";
- import Swiper from "swiper";
- import "../../../swiper/css/swiper.min.css";
- export default {
- name: "help",
- //import引入的组件需要注入到对象中才能使用
- components: {
- MescrollVue,
- Swiper,
- },
- data() {
- //这里存放数据
- return {
- fullHeight: document.documentElement.clientHeight,
- navList: [{ name: "交流" }, { name: "鉴定" }],
- nowIndex: 0,
- mySwiper: "",
- // 交流
- interflowDat: [], //交流列表数据
- isClick: true, //点赞开关
- amplificationShow: false, //查看大图
- imgList: "",
- img: "", //用户头像
- interflowShow: true, //暂无数据
- // 上拉加载下拉刷新
- mescroll: null, // mescroll实例对象
- mescrollDown: {}, //下拉刷新的配置. (如果下拉刷新和上拉加载处理的逻辑是一样的,则mescrollDown可不用写了)
- mescrollUp: {
- // 上拉加载的配置.
- callback: this.upCallback, // 上拉回调,此处简写; 相当于 callback: function(page, mescroll) { }
- //以下是一些常用的配置,当然不写也可以的.
- page: {
- num: 0, //当前页 默认0,回调之前会加1; 即callback(page)会从1开始
- size: 6, //每页数据条数,默认10
- },
- isBounce: true, //根据记录的滚动条高度回弹
- htmlNodata: '<p class="upwarp-nodata">-- 已经到底了! --</p>',
- noMoreSize: 6, //如果列表已无数据,可设置列表的总数量要大于5才显示无更多数据;
- // 避免列表数据过少(比如只有一条数据),显示无更多数据会不好看
- // 这就是为什么无更多数据有时候不显示的原因
- toTop: {
- //回到顶部按钮
- src:
- "http://pic.51yuansu.com/pic3/cover/00/65/23/5896fa4bc81fc_610.jpg", //图片路径,默认null,支持网络图
- offset: 500, //列表滚动1000px才显示回到顶部按钮
- },
- onScroll: function (mescroll, y, isUp) {
- //吸顶
- // if (y > 500) {
- // self.navBarFixed = true;
- // } else {
- // self.navBarFixed = false;
- // }
- },
- lazyLoad: {
- use: true, // 是否开启懒加载,默认false
- },
- },
- aggregate: "", //后端传来数据的总条数
- loading: true,
- // 上拉加载下拉刷新
- };
- },
- beforeRouteEnter(to, from, next) {
- if (from.name === "field_details") {
- to.meta.isBack = true;
- }
- // 如果没有配置顶部按钮或isBounce,则beforeRouteEnter不用写
- next((vm) => {
- if (from.name === "field_details") {
- // 滚动到原来的列表位置,恢复顶部按钮和isBounce的配置
- vm.$refs.mescroll && vm.$refs.mescroll.beforeRouteEnter();
- }
- });
- },
- beforeRouteLeave(to, from, next) {
- if (to.name !== "field_details") {
- to.meta.isBack = false;
- } else {
- to.meta.isBack = true;
- // 如果没有配置顶部按钮或isBounce,则beforeRouteLeave不用写
- // 记录列表滚动的位置,隐藏顶部按钮和isBounce的配置
- this.$refs.mescroll && this.$refs.mescroll.beforeRouteLeave();
- }
- next();
- },
- activated() {
- if (!this.$route.meta.isBack) {
- // 如果isBack是false,表明需要获取新数据,否则就不再请求,直接使用缓存的数据
- this.mescroll.resetUpScroll(); // 刷新列表数据
- }
- // 恢复成默认的false,避免isBack一直是true,导致下次无法获取数据
- this.$route.meta.isBack = false;
- },
- //监听属性 类似于data概念
- computed: {},
- //监控data中的数据变化
- watch: {
- fullHeight(val) {
- //监控浏览器高度变化
- if (!this.timer) {
- this.fullHeight = val;
- this.timer = true;
- let that = this;
- setTimeout(function () {
- //防止过度调用监测事件,导致卡顿
- that.timer = false;
- }, 400);
- }
- },
- //交流鉴定切换
- nowIndex(val) {
- if (val == 0) {
- this.interflowData();
- } else if (val == 1) {
- this.interflowData();
- }
- },
- },
- //方法集合
- methods: {
- //动态获取浏览器高度
- get_boderHeight() {
- const that = this;
- window.onresize = () => {
- return (() => {
- window.fullHeight = document.documentElement.clientHeight;
- that.fullHeight = window.fullHeight;
- })();
- };
- },
- // mescroll组件初始化的回调,可获取到mescroll对象
- mescrollInit(mescroll) {
- this.mescroll = mescroll; // 如果this.mescroll对象没有使用到,则mescrollInit可以不用配置
- },
- upCallback(page, mescroll) {
- var that = this;
- // diverse 0 鉴定 1、交流
- if (that.nowIndex == 0) {
- var diverse = "1";
- } else if (that.nowIndex == 1) {
- var diverse = "0";
- }
- that
- .$axios({
- method: "get",
- url: "http://192.168.1.8:8002/user_answer",
- params: {
- page: that.mescrollUp.page.num,
- ret: "user",
- diverse: diverse,
- },
- })
- .then((res) => {
- var nums = res.data.num;
- if (this.aggregate === "") {
- //存变量
- this.aggregate = nums;
- var b = "6";
- this.aggregate = this.aggregate / b;
- this.aggregate = Math.ceil(this.aggregate); //将小数点转换为整数
- console.log(this.aggregate);
- }
- if (res.data.num !== 0) {
- var data = res.data.dat;
- for (var i = 0; i < data.length; i++) {
- if (data[i].username !== "admin") {
- // 1字符串转化成数组
- let phoneArr = [...data[i].username];
- var n = "";
- // 2.将数组中的4-7位变成*
- phoneArr.map((res, index) => {
- if (index > 2 && index < 7) {
- n += "*";
- // return '*';
- } else {
- n += res;
- }
- });
- data[i]["username"] = n;
- } else {
- data[i]["username"] = data[i].username;
- }
- }
- // 如果是第一页需手动置空列表
- if (page.num === 1) this.interflowDat = [];
- // 把请求到的数据添加到列表
- this.interflowDat = this.interflowDat.concat(data);
- // // 数据渲染成功后,隐藏下拉刷新的状态
- // this.$nextTick(() => {
- // mescroll.endSuccess(data.length);
- // });
- that.interflowShow = true;
- } else if (res.data.num == 0) {
- this.gerenShow = false;
- var data = res.data.dat;
- that.interflowDat = data;
- that.interflowShow = false;
- }
- // 数据渲染成功后,隐藏下拉刷新的状态
- this.$nextTick(() => {
- mescroll.endSuccess(res.data.dat.length);
- });
- that.loading = false;
- })
- .catch((err) => {
- mescroll.endErr();
- console.log(err);
- });
- },
- // 返回
- goBack() {
- var that = this;
- that.$router.replace("/person");
- },
- // tab切换交流、鉴定
- initSwiper() {
- var that = this;
- that.mySwiper = new Swiper(".swiper-container", {
- initialSlide: 0,
- autoplay: false,
- keyboardControl: true,
- autoHeight: true,
- observer: true, //修改swiper自己或子元素时,自动初始化swiper
- observeParents: true,
- autoplayDisableOnInteraction: false, //解决拖动之后不能自动轮播
- preventLinksPropagation: false, // 阻止点击事件冒泡
- onSlideChangeStart: function (swiper) {
- //这个是当swiper被改变是的回调函数,可以拿到当前索引
- console.log(swiper.activeIndex);
- // alert(swiper.activeIndex);
- that.nowIndex = swiper.activeIndex;
- },
- onSlideChangeTransitionStart: function (swiper, event) {},
- });
- },
- tabClick(index) {
- this.nowIndex = index;
- if (!this.mySwiper.slideTo) {
- this.initSwiper();
- }
- this.mySwiper.slideTo(index, 300, false);
- },
- // 交流、鉴定列表数据接口
- interflowData() {
- var that = this;
- // diverse 0 鉴定 1、交流
- if (that.nowIndex == 0) {
- var diverse = "1";
- } else if (that.nowIndex == 1) {
- var diverse = "0";
- }
- that
- .$axios({
- method: "get",
- url: "http://192.168.1.8:8002/user_answer",
- params: {
- page: 1,
- ret: "user",
- diverse: diverse,
- },
- })
- .then((res) => {
- if (res.data.num !== 0) {
- var data = res.data.dat;
- that.interflowDat = [];
- for (var i = 0; i < data.length; i++) {
- if (data[i].username !== "admin") {
- // 1字符串转化成数组
- let phoneArr = [...data[i].username];
- var n = "";
- // 2.将数组中的4-7位变成*
- phoneArr.map((res, index) => {
- if (index > 2 && index < 7) {
- n += "*";
- // return '*';
- } else {
- n += res;
- }
- });
- data[i]["username"] = n;
- } else {
- data[i]["username"] = data[i].username;
- }
- }
- that.interflowDat = data;
- that.interflowShow = true;
- } else if (res.data.num == 0) {
- this.gerenShow = false;
- var data = res.data.dat;
- that.interflowDat = data;
- that.interflowShow = false;
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- // 点击进入交流详情
- interflowDetails(e, id, visit_num, replys, like, like_num) {
- var that = this;
- if (e.target.className !== "help_box-main-listA-userBox-name-del") {
- this.$router.push({
- name: "field_details",
- query: {
- id: id, //id
- visit_num: visit_num, //查看
- replys: replys, //评论
- like: like, //点赞状态
- like_num: like_num, //点赞次数
- ret: "help", //判断是从我的主页进入还是在交流进入
- },
- });
- }
- },
- // 点击进入鉴定详情
- authenticateDetails(e, id) {
- var that = this;
- if (e.target.className !== "help_box-main-authenticateList-imgDel") {
- that.$router.push({
- name: "addData_details",
- query: {
- id: id, //id
- ret: "help",
- // visit_num: visit_num, //查看
- // replys: replys, //评论
- // like: like, //点赞状态
- // like_num: like_num, //点赞次数
- },
- });
- }
- },
- // 交流点赞
- like(id, index) {
- var that = this;
- var isClick = that.isClick;
- var postData = that.$qs.parse({
- id: id, //id
- ret: "add", //点赞
- req: "title", //主问题
- });
- if (isClick === true) {
- that.isClick = false;
- that
- .$axios({
- method: "post",
- url: "http://192.168.1.8:8002/farm_likes",
- data: postData,
- })
- .then((res) => {
- if (res.data === 0) {
- this.$message({
- type: "success",
- message: "点赞成功!",
- duration: 1500,
- });
- that.interflowDat[index].like = "1"; //改变点赞状态
- that.interflowDat[index].like_num =
- that.interflowDat[index].like_num + 1; //改变点赞数据
- } else if (res.data === 1) {
- this.$notify.error({
- title: "错误",
- message: "点赞出错了!!",
- duration: 1500,
- });
- }
- })
- .catch((err) => {
- console.log(err);
- });
- setTimeout(function () {
- that.isClick = true;
- }, 1500);
- }
- },
- // 交流取消点赞
- noLike(id, index) {
- var that = this;
- var isClick = that.isClick;
- var postData = that.$qs.parse({
- id: id, //id
- ret: "off", //点赞
- req: "title", //主问题
- });
- if (isClick === true) {
- that.isClick = false;
- that
- .$axios({
- method: "post",
- url: "http://192.168.1.8:8002/farm_likes",
- data: postData,
- })
- .then((res) => {
- if (res.data === 0) {
- that.$message({
- type: "success",
- message: "取消点赞成功!",
- duration: 1500,
- });
- that.interflowDat[index].like = "0"; //改变点赞状态
- that.interflowDat[index].like_num =
- that.interflowDat[index].like_num - 1; //改变点赞数量
- } else if (res.data === 1) {
- that.$notify.error({
- title: "错误",
- message: "取消点赞出错了!!",
- duration: 1500,
- });
- }
- })
- .catch((err) => {
- console.log(err);
- });
- setTimeout(function () {
- that.isClick = true;
- }, 1500);
- }
- },
- //点击轮播图片进行放大
- imgShow(img) {
- this.amplificationShow = true;
- this.imgList = img;
- console.log(img);
- console.log(111);
- console.log(this.imgList);
- },
- // 点击删除数据
- delData(id) {
- var that = this;
- this.$confirm("确定删除当前数据?")
- .then((_) => {
- that
- .$axios({
- method: "get",
- url: "http://192.168.1.8:8002/user_reply",
- params: {
- id: id,
- ret: "anwers",
- },
- })
- .then((res) => {
- if (res.data.code == "200") {
- this.$message({
- type: "success",
- message: "删除成功!",
- duration: 1500,
- });
- that.interflowData();
- } else {
- this.$notify.error({
- title: "错误",
- message: "删除出错了!!",
- duration: 1500,
- });
- }
- })
- .catch((err) => {
- consoel.log(err);
- });
- })
- .catch((_) => {});
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- this.img = this.$route.query.img;
- this.get_boderHeight();
- // this.initSwiper(); //tab切换交流、鉴定、方案
- // this.interflowData(); //交流、鉴定列表接口
- },
- };
- </script>
- <style lang='scss'>
- @import "../../assets/scss/help.scss";
- //@import url(); 引入公共css类
- .el-message-box {
- width: 340px;
- }
- </style>
|