ProductDesc.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="div ui-detail" id="mbBody" ref="mbBody">
  3. <view class="title"><text class="border"></text><text class="titleinfo">宝贝详情</text><text class="border"></text></view>
  4. <view class="div">
  5. <desc-item
  6. :mbBody="mbBody"
  7. :detailInfo="detailInfo"
  8. v-if="detailInfo"
  9. ></desc-item>
  10. </view>
  11. <v-back-top v-if="isshowBacktop" :target="target"></v-back-top>
  12. </view>
  13. </template>
  14. <script>
  15. import { mapState } from 'vuex'
  16. import DescItem from './DescItem'
  17. import BackTop from './DetailBackTop'
  18. export default {
  19. data () {
  20. return {
  21. isshowBacktop: false
  22. }
  23. },
  24. mounted () {
  25. addEventListener('scroll', this.handleScroll, true)
  26. },
  27. components: {
  28. 'desc-item': DescItem,
  29. 'v-back-top': BackTop
  30. },
  31. computed: mapState({
  32. detailInfo: state => state.goodsdetail.detailInfo,
  33. mbBody: state => state.goodsdetail.mbBody
  34. }),
  35. methods: {
  36. handleScroll() {
  37. let mbBodytop = 0
  38. let query = uni.createSelectorQuery().in(this)
  39. query.select('#mbBody').boundingClientRect(data =>{
  40. mbBodytop = data.top
  41. }).exec();
  42. this.$emit('mbBodytop',mbBodytop);
  43. },
  44. }
  45. }
  46. </script>
  47. <style lang="scss" scoped>
  48. .ui-detail {
  49. margin: .5rem 0;
  50. min-height: 10rem;
  51. position: relative;
  52. .title{
  53. font-size: .8rem;
  54. text-align: center;
  55. padding: 0.3rem 0;
  56. display: flex;
  57. align-items: center;
  58. justify-content: center;
  59. .border{
  60. width: 3rem;
  61. height: 1px;
  62. background-color: #eee;
  63. margin: 0 .5rem;
  64. }
  65. }
  66. }
  67. </style>