questiondetails.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <view>
  3. <!-- pages/me.wxml -->
  4. <view class="container">
  5. <h1 class="title">{{ form.title }}</h1>
  6. <view class="wenzhangLy">
  7. <!-- 头像昵称 -->
  8. <view class="txTime">
  9. <image
  10. :src="initInfo.headImg == null || initInfo.headImg == '' ? initImgPath : loadImgSrcLocalhost(initInfo.headImg)"></image>
  11. <view class="time">
  12. <p>{{ initInfo.name == null || initInfo.name == '' ? initInfo.wechatName : initInfo.name }}</p>
  13. <span>{{ form.createTime }}</span>
  14. </view>
  15. </view>
  16. <!-- 积分 -->
  17. <span class="jf">{{ form.score }}</span>
  18. </view>
  19. <view class="wenzhangCont">
  20. <view v-html="form.text"></view>
  21. <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in form.paths" :key="index2"></image>
  22. </view>
  23. <view class="fengexian"></view>
  24. <!-- 分割线 -->
  25. <view class="pinglunTj">
  26. <span class="pinglunTitle">
  27. 回答
  28. <em>{{ form.answerList.length }}</em>
  29. </span>
  30. <view class="ck">
  31. <span>
  32. <em class="iconfont icon-chakan"></em>
  33. {{ form.browse }}
  34. </span>
  35. <span>
  36. <em class="iconfont icon-shoucang"></em>
  37. {{ form.collect }}
  38. </span>
  39. </view>
  40. </view>
  41. <ul class="pinglunList" id="pinglunList">
  42. <li v-for="(e,idx) in form.answerList" :key="idx" style="position: relative;">
  43. <!-- 头像昵称 -->
  44. <view class="txTime">
  45. <image :src="e.headImg == null || e.headImg == '' ? initImgPath : loadImgSrcLocalhost(e.headImg)"></image>
  46. <view class="time">
  47. <p>{{ e.name == null || e.name == '' ? e.wechatName : e.name }}</p>
  48. <span>{{ e.createTime }}</span>
  49. </view>
  50. </view>
  51. <!-- <div class="effectBox" :style="{ top: adoptTopSize + '%' }">精选答案</div> -->
  52. <div class="effectBix" :style="e.adopt == adoptIndex ? 'display:block' : 'display:none' ">采 纳</div>
  53. <text class="plListcont" style="z-index: 10;">{{ e.answer }}</text>
  54. <uploadImage/>
  55. <button v-show="!isAdopt" @click="adoptFunc(e.id)">采纳答案</button>
  56. </li>
  57. </ul>
  58. </view>
  59. <view class="fabiaoPl" :class="isCollection ? 'collect' : 'not-collect'" style="z-index: 100;">
  60. <view class="shuRu">
  61. <em class="iconfont icon-bianji"></em>
  62. <input placeholder="请输入内容,友好回答" v-model="anwserVal"/>
  63. </view>
  64. <em
  65. class="iconfont icon-shoucang"
  66. @click="collectionFunc(form.id)"
  67. >
  68. </em>
  69. <view class="fasong" @click="answerFunc(form.id,anwserVal)"><em class="iconfont icon-fasong"></em></view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import {
  75. getDetailById,
  76. getUserInfo,
  77. addCollect,
  78. addAnswer,
  79. adoptAnswer,
  80. selectCollect
  81. } from '@/api/asking/questiondetails.js';
  82. // pages/me.js
  83. export default {
  84. data() {
  85. return {
  86. initImgPath: 'https://sookajs.top:8888/profile/upload/moren.png',
  87. anwserVal: '',
  88. isCollection: false,
  89. isAdopt: false,
  90. adoptTopSize: '115',
  91. adoptIndex: 1,
  92. form: {},
  93. answer: {},
  94. initInfo: {},
  95. collect: {},
  96. };
  97. },
  98. methods: {
  99. // 评论回答
  100. answerFunc(id, answer) {
  101. this.answer.questionId = id
  102. this.answer.answer = answer
  103. this.answer.createBy = getApp().globalData.userId
  104. addAnswer(this.answer).then(res => {
  105. getUserInfo(getApp().globalData.userId).then((res) => {
  106. let userInfo = res.data;
  107. let newAnswer={
  108. adopt: null,
  109. answer: answer,
  110. createTime: new Date(),
  111. headImg: userInfo.headImg,
  112. name: userInfo.name,
  113. questionId: id,
  114. remark: null,
  115. score: null,
  116. updateBy: null,
  117. updateTime: null,
  118. version: null,
  119. wechatName: userInfo.wechatName
  120. }
  121. this.form.answerList.push(newAnswer);
  122. });
  123. })
  124. this.anwserVal = null
  125. },
  126. //采纳答案
  127. adoptFunc(id) {
  128. this.answer.id = id
  129. this.answer.createBy = getApp().globalData.userId
  130. this.answer.score = this.form.score
  131. console.log(this.answer)
  132. adoptAnswer(this.answer).then(res => {
  133. })
  134. this.isAdopt = true
  135. this.form.answerList.forEach(v => {
  136. if (v.id == id) {
  137. v.adopt = 1
  138. }
  139. })
  140. },
  141. //是否收藏
  142. selectCollect(id) {
  143. this.collect.userId = getApp().globalData.userId;
  144. this.collect.questionId = id
  145. selectCollect(this.collect).then(res => {
  146. console.log(res)
  147. if (res.data.length != 0) {
  148. this.isCollection = true
  149. }
  150. })
  151. },
  152. // 标记喜欢
  153. collectionFunc(id) {
  154. this.collect.userId = getApp().globalData.userId;
  155. this.collect.questionId = id
  156. addCollect(this.collect).then(res => {
  157. })
  158. this.isCollection = !this.isCollection
  159. },
  160. //获取问题详情
  161. getDetailById(id) {
  162. this.form.id = id
  163. getDetailById(this.form).then(res => {
  164. res.data.answerList.forEach(v => {
  165. if (v.adopt == "1") {
  166. this.isAdopt = true
  167. }
  168. })
  169. this.form = res.data
  170. this.getUserInfoByUserId(this.form.createBy);//获取用户信息
  171. this.selectCollect(id);//是否收藏
  172. })
  173. },
  174. //获取用户信息:用户名称:头像
  175. getUserInfoByUserId(userId) {
  176. getUserInfo(userId).then((res) => {
  177. this.initInfo = res.data;
  178. });
  179. },
  180. }
  181. /**
  182. * 生命周期函数--监听页面加载
  183. */,
  184. onLoad(options) {
  185. this.getDetailById(options.id)
  186. },
  187. /**
  188. * 生命周期函数--监听页面初次渲染完成
  189. */
  190. onReady(e) {
  191. },
  192. /**
  193. * 生命周期函数--监听页面显示
  194. */
  195. onShow() {
  196. },
  197. /**
  198. * 生命周期函数--监听页面隐藏
  199. */
  200. onHide() {
  201. },
  202. /**
  203. * 生命周期函数--监听页面卸载
  204. */
  205. onUnload() {
  206. },
  207. /**
  208. * 页面相关事件处理函数--监听用户下拉动作
  209. */
  210. onPullDownRefresh() {
  211. },
  212. /**
  213. * 页面上拉触底事件的处理函数
  214. */
  215. onReachBottom() {
  216. },
  217. /**
  218. * 用户点击右上角分享
  219. */
  220. onShareAppMessage() {
  221. },
  222. };
  223. </script>
  224. <style lang="scss">
  225. @import '@/pages/asking/questiondetails.css';
  226. .collect {
  227. .icon-shoucang:before {
  228. color: red;
  229. }
  230. }
  231. .not-collect {
  232. }
  233. .effectBix {
  234. width: 56px;
  235. height: 56px;
  236. border-radius: 50px;
  237. font-family: 'Bebas Neue', cursive;
  238. background: linear-gradient(45deg, transparent 5%, #FF013C 5%);
  239. border: 0;
  240. color: #fff;
  241. text-align: center;
  242. line-height: 56px;
  243. outline: transparent;
  244. position: absolute;
  245. transform: rotate(-30deg);
  246. right: 3%;
  247. top: -5%;
  248. }
  249. .effectBox, .effectBox::after {
  250. width: 56px;
  251. height: 56px;
  252. border-radius: 50px;
  253. font-size: 16px;
  254. font-family: 'Bebas Neue', cursive;
  255. background: linear-gradient(45deg, transparent 5%, #FF013C 5%);
  256. border: 0;
  257. color: #fff;
  258. opacity: 1;
  259. letter-spacing: 3px;
  260. text-align: center;
  261. line-height: 56px;
  262. outline: transparent;
  263. position: relative;
  264. left: 78%;
  265. top: 113%;
  266. transform: rotate(-30deg);
  267. z-index: 1;
  268. }
  269. .effectBox::after {
  270. --slice-0: inset(50% 50% 50% 50%);
  271. --slice-1: inset(80% -6px 0 0);
  272. --slice-2: inset(50% -6px 30% 0);
  273. --slice-3: inset(10% -6px 85% 0);
  274. --slice-4: inset(40% -6px 43% 0);
  275. --slice-5: inset(80% -6px 5% 0);
  276. content: 'AVAILABLE NOW';
  277. display: block;
  278. position: absolute;
  279. top: 0;
  280. left: 0;
  281. right: 0;
  282. bottom: 0;
  283. background: linear-gradient(45deg, transparent 3%, #00E6F6 3%, #00E6F6 5%, #FF013C 5%);
  284. text-shadow: -3px -3px 0px #F8F005, 3px 3px 0px #00E6F6;
  285. clip-path: var(--slice-0);
  286. }
  287. .effectBox:hover::after {
  288. animation: 1s glitch;
  289. animation-timing-function: steps(2, end);
  290. }
  291. @keyframes glitch {
  292. 0% {
  293. clip-path: var(--slice-1);
  294. transform: translate(-20px, -10px);
  295. }
  296. 10% {
  297. clip-path: var(--slice-3);
  298. transform: translate(10px, 10px);
  299. }
  300. 20% {
  301. clip-path: var(--slice-1);
  302. transform: translate(-10px, 10px);
  303. }
  304. 30% {
  305. clip-path: var(--slice-3);
  306. transform: translate(0px, 5px);
  307. }
  308. 40% {
  309. clip-path: var(--slice-2);
  310. transform: translate(-5px, 0px);
  311. }
  312. 50% {
  313. clip-path: var(--slice-3);
  314. transform: translate(5px, 0px);
  315. }
  316. 60% {
  317. clip-path: var(--slice-4);
  318. transform: translate(5px, 10px);
  319. }
  320. 70% {
  321. clip-path: var(--slice-2);
  322. transform: translate(-10px, 10px);
  323. }
  324. 80% {
  325. clip-path: var(--slice-5);
  326. transform: translate(20px, -10px);
  327. }
  328. 90% {
  329. clip-path: var(--slice-1);
  330. transform: translate(-10px, 0px);
  331. }
  332. 100% {
  333. clip-path: var(--slice-1);
  334. transform: translate(0);
  335. }
  336. }
  337. </style>