questiondetails.vue 8.2 KB

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