view.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. position: ["tl","tc","tr","cl","cc","cr","bl","bc","br"],
  32. position_f: ["tl","tr","bl","br"],
  33. //记录当前第几页
  34. page : 1,
  35. //记录哪个页面需要停止
  36. stop : [],
  37. }
  38. }
  39. },
  40. onLoad(option) {
  41. this.id = option.id;
  42. this.getData();
  43. },
  44. // 下拉刷新
  45. onPullDownRefresh: function() {
  46. this.getData();
  47. },
  48. // 重新加载
  49. onPullDownRefresh: function() {
  50. this.getData();
  51. },
  52. methods:{
  53. change : function(e) {
  54. this.swiper.index = e.detail.current;
  55. this.config.page = this.swiper.index + 1;
  56. if (this.config.stop.length) {
  57. var i = 0;
  58. for (i in this.config.stop) {
  59. if (this.config.page == i) {
  60. this.config.stop[i].start();
  61. } else {
  62. this.config.stop[i].stop();
  63. }
  64. }
  65. }
  66. },
  67. view : function() {
  68. this.Dever.location('dream/view?id=1');
  69. },
  70. getData : function() {
  71. this.Dever.get(this, 'app/collection/?l=api.getContent', {id:this.id});
  72. }
  73. },
  74. components:{
  75. gracePage,dream
  76. }
  77. }
  78. </script>
  79. <style>
  80. .container {
  81. position: absolute;
  82. height: 100%;
  83. width: 100%;
  84. left: 0;
  85. top: 0;
  86. }
  87. .swiper {
  88. width: 750rpx;
  89. height: 100%;
  90. }
  91. swiper-item>view{
  92. height: 100%;
  93. }
  94. swiper-item image{
  95. width: 750rpx;
  96. height: 100%;
  97. }
  98. .scroll-height {
  99. height:100%;
  100. }
  101. .page-num {
  102. position: fixed;
  103. right: 30rpx;
  104. bottom: 30rpx;
  105. width: 80rpx;
  106. height: 80rpx;
  107. background-color: rgba(0, 0, 0, 0.75);
  108. border-radius: 80rpx;
  109. color: #fff;
  110. font-size: 30rpx;
  111. line-height: 80rpx;
  112. text-align: center;
  113. z-index: 200;
  114. }
  115. </style>