diff --git a/env/.env b/env/.env index 3ce1778..631bc28 100644 --- a/env/.env +++ b/env/.env @@ -5,7 +5,7 @@ VITE_APP_TITLE=uniapp-vue3模板项目 VITE_APP_ENV=development # 接口地址 -VITE_API_BASE_URL=https://test.shop.lihaink.cn +VITE_API_BASE_URL=http://www.caipu.com:8545 # 端口号 VITE_APP_PORT=9527 @@ -14,10 +14,11 @@ VITE_APP_PORT=9527 VITE_APP_PROXY=true # API代理前缀 -VITE_API_PREFIX= https://test.shop.lihaink.cn +VITE_API_PREFIX= http://www.caipu.com:8545 # 删除console VITE_DROP_CONSOLE=false # Tencent Map Key -VITE_APP_MAP_KEY= "SMJBZ-WCHK4-ZPZUA-DSIXI-XDDVQ-XWFX7" +VITE_APP_MAP_KEY= "IOUBZ-HCDW3-KP53C-RFNVK-QAZ7O-EQFKM" +# SMJBZ-WCHK4-ZPZUA-DSIXI-XDDVQ-XWFX7 diff --git a/env/.env.development b/env/.env.development index ac6762f..91fce12 100644 --- a/env/.env.development +++ b/env/.env.development @@ -2,7 +2,7 @@ VITE_APP_ENV=development # 接口地址 -VITE_API_BASE_URL=https://test.shop.lihaink.cn +VITE_API_BASE_URL=http://www.caipu.com:8545 # 删除console VITE_DROP_CONSOLE=false diff --git a/env/.env.production b/env/.env.production index 95ba5a8..3d21578 100644 --- a/env/.env.production +++ b/env/.env.production @@ -2,7 +2,7 @@ VITE_APP_ENV=production # 接口地址 -VITE_API_BASE_URL=https://test.shop.lihaink.cn +VITE_API_BASE_URL=http://www.caipu.com:8545 # 删除console VITE_DROP_CONSOLE=true diff --git a/src/api/common/index.ts b/src/api/common/index.ts index 2653a9c..58a7423 100644 --- a/src/api/common/index.ts +++ b/src/api/common/index.ts @@ -20,5 +20,8 @@ export const goodsMenu = (data:any) => get('/api/config', { data, custom: { toas /** 登录 post 实列 */ export const goodsLogin = (data:any) => post('/api/auth/login', { data, custom: { toast: false } }); +//公共请求接口 +export const commonPost = (url:any,data:any) => post(url, { data, custom: { toast: false } }); +export const commonGet = (url:any,data:any) => get(url, { data, custom: { toast: false } }); diff --git a/src/api/user/types.ts b/src/api/user/types.ts index 82db2cb..9014a3a 100644 --- a/src/api/user/types.ts +++ b/src/api/user/types.ts @@ -19,10 +19,11 @@ export interface LoginReqPassword { } export interface LoginRes { - token: string; - user_id: number; - user_name: string; - avatar: string; + user_id?: string; + user_name?: string; + avatar?: string; + token?: string; + user?: any; } export interface LoginByCodeReq { diff --git a/src/hooks/use-location/index.ts b/src/hooks/use-location/index.ts index 3cef3ad..ba0ed4d 100644 --- a/src/hooks/use-location/index.ts +++ b/src/hooks/use-location/index.ts @@ -91,7 +91,7 @@ export default function useLocation() { const getAddress = (latitude: number, longitude: number) => { return new Promise((resolve, reject) => { // console.log('getAddress', `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${map_key}`); - // #ifdef APP-PLUS + uni.request({ url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${map_key}`, success: (res: any) => { @@ -125,13 +125,7 @@ export default function useLocation() { reject(err); }, }); - // #endif - - // #ifndef APP-PLUS - // 其他平台可以使用uni.getLocation的geocode参数获取(仅App和微信小程序支持) - // 或者使用其他地图服务的API - reject(new Error('当前平台不支持地址解析')); - // #endif + }); }; diff --git a/src/manifest.json b/src/manifest.json index dd11f03..48244f2 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -50,11 +50,20 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "", + "appid" : "wxdee751952c8c2027", "setting" : { - "urlCheck" : false + "urlCheck" : false, + "minified" : true, + "postcss" : true, + "es6" : true }, - "usingComponents" : true + "usingComponents" : true, + "permission" : { + "scope.userLocation" : { + "desc" : "获取您的位置" + } + }, + "requiredPrivateInfos" : [ "getLocation", "chooseAddress" , "chooseLocation" ] }, "mp-alipay" : { "usingComponents" : true @@ -77,7 +86,7 @@ "sdkConfigs" : { "maps" : { "tencent" : { - "key" : "SMJBZ-WCHK4-ZPZUA-DSIXI-XDDVQ-XWFX7" + "key" : "IOUBZ-HCDW3-KP53C-RFNVK-QAZ7O-EQFKM" } } } diff --git a/src/pages.json b/src/pages.json index b021ac7..71ab23d 100644 --- a/src/pages.json +++ b/src/pages.json @@ -64,13 +64,29 @@ "navigationStyle": "custom" } }, + { + "path": "goods/pay_order", + "style": { + "navigationBarTitleText": "订单详情", + "navigationStyle": "custom" + } + }, { "path": "goods/order", "style": { "navigationBarTitleText": "订单详情", "navigationStyle": "custom" } + }, + { + "path": "goods/order_detail", + "style": { + "navigationBarTitleText": "订单详情", + "navigationStyle": "custom" + } } + + ] } ], diff --git a/src/pages/common/goods/detail.vue b/src/pages/common/goods/detail.vue index 6d437de..69c0aa4 100644 --- a/src/pages/common/goods/detail.vue +++ b/src/pages/common/goods/detail.vue @@ -22,33 +22,32 @@ - + - + - - - - + + + + + + - + - - @@ -59,7 +58,7 @@ - + - \ No newline at end of file diff --git a/src/pages/common/goods/goods.vue b/src/pages/common/goods/goods.vue new file mode 100644 index 0000000..57719a7 --- /dev/null +++ b/src/pages/common/goods/goods.vue @@ -0,0 +1,240 @@ + + + + diff --git a/src/pages/common/goods/order copy.vue b/src/pages/common/goods/order copy.vue deleted file mode 100644 index 74b61e4..0000000 --- a/src/pages/common/goods/order copy.vue +++ /dev/null @@ -1,507 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/pages/common/goods/order.vue b/src/pages/common/goods/order.vue index bacb30e..099f22f 100644 --- a/src/pages/common/goods/order.vue +++ b/src/pages/common/goods/order.vue @@ -2,261 +2,166 @@ .ellipsis { /* 在末尾显示省略号 */ width: 420rpx; - /* 防止文字换行 */ overflow: hidden; - /* 隐藏超出部分的文字 */ text-overflow: ellipsis; white-space: nowrap; - /* 确保元素有宽度 */ } + diff --git a/src/pages/common/goods/order_detail.vue b/src/pages/common/goods/order_detail.vue new file mode 100644 index 0000000..24d726b --- /dev/null +++ b/src/pages/common/goods/order_detail.vue @@ -0,0 +1,209 @@ + + + + \ No newline at end of file diff --git a/src/pages/common/goods/pay_order.vue b/src/pages/common/goods/pay_order.vue new file mode 100644 index 0000000..4944212 --- /dev/null +++ b/src/pages/common/goods/pay_order.vue @@ -0,0 +1,604 @@ + + + + + diff --git a/src/pages/common/login/index.vue b/src/pages/common/login/index.vue index d0833ee..916183e 100644 --- a/src/pages/common/login/index.vue +++ b/src/pages/common/login/index.vue @@ -123,9 +123,12 @@ async function submit() { } await userStore.passwordLogin({ account: account.value, password: password.value }).catch((res) => { console.log(res); - if (res.status === 200) { - setToken(res.data.token); - uni.$u.toast('登录成功'); + if (res.code === 1) { + // const token = res.data.token; + // if (token) { + // setToken(token.token_type+' '+token.token); + // } + uni.$u.toast('登录成功'); } else { uni.$u.toast(`登录失败,${res.message}`); @@ -138,8 +141,11 @@ async function submit() { return; } await userStore.login({ account: account.value, code: password.value }).catch(() => { - if (res.status === 200) { - setToken(res.data.token); + if (res.code === 1) { + // const token = res.data.token; + // if (token) { + // setToken(token.token_type+' '+token.token); + // } uni.$u.toast('登录成功'); } else { @@ -148,7 +154,7 @@ async function submit() { }); } if(isLogin()){ - await userStore.info() + // await userStore.info() setTimeout(() => { uni.$u.route({ type: isTabBarPath(redirect) ? 'switchTab' : 'redirectTo', diff --git a/src/pages/tab/home/index.vue b/src/pages/tab/home/index.vue index 92d5eef..6438d9a 100644 --- a/src/pages/tab/home/index.vue +++ b/src/pages/tab/home/index.vue @@ -12,7 +12,7 @@ } .ellipsis_text { - width: 340rpx !important; + // width: 340rpx !important; // width: calc(100% - 80rpx)!important; } @@ -30,33 +30,33 @@ body { - + - - + - + {{ item.name }} - + - - @@ -65,25 +65,39 @@ body { - + - + @@ -96,743 +110,100 @@ body { diff --git a/src/pages/tab/list/index.vue b/src/pages/tab/list/index.vue index 77b15ff..953e195 100644 --- a/src/pages/tab/list/index.vue +++ b/src/pages/tab/list/index.vue @@ -1,5 +1,5 @@ + --> diff --git a/src/pages/tab/user/index.vue b/src/pages/tab/user/index.vue index 6b4a8a0..5dd08d2 100644 --- a/src/pages/tab/user/index.vue +++ b/src/pages/tab/user/index.vue @@ -27,18 +27,19 @@ /> @@ -63,9 +64,9 @@ const { setClipboardData, getClipboardData } = useClipboard(); const userStore = useUserStore(); const redirect = HOME_PATH; - -console.log('userStore', userStore); -console.log('userStore', userStore.user_name); +console.log('userStore', userStore.token); +console.log('userStore', userStore.user); +// console.log('userStore', userStore.user_name); // import { CommonApi, UserApi } from "@/api"; // profile // 复制 @@ -85,12 +86,23 @@ function loginOut() { success: (res) => { if (res.confirm) { // 退出请求 - loginOuts(); + // loginOuts(); + setToken(''); + uni.$u.route({ + type: isTabBarPath(redirect) ? 'switchTab' : 'redirectTo', + url: redirect, + }); } }, }); } -// userStore.info() + function orderList() { + uni.$u.route({ + type: 'navigateTo', + url: '/pages/common/goods/order', + }); +} + async function loginOuts() { // 退出请求 await userStore.logout().catch(() => { diff --git a/src/static/styles/common.scss b/src/static/styles/common.scss index 3184c5f..ae3de4f 100644 --- a/src/static/styles/common.scss +++ b/src/static/styles/common.scss @@ -3,8 +3,23 @@ page { color: $u-main-color; background-color: $u-bg-color; } - +// .category-item { +// display: inline-flex; +// flex-direction: column; +// align-items: center; +// margin: 0 9px; +// width: 56px; +// padding-bottom: 9px /* 增加底部内边距 */; +// } .scroll-list { + + // display: inline-flex; + // flex-direction: column; + // align-items: center; + // margin: 0 9px; + + // padding-bottom: 9px /* 增加底部内边距 */; + @include flex(column); &__goods-item { diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index 7bd7b59..7115435 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -12,6 +12,7 @@ const useUserStore = defineStore('user', { avatar: 'https://test.shop.lihaink.cn/static/f.png', token: '', user: {}, + code: '', }), getters: { userInfo(state: UserState): UserState { @@ -29,36 +30,64 @@ const useUserStore = defineStore('user', { }, // 获取用户信息 info() { - UserApi.profile().catch((res) => { - console.log('登录信息',res.data); - // reject(error); - this.setInfo({ user: res.data }); - }); + // UserApi.profile().catch((res) => { + // // console.log('登录信息',res.data); + // // reject(error); + // this.setInfo({ user: res.data }); + // }); }, // 异步登录并存储token login(loginForm: LoginReq) { return new Promise((resolve, reject) => { - UserApi.login(loginForm).then((res) => { - const token = res.token; - if (token) { - setToken(token); + UserApi.login(loginForm) + // .then((res) => { + // const token = res.data.token; + // if (token) { + // console.log('登录信息',res.data); + // let authorization = token.token_type+' '+token.token; + // setToken(authorization); + // this.setInfo({ token:authorization , user: res.data }); + // } + // resolve(res); + // }) + .catch((res) => { + if(res.code==1){ + const token = res.data.token; + if (token) { + console.log('登录信息',res.data); + let authorization = token.token_type+' '+token.access_token; + setToken(authorization); + this.setInfo({ token: authorization , user: res.data }); + } } - resolve(res); - }).catch((error) => { - reject(error); + reject(res); }); }); }, passwordLogin(loginForm: LoginReqPassword) { return new Promise((resolve, reject) => { - UserApi.passwordLogin(loginForm).then((res) => { - const token = res.token; - if (token) { - setToken(token); + UserApi.passwordLogin(loginForm) + // .then((res) => { + // const token = res.data.token; + // if (token) { + // console.log('登录信息',res.data); + // let authorization = token.token_type+' '+token.token; + // setToken(authorization); + // this.setInfo({ token:authorization , user: res.data }); + // } + // resolve(res); + // }) + .catch((res) => { + if(res.code==1){ + const token = res.data.token; + if (token) { + console.log('登录信息',res.data); + let authorization = token.token_type+' '+token.access_token; + setToken(authorization); + this.setInfo({ token: authorization , user: res.data }); + } } - resolve(res); - }).catch((error) => { - reject(error); + reject(res); }); }); }, diff --git a/src/store/modules/user/types.ts b/src/store/modules/user/types.ts index 94eced3..86bea25 100644 --- a/src/store/modules/user/types.ts +++ b/src/store/modules/user/types.ts @@ -1,10 +1,11 @@ export type RoleType = '' | '*' | 'user'; export interface UserState { - user_id?: string; + user_id?: string|number; user_name?: string; avatar?: string; token?: string; user?: any; + code?: string; } export type providerType = diff --git a/src/utils/request/interceptors.ts b/src/utils/request/interceptors.ts index 30b0b95..7eeb76d 100644 --- a/src/utils/request/interceptors.ts +++ b/src/utils/request/interceptors.ts @@ -84,7 +84,8 @@ function requestInterceptors(http: HttpRequestAbstract) { const isToken = custom?.auth === false; if (getToken() && !isToken && config.header) { // token设置 - config.header['X-Token'] = getToken(); + config.header['Content-Type'] ='application/json'; + config.header['authorization'] = getToken(); } // 是否显示 loading diff --git a/src/utils/request/types.ts b/src/utils/request/types.ts index a9f24b8..783c094 100644 --- a/src/utils/request/types.ts +++ b/src/utils/request/types.ts @@ -1,7 +1,7 @@ // 返回res.data的interface export interface IResponse { - code: number | string; - result: T; - message: string; - status: string | number; + code: number | string; + show: string | number; + msg: string; + result: T; }