123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- import Vue from "vue";
- import config from "../config";
- import bus from "../utils/eventbus.js";
- import { Alert, Confirm, Tips } from "../components/shared/message";
- import clickoutside from "./v-clickoutside";
- import clickwindow from "./v-clickwindow";
- import * as api from "../api";
- import { Message, InfiniteScroll } from 'element-ui'
- const MARERIAL = ["image", "pano", "scene", "audio", "video"];
- const MAPTABLEHEADER = {};
- MARERIAL.forEach((item) => {
- MAPTABLEHEADER[item] = require(`@/views/material/${item}/${item}`).data;
- });
- console.log('$MAPTABLEHEADER: ', MAPTABLEHEADER);
- const MARERIALSTR = {
- image: "图片",
- pano: "全景图",
- scene: "场景",
- audio: "音频",
- video: "视频",
- };
- let STRSTATUS = {
- 1: "制作中",
- 2: "制作失败",
- 3: "制作成功",
- 4: "上传中",
- 5: "上传失败"
- };
- Vue.use(InfiniteScroll)
- Vue.prototype.$bus = bus;
- Vue.prototype.$api = api;
- Vue.prototype.$intranet = config.intranet;
- Vue.prototype.$cdn = config.CDN;
- Vue.prototype.$config = config;
- Vue.prototype.$thumb = config.thumb;
- Vue.prototype.$noresult = config.noresult;
- Vue.prototype.$MAPTABLEHEADER = MAPTABLEHEADER;
- Vue.prototype.$MARERIALSTR = MARERIALSTR;
- Vue.prototype.$STRSTATUS = STRSTATUS;
- Vue.prototype.$msg = (data)=>{
- return Message({
- offset: 85,
- ...data
- });
- }
- Vue.prototype.$msg.success = (string)=>{
- return Message.success({
- offset: 85,
- message: string,
- duration: 1000
- });
- }
- Vue.prototype.$msg.warning = (string)=>{
- return Message.warning({
- offset: 85,
- message: string,
- duration: 1000
- });
- }
- Vue.prototype.$msg.message = (string)=>{
- return Message.info({
- offset: 85,
- message: string,
- duration: 1000
- });
- }
- Vue.prototype.$msg.error = (string)=>{
- return Message.error({
- offset: 85,
- message: string,
- duration: 1000
- });
- }
- Vue.prototype.$videoImg =
- "?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto";
- Vue.prototype.$panoType = [
- {
- id: "building",
- name: "楼盘全景",
- },
- {
- id: "garden",
- name: "园林全景",
- },
- {
- id: "house",
- name: "户型",
- },
- ];
- Vue.prototype.$nameStr = {
- building: "楼盘全景",
- garden: "园林全景",
- house: "户型",
- };
- Vue.prototype.$nameSort = {
- building: 1,
- garden: 2,
- house: 3,
- };
- Vue.prototype.$scrollbars = [];
- // todo: 无用了
- let SettingPanel = require("@/framework/SettingPC").default;
- Vue.mixin({
- components: {
- SettingPanel,
- },
- directives: {
- clickoutside: clickoutside,
- clickwindow: clickwindow,
- },
- data() {
- return {};
- },
- methods: {
- $alert(data = {}) {
- let instance = new Alert({
- data,
- }).$mount();
- document.body.appendChild(instance.$el);
- Vue.nextTick(() => {
- instance.show = true;
- });
- },
- $confirm(data = {}) {
- let instance = new Confirm({
- data,
- }).$mount();
- document.body.appendChild(instance.$el);
- Vue.nextTick(() => {
- instance.show = true;
- });
- },
- $tips(data = {}) {
- let instance = new Tips({
- data,
- }).$mount();
- document.body.appendChild(instance.$el);
- Vue.nextTick(() => {
- instance.show = true;
- });
- },
- $isCacheId(id) {
- return String(id).indexOf("tmp") > -1;
- },
- $getStaticResource(url) {
- return config.getStaticResource(url);
- },
- $html_encode(str) {
- return config.html_encode(str);
- },
- $getKrpano(str) {
- return config.getKrpano(str);
- },
- $randomWord(randomFlag, min, max) {
- //随机字符串
- var str = "",
- range = min,
- 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",
- ];
- if (randomFlag) {
- // 随机长度
- range = Math.round(Math.random() * (max - min)) + min;
- }
- for (var i = 0; i < range; i++) {
- var pos = Math.round(Math.random() * (arr.length - 1));
- str += arr[pos];
- }
- return str;
- },
- $unique(arr) {
- let map = new Map();
- let array = new Array(); // 数组用于返回结果
- for (let i = 0; i < arr.length; i++) {
- if (map.has(arr[i])) {
- // 如果有该key值
- map.set(arr[i], true);
- } else {
- map.set(arr[i], false); // 如果没有该key值
- array.push(arr[i]);
- }
- }
- return array;
- },
- $iosGrantedTips(cb) {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf("like mac os x") > 0) {
- var reg = /os [\d._]*/gi;
- var verinfo = ua.match(reg);
- var version = (verinfo + "")
- .replace(/[^0-9|_.]/gi, "")
- .replace(/_/gi, ".");
- var arr = version.split(".");
- console.log(arr);
-
- if (arr[0] > 12 && arr[1] >= 0) {
- //对13.3以后的版本处理,包括13.3,
- DeviceMotionEvent && DeviceMotionEvent.requestPermission()
- .then((permissionState) => {
- if (permissionState == "granted") {
- cb({
- msg:'授权成功',
- code:1
- })
- this.reload();
- } else {
- cb({
- msg:'授权失败',
- code:0
- })
- }
- })
- }
- else {
- //13.3以前的版本
- cb({
- msg:'无需授权,直接成功',
- code:1
- })
- }
- } else{
- cb({
- msg:'无需授权,直接成功',
- code:1
- })
- }
- },
- $htmlEncode(str) {
- var s = "";
- if (str.length == 0) return "";
- s = str.replace(/\'/g, "'");
- s = s.replace(/\"/g, """);
- s = s.replace(/\(/g, "(");
- s = s.replace(/\)/g, ")");
- s = s.replace(/,/g, ",");
- return s;
- },
- },
- });
|