view.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <gracePage :customHeader="false">
  3. <view class="container" slot="gBody">
  4. <drawerPage :show="drawer.show ? 'left' : ''">
  5. <view class="container_main" slot="links">
  6. <swiper class="swiper" @change="change" :circular="swiper.circular" :current="index">
  7. <swiper-item v-for="(v, k) in fetch.items" v-if="v.data" :key="k" >
  8. <scroll-view scroll-y="true" scroll-x="true" class="scroll-height">
  9. <dream ref="dream" @showDrawer="showDrawer" :index="k" :item="v" :control="control" class="item"></dream>
  10. </scroll-view>
  11. </swiper-item>
  12. </swiper>
  13. </view>
  14. </drawerPage>
  15. <drawerWindow v-for="(v, k) in drawer.item" :key="k" :show="v.show" :zIndex="v.index" padding="v.padding" :top="v.top" direction="v.direction" :width="v.width" v-on:closeDrawer="closeDrawer(k)">
  16. <view slot="links">
  17. <block v-if="k == 'cate'">
  18. <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" :width="v.width" :param="v.param"></cate>
  19. </block>
  20. <block v-if="k == 'community'">
  21. <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" :width="v.width" :param="v.param"></community>
  22. </block>
  23. </view>
  24. </drawerWindow>
  25. <y-Fab v-if="!drawer.show && fetch.user.avatar" :bottom="20" :right="20" :btnList="drawer.button" @click="clickDrawerButton" :text="`P`+(swiper.index+1)" :icon_o="fetch.user.avatar"></y-Fab>
  26. </view>
  27. </gracePage>
  28. </template>
  29. <script>
  30. import cate from "@/pages/dream/view/cate.vue";
  31. import community from "@/pages/dream/view/community.vue";
  32. import dream from "@/pages/dream/view/dream.vue";
  33. import drawerPage from "@/lib/dever/components/drawerPage.vue";
  34. import drawerWindow from "@/lib/dever/components/drawerWindow.vue";
  35. var graceRichText = require("@/lib/graceUI/jsTools/richText.js");
  36. export default{
  37. data() {
  38. return {
  39. id : 1,
  40. page_id : 1,
  41. index : 0,
  42. content_id : 0,
  43. swiper : {
  44. index : 0,
  45. circular : false,
  46. },
  47. fetch: {
  48. items : [],
  49. user : {},
  50. info_id : 0,
  51. page_id : 0,
  52. parent_page_id : 0,
  53. },
  54. control : {},
  55. drawer : {
  56. // 是否显示
  57. show : '',
  58. button : [],
  59. item : {
  60. cate : {
  61. show : false,
  62. index : 5,
  63. top: 0,
  64. padding: '0rpx',
  65. width : '86%',
  66. direction : 'left',
  67. param : {},
  68. button : {
  69. bgColor: '#55ff7f',
  70. text: '选集',
  71. fontSize: 28,
  72. color: '#fff'
  73. }
  74. },
  75. community : {
  76. show : false,
  77. index : 5,
  78. top: 0,
  79. padding: '0rpx',
  80. width : '86%',
  81. direction : 'left',
  82. param : {
  83. type : 3,
  84. type_id : this.content_id,
  85. },
  86. button : {
  87. bgColor: '#16C2C2',
  88. text: '御所',
  89. fontSize: 28,
  90. color: '#fff'
  91. },
  92. }
  93. }
  94. }
  95. }
  96. },
  97. onLoad(option) {
  98. this.id = option.id;
  99. this.page_id = option.page_id;
  100. this.index = option.index;
  101. this.initDrawer();
  102. this.getData();
  103. },
  104. // 重新加载
  105. onPullDownRefresh: function() {
  106. if (this.drawer.show && this.drawer.item[this.drawer.show].show == true) {
  107. this.$refs[this.drawer.show].getData();
  108. } else {
  109. this.getData();
  110. }
  111. },
  112. // 触底刷新
  113. onReachBottom: function() {
  114. console.info(222);
  115. },
  116. methods:{
  117. change : function(e) {
  118. this.swiper.index = e.detail.current;
  119. if (this.control) {
  120. var i = 0;
  121. for (i in this.control) {
  122. if (this.control[i].load) {
  123. console.info(i);
  124. if (this.swiper.index == i) {
  125. console.info('start');
  126. this.control[i].start();
  127. } else {
  128. this.control[i].stop();
  129. }
  130. }
  131. }
  132. }
  133. },
  134. view : function() {
  135. this.Dever.location('dream/view?id=1');
  136. },
  137. initDrawer : function() {
  138. var i = '';
  139. for (i in this.drawer.item) {
  140. this.drawer.item[i].button.key = i;
  141. this.drawer.button.push(this.drawer.item[i].button);
  142. }
  143. },
  144. getData : function() {
  145. var self = this;
  146. this.Dever.get(this, 'app/collection/?l=api.getContent', {id:this.id, page_id:this.page_id}, function(t) {
  147. self.getCate(t);
  148. });
  149. },
  150. getCate : function(info) {
  151. var self = this;
  152. this.Dever.get(this, 'app/collection/?l=api.category', {id:info.info_id, parent_page_id:info.parent_page_id, page_id:info.page_id, noloading:1}, function(t) {
  153. self.drawer.item['cate'].param = t;
  154. });
  155. },
  156. goIndex : function(index) {
  157. this.index = index;
  158. if (this.drawer.show) {
  159. this.closeDrawer(this.drawer.show);
  160. }
  161. },
  162. showDrawer : function(key) {
  163. this.getContentId();
  164. this.drawer.item[key].show = !this.drawer.item[key].show;
  165. if (this.drawer.show) {
  166. this.drawer.show = '';
  167. } else {
  168. this.drawer.show = key;
  169. }
  170. },
  171. closeDrawer : function(key) {
  172. this.drawer.item[key].show = false;
  173. this.drawer.show = '';
  174. },
  175. getContentId : function() {
  176. this.content_id = this.fetch.items[this.swiper.index].id;
  177. },
  178. clickDrawerButton : function(e) {
  179. this.showDrawer(this.drawer.button[e.index].key);
  180. }
  181. },
  182. components:{
  183. dream,cate,community,drawerPage,drawerWindow
  184. }
  185. }
  186. </script>
  187. <style>
  188. .container {
  189. position: absolute;
  190. height: 100%;
  191. width: 100%;
  192. left: 0;
  193. top: 0;
  194. -webkit-overflow-scrolling: touch;
  195. }
  196. .container_main {
  197. width: 750rpx;
  198. height: 100%;
  199. }
  200. .swiper {
  201. width: 750rpx;
  202. height: 100%;
  203. }
  204. swiper-item>view{
  205. height: 100%;
  206. }
  207. swiper-item image{
  208. width: 750rpx;
  209. height: 100%;
  210. }
  211. .scroll-height {
  212. height:100%;
  213. }
  214. </style>