From 6abe22fc75b115d2a68103a4d8b24d0815a016f8 Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期三, 06 八月 2025 17:37:35 +0800 Subject: [PATCH] 登录页联调开发,首页开发 --- src/pages/index.vue | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 179 insertions(+), 0 deletions(-) diff --git a/src/pages/index.vue b/src/pages/index.vue new file mode 100644 index 0000000..3cad7a1 --- /dev/null +++ b/src/pages/index.vue @@ -0,0 +1,179 @@ +<template> + <view class="content"> + <view> + <view class="currentFactory"> + <up-text type="primary" :text="userStore.currentFactoryName" @click="show = true" + class="factoryName" suffixIcon="arrow-right" :iconStyle="iconStyle"></up-text> + </view> + <up-picker :show="show" :columns="factoryList" @confirm="changeFactory"></up-picker> + <view> + <view class="bg-img"></view> + </view> + <view class="bg-img"> + <up-grid + :border="false" + col="4" + > + <up-grid-item + v-for="(listItem,listIndex) in list" + :key="listIndex" + > + <up-icon + :customStyle="{paddingTop:20+'rpx'}" + :name="listItem.name" + :size="22" + ></up-icon> + <text class="grid-text">{{listItem.title}}</text> + </up-grid-item> + </up-grid> + </view> + </view> +<!-- <view class="select-container">--> +<!-- <up-picker-data--> +<!-- class="picker"--> +<!-- v-model="currentFatoryId"--> +<!-- title="璇烽�夋嫨鍏徃"--> +<!-- :options="factoryList"--> +<!-- valueKey="id"--> +<!-- labelKey="name">--> +<!-- </up-picker-data>--> +<!-- </view>--> + </view> +</template> + +<script setup> +import {ref, onMounted, nextTick, reactive} from 'vue'; +import {userLoginFacotryList} from "@/api/login"; +import modal from "@/plugins/modal"; +import useUserStore from "@/store/modules/user"; + +const userStore = useUserStore() +const factoryId = ref(''); +const show = ref(false); +const factoryList = ref([]); +const factoryListTem = ref([]); +const iconStyle = { + fontSize: '14px', + color: '#165DFF' +} +// 鍒涘缓鍝嶅簲寮忔暟鎹� +const list = reactive([ + { + name: 'photo', + title: '鍥剧墖' + }, + { + name: 'lock', + title: '閿佸ご' + }, + { + name: 'star', + title: '鏄熸槦' + }, + { + name: 'hourglass', + title: '娌欐紡' + }, + { + name: 'home', + title: '棣栭〉' + }, + { + name: 'volume', // 娉ㄦ剰锛氳繖閲屼慨鏀逛簡 name 浠� 'star' 鏀逛负 'volume'锛屼互閬垮厤鍒楄〃涓袱涓厓绱犲叿鏈夌浉鍚岀殑 name + title: '闊抽噺' + }, +]); +// 鍒涘缓瀵瑰瓙缁勪欢鐨勫紩鐢� +const uToastRef = ref(null); + +function getUserLoginFacotryList() { + userLoginFacotryList({userName: userStore.nickName}).then(res => { + // 妫�鏌es.data鏄惁涓烘暟缁� + factoryList.value[0] = [] + if (res.data && Array.isArray(res.data)) { + factoryListTem.value = res.data + res.data.forEach(item => { + factoryList.value[0].push(item.deptName) + }) + factoryId.value = userStore.currentDeptId + } else { + // 濡傛灉res.data涓嶆槸鏁扮粍锛岃缃负绌烘暟缁� + factoryList.value = [] + } + }).catch(error => { + modal.msgError('鑾峰彇鍏徃鍒楄〃澶辫触:', error) + factoryList.value = [] + }) +} +const changeFactory = async (arr) => { + show.value = false; + const factoryId = factoryListTem.value[arr.indexs[0]].deptId + const loginForm = { + username: userStore.name, + password: uni.getStorageSync('remembered_password'), + factoryId: factoryId, + } + modal.loading("鍒锋柊涓紝璇疯�愬績绛夊緟...") + userStore.loginCheckFactory(loginForm).then(() => { + modal.closeLoading() + nextTick(() => { + loginSuccess() + }); + }).catch(() => { + modal.closeLoading() + }) +} +function loginSuccess(result) { + uni.reLaunch({ + url: '/pages/index' + }); +} + +// 瀹氫箟鏂规硶 +const click = (name) => { + if (uToastRef.value) { + uToastRef.value.success(`鐐瑰嚮浜嗙${name + 1}涓猔); // 娉ㄦ剰锛氳繖閲屽姞1鏄洜涓洪�氬父鎴戜滑鏄粠绗�1涓紑濮嬭鏁扮殑 + } +}; + +onMounted(() => { + // 璁剧疆鐢ㄦ埛淇℃伅 + userStore.getInfo() + getUserLoginFacotryList() +}); +</script> + +<style scoped lang="scss"> +.content { + background-color: transparent !important; + padding: 14px; +} +.currentFactory { + margin-top: 12px; + margin-left: 6px; + font-weight: 400; + font-size: 14px; + display: flex; +} +.factoryName { + width: auto; +} +:deep(.u-text) { + align-items: flex-end; +} +.bg-img { + margin-top: 12px; + width: 100%; + height: 145px; + background-color: #ffffff; + border-radius: 10px 10px 10px 10px; +} +.grid-text { + font-size: 14px; + color: #909399; + padding: 10rpx 0 20rpx 0rpx; + /* #ifndef APP-PLUS */ + box-sizing: border-box; + /* #endif */ +} +</style> -- Gitblit v1.9.3