view.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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" :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" @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. content_id : 0,
  64. type : -1,
  65. show : 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. if (!option.code) {
  125. this.Dever.location('index/index');
  126. return;
  127. }
  128. if (option && option.name) {
  129. uni.setNavigationBarTitle({
  130. title:option.name
  131. });
  132. }
  133. this.Dever.login = 'user/login?code=' + option.code;
  134. this.Dever.checkLogin();
  135. this.Dever.config.name = option.name;
  136. this.Dever.config.code = option.code;
  137. this.getData();
  138. },
  139. // 重新加载
  140. onPullDownRefresh: function() {
  141. if (this.drawer.show && this.drawer.item[this.drawer.show].show == true) {
  142. this.$refs[this.drawer.show][0].getData();
  143. } else {
  144. this.getData();
  145. }
  146. },
  147. onShow : function() {
  148. this.controlHandle();
  149. },
  150. methods:{
  151. // 触底刷新
  152. bottomCall: function() {
  153. if (this.bottom && this.bottom[this.swiper.index]) {
  154. this.bottom[this.swiper.index].getData(2);
  155. }
  156. },
  157. // 触底刷新
  158. bottomFunc : function() {
  159. if (this.drawer.show && this.drawer.item[this.drawer.show].show == true) {
  160. this.$refs[this.drawer.show][0].getInfo(2);
  161. }
  162. },
  163. record : function() {
  164. var content_id = this.fetch.items[this.swiper.index].id;
  165. this.Dever.post('app/user/?l=api.record', {noloading:1, code:this.Dever.config.code, index: this.swiper.index, content_id: content_id});
  166. },
  167. controlHandle : function() {
  168. if (this.control) {
  169. var i = 0;
  170. for (i in this.control) {
  171. if (this.control[i].load) {
  172. console.info(i);
  173. if (this.swiper.index == i) {
  174. console.info('start');
  175. this.control[i].start();
  176. } else {
  177. this.control[i].stop();
  178. }
  179. }
  180. }
  181. }
  182. },
  183. change : function(e) {
  184. this.swiper.index = parseInt(e.detail.current);
  185. //用户记录
  186. this.record();
  187. this.controlHandle();
  188. if (this.swiper.index >= this.fetch.total) {
  189. }
  190. },
  191. view : function() {
  192. this.Dever.location('dream/view?id=1');
  193. },
  194. initDrawer : function() {
  195. //this.getContentId();
  196. var i = '';
  197. this.drawer.button = [];
  198. for (i in this.drawer.item) {
  199. this.drawer.item[i].button.key = i;
  200. this.drawer.item[i].param.type = 3;
  201. this.drawer.item[i].param.type_id = this.content_id;
  202. this.drawer.button.push(this.drawer.item[i].button);
  203. }
  204. },
  205. getData : function() {
  206. var self = this;
  207. self.drawer.item = {};
  208. this.Dever.get(this, 'app/collection/?l=api.getContent', {code:this.Dever.config.code}, function(t) {
  209. self.show = t.show;
  210. uni.setNavigationBarTitle({
  211. title:t.info.name
  212. });
  213. self.swiper.index = parseInt(t.index);
  214. self.record();
  215. if (t && t['func']) {
  216. self.drawer.item = t['func'];
  217. self.initDrawer();
  218. if (t['func']['cate']) {
  219. self.getCate();
  220. }
  221. if (t['func']['times']) {
  222. self.getTimes();
  223. }
  224. }
  225. });
  226. },
  227. getCate : function() {
  228. var self = this;
  229. this.Dever.get(this, 'app/collection/?l=api.getCategory', {code:this.Dever.config.code,noloading:1}, function(t) {
  230. self.drawer.item['cate'].param = t;
  231. });
  232. },
  233. getTimes : function() {
  234. var self = this;
  235. this.Dever.get(this, 'app/collection/?l=api.getTimes', {code:this.Dever.config.code,noloading:1}, function(t) {
  236. if (t && t.times && t.times.length > 0) {
  237. self.drawer.item['times'].param = t;
  238. } else {
  239. delete self.drawer.item['times'];
  240. self.initDrawer();
  241. }
  242. });
  243. },
  244. goIndex : function(index) {
  245. this.fetch.index = index;
  246. if (this.drawer.show) {
  247. this.closeDrawer(this.drawer.show);
  248. }
  249. },
  250. showDrawer : function(key) {
  251. this.getContentId();
  252. this.drawer.item[key].show = !this.drawer.item[key].show;
  253. if (this.drawer.show) {
  254. this.drawer.show = '';
  255. } else {
  256. this.drawer.show = key;
  257. }
  258. },
  259. closeDrawer : function(key) {
  260. if (!key && this.drawer.show) {
  261. key = this.drawer.show;
  262. }
  263. if (!key) {
  264. return;
  265. }
  266. this.drawer.item[key].show = false;
  267. this.drawer.show = '';
  268. },
  269. getContentId : function() {
  270. this.content_id = this.fetch.items[this.swiper.index].id;
  271. this.type = this.fetch.items[this.swiper.index].type;
  272. },
  273. clickDrawerButton : function(e) {
  274. this.showDrawer(this.drawer.button[e.index].key);
  275. },
  276. goHome : function() {
  277. this.Dever.location('dream/index?id='+this.fetch.info_id);
  278. }
  279. },
  280. components:{
  281. dream,cate,community,times,shop,my,share,deverDrawerPage,deverDrawerWindow
  282. }
  283. }
  284. </script>
  285. <style>
  286. .container {
  287. position: absolute;
  288. height: 100%;
  289. width: 100%;
  290. left: 0;
  291. top: 0;
  292. -webkit-overflow-scrolling: touch;
  293. overflow: hidden;
  294. }
  295. .container_main {
  296. width: 750rpx;
  297. height: 100%;
  298. }
  299. .swiper {
  300. width: 750rpx;
  301. height: 100%;
  302. }
  303. swiper-item>view{
  304. height: 100%;
  305. }
  306. swiper-item image{
  307. width: 750rpx;
  308. height: 100%;
  309. }
  310. .scroll-height {
  311. height:100%;
  312. }
  313. </style>