diff --git a/env/.env b/env/.env index 631bc28..dd83a91 100644 --- a/env/.env +++ b/env/.env @@ -6,6 +6,7 @@ VITE_APP_ENV=development # 接口地址 VITE_API_BASE_URL=http://www.caipu.com:8545 +# VITE_API_BASE_URL=http://ceshi-recipeapi.lihaink.cn/ # 端口号 VITE_APP_PORT=9527 @@ -13,8 +14,9 @@ VITE_APP_PORT=9527 # h5是否需要配置代理 VITE_APP_PROXY=true -# API代理前缀 +# API代理前缀 VITE_API_PREFIX= http://www.caipu.com:8545 +# VITE_API_PREFIX= http://ceshi-recipeapi.lihaink.cn/ # 删除console VITE_DROP_CONSOLE=false diff --git a/env/.env.development b/env/.env.development index 91fce12..13c983b 100644 --- a/env/.env.development +++ b/env/.env.development @@ -2,7 +2,7 @@ VITE_APP_ENV=development # 接口地址 -VITE_API_BASE_URL=http://www.caipu.com:8545 +VITE_API_BASE_URL=http://ceshi-recipeapi.lihaink.cn # 删除console VITE_DROP_CONSOLE=false diff --git a/env/.env.production b/env/.env.production index 3d21578..3c64c30 100644 --- a/env/.env.production +++ b/env/.env.production @@ -2,7 +2,7 @@ VITE_APP_ENV=production # 接口地址 -VITE_API_BASE_URL=http://www.caipu.com:8545 +VITE_API_BASE_URL=http://ceshi-recipeapi.lihaink.cn # 删除console VITE_DROP_CONSOLE=true diff --git a/src/manifest.json b/src/manifest.json index 48244f2..9de1ca7 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -81,7 +81,7 @@ "h5" : { "router" : { "mode" : "hash", - "base" : "/uniapp-vue3-template/" + "base" : "/caipu_uni/" }, "sdkConfigs" : { "maps" : { diff --git a/src/pages.json b/src/pages.json index 71ab23d..b36de7b 100644 --- a/src/pages.json +++ b/src/pages.json @@ -62,28 +62,32 @@ "style": { "navigationBarTitleText": "菜谱详情", "navigationStyle": "custom" - } + }, + "needLogin": true }, { "path": "goods/pay_order", "style": { "navigationBarTitleText": "订单详情", "navigationStyle": "custom" - } + }, + "needLogin": true }, { "path": "goods/order", "style": { "navigationBarTitleText": "订单详情", "navigationStyle": "custom" - } + }, + "needLogin": true }, { "path": "goods/order_detail", "style": { "navigationBarTitleText": "订单详情", "navigationStyle": "custom" - } + }, + "needLogin": true } @@ -102,20 +106,20 @@ "borderStyle": "black", "backgroundColor": "#ffffff", "list": [{ - "iconPath": "static/images/tabbar/icon_home.png", - "selectedIconPath": "static/images/tabbar/icon_home_selected.png", + "iconPath": "static/images/tabbar/shouye.png", + "selectedIconPath": "static/images/tabbar/shouye_selected.png", "pagePath": "pages/tab/home/index", "text": "菜单分类" }, { - "iconPath": "static/images/tabbar/icon_list.png", - "selectedIconPath": "static/images/tabbar/icon_list_selected.png", + "iconPath": "static/images/tabbar/bofang.png", + "selectedIconPath": "static/images/tabbar/bofang_selected.png", "pagePath": "pages/tab/list/index", "text": "食谱清单" }, { - "iconPath": "static/images/tabbar/icon_me.png", - "selectedIconPath": "static/images/tabbar/icon_me_selected.png", + "iconPath": "static/images/tabbar/wode.png", + "selectedIconPath": "static/images/tabbar/wode_selected.png", "pagePath": "pages/tab/user/index", "text": "我的" }] diff --git a/src/pages/common/goods/address.vue b/src/pages/common/goods/address.vue deleted file mode 100644 index 57719a7..0000000 --- a/src/pages/common/goods/address.vue +++ /dev/null @@ -1,240 +0,0 @@ - - - - diff --git a/src/pages/common/goods/detail.vue b/src/pages/common/goods/detail.vue index 69c0aa4..c9d8c11 100644 --- a/src/pages/common/goods/detail.vue +++ b/src/pages/common/goods/detail.vue @@ -58,16 +58,19 @@ - - - - - + + + + + + + + diff --git a/src/pages/common/goods/order.vue b/src/pages/common/goods/order.vue index 099f22f..6ce8410 100644 --- a/src/pages/common/goods/order.vue +++ b/src/pages/common/goods/order.vue @@ -19,14 +19,14 @@ height="80rpx" leftIconSize="38rpx" leftIconColor="#303133" :safeAreaInsetTop="true" :placeholder="true" :fixed="true"> + v-model="matchedItems_sp" @query="changeSP" class="fv-page flex-col "> @@ -54,9 +54,9 @@ iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1" decoration="none"> - + @@ -128,7 +128,11 @@ export default defineComponent({ this.$refs.pagingRefSP?.reload(); }, //列表分页 - changeSP () { + changeSP (pageNo: number) { + + console.log('列表分页',pageNo); + this.search_sp.page = pageNo; + console.log('列表分页',this.search_sp); CommonApi.commonGet('/api/order/list', this.search_sp).catch((res) => { if (res.code === 1) { this.$refs.pagingRefSP?.complete(res.data); @@ -139,7 +143,7 @@ export default defineComponent({ // this.createOrderData.cart_ids.push(item.id); // } // }); - + } else { uni.$u.toast(res.msg); } diff --git a/src/pages/common/goods/order_detail.vue b/src/pages/common/goods/order_detail.vue index 24d726b..2e18142 100644 --- a/src/pages/common/goods/order_detail.vue +++ b/src/pages/common/goods/order_detail.vue @@ -24,33 +24,41 @@ leftIconColor="#303133" :safeAreaInsetTop="true" :placeholder="true" :fixed="true"> - + @@ -92,7 +100,7 @@ - @@ -100,40 +108,68 @@ line-color="#18C936" line-width="40rpx" line-height="6rpx" line-bg-size="cover" :scrollable="true" /> - + + + + + + + + + - + + - + - + + + - - - + + + + + + @@ -229,12 +239,15 @@ - - + + + + + + custom-style="width:200rpx;float:right;margin-right:0rpx;" @click="handleSubmit"> @@ -464,7 +477,7 @@ export default defineComponent({ that.addFrom.city = res.data.address_component.city that.addFrom.district = res.data.address_component.district that.addFrom.latitude = res.data.location.lat - that.addFrom.longitude = res.data.location.long + that.addFrom.longitude = res.data.location.lng // that.addFrom.detail = res.data.address_component.street } else { uni.$u.toast(res.msg); @@ -527,14 +540,31 @@ export default defineComponent({ }, deleteAddress (id) { - CommonApi.commonPost('/api/user/deleteAddress',{id:id}).catch((res) => { - if (res.code === 1) { - // this.propShowAddress = false; - this.getAddressInfoListData(); - } else { - uni.$u.toast(res.msg); - } + + useModal().showModal('success', { + title: '删除提示', + content: '确定删除当前地址吗?', + showCancel: true, + confirmText: '确定', + cancelText: '取消', + success: (res) => { + if (res.confirm) { + CommonApi.commonPost('/api/user/deleteAddress', { id: id }).catch((res) => { + if (res.code === 1) { + // this.propShowAddress = false; + this.getAddressInfoListData(); + } else { + uni.$u.toast(res.msg); + } + }); + } + else if (res.cancel) { + // console.log('用户点击取消'); + } + }, }); + + }, //修改地址 editAddress (itme) { diff --git a/src/pages/common/login/index.vue b/src/pages/common/login/index.vue index 916183e..7e51671 100644 --- a/src/pages/common/login/index.vue +++ b/src/pages/common/login/index.vue @@ -2,40 +2,42 @@ - 欢迎登录 + - - - - - - - - + + + + + + + + + + + + + - - - - - - + + 密码登录 验证码登录 - + - @@ -63,10 +68,15 @@ import type { CSSProperties } from 'vue'; import { HOME_PATH, isTabBarPath, LOGIN_PATH, removeQueryString } from '@/router'; import { useUserStore } from '@/store'; -import { setToken ,getToken , isLogin } from '@/utils/auth'; +import { setToken, getToken, isLogin } from '@/utils/auth'; import uCode from 'uview-plus/components/u-code/u-code.vue'; const userStore = useUserStore(); +const isWechat = ref(false); +// #ifdef H5 +isWechat.value = true; +// #endif + const loginType = ref(0); const account = ref('18181941463'); @@ -81,20 +91,20 @@ const inputStyle = computed(() => { const style = {} as CSSProperties; if (account.value && code.value) { style.color = '#fff'; - style.backgroundColor = uni.$u.color.warning; + style.backgroundColor = uni.$u.color.success; } return style; }); -function codeChange(text: string) { +function codeChange (text: string) { tips.value = text; } -function changLoginType(text: number) { +function changLoginType (text: number) { loginType.value = text; } -function getCode() { +function getCode () { if (uCodeRef.value?.canGetCode) { // 模拟向后端请求验证码 uni.showLoading({ @@ -111,7 +121,7 @@ function getCode() { uni.$u.toast('倒计时结束后再发送'); } } -async function submit() { +async function wechatLogin () { if (!uni.$u.test.mobile(Number(account.value))) { uni.$u.toast('请输入正确的手机号'); return; @@ -124,11 +134,11 @@ async function submit() { await userStore.passwordLogin({ account: account.value, password: password.value }).catch((res) => { console.log(res); if (res.code === 1) { - // const token = res.data.token; - // if (token) { - // setToken(token.token_type+' '+token.token); - // } - uni.$u.toast('登录成功'); + // const token = res.data.token; + // if (token) { + // setToken(token.token_type+' '+token.token); + // } + uni.$u.toast('登录成功'); } else { uni.$u.toast(`登录失败,${res.message}`); @@ -142,10 +152,10 @@ async function submit() { } await userStore.login({ account: account.value, code: password.value }).catch(() => { if (res.code === 1) { - // const token = res.data.token; - // if (token) { - // setToken(token.token_type+' '+token.token); - // } + // const token = res.data.token; + // if (token) { + // setToken(token.token_type+' '+token.token); + // } uni.$u.toast('登录成功'); } else { @@ -153,7 +163,7 @@ async function submit() { } }); } - if(isLogin()){ + if (isLogin()) { // await userStore.info() setTimeout(() => { uni.$u.route({ @@ -161,11 +171,11 @@ async function submit() { url: redirect, }); }, 800); - }else{ - uni.$u.toast('登录失败,请重新登录 '); + } else { + uni.$u.toast('登录失败,请重新登录 '); setToken(''); } - + // setToken('1234567890'); } @@ -189,7 +199,7 @@ body { @apply mt-80rpx mx-auto mb-0 w-600rpx; .title { - @apply mb-100rpx text-60rpx text-left font-500; + @apply mb-200rpx text-60rpx text-left font-500; } input { diff --git a/src/pages/tab/list/index.vue b/src/pages/tab/list/index.vue index 953e195..3f8497f 100644 --- a/src/pages/tab/list/index.vue +++ b/src/pages/tab/list/index.vue @@ -25,16 +25,20 @@ :lazy-load="true" duration="500" bg-color="#f3f4f6NaN" :show-menu-by-longpress="true" /> @@ -106,8 +110,8 @@ :paging-style="{ 'background-color': '#FFFFFFFF', 'padding': '20rpx' }" v-if="!currentTab" ref="pagingRefSP" v-model="matchedItems_sp" class="fv-page flex-col " @query="changeSP"> - - + + @@ -126,26 +135,22 @@ @@ -242,6 +251,7 @@ export default defineComponent({ onShow () { //进入页面时刷新数据--避免加入购物车不显示 this.searchSP(); + this.searchSC(); }, onLoad () { // if (isLogin()) { @@ -370,7 +380,7 @@ export default defineComponent({ if (res.confirm) { console.log(that.aloneChecked); //删除购物车菜品 - CommonApi.commonPost('/api/cart/delete', { id: this.checkboxValue }).catch((res) => { + CommonApi.commonPost('/api/cart/delete', { ids: this.checkboxValue }).catch((res) => { if (res.code === 1) { that.aloneChecked = false; this.aloneCheckedValue = [] @@ -400,10 +410,10 @@ export default defineComponent({ }, //修改商品数量 changeProductNumber (e) { - // console.log(e); + console.log(e); this.goods_sc = this.matchedItems_sc.find(item => item.product_id === e.name); // console.log(this.goods_sc); - CommonApi.commonPost('/api/cart/changeNumber', { id: e.name, nums: (this.goods_sc.nums * this.goods_sc.cart_num) }).catch((res) => { + CommonApi.commonPost('/api/cart/changeNumber', { id: e.name, people_number: e.value }).catch((res) => { if (res.code === 1) { } else { uni.$u.toast(res.msg); @@ -412,10 +422,10 @@ export default defineComponent({ }, //修改人数 changePeopleNumber (e) { - CommonApi.commonPost('/api/cart/changePeopleNumber', { totalNum: this.totalNum }).catch((res) => { + CommonApi.commonPost('/api/cart/changePeopleNumber', { people_number: this.totalNum }).catch((res) => { if (res.code === 1) { this.matchedItems_sc.forEach((item, index) => { - this.matchedItems_sc[index].cart_num = e.value; + this.matchedItems_sc[index].people_number = e.value; }); } else { uni.$u.toast(res.msg); @@ -432,6 +442,10 @@ export default defineComponent({ CommonApi.commonPost('/api/cart/count').catch((res) => { if (res.code === 1) { this.cartNUM = res.data.count; + if (this.totalNum == 1) { + this.totalNum = res.data.peopleNumber + } + } }); }, diff --git a/src/pages/tab/user/index.vue b/src/pages/tab/user/index.vue index 5dd08d2..a5831fc 100644 --- a/src/pages/tab/user/index.vue +++ b/src/pages/tab/user/index.vue @@ -2,7 +2,7 @@ - + @@ -12,43 +12,33 @@ {{ userStore.user.phone }} - + - + - + - + - + - + + @@ -76,7 +66,7 @@ const toCopy = async () => { console.log('[ data ] >', data); }; -function loginOut() { +function loginOut () { showModal('success', { title: '提示', content: '确定退出登录?', @@ -87,23 +77,23 @@ function loginOut() { if (res.confirm) { // 退出请求 // loginOuts(); - setToken(''); - uni.$u.route({ - type: isTabBarPath(redirect) ? 'switchTab' : 'redirectTo', - url: redirect, - }); + setToken(''); + uni.$u.route({ + type: isTabBarPath(redirect) ? 'switchTab' : 'redirectTo', + url: redirect, + }); } }, }); } - function orderList() { +function orderList () { uni.$u.route({ type: 'navigateTo', url: '/pages/common/goods/order', - }); + }); } -async function loginOuts() { +async function loginOuts () { // 退出请求 await userStore.logout().catch(() => { setToken(''); @@ -121,17 +111,3 @@ onShow(async () => { console.log(hasPermission ? '已登录' : '未登录,拦截跳转'); }); - - diff --git a/src/static/images/tabbar/bofang.png b/src/static/images/tabbar/bofang.png new file mode 100644 index 0000000..36ae5bf Binary files /dev/null and b/src/static/images/tabbar/bofang.png differ diff --git a/src/static/images/tabbar/bofang_selected.png b/src/static/images/tabbar/bofang_selected.png new file mode 100644 index 0000000..80d67ae Binary files /dev/null and b/src/static/images/tabbar/bofang_selected.png differ diff --git a/src/static/images/tabbar/shezhi.png b/src/static/images/tabbar/shezhi.png new file mode 100644 index 0000000..0f4ee60 Binary files /dev/null and b/src/static/images/tabbar/shezhi.png differ diff --git a/src/static/images/tabbar/shouye.png b/src/static/images/tabbar/shouye.png new file mode 100644 index 0000000..eeea58b Binary files /dev/null and b/src/static/images/tabbar/shouye.png differ diff --git a/src/static/images/tabbar/shouye_selected.png b/src/static/images/tabbar/shouye_selected.png new file mode 100644 index 0000000..8b3e4ab Binary files /dev/null and b/src/static/images/tabbar/shouye_selected.png differ diff --git a/src/static/images/tabbar/wode.png b/src/static/images/tabbar/wode.png new file mode 100644 index 0000000..3a0c41c Binary files /dev/null and b/src/static/images/tabbar/wode.png differ diff --git a/src/static/images/tabbar/wode_selected.png b/src/static/images/tabbar/wode_selected.png new file mode 100644 index 0000000..fd9ef7d Binary files /dev/null and b/src/static/images/tabbar/wode_selected.png differ diff --git a/src/static/styles/common.scss b/src/static/styles/common.scss index ae3de4f..04a5346 100644 --- a/src/static/styles/common.scss +++ b/src/static/styles/common.scss @@ -3,6 +3,27 @@ page { color: $u-main-color; background-color: $u-bg-color; } + + + + +html, +body { + height: 100vh; +} + + + +.detail-box { + margin: 10rpx; + background-color: #fff; + border: 1rpx solid #dfdfdf; + border-radius: 20rpx; + padding: 20rpx; +} +.tab-bar{ + display: flex; position: fixed; left: 0px;right: 0px; bottom: 0rpx; +} // .category-item { // display: inline-flex; // flex-direction: column; diff --git a/src/utils/request/index.ts b/src/utils/request/index.ts index 71e8e6e..7fa7f17 100644 --- a/src/utils/request/index.ts +++ b/src/utils/request/index.ts @@ -3,7 +3,7 @@ import type { HttpRequestConfig, HttpResponse } from 'uview-plus/libs/luch-reque import type { IResponse } from './types'; import Request from 'uview-plus/libs/luch-request/index'; import { requestInterceptors, responseInterceptors } from './interceptors'; - +import { useClipboard, useModal, usePermission } from '@/hooks'; const http = new Request(); // 引入拦截器配置 @@ -28,9 +28,15 @@ export function request(config: HttpRequestConfig): Promise { console.log('[ res ] >', res); const { result } = res.data; resolve(result as T); - }).catch((err: any) => { + }).catch((res: any) => { + if(res.data.code==401){ + //未登录拦截跳转 + uni.$u.toast(res.data.msg); + usePermission(); + return; + } // console.error('[ err ] >', err); - reject(err); + reject(res); }); }); }