guoshilong
2023-03-18 3a85d31c1039315667f8fa66ce01be06626ed23f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<template>
  <div>
    <!--头部按钮-->
    <div class="avue-crud__menu">
      <!-- 头部左侧按钮模块 -->
      <div class="avue-crud__left">
        <el-button size="small" class="button" icon="el-icon-back" @click="backModules">返回模块列表</el-button>
        <el-button size="small" class="button" icon="el-icon-back" @click="backStartPage">回到开始页</el-button>
      </div>
    </div>
 
    <div class="content-view">
      <!--开始页-->
      <div v-if="currentIndex==1" class="start">
        <img class="start-img" :src="startPage.fileUrl[0].value">
        <div class="start-button-group">
          <el-button size="small" v-for="data in contentFunList" :index="data.id" :key="data.id" @click="jumpToContent(data)">
            {{ data.name }}
          </el-button>
        </div>
      </div>
 
      <!--内容页-->
      <div style="height: 100%;width: 100%;background-color: #404040"  v-if="currentIndex==2" class="content">
 
        <!--flash-->
        <div  v-if="content.type == 1">
 
        </div>
 
        <!--图册-->
        <FlipBook v-if="content.type == 2" class="flipbook"
                  :pages="flipConfig.pages"
                  :startPage="flipConfig.pageNum"
                  v-slot="flipbook"
                  ref="flipbook">
          <div class="action-bar">
            <left-icon
              class="btn left"
              :class="{ disabled: !flipbook.canFlipLeft }"
              @click="flipbook.flipLeft"
            />
            <plus-icon
              class="btn plus"
              :class="{ disabled: !flipbook.canZoomIn }"
              @click="flipbook.zoomIn"
            />
            <span class="page-num">
          Page {{ flipbook.page }} of {{ flipbook.numPages }}
        </span>
            <minus-icon
              class="btn minus"
              :class="{ disabled: !flipbook.canZoomOut }"
              @click="flipbook.zoomOut"
            />
            <right-icon
              class="btn right"
              :class="{ disabled: !flipbook.canFlipRight }"
              @click="flipbook.flipRight"
            />
          </div>
        </FlipBook>
 
        <!--视频-->
        <iframe v-if="content.type == 3" style="height: 100%;width: 100%" class="view-iframe" :src="iframePath"/>
 
      </div>
 
    </div>
 
  </div>
</template>
 
<script>
import {getAll} from "@/api/modules/function";
import FlipBook from "flipbook-vue/dist/vue2/flipbook";
import LeftIcon from 'vue-material-design-icons/ChevronLeftCircle'
import RightIcon from 'vue-material-design-icons/ChevronRightCircle'
import PlusIcon from 'vue-material-design-icons/PlusCircle'
import MinusIcon from 'vue-material-design-icons/MinusCircle'
 
export default {
  name: "modulesView",
  props:['modules'],
  components: {FlipBook,LeftIcon, RightIcon, PlusIcon, MinusIcon},
  data() {
    return {
      funList:[],
      startPage:{},
      contentFunList:[],
      endPage:[],
      currentIndex:1,
      content:{},
      iframePath:"",
      flipConfig: {
        pages: [],
        pagesHiRes: [],
        hasMouse: true,
        pageNum: null,
      },
    }
  },
  created() {
    this.getAllFunc()
  },
  methods: {
    //返回模块列表页
    backModules() {
      this.$emit('backModules')
    },
    //获取当前模块id下的所有子功能
    getAllFunc() {
      let params = {
        modulesId: this.modules.id
      }
      getAll(params).then(res => {
        if (res.data.code == 200) {
          let data = res.data.data
          data.forEach(e=>{
            if (e.property == 1){
              this.startPage = e
            }else if (e.property == 2){
              this.contentFunList.push(e)
            }else if (e.property == 3){
              this.endPage = e
            }
          })
        }
      })
    },
    jumpToContent(data){
      this.currentIndex = 2
      this.content = data
      if (data.type == 1) {
 
      } else if (data.type == 2) {
        let fileArray = data.fileUrl
        this.flipConfig.pages = []
        if (fileArray.length>0){
          fileArray.forEach(e => {
            this.flipConfig.pages.push(e.value)
          })
        }
      } else if (data.type == 3) {
        if (data.fileUrl.length>0){
          let url = data.fileUrl[0].value
          this.iframePath = 'http://192.168.0.200:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(url))
        }
      }
    },
    backStartPage(){
      this.currentIndex = 1
      this.content = this.startPage
    }
  }
}
</script>
 
<style scoped>
.content-view{
  width: 100%;
  height: 77vh;
}
 
.start{
  width: 100%;
  height: 100%;
}
 
.start-img, .end-img {
  width: 100%;
  height: 100%;
}
 
.start-button-group {
  position: relative;
  display: flex;
  top: -25%;
  justify-content: center;
}
/**
翻页
 */
.flipbook {
  width: 100%;
  height: 100%;
}
 
.page-num {
  color: white;
}
 
.action-bar {
  width: 100%;
  height: 30px;
  padding: 10px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
 
.action-bar .btn {
  font-size: 30px;
  color: #999;
}
 
.action-bar .btn svg {
  bottom: 0;
}
 
.action-bar .btn:not(:first-child) {
  margin-left: 10px;
}
 
.has-mouse .action-bar .btn:hover {
  color: #ccc;
  filter: drop-shadow(1px 1px 5px #000);
  cursor: pointer;
}
 
.action-bar .btn:active {
  filter: none !important;
}
 
.action-bar .btn.disabled {
  color: #666;
  pointer-events: none;
}
 
.action-bar .page-num {
  font-size: 12px;
  margin-left: 10px;
}
 
.flipbook .viewport {
  width: 90vw !important;
  height: calc(100vh - 800px - 40px) !important;
}
 
.flipbook .bounding-box {
  box-shadow: 0 0 20px #000;
}
 
.credit {
  font-size: 12px;
  line-height: 20px;
  margin: 10px;
}
</style>