From e40a419e5533530a8103d754d751595013f5644a Mon Sep 17 00:00:00 2001 From: zhuguifei <zhuguifei@zhuguifeideiMac.local> Date: 星期五, 18 四月 2025 14:28:32 +0800 Subject: [PATCH] login --- eims-ui-mobile/src/utils/http.ts | 2 eims-ui-mobile/src/pages/login/index.vue | 83 +++++++++++++++- eims-ui-mobile/src/pages/equ/index.vue | 1 eims-ui-mobile/src/pages/home/index.vue | 178 ++++++++++++++++++++++++++++++++--- 4 files changed, 242 insertions(+), 22 deletions(-) diff --git a/eims-ui-mobile/src/pages/equ/index.vue b/eims-ui-mobile/src/pages/equ/index.vue index 8981478..bda1221 100644 --- a/eims-ui-mobile/src/pages/equ/index.vue +++ b/eims-ui-mobile/src/pages/equ/index.vue @@ -1,6 +1,7 @@ <route lang="json5"> { layout: 'tabbar', + needLogin: true, style: { navigationBarTitleText: '鍏充簬', }, diff --git a/eims-ui-mobile/src/pages/home/index.vue b/eims-ui-mobile/src/pages/home/index.vue index 2c10cbb..636a1e2 100644 --- a/eims-ui-mobile/src/pages/home/index.vue +++ b/eims-ui-mobile/src/pages/home/index.vue @@ -3,30 +3,126 @@ { layout: 'tabbar', style: { - navigationStyle: 'custom', navigationBarTitleText: '棣栭〉', }, } </route> <template> <view - class="bg-white overflow-hidden pt-2 px-4" - :style="{ marginTop: safeAreaInsets?.top + 'px' }" + class="bg-base overflow-hidden" + :style="{ + marginTop: safeAreaInsets?.top + 'px', + }" > - <view class="mt-12"> - <image src="/static/logo.svg" alt="" class="w-28 h-28 block mx-auto" /> - </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="bg-white h-[80rpx] px-2 flex items-center justify-between"> + <view class="flex items-center" @click="handleUserInfo"> + <wd-icon name="user" size="40rpx" class="icon-color-base"></wd-icon> + <text class="ml-1 text-color-base">寮犱笁</text> + </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="flex items-center"> + <wd-icon name="notification" size="40rpx" class="icon-color-base mr-3"></wd-icon> + <wd-icon name="tips" size="40rpx" class="icon-color-base mr-3"></wd-icon> + <wd-icon name="app" size="40rpx" class="icon-color-base"></wd-icon> + </view> </view> - <view class="text-center mt-4"> - 妯℃澘鍒嗘敮鏄細 - <text class="text-green-500">tabbar</text> + + <view class="bg-white py-2 px-2"> + <wd-img class="w-full h-[260rpx]" src="/static/images/pic4.jpeg" /> + </view> + <view class="bg-noti flex flex-row"> + <wd-notice-bar + text="杩欐槸涓�鏉℃秷鎭彁绀轰俊鎭紝杩欐槸涓�鏉℃秷鎭彁绀轰俊鎭紝杩欐槸涓�鏉℃秷鎭彁绀轰俊鎭�" + prefix="clock" + type="info" + :scrollable="false" + custom-class="flex-1 overflow-hidden" + /> + <wd-button type="text" class="w-[120rpx]">鏌ョ湅</wd-button> + </view> + + <view class="bg-white"> + <wd-card type="rectangle"> + <template #title> + <view class="flex items-center menu-title-box"> + <view class="menu-indicator"></view> + <view class="ml-1 text-xs">鏁版嵁鎬昏</view> + </view> + </template> + <view class="flex flex-row justify-around"> + <view class="flex flex-col justify-center"> + <text class="text-lg text-center">0</text> + <text class="text-color-gray">璁惧鎬绘暟</text> + </view> + <view class="flex flex-col justify-center"> + <text class="text-lg text-center">0</text> + <text class="text-color-gray">鏁呴殰璁惧鏁�</text> + </view> + <view class="flex flex-col justify-center"> + <text class="text-lg text-center">0</text> + <text class="text-color-gray">鏈慨澶嶆晠闅�</text> + </view> + </view> + </wd-card> + </view> + + <view class="bg-white mt-2"> + <wd-card type="rectangle"> + <template #title> + <view class="flex items-center menu-title-box"> + <view class="menu-indicator"></view> + <view class="ml-1 text-xs">鏁版嵁鎬昏</view> + </view> + </template> + <wd-grid :column="4"> + <wd-grid-item use-slot class="flex justify-center items-center"> + <image class="slot-img text-center" src="/static/menu/menu2.png" /> + <text>12</text> + </wd-grid-item> + <wd-grid-item use-slot class="flex justify-center items-center"> + <image class="slot-img text-center" src="/static/menu/menu2.png" /> + <text>12</text> + </wd-grid-item> + <wd-grid-item use-slot class="flex justify-center items-center"> + <image class="slot-img text-center" src="/static/menu/menu2.png" /> + <text>12</text> + </wd-grid-item> + <wd-grid-item use-slot is-dot class="flex justify-center items-center"> + <image class="slot-img text-center" src="/static/menu/menu2.png" /> + <text>12</text> + </wd-grid-item> + <wd-grid-item use-slot class="flex justify-center items-center"> + <image class="slot-img text-center" src="/static/menu/menu2.png" /> + <text>12</text> + </wd-grid-item> + <wd-grid-item use-slot class="flex justify-center items-center"> + <image class="slot-img text-center" src="/static/menu/menu2.png" /> + <text>12</text> + </wd-grid-item> + </wd-grid> + </wd-card> + </view> + + <view class="bg-white mt-2"> + <wd-card type="rectangle"> + <template #title> + <view class="flex items-center menu-title-box"> + <view class="menu-indicator"></view> + <view class="ml-1 text-xs">鏁版嵁鎬昏</view> + </view> + </template> + <wd-grid :column="4"> + <wd-grid-item + use-slot + class="flex justify-center items-center" + v-for="(item, index) in menuList" + :key="item.id" + > + <image class="slot-img text-center" :src="item.url" /> + <text>{{ item.name }}</text> + </wd-grid-item> + </wd-grid> + </wd-card> </view> </view> </template> @@ -50,10 +146,62 @@ console.log(author) console.log(TestEnum.A) }) + +const menuList = reactive([ + { + id: 1, + name: '娴嬭瘯', + url: '/static/menu/menu1.png', + }, + { + id: 2, + name: '娴嬭瘯', + url: '/static/menu/menu1.png', + }, +]) + +function handleUserInfo() { + console.error('12121') +} + + </script> <style lang="scss" scoped> .main-title-color { color: $uni-color-primary; } + +.bg-noti { + background: #f4f9ff; +} + +:deep(.wd-card) { + margin-bottom: 0; +} + +:deep(.wd-card__footer) { + padding: 0 !important; +} + +:deep(.wd-card__footer)::after { + height: 0 !important; +} + +.menu-title-box { + height: 30rpx; +} + +.menu-indicator { + width: 6rpx; + height: 24rpx; + border-radius: 10rpx; + background-color: $uni-color-primary; +} + +.slot-img { + width: 72rpx; + height: 72rpx; + border-radius: 8rpx; +} </style> diff --git a/eims-ui-mobile/src/pages/login/index.vue b/eims-ui-mobile/src/pages/login/index.vue index 17c5a1d..f26a05d 100644 --- a/eims-ui-mobile/src/pages/login/index.vue +++ b/eims-ui-mobile/src/pages/login/index.vue @@ -2,19 +2,90 @@ { layout: 'default', style: { - navigationStyle: 'custom', navigationBarTitleText: '鐧诲綍', }, } </route> + +<template> + <wd-img class="w-full h-[260rpx]" src="/static/images/pic2.jpg" /> + <wd-form ref="form" :model="model" class="mt-2"> + <wd-cell-group border> + <wd-input + label="鐢ㄦ埛鍚�" + label-width="100px" + prop="username" + clearable + v-model="model.username" + placeholder="璇疯緭鍏ョ敤鎴峰悕" + :rules="[{ required: true, message: '璇峰~鍐欑敤鎴峰悕' }]" + /> + <wd-input + label="瀵嗙爜" + label-width="100px" + prop="password" + show-password + clearable + v-model="model.password" + placeholder="璇疯緭鍏ュ瘑鐮�" + :rules="[{ required: true, message: '璇峰~鍐欏瘑鐮�' }]" + /> + </wd-cell-group> + <view class="footer mt-6"> + <wd-button type="primary" size="large" @click="handleSubmit" block>鎻愪氦</wd-button> + </view> + </wd-form> +</template> + <script setup lang="ts"> +import { currRoute } from '@/utils' +import { useUserStore, useAccessStore } from '@/store' +import { useToast } from 'wot-design-uni' +import { login } from '@/service/login' +const userStore = useUserStore() +const accessStore = useAccessStore() +const { success: showSuccess } = useToast() + +const model = reactive<{ + username: string + password: string +}>({ + username: 'admin', + password: 'admin123', +}) + +const form = ref() +function handleSubmit() { + form.value + .validate() + .then(({ valid, errors }) => { + if (valid) { + toLogin() + } + }) + .catch((error) => { + console.log(error, 'error') + }) +} +const toLogin = async () => { + const res = await login(model) + console.error(res) + accessStore.setAccessInfo(res as any) + console.error(accessStore.accessInfo.access_token) + // userStore.setUserInfo({ nickname: '鑿查附', avatar: '', token: 'abcdef' }) + const { query } = currRoute() + console.error(query.redirect) + uni.switchTab({ url: query.redirect }) +} + + + + </script> -<template> - -</template> - <style scoped lang="scss"> - +.footer { + padding: 12px; +} </style> diff --git a/eims-ui-mobile/src/utils/http.ts b/eims-ui-mobile/src/utils/http.ts index 246cc7e..f98f884 100644 --- a/eims-ui-mobile/src/utils/http.ts +++ b/eims-ui-mobile/src/utils/http.ts @@ -15,7 +15,7 @@ if (res.statusCode >= 200 && res.statusCode < 300) { // 2.1 鎻愬彇鏍稿績鏁版嵁 res.data if ((res.data as IResData<T>).code === 200) { - resolve((res.data as IResData<T>).data as IResData<T>) + resolve(((res.data as IResData<T>).data || res.data) as IResData<T>) } else { uni.showToast({ icon: 'none', -- Gitblit v1.9.3