view.vue 11 KB

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