view.vue 8.5 KB

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