From f32a5307573c99dc386dd42ce1bba60782531f73 Mon Sep 17 00:00:00 2001 From: Hx <2294602187@qq.com> Date: Fri, 28 Mar 2025 17:55:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF+=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.ts | 7 +- src/api/user.ts | 46 +++++++++- src/pages.json | 16 ++-- src/pages/login/login.vue | 6 +- src/pages/mine/add.vue | 71 ++++++++++++--- src/pages/mine/index.vue | 186 +++++++++++++++++++++++++++++--------- src/store/user.ts | 31 +++++-- 7 files changed, 279 insertions(+), 84 deletions(-) diff --git a/src/api/login.ts b/src/api/login.ts index e1294d9..92c221b 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -14,10 +14,9 @@ export function getMobile(data: { code: string; openid: string }) { }) } -export function getUserInfo(data: { mobile: string }) { +export function getAdminPhone() { return request.http({ - url: '/api/member_mobile', - method: 'GET', - data + url: '/api/admin_mobile', + method: 'GET' }) } diff --git a/src/api/user.ts b/src/api/user.ts index d153bf4..d348453 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,9 +1,51 @@ import { request } from '@/utils/http' -export function getUserList(data: { name: string }) { +export interface listType { + name: string + age: number + sex: number + nation: string + mobile: string + position: string + work_unit: string +} + +export interface dateListtype extends listType { + id: number +} + +export function infoForOpenid(data: { openid: string }) { + return request.http({ + url: '/api/member', + method: 'GET', + data + }) +} +export function list(data: { name: string }) { return request.http({ - url: '/api/openid', + url: '/api/member_name', method: 'GET', data }) } + +export function update(data: { [n: string]: string }, openid: string) { + return request.http({ + url: '/api/member_update', + data: Object.assign(data, { openid }) + }) +} + +export function bind(data: { id: number; openid: string }) { + return request.http({ + url: '/api/name_sub', + data + }) +} + +export function add(data: listType) { + return request.http({ + url: '/api/member_add', + data + }) +} diff --git a/src/pages.json b/src/pages.json index 8ba162d..8156b95 100644 --- a/src/pages.json +++ b/src/pages.json @@ -7,14 +7,6 @@ } }, "pages": [ - { - "path": "pages/login/login", - "style": { - "navigationBarTitleText": "登录", - "enablePullDownRefresh": false, - "navigationStyle": "custom" - } - }, { "path": "pages/votingElection/index", "style": { @@ -75,6 +67,14 @@ "navigationBarTitleText": "个人信息", "enablePullDownRefresh": false } + }, + { + "path": "pages/login/login", + "style": { + "navigationBarTitleText": "登录", + "enablePullDownRefresh": false, + "navigationStyle": "custom" + } } ], "globalStyle": { diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue index e19b06b..2577394 100644 --- a/src/pages/login/login.vue +++ b/src/pages/login/login.vue @@ -40,9 +40,9 @@ const onGetPhoneNumber = debounce(async (e: phoneEvent) => { } const { data: phone } = (await getMobile({ openid: userStore.openId, code: e.detail.code })) as { data: string } - userStore.userInfo.mobile = phone + userStore.mobile = phone - userStore.getUserInfo({ mobile: phone }) + userStore.getUserInfo() onLoginSuccess() } catch (error) { @@ -63,7 +63,7 @@ const onLoginSuccess = () => { } onShow(() => { - if (userStore.userInfo.mobile) { + if (userStore.mobile) { onLoginSuccess() } }) diff --git a/src/pages/mine/add.vue b/src/pages/mine/add.vue index 6d9e220..fc58bd7 100644 --- a/src/pages/mine/add.vue +++ b/src/pages/mine/add.vue @@ -1,54 +1,88 @@ @@ -84,6 +118,17 @@ &-label { color: #4b5563; + position: relative; + + &.required::before { + content: '*'; + color: #f56c6c; + margin-right: 4px; + position: absolute; + top: 0; + bottom: 0; + left: -16rpx; + } } &-content { diff --git a/src/pages/mine/index.vue b/src/pages/mine/index.vue index e6870f6..aa55fb2 100644 --- a/src/pages/mine/index.vue +++ b/src/pages/mine/index.vue @@ -1,55 +1,126 @@ @@ -120,10 +203,25 @@ const getList = () => { .userview { width: 100%; padding: 32rpx; - min-height: calc(100vh - 94px); + min-height: 100vh; box-sizing: border-box; background-color: #f9fafb; + .popupView { + width: 90vw; + padding: 20rpx 40rpx 0; + + .title { + font-size: 36rpx; + font-weight: 500; + margin-bottom: 40rpx; + } + + .bts { + margin-top: 40rpx; + } + } + .box { margin-bottom: 32rpx; border-radius: 24rpx; @@ -153,7 +251,7 @@ const getList = () => { padding: 0 32rpx 32rpx; border: 1rpx solid #fff; - &.border { + &.active { border-color: #2563eb; } diff --git a/src/store/user.ts b/src/store/user.ts index 26c2c86..7aa721a 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -1,7 +1,8 @@ // 定义组合式API仓库 import { defineStore } from 'pinia' import { getPrefixName } from '@/config' -import { getOpenid, getUserInfo as getUserInfoApi } from '@/api/login' +import { getOpenid } from '@/api/login' +import { infoForOpenid, bind as bindApi } from '@/api/user' interface userInfoStoreInt { [n: string]: any @@ -10,11 +11,8 @@ export default defineStore( getPrefixName('user'), () => { const openId = ref('') - const userInfo = ref({ - mobile: '' - }) - - const checkLogin = computed(() => openId.value !== '') + const mobile = ref('') + const userInfo = ref({}) function getopenid(params: { code: string }) { return new Promise((resolve, reject) => { @@ -32,13 +30,13 @@ export default defineStore( }) } - function getUserInfo(params: { mobile: string }) { + function getUserInfo() { return new Promise((resolve, reject) => { - getUserInfoApi(params) + infoForOpenid({ openid: openId.value }) .then((res) => { const { data } = res as { data: userInfoStoreInt } - userInfo.value = Object.assign(userInfo.value, data) + userInfo.value = data resolve({ code: 1, data, message: 'SUCCESS' }) }) @@ -48,6 +46,18 @@ export default defineStore( }) } + function bindUser(id: number) { + return new Promise((resolve, reject) => { + bindApi({ id, openid: openId.value }) + .then(() => { + resolve({ code: 1, message: 'SUCCESS' }) + }) + .catch((err) => { + reject(err) + }) + }) + } + function logOut() { userInfo.value = {} uni.clearStorageSync() @@ -64,9 +74,10 @@ export default defineStore( return { openId, + mobile, userInfo, - checkLogin, getopenid, + bindUser, getUserInfo, logOut }