index.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view class="container cart clearfix">
  3. <cart ref="cart" :pathType='pathType'></cart>
  4. </view>
  5. </template>
  6. <script>
  7. import { mapState,mapMutations } from 'vuex';
  8. import cart from './components/index.vue'
  9. export default{
  10. components:{
  11. cart
  12. },
  13. data(){
  14. return{
  15. nvabarData: {//顶部自定义导航
  16. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  17. showSearch: 0,
  18. title: '购物车', // 导航栏 中间的标题
  19. },
  20. headerBtnPosi:this.setHeaderBtnPosi(),//获取设备顶部胶囊高度
  21. systeminfo:this.setSysteminfo(), //获取设备信息
  22. CustomBar:this.CustomBar,// 顶部导航栏高度
  23. isIphoneX:this.$store.state.isIphoneX,
  24. isShowComponents:false,
  25. pathType:1
  26. }
  27. },
  28. onLoad(){
  29. this.isShowComponents = true;
  30. },
  31. computed: {
  32. ...mapState(['hasLogin','userInfo','isWxAuthorize'])
  33. },
  34. methods:{
  35. setHeaderBtnPosi(){
  36. // 获得胶囊按钮位置信息
  37. let headerBtnPosi = uni.getMenuButtonBoundingClientRect();
  38. return headerBtnPosi
  39. },
  40. setSysteminfo(){
  41. let systeminfo;
  42. uni.getSystemInfo({ // 获取设备信息
  43. success: (res) => {
  44. systeminfo = res
  45. },
  46. })
  47. return systeminfo
  48. }
  49. },
  50. onPullDownRefresh() {//下拉刷新
  51. this.$refs.cart.initData()
  52. uni.stopPullDownRefresh()
  53. },
  54. onShow(){
  55. if(this.hasLogin){
  56. this.$refs.cart.initData()
  57. }else{
  58. this.$api.redirectTo('/pages/login/login')
  59. }
  60. },
  61. }
  62. </script>
  63. <style lang="scss">
  64. </style>