instructions.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <template>
  2. <div class="instructionWrap">
  3. <!-- :w="w" -->
  4. <vue-drag-resize
  5. v-if="isShow"
  6. :snapToGrid="false"
  7. :isActive="true"
  8. :parentH="docY"
  9. :h="h"
  10. :z="1999"
  11. :w="w"
  12. :y="y"
  13. :x="x"
  14. id="instructions"
  15. @resizestop="resizestop"
  16. @resizing="onResizing"
  17. @dragging="onResizing"
  18. @dragstop="resizestop"
  19. :preventActiveBehavior="true"
  20. >
  21. <div class="wall"></div>
  22. <div class="showBtnList">
  23. <el-popover placement="bottom" trigger="hover">
  24. <div class="popover-container" style="text-align: center">
  25. 新窗口打开
  26. </div>
  27. <i
  28. slot="reference"
  29. class="icon iconfont icon-jia add"
  30. @click="gotoIns"
  31. @mouseenter="enter($event)"
  32. @mouseleave="leave($event)"
  33. ></i>
  34. </el-popover>
  35. <el-popover placement="bottom" trigger="hover" v-if="!fullscreen">
  36. <div class="popover-container" style="text-align: center">最大化</div>
  37. <i
  38. slot="reference"
  39. class="icon iconfont icon-fullscreen fullscreen"
  40. @click="fullPageBook"
  41. ></i>
  42. </el-popover>
  43. <el-popover placement="bottom" trigger="hover" v-else>
  44. <div class="popover-container" style="text-align: center">还原</div>
  45. <i
  46. slot="reference"
  47. class="icon iconfont icon-huanyuan huanyuan"
  48. @click="resetBook"
  49. ></i>
  50. </el-popover>
  51. <el-popover placement="bottom" trigger="hover">
  52. <div class="popover-container" style="text-align: center">关闭</div>
  53. <i
  54. slot="reference"
  55. class="icon el-icon-close"
  56. @click="showInstructions"
  57. ></i>
  58. </el-popover>
  59. <!-- -->
  60. <!-- <i class="iconfont icon-tubiao-huanyuan"></i> -->
  61. </div>
  62. <div class="iframeDiv" v-show="isResizing"></div>
  63. <iframe
  64. id="iframeId"
  65. ref="iframe"
  66. :src="url"
  67. frameborder="0"
  68. class="pc iframe"
  69. :width="iframeWidth"
  70. :height="iframeHeight"
  71. seamless
  72. allowfullscreen="true"
  73. >
  74. </iframe>
  75. </vue-drag-resize>
  76. <videoView
  77. v-if="showVideo"
  78. :docY="docY"
  79. @isResizing="
  80. (val) => {
  81. this.isResizing = val;
  82. }
  83. "
  84. @closeVideo="showVideo = false"
  85. :videoSrc="src"
  86. ></videoView>
  87. </div>
  88. </template>
  89. <script>
  90. import screenfull from "screenfull";
  91. import VueDragResize from "vue-drag-resize";
  92. import { instructionList} from "@/constant/instructionList";
  93. import { operationLog } from "./api";
  94. import videoView from "./insVideo";
  95. const defaultSettings = require("@/settings.js");
  96. export default {
  97. components: {
  98. "vue-drag-resize": VueDragResize,
  99. videoView,
  100. },
  101. data() {
  102. return {
  103. url: "/html/index.html" + "#g=1&p=新建乐团",
  104. isShow: false,
  105. w: "",
  106. y: 135,
  107. h: "",
  108. x: "",
  109. docY: "",
  110. isResizing: false,
  111. showVideo: false,
  112. src: "",
  113. isShowBtn: false,
  114. };
  115. },
  116. mounted() {
  117. this.initSize();
  118. this.setBtnStatus(this.$route);
  119. // document.onfullscreenchange = this.resizeI;
  120. window.addEventListener("resize", this.resizeWindow);
  121. // document.querySelector(".app-main").addEventListener("resize",this.resizeMain)
  122. },
  123. beforeDestroy() {},
  124. methods: {
  125. enter($event) {
  126. $event.currentTarget.className =
  127. "icon iconfont icon-jia-tianchong addPuls";
  128. },
  129. leave($event) {
  130. $event.currentTarget.className = "icon iconfont icon-jia add";
  131. },
  132. resizeWindow() {
  133. if (this.isShow) {
  134. this.isShow = false;
  135. this.initSize();
  136. this.$nextTick((res) => {
  137. this.isShow = true;
  138. });
  139. }
  140. },
  141. initSize() {
  142. let clientWidth =
  143. document.documentElement.clientWidth || document.body.clientWidth;
  144. this.w = 500;
  145. this.x = clientWidth - (this.w + 10);
  146. this.y = 135;
  147. this.docY =
  148. document.documentElement.clientHeight || document.body.clientHeight;
  149. this.h = this.docY - this.y;
  150. },
  151. resizestop(e) {
  152. if (!this.fullscreen) {
  153. this.h = Math.abs(e.height);
  154. this.w = Math.abs(e.width);
  155. if (e.top < 135) {
  156. this.y = 135;
  157. this.isShow = false;
  158. this.$nextTick((res) => {
  159. this.isShow = true;
  160. });
  161. }
  162. }
  163. setTimeout(() => {
  164. this.isResizing = false;
  165. }, 500);
  166. },
  167. onResizing(e) {
  168. this.isResizing = true;
  169. this.x = e.left;
  170. this.y = e.top;
  171. if (e.top < 135) {
  172. this.y = 135;
  173. // document.documentElement.querySelector("#instructions").style.top =
  174. // "135px";
  175. }
  176. },
  177. resetBook() {
  178. this.isShow = false;
  179. this.$nextTick((res) => {
  180. let clientWidth =
  181. document.documentElement.clientWidth || document.body.clientWidth;
  182. this.docY =
  183. document.documentElement.clientHeight || document.body.clientHeight;
  184. this.w = 500;
  185. this.h = this.docY - this.y;
  186. this.y = 135;
  187. this.x = clientWidth - (this.w + 10);
  188. this.isShow = true;
  189. });
  190. },
  191. fullPageBook() {
  192. this.isShow = false;
  193. this.$nextTick((res) => {
  194. this.h = this.docY - this.y;
  195. const bodyEle = document.querySelector(".app-main");
  196. this.w = bodyEle.clientWidth;
  197. this.x = 210;
  198. this.y = 135;
  199. this.isShow = true;
  200. });
  201. },
  202. // resizeMain(){
  203. // // const bodyEle = document.querySelector(".app-main");
  204. // // this.w =
  205. // },
  206. async showInstructions() {
  207. this.initSize();
  208. if (!this.isShow) {
  209. // 埋点
  210. try {
  211. const res = await operationLog({
  212. operateName: this.str,
  213. interfaceUrl: this.$route.path,
  214. });
  215. } catch (e) {}
  216. // console.log("埋点");
  217. }
  218. this.isShow = !this.isShow;
  219. },
  220. setBtnStatus(to) {
  221. // console.log(to.path)
  222. this.str = "";
  223. if (instructionList.hasOwnProperty(to.path)) {
  224. this.isShowBtn = true;
  225. // this.$emit('checkShow',this.isShowBtn)
  226. // console.log(Object.prototype.toString.call(instructionList[to.path]),instructionList[to.path])
  227. if (
  228. Object.prototype.toString.call(instructionList[to.path]) ===
  229. "[object Object]"
  230. ) {
  231. // 对象 肯定是详情页
  232. let obj = {};
  233. obj = instructionList[to.path];
  234. // if (instructionList[to.path][to.query[keyOfValue[to.path]]]) {
  235. // let parameter = to.query[keyOfValue[to.path]];
  236. // obj = { ...instructionList[to.path][parameter] };
  237. // } else {
  238. // }
  239. if (!to.query.tabrouter) {
  240. let some = Object.keys(obj)[0];
  241. this.url = `/html/index.html#&p=${obj[some]}`;
  242. this.str = obj[some];
  243. } else {
  244. this.str = obj[to.query.tabrouter];
  245. if (obj[to.query.tabrouter]) {
  246. this.url = `/html/index.html#&p=${this.str}`;
  247. // 判断一下 如果是乐团详情 就判断
  248. } else {
  249. this.isShowBtn = false;
  250. }
  251. }
  252. } else {
  253. // 字符串
  254. this.url = `/html/index.html#&p=${instructionList[to.path]}`;
  255. this.str = instructionList[to.path];
  256. }
  257. } else {
  258. this.isShowBtn = false;
  259. }
  260. // console.log(this.isShowBtn);
  261. this.$emit("checkShow", this.isShowBtn);
  262. },
  263. gotoIns() {
  264. let str = this.url.replace("&c=1", "")+'&g=1';
  265. this.$router.push({
  266. path: "/instructions/instructions",
  267. query: { url: str },
  268. });
  269. },
  270. },
  271. computed: {
  272. // key() {
  273. // console.log(this.$route);
  274. // this.isShow = false;
  275. // return this.$route.path;
  276. // },
  277. iframeWidth() {
  278. return this.w + "px";
  279. },
  280. iframeHeight() {
  281. return this.h - 30 + "px";
  282. },
  283. fullscreen() {
  284. const bodyEle = document.querySelector(".app-main");
  285. // this.h = this.docY - this.y;
  286. return (
  287. this.h == this.docY - this.y &&
  288. this.w == bodyEle.clientWidth &&
  289. this.x == 210 &&
  290. this.y == 135
  291. );
  292. },
  293. // fullscreenVideo() {
  294. // const bodyEle = document.querySelector(".app-main");
  295. // return (
  296. // this.videoH == this.docY - this.y &&
  297. // this.videoW == bodyEle.clientWidth &&
  298. // this.x == 210 &&
  299. // this.y == 130
  300. // );
  301. // },
  302. },
  303. watch: {
  304. $route(to, from) {
  305. this.isShow = false;
  306. this.setBtnStatus(to);
  307. },
  308. isShow(val) {
  309. if (val) {
  310. this.$nextTick((res) => {
  311. let outFrame = this.$refs.iframe;
  312. let outFrameWindow = this.$refs.iframe.contentWindow;
  313. setTimeout((res) => {
  314. let rightFrame =
  315. outFrameWindow.document.querySelector("#mainFrame");
  316. rightFrame.contentWindow.document.addEventListener(
  317. "click",
  318. (e) => {
  319. let path = (e.composedPath && e.composedPath()) || e.path || [];
  320. if (path.length > 0) {
  321. for (let i in path) {
  322. if (path[i]?.getAttribute("title")) {
  323. // console.log(
  324. // "打开视频链接",
  325. // e.path[i].getAttribute("title")
  326. // );
  327. this.src = e.path[i].getAttribute("title");
  328. this.showVideo = true;
  329. this.$nextTick((res) => {
  330. this.isShow = false;
  331. });
  332. // this.isShow = false;
  333. break;
  334. }
  335. }
  336. } else {
  337. this.$message.error(
  338. "该浏览器不支持,请更换或升级chrome浏览器"
  339. );
  340. }
  341. // let document
  342. },
  343. true
  344. );
  345. }, 500);
  346. });
  347. }
  348. },
  349. },
  350. };
  351. </script>
  352. <style lang="scss" scoped>
  353. .iframeDiv {
  354. width: 100%;
  355. height: 100%;
  356. position: absolute;
  357. z-index: 2000;
  358. filter: alpha(opacity=0);
  359. opacity: 0;
  360. background: transparent;
  361. /*display: none;*/
  362. }
  363. .content-container {
  364. .showBtnList {
  365. display: flex;
  366. flex-direction: row;
  367. align-items: center;
  368. justify-content: space-around;
  369. font-size: 20px;
  370. position: absolute;
  371. right: 5px;
  372. top: 0;
  373. background-color: #ccc;
  374. height: 30px;
  375. z-index: 2000;
  376. .icon {
  377. line-height: 30px;
  378. }
  379. }
  380. }
  381. .wall {
  382. height: 30px;
  383. background-color: #ccc;
  384. cursor: pointer;
  385. }
  386. .videowall {
  387. height: 30px;
  388. background-color: #ccc;
  389. }
  390. .fullscreen {
  391. padding: 0 5px;
  392. font-size: 20px;
  393. }
  394. .add {
  395. padding: 0 5px;
  396. font-size: 20px;
  397. font-weight: bold;
  398. color: #707070;
  399. }
  400. .addPuls {
  401. padding: 0 5px;
  402. font-size: 20px;
  403. color: #707070;
  404. }
  405. .huanyuan {
  406. padding: 0 5px;
  407. font-size: 22px;
  408. }
  409. .newPageBtn {
  410. font-size: 14px;
  411. line-height: 30px;
  412. color: var(--color-primary);
  413. height: 30px;
  414. display: inline-block;
  415. }
  416. </style>
  417. <style lang="scss">
  418. // .instructionWrap{
  419. // position: absolute;
  420. // z-index: 2000;
  421. // }
  422. .instructionBtn {
  423. position: fixed;
  424. right: 30px;
  425. top: 200px;
  426. z-index: 2000;
  427. }
  428. .iframeId {
  429. width: 100%;
  430. }
  431. #instructions {
  432. background-color: #fff;
  433. position: fixed;
  434. z-index: 9998 !important;
  435. border: 1px solid #ccc;
  436. }
  437. .vdr-stick {
  438. opacity: 0;
  439. }
  440. .vdr-stick-tm,
  441. .vdr-stick-bm {
  442. width: 99% !important;
  443. width: calc(100% - 8px) !important;
  444. margin-left: 0 !important;
  445. left: 4px;
  446. // margin-left: -50%!important;
  447. }
  448. .vdr-stick-mr,
  449. .vdr-stick-ml {
  450. height: 99% !important;
  451. height: calc(100% - 8px) !important;
  452. margin-top: 0 !important;
  453. top: 4px !important;
  454. }
  455. .vdr {
  456. &:before {
  457. outline: 0px dashed #d6d6d6 !important;
  458. }
  459. }
  460. .icon {
  461. cursor: pointer;
  462. color: #707070;
  463. }
  464. </style>