view.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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.getData();
  102. },
  103. // 重新加载
  104. onPullDownRefresh: function() {
  105. if (this.drawer.show && this.drawer.item[this.drawer.show].show == true) {
  106. this.$refs[this.drawer.show].getData();
  107. } else {
  108. this.getData();
  109. }
  110. },
  111. // 触底刷新
  112. onReachBottom: function() {
  113. console.info(222);
  114. },
  115. methods:{
  116. change : function(e) {
  117. this.swiper.index = e.detail.current;
  118. if (this.control) {
  119. var i = 0;
  120. for (i in this.control) {
  121. if (this.control[i].load) {
  122. console.info(i);
  123. if (this.swiper.index == i) {
  124. console.info('start');
  125. this.control[i].start();
  126. } else {
  127. this.control[i].stop();
  128. }
  129. }
  130. }
  131. }
  132. },
  133. view : function() {
  134. this.Dever.location('dream/view?id=1');
  135. },
  136. initDrawer : function() {
  137. var i = '';
  138. for (i in this.drawer.item) {
  139. this.drawer.item[i].button.key = i;
  140. this.drawer.button.push(this.drawer.item[i].button);
  141. }
  142. },
  143. getData : function() {
  144. var self = this;
  145. self.drawer.item = {};
  146. this.Dever.get(this, 'app/collection/?l=api.getContent', {id:this.id, page_id:this.page_id}, function(t) {
  147. if (t && t['func']) {
  148. self.drawer.item = t['func'];
  149. self.initDrawer();
  150. if (t['func']['cate']) {
  151. self.getCate(t);
  152. }
  153. }
  154. });
  155. },
  156. getCate : function(info) {
  157. var self = this;
  158. 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) {
  159. self.drawer.item['cate'].param = t;
  160. });
  161. },
  162. goIndex : function(index) {
  163. this.index = index;
  164. if (this.drawer.show) {
  165. this.closeDrawer(this.drawer.show);
  166. }
  167. },
  168. showDrawer : function(key) {
  169. this.getContentId();
  170. this.drawer.item[key].show = !this.drawer.item[key].show;
  171. if (this.drawer.show) {
  172. this.drawer.show = '';
  173. } else {
  174. this.drawer.show = key;
  175. }
  176. },
  177. closeDrawer : function(key) {
  178. this.drawer.item[key].show = false;
  179. this.drawer.show = '';
  180. },
  181. getContentId : function() {
  182. this.content_id = this.fetch.items[this.swiper.index].id;
  183. },
  184. clickDrawerButton : function(e) {
  185. this.showDrawer(this.drawer.button[e.index].key);
  186. }
  187. },
  188. components:{
  189. dream,cate,community,drawerPage,drawerWindow
  190. }
  191. }
  192. </script>
  193. <style>
  194. .container {
  195. position: absolute;
  196. height: 100%;
  197. width: 100%;
  198. left: 0;
  199. top: 0;
  200. -webkit-overflow-scrolling: touch;
  201. }
  202. .container_main {
  203. width: 750rpx;
  204. height: 100%;
  205. }
  206. .swiper {
  207. width: 750rpx;
  208. height: 100%;
  209. }
  210. swiper-item>view{
  211. height: 100%;
  212. }
  213. swiper-item image{
  214. width: 750rpx;
  215. height: 100%;
  216. }
  217. .scroll-height {
  218. height:100%;
  219. }
  220. </style>