ProductReview.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <!-- Evaluation.vue -->
  2. <template>
  3. <view class="scroll-view-wrapper div ui-evaluation" style="height:100%">
  4. <view class="div ui-evaluation-header">
  5. <view class="div flex-header">
  6. <view class="div"
  7. v-for="(item, index) in staticData"
  8. v-bind:key="item.id"
  9. v-bind:class="{ active: currentTag == item.value }"
  10. v-on:click="changeTab(item.value, item.grade)"
  11. >
  12. {{ item.name }}
  13. </view>
  14. </view>
  15. </view>
  16. <view class="scroll-view div" style="position:relative">
  17. <scroll-view
  18. style="position: absolute;top:0;right:0;left:0;bottom:0"
  19. class="div ui-evaluation-body"
  20. @scrolltolower="loadMore"
  21. scroll-y="true"
  22. >
  23. <view
  24. class="div list"
  25. v-for="(item, index) in reviewList"
  26. v-if="reviewList.length > 0"
  27. :key="index"
  28. >
  29. <view class="div item">
  30. <view class="span">
  31. <image mode="aspectFit" class="img avatar" :src="item.member_avatar" />
  32. {{ item.geval_isanonymous?'匿名':item.geval_frommembername }}
  33. <view class="span"
  34. v-bind:class="{
  35. 'good-review': item.geval_scores > 3,
  36. 'medium-review': item.geval_scores > 1,
  37. 'bad-review': item.geval_scores == 1
  38. }"
  39. >{{ getGrade(item.geval_scores) }}</view
  40. >
  41. </view>
  42. <text class="span">{{ getTime(item.geval_addtime) }}</text>
  43. </view>
  44. <view class="p" v-if="item.geval_content">{{ item.geval_content }}</view>
  45. <view class="p" v-if="!item.geval_content">无评价信息</view>
  46. <view class="p explain" v-if="item.geval_explain">掌柜回复:{{ item.geval_explain }}</view>
  47. <view class="div geval-image-list" v-if="item.geval_image && item.geval_image.length">
  48. <view class="div geval-image-item" v-for="(image,i) in item.geval_image" :key="i">
  49. <view class="div image-wrapper"><image mode="aspectFit" class="img image" :src="image" @click="openImage(image)" /></view>
  50. </view>
  51. </view>
  52. </view>
  53. </scroll-view>
  54. <view class="div list-empty" v-if="reviewList.length <= 0">
  55. <view class="div iconfont empty-icon">&#xe636;</view>
  56. <view class="p">本商品暂无评价</view>
  57. </view>
  58. </view>
  59. <uni-popup ref="isshow" class="popup" >
  60. <image mode="aspectFit" class="img" :src="showimage" :style="getBannerStyle" @click="hidePopup('isshow')">
  61. </uni-popup>
  62. </view>
  63. </template>
  64. <script>
  65. import { evaluation } from '../static'
  66. import { getReviewList } from '../../../../api/homegoodsdetail'
  67. export default {
  68. data () {
  69. return {
  70. showimage: '',
  71. staticData: evaluation,
  72. id: this.$store.state.goodsdetail.currentProductId
  73. ? this.$store.state.goodsdetail.currentProductId
  74. : '',
  75. currentTag: 'total',
  76. grade: 0,
  77. subTotal: {},
  78. reviewList: [],
  79. page: 0,
  80. loading: false,
  81. hasmore: true
  82. }
  83. },
  84. created () {
  85. this.loadMore()
  86. },
  87. computed: {
  88. getBannerStyle: function () {
  89. const res = uni.getSystemInfoSync()
  90. var width = res.windowWidth
  91. var height = res.windowHeight
  92. let itemWidth = width
  93. let itemHeight = height
  94. return "width:"+itemWidth +"px;height:"+itemHeight +"px"
  95. }
  96. },
  97. methods:{
  98. showPopup(id){
  99. this.$refs[id].open()
  100. },
  101. hidePopup(id){
  102. this.$refs[id].close()
  103. },
  104. openImage (src) {
  105. this.showimage = src
  106. this.isshow = true
  107. },
  108. loadMore () {
  109. if(this.loading){
  110. return
  111. }
  112. this.loading = true
  113. if (this.hasmore) {
  114. this.page = ++this.page
  115. this.getReviewList(true)
  116. }
  117. },
  118. getReviewList (ispush) {
  119. getReviewList(this.id, this.grade, 10, this.page).then(res => {
  120. this.loading = false
  121. if (res) {
  122. if (ispush) {
  123. this.reviewList = this.reviewList.concat(res.result.goods_eval_list)
  124. } else {
  125. this.reviewList = res.result.goods_eval_list
  126. }
  127. this.hasmore = res.result.hasmore
  128. }
  129. })
  130. },
  131. changeTab (value, grade) {
  132. this.currentTag = value
  133. this.grade = grade
  134. this.getReviewList(false)
  135. },
  136. getGrade (grade) {
  137. if (grade == 1) {
  138. return '差评'
  139. } else if (grade > 3) {
  140. return '好评'
  141. } else {
  142. return '中评'
  143. }
  144. },
  145. getTime (timestamps) {
  146. let date = new Date(timestamps * 1000)
  147. let year = date.getFullYear()
  148. let month = date.getMonth() + 1
  149. let day = date.getDate()
  150. return year + '-' + month + '-' + day
  151. }
  152. }
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .scroll-view-wrapper{display: flex;flex-direction: column;}
  157. .scroll-view{flex:1}
  158. .ui-evaluation {
  159. .ui-evaluation-header {
  160. background: #ffffff;
  161. .flex-header {
  162. width: auto;
  163. display: flex;
  164. display: -webkit-flex;
  165. display: -moz-flex;
  166. flex-basis: 100%;
  167. justify-content: space-around;
  168. align-content: center;
  169. align-items: center;
  170. height:2.2rem;
  171. .div {
  172. color: $descTextColor;
  173. font-size:$subFontSize;
  174. height:1.2rem;
  175. border: 0.5px solid #eee;
  176. padding: 0 0.45rem;
  177. line-height: 1.2rem;
  178. text-align: center;
  179. border-radius: 1.2rem;
  180. &.active {
  181. color: $primaryColor;
  182. border: 0.5px solid $primaryColor;
  183. }
  184. }
  185. }
  186. }
  187. .ui-evaluation-body {
  188. padding: 0 0.75rem;
  189. background: rgba(255, 255, 255, 1);
  190. box-sizing: border-box;
  191. .list {
  192. padding: 0.75rem 0;
  193. border-bottom: 0.5px dashed #eee;
  194. color: #333;
  195. font-size:$subFontSize;
  196. .item {
  197. overflow: hidden;
  198. padding-bottom:0.75rem;
  199. display: flex;
  200. justify-content: space-between;
  201. align-content: center;
  202. align-items: center;
  203. .avatar{width:2rem;height: 2rem;border-radius: 50%;margin-right: .3rem;}
  204. .span {
  205. &:first-child {
  206. display: flex;
  207. justify-content: space-around;
  208. align-content: center;
  209. align-items: center;
  210. .span {
  211. margin-left:0.75rem;
  212. color: #ffffff;
  213. font-size:$fontSize;
  214. }
  215. }
  216. &:last-child {
  217. color: #999999;
  218. font-size:$fontSize;
  219. }
  220. &.good-review {
  221. background: #fc2e39;
  222. width:1.8rem;
  223. height:0.8rem;
  224. text-align: center;
  225. background-size: cover;
  226. line-height:0.8rem;
  227. border-radius:0.4rem;
  228. }
  229. &.medium-review {
  230. background: $primaryColor;
  231. width:1.8rem;
  232. height:0.8rem;
  233. text-align: center;
  234. background-size: cover;
  235. line-height:0.8rem;
  236. border-radius:0.4rem;
  237. }
  238. &.bad-review {
  239. background: #c3c3c3;
  240. width:1.8rem;
  241. height:0.8rem;
  242. text-align: center;
  243. background-size: cover;
  244. line-height:0.8rem;
  245. border-radius:0.4rem;
  246. }
  247. }
  248. }
  249. .p {
  250. padding: 0;
  251. margin: 0;
  252. flex-basis: 100%;
  253. display: -webkit-box;
  254. -webkit-box-orient: vertical;
  255. -webkit-line-clamp: 2;
  256. overflow: hidden;
  257. }
  258. .explain{color:orange}
  259. }
  260. }
  261. .list-empty {
  262. position: absolute;
  263. top: 50%;
  264. left: 50%;
  265. transform: translate(-50%, -50%);
  266. text-align: center;
  267. .empty-icon{font-size:3rem;padding:1rem 0;color:#999}
  268. .img {
  269. width:2.75rem;
  270. }
  271. .p {
  272. color: #7c7f88;
  273. font-size:$subFontSize;
  274. padding: 0;
  275. margin: 0;
  276. font-weight: normal;
  277. }
  278. }
  279. .geval-image-list{overflow: hidden;margin-top:1rem;
  280. .geval-image-item{width:33.33%;height:0;padding-bottom: 33.33%;float: left;position: relative;
  281. .image-wrapper{position: absolute;left:0;right:0.1rem;top:0;bottom:0.1rem;
  282. .image{width:100%;height: 100%;}
  283. }
  284. }
  285. }
  286. }
  287. </style>