questiondetails.vue 8.8 KB

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