comment_con.vue 12 KB

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