view.vue 10 KB

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