questiondetails.vue 8.1 KB

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