InfoGoodsReview.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!-- Goodsreview.vue -->
  2. <template>
  3. <view
  4. id="review"
  5. ref="review"
  6. class="div ui-review-wrapper ui-detail-common"
  7. @click="getGoodsEvaluation()"
  8. >
  9. <view class="div main-content"><flex-line :is-link="true" :show-border="true"><text class="span line-name">评价</text></flex-line></view>
  10. <view class="div goods-review-body">
  11. <review-list :list="reviewList"></review-list>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import { urlencode } from '@/util/common'
  17. import ReviewList from './ReviewList'
  18. import flexLine from '../../../flexLine'
  19. import { getReviewList } from '../../../../api/homegoodsdetail'
  20. import { mapState, mapMutations } from 'vuex'
  21. export default {
  22. data () {
  23. return {
  24. reviewList: []
  25. }
  26. },
  27. computed: {
  28. ...mapState({
  29. currentProductId: state => state.goodsdetail.currentProductId
  30. })
  31. },
  32. components: {
  33. flexLine,
  34. ReviewList
  35. },
  36. created () {
  37. this.getReviewList()
  38. },
  39. mounted () {
  40. addEventListener('scroll', this.handleScroll, true)
  41. },
  42. methods: {
  43. ...mapMutations({
  44. changeIndex: 'changeIndex'
  45. }),
  46. getReviewList () {
  47. getReviewList(this.currentProductId,'',1).then(res => {
  48. if (res) {
  49. this.reviewList = res.result.goods_eval_list
  50. }
  51. })
  52. },
  53. /* 评论 */
  54. getGoodsEvaluation () {
  55. uni.navigateTo({ url: '/pages/home/goodsdetail/GoodsEvaluation'+'?'+urlencode( { 'goods_id': this.currentProductId } )})
  56. },
  57. handleScroll() {
  58. let reviewtop = 0
  59. let query = uni.createSelectorQuery().in(this)
  60. query.select('#review').boundingClientRect(data =>{
  61. reviewtop = data.top
  62. }).exec();
  63. this.$emit('reviewtop',reviewtop);
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .main-content{padding:0 $pageSpace;background-color: #fff;}
  70. .ui-review-wrapper {
  71. .goods-review-body {
  72. background: #ffffff;
  73. }
  74. }
  75. </style>