view.vue 7.5 KB

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