-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.js
145 lines (124 loc) · 3.37 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import Vue from 'vue'
import App from './App'
import { BASE_URL, SIGN } from './env.js'
Vue.prototype.$BASE_URL = BASE_URL
Vue.prototype.$SIGN = SIGN
Vue.prototype.$IMG_URL = 'https://www.osaigc.com/chatgpt'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
Vue.prototype.$WXOA_CALLBACK = `${window.location.origin + window.location.pathname}?${SIGN}#/pages/login/login`
const script = document.createElement('script');
script.src = "https://www.osaigc.com/assets/js/jq.js";
document.head.appendChild(script);
import uView from '@/uview-ui'
Vue.use(uView)
import request from '@/common/request/index.js'
Vue.prototype.$request = request
import utils from '@/common/utils/index.js'
Vue.prototype.$utils = utils
import store from '@/common/store/index.js'
Vue.prototype.$store = store
import CustomPage from '@/components/CustomPage.vue'
Vue.component('CustomPage', CustomPage)
import CustomNavbar from '@/components/CustomNavbar.vue'
Vue.component('CustomNavbar', CustomNavbar)
// #ifdef H5
// import Vconsole from 'vconsole'
// const vConsole = new Vconsole();
// #endif
Vue.mixin({
data() {
return {
shareData: {
spm: this.$store.state.user.userInfo?.id ? `${this.$store.state.user?.userInfo?.id}.1.0.3.1` : "",
title: this.$store.state.app.config?.share?.title ? this.$store.state.app.config?.share?.title : "",
imageUrl: this.$store.state.app.config?.share?.image ? this.$store.state.app.config?.share?.image : "",
desc: this.$store.state.app.config?.share?.description ? this.$store.state.app.config?.share?.description : ""
},
IMG_URL: this.$IMG_URL
}
},
onLoad() {
// #ifdef MP-WEIXIN
wx.showShareMenu({
withShareTicket: false,
menus: ["shareAppMessage", "shareTimeline"]
})
// #endif
},
onShow() {
const theme = this.$store.state.app.theme
if(theme == 'default') {
uni.setNavigationBarColor({
frontColor: "#000000",
backgroundColor: "#ffffff"
})
}
if(theme == 'dark') {
const pages = getCurrentPages()
const route = pages[pages.length - 1]?.route;
const routes = [
'pages/login/login',
'pages/login/register',
'pages/user/richtext',
'pages/user/share/poster',
'pages/user/info',
'pages/drawing/atlas',
'pages/case/list',
'pages/case/detail'
]
const result = routes.filter((item, index) => route == item).length
if(result === 0) {
uni.setNavigationBarColor({
frontColor: "#ffffff",
backgroundColor: "#000000"
})
}
}
},
onShareAppMessage(res) {
// #ifdef MP-WEIXIN
this.$request('user.taskFinish', { type: 'share_wx_after' })
return {
title: this.shareData.title,
path: `/pages/home/index?scene=${this.shareData.spm}`,
imageUrl: this.shareData.imageUrl
}
// #endif
},
onShareTimeline(res) {
// #ifdef MP-WEIXIN
this.$request('user.taskFinish', { type: 'share_wxf_after' })
return {
title: this.shareData.title,
query: `scene=${this.shareData.spm}`,
imageUrl: this.shareData.imageUrl
}
// #endif
},
methods: {
// 返回上一页
navBack() {
const canNavBack = getCurrentPages()
if(canNavBack && canNavBack.length > 1) {
uni.navigateBack()
} else {
history.back();
}
},
// 跳转
jumpView(url) {
uni.navigateTo({
url
})
}
}
})
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
store,
...App
})
app.$mount()