diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..2db8a54 --- /dev/null +++ b/.env.development @@ -0,0 +1,5 @@ +NODE_ENV='development' + +VITE_API_URL='http://www.hylszsh.cn/Api/' + +VITE_OSS_URL='http://www.hylszsh.cn/Api/StaticFiles/' \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..4497eef --- /dev/null +++ b/.env.production @@ -0,0 +1,5 @@ +NODE_ENV='production' + +VITE_API_URL='http://www.hylszsh.cn/Api/' + +VITE_OSS_URL='http://www.hylszsh.cn/Api/StaticFiles/' \ No newline at end of file diff --git a/package.json b/package.json index 0b9b5cc..97b17c0 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,10 @@ }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", - "axios": "^1.7.9", "canvas2image": "^1.0.5", "element-plus": "^2.9.4", "html2canvas": "^1.4.1", "jquery": "^3.7.1", - "pan.template.h5": "file:", "postcss-px-to-viewport": "^1.1.1", "vant": "^4.9.9", "vue": "^3.2.45", diff --git a/src/api/common.js b/src/api/common.js deleted file mode 100644 index fe1e925..0000000 --- a/src/api/common.js +++ /dev/null @@ -1,11 +0,0 @@ -import http from '../utils/http'; - -const CommonAPI = { - Post(name, data, index, size) { - if (index) - return http.post(`Common/${name}`, { data: data, PageIndex: index, PageSize: size }); - return http.post(`Common/${name}`, { data: data }); - }, -} - -export default CommonAPI; \ No newline at end of file diff --git a/src/api/member.js b/src/api/member.js deleted file mode 100644 index a120b51..0000000 --- a/src/api/member.js +++ /dev/null @@ -1,17 +0,0 @@ -import http from '../utils/http' - -const MemberAPI = { - WXAuthorize(data) { - return http.get('Wechat/Authorize', { path: data }); - }, - Login(data) { - return http.get('Auth/Token', data); - }, - Post(name, data, index, size) { - if (index) - return http.post(`Member/${name}`, { data: data, PageIndex: index, PageSize: size }); - return http.post(`Member/${name}`, { data: data }); - }, -} - -export default MemberAPI; \ No newline at end of file diff --git a/src/api/pay.js b/src/api/pay.js deleted file mode 100644 index bad7ce6..0000000 --- a/src/api/pay.js +++ /dev/null @@ -1,21 +0,0 @@ -import http from '../utils/http' - -const PayAPI = { - PayInfo(data) { - return http.post('Member/PayInfo', { data: data }); - }, - WalletPay(data) { - return http.post('Member/WalletPay', { data, data }); - }, - Wechat_JS(data) { - return http.get('Pay/Wechat_JS', data); - }, - AliPay_H5(data) { - return http.get('Pay/AliPay_H5', data); - }, - // Wechat_Mini(data) { - // return http.get('Pay/Wechat_Mini', data); - // }, -} - -export default PayAPI; \ No newline at end of file diff --git a/src/main.js b/src/main.js index ac5574f..662ec0a 100644 --- a/src/main.js +++ b/src/main.js @@ -253,12 +253,31 @@ app.config.globalProperties.$goIndex = () => { app.config.globalProperties.$CheckStates = [{ label: '待审核', color: 'primary' }, { label: '已通过', color: 'success' }, { label: '已拒绝', color: 'danger' }]; // api -import MemberAPI from './api/member'; -import CommonAPI from './api/common'; -import PayAPI from './api/pay'; -app.config.globalProperties.$MemberAPI = MemberAPI; -app.config.globalProperties.$CommonAPI = CommonAPI; -app.config.globalProperties.$PayAPI = PayAPI; +app.config.globalProperties.$api = { + post(e, data) { + return new Promise((resolve, reject) => { + fetch(`${import.meta.env.VITE_API_URL}${e}`, { + method: 'POST', + headers: { + 'content-type': 'application/json' + }, + body: JSON.stringify(data), + }).then(rep => { + rep.json().then(data => { + if (data.Code == 0) { + resolve(data.Data); + } + else + reject(data.Message); + }).catch(err => { + reject(err); + }); + }).catch(err => { + reject(err); + }); + }); + }, +}; app.config.globalProperties.$isWechat = () => { return navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger' }; app.config.globalProperties.$isWechatMini = () => { return window.__wxjs_environment == 'miniprogram' }; diff --git a/src/utils/http.js b/src/utils/http.js deleted file mode 100644 index 4c07148..0000000 --- a/src/utils/http.js +++ /dev/null @@ -1,36 +0,0 @@ -import {request} from './request' -const http = { - get(url, params) { - const config = { - method: 'get', - url: url - } - if (params) config.params = params - return request(config) - }, - post(url, params) { - const config = { - method: 'post', - url: url - } - if (params) config.data = params - return request(config) - }, - put(url, params) { - const config = { - method: 'put', - url: url - } - if (params) config.params = params - return request(config) - }, - delete(url, params) { - const config = { - method: 'post', - url: url - } - if (params) config.params = params - return request(config) - } -} -export default http \ No newline at end of file diff --git a/src/utils/request.js b/src/utils/request.js deleted file mode 100644 index 8887aef..0000000 --- a/src/utils/request.js +++ /dev/null @@ -1,68 +0,0 @@ -import axios from 'axios' - -export function request(config) { - const instance = axios.create({ - baseURL: import.meta.env.VITE_API_URL, - timeout: 60000, - }) - instance.interceptors.request.use(config => { - config.headers['Member-Token'] = localStorage.getItem('member_token') || ''; - config.headers['Content-Type'] = 'application/json'; - if (config.data) { - config.data.ts = Date.now(); - } else { - config.data = { - data: {}, - ts: Date.now(), - }; - } - return config; - }, error => { - return Promise.error(error) - } - ) - instance.interceptors.response.use(rep => { - if (rep.data.errcode) { - if (rep.data.errcode == 41000) { - localStorage.setItem('member_token', rep.data.access_token); - return new Promise((resolve, reject) => { - axios.request(rep.config).then(data => { - if (data.data.errcode) - reject(data.data); - else - resolve(data.data); - }).catch(err => { - if (err.isAxiosError) { - switch (err.code) { - case 'ERR_NETWORK': reject('服务器连接失败'); - case 'ECONNABORTED': reject('网络繁忙,请重试'); - default: reject(err.message); - } - } - reject(err); - }); - }); - } - else if ([41001, 40001, 40002].includes(rep.data.errcode)) { - localStorage.removeItem('member_token'); - location.replace('#/Login'); - return Promise.reject({ errcode: rep.data.errcode, errmsg: '请先登录' }); - } - else - return Promise.reject(rep.data); - } - else - return Promise.resolve(rep.data); - }, error => { - if (error.isAxiosError) { - switch (error.code) { - case 'ERR_NETWORK': return Promise.reject('服务器连接失败'); - case 'ECONNABORTED': return Promise.reject('网络繁忙,请重试'); - default: return Promise.reject(error.message); - } - } - return Promise.reject(error) - }) - return instance(config); -} -export default request \ No newline at end of file diff --git a/src/views/Home.vue b/src/views/Home.vue index b2c9177..81e3d41 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -114,6 +114,10 @@ export default { }, mounted() { this.scrollDiy(); + this.$api.post('Carousel/Get', { Type: 1 }).then(data => { + console.log(data); + + }); }, data() { return { diff --git a/src/views/Index.vue b/src/views/Index.vue index 4a4a725..cad15c2 100644 --- a/src/views/Index.vue +++ b/src/views/Index.vue @@ -1,19 +1,9 @@