index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import Vue from 'vue'
  2. import config from '../config'
  3. import bus from '../utils/eventbus'
  4. import {
  5. Alert,
  6. Confirm,
  7. Tips
  8. } from '../components/shared/message'
  9. import clickoutside from './v-clickoutside'
  10. import clickwindow from './v-clickwindow'
  11. import * as api from '../api'
  12. Vue.prototype.$bus = bus
  13. Vue.prototype.$api = api
  14. Vue.prototype.$intranet = config.intranet
  15. Vue.prototype.$cdn = config.CDN
  16. Vue.prototype.$config = config
  17. Vue.prototype.$panoType = [{
  18. id:'building',
  19. name:'楼盘全景'
  20. },{
  21. id:'garden',
  22. name:'园林全景'
  23. },{
  24. id:'house',
  25. name:'户型'
  26. }]
  27. Vue.prototype.$nameStr = {
  28. 'building':'楼盘全景',
  29. 'garden':'园林全景',
  30. 'house':'户型'
  31. }
  32. Vue.prototype.$nameSort = {
  33. 'building':1,
  34. 'garden':2,
  35. 'house':3
  36. }
  37. Vue.prototype.$scrollbars = []
  38. let SettingPanel = require('@/framework/SettingPC').default
  39. Vue.mixin({
  40. components: {
  41. SettingPanel
  42. },
  43. directives: {
  44. 'clickoutside': clickoutside,
  45. 'clickwindow': clickwindow
  46. },
  47. data() {
  48. return {
  49. }
  50. },
  51. methods: {
  52. $alert(data = {}) {
  53. let instance = new Alert({
  54. data
  55. }).$mount()
  56. document.body.appendChild(instance.$el)
  57. Vue.nextTick(() => {
  58. instance.show = true
  59. })
  60. },
  61. $confirm(data = {}) {
  62. let instance = new Confirm({
  63. data
  64. }).$mount()
  65. document.body.appendChild(instance.$el)
  66. Vue.nextTick(() => {
  67. instance.show = true
  68. })
  69. },
  70. $tips(data = {}) {
  71. let instance = new Tips({
  72. data
  73. }).$mount()
  74. document.body.appendChild(instance.$el)
  75. Vue.nextTick(() => {
  76. instance.show = true
  77. })
  78. },
  79. $getStaticResource(url) {
  80. return config.getStaticResource(url)
  81. },
  82. $html_encode(str){
  83. return config.html_encode(str)
  84. },
  85. $getKrpano(str){
  86. return config.getKrpano(str)
  87. },
  88. $randomWord(randomFlag, min, max) {//随机字符串
  89. var str = "",
  90. range = min,
  91. arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
  92. if (randomFlag) { // 随机长度
  93. range = Math.round(Math.random() * (max - min)) + min;
  94. }
  95. for (var i = 0; i < range; i++) {
  96. var pos = Math.round(Math.random() * (arr.length - 1));
  97. str += arr[pos];
  98. }
  99. return str;
  100. },
  101. $htmlEncode(str) {
  102. var s = "";
  103. if (str.length == 0) return "";
  104. s = str.replace(/\'/g, "&#39;");
  105. s = s.replace(/\"/g, "&quot;");
  106. s = s.replace(/\(/g, "(");
  107. s = s.replace(/\)/g, ")");
  108. s = s.replace(/,/g, ",");
  109. return s;
  110. },
  111. $deleteKRHotspot(data){
  112. let krpano = document.getElementById('krpanoSWFObject');
  113. let HV = window.__krfn.utils.getHotspotHV(krpano,data.name);
  114. krpano.call('removehotspot('+data.name+',true);');
  115. krpano.call('removeplugin(' + ('tooltip_' + data.name) + ',true);');
  116. return HV
  117. },
  118. $refreshHotspot(data){
  119. let HV = this.$deleteKRHotspot(data)
  120. data.ath = HV.ath
  121. data.atv = HV.atv
  122. this.$bus.emit("addhotspot", data);
  123. }
  124. }
  125. })