接口

parent d97c9db9
# 环境标识
VITE_APP_ENV = 'development'
# URL路径
VITE_APP_BASE_URL = '/api'
# 照片url路径
VITE_APP_IMG_URL = 'http://file.rhhzkj.com:8080'
# 环境标识
VITE_APP_ENV = 'production'
# URL路径
VITE_APP_BASE_URL = 'https://api.rddyz.com'
# 照片url路径
VITE_APP_IMG_URL = 'https://file.rddyz.com'
\ No newline at end of file
<script setup lang="ts">
<script setup>
onLaunch(() => {
console.log('App Launch');
});
......
import { request } from '../utils/request';
export function test(data) {
// 登录
export function getTokenUser(data) {
return request({
url: '/sgyrdd/auth/getToken',
method: 'POST',
data,
});
}
// 分类
export function groupBuyList() {
return request({
url: '/sgyrdd/category/groupBuyList',
method: 'GET',
});
}
......@@ -128,17 +128,35 @@ import FoodDetails from '../../components/index/FoodDetails.vue';
import ShopCard from '../../components/index/ShopCard.vue';
import Marketing from '../../components/index/Marketing.vue';
import Position from '../../components/index/Position.vue';
import { test } from '../../api/index';
import testJson from '../../json/test.json';
import { getTokenUser, groupBuyList } from '../../api/index';
import testJson from '../../static/json/test.json';
import { getToken } from '../../utils/auth';
const title = ref('小程序平台');
const { countInfo, addCount } = useCountStore();
onMounted(() => {
test(testJson).then((res) => {
console.log('打印', res);
});
onMounted(async () => {
if (!getToken()) await signIn();
getClassification();
// test(testJson).then((res) => {
// console.log('打印', res);
// });
// console.log('testJson', testJson);
});
// 登录
const signIn = () => {
getTokenUser(testJson).then((res) => {
const token = res.data.access_token;
xma.setStorageSync('Authorization', token);
console.log('登录...');
});
};
// 获取分类
const getClassification = () => {
groupBuyList().then((res) => {
console.log('res', res);
});
};
const light = ref(0);
const rotate = ref(false);
const classificationT = reactive([
......@@ -197,7 +215,7 @@ const handleClick = (e) => {
}
};
const onChange = (e) => {
console.log(e);
// console.log(e);
};
// function toUIComponentsDoc() {
// window.open('https://wot-design-uni.netlify.app/component/button.html');
......@@ -260,9 +278,8 @@ page {
display: flex;
flex-direction: column;
align-items: center;
font-size: 24rpx;
font-size: 18rpx;
color: #3d3d3d;
font-weight: 500;
justify-content: flex-end;
font-family:
Source Han Sans,
......
// const { env } = require('./env');
import { env } from './env';
let domain = {};
if (env === 'dev') {
......@@ -12,7 +11,5 @@ if (env === 'dev') {
// imgPrefix: 'https://gdlxy-images.wjzpgz.com/',
};
}
// domain.ossImgPrefix = 'https://gdlxy-images.wjzpgz.com/mp',
// module.exports = domain;
export default domain;
export const env = 'dev';
// prod 生产
// dev 开发
// export default env;
import { getToken, removeToken } from './auth';
import domain from './domain';
// import domain from './domain';
export const request = ({ url, data = {}, header, method = 'GET' }) => {
return new Promise((resolve, reject) => {
console.log('url', url);
const token = getToken();
header = {
/* "Client-Type": 1,
......@@ -16,12 +15,12 @@ export const request = ({ url, data = {}, header, method = 'GET' }) => {
header.Authorization = 'Bearer ' + token;
}
xma.request({
url: domain.apiPrefix + url,
url: import.meta.env.VITE_APP_BASE_URL + url,
data,
header,
method,
success: (res) => {
console.log(res.data);
resolve(res.data);
},
fail: (e) => {
console.log('e', e);
......
......@@ -43,6 +43,7 @@ export default defineConfig({
'/api': {
target: 'http://test.rhhzkj.com:8080',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment