main.js 1.49 KB
Newer Older
张成 committed
1
import App from './App';
zhangpeng committed
2
//引入vuex
张成 committed
3 4
import store from './store';
import utils from './utils/utils';
zhangcheng committed
5

zhangpeng committed
6
// console.log(Vue.$u,22)
zhangpeng committed
7 8
// 需要在Vue.use(uView)之后执行
// #ifndef VUE3
张成 committed
9
import Vue from 'vue';
10
import Vuex from 'vuex'
zhangcheng committed
11
import uView from 'uview-ui';
张成 committed
12 13
import User from '@/request/user';

14 15 16 17 18 19 20 21
// main.js
import initToast from "@/components/bocft-toast/initToast.js"
import showToast from "@/components/bocft-toast/bocft-toast.vue"

initToast(Vue);
Vue.component('show-toast',showToast);


zhangcheng committed
22
Vue.use(uView);
张成 committed
23 24 25
Vue.prototype.$utils = utils;
Vue.prototype.setPrice = (price) => price && Number(price).toFixed(2);

宋冰琦 committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

// #ifdef MP-WEIXIN
Vue.mixin({
  methods:{
      setTabBarIndex(index) {
          if (typeof this.$mp.page.getTabBar === 'function' &&
          this.$mp.page.getTabBar()) {
              this.$mp.page.getTabBar().setData({
                  selected: index
              })
          }
      }
  }
})
// #endif


张成 committed
43 44 45 46 47 48 49 50 51 52 53
Vue.prototype.loginByPhoneNumber = (e) => {
  if (e.detail.errMsg == 'getPhoneNumber:ok') {
    User.getPhoneNumber(e);
  } else if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
    uni.showToast({ title: '已拒绝手机号授权', icon: 'error' });
  }
};

Vue.config.productionTip = false;

App.mpType = 'app';
zhangpeng committed
54
const app = new Vue({
张成 committed
55 56 57
  ...App,
  store,
});
58
export default app
张成 committed
59 60
app.$mount();
require('./request/index')(app);
zhangpeng committed
61 62 63
// #endif

// #ifdef VUE3
张成 committed
64
import { createSSRApp } from 'vue';
zhangpeng committed
65
export function createApp() {
张成 committed
66
  const app = createSSRApp(App);
zhangpeng committed
67
  return {
张成 committed
68 69
    app,
  };
zhangpeng committed
70
}
张成 committed
71
// #endif