快乐论文相关业务h5端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

104 lines
3.1 KiB

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill';
import App from './App'
import router from './router'
import VueWechatTitle from 'vue-wechat-title'
import VueTouch from 'vue-touch'
import VueClipboard from 'vue-clipboard2'
// 导入全局变量模块
import _global from './components/utils/Global'
Vue.prototype.GLOBAL = _global
//倒入全局weui
import 'weui'
import weui from 'weui.js'
Vue.prototype.$weui = weui;
require('es6-promise').polyfill();
Vue.config.productionTip = false
Vue.use(VueWechatTitle)
Vue.use(VueTouch)
Vue.use(VueClipboard)
Vue.use(VueLazyload, {
error: '',//这个是请求失败后显示的图片
loading: 'static/loading.gif',//这个是加载的loading过渡效果
try: 4 // 这个是加载图片数量
})
Vue.http.interceptors.push(function (request, next) {//拦截器
// 跨域携带cookie
request.credentials = true;
request.crossDomain = true;
// request.Cookies = document.cookie;
next()
})
Vue.http.headers = {'Content-Type': 'application/x-www-form-urlencoded'}
Vue.http.options.xhr = {withCredentials: true}
Vue.http.options.emulateJSON = true
let query = {};
if (window.location.href.split('?')[1]) {
query = window.location.href.split('?')[1].split('&').reduce(function (ret, pair) {
pair = pair.split('=');
ret[pair[0]] = pair[1];
return ret;
}, {});
}
if(query.url){
const parsedUrl = new URL(decodeURIComponent(query.url));
localStorage.setItem('query_url', query.url);
localStorage.setItem('agent_url', parsedUrl.origin);
}
//判断是否登录
let cookieobj = document.cookie;
let Cookies = {};
cookieobj.split(';').forEach(l => {
var parts = l.split('=');
Cookies[parts[0].trim()] = (parts[1] || '').trim();
});
let islogin = false;
let site_uid = Cookies['site_uid'];
let openid = 'openid_' + site_uid;
if (Cookies[openid] && Cookies['site_uid']) {
islogin = true;
}
window.islogin = false;
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: {App},
template: '<App/>',
mounted: function () {
if(window.location.href.indexOf('h5OpenError') === -1){
let agent_url = localStorage.getItem('agent_url');
if(agent_url === null || agent_url === ""){
let error = {
title_error:"商家尚未开通手机访问功能",
detail_error_one:"商家尚未开通手机访问功能",
}
localStorage.setItem('H5OpenError', JSON.stringify(error));
this.$router.push({ path: '/h5OpenError' });
return false;
}
let isweixin = navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1;
if (!isweixin) {
let error = {
title_error:"只支持在微信中访问",
detail_error_one:"移动端只能在微信浏览器中访问",
detail_error_two:"请复制链接发送到手机微信端或者电脑端访问",
device:"手机微信端或者电脑端",
}
localStorage.setItem('H5OpenError', JSON.stringify(error));
this.$router.push({ path: '/h5OpenError?url=' + this.query_url });
return false;
}
}
}
});