view.vue 8.4 KB

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