view.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <gracePage :customHeader="false">
  3. <view class="container" slot="gBody">
  4. <swiper class="swiper" @change="change" :circular="swiper.circular">
  5. <swiper-item v-for="(v, k) in fetch.items" v-if="v.data">
  6. <scroll-view scroll-y="true" class="scroll-height">
  7. <dream :item="v" :config="config" class="item"></dream>
  8. <view class="page-num" v-if="swiper.index != -1">P{{swiper.index+1}}</view>
  9. </scroll-view>
  10. </swiper-item>
  11. </swiper>
  12. </view>
  13. </gracePage>
  14. </template>
  15. <script>
  16. import gracePage from "@/lib/graceUI/components/gracePage.vue";
  17. import dream from "@/pages/dream/view/dream.vue";
  18. var graceRichText = require("@/lib/graceUI/jsTools/richText.js");
  19. export default{
  20. data() {
  21. return {
  22. id : 1,
  23. swiper : {
  24. index : 0,
  25. circular : false,
  26. },
  27. fetch: {
  28. items : []
  29. },
  30. config : {
  31. //记录当前第几页
  32. page : 1,
  33. //记录哪个页面需要停止
  34. stop : [],
  35. }
  36. }
  37. },
  38. onLoad(option) {
  39. this.id = option.id;
  40. this.getData();
  41. },
  42. // 下拉刷新
  43. onPullDownRefresh: function() {
  44. this.getData();
  45. },
  46. // 重新加载
  47. onPullDownRefresh: function() {
  48. this.getData();
  49. },
  50. methods:{
  51. change : function(e) {
  52. this.swiper.index = e.detail.current;
  53. this.config.page = this.swiper.index + 1;
  54. if (this.config.stop.length) {
  55. var i = 0;
  56. for (i in this.config.stop) {
  57. if (this.config.page == i) {
  58. this.config.stop[i].start();
  59. } else {
  60. this.config.stop[i].stop();
  61. }
  62. }
  63. }
  64. },
  65. view : function() {
  66. this.Dever.location('dream/view?id=1');
  67. },
  68. getData : function() {
  69. this.Dever.get(this, 'app/collection/?l=api.getContent', {id:this.id});
  70. }
  71. },
  72. components:{
  73. gracePage,dream
  74. }
  75. }
  76. </script>
  77. <style>
  78. .container {
  79. position: absolute;
  80. height: 100%;
  81. width: 100%;
  82. left: 0;
  83. top: 0;
  84. }
  85. .swiper {
  86. width: 750rpx;
  87. height: 100%;
  88. }
  89. swiper-item>view{
  90. height: 100%;
  91. }
  92. swiper-item image{
  93. width: 750rpx;
  94. height: 100%;
  95. }
  96. .scroll-height {
  97. height:100%;
  98. }
  99. .page-num {
  100. position: fixed;
  101. right: 30rpx;
  102. bottom: 30rpx;
  103. width: 80rpx;
  104. height: 80rpx;
  105. background-color: rgba(0, 0, 0, 0.75);
  106. border-radius: 80rpx;
  107. color: #fff;
  108. font-size: 30rpx;
  109. line-height: 80rpx;
  110. text-align: center;
  111. z-index: 200;
  112. }
  113. </style>