view.vue 7.0 KB

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