comment_con.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <view class="evaluateWtapper" :style="colorStyle">
  3. <!-- 商品详情 -->
  4. <view class="pt-24 pb-24 pl-32 pr-32 flex-between-center" v-if="replyCon.product"
  5. @click="details(replyCon.product)">
  6. <image class="w-104 h-104 rd-16rpx" :src="replyCon.product.image"></image>
  7. <view class="ml-24 w-462 line2 text--w111-333 fs-28 lh-40rpx">{{replyCon.product.store_name}}</view>
  8. <view class="flex-center w-56 h-56 rd-28rpx cart_border ml-40">
  9. <text class="iconfont icon-ic_ShoppingCart1 text-primary-con"></text>
  10. </view>
  11. </view>
  12. <!-- 评价内容卡片 -->
  13. <view class="bg--w111-fff rd-24rpx pt-32 pb-32 pl-56 pr-56 mt-24" v-if="replyCon.reply">
  14. <view class="flex-between-center">
  15. <view class="flex-y-center">
  16. <image :src="replyCon.reply.avatar" class="w-56 h-56 rd-28rpx"></image>
  17. <text class="fs-28 text--w111-333 pl-12">{{replyCon.reply.nickname}}</text>
  18. </view>
  19. <view class="fs-26 text--w111-999">{{replyCon.reply.add_time}}</view>
  20. </view>
  21. <view class="mt-32">
  22. <view class="flex-y-center">
  23. <view class="flex pr-40">
  24. <text class="iconfont icon-ic_star1 fs-18 text-primary-con"
  25. v-for="item in Number(replyCon.star)" :key="item"></text>
  26. </view>
  27. <text class="fs-22 text--w111-999 pro_name relative" v-if="replyCon.reply.suk">{{replyCon.reply.suk }}</text>
  28. </view>
  29. </view>
  30. <view class="mt-24 fs-28 text--w111-333 lh-44rpx">{{replyCon.reply.comment}}</view>
  31. <image :src="pic" v-for="(pic,i) in replyCon.reply.pics" :key="i" class="w-full mt-20 rd-16rpx"
  32. mode="widthFix"></image>
  33. <view class="mt-24">
  34. <text class="fs-22 text--w111-999">浏览{{replyCon.reply.views_num}}次</text>
  35. </view>
  36. </view>
  37. <view class="bg--w111-fff rd-24rpx pt-32 pb-32 pl-56 pr-56 mt-24">
  38. <view class="text--w111-333 fs-28 fw-500">{{replyNum}}条回复</view>
  39. <view class="reply_box pb-24" v-for="(item,index) in replyList" :key="index">
  40. <view class="flex justify-between items-baseline">
  41. <view class="flex-y-center mt-32">
  42. <image class="w-64 h-64 rd-50%" :src="item.user.avatar" v-if="item.uid && item.user"></image>
  43. <image class="w-64 h-64 rd-50%" src="../static/store.png" v-if="!item.uid"></image>
  44. <image class="w-64 h-64 rd-50%" src="@/static/images/f.png" v-if="!item.user"></image>
  45. <view class="flex-col pl-16">
  46. <view class="flex-y-center">
  47. <text class="text--w111-333 fs-24"
  48. :class="!item.uid ? 'text_score':''">{{item.user?item.user.nickname:'用户'}}</text>
  49. <view class="store_badge flex-center fs-18" v-if="!item.uid">商家</view>
  50. </view>
  51. <view class="fs-26 text--w111-999">{{item.create_time}}</view>
  52. </view>
  53. </view>
  54. <view class="flex-y-center" :class="item.is_praise ? 'font-num':''">
  55. <text class="iconfont icon-ic_Like fs-32" @click="praise(item)"></text>
  56. <text class="fs-22 pl-8">{{item.praise}}</text>
  57. </view>
  58. </view>
  59. <view class="mt-24 fs-26 text--w111-333 lh-44rpx pb-24">{{item.content}}</view>
  60. </view>
  61. </view>
  62. <view class="h-120 pb-safe"></view>
  63. <view class="page_footer fixed-lb w-full bg--w111-fff pr-20 pb-safe">
  64. <view class="pl-32 pr-24 h-96 flex-between-center">
  65. <view class="w-498 h-64 rd-32rpx bg--w111-f5f5f5 pl-24 flex-y-center text--w111-999 px-20"
  66. @tap="showInput = true">
  67. <text class="iconfont icon-ic_edit"></text>
  68. <text class="fs-26 pl-16">说说你的看法吧~</text>
  69. </view>
  70. <view class="flex-y-center pl-28">
  71. <view :class="replyCon.is_praise ? 'text-primary-con':''">
  72. <text class="iconfont icon-ic_Like"
  73. @click="tapPraise"></text>
  74. <text class="fs-22 pl-8">{{replyCon.reply?replyCon.reply.praise:0}}</text>
  75. </view>
  76. <view class="pl-32">
  77. <text class="iconfont icon-ic_message"></text>
  78. <text class="fs-22 pl-8">{{replyCon.reply ? replyCon.reply.comment_sum : 0}}</text>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <tui-drawer mode="bottom" :visible="showInput" background-color="transparent" mask maskClosable @close="closeDrawer">
  84. <view class="w-full bg--w111-fff drawer-text pt-32 pl-32 pr-32">
  85. <view class="bg--w111-f5f5f5 rd-32rpx pt-16 pr-14 pb-16 pl-24 relative">
  86. <textarea class="w-528 fs-28 h-auto"
  87. :auto-height="true"
  88. wrap-style="wrap"
  89. max-height="100px"
  90. placeholder-class='placeholder'
  91. placeholder="说说你的看法吧"
  92. :always-embed="true"
  93. :adjust-position="true"
  94. cursor-spacing="85rpx"
  95. v-model="con"
  96. :maxlength="150"
  97. name="mark">
  98. </textarea>
  99. <view class="reply-confirm-btn w-96 h-48 rd-24rpx flex-center bg-color text--w111-fff fs-24 ml-24"
  100. @tap="sendText">发送</view>
  101. </view>
  102. </view>
  103. </tui-drawer>
  104. </view>
  105. </template>
  106. <script>
  107. import {
  108. getReplyInfo,
  109. getReplyComment,
  110. postReplyPraise,
  111. replyComment,
  112. postUnReplyPraise,
  113. getReplyPraise,
  114. getUnReplyPraise
  115. } from '@/api/store.js';
  116. import tuiDrawer from "@/components/tui-drawer/tui-drawer.vue"
  117. import colors from '@/mixins/color.js';
  118. export default {
  119. components: {
  120. tuiDrawer
  121. },
  122. mixins: [colors],
  123. data: function() {
  124. return {
  125. id: 0,
  126. page: 1,
  127. limit: 200,
  128. replyCon: {},
  129. replyList: [],
  130. con: '',
  131. scrollTop: 0,
  132. replyNum: 0,
  133. showInput:false
  134. };
  135. },
  136. onLoad(options) {
  137. this.id = options.id
  138. this.getInfo();
  139. this.getList();
  140. },
  141. onShow() {
  142. uni.removeStorageSync('form_type_cart');
  143. },
  144. methods: {
  145. tapPraise() {
  146. if (this.replyCon.is_praise) {
  147. getUnReplyPraise(this.id).then(res => {
  148. this.replyCon.is_praise = !this.replyCon.is_praise
  149. this.replyCon.reply.praise = this.replyCon.reply.praise - 1
  150. return this.$util.Tips({
  151. title: res.msg
  152. });
  153. });
  154. } else {
  155. getReplyPraise(this.id).then(res => {
  156. this.replyCon.is_praise = !this.replyCon.is_praise
  157. this.replyCon.reply.praise = this.replyCon.reply.praise + 1
  158. return this.$util.Tips({
  159. title: res.msg
  160. });
  161. });
  162. }
  163. },
  164. // 设置页面滚动位置
  165. setPageScrollTo() {
  166. let view = uni
  167. .createSelectorQuery()
  168. .in(this)
  169. .select('#tops');
  170. view.boundingClientRect(res => {
  171. this.scrollTop = parseFloat(res.height);
  172. }).exec();
  173. },
  174. sendText() {
  175. if (!this.con.trim()) {
  176. return this.$util.Tips({
  177. title: '说点什么呗'
  178. });
  179. }
  180. replyComment(this.id, {
  181. content: this.con
  182. }).then(res => {
  183. let that = this;
  184. this.con = '';
  185. that.showInput = false;
  186. this.replyNum = this.replyNum + 1;
  187. this.getList();
  188. this.$util.Tips({
  189. title: res.msg
  190. });
  191. })
  192. },
  193. details(info) {
  194. if(info.is_presale_product){
  195. uni.navigateTo({
  196. url: `/pages/activity/goods_details/index?id=${info.id}&type=6`
  197. })
  198. }else{
  199. uni.navigateTo({
  200. url: `/pages/goods_details/index?id=${info.id}`
  201. })
  202. }
  203. },
  204. getInfo() {
  205. getReplyInfo(this.id).then(res => {
  206. this.replyCon = res.data;
  207. this.replyNum = this.replyCon.reply.comment_sum;
  208. })
  209. },
  210. getList() {
  211. getReplyComment(this.id, {
  212. page: this.page,
  213. limit: this.limit
  214. }).then(res => {
  215. this.replyList = res.data
  216. }).catch(err => {
  217. return this.$util.Tips({
  218. title: err.msg
  219. });
  220. })
  221. },
  222. getpreviewImage: function(index) {
  223. uni.previewImage({
  224. urls: this.replyCon.reply.pics,
  225. current: this.replyCon.reply.pics[index]
  226. });
  227. },
  228. praise(item) {
  229. if (item.is_praise) {
  230. postUnReplyPraise(item.id).then(res => {
  231. item.is_praise = !item.is_praise
  232. item.praise = item.praise - 1
  233. return this.$util.Tips({
  234. title: res.msg
  235. });
  236. });
  237. } else {
  238. postReplyPraise(item.id).then(res => {
  239. item.is_praise = !item.is_praise
  240. item.praise = item.praise + 1
  241. return this.$util.Tips({
  242. title: res.msg
  243. });
  244. });
  245. }
  246. },
  247. closeDrawer(){
  248. this.showInput = false;
  249. }
  250. }
  251. }
  252. </script>
  253. <style>
  254. .cart_border {
  255. border: 1px solid var(--view-theme);
  256. }
  257. .text-primary-con {
  258. color: var(--view-theme);
  259. }
  260. .text_score {
  261. color: #FAAD14;
  262. }
  263. .store_badge {
  264. width: 48rpx;
  265. height: 26rpx;
  266. background: #FAAD14;
  267. border-radius: 4rpx;
  268. color: #fff;
  269. margin-left: 8rpx;
  270. }
  271. .drawer-text{
  272. padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  273. }
  274. .pro_name::before {
  275. content: '';
  276. width: 1px;
  277. height: 18rpx;
  278. background-color: #ccc;
  279. position: absolute;
  280. left: -20rpx;
  281. top: 8rpx;
  282. }
  283. .reply_box~.reply_box {
  284. border-top: 1px solid #ddd;
  285. }
  286. .reply-confirm-btn{
  287. position: absolute;
  288. bottom: 10rpx;
  289. right: 14rpx;
  290. }
  291. </style>