evaluate.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template name="evaluate">
  2. <!-- 供应商信息 -->
  3. <view class="evaluate clearfix">
  4. <view class="evaluate-header">评价({{evaluateList.length}})</view>
  5. <view class="evaluate-empty" v-if="isEmpty">该商品暂无评价</view>
  6. <view class="evaluate-list" v-else>
  7. <scroll-view scroll-y :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower">
  8. <view class="row-list" v-for="(item, index) in evaluateList" :key="index">
  9. <view class="list-title">
  10. <view class="name">{{item.name}}</view>
  11. <view class="stars">
  12. <uni-stars :stars="item.score2" :icon-class='iconClass' :icon-color='iconColor' :font-size='36' :width-info="178"></uni-stars>
  13. </view>
  14. </view>
  15. <view class="list-content">
  16. {{item.commentContent}}
  17. </view>
  18. <view class="list-time">
  19. <text>{{item.postTime }}</text>
  20. </view>
  21. </view>
  22. <!--加载loadding-->
  23. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  24. <tui-nomore :visible="!pullUpOn" bgcolor="#FFFFFF" :text='nomoreText'></tui-nomore>
  25. <!--加载loadding-->
  26. </scroll-view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import authorize from '@/common/config/authorize.js'
  32. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  33. import tuiNomore from "@/components/tui-components/nomore/nomore"
  34. import uniStars from '@/components/uni-stars/uni-stars.vue'
  35. import { queryEvaluate } from "@/api/product.js"
  36. export default{
  37. name:'evaluate',
  38. props:{
  39. queryProductid: {
  40. // Unistars类型
  41. type: Number,
  42. default: 0
  43. }
  44. },
  45. components:{
  46. tuiLoadmore,
  47. tuiNomore,
  48. uniStars
  49. },
  50. data() {
  51. return{
  52. evaluateList:[],
  53. iconClass:'icon-aixin',
  54. iconColor:'#FF7800',
  55. isEmpty:false,
  56. pageNum:1,
  57. pageSize:10,
  58. hasNextPage:false,
  59. loadding: false,
  60. pullUpOn: true,
  61. nomoreText: '上拉显示更多',
  62. productID:'',
  63. scrollHeight: '',
  64. }
  65. },
  66. created() {
  67. this.productID = this.queryProductid
  68. this.infoEvaluate()
  69. this.setScrollHeight();
  70. },
  71. methods:{
  72. infoEvaluate(){
  73. queryEvaluate({productID:this.productID,pageNum:this.pageNum,pageSize:this.pageSize}).then(response =>{
  74. let responseData = response.data
  75. if(responseData.results&&responseData.results.length > 0){
  76. this.isEmpty = false
  77. this.hasNextPage = responseData.hasNextPage
  78. this.evaluateList =responseData.results
  79. this.pullFlag = false;
  80. setTimeout(()=>{this.pullFlag = true;},500)
  81. if(this.hasNextPage){
  82. this.pullUpOn = false
  83. this.nomoreText = '上拉显示更多'
  84. }else{
  85. this.pullUpOn = true
  86. this.loadding = false
  87. this.nomoreText = '已至底部'
  88. }
  89. }else{
  90. this.isEmpty = true
  91. }
  92. }).catch(response =>{
  93. this.$util.msg(response.msg,2000)
  94. })
  95. },
  96. getOnReachBottomData(){
  97. this.pageNum+=1
  98. let params = {productID:this.productID,pageNum:this.pageNum,pageSize:this.pageSize}
  99. queryEvaluate(params).then(response =>{
  100. let responseData = response.data
  101. if(responseData.results&&responseData.results.length > 0){
  102. this.hasNextPage = responseData.hasNextPage
  103. this.evaluateList = this.evaluateList.concat(responseData.results)
  104. this.pullFlag = false;// 防上拉暴滑
  105. setTimeout(()=>{this.pullFlag = true;},500)
  106. if(this.hasNextPage){
  107. this.pullUpOn = false
  108. this.nomoreText = '上拉显示更多'
  109. }else{
  110. this.pullUpOn = false
  111. this.loadding = false
  112. this.nomoreText = '已至底部'
  113. }
  114. }
  115. }).catch(response =>{
  116. this.$util.msg(response.msg,2000)
  117. })
  118. },
  119. scrolltolower() {
  120. if(this.hasNextPage){
  121. this.loadding = true
  122. this.pullUpOn = true
  123. this.getOnReachBottomData(this.currentTab);
  124. }
  125. },
  126. setScrollHeight() {
  127. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  128. this.windowHeight = windowHeight - 1;
  129. this.scrollHeight = windowHeight - 1;
  130. }
  131. },
  132. }
  133. </script>
  134. <style lang="scss">
  135. .evaluate{
  136. background: #FFFFFF;
  137. width: 100%;
  138. .scoll-y {
  139. height: 100%;
  140. }
  141. .evaluate-empty{
  142. width: 702rpx;
  143. height: 100rpx;
  144. line-height: 100rpx;
  145. padding: 0 24rpx;
  146. font-size: $font-size-32;
  147. color: #999999;
  148. text-align: center;
  149. }
  150. .evaluate-header{
  151. width: 702rpx;
  152. height: 88rpx;
  153. line-height: 88rpx;
  154. padding: 0 24rpx;
  155. font-size: $font-size-32;
  156. color: $text-color;
  157. border-bottom: 1px solid #F2F2F2;
  158. text-align: left;
  159. }
  160. .evaluate-list{
  161. width: 702rpx;
  162. height: auto;
  163. padding: 24rpx;
  164. .row-list{
  165. width: 100%;
  166. height: auto;
  167. float: left;
  168. padding: 15rpx 0;
  169. border-bottom: 1px solid #F2F2F2;
  170. &:last-child{
  171. margin-bottom: 30rpx;
  172. }
  173. .list-title{
  174. height: 40rpx;
  175. line-height: 40rpx;
  176. font-size: $font-size-28;
  177. color: $text-color;
  178. padding: 20rpx 0;
  179. .name{
  180. float: left;
  181. margin-right: 30rpx;
  182. }
  183. .stars{
  184. width: 178rpx;
  185. float: right;
  186. }
  187. }
  188. .list-content{
  189. width: 100%;
  190. min-height: 80rpx;
  191. height: auto;
  192. font-size: $font-size-24;
  193. line-height: 30rpx;
  194. text-align: justify;
  195. padding: 10rpx 0;
  196. color: #999999;
  197. }
  198. .list-time{
  199. width: 100%;
  200. height: 40rpx;
  201. font-size: $font-size-24;
  202. line-height: 40rpx;
  203. text-align: right;
  204. color: #999999;
  205. }
  206. }
  207. }
  208. }
  209. </style>