evaluate.vue 5.1 KB

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