index.js 6.5 KB

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