view.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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 : true,
  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.Dever.config.system = uni.getSystemInfoSync();
  162. this.getData();
  163. },
  164. // 重新加载
  165. onPullDownRefresh: function() {
  166. if (this.drawer.show && this.drawer.item[this.drawer.show].show == true) {
  167. this.$refs[this.drawer.show][0].getData();
  168. } else {
  169. this.getData();
  170. }
  171. },
  172. onShow : function() {
  173. this.controlHandle();
  174. },
  175. onHide() {
  176. //this.stop();
  177. },
  178. onBackPress(e) {
  179. this.stop();
  180. },
  181. beforeDestroy() {
  182. this.stop();
  183. },
  184. methods:{
  185. closeGuide : function() {
  186. this.guide = false;
  187. this.Dever.data('guide', 2);
  188. },
  189. stop : function() {
  190. if (this.control) {
  191. var i = 0;
  192. for (i in this.control) {
  193. if (this.control[i].load) {
  194. this.control[i].stop();
  195. }
  196. }
  197. }
  198. this.Dever.bgm().stop();
  199. },
  200. // 播放背景音乐
  201. bgmControl : function() {
  202. this.Dever.bgm().control();
  203. },
  204. // 页面触底刷新
  205. bottomCall: function() {
  206. if (this.bottom && this.bottom[this.swiper.index]) {
  207. this.bottom[this.swiper.index].getData(2);
  208. }
  209. },
  210. // drawer触底刷新
  211. bottomFunc : function() {
  212. if (this.drawer.show && this.drawer.item[this.drawer.show].show == true) {
  213. this.$refs[this.drawer.show][0].getInfo(2);
  214. }
  215. },
  216. record : function() {
  217. if (!this.login) {
  218. return;
  219. }
  220. var self = this;
  221. var content_id = this.fetch.items[this.swiper.index].id;
  222. 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) {
  223. self.Dever.config.code = t.code;
  224. if (self.Dever.source == 'h5') {
  225. }
  226. });
  227. },
  228. controlHandle : function() {
  229. if (this.control) {
  230. var i = 0;
  231. for (i in this.control) {
  232. if (this.control[i].load) {
  233. //console.info(i);
  234. if (this.swiper.index == i) {
  235. //console.info('start');
  236. this.Dever.bgm().stop();
  237. this.control[i].start();
  238. } else {
  239. this.control[i].stop();
  240. }
  241. }
  242. }
  243. if (this.control[this.swiper.index]) {
  244. this.bgm.show = false;
  245. } else if (this.fetch.page_info.bgmusic) {
  246. this.bgm.show = true;
  247. }
  248. }
  249. },
  250. change : function(e) {
  251. this.fetch.index = this.swiper.index = parseInt(e.detail.current);
  252. //用户记录
  253. this.record();
  254. this.controlHandle();
  255. if (this.swiper.index >= this.fetch.total) {
  256. }
  257. },
  258. view : function() {
  259. this.Dever.location('dream/view?id=1');
  260. },
  261. initDrawer : function() {
  262. //this.getContentId();
  263. var i = '';
  264. this.drawer.button = [];
  265. for (i in this.drawer.item) {
  266. this.drawer.item[i].button.key = i;
  267. this.drawer.item[i].param.type = 3;
  268. this.drawer.item[i].param.type_id = this.content_id;
  269. this.drawer.button.push(this.drawer.item[i].button);
  270. }
  271. },
  272. getData : function() {
  273. var self = this;
  274. self.drawer.item = {};
  275. this.Dever.get(this, 'app/collection/?l=api.getContent', {code:this.Dever.config.code}, function(t) {
  276. self.show = t.show;
  277. 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);
  278. uni.setNavigationBarTitle({
  279. title:t.info.name
  280. });
  281. self.swiper.index = t.index ? parseInt(t.index) : 0;
  282. self.record();
  283. if (t && t['func']) {
  284. self.drawer.item = t['func'];
  285. self.initDrawer();
  286. if (t['func']['cate']) {
  287. self.getCate();
  288. }
  289. if (t['func']['times']) {
  290. self.getTimes();
  291. }
  292. }
  293. });
  294. },
  295. getCate : function() {
  296. if (!this.login) {
  297. return;
  298. }
  299. var self = this;
  300. this.Dever.get(this, 'app/collection/?l=api.getCategory', {code:this.Dever.config.code,noloading:1}, function(t) {
  301. self.drawer.item['cate'].param = t;
  302. });
  303. },
  304. getTimes : function() {
  305. if (!this.login) {
  306. return;
  307. }
  308. var self = this;
  309. this.Dever.get(this, 'app/collection/?l=api.getTimes', {code:this.Dever.config.code,noloading:1}, function(t) {
  310. if (t && t.times && t.times.length > 0) {
  311. self.drawer.item['times'].param = t;
  312. } else {
  313. delete self.drawer.item['times'];
  314. self.initDrawer();
  315. }
  316. });
  317. },
  318. goIndex : function(index) {
  319. this.fetch.index = index;
  320. if (this.drawer.show) {
  321. this.closeDrawer(this.drawer.show);
  322. }
  323. },
  324. showDrawer : function(key) {
  325. this.getContentId();
  326. this.drawer.item[key].show = !this.drawer.item[key].show;
  327. if (this.drawer.show) {
  328. this.drawer.show = '';
  329. } else {
  330. this.drawer.show = key;
  331. }
  332. },
  333. closeDrawer : function(key) {
  334. if (!key && this.drawer.show) {
  335. key = this.drawer.show;
  336. }
  337. if (!key) {
  338. return;
  339. }
  340. this.drawer.item[key].show = false;
  341. this.drawer.show = '';
  342. },
  343. getContentId : function() {
  344. this.content_id = this.fetch.items[this.swiper.index].id;
  345. this.type = this.fetch.items[this.swiper.index].type;
  346. },
  347. clickDrawerButton : function(e) {
  348. var key = this.drawer.button[e.index].key;
  349. if (key != 'bgm') {
  350. this.showDrawer(key);
  351. }
  352. },
  353. goHome : function() {
  354. this.Dever.location('dream/index?id='+this.fetch.info_id);
  355. }
  356. },
  357. components:{
  358. dream,cate,community,times,shop,my,share,deverDrawerPage,deverDrawerWindow,deverShare
  359. }
  360. }
  361. </script>
  362. <style>
  363. .container {
  364. position: absolute;
  365. height: 100%;
  366. width: 100%;
  367. left: 0;
  368. top: 0;
  369. -webkit-overflow-scrolling: touch;
  370. overflow: hidden;
  371. }
  372. .container_main {
  373. width: 750rpx;
  374. height: 100%;
  375. }
  376. .swiper {
  377. width: 750rpx;
  378. height: 100%;
  379. }
  380. swiper-item>view{
  381. height: 100%;
  382. }
  383. swiper-item image{
  384. width: 750rpx;
  385. height: 100%;
  386. }
  387. .scroll-height {
  388. height:100%;
  389. }
  390. .journal-guide {
  391. position: absolute;
  392. top: 0;
  393. left: 0;
  394. bottom: 0;
  395. right: 0;
  396. background-color: rgba(0, 0, 0, 0.5);
  397. z-index: 300;
  398. }
  399. .journal-guide .guide-center {
  400. background: url(@/static/images/guide-center.png) no-repeat center;
  401. background-size: 628rpx 118rpx;
  402. width: 628rpx;
  403. height: 118rpx;
  404. position: absolute;
  405. top: 50%;
  406. left: 50%;
  407. transform: translate3d(-50%, -50%, 0);
  408. }
  409. .journal-guide .guide-bottom {
  410. background: url(@/static/images/guide-bt.png) no-repeat center;
  411. background-size: 298rpx 105rpx;
  412. width: 298rpx;
  413. height: 105rpx;
  414. position: absolute;
  415. bottom: 86rpx;
  416. left: 50%;
  417. transform: translate3d(-50%, 0, 0);
  418. }
  419. </style>