view.vue 4.2 KB

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