comment_con.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <view class="evaluateWtapper" :style="colorStyle">
  3. <view class="scroll-box">
  4. <scroll-view scroll-y="true" style="height: 100%;" :scroll-top="scrollTop">
  5. <view id='tops'>
  6. <view class="goods acea-row row-middle" v-if="replyCon.product" @click="details(replyCon.product.id)">
  7. <view class="pictrue">
  8. <image :src="replyCon.product.image"></image>
  9. </view>
  10. <view class="text line2">{{replyCon.product.store_name}}</view>
  11. <!-- <view class="cart acea-row row-center-wrapper" @click="details(replyCon.product.id)">
  12. <text class="iconfont icon-gouwuche7"></text>
  13. </view> -->
  14. </view>
  15. <view class="evaluateItem" v-if="replyCon.reply">
  16. <view class="pic-text acea-row row-between-wrapper">
  17. <view class="acea-row row-middle">
  18. <view class="pictrue">
  19. <image :src="replyCon.reply.avatar" mode="aspectFill"></image>
  20. </view>
  21. <view class="acea-row row-middle">
  22. <view class="acea-row row-middle" style="margin-right: 15rpx;">
  23. <view class="name line1">{{ replyCon.reply.nickname }}</view>
  24. <view class="vipImg" v-if="replyCon.user.is_money_level>0"><image src="../../../static/images/vip.png"></image></view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="start" :class="'star' + replyCon.star"></view>
  29. </view>
  30. <view class="time">{{ replyCon.reply.add_time }} {{ replyCon.reply.suk }}</view>
  31. <view class="evaluate-infor">{{ replyCon.reply.comment }}</view>
  32. <view class="imgList">
  33. <view class="pictrue" v-for="(item, index) in replyCon.reply.pics" :key="index">
  34. <image :src="item" class="image" @click='getpreviewImage(index)' mode="widthFix">
  35. </image>
  36. </view>
  37. </view>
  38. <view class="census acea-row row-between-wrapper">
  39. <view>浏览{{replyCon.reply.views_num}}次</view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="list" v-if="replyList.length">
  44. <view class="title">{{replyNum}}条回复</view>
  45. <view class="item" v-for="(item,index) in replyList" :key="index">
  46. <view class="info acea-row row-between-wrapper">
  47. <view class="picTxt acea-row row-middle">
  48. <view class="pictrue">
  49. <image :src="item.user.avatar" v-if="item.uid && item.user"></image>
  50. <image src="../static/store.png" v-if="!item.uid"></image>
  51. </view>
  52. <view class="text">
  53. <view class="acea-row row-middle">
  54. <view class="acea-row row-middle">
  55. <view class="name line1" :class="!item.uid?'on':''">{{item.user?item.user.nickname:'用户'}}</view>
  56. <view class="store" v-if="!item.uid">商家</view>
  57. </view>
  58. <view class="vipImg" v-if="item.uid && item.user && item.user.is_money_level>0"><image src="../../../static/images/vip.png"></image></view>
  59. </view>
  60. <view class="time">{{item.create_time}}</view>
  61. </view>
  62. </view>
  63. <view @click="praise(item)"><text class="iconfont" :class="item.is_praise?'icon-weizan font-num':'icon-zan'"></text>{{item.praise}}</view>
  64. </view>
  65. <view class="conter">{{item.content}}</view>
  66. <view class="item items" v-if="item.children">
  67. <view class="info acea-row row-between-wrapper">
  68. <view class="picTxt acea-row row-middle">
  69. <view class="pictrue">
  70. <image src="../static/store.png"></image>
  71. </view>
  72. <view class="text">
  73. <view class="acea-row row-middle">
  74. <view class="name line1">{{item.children.user.nickname}}</view>
  75. <view class="store">商家</view>
  76. </view>
  77. <view class="time">{{item.children.create_time}}</view>
  78. </view>
  79. </view>
  80. <view @click="praise(item.children)"><text class="iconfont" :class="item.children.is_praise?'icon-weizan font-num':'icon-zan'"></text>{{item.children.praise}}</view>
  81. </view>
  82. <view class="conter">{{item.children.content}}</view>
  83. </view>
  84. </view>
  85. </view>
  86. </scroll-view>
  87. </view>
  88. <view class="footer-box">
  89. <view class="input-box">
  90. <input type="text" placeholder="说点什么呗~" v-model="con" confirm-type="send" @confirm="sendText" />
  91. </view>
  92. <view class="icons acea-row row-middle">
  93. <view class="item"><text class="iconfont icon-pinglun1"></text>{{replyNum}}</view>
  94. <view class="item" @click="tapPraise"><text class="iconfont" :class="replyCon.is_praise?'icon-weizan font-num':'icon-zan'"></text>{{replyCon.reply?replyCon.reply.praise:0}}</view>
  95. </view>
  96. </view>
  97. <home v-if="navigation"></home>
  98. </view>
  99. </template>
  100. <script>
  101. import {
  102. getReplyInfo,
  103. getReplyComment,
  104. postReplyPraise,
  105. replyComment,
  106. postUnReplyPraise,
  107. getReplyPraise,
  108. getUnReplyPraise
  109. } from '@/api/store.js';
  110. import home from '@/components/home';
  111. import colors from '@/mixins/color.js';
  112. export default {
  113. components: {
  114. home
  115. },
  116. mixins: [colors],
  117. data: function() {
  118. return {
  119. id: 0,
  120. page:1,
  121. limit:200,
  122. replyCon: {},
  123. replyList: [],
  124. con:'',
  125. scrollTop:0,
  126. replyNum:0
  127. };
  128. },
  129. onLoad(options) {
  130. this.id = options.id
  131. this.getInfo();
  132. this.getList();
  133. },
  134. onShow() {
  135. uni.removeStorageSync('form_type_cart');
  136. },
  137. methods: {
  138. tapPraise(){
  139. if (this.replyCon.is_praise) {
  140. getUnReplyPraise(this.id).then(res => {
  141. this.replyCon.is_praise = !this.replyCon.is_praise
  142. this.replyCon.reply.praise = this.replyCon.reply.praise - 1
  143. return this.$util.Tips({
  144. title: res.msg
  145. });
  146. });
  147. } else {
  148. getReplyPraise(this.id).then(res => {
  149. this.replyCon.is_praise = !this.replyCon.is_praise
  150. this.replyCon.reply.praise = this.replyCon.reply.praise + 1
  151. return this.$util.Tips({
  152. title: res.msg
  153. });
  154. });
  155. }
  156. },
  157. // 设置页面滚动位置
  158. setPageScrollTo() {
  159. let view = uni
  160. .createSelectorQuery()
  161. .in(this)
  162. .select('#tops');
  163. view.boundingClientRect(res => {
  164. this.scrollTop = parseFloat(res.height);
  165. }).exec();
  166. },
  167. sendText(){
  168. if(!this.con.trim()){
  169. return this.$util.Tips({
  170. title: '说点什么呗'
  171. });
  172. }
  173. replyComment(this.id,{content:this.con}).then(res=>{
  174. let that = this;
  175. this.con = '';
  176. this.replyNum = this.replyNum+1;
  177. this.getList();
  178. this.$nextTick(() => {
  179. setTimeout(function(){
  180. that.setPageScrollTo();
  181. },100)
  182. });
  183. this.$util.Tips({
  184. title: res.msg
  185. });
  186. })
  187. },
  188. details(id){
  189. uni.navigateTo({
  190. url: '/pages/goods_details/index?id=' + id
  191. })
  192. },
  193. getInfo() {
  194. getReplyInfo(this.id).then(res => {
  195. this.replyCon = res.data;
  196. this.replyNum = this.replyCon.reply.comment_sum;
  197. })
  198. },
  199. getList(){
  200. getReplyComment(this.id,{
  201. page: this.page,
  202. limit: this.limit
  203. }).then(res=>{
  204. this.replyList = res.data
  205. }).catch(err=>{
  206. return this.$util.Tips({
  207. title: err.msg
  208. });
  209. })
  210. },
  211. getpreviewImage: function(index) {
  212. uni.previewImage({
  213. urls: this.replyCon.reply.pics,
  214. current: this.replyCon.reply.pics[index]
  215. });
  216. },
  217. praise(item) {
  218. if (item.is_praise) {
  219. postUnReplyPraise(item.id).then(res => {
  220. item.is_praise = !item.is_praise
  221. item.praise = item.praise - 1
  222. return this.$util.Tips({
  223. title: res.msg
  224. });
  225. });
  226. } else {
  227. postReplyPraise(item.id).then(res => {
  228. item.is_praise = !item.is_praise
  229. item.praise = item.praise + 1
  230. return this.$util.Tips({
  231. title: res.msg
  232. });
  233. });
  234. }
  235. }
  236. }
  237. }
  238. </script>
  239. <style scoped lang='scss'>
  240. .vipImg {
  241. width: 56rpx;
  242. height: 20rpx;
  243. margin-left: 10rpx;
  244. image {
  245. width: 100%;
  246. height: 100%;
  247. display: block;
  248. }
  249. }
  250. .evaluateWtapper {
  251. display: flex;
  252. flex-direction: column;
  253. height: 100vh;
  254. .scroll-box{
  255. flex: 1;
  256. overflow: hidden;
  257. }
  258. .goods {
  259. margin: 0 20rpx;
  260. padding: 24rpx 0;
  261. position: relative;
  262. .pictrue {
  263. width: 108rpx;
  264. height: 108rpx;
  265. border-radius: 12rpx;
  266. margin-right: 24rpx;
  267. image{
  268. width: 100%;
  269. height: 100%;
  270. border-radius: 12rpx;
  271. }
  272. }
  273. .text{
  274. width: 560rpx;
  275. font-size: 26rpx;
  276. color: #333;
  277. }
  278. .cart{
  279. width: 60rpx;
  280. height: 60rpx;
  281. border-radius: 50%;
  282. background-color: #fff;
  283. position: absolute;
  284. right: 20rpx;
  285. top:50%;
  286. margin-top: -30rpx;
  287. }
  288. .iconfont{
  289. font-size: 40rpx;
  290. color: var(--view-theme);
  291. }
  292. }
  293. .list{
  294. margin: 0 20rpx 30rpx 20rpx;
  295. padding: 28rpx 20rpx 0 20rpx;
  296. background-color: #fff;
  297. border-radius: 12rpx;
  298. .title{
  299. font-size: 30rpx;
  300. color: #333;
  301. }
  302. .item{
  303. padding: 28rpx 0 30rpx 0;
  304. .store{
  305. background-color: var(--view-theme);
  306. font-size: 18rpx;
  307. color: #fff;
  308. border-radius: 8rpx;
  309. padding: 2rpx 5rpx;
  310. margin-left: 10rpx;
  311. }
  312. &~.item{
  313. border-top: 1rpx solid #eee;
  314. }
  315. &.items{
  316. background-color: #F5F5F5;
  317. border-radius: 8rpx;
  318. margin-top: 22rpx;
  319. padding: 24rpx;
  320. .info .picTxt .text .name{
  321. max-width: 230rpx;
  322. color: var(--view-theme);
  323. }
  324. }
  325. .info{
  326. .picTxt{
  327. .pictrue{
  328. width: 56rpx;
  329. height: 56rpx;
  330. border-radius: 50%;
  331. margin-right: 20rpx;
  332. image{
  333. width: 100%;
  334. height: 100%;
  335. border-radius: 50%;
  336. }
  337. }
  338. .text{
  339. font-size: 20rpx;
  340. color: #999999;
  341. .name{
  342. max-width: 330rpx;
  343. margin-right: 4rpx;
  344. color: #333;
  345. &.on{
  346. color: var(--view-theme);
  347. }
  348. }
  349. }
  350. }
  351. .iconfont{
  352. margin-right: 6rpx;
  353. }
  354. }
  355. .conter{
  356. margin-top: 24rpx;
  357. word-break: break-all;
  358. }
  359. }
  360. }
  361. .footer-box{
  362. display: flex;
  363. align-items: center;
  364. padding: 0 20rpx;
  365. color: rgba(0, 0, 0, 0.8);
  366. background: #fff;
  367. height: 96rpx;
  368. height: calc(96rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  369. height: calc(96rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  370. .icons{
  371. width: 217rpx;
  372. .item{
  373. margin-left: 42rpx;
  374. .iconfont{
  375. margin-right: 6rpx;
  376. }
  377. }
  378. }
  379. .input-box {
  380. display: flex;
  381. align-items: center;
  382. flex: 1;
  383. height: 64rpx;
  384. padding-right: 5rpx;
  385. background-color: #eee;
  386. border-radius: 32rpx;
  387. input {
  388. flex: 1;
  389. padding-left: 20rpx;
  390. height: 100%;
  391. font-size: 28rpx;
  392. font-weight: normal;
  393. }
  394. .icon-fasong {
  395. font-size: 50rpx;
  396. color: #ccc;
  397. font-weight: normal;
  398. }
  399. }
  400. }
  401. }
  402. .evaluateWtapper .census {
  403. padding: 0 20rpx;
  404. font-size: 22rpx;
  405. color: #999;
  406. }
  407. .evaluateWtapper .census .iconfont {
  408. font-size: 26rpx;
  409. margin-right: 6rpx;
  410. }
  411. .evaluateWtapper .census .icons {
  412. color: #333;
  413. }
  414. .evaluateWtapper .census .icon {
  415. margin-left: 40rpx;
  416. }
  417. .evaluateWtapper .evaluateItem {
  418. background-color: #fff;
  419. padding-bottom: 25rpx;
  420. margin: 0 20rpx 20rpx 20rpx;
  421. border-radius: 12rpx;
  422. }
  423. .evaluateWtapper .evaluateItem~.evaluateItem {
  424. /* border-top: 1rpx solid #f5f5f5; */
  425. }
  426. .evaluateWtapper .evaluateItem .pic-text {
  427. font-size: 26rpx;
  428. color: #282828;
  429. height: 95rpx;
  430. padding: 0 20rpx;
  431. }
  432. .evaluateWtapper .evaluateItem .pic-text .pictrue {
  433. width: 56rpx;
  434. height: 56rpx;
  435. margin-right: 20rpx;
  436. }
  437. .evaluateWtapper .evaluateItem .pic-text .pictrue image {
  438. width: 100%;
  439. height: 100%;
  440. border-radius: 50%;
  441. }
  442. .evaluateWtapper .evaluateItem .pic-text .name {
  443. max-width: 450rpx;
  444. }
  445. .evaluateWtapper .evaluateItem .time {
  446. font-size: 24rpx;
  447. color: #82848f;
  448. padding: 0 20rpx;
  449. }
  450. .evaluateWtapper .evaluateItem .evaluate-infor {
  451. font-size: 28rpx;
  452. color: #282828;
  453. margin-top: 19rpx;
  454. padding: 0 20rpx;
  455. }
  456. .evaluateWtapper .evaluateItem .imgList {
  457. padding: 0 20rpx 0 6rpx;
  458. margin-top: 25rpx;
  459. }
  460. .evaluateWtapper .evaluateItem .imgList .pictrue {
  461. width: 100%;
  462. margin: 0 0 15rpx 15rpx;
  463. border-radius: 12rpx;
  464. }
  465. .evaluateWtapper .evaluateItem .imgList .pictrue image {
  466. width: 100%;
  467. height: 100%;
  468. background-color: #f7f7f7;
  469. border-radius: 12rpx;
  470. }
  471. </style>