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" class="rich-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. adoptAnswer(this.answer).then(res => {
  132. })
  133. this.isAdopt = true
  134. this.form.answerList.forEach(v => {
  135. if (v.id == id) {
  136. v.adopt = 1
  137. }
  138. })
  139. },
  140. //是否收藏
  141. selectCollect(id) {
  142. this.collect.userId = getApp().globalData.userId;
  143. this.collect.questionId = id
  144. selectCollect(this.collect).then(res => {
  145. if (res.data.length != 0) {
  146. this.isCollection = true
  147. }
  148. })
  149. },
  150. // 标记喜欢
  151. collectionFunc(id) {
  152. this.collect.userId = getApp().globalData.userId;
  153. this.collect.questionId = id
  154. addCollect(this.collect).then(res => {
  155. })
  156. this.isCollection = !this.isCollection
  157. },
  158. //获取问题详情
  159. getDetailById(id) {
  160. this.form.id = id
  161. getDetailById(this.form).then(res => {
  162. res.data.answerList.forEach(v => {
  163. if (v.adopt == "1") {
  164. this.isAdopt = true
  165. }
  166. })
  167. this.form = res.data
  168. this.getUserInfoByUserId(this.form.createBy);//获取用户信息
  169. this.selectCollect(id);//是否收藏
  170. })
  171. },
  172. //获取用户信息:用户名称:头像
  173. getUserInfoByUserId(userId) {
  174. getUserInfo(userId).then((res) => {
  175. this.initInfo = res.data;
  176. });
  177. },
  178. }
  179. /**
  180. * 生命周期函数--监听页面加载
  181. */,
  182. onLoad(options) {
  183. this.getDetailById(options.id)
  184. },
  185. /**
  186. * 生命周期函数--监听页面初次渲染完成
  187. */
  188. onReady(e) {
  189. },
  190. /**
  191. * 生命周期函数--监听页面显示
  192. */
  193. onShow() {
  194. },
  195. /**
  196. * 生命周期函数--监听页面隐藏
  197. */
  198. onHide() {
  199. },
  200. /**
  201. * 生命周期函数--监听页面卸载
  202. */
  203. onUnload() {
  204. },
  205. /**
  206. * 页面相关事件处理函数--监听用户下拉动作
  207. */
  208. onPullDownRefresh() {
  209. },
  210. /**
  211. * 页面上拉触底事件的处理函数
  212. */
  213. onReachBottom() {
  214. },
  215. /**
  216. * 用户点击右上角分享
  217. */
  218. onShareAppMessage() {
  219. },
  220. };
  221. </script>
  222. <style lang="scss" scoped>
  223. @import '@/pages/asking/questiondetails.css';
  224. .collect {
  225. .icon-shoucang:before {
  226. color: red;
  227. }
  228. }
  229. .not-collect {
  230. }
  231. .rich-text {
  232. overflow: hidden;
  233. }
  234. .effectBix {
  235. width: 56px;
  236. height: 56px;
  237. border-radius: 50px;
  238. font-family: 'Bebas Neue', cursive;
  239. background: linear-gradient(45deg, transparent 5%, #FF013C 5%);
  240. border: 0;
  241. color: #fff;
  242. text-align: center;
  243. line-height: 56px;
  244. outline: transparent;
  245. position: absolute;
  246. transform: rotate(-30deg);
  247. right: 3%;
  248. top: -5%;
  249. }
  250. .effectBox, .effectBox::after {
  251. width: 56px;
  252. height: 56px;
  253. border-radius: 50px;
  254. font-size: 16px;
  255. font-family: 'Bebas Neue', cursive;
  256. background: linear-gradient(45deg, transparent 5%, #FF013C 5%);
  257. border: 0;
  258. color: #fff;
  259. opacity: 1;
  260. letter-spacing: 3px;
  261. text-align: center;
  262. line-height: 56px;
  263. outline: transparent;
  264. position: relative;
  265. left: 78%;
  266. top: 113%;
  267. transform: rotate(-30deg);
  268. z-index: 1;
  269. }
  270. .effectBox::after {
  271. --slice-0: inset(50% 50% 50% 50%);
  272. --slice-1: inset(80% -6px 0 0);
  273. --slice-2: inset(50% -6px 30% 0);
  274. --slice-3: inset(10% -6px 85% 0);
  275. --slice-4: inset(40% -6px 43% 0);
  276. --slice-5: inset(80% -6px 5% 0);
  277. content: 'AVAILABLE NOW';
  278. display: block;
  279. position: absolute;
  280. top: 0;
  281. left: 0;
  282. right: 0;
  283. bottom: 0;
  284. background: linear-gradient(45deg, transparent 3%, #00E6F6 3%, #00E6F6 5%, #FF013C 5%);
  285. text-shadow: -3px -3px 0px #F8F005, 3px 3px 0px #00E6F6;
  286. clip-path: var(--slice-0);
  287. }
  288. .effectBox:hover::after {
  289. animation: 1s glitch;
  290. animation-timing-function: steps(2, end);
  291. }
  292. @keyframes glitch {
  293. 0% {
  294. clip-path: var(--slice-1);
  295. transform: translate(-20px, -10px);
  296. }
  297. 10% {
  298. clip-path: var(--slice-3);
  299. transform: translate(10px, 10px);
  300. }
  301. 20% {
  302. clip-path: var(--slice-1);
  303. transform: translate(-10px, 10px);
  304. }
  305. 30% {
  306. clip-path: var(--slice-3);
  307. transform: translate(0px, 5px);
  308. }
  309. 40% {
  310. clip-path: var(--slice-2);
  311. transform: translate(-5px, 0px);
  312. }
  313. 50% {
  314. clip-path: var(--slice-3);
  315. transform: translate(5px, 0px);
  316. }
  317. 60% {
  318. clip-path: var(--slice-4);
  319. transform: translate(5px, 10px);
  320. }
  321. 70% {
  322. clip-path: var(--slice-2);
  323. transform: translate(-10px, 10px);
  324. }
  325. 80% {
  326. clip-path: var(--slice-5);
  327. transform: translate(20px, -10px);
  328. }
  329. 90% {
  330. clip-path: var(--slice-1);
  331. transform: translate(-10px, 0px);
  332. }
  333. 100% {
  334. clip-path: var(--slice-1);
  335. transform: translate(0);
  336. }
  337. }
  338. </style>