instructions.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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, keyOfValue } 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. },
  122. beforeDestroy() {},
  123. methods: {
  124. enter($event) {
  125. $event.currentTarget.className =
  126. "icon iconfont icon-jia-tianchong addPuls";
  127. },
  128. leave($event) {
  129. $event.currentTarget.className = "icon iconfont icon-jia add";
  130. },
  131. resizeWindow() {
  132. if (this.isShow) {
  133. this.isShow = false;
  134. this.initSize();
  135. this.$nextTick((res) => {
  136. this.isShow = true;
  137. });
  138. }
  139. },
  140. initSize() {
  141. let clientWidth =
  142. document.documentElement.clientWidth || document.body.clientWidth;
  143. this.w = 500;
  144. this.x = clientWidth - (this.w + 10);
  145. this.y = 135;
  146. this.docY =
  147. document.documentElement.clientHeight || document.body.clientHeight;
  148. this.h = this.docY - this.y;
  149. },
  150. resizestop(e) {
  151. if (!this.fullscreen) {
  152. this.h = Math.abs(e.height);
  153. this.w = Math.abs(e.width);
  154. }
  155. setTimeout(() => {
  156. this.isResizing = false;
  157. }, 500);
  158. },
  159. onResizing(e) {
  160. // console.log(e)
  161. this.isResizing = true;
  162. this.x = e.left
  163. this.y = e.top
  164. if (e.top < 135) {
  165. // console.log('来了')
  166. this.y = 135;
  167. // document.documentElement.querySelector("#instructions").style.top =
  168. // "135px";
  169. }
  170. },
  171. resetBook() {
  172. this.isShow = false;
  173. this.$nextTick((res) => {
  174. let clientWidth =
  175. document.documentElement.clientWidth || document.body.clientWidth;
  176. this.docY =
  177. document.documentElement.clientHeight || document.body.clientHeight;
  178. this.w = 500;
  179. this.h = this.docY - this.y;
  180. this.y = 135;
  181. this.x = clientWidth - (this.w + 10);
  182. this.isShow = true;
  183. });
  184. },
  185. fullPageBook() {
  186. this.isShow = false;
  187. this.$nextTick((res) => {
  188. const bodyEle = document.querySelector(".app-main");
  189. this.h = this.docY - this.y;
  190. // document.querySelector('#instructions .content-container').style.width = this.w+'px'
  191. this.w = bodyEle.clientWidth;
  192. this.x = 210;
  193. this.y = 135;
  194. this.isShow = true;
  195. });
  196. },
  197. async showInstructions() {
  198. this.initSize();
  199. if (!this.isShow) {
  200. // 埋点
  201. try {
  202. const res = await operationLog({
  203. operateName: this.str,
  204. interfaceUrl: this.$route.path,
  205. });
  206. } catch (e) {}
  207. // console.log("埋点");
  208. }
  209. this.isShow = !this.isShow;
  210. },
  211. setBtnStatus(to) {
  212. this.str = "";
  213. if (instructionList.hasOwnProperty(to.path)) {
  214. this.isShowBtn = true;
  215. // this.$emit('checkShow',this.isShowBtn)
  216. // console.log(Object.prototype.toString.call(instructionList[to.path]),instructionList[to.path])
  217. if (
  218. Object.prototype.toString.call(instructionList[to.path]) ===
  219. "[object Object]"
  220. ) {
  221. // 对象 肯定是详情页
  222. // console.log('状态',to.query[keyOfValue[to.path]])
  223. let obj = {};
  224. if (instructionList[to.path][to.query[keyOfValue[to.path]]]) {
  225. let parameter = to.query[keyOfValue[to.path]];
  226. obj = { ...instructionList[to.path][parameter] };
  227. } else {
  228. obj = instructionList[to.path];
  229. }
  230. if (!to.query.tabrouter) {
  231. let some = Object.keys(obj)[0];
  232. this.url = `/html/index.html#g=1&p=${obj[some]}&c=1`;
  233. this.str = obj[some];
  234. } else {
  235. this.str = obj[to.query.tabrouter];
  236. // if (
  237. // to.path == "/business/resetTeaming" &&
  238. // to.query.tabrouter == "11"
  239. // ) {
  240. // to.query.team_status == "APPLY"
  241. // ? (this.str = "乐团报名")
  242. // : (this.str = "乐团缴费");
  243. // }
  244. // if (
  245. // to.path == "/business/resetTeaming" &&
  246. // (to.query.tabrouter == "3" || to.query.tabrouter == "6") &&
  247. // to.query.team_status == "PROGRESS"
  248. // ) {
  249. // this.str = "缴费项目创建";
  250. // }
  251. if (obj[to.query.tabrouter]) {
  252. this.url = `/html/index.html#g=1&p=${this.str}&c=1`;
  253. // 判断一下 如果是乐团详情 就判断
  254. } else {
  255. this.isShowBtn = false;
  256. }
  257. }
  258. } else {
  259. // 字符串
  260. this.url = `/html/index.html#g=1&p=${instructionList[to.path]}&c=1`;
  261. this.str = instructionList[to.path];
  262. }
  263. } else {
  264. this.isShowBtn = false;
  265. }
  266. console.log(this.isShowBtn);
  267. this.$emit("checkShow", this.isShowBtn);
  268. },
  269. showFullPage() {},
  270. resetVideo() {},
  271. gotoIns() {
  272. let str = this.url.replace("&c=1", "");
  273. this.$router.push({
  274. path: "/instructions/instructions",
  275. query: { url: str },
  276. });
  277. },
  278. },
  279. computed: {
  280. // key() {
  281. // console.log(this.$route);
  282. // this.isShow = false;
  283. // return this.$route.path;
  284. // },
  285. iframeWidth() {
  286. return this.w + "px";
  287. },
  288. iframeHeight() {
  289. return this.h - 30 + "px";
  290. },
  291. fullscreen() {
  292. const bodyEle = document.querySelector(".app-main");
  293. // this.h = this.docY - this.y;
  294. return (
  295. this.h == this.docY - this.y &&
  296. this.w == bodyEle.clientWidth &&
  297. this.x == 210 &&
  298. this.y == 135
  299. );
  300. },
  301. // fullscreenVideo() {
  302. // const bodyEle = document.querySelector(".app-main");
  303. // return (
  304. // this.videoH == this.docY - this.y &&
  305. // this.videoW == bodyEle.clientWidth &&
  306. // this.x == 210 &&
  307. // this.y == 130
  308. // );
  309. // },
  310. },
  311. watch: {
  312. $route(to, from) {
  313. this.isShow = false;
  314. this.setBtnStatus(to);
  315. },
  316. isShow(val) {
  317. if (val) {
  318. this.$nextTick((res) => {
  319. let outFrame = this.$refs.iframe;
  320. let outFrameWindow = this.$refs.iframe.contentWindow;
  321. setTimeout((res) => {
  322. let rightFrame = outFrameWindow.document.querySelector(
  323. "#mainFrame"
  324. );
  325. rightFrame.contentWindow.document.addEventListener(
  326. "click",
  327. (e) => {
  328. let path = (e.composedPath && e.composedPath()) || e.path || [];
  329. if (path.length > 0) {
  330. for (let i in path) {
  331. if (path[i]?.getAttribute("title")) {
  332. console.log(
  333. "打开视频链接",
  334. e.path[i].getAttribute("title")
  335. );
  336. this.src = e.path[i].getAttribute("title");
  337. this.showVideo = true;
  338. this.$nextTick((res) => {
  339. this.isShow = false;
  340. });
  341. // this.isShow = false;
  342. break;
  343. }
  344. }
  345. } else {
  346. this.$message.error(
  347. "该浏览器不支持,请更换或升级chrome浏览器"
  348. );
  349. }
  350. // let document
  351. },
  352. true
  353. );
  354. }, 500);
  355. });
  356. }
  357. },
  358. },
  359. };
  360. </script>
  361. <style lang="scss" scoped>
  362. .iframeDiv {
  363. width: 100%;
  364. height: 100%;
  365. position: absolute;
  366. z-index: 2000;
  367. filter: alpha(opacity=0);
  368. opacity: 0;
  369. background: transparent;
  370. /*display: none;*/
  371. }
  372. .content-container {
  373. .showBtnList {
  374. display: flex;
  375. flex-direction: row;
  376. align-items: center;
  377. justify-content: space-around;
  378. font-size: 20px;
  379. position: absolute;
  380. right: 5px;
  381. top: 0;
  382. background-color: #ccc;
  383. height: 30px;
  384. z-index: 2000;
  385. .icon {
  386. line-height: 30px;
  387. }
  388. }
  389. }
  390. .wall {
  391. height: 30px;
  392. background-color: #ccc;
  393. cursor: pointer;
  394. }
  395. .videowall {
  396. height: 30px;
  397. background-color: #ccc;
  398. }
  399. .fullscreen {
  400. padding: 0 5px;
  401. font-size: 20px;
  402. }
  403. .add {
  404. padding: 0 5px;
  405. font-size: 20px;
  406. font-weight: bold;
  407. color: #707070;
  408. }
  409. .addPuls {
  410. padding: 0 5px;
  411. font-size: 20px;
  412. color: #707070;
  413. }
  414. .huanyuan {
  415. padding: 0 5px;
  416. font-size: 22px;
  417. }
  418. .newPageBtn {
  419. font-size: 14px;
  420. line-height: 30px;
  421. color: #14928a;
  422. height: 30px;
  423. display: inline-block;
  424. }
  425. </style>
  426. <style lang="scss">
  427. // .instructionWrap{
  428. // position: absolute;
  429. // z-index: 2000;
  430. // }
  431. .instructionBtn {
  432. position: fixed;
  433. right: 30px;
  434. top: 200px;
  435. z-index: 2000;
  436. }
  437. .iframeId {
  438. width: 100%;
  439. }
  440. #instructions {
  441. background-color: #fff;
  442. position: fixed;
  443. z-index: 9998 !important;
  444. border: 1px solid #ccc;
  445. }
  446. .vdr-stick {
  447. opacity: 0;
  448. }
  449. .vdr-stick-tm,
  450. .vdr-stick-bm {
  451. width: 99% !important;
  452. width: calc(100% - 8px) !important;
  453. margin-left: 0 !important;
  454. left: 4px;
  455. // margin-left: -50%!important;
  456. }
  457. .vdr-stick-mr,
  458. .vdr-stick-ml {
  459. height: 99% !important;
  460. height: calc(100% - 8px) !important;
  461. margin-top: 0 !important;
  462. top: 4px !important;
  463. }
  464. .vdr {
  465. &:before {
  466. outline: 0px dashed #d6d6d6 !important;
  467. }
  468. }
  469. .icon {
  470. cursor: pointer;
  471. color: #707070;
  472. }
  473. </style>