view.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. <drawerPage :show="drawer.show ? 'left' : ''">
  7. <view class="container_main" slot="links" @click="closeDrawer()">
  8. <block v-if="login">
  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="!login">
  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. </drawerPage>
  22. <drawerWindow 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" :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. </drawerWindow>
  44. <y-Fab v-if="!drawer.show && fetch.user.avatar && login" :bottom="20" :right="20" :btnList="drawer.button" @click="clickDrawerButton" :text="`P`+(swiper.index+1)" :icon_o="fetch.user.avatar"></y-Fab>
  45. <y-Fab v-if="!login" :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 drawerPage from "@/lib/dever/components/drawerPage.vue";
  59. import drawerWindow from "@/lib/dever/components/drawerWindow.vue";
  60. export default{
  61. data() {
  62. return {
  63. content_id : 0,
  64. type : -1,
  65. login : false,
  66. swiper : {
  67. index : 0,
  68. circular : false,
  69. },
  70. fetch: {
  71. items : [],
  72. user : {},
  73. index : 0,
  74. info_id : 0,
  75. page_id : 0,
  76. parent_page_id : 0,
  77. times_id : 0,
  78. },
  79. control : {},
  80. bottom : {},
  81. drawer : {
  82. // 是否显示
  83. show : '',
  84. button : [],
  85. item : {
  86. cate : {
  87. show : false,
  88. index : 5,
  89. top: 0,
  90. padding: '0rpx',
  91. width : '86%',
  92. direction : 'left',
  93. param : {},
  94. button : {
  95. bgColor: '#55ff7f',
  96. text: '选集',
  97. fontSize: 28,
  98. color: '#fff'
  99. }
  100. },
  101. community : {
  102. show : false,
  103. index : 5,
  104. top: 0,
  105. padding: '0rpx',
  106. width : '86%',
  107. direction : 'left',
  108. param : {
  109. type : 3,
  110. type_id : this.content_id,
  111. },
  112. button : {
  113. bgColor: '#16C2C2',
  114. text: '社区',
  115. fontSize: 28,
  116. color: '#fff'
  117. },
  118. }
  119. }
  120. }
  121. }
  122. },
  123. onLoad(option) {
  124. this.login = true;
  125. if (option && option.name) {
  126. uni.setNavigationBarTitle({
  127. title:option.name
  128. });
  129. }
  130. this.Dever.config.code = option.code;
  131. this.getData();
  132. },
  133. // 重新加载
  134. onPullDownRefresh: function() {
  135. if (this.drawer.show && this.drawer.item[this.drawer.show].show == true) {
  136. this.$refs[this.drawer.show][0].getData();
  137. } else {
  138. this.getData();
  139. }
  140. },
  141. onShow : function() {
  142. this.controlHandle();
  143. },
  144. methods:{
  145. // 触底刷新
  146. bottomCall: function() {
  147. if (this.bottom && this.bottom[this.swiper.index]) {
  148. this.bottom[this.swiper.index].getData(2);
  149. }
  150. },
  151. // 触底刷新
  152. bottomFunc : function() {
  153. if (this.drawer.show && this.drawer.item[this.drawer.show].show == true) {
  154. this.$refs[this.drawer.show][0].getInfo(2);
  155. }
  156. },
  157. record : function() {
  158. var content_id = this.fetch.items[this.swiper.index].id;
  159. this.Dever.post('app/collection/?l=api.record', {noloading:1, code:this.Dever.config.code, index: this.swiper.index, content_id: content_id});
  160. },
  161. controlHandle : function() {
  162. if (this.control) {
  163. var i = 0;
  164. for (i in this.control) {
  165. if (this.control[i].load) {
  166. console.info(i);
  167. if (this.swiper.index == i) {
  168. console.info('start');
  169. this.control[i].start();
  170. } else {
  171. this.control[i].stop();
  172. }
  173. }
  174. }
  175. }
  176. },
  177. change : function(e) {
  178. this.swiper.index = e.detail.current;
  179. //用户记录
  180. this.record();
  181. this.controlHandle();
  182. if (this.swiper.index >= this.fetch.total) {
  183. }
  184. },
  185. view : function() {
  186. this.Dever.location('dream/view?id=1');
  187. },
  188. initDrawer : function() {
  189. //this.getContentId();
  190. var i = '';
  191. this.drawer.button = [];
  192. for (i in this.drawer.item) {
  193. this.drawer.item[i].button.key = i;
  194. this.drawer.item[i].param.type = 3;
  195. this.drawer.item[i].param.type_id = this.content_id;
  196. this.drawer.button.push(this.drawer.item[i].button);
  197. }
  198. },
  199. getData : function() {
  200. var self = this;
  201. self.drawer.item = {};
  202. this.Dever.get(this, 'app/collection/?l=api.getContent', {code:this.Dever.config.code}, function(t) {
  203. uni.setNavigationBarTitle({
  204. title:t.info.name
  205. });
  206. self.swiper.index = parseInt(t.index);
  207. self.record();
  208. if (t && t['func']) {
  209. self.drawer.item = t['func'];
  210. self.initDrawer();
  211. if (t['func']['cate']) {
  212. self.getCate();
  213. }
  214. if (t['func']['times']) {
  215. self.getTimes();
  216. }
  217. }
  218. });
  219. },
  220. getCate : function() {
  221. var self = this;
  222. this.Dever.get(this, 'app/collection/?l=api.getCategory', {code:this.Dever.config.code,noloading:1}, function(t) {
  223. self.drawer.item['cate'].param = t;
  224. });
  225. },
  226. getTimes : function() {
  227. var self = this;
  228. this.Dever.get(this, 'app/collection/?l=api.getTimes', {code:this.Dever.config.code,noloading:1}, function(t) {
  229. if (t && t.times && t.times.length > 0) {
  230. self.drawer.item['times'].param = t;
  231. } else {
  232. delete self.drawer.item['times'];
  233. self.initDrawer();
  234. }
  235. });
  236. },
  237. goIndex : function(index) {
  238. this.fetch.index = index;
  239. if (this.drawer.show) {
  240. this.closeDrawer(this.drawer.show);
  241. }
  242. },
  243. showDrawer : function(key) {
  244. this.getContentId();
  245. this.drawer.item[key].show = !this.drawer.item[key].show;
  246. if (this.drawer.show) {
  247. this.drawer.show = '';
  248. } else {
  249. this.drawer.show = key;
  250. }
  251. },
  252. closeDrawer : function(key) {
  253. if (!key && this.drawer.show) {
  254. key = this.drawer.show;
  255. }
  256. if (!key) {
  257. return;
  258. }
  259. this.drawer.item[key].show = false;
  260. this.drawer.show = '';
  261. },
  262. getContentId : function() {
  263. this.content_id = this.fetch.items[this.swiper.index].id;
  264. this.type = this.fetch.items[this.swiper.index].type;
  265. },
  266. clickDrawerButton : function(e) {
  267. this.showDrawer(this.drawer.button[e.index].key);
  268. },
  269. goHome : function() {
  270. this.Dever.location('dream/index?id='+this.fetch.info_id);
  271. }
  272. },
  273. components:{
  274. dream,cate,community,times,shop,my,share,drawerPage,drawerWindow
  275. }
  276. }
  277. </script>
  278. <style>
  279. .container {
  280. position: absolute;
  281. height: 100%;
  282. width: 100%;
  283. left: 0;
  284. top: 0;
  285. -webkit-overflow-scrolling: touch;
  286. overflow: hidden;
  287. }
  288. .container_main {
  289. width: 750rpx;
  290. height: 100%;
  291. }
  292. .swiper {
  293. width: 750rpx;
  294. height: 100%;
  295. }
  296. swiper-item>view{
  297. height: 100%;
  298. }
  299. swiper-item image{
  300. width: 750rpx;
  301. height: 100%;
  302. }
  303. .scroll-height {
  304. height:100%;
  305. }
  306. </style>