123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- // 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 Vue from 'vue'
- import FastClick from 'fastclick'
- import VueRouter from 'vue-router'
- import VueResource from 'vue-resource'
- import App from './App.vue'
- import Vuex from 'vuex'
- import {ConfirmPlugin} from 'vux'
- import VueVideoPlayer from 'vue-video-player'
- import {ToastPlugin} from 'vux'
- import routes from './router/routes'
- import WechatShare from './wechat/WechatShare'
- import {base64} from 'vux'
- import CommonUtil from './components/util/commonUtil.js'
- import Actions from './lib/Actions'
- Vue.use(VueRouter);
- Vue.use(VueResource);
- Vue.use(Vuex);
- Vue.use(VueVideoPlayer);
- Vue.use(ToastPlugin);
- Vue.use(ConfirmPlugin);
- const store = new Vuex.Store({
- state: {
- isLoading: false,
- isLogIn: false,
- user: {
- name: '',
- image: ''
- },
- changeState: {
- action: null,
- action_id: -1
- },
- user_bonus: [],
- address:{
- aid:'',
- name:'',
- mobile:'',
- address:''
- },
- wechatShareMsg:{
- title:'熊猫美妆测试版',
- desc:'熊猫美妆即将上线',
- link:window.location.host,
- imgUrl:'http://manager.lrlz.com/data/upload/shop/store/goods/6/6_05065318508868273_360.jpg'
- }
- },
- mutations: {
- updateLoadingStatus (state, payload) {
- state.isLoading = payload.isLoading
- },
- updateLogIn(state){
- state.isLogIn = true
- },
- updateUser(state, payload){
- state.user['name'] = payload.name;
- state.user['image'] = payload.image;
- },
- updateOrderState(state, payload){
- state.changeState.action = payload.action;
- state.changeState.action_id = payload.action_id;
- },
- updateUser_bonus(state, payload) {
- state.user_bonus = payload.array;
- },
- update_address(state, payload){
- state.address.name = payload.name;
- state.address.mobile = payload.mobile;
- state.address.address = payload.address;
- state.address.aid = payload.aid;
- },
- updateWxShareMsg(state,payload){
- state.wechatShareMsg.title = payload.title;
- state.wechatShareMsg.desc = payload.desc;
- state.wechatShareMsg.link = payload.link;
- state.wechatShareMsg.imgUrl = payload.imgUrl;
- }
- }
- });
- const scrollBehavior = (to, from, savedPosition) => {
- if (savedPosition) {
- setTimeout(() => {
- document.body.scrollTop = savedPosition.y
- }, 100);
- return savedPosition
- }
- return {
- x: 0,
- y: 0
- };
- };
- const router = new VueRouter({
- routes,
- scrollBehavior,
- mode: 'hash'
- });
- router.beforeEach(function (to, from, next) {
- if (to.path.indexOf("schema") !== -1) {
- let schema = base64.decode(to.query.schema);
- let urlObj = CommonUtil.parseURL(schema);
- let path = urlObj.path;
- switch (path) {
- case "//p.lrlz.com/web/web":
- let title = decodeURI(urlObj.params.title);
- let url = base64.encode(decodeURIComponent(urlObj.params.url));
- next(Actions.getWebViewPath(title, url));
- break
- }
- } else {
- next();
- }
- });
- let Wechat_share = new WechatShare(store.state.wechatShareMsg);
- FastClick.attach(document.body);
- Vue.config.productionTip = false;
- Vue.directive('document_title', {
- inserted: function (el, binding) {
- document.title = el.innerText;
- el.remove();
- }
- });
- /* eslint-disable no-new */
- new Vue({
- store,
- router,
- render: h => h(App)
- }).$mount('#app-box');
|