view.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <view class="container" slot="gBody">
  3. <ourLoading isFullScreen :active="pageLoading" :text="pageLoadingText" />
  4. <view v-if="fetch.items.length > 0">
  5. <dever-drawer-page :show="drawer.show ? 'left' : ''">
  6. <view class="container_main" slot="links" @click="closeDrawer()">
  7. <block v-if="show">
  8. <view class='cover' v-if="guide" @touchstart="closeGuide()">
  9. <view class='journal-guide'>
  10. <view class='guide-center'></view>
  11. <view class='guide-bottom'></view>
  12. </view>
  13. </view>
  14. <!--
  15. <swiper class="swiper" @change="change" :circular="swiper.circular" :current="swiper.index">
  16. <swiper-item v-for="(v, k) in fetch.items" v-if="v.data" :key="k" >
  17. <scroll-view scroll-y="true" scroll-x="true" class="scroll-height" @scrolltolower="bottomCall">
  18. <dream ref="dream" @showDrawer="showDrawer" @showPage="showPage" :index="k" :item="v" :control="control" :bottom="bottom" class="item"></dream>
  19. </scroll-view>
  20. </swiper-item>
  21. </swiper>
  22. -->
  23. <dever-swiper class="swiper" @change="change" :current="swiper.index" :circular="swiper.circular" :item="fetch.items" v-slot="{k,v,i}">
  24. <scroll-view scroll-y="true" scroll-x="true" class="scroll-height" @scrolltolower="bottomCall">
  25. <dream :ref="`dream_`+k" @showDrawer="showDrawer" @showPage="showPage" :index="k" :item="v" :control="control" :bottom="bottom" class="item"></dream>
  26. </scroll-view>
  27. </dever-swiper>
  28. </block>
  29. <block v-if="!show">
  30. <dream :ref="`dream_`+swiper.index" @showDrawer="showDrawer" @showPage="showPage" :index="swiper.index" :item="fetch.items[swiper.index]" :control="control" :bottom="bottom" class="item"></dream>
  31. </block>
  32. </view>
  33. </dever-drawer-page>
  34. <dever-drawer-window 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">
  35. <view slot="links">
  36. <block v-if="k == 'cate'">
  37. <cate ref="cate" @goIndex="goIndex" :index="swiper.index" :content_id="content_id" :width="v.width" :param="v.param" :page_id="fetch.page_id" @getCate="getCate"></cate>
  38. </block>
  39. <block v-if="k == 'community'">
  40. <community ref="community" @goIndex="goIndex" :index="swiper.index" :content_id="content_id" :width="v.width" :param="v.param"></community>
  41. </block>
  42. <block v-if="k == 'times'">
  43. <times ref="times" @goIndex="goIndex" :index="swiper.index" :content_id="content_id" :width="v.width" :param="v.param" :set="v.set" :times="fetch.times_id" @getTimes="getTimes"></times>
  44. </block>
  45. <block v-if="k == 'shop'">
  46. <shop ref="shop" @goIndex="goIndex" :index="swiper.index" :content_id="content_id" :width="v.width" :param="v.param"></shop>
  47. </block>
  48. <block v-if="k == 'my'">
  49. <my ref="my" @goIndex="goIndex" :index="swiper.index" :content_id="content_id" :width="v.width" :param="v.param"></my>
  50. </block>
  51. <block v-if="k == 'share'">
  52. <share ref="share" @goIndex="goIndex" :index="swiper.index" :content_id="content_id" :width="v.width" :param="v.param" :type="type"></share>
  53. </block>
  54. </view>
  55. </dever-drawer-window>
  56. <y-Fab v-if="!drawer.show && show" :bottom="20" :right="20" :btnList="drawer.button" :bgmPlay="bgm.playing" @click="clickDrawerButton" :text="page_text" :icon_o="fetch.user.avatar"></y-Fab>
  57. <y-Fab v-if="!show" :bottom="20" :right="20" @click="goHome" :text="`更多`"></y-Fab>
  58. </view>
  59. <dever-share ref="share" :data="fetch.share" v-if="fetch.share"></dever-share>
  60. </view>
  61. </template>
  62. <script>
  63. import cate from "@/pages/dream/func/cate.vue";
  64. import community from "@/pages/dream/func/community.vue";
  65. import times from "@/pages/dream/func/times.vue";
  66. import shop from "@/pages/dream/func/shop.vue";
  67. import my from "@/pages/dream/func/my.vue";
  68. import share from "@/pages/dream/func/share.vue";
  69. import dream from "@/pages/dream/view/dream.vue";
  70. import deverDrawerPage from "@/lib/dever/components/drawerPage.vue";
  71. import deverDrawerWindow from "@/lib/dever/components/drawerWindow.vue";
  72. import deverShare from '@/lib/dever/components/share.vue';
  73. import deverSwiper from '@/lib/dever/components/swiper.vue';
  74. export default{
  75. data() {
  76. return {
  77. s:2,
  78. guide : false,
  79. bgm : {
  80. show : false,
  81. playing : false,
  82. },
  83. login : '',
  84. content_id : 0,
  85. type : -1,
  86. show : false,
  87. swiper : {
  88. index : 0,
  89. circular : true,
  90. },
  91. page_index : 0,
  92. page_text : '',
  93. fetch: {
  94. items : [],
  95. user : {},
  96. index : 0,
  97. info_id : 0,
  98. page_id : 0,
  99. page_info : {
  100. bgmusic : '',
  101. },
  102. parent_page_id : 0,
  103. times_id : 0,
  104. },
  105. control : {},
  106. bottom : {},
  107. drawer : {
  108. // 是否显示
  109. show : '',
  110. button : [],
  111. item : {
  112. cate : {
  113. show : false,
  114. index : 5,
  115. top: 0,
  116. padding: '0rpx',
  117. width : '86%',
  118. direction : 'left',
  119. param : {},
  120. button : {
  121. bgColor: '#55ff7f',
  122. text: '选集',
  123. fontSize: 28,
  124. color: '#fff'
  125. }
  126. },
  127. community : {
  128. show : false,
  129. index : 5,
  130. top: 0,
  131. padding: '0rpx',
  132. width : '86%',
  133. direction : 'left',
  134. param : {
  135. type : 3,
  136. type_id : this.content_id,
  137. },
  138. button : {
  139. bgColor: '#16C2C2',
  140. text: '社区',
  141. fontSize: 28,
  142. color: '#fff'
  143. },
  144. }
  145. }
  146. }
  147. }
  148. },
  149. onLoad(option) {
  150. if (!option.code) {
  151. this.Dever.location('index/index');
  152. return;
  153. }
  154. var g = this.Dever.data('guide');
  155. if (!g) {
  156. this.guide = true;
  157. } else {
  158. this.guide = false;
  159. }
  160. if (option && option.name) {
  161. uni.setNavigationBarTitle({
  162. title:option.name
  163. });
  164. }
  165. //this.Dever.login = 'user/login?code=' + option.code;
  166. //this.Dever.checkLogin();
  167. this.login = this.Dever.getToken();
  168. this.Dever.config.name = option.name;
  169. this.Dever.config.code = option.code;
  170. // 此处为了记录图片信息
  171. this.Dever.config.pic = {};
  172. this.Dever.config.system = uni.getSystemInfoSync();
  173. this.getData();
  174. },
  175. // 重新加载
  176. onPullDownRefresh: function() {
  177. if (this.drawer.show && this.drawer.item[this.drawer.show].show == true) {
  178. this.$refs[this.drawer.show][0].getData();
  179. } else {
  180. this.getData();
  181. }
  182. },
  183. onShow : function() {
  184. this.controlHandle();
  185. },
  186. onHide() {
  187. //this.stop();
  188. },
  189. onBackPress(e) {
  190. this.stop();
  191. },
  192. beforeDestroy() {
  193. this.stop();
  194. },
  195. methods:{
  196. closeGuide : function() {
  197. this.guide = false;
  198. this.Dever.data('guide', 2);
  199. },
  200. stop : function() {
  201. if (this.control) {
  202. var i = 0;
  203. for (i in this.control) {
  204. if (this.control[i].load) {
  205. this.control[i].stop();
  206. }
  207. }
  208. }
  209. this.Dever.bgm().stop();
  210. },
  211. // 播放背景音乐
  212. bgmControl : function() {
  213. this.Dever.bgm().control();
  214. },
  215. // 页面触底刷新
  216. bottomCall: function() {
  217. if (this.bottom && this.bottom[this.swiper.index]) {
  218. this.bottom[this.swiper.index].getData(2);
  219. }
  220. },
  221. // drawer触底刷新
  222. bottomFunc : function() {
  223. if (this.drawer.show && this.drawer.item[this.drawer.show].show == true) {
  224. this.$refs[this.drawer.show][0].getInfo(2);
  225. }
  226. },
  227. record : function(index) {
  228. if (!this.login) {
  229. return;
  230. }
  231. if (!index) {
  232. index = this.swiper.index;
  233. }
  234. var self = this;
  235. var content_id = this.fetch.items[index].id;
  236. this.Dever.post('app/user/?l=api.record', {noloading:1, code:this.Dever.config.code, index: index, content_id: content_id}, function(t) {
  237. self.Dever.config.code = t.code;
  238. if (self.Dever.source == 'h5') {
  239. }
  240. });
  241. },
  242. controlHandle : function() {
  243. if (this.control) {
  244. var i = 0;
  245. for (i in this.control) {
  246. if (this.control[i].load) {
  247. //console.info(i);
  248. if (this.swiper.index == i) {
  249. //console.info('start');
  250. this.Dever.bgm().stop();
  251. this.control[i].start();
  252. } else {
  253. this.control[i].stop();
  254. }
  255. }
  256. }
  257. if (this.control[this.swiper.index]) {
  258. this.bgm.show = false;
  259. } else if (this.fetch.page_info.bgmusic) {
  260. this.bgm.show = true;
  261. }
  262. }
  263. },
  264. change : function(current, index) {
  265. /*
  266. if (this.$refs['dream_' + index]) {
  267. this.$refs['dream_' + index].show(0);
  268. }*/
  269. this.showPage(current);
  270. this.record(current);
  271. this.controlHandle();
  272. if (this.swiper.index >= this.fetch.total) {
  273. }
  274. },
  275. view : function() {
  276. this.Dever.location('dream/view?id=1');
  277. },
  278. initDrawer : function() {
  279. //this.getContentId();
  280. var i = '';
  281. this.drawer.button = [];
  282. for (i in this.drawer.item) {
  283. this.drawer.item[i].button.key = i;
  284. this.drawer.item[i].param.type = 3;
  285. this.drawer.item[i].param.type_id = this.content_id;
  286. this.drawer.button.push(this.drawer.item[i].button);
  287. }
  288. },
  289. getData : function() {
  290. var self = this;
  291. self.drawer.item = {};
  292. this.Dever.get(this, 'app/collection/?l=api.getContent', {code:this.Dever.config.code}, function(t) {
  293. self.show = t.show;
  294. self.Dever.bgm().init(self, t.page_info.bgmusic, t.page_info.name, t.info.name, t.page_info.pic, t.page_info.bgmusic_autoplay);
  295. uni.setNavigationBarTitle({
  296. title:t.info.name
  297. });
  298. self.swiper.index = t.index ? parseInt(t.index) : 0;
  299. self.showPage(self.swiper.index);
  300. self.record(self.swiper.index);
  301. if (t && t['func']) {
  302. self.drawer.item = t['func'];
  303. self.initDrawer();
  304. if (t['func']['cate']) {
  305. self.getCate();
  306. }
  307. if (t['func']['times']) {
  308. self.getTimes();
  309. }
  310. }
  311. });
  312. },
  313. getCate : function() {
  314. if (!this.login) {
  315. return;
  316. }
  317. var self = this;
  318. this.Dever.get(this, 'app/collection/?l=api.getCategory', {code:this.Dever.config.code,noloading:1}, function(t) {
  319. self.drawer.item['cate'].param = t;
  320. });
  321. },
  322. getTimes : function() {
  323. if (!this.login) {
  324. return;
  325. }
  326. var self = this;
  327. this.Dever.get(this, 'app/collection/?l=api.getTimes', {code:this.Dever.config.code,noloading:1}, function(t) {
  328. if (t && t.times && t.times.length > 0) {
  329. self.drawer.item['times'].param = t;
  330. } else {
  331. delete self.drawer.item['times'];
  332. self.initDrawer();
  333. }
  334. });
  335. },
  336. goIndex : function(index) {
  337. this.swiper.index = index;
  338. if (this.drawer.show) {
  339. this.closeDrawer(this.drawer.show);
  340. }
  341. },
  342. showPage : function(page, index) {
  343. if (page >= 0) {
  344. this.page_index = page;
  345. }
  346. if (index >= 0) {
  347. this.page_text = 'P'+(this.page_index+1) + '.' + (index+1);
  348. } else {
  349. this.page_text = 'P'+(this.page_index+1);
  350. }
  351. },
  352. showDrawer : function(key) {
  353. this.getContentId();
  354. this.drawer.item[key].show = !this.drawer.item[key].show;
  355. if (this.drawer.show) {
  356. this.drawer.show = '';
  357. } else {
  358. this.drawer.show = key;
  359. }
  360. },
  361. closeDrawer : function(key) {
  362. if (!key && this.drawer.show) {
  363. key = this.drawer.show;
  364. }
  365. if (!key) {
  366. return;
  367. }
  368. this.drawer.item[key].show = false;
  369. this.drawer.show = '';
  370. },
  371. getContentId : function() {
  372. this.content_id = this.fetch.items[this.swiper.index].id;
  373. this.type = this.fetch.items[this.swiper.index].type;
  374. },
  375. clickDrawerButton : function(e) {
  376. var key = this.drawer.button[e.index].key;
  377. if (key == 'return') {
  378. this.Dever.location('dream/index?code=' + this.Dever.config.code, 'go');
  379. return;
  380. }
  381. if (key != 'bgm') {
  382. this.showDrawer(key);
  383. }
  384. },
  385. goHome : function() {
  386. this.Dever.location('dream/index?id='+this.fetch.info_id);
  387. }
  388. },
  389. components:{
  390. dream,cate,community,times,shop,my,share,deverDrawerPage,deverDrawerWindow,deverShare,deverSwiper
  391. }
  392. }
  393. </script>
  394. <style>
  395. .container {
  396. position: absolute;
  397. height: 100%;
  398. width: 100%;
  399. left: 0;
  400. top: 0;
  401. -webkit-overflow-scrolling: touch;
  402. overflow: hidden;
  403. }
  404. .container_main {
  405. width: 750rpx;
  406. height: 100%;
  407. }
  408. .swiper {
  409. width: 750rpx;
  410. height: 100%;
  411. }
  412. swiper-item>view{
  413. height: 100%;
  414. }
  415. swiper-item image{
  416. width: 750rpx;
  417. height: 100%;
  418. }
  419. .scroll-height {
  420. height:100%;
  421. }
  422. .journal-guide {
  423. position: absolute;
  424. top: 0;
  425. left: 0;
  426. bottom: 0;
  427. right: 0;
  428. background-color: rgba(0, 0, 0, 0.5);
  429. z-index: 300;
  430. }
  431. .journal-guide .guide-center {
  432. background: url(@/static/images/guide-center.png) no-repeat center;
  433. background-size: 628rpx 118rpx;
  434. width: 628rpx;
  435. height: 118rpx;
  436. position: absolute;
  437. top: 50%;
  438. left: 50%;
  439. transform: translate3d(-50%, -50%, 0);
  440. }
  441. .journal-guide .guide-bottom {
  442. background: url(@/static/images/guide-bt.png) no-repeat center;
  443. background-size: 298rpx 105rpx;
  444. width: 298rpx;
  445. height: 105rpx;
  446. position: absolute;
  447. bottom: 86rpx;
  448. left: 50%;
  449. transform: translate3d(-50%, 0, 0);
  450. }
  451. </style>