瀏覽代碼

Merge branch 'dev' into catgory

陈雪 1 月之前
父節點
當前提交
dcfe0ea3ea

+ 3 - 6
.vscode/settings.json

@@ -16,12 +16,6 @@
   "css.validate": false,
   "less.validate": false,
   "scss.validate": false,
-  "[shellscript]": {
-    "editor.defaultFormatter": "foxundermoon.shell-format"
-  },
-  "[dotenv]": {
-    "editor.defaultFormatter": "foxundermoon.shell-format"
-  },
   "[vue]": {
     "editor.defaultFormatter": "esbenp.prettier-vscode"
   },
@@ -38,16 +32,19 @@
   },
   "cSpell.words": [
     "Aplipay",
+    "Attributify",
     "climblee",
     "commitlint",
     "dcloudio",
     "iconfont",
+    "iconify",
     "qrcode",
     "refresherrefresh",
     "scrolltolower",
     "tabbar",
     "Toutiao",
     "unibest",
+    "unocss",
     "uvui",
     "Wechat",
     "WechatMiniprogram",

+ 2 - 0
src/App.vue

@@ -1,6 +1,7 @@
 <script setup lang="ts">
   import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
   import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
+  import i18n from './locale'
 
   onLaunch(() => {
     console.log('App Launch')
@@ -11,6 +12,7 @@
   onHide(() => {
     console.log('App Hide')
   })
+  i18n.global.locale = 'en'
   uni.setLocale('en')
 </script>
 

+ 11 - 1
src/components/shop-tabbar/shop-tabbar.vue

@@ -86,6 +86,16 @@
         console.log('hideTabBar success: ', res)
       },
     })
+    const routes = getCurrentPages()
+    const curRoute = routes[routes.length - 1].route
+    for (let i = 0; i < tabBar.list.length; i++) {
+      const { pagePath } = tabBar.list[i]
+      if (pagePath === curRoute) {
+        tabbarStore.setCurIdx(i)
+        break
+      }
+    }
+
     // #endif
   })
 </script>
@@ -149,7 +159,7 @@
         .tabbar-item-wrapper {
           .tabbar-item-wrapper-active-bg {
             display: block;
-            box-shadow: 0 0 40rpx 0 rgba($color: #ff4c1b, $alpha: 0.6);
+            @include shop-box-show(40rpx);
           }
         }
       }

+ 5 - 1
src/locale/en.json

@@ -8,5 +8,9 @@
   "weight": "{heavy}KG",
   "detail": "{0}cm, {1}KG",
   "introduction": "I am {name},height:{detail.height},weight:{detail.weight}",
-  "category.search": "Search"
+  "category.search": "Search",
+  "home.search": "Search",
+  "home.seeAll": "See All",
+  "home.hotCategory": "Hot Category",
+  "home.hotSelling": "Hot Selling"
 }

+ 0 - 3
src/locale/index.ts

@@ -14,9 +14,6 @@ const i18n = createI18n({
   allowComposition: true,
 })
 
-console.log(uni.getLocale())
-console.log(i18n.global.locale)
-
 /**
  * 可以拿到原始的语言模板,非 vue 文件使用这个方法,
  * @param { string } key 多语言的key,eg: "app.name"

+ 5 - 3
src/locale/zh-Hans.json

@@ -8,7 +8,9 @@
   "weight": "{heavy}公斤",
   "detail": "{0}cm, {1}公斤",
   "introduction": "我是 {name},身高:{detail.height},体重:{detail.weight}",
-  "category": {
-    "search": "搜索"
-  }
+  "category.search": "搜索",
+  "home.search": "搜索",
+  "home.seeAll": "更多",
+  "home.hotCategory": "热门分类",
+  "home.hotSelling": "热销商品"
 }

+ 1 - 1
src/pages.json

@@ -63,7 +63,7 @@
       "layout": "tabbar",
       "style": {
         "navigationStyle": "custom",
-        "navigationBarTitleText": "首页"
+        "navigationBarTitleText": "%tabbar.home%"
       }
     },
     {

+ 248 - 31
src/pages/index/index.vue

@@ -4,57 +4,274 @@
   layout: 'tabbar',
   style: {
     navigationStyle: 'custom',
-    navigationBarTitleText: '首页',
+    navigationBarTitleText: '%tabbar.home%',
   },
 }
 </route>
 <template>
-  <view
-    class="bg-white overflow-hidden pt-2 px-4"
-    :style="{ marginTop: safeAreaInsets?.top + 'px' }"
-  >
-    <view class="mt-12">
-      <image src="/static/logo.svg" alt="" class="w-28 h-28 block mx-auto" />
+  <view class="bg-white overflow-hidden" :style="{ marginTop: safeAreaInsets?.top + 'px' }">
+    <view class="pos-msg-container">
+      <view class="pos-container">
+        <image style="width: 36rpx" src="@/static/images/pos.svg" mode="widthFix"></image>
+        <view class="pos-name">Serbia</view>
+        <image style="width: 36rpx" src="@/static/images/select.svg" mode="widthFix"></image>
+      </view>
+      <view class="msg-info">
+        <image style="width: 76rpx" src="@/static/images/msg.svg" mode="widthFix"></image>
+      </view>
     </view>
-    <view class="text-center text-4xl main-title-color mt-4">unibest</view>
-    <view class="text-center text-2xl mt-2 mb-8">最好用的 uniapp 开发模板</view>
-
-    <view class="text-justify max-w-100 m-auto text-4 indent mb-2">{{ description }}</view>
-    <view class="text-center mt-8">
-      当前平台是:
-      <text class="text-green-500">{{ PLATFORM.platform }}</text>
+    <view class="search-container">
+      <view class="search-item">
+        <image style="width: 40rpx" src="@/static/images/search.svg" mode="widthFix"></image>
+        <view class="search-text">{{ t('home.search') }}</view>
+      </view>
+    </view>
+    <view class="card-swiper-container">
+      <wd-swiper
+        autoplay
+        v-model:current="current"
+        custom-indicator-class="custom-indicator-class"
+        custom-image-class="custom-image"
+        custom-next-image-class="custom-image-prev"
+        custom-prev-image-class="custom-image-prev"
+        :list="swiperList"
+      ></wd-swiper>
     </view>
-    <view class="text-center mt-4">
-      模板分支是:
-      <text class="text-green-500">i18n</text>
+    <view class="hot-category">
+      <view class="home-title">
+        <view class="home-title-text">{{ t('home.hotCategory') }}</view>
+        <view class="home-see-all">
+          <view class="see-all-text">{{ t('home.seeAll') }}</view>
+          <image class="w-9rpx" src="@/static/images/right.svg" mode="widthFix"></image>
+        </view>
+      </view>
+      <view class="hot-category-content">
+        <view v-for="item in categories" :key="item.id" class="category-item">
+          <image class="category-item-img" :src="item.img" mode="scaleToFill"></image>
+          <view class="category-item-text">{{ item.text }}</view>
+        </view>
+      </view>
+    </view>
+    <view class="hot-selling">
+      <view class="selling-title">
+        <view class="selling-title-text">{{ t('home.hotSelling') }}</view>
+        <view class="selling-see-all">
+          <view class="selling-see-all-text">{{ t('home.seeAll') }}</view>
+          <image class="w-9rpx" src="@/static/images/right.svg" mode="widthFix"></image>
+        </view>
+      </view>
     </view>
   </view>
   <tabbar />
 </template>
 
 <script lang="ts" setup>
-  import { TestEnum } from '@/typings'
-  import PLATFORM from '@/utils/platform'
+  import { t } from '@/locale'
+  import CateImg1 from '@/static/temp/cate-1.png'
+  import CateImg2 from '@/static/temp/cate-2.png'
+  import CateImg3 from '@/static/temp/cate-3.png'
+  import CateImg4 from '@/static/temp/cate-4.png'
 
   defineOptions({
     name: 'Home',
   })
 
+  const current = ref(0)
+
+  const swiperList = ref([
+    'https://t.xiaoyaotravel.com/image/TourImComplait/messageContent/696b679508664bb4bceb6cc6b06d0cdc.png',
+    'https://registry.npmmirror.com/wot-design-uni-assets/*/files/redpanda.jpg',
+    'https://registry.npmmirror.com/wot-design-uni-assets/*/files/capybara.jpg',
+    'https://registry.npmmirror.com/wot-design-uni-assets/*/files/panda.jpg',
+    'https://registry.npmmirror.com/wot-design-uni-assets/*/files/moon.jpg',
+    'https://registry.npmmirror.com/wot-design-uni-assets/*/files/meng.jpg',
+  ])
+
+  const categories = ref([
+    { img: CateImg1, id: 1, text: 'Panda' },
+    { img: CateImg2, id: 2, text: 'Gift Shop' },
+    { img: CateImg3, id: 3, text: 'Egg&Meat' },
+    { img: CateImg4, id: 4, text: 'Vegs&Fruits' },
+  ])
+
   // 获取屏幕边界到安全区域距离
   const { safeAreaInsets } = uni.getSystemInfoSync()
-  const author = ref('菲鸽')
-  const description = ref(
-    'unibest 是一个集成了多种工具和技术的 uniapp 开发模板,由 uniapp + Vue3 + Ts + Vite4 + UnoCss + UniUI + VSCode 构建,模板具有代码提示、自动格式化、统一配置、代码片段等功能,并内置了许多常用的基本组件和基本功能,让你编写 uniapp 拥有 best 体验。',
-  )
-  // 测试 uni API 自动引入
-  onLoad(() => {
-    console.log(author)
-    console.log(TestEnum.A)
-  })
 </script>
 
-<style>
-  .main-title-color {
-    color: #d14328;
+<style lang="scss" scoped>
+  .hot-selling {
+    box-sizing: border-box;
+    display: flex;
+    flex-direction: column;
+    align-items: flex-start;
+    justify-content: center;
+    padding: 24rpx 32rpx;
+
+    .selling-title {
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      width: 100%;
+      padding-right: 5rpx;
+      font-family: 'PingFang SC';
+      font-size: 36rpx;
+      font-style: normal;
+      font-weight: 600;
+      line-height: 52rpx; /* 144.444% */
+      color: $shop-text-3;
+
+      .selling-see-all {
+        display: flex;
+        align-items: center;
+
+        .selling-see-all-text {
+          margin-right: 18rpx;
+          font-family: 'PingFang SC';
+          font-size: 24rpx;
+          font-style: normal;
+          font-weight: 400;
+          line-height: 40rpx; /* 166.667% */
+          color: $shop-primary;
+          text-align: center;
+        }
+      }
+    }
+  }
+
+  .hot-category {
+    box-sizing: border-box;
+    display: flex;
+    flex-direction: column;
+    align-items: flex-start;
+    justify-content: center;
+    padding: 24rpx 32rpx;
+
+    .hot-category-content {
+      display: flex;
+      justify-content: space-between;
+      width: 100%;
+      margin-top: 24rpx;
+
+      .category-item {
+        display: flex;
+        flex-direction: column;
+        align-items: center;
+
+        .category-item-img {
+          width: 128rpx;
+          height: 128rpx;
+          margin-bottom: 8rpx;
+          border-radius: 50%;
+        }
+
+        .category-item-text {
+          font-family: 'PingFang SC';
+          font-size: 14px;
+          font-style: normal;
+          font-weight: 400;
+          line-height: 22px; /* 157.143% */
+          color: $shop-text-3;
+        }
+      }
+    }
+
+    .home-title {
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      width: 100%;
+      padding-right: 5rpx;
+      font-family: 'PingFang SC';
+      font-size: 36rpx;
+      font-style: normal;
+      font-weight: 600;
+      line-height: 52rpx; /* 144.444% */
+      color: $shop-text-3;
+
+      .home-see-all {
+        display: flex;
+        align-items: center;
+
+        .see-all-text {
+          margin-right: 18rpx;
+          font-family: 'PingFang SC';
+          font-size: 24rpx;
+          font-style: normal;
+          font-weight: 400;
+          line-height: 40rpx; /* 166.667% */
+          color: $shop-primary;
+          text-align: center;
+        }
+      }
+    }
+  }
+
+  .card-swiper-container {
+    box-sizing: border-box;
+    padding: 0 16rpx 24rpx;
+    padding-bottom: 24rpx;
+    --wot-swiper-radius: 0;
+    --wot-swiper-item-padding: 0 0;
+    --wot-swiper-nav-dot-color: rgba(255, 169, 145, 0.2);
+    --wot-swiper-nav-dot-active-color: #ff4c1b;
+
+    :deep(.custom-indicator-class) {
+      bottom: -24rpx;
+    }
+    :deep(.custom-image) {
+      border-radius: 12rpx;
+    }
+    :deep(.custom-image-prev) {
+      height: 300rpx !important;
+    }
+  }
+  .search-container {
+    box-sizing: border-box;
+    padding: 0 16rpx 24rpx;
+
+    .search-item {
+      box-sizing: border-box;
+      display: flex;
+      align-items: center;
+      height: 84rpx;
+      padding: 20rpx 24rpx;
+      border: 2rpx solid $shop-bg-line;
+      border-radius: 42rpx;
+
+      .search-text {
+        margin-left: 16rpx;
+        font-family: 'PingFang SC';
+        font-size: 28rpx;
+        font-style: normal;
+        font-weight: 400;
+        line-height: 44rpx; /* 157.143% */
+        color: var(--999, #999);
+        text-align: center;
+      }
+    }
+  }
+  .pos-msg-container {
+    box-sizing: border-box;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    padding: 16rpx 23rpx;
+
+    .pos-container {
+      display: flex;
+      align-items: center;
+      height: 76rpx;
+
+      .pos-name {
+        margin: 0 16rpx;
+        font-family: 'PingFang SC';
+        font-size: 28rpx;
+        font-style: normal;
+        font-weight: 600;
+        line-height: 44rpx; /* 157.143% */
+        color: var(--333, #333);
+        text-align: center;
+      }
+    }
   }
 </style>

文件差異過大導致無法顯示
+ 3 - 0
src/static/images/msg.svg


+ 3 - 0
src/static/images/pos.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
+  <path d="M4.28602 12.3134C3.66742 11.6998 3.17642 10.9699 2.84135 10.1656C2.50628 9.36135 2.33377 8.4987 2.33377 7.62743C2.33377 6.75616 2.50628 5.89351 2.84135 5.08925C3.17642 4.28499 3.66742 3.55503 4.28602 2.94148C6.88933 0.35284 11.1106 0.35284 13.7139 2.94148C14.3326 3.55504 14.8237 4.28504 15.1588 5.08937C15.494 5.89369 15.6665 6.75642 15.6665 7.62776C15.6665 8.49911 15.494 9.36184 15.1588 10.1662C14.8237 10.9705 14.3326 11.7005 13.7139 12.314L8.99997 17L4.28602 12.3134ZM8.99997 9.66674C9.26261 9.66674 9.52268 9.61501 9.76533 9.5145C10.008 9.41399 10.2285 9.26668 10.4142 9.08096C10.5999 8.89525 10.7472 8.67477 10.8477 8.43212C10.9482 8.18947 11 7.9294 11 7.66676C11 7.40412 10.9482 7.14405 10.8477 6.9014C10.7472 6.65876 10.5999 6.43828 10.4142 6.25256C10.2285 6.06685 10.008 5.91953 9.76533 5.81902C9.52268 5.71852 9.26261 5.66678 8.99997 5.66678C8.46954 5.66678 7.96084 5.8775 7.58577 6.25256C7.2107 6.62763 6.99999 7.13634 6.99999 7.66676C6.99999 8.19719 7.2107 8.70589 7.58577 9.08096C7.96084 9.45603 8.46954 9.66674 8.99997 9.66674Z" fill="#FF4C1B"/>
+</svg>

+ 3 - 0
src/static/images/right.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="7" height="11" viewBox="0 0 7 11" fill="none">
+  <path d="M1.12473 0.928406L5.62473 5.42841L1.12473 9.92841" stroke="#FF4C1B" stroke-width="1.35" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>

+ 5 - 0
src/static/images/search.svg

@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
+  <path d="M8.75 15.8333C12.662 15.8333 15.8333 12.662 15.8333 8.75C15.8333 4.838 12.662 1.66666 8.75 1.66666C4.838 1.66666 1.66667 4.838 1.66667 8.75C1.66667 12.662 4.838 15.8333 8.75 15.8333Z" stroke="#FF4C1B" stroke-width="1.25" stroke-linejoin="round"/>
+  <path d="M11.1071 5.97629C10.5039 5.37308 9.67052 5 8.75002 5C7.82957 5 6.99623 5.37308 6.39302 5.97629" stroke="#FF4C1B" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
+  <path d="M13.8424 13.8424L17.3779 17.3779" stroke="#FF4C1B" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>

+ 3 - 0
src/static/images/select.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
+  <path d="M13.5 7.12471L9 11.6247L4.5 7.12471" stroke="#333333" stroke-width="1.35" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>

二進制
src/static/temp/cate-1.png


二進制
src/static/temp/cate-2.png


二進制
src/static/temp/cate-3.png


二進制
src/static/temp/cate-4.png


+ 1 - 0
src/store/tabbar.ts

@@ -8,6 +8,7 @@ export const useTabbarStore = defineStore('tabbar', {
   actions: {
     setCurIdx(idx: number) {
       this.tabbarIndex = idx
+      uni.setStorageSync('app-tabbar-index', idx)
     },
   },
   getters: {

+ 15 - 77
src/uni.scss

@@ -1,77 +1,15 @@
-/* stylelint-disable comment-empty-line-before */
-/**
- * 这里是uni-app内置的常用样式变量
- *
- * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
- * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
- *
- */
-
-/**
- * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
- *
- * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
- */
-
-/* 颜色变量 */
-
-/* 行为相关颜色 */
-$uni-color-primary: #007aff;
-$uni-color-success: #4cd964;
-$uni-color-warning: #f0ad4e;
-$uni-color-error: #dd524d;
-
-/* 文字基本颜色 */
-$uni-text-color: #333; // 基本色
-$uni-text-color-inverse: #fff; // 反色
-$uni-text-color-grey: #999; // 辅助灰色,如加载更多的提示信息
-$uni-text-color-placeholder: #808080;
-$uni-text-color-disable: #c0c0c0;
-
-/* 背景颜色 */
-$uni-bg-color: #fff;
-$uni-bg-color-grey: #f8f8f8;
-$uni-bg-color-hover: #f1f1f1; // 点击状态颜色
-$uni-bg-color-mask: rgb(0 0 0 / 40%); // 遮罩颜色
-
-/* 边框颜色 */
-$uni-border-color: #c8c7cc;
-
-/* 尺寸变量 */
-
-/* 文字尺寸 */
-$uni-font-size-sm: 12px;
-$uni-font-size-base: 14px;
-$uni-font-size-lg: 16;
-
-/* 图片尺寸 */
-$uni-img-size-sm: 20px;
-$uni-img-size-base: 26px;
-$uni-img-size-lg: 40px;
-
-/* Border Radius */
-$uni-border-radius-sm: 2px;
-$uni-border-radius-base: 3px;
-$uni-border-radius-lg: 6px;
-$uni-border-radius-circle: 50%;
-
-/* 水平间距 */
-$uni-spacing-row-sm: 5px;
-$uni-spacing-row-base: 10px;
-$uni-spacing-row-lg: 15px;
-
-/* 垂直间距 */
-$uni-spacing-col-sm: 4px;
-$uni-spacing-col-base: 8px;
-$uni-spacing-col-lg: 12px;
-
-/* 透明度 */
-$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
-
-/* 文章场景相关 */
-$uni-color-title: #2c405a; // 文章标题颜色
-$uni-font-size-title: 20px;
-$uni-color-subtitle: #555; // 二级标题颜色
-$uni-font-size-subtitle: 18px;
-$uni-color-paragraph: #3f536e; // 文章段落颜色
-$uni-font-size-paragraph: 15px;
+$shop-primary: #ff4c1b; // 主题色
+$shop-help: #fc7b1c; // 辅助色
+$shop-bg-line: #f2f2f2; // 背景色-分割线
+$shop-text-3: #333; // 文字颜色
+$shop-text-6: #666; // 文字颜色
+$shop-text-9: #999; // 文字颜色
+$shop-white: #fff; // 文字颜色
+
+@mixin shop-gradient-color {
+  background: linear-gradient($shop-primary, $shop-help);
+}
+
+@mixin shop-box-show($limit) {
+  box-shadow: 0 0 $limit 0 rgba($color: $shop-primary, $alpha: 0.6);
+}

部分文件因文件數量過多而無法顯示