evaluate.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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/authorize.js'
  32. export default{
  33. name:'evaluate',
  34. props:{
  35. queryProductid: {
  36. // Unistars类型
  37. type: Number,
  38. default: 0
  39. }
  40. },
  41. data() {
  42. return{
  43. evaluateList:[],
  44. iconClass:'icon-aixin',
  45. iconColor:'#FF7800',
  46. isEmpty:false,
  47. pageNum:1,
  48. pageSize:10,
  49. hasNextPage:false,
  50. loadding: false,
  51. pullUpOn: true,
  52. nomoreText: '上拉显示更多',
  53. productID:'',
  54. scrollHeight: '',
  55. }
  56. },
  57. created() {
  58. this.productID = this.queryProductid
  59. this.infoEvaluate()
  60. this.setScrollHeight();
  61. },
  62. methods:{
  63. infoEvaluate(){
  64. this.ProductService.GetProductEvaluate({productID:this.productID,pageNum:this.pageNum,pageSize:this.pageSize}).then(response =>{
  65. let responseData = response.data
  66. if(responseData.results&&responseData.results.length > 0){
  67. this.isEmpty = false
  68. this.hasNextPage = responseData.hasNextPage
  69. this.evaluateList =responseData.results
  70. this.pullFlag = false;
  71. setTimeout(()=>{this.pullFlag = true;},500)
  72. if(this.hasNextPage){
  73. this.pullUpOn = false
  74. this.nomoreText = '上拉显示更多'
  75. }else{
  76. this.pullUpOn = true
  77. this.loadding = false
  78. this.nomoreText = '已至底部'
  79. }
  80. }else{
  81. this.isEmpty = true
  82. }
  83. }).catch(error =>{
  84. this.$util.msg(error.msg,2000)
  85. })
  86. },
  87. getOnReachBottomData(){
  88. this.pageNum+=1
  89. let params = {productID:this.productID,pageNum:this.pageNum,pageSize:this.pageSize}
  90. this.ProductService.GetProductEvaluate(params).then(response =>{
  91. let responseData = response.data
  92. if(responseData.results&&responseData.results.length > 0){
  93. this.hasNextPage = responseData.hasNextPage
  94. this.evaluateList = this.evaluateList.concat(responseData.results)
  95. this.pullFlag = false;// 防上拉暴滑
  96. setTimeout(()=>{this.pullFlag = true;},500)
  97. if(this.hasNextPage){
  98. this.pullUpOn = false
  99. this.nomoreText = '上拉显示更多'
  100. }else{
  101. this.pullUpOn = false
  102. this.loadding = false
  103. this.nomoreText = '已至底部'
  104. }
  105. }
  106. }).catch(error =>{
  107. this.$util.msg(error.msg,2000)
  108. })
  109. },
  110. scrolltolower() {
  111. if(this.hasNextPage){
  112. this.loadding = true
  113. this.pullUpOn = true
  114. this.getOnReachBottomData(this.currentTab);
  115. }
  116. },
  117. setScrollHeight() {
  118. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  119. this.windowHeight = windowHeight - 1;
  120. this.scrollHeight = windowHeight - 1;
  121. }
  122. },
  123. }
  124. </script>
  125. <style lang="scss">
  126. .evaluate{
  127. background: #FFFFFF;
  128. width: 100%;
  129. .scoll-y {
  130. height: 100%;
  131. }
  132. .evaluate-empty{
  133. width: 702rpx;
  134. height: 100rpx;
  135. line-height: 100rpx;
  136. padding: 0 24rpx;
  137. font-size: $font-size-28;
  138. color: #999999;
  139. text-align: center;
  140. }
  141. .evaluate-header{
  142. width: 702rpx;
  143. height: 88rpx;
  144. line-height: 88rpx;
  145. padding: 0 24rpx;
  146. font-size: $font-size-32;
  147. color: $text-color;
  148. border-bottom: 1px solid #F2F2F2;
  149. text-align: left;
  150. }
  151. .evaluate-list{
  152. width: 702rpx;
  153. height: auto;
  154. padding: 24rpx;
  155. .row-list{
  156. width: 100%;
  157. height: auto;
  158. float: left;
  159. padding: 15rpx 0;
  160. border-bottom: 1px solid #F2F2F2;
  161. &:last-child{
  162. margin-bottom: 30rpx;
  163. }
  164. .list-title{
  165. height: 40rpx;
  166. line-height: 40rpx;
  167. font-size: $font-size-28;
  168. color: $text-color;
  169. padding: 20rpx 0;
  170. .name{
  171. float: left;
  172. margin-right: 30rpx;
  173. }
  174. .stars{
  175. width: 178rpx;
  176. float: right;
  177. }
  178. }
  179. .list-content{
  180. width: 100%;
  181. min-height: 80rpx;
  182. height: auto;
  183. font-size: $font-size-24;
  184. line-height: 30rpx;
  185. text-align: justify;
  186. padding: 10rpx 0;
  187. color: #999999;
  188. }
  189. .list-time{
  190. width: 100%;
  191. height: 40rpx;
  192. font-size: $font-size-24;
  193. line-height: 40rpx;
  194. text-align: right;
  195. color: #999999;
  196. }
  197. }
  198. }
  199. }
  200. </style>