view.vue 12 KB

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