evaluate.vue 5.2 KB

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