创建基础的路由文件,配置一些基础的东西

This commit is contained in:
hejin 2025-08-12 00:07:19 +08:00
parent ac4b921464
commit 7d0c8325c1
41 changed files with 252 additions and 36 deletions

View File

@ -9,9 +9,11 @@
<script setup>
import { onLaunch } from "@dcloudio/uni-app";
import { ref } from "vue";
import { useIndex } from '@/stores/index.js'
onLaunch( async(e) => {
uni.setLocale('en')
useIndex().menuInit()
})
</script>
<style lang="scss">

View File

@ -1,10 +1,15 @@
import request from '@/utils/request';
/**
* @function
* @return
* @function 获取菜单分类树
**/
export const getFriendLink = (params) => {
return request.get('',{params})
export const menuCategoryApi = () => {
return request.get('/web/category')
}
/**
* @function 获取首页轮播图
**/
export const homeBannberApi = () => {
return request.get('/web/pic')
}

View File

@ -7,6 +7,10 @@ button {
border-radius: 16rpx;
}
.pages {
height: 100vh;
min-height: 100vh;
font-size: 26rpx;
}
.tabbar-pages {
min-height: calc(100vh - 50px);
font-size: 26rpx;
}

BIN
src/assets/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

View File

@ -43,7 +43,39 @@
/* ios */
"ios" : {},
/* SDK */
"sdkConfigs" : {}
"sdkConfigs" : {},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
}
}
},
/* */

View File

@ -12,8 +12,68 @@
"style": {
"navigationBarTitleText": "China Trailer, Truck, Trailer Parts, Truck Parts Manufacturers and Factory - Price - SINOTRUCK"
}
},
{
"path": "pages/products/index",
"style": {
"navigationBarTitleText": "Product"
}
},
{
"path": "pages/article-page/index",
"style": {
"navigationBarTitleText": "News"
}
},
{
"path": "pages/separate/index",
"style": {
"navigationBarTitleText": "About Us"
}
},
{
"path": "pages/inquiry/index",
"style": {
"navigationBarTitleText": "Contact Us"
}
}
],
"tabBar": {
"color": "#54585c",
"selectedColor": "#0358ff",
"list": [
{
"text": "Home",
"pagePath": "pages/index/index",
"iconPath": "/static/home.png",
"selectedIconPath": "/static/home-select.png"
},
{
"text": "Product",
"pagePath": "pages/products/index",
"iconPath": "/static/product.png",
"selectedIconPath": "/static/product-select.png"
},
{
"text": "News",
"pagePath": "pages/article-page/index",
"iconPath": "/static/news.png",
"selectedIconPath": "/static/news-select.png"
},
{
"text": "About Us",
"pagePath": "pages/separate/index",
"iconPath": "/static/aboutus.png",
"selectedIconPath": "/static/aboutus-select.png"
},
{
"text": "Contact Us",
"pagePath": "pages/inquiry/index",
"iconPath": "/static/contactus.png",
"selectedIconPath": "/static/contactus-select.png"
}
]
},
"globalStyle": {
"navigationStyle": "custom",
"navigationBarTextStyle": "black",

View File

@ -0,0 +1,15 @@
<template>
<view class="pages">
文章栏目
</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
</script>
<style lang="scss" scoped>
</style>

View File

@ -1,25 +1,49 @@
<template>
<view class="content">
{{$t('index.companyProfile')}}
<ConfirmPopup ref="comfirmPopupRef" v-if="popupShow" />
<view class="tabbar-pages">
<swiper
class="swiper"
circular
:autoplay="true"
>
<swiper-item v-for="(item,index) in bannerList" :key="index">
<view class="swiper-item">
<image :src="item.pic" mode="aspectFill"></image>
</view>
</swiper-item>
</swiper>
</view>
</template>
<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { index } from '@/stores/index.js';
import { useComfirmPopup } from '@/hooks/utils.js';
import { getFriendLink } from '@/api/index.js';
import { homeBannberApi } from '@/api/index.js';
const { popupShow,comfirmPopupRef,openPopup } = useComfirmPopup()
const bannerList = ref([])
const getBannerList = () => {
homeBannberApi().then(({data:res}) => {
bannerList.value = res.data
})
}
const piniaIndex = index()
onLoad(() => {
uni.setLocale('en')
getBannerList()
})
</script>
<style lang="scss" scoped>
.tabbar-pages {
.swiper {
width: 100%;
height: 400rpx;
.swiper-item {
width: 100%;
height: 400rpx;
image {
width: 100%;
height: 100%;
}
}
}
}
</style>

View File

@ -0,0 +1,15 @@
<template>
<view class="pages">
询盘栏目
</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
</script>
<style lang="scss" scoped>
</style>

View File

@ -0,0 +1,15 @@
<template>
<view class="pages">
产品栏目
</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
</script>
<style lang="scss" scoped>
</style>

View File

@ -0,0 +1,15 @@
<template>
<view class="pages">
单页面
</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
</script>
<style lang="scss" scoped>
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

BIN
src/static/aboutus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

BIN
src/static/contactus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

BIN
src/static/home-select.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

BIN
src/static/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

BIN
src/static/news-select.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

BIN
src/static/news.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

BIN
src/static/product.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

View File

@ -1,14 +1,49 @@
import { defineStore } from 'pinia';
import { reactive, ref } from 'vue';
import { ref } from 'vue';
import { menuCategoryApi } from '@/api/index.js';
export const index = defineStore('index',()=>{
let num = ref(0);
const countHanderl = () => {
num.value += 1
export const useIndex = defineStore('index',()=>{
const routeMap = {
'dym': {
view: 'separate', // 单页面
},
'xp': {
view: 'inquiry' // 询盘栏目
},
'wz': {
view: 'article-page' // 文章栏目
},
'cp': {
view: 'products' // 产品栏目
}
return {
num,
countHanderl
}
const menuTree = ref([])
const menuInit = () => {
menuTree.value = [
{ label: 'Home', to: '/', children: [] },
]
menuCategoryApi().then(({data:res}) => {
const fn = (list) => {
list.forEach(item => {
if (item.catgLevel===1) {
item.to = `/pages/${routeMap[item.catgType].view}?maxCatgId=${item.id}&title=${item.label}`
} else {
item.to = `/pages/${routeMap[item.catgType].view}?&catgId=${item.id}&maxCatgId=${item.maxParentId}&title=${item.label}`
}
if (item.children.length) {
fn(item.children)
}
})
}
fn(res.data)
menuTree.value = [...menuTree.value, ...res.data]
})
}
return {
menuInit,
menuTree
}
})

View File

@ -10,9 +10,9 @@ $http.config = {
// web运行端口默认5173可在manifest进行修改默认端口号
$http.interceptors.request.use(async (config) => { // 可使用async await 做异步操作
config.header = {
...config.header,
'Token': uni.getStorageSync('annualTicketToken'),
...config.header
}
config.params = {...config.params, tenantId: 'main'}
uni.showLoading({
title: '加载中...',
mask: true
@ -27,18 +27,12 @@ $http.interceptors.request.use(async (config) => { // 可使用async await 做
$http.interceptors.response.use((response) => {
uni.hideLoading()
switch(response.data.code) {
case 0:
case 200:
break;
default:
// 加入到messageBoxUrl的请求url可触发弹窗形式的提示
let messageBoxUrl = []
if (messageBoxUrl.indexOf(response.config.url) !== -1) {
uni.$showModal('提示',response.data.msg)
} else {
if (response.data.msg) {
uni.$showTost(response.data.msg)
}
}
return Promise.reject(response)
}
return response

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB