view.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <gracePage :customHeader="false">
  3. <view class="container" slot="gBody">
  4. <swiper class="swiper" @change="change" :circular="swiper.circular" :current="index">
  5. <swiper-item v-for="(v, k) in fetch.items" v-if="v.data" :key="k" >
  6. <scroll-view scroll-y="true" scroll-x="true" class="scroll-height">
  7. <dream ref="dream" @cate="cate" @community="community" :index="k" :item="v" :control="control" class="item"></dream>
  8. </scroll-view>
  9. </swiper-item>
  10. </swiper>
  11. <graceDrawer :show="cate_drawer.show" :zIndex="cate_drawer.index" padding="cate_drawer.padding" :top="cate_drawer.top" direction="left" width="100%" v-on:closeDrawer="closeCate">
  12. <view slot="links">
  13. <cate ref="cate" @goIndex="goIndex" :index="index" :info_id="fetch.info_id" :page_id="fetch.page_id" :parent_page_id="fetch.parent_page_id"></cate>
  14. </view>
  15. </graceDrawer>
  16. <graceDrawer :show="community_drawer.show" :zIndex="community_drawer.index" padding="community_drawer.padding" :top="community_drawer.top" direction="right" width="100%" v-on:closeDrawer="closeCommunity">
  17. <view slot="links">
  18. <community ref="community" @goIndex="goIndex" :index="index" :info_id="fetch.info_id" :page_id="fetch.page_id" :parent_page_id="fetch.parent_page_id"></community>
  19. </view>
  20. </graceDrawer>
  21. </view>
  22. </gracePage>
  23. </template>
  24. <script>
  25. import cate from "@/pages/dream/view/cate.vue";
  26. import community from "@/pages/dream/view/community.vue";
  27. import dream from "@/pages/dream/view/dream.vue";
  28. var graceRichText = require("@/lib/graceUI/jsTools/richText.js");
  29. export default{
  30. data() {
  31. return {
  32. id : 1,
  33. page_id : 1,
  34. index : 0,
  35. swiper : {
  36. index : 0,
  37. circular : false,
  38. },
  39. fetch: {
  40. items : [],
  41. info_id : 0,
  42. page_id : 0,
  43. parent_page_id : 0,
  44. },
  45. control : {},
  46. cate_drawer : {
  47. index : 5,
  48. top: 0,
  49. padding: '0rpx',
  50. show : false,
  51. },
  52. community_drawer : {
  53. index : 5,
  54. top: 0,
  55. padding: '0rpx',
  56. show : false,
  57. },
  58. }
  59. },
  60. onLoad(option) {
  61. this.id = option.id;
  62. this.page_id = option.page_id;
  63. this.index = option.index;
  64. this.getData();
  65. },
  66. // 重新加载
  67. onPullDownRefresh: function() {
  68. if (this.cate_drawer.show == true) {
  69. this.$refs.cate.getData();
  70. } else if (this.community_drawer.show == true) {
  71. this.$refs.community.getData();
  72. } else {
  73. this.getData();
  74. }
  75. },
  76. methods:{
  77. change : function(e) {
  78. this.swiper.index = e.detail.current;
  79. if (this.control) {
  80. var i = 0;
  81. for (i in this.control) {
  82. if (this.control[i].load) {
  83. console.info(i);
  84. if (this.swiper.index == i) {
  85. console.info('start');
  86. this.control[i].start();
  87. } else {
  88. this.control[i].stop();
  89. }
  90. }
  91. }
  92. }
  93. if (this.swiper.index == this.fetch.items.length - 1) {
  94. //this.$refs.dream[this.swiper.index].setShow();
  95. }
  96. },
  97. view : function() {
  98. this.Dever.location('dream/view?id=1');
  99. },
  100. getData : function() {
  101. this.Dever.get(this, 'app/collection/?l=api.getContent', {id:this.id, page_id:this.page_id});
  102. },
  103. goIndex : function(index) {
  104. this.index = index;
  105. this.closeCate();
  106. this.closeCommunity();
  107. var dream = this.$refs.dream[this.swiper.index];
  108. dream.setShow();
  109. },
  110. cate : function() {
  111. this.cate_drawer.show = !this.cate_drawer.show;
  112. },
  113. closeCate : function() {
  114. this.cate_drawer.show = false;
  115. },
  116. community : function() {
  117. this.community_drawer.show = !this.community_drawer.show;
  118. },
  119. closeCommunity : function() {
  120. this.community_drawer.show = false;
  121. },
  122. },
  123. components:{
  124. dream,cate,community
  125. }
  126. }
  127. </script>
  128. <style>
  129. .container {
  130. position: absolute;
  131. height: 100%;
  132. width: 100%;
  133. left: 0;
  134. top: 0;
  135. -webkit-overflow-scrolling: touch;
  136. }
  137. .swiper {
  138. width: 750rpx;
  139. height: 100%;
  140. }
  141. swiper-item>view{
  142. height: 100%;
  143. }
  144. swiper-item image{
  145. width: 750rpx;
  146. height: 100%;
  147. }
  148. .scroll-height {
  149. height:100%;
  150. }
  151. </style>