view.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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" :content_id="content_id" :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" :content_id="content_id" :info_id="fetch.info_id" :page_id="fetch.page_id" :parent_page_id="fetch.parent_page_id" :type="community_drawer.type" :type_id="content_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. content_id : 0,
  36. swiper : {
  37. index : 0,
  38. circular : false,
  39. },
  40. fetch: {
  41. items : [],
  42. info_id : 0,
  43. page_id : 0,
  44. parent_page_id : 0,
  45. },
  46. control : {},
  47. cate_drawer : {
  48. index : 5,
  49. top: 0,
  50. padding: '0rpx',
  51. show : false,
  52. },
  53. community_drawer : {
  54. index : 5,
  55. top: 0,
  56. padding: '0rpx',
  57. show : false,
  58. type : 3,
  59. },
  60. }
  61. },
  62. onLoad(option) {
  63. this.id = option.id;
  64. this.page_id = option.page_id;
  65. this.index = option.index;
  66. this.getData();
  67. },
  68. // 重新加载
  69. onPullDownRefresh: function() {
  70. if (this.cate_drawer.show == true) {
  71. this.$refs.cate.getData();
  72. } else if (this.community_drawer.show == true) {
  73. this.$refs.community.getData();
  74. } else {
  75. this.getData();
  76. }
  77. },
  78. methods:{
  79. change : function(e) {
  80. this.swiper.index = e.detail.current;
  81. if (this.control) {
  82. var i = 0;
  83. for (i in this.control) {
  84. if (this.control[i].load) {
  85. console.info(i);
  86. if (this.swiper.index == i) {
  87. console.info('start');
  88. this.control[i].start();
  89. } else {
  90. this.control[i].stop();
  91. }
  92. }
  93. }
  94. }
  95. if (this.swiper.index == this.fetch.items.length - 1) {
  96. //this.$refs.dream[this.swiper.index].setShow();
  97. }
  98. },
  99. view : function() {
  100. this.Dever.location('dream/view?id=1');
  101. },
  102. getData : function() {
  103. this.Dever.get(this, 'app/collection/?l=api.getContent', {id:this.id, page_id:this.page_id});
  104. },
  105. goIndex : function(index) {
  106. this.index = index;
  107. this.closeCate();
  108. this.closeCommunity();
  109. var dream = this.$refs.dream[this.swiper.index];
  110. dream.setShow();
  111. },
  112. cate : function() {
  113. this.getContentId();
  114. this.cate_drawer.show = !this.cate_drawer.show;
  115. },
  116. closeCate : function() {
  117. this.cate_drawer.show = false;
  118. },
  119. community : function() {
  120. this.getContentId();
  121. this.community_drawer.show = !this.community_drawer.show;
  122. },
  123. closeCommunity : function() {
  124. this.community_drawer.show = false;
  125. },
  126. getContentId : function() {
  127. this.content_id = this.fetch.items[this.swiper.index].id;
  128. }
  129. },
  130. components:{
  131. dream,cate,community
  132. }
  133. }
  134. </script>
  135. <style>
  136. .container {
  137. position: absolute;
  138. height: 100%;
  139. width: 100%;
  140. left: 0;
  141. top: 0;
  142. -webkit-overflow-scrolling: touch;
  143. }
  144. .swiper {
  145. width: 750rpx;
  146. height: 100%;
  147. }
  148. swiper-item>view{
  149. height: 100%;
  150. }
  151. swiper-item image{
  152. width: 750rpx;
  153. height: 100%;
  154. }
  155. .scroll-height {
  156. height:100%;
  157. }
  158. </style>