help.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <!-- -->
  2. <template>
  3. <div class="help_box" :style="'height:' + fullHeight + 'px'">
  4. <!-- 头部信息 -->
  5. <div class="help_box-head">
  6. <div class="help_box-headBox">
  7. <img
  8. src="../../assets/image/user.jpg"
  9. alt=""
  10. class="help_box-headImg"
  11. />
  12. </div>
  13. </div>
  14. <!-- 主内容 -->
  15. <div class="help_box-main">
  16. <!-- 标题 -->
  17. <div class="navlist">
  18. <ul>
  19. <li
  20. class="navli"
  21. v-for="(item, index) in navList"
  22. :class="{ activeT: nowIndex === index }"
  23. @click="tabClick(index)"
  24. :key="index"
  25. >
  26. <div class="navliVal">{{ item.name }}</div>
  27. </li>
  28. </ul>
  29. </div>
  30. <!-- 相应内容 -->
  31. <div
  32. class="swiper-container swiper_con"
  33. style="background: #f7f8fc; margin-bottom: 1rem"
  34. >
  35. <div class="swiper-wrapper">
  36. <!-- 交流 -->
  37. <div class="swiper-slide" ref="viewBox">
  38. <ul class="help_box-main-ulA">
  39. <li
  40. class="help_box-main-listA"
  41. v-for="(item, index) in this.interflowDat"
  42. :key="index"
  43. >
  44. <!-- 用户信息 -->
  45. <div class="help_box-main-listA-userBox">
  46. <img
  47. preview="1"
  48. v-lazy="'/bigservers' + item.photo"
  49. alt
  50. class="help_box-main-listA-userBox-img"
  51. />
  52. <div class="help_box-main-listA-userBox-txt">
  53. <div class="help_box-main-listA-userBox-name">
  54. {{ item.user_remark }}
  55. </div>
  56. <div class="help_box-main-listA-userBox-time">
  57. {{ item.time }}
  58. </div>
  59. </div>
  60. </div>
  61. <!-- 交流内容-文字 -->
  62. <div class="help_box-main-listA-writing">
  63. {{ item.problem }}
  64. </div>
  65. <!-- 交流图片 -->
  66. <div class="help_box-main-listA-image">
  67. <ul class="help_box-main-listA-image-ul">
  68. <li
  69. class="help_box-main-listA-image-list"
  70. v-for="itemA in item.img"
  71. :key="itemA"
  72. @click="imgShow(itemA)"
  73. preview="1"
  74. >
  75. <img
  76. v-lazy="'/bigservers' + itemA"
  77. alt
  78. class="help_box-main-listA-imageList"
  79. />
  80. </li>
  81. </ul>
  82. </div>
  83. <!-- 交流数据的查看评论点赞 -->
  84. <div class="help_box-main-listA-operation">
  85. <ul class="help_box-main-listA-operation-ul">
  86. <li class="help_box-main-listA-operation-list">
  87. <img
  88. src="../../assets/image/new/8.png"
  89. alt
  90. class="help_box-main-listA-operation-listImg"
  91. />
  92. <div class="help_box-main-listA-operation-listNum">
  93. {{ item.visit_num }}
  94. </div>
  95. </li>
  96. <li class="help_box-main-listA-operation-list">
  97. <img
  98. src="../../assets/image/new/10.png"
  99. alt
  100. class="help_box-main-listA-operation-listImg"
  101. />
  102. <div class="help_box-main-listA-operation-listNum">
  103. {{ item.replys }}
  104. </div>
  105. </li>
  106. <li class="help_box-main-listA-operation-list">
  107. <!-- 未点赞 -->
  108. <img
  109. @click.stop="like(item.id, index)"
  110. v-if="item.like === '0'"
  111. src="../../assets/image/new/3.png"
  112. alt
  113. class="help_box-main-listA-operation-listImg"
  114. />
  115. <!-- 点赞了 -->
  116. <img
  117. v-else
  118. @click.stop="noLike(item.id, index)"
  119. src="../../assets/image/new/23.png"
  120. alt
  121. class="help_box-main-listA-operation-listImg"
  122. />
  123. <div class="help_box-main-listA-operation-listNum">
  124. {{ item.like_num }}
  125. </div>
  126. </li>
  127. </ul>
  128. </div>
  129. </li>
  130. </ul>
  131. </div>
  132. <!-- 鉴定 -->
  133. <div class="swiper-slide">
  134. <ul class="help_box-main-authenticateUl">
  135. <li class="help_box-main-authenticateList">
  136. <div class="help_box-main-authenticateList-box1">
  137. <img
  138. src="../../assets/image/timg4.jpg"
  139. alt
  140. class="help_box-main-authenticateList-box1-img"
  141. />
  142. <div class="help_box-main-authenticateList-box1-txt">
  143. 这是什么虫子?以前好像见过
  144. </div>
  145. </div>
  146. <div class="help_box-main-authenticateList-box2">
  147. <div class="help_box-main-authenticateList-box3">
  148. <img
  149. src="../../assets/image/user.jpg"
  150. alt
  151. class="help_box-main-authenticateList-box3-img"
  152. />
  153. <div class="help_box-main-authenticateList-box3-name">
  154. 用户123456
  155. </div>
  156. </div>
  157. <img
  158. src="../../assets/image/new/10.png"
  159. alt
  160. class="help_box-main-authenticateList-box4-img"
  161. />
  162. </div>
  163. </li>
  164. <li class="help_box-main-authenticateList">
  165. <div class="help_box-main-authenticateList-box1">
  166. <img
  167. src="../../assets/image/timg4.jpg"
  168. alt
  169. class="help_box-main-authenticateList-box1-img"
  170. />
  171. <div class="help_box-main-authenticateList-box1-txt">
  172. 这是什么虫子?以前好像见过
  173. </div>
  174. </div>
  175. <div class="help_box-main-authenticateList-box2">
  176. <div class="help_box-main-authenticateList-box3">
  177. <img
  178. src="../../assets/image/user.jpg"
  179. alt
  180. class="help_box-main-authenticateList-box3-img"
  181. />
  182. <div class="help_box-main-authenticateList-box3-name">
  183. 用户123456
  184. </div>
  185. </div>
  186. <img
  187. src="../../assets/image/new/10.png"
  188. alt
  189. class="help_box-main-authenticateList-box4-img"
  190. />
  191. </div>
  192. </li>
  193. <li class="help_box-main-authenticateList">
  194. <div class="help_box-main-authenticateList-box1">
  195. <img
  196. src="../../assets/image/timg4.jpg"
  197. alt
  198. class="help_box-main-authenticateList-box1-img"
  199. />
  200. <div class="help_box-main-authenticateList-box1-txt">
  201. 这是什么虫子?以前好像见过
  202. </div>
  203. </div>
  204. <div class="help_box-main-authenticateList-box2">
  205. <div class="help_box-main-authenticateList-box3">
  206. <img
  207. src="../../assets/image/user.jpg"
  208. alt
  209. class="help_box-main-authenticateList-box3-img"
  210. />
  211. <div class="help_box-main-authenticateList-box3-name">
  212. 用户123456
  213. </div>
  214. </div>
  215. <img
  216. src="../../assets/image/new/10.png"
  217. alt
  218. class="help_box-main-authenticateList-box4-img"
  219. />
  220. </div>
  221. </li>
  222. <li class="help_box-main-authenticateList">
  223. <div class="help_box-main-authenticateList-box1">
  224. <img
  225. src="../../assets/image/timg4.jpg"
  226. alt
  227. class="help_box-main-authenticateList-box1-img"
  228. />
  229. <div class="help_box-main-authenticateList-box1-txt">
  230. 这是什么虫子?以前好像见过
  231. </div>
  232. </div>
  233. <div class="help_box-main-authenticateList-box2">
  234. <div class="help_box-main-authenticateList-box3">
  235. <img
  236. src="../../assets/image/user.jpg"
  237. alt
  238. class="help_box-main-authenticateList-box3-img"
  239. />
  240. <div class="help_box-main-authenticateList-box3-name">
  241. 用户123456
  242. </div>
  243. </div>
  244. <img
  245. src="../../assets/image/new/10.png"
  246. alt
  247. class="help_box-main-authenticateList-box4-img"
  248. />
  249. </div>
  250. </li>
  251. <li class="help_box-main-authenticateList">
  252. <div class="help_box-main-authenticateList-box1">
  253. <img
  254. src="../../assets/image/timg4.jpg"
  255. alt
  256. class="help_box-main-authenticateList-box1-img"
  257. />
  258. <div class="help_box-main-authenticateList-box1-txt">
  259. 这是什么虫子?以前好像见过
  260. </div>
  261. </div>
  262. <div class="help_box-main-authenticateList-box2">
  263. <div class="help_box-main-authenticateList-box3">
  264. <img
  265. src="../../assets/image/user.jpg"
  266. alt
  267. class="help_box-main-authenticateList-box3-img"
  268. />
  269. <div class="help_box-main-authenticateList-box3-name">
  270. 用户123456
  271. </div>
  272. </div>
  273. <img
  274. src="../../assets/image/new/10.png"
  275. alt
  276. class="help_box-main-authenticateList-box4-img"
  277. />
  278. </div>
  279. </li>
  280. <li class="help_box-main-authenticateList">
  281. <div class="help_box-main-authenticateList-box1">
  282. <img
  283. src="../../assets/image/timg4.jpg"
  284. alt
  285. class="help_box-main-authenticateList-box1-img"
  286. />
  287. <div class="help_box-main-authenticateList-box1-txt">
  288. 这是什么虫子?以前好像见过
  289. </div>
  290. </div>
  291. <div class="help_box-main-authenticateList-box2">
  292. <div class="help_box-main-authenticateList-box3">
  293. <img
  294. src="../../assets/image/user.jpg"
  295. alt
  296. class="help_box-main-authenticateList-box3-img"
  297. />
  298. <div class="help_box-main-authenticateList-box3-name">
  299. 用户123456
  300. </div>
  301. </div>
  302. <img
  303. src="../../assets/image/new/10.png"
  304. alt
  305. class="help_box-main-authenticateList-box4-img"
  306. />
  307. </div>
  308. </li>
  309. </ul>
  310. </div>
  311. </div>
  312. </div>
  313. </div>
  314. </div>
  315. </template>
  316. <script>
  317. import Swiper from "swiper";
  318. import "swiper/css/swiper.min.css";
  319. import "swiper/js/swiper.min.js";
  320. export default {
  321. //import引入的组件需要注入到对象中才能使用
  322. components: {},
  323. data() {
  324. //这里存放数据
  325. return {
  326. fullHeight: document.documentElement.clientHeight,
  327. navList: [{ name: "交流" }, { name: "鉴定" }],
  328. nowIndex: 0,
  329. mySwiper: "",
  330. // 交流
  331. interflowDat: [], //交流列表数据
  332. isClick: true, //点赞开关
  333. amplificationShow: false, //查看大图
  334. imgList: "",
  335. };
  336. },
  337. //监听属性 类似于data概念
  338. computed: {},
  339. //监控data中的数据变化
  340. watch: {
  341. fullHeight(val) {
  342. //监控浏览器高度变化
  343. if (!this.timer) {
  344. this.fullHeight = val;
  345. this.timer = true;
  346. let that = this;
  347. setTimeout(function () {
  348. //防止过度调用监测事件,导致卡顿
  349. that.timer = false;
  350. }, 400);
  351. }
  352. },
  353. },
  354. //方法集合
  355. methods: {
  356. //动态获取浏览器高度
  357. get_boderHeight() {
  358. const that = this;
  359. window.onresize = () => {
  360. return (() => {
  361. window.fullHeight = document.documentElement.clientHeight;
  362. that.fullHeight = window.fullHeight;
  363. })();
  364. };
  365. },
  366. // tab切换交流、鉴定、方案
  367. initSwiper() {
  368. var that = this;
  369. that.mySwiper = new Swiper(".swiper-container", {
  370. initialSlide: 0,
  371. autoplay: false,
  372. keyboardControl: true,
  373. autoHeight: true,
  374. observer: true, //修改swiper自己或子元素时,自动初始化swiper
  375. observeParents: true,
  376. autoplayDisableOnInteraction: false, //解决拖动之后不能自动轮播
  377. preventLinksPropagation: false, // 阻止点击事件冒泡
  378. onSlideChangeStart: function (swiper) {
  379. //这个是当swiper被改变是的回调函数,可以拿到当前索引
  380. console.log(swiper.activeIndex);
  381. // alert(swiper.activeIndex);
  382. that.nowIndex = swiper.activeIndex;
  383. },
  384. onSlideChangeTransitionStart: function (swiper, event) {},
  385. });
  386. },
  387. tabClick(index) {
  388. this.nowIndex = index;
  389. if (!this.mySwiper.slideTo) {
  390. this.initSwiper();
  391. }
  392. this.mySwiper.slideTo(index, 300, false);
  393. },
  394. // 交流列表数据接口
  395. interflowData() {
  396. var that = this;
  397. that
  398. .$axios({
  399. method: "get",
  400. url: "bigservers/user_farm_show",
  401. params: {
  402. page: 1,
  403. },
  404. })
  405. .then((res) => {
  406. if (res.data.num !== 0) {
  407. var data = res.data.dat;
  408. that.interflowDat = data;
  409. } else if (res.data.num === 0) {
  410. this.gerenShow = false;
  411. }
  412. })
  413. .catch((err) => {
  414. console.log(err);
  415. });
  416. },
  417. // 交流点赞
  418. like(id, index) {
  419. var that = this;
  420. var isClick = that.isClick;
  421. var postData = that.$qs.parse({
  422. id: id, //id
  423. ret: "add", //点赞
  424. req: "title", //主问题
  425. });
  426. if (isClick === true) {
  427. that.isClick = false;
  428. that
  429. .$axios({
  430. method: "post",
  431. url: "bigservers/farm_likes",
  432. data: postData,
  433. })
  434. .then((res) => {
  435. if (res.data === 0) {
  436. this.$message({
  437. type: "success",
  438. message: "点赞成功!",
  439. duration: 1500,
  440. });
  441. that.interflowDat[index].like = "1"; //改变点赞状态
  442. that.interflowDat[index].like_num =
  443. that.interflowDat[index].like_num + 1; //改变点赞数据
  444. } else if (res.data === 1) {
  445. this.$notify.error({
  446. title: "错误",
  447. message: "点赞出错了!!",
  448. duration: 1500,
  449. });
  450. }
  451. })
  452. .catch((err) => {
  453. console.log(err);
  454. });
  455. setTimeout(function () {
  456. that.isClick = true;
  457. }, 1500);
  458. }
  459. },
  460. // 交流取消点赞
  461. noLike(id, index) {
  462. var that = this;
  463. var isClick = that.isClick;
  464. var postData = that.$qs.parse({
  465. id: id, //id
  466. ret: "off", //点赞
  467. req: "title", //主问题
  468. });
  469. if (isClick === true) {
  470. that.isClick = false;
  471. that
  472. .$axios({
  473. method: "post",
  474. url: "bigservers/farm_likes",
  475. data: postData,
  476. })
  477. .then((res) => {
  478. if (res.data === 0) {
  479. that.$message({
  480. type: "success",
  481. message: "取消点赞成功!",
  482. duration: 1500,
  483. });
  484. that.interflowDat[index].like = "0"; //改变点赞状态
  485. that.interflowDat[index].like_num =
  486. that.interflowDat[index].like_num - 1; //改变点赞数量
  487. } else if (res.data === 1) {
  488. that.$notify.error({
  489. title: "错误",
  490. message: "取消点赞出错了!!",
  491. duration: 1500,
  492. });
  493. }
  494. })
  495. .catch((err) => {
  496. console.log(err);
  497. });
  498. setTimeout(function () {
  499. that.isClick = true;
  500. }, 1500);
  501. }
  502. },
  503. //点击轮播图片进行放大
  504. imgShow(img) {
  505. this.amplificationShow = true;
  506. this.imgList = img;
  507. console.log(img);
  508. console.log(111);
  509. console.log(this.imgList);
  510. },
  511. },
  512. //生命周期 - 创建完成(可以访问当前this实例)
  513. created() {},
  514. //生命周期 - 挂载完成(可以访问DOM元素)
  515. mounted() {
  516. this.get_boderHeight();
  517. this.initSwiper(); //tab切换交流、鉴定、方案
  518. this.interflowData(); //交流列表接口
  519. },
  520. };
  521. </script>
  522. <style lang='scss'>
  523. @import "../../assets/scss/help.scss";
  524. //@import url(); 引入公共css类
  525. </style>