view.vue 12 KB

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