index.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. import Vue from "vue";
  2. import config from "../config";
  3. import bus from "../utils/eventbus.js";
  4. import { Alert, Confirm, Tips } from "../components/shared/message";
  5. import clickoutside from "./v-clickoutside";
  6. import clickwindow from "./v-clickwindow";
  7. import * as api from "../api";
  8. import { Message, InfiniteScroll } from 'element-ui'
  9. const MARERIAL = ["image", "pano", "scene", "audio", "video"];
  10. const MAPTABLEHEADER = {};
  11. MARERIAL.forEach((item) => {
  12. MAPTABLEHEADER[item] = require(`@/views/material/${item}/${item}`).data;
  13. });
  14. console.log('$MAPTABLEHEADER: ', MAPTABLEHEADER);
  15. const MARERIALSTR = {
  16. image: "图片",
  17. pano: "全景图",
  18. scene: "场景",
  19. audio: "音频",
  20. video: "视频",
  21. };
  22. let STRSTATUS = {
  23. 1: "制作中",
  24. 2: "制作失败",
  25. 3: "制作成功",
  26. 4: "上传中",
  27. 5: "上传失败"
  28. };
  29. Vue.use(InfiniteScroll)
  30. Vue.prototype.$bus = bus;
  31. Vue.prototype.$api = api;
  32. Vue.prototype.$intranet = config.intranet;
  33. Vue.prototype.$cdn = config.CDN;
  34. Vue.prototype.$config = config;
  35. Vue.prototype.$thumb = config.thumb;
  36. Vue.prototype.$noresult = config.noresult;
  37. Vue.prototype.$MAPTABLEHEADER = MAPTABLEHEADER;
  38. Vue.prototype.$MARERIALSTR = MARERIALSTR;
  39. Vue.prototype.$STRSTATUS = STRSTATUS;
  40. Vue.prototype.$msg = (data)=>{
  41. return Message({
  42. offset: 85,
  43. ...data
  44. });
  45. }
  46. Vue.prototype.$msg.success = (string)=>{
  47. return Message.success({
  48. offset: 85,
  49. message: string,
  50. duration: 1000
  51. });
  52. }
  53. Vue.prototype.$msg.warning = (string)=>{
  54. return Message.warning({
  55. offset: 85,
  56. message: string,
  57. duration: 1000
  58. });
  59. }
  60. Vue.prototype.$msg.message = (string)=>{
  61. return Message.info({
  62. offset: 85,
  63. message: string,
  64. duration: 1000
  65. });
  66. }
  67. Vue.prototype.$msg.error = (string)=>{
  68. return Message.error({
  69. offset: 85,
  70. message: string,
  71. duration: 1000
  72. });
  73. }
  74. Vue.prototype.$videoImg =
  75. "?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto";
  76. Vue.prototype.$panoType = [
  77. {
  78. id: "building",
  79. name: "楼盘全景",
  80. },
  81. {
  82. id: "garden",
  83. name: "园林全景",
  84. },
  85. {
  86. id: "house",
  87. name: "户型",
  88. },
  89. ];
  90. Vue.prototype.$nameStr = {
  91. building: "楼盘全景",
  92. garden: "园林全景",
  93. house: "户型",
  94. };
  95. Vue.prototype.$nameSort = {
  96. building: 1,
  97. garden: 2,
  98. house: 3,
  99. };
  100. Vue.prototype.$scrollbars = [];
  101. // todo: 无用了
  102. let SettingPanel = require("@/framework/SettingPC").default;
  103. Vue.mixin({
  104. components: {
  105. SettingPanel,
  106. },
  107. directives: {
  108. clickoutside: clickoutside,
  109. clickwindow: clickwindow,
  110. },
  111. data() {
  112. return {};
  113. },
  114. methods: {
  115. $alert(data = {}) {
  116. let instance = new Alert({
  117. data,
  118. }).$mount();
  119. document.body.appendChild(instance.$el);
  120. Vue.nextTick(() => {
  121. instance.show = true;
  122. });
  123. },
  124. $confirm(data = {}) {
  125. let instance = new Confirm({
  126. data,
  127. }).$mount();
  128. document.body.appendChild(instance.$el);
  129. Vue.nextTick(() => {
  130. instance.show = true;
  131. });
  132. },
  133. $tips(data = {}) {
  134. let instance = new Tips({
  135. data,
  136. }).$mount();
  137. document.body.appendChild(instance.$el);
  138. Vue.nextTick(() => {
  139. instance.show = true;
  140. });
  141. },
  142. $isCacheId(id) {
  143. return String(id).indexOf("tmp") > -1;
  144. },
  145. $getStaticResource(url) {
  146. return config.getStaticResource(url);
  147. },
  148. $html_encode(str) {
  149. return config.html_encode(str);
  150. },
  151. $getKrpano(str) {
  152. return config.getKrpano(str);
  153. },
  154. $randomWord(randomFlag, min, max) {
  155. //随机字符串
  156. var str = "",
  157. range = min,
  158. arr = [
  159. "0",
  160. "1",
  161. "2",
  162. "3",
  163. "4",
  164. "5",
  165. "6",
  166. "7",
  167. "8",
  168. "9",
  169. "a",
  170. "b",
  171. "c",
  172. "d",
  173. "e",
  174. "f",
  175. "g",
  176. "h",
  177. "i",
  178. "j",
  179. "k",
  180. "l",
  181. "m",
  182. "n",
  183. "o",
  184. "p",
  185. "q",
  186. "r",
  187. "s",
  188. "t",
  189. "u",
  190. "v",
  191. "w",
  192. "x",
  193. "y",
  194. "z",
  195. "A",
  196. "B",
  197. "C",
  198. "D",
  199. "E",
  200. "F",
  201. "G",
  202. "H",
  203. "I",
  204. "J",
  205. "K",
  206. "L",
  207. "M",
  208. "N",
  209. "O",
  210. "P",
  211. "Q",
  212. "R",
  213. "S",
  214. "T",
  215. "U",
  216. "V",
  217. "W",
  218. "X",
  219. "Y",
  220. "Z",
  221. ];
  222. if (randomFlag) {
  223. // 随机长度
  224. range = Math.round(Math.random() * (max - min)) + min;
  225. }
  226. for (var i = 0; i < range; i++) {
  227. var pos = Math.round(Math.random() * (arr.length - 1));
  228. str += arr[pos];
  229. }
  230. return str;
  231. },
  232. $unique(arr) {
  233. let map = new Map();
  234. let array = new Array(); // 数组用于返回结果
  235. for (let i = 0; i < arr.length; i++) {
  236. if (map.has(arr[i])) {
  237. // 如果有该key值
  238. map.set(arr[i], true);
  239. } else {
  240. map.set(arr[i], false); // 如果没有该key值
  241. array.push(arr[i]);
  242. }
  243. }
  244. return array;
  245. },
  246. $iosGrantedTips(cb) {
  247. var ua = navigator.userAgent.toLowerCase();
  248. if (ua.indexOf("like mac os x") > 0) {
  249. var reg = /os [\d._]*/gi;
  250. var verinfo = ua.match(reg);
  251. var version = (verinfo + "")
  252. .replace(/[^0-9|_.]/gi, "")
  253. .replace(/_/gi, ".");
  254. var arr = version.split(".");
  255. console.log(arr);
  256. if (arr[0] > 12 && arr[1] >= 0) {
  257. //对13.3以后的版本处理,包括13.3,
  258. DeviceMotionEvent && DeviceMotionEvent.requestPermission()
  259. .then((permissionState) => {
  260. if (permissionState == "granted") {
  261. cb({
  262. msg:'授权成功',
  263. code:1
  264. })
  265. this.reload();
  266. } else {
  267. cb({
  268. msg:'授权失败',
  269. code:0
  270. })
  271. }
  272. })
  273. }
  274. else {
  275. //13.3以前的版本
  276. cb({
  277. msg:'无需授权,直接成功',
  278. code:1
  279. })
  280. }
  281. } else{
  282. cb({
  283. msg:'无需授权,直接成功',
  284. code:1
  285. })
  286. }
  287. },
  288. $htmlEncode(str) {
  289. var s = "";
  290. if (str.length == 0) return "";
  291. s = str.replace(/\'/g, "&#39;");
  292. s = s.replace(/\"/g, "&quot;");
  293. s = s.replace(/\(/g, "(");
  294. s = s.replace(/\)/g, ")");
  295. s = s.replace(/,/g, ",");
  296. return s;
  297. },
  298. },
  299. });