evaluate.vue 5.3 KB

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