view.vue 9.4 KB

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