From 332808648d332c8cd7b87e07174aae93764fc493 Mon Sep 17 00:00:00 2001 From: jacobxu666 Date: Sun, 14 Jun 2026 23:10:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=A1=B9=E7=9B=AE=E6=9E=B6?= =?UTF-8?q?=E6=9E=84=E6=B8=85=E7=90=86=20=E2=80=94=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E9=A1=B5=E9=9D=A2/=E5=86=97=E4=BD=99store/H5?= =?UTF-8?q?=E9=99=8D=E7=BA=A7=E4=BB=A3=E7=A0=81/=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 2 +- app.js | 19 -- app.json | 15 -- app.wxss | 10 - pages/index/index.js | 49 ---- pages/index/index.json | 4 - pages/index/index.wxml | 27 -- pages/index/index.wxss | 62 ----- sitemap.json | 7 - src/api/index.ts | 5 - src/api/types.ts | 6 - src/api/user.ts | 9 +- src/components/McGlass.vue | 44 ++++ src/manifest.json | 10 + src/packages/user/pages/card/activate.vue | 5 +- src/packages/user/pages/card/bind.vue | 5 +- src/packages/user/pages/card/detail.vue | 6 +- src/packages/user/pages/card/list.vue | 25 +- src/packages/user/pages/card/qrcode.vue | 5 +- src/packages/user/pages/index/index.vue | 190 -------------- src/pages.json | 196 +++++++------- src/pages/login/login.vue | 108 +------- .../user => }/pages/profile/index.vue | 2 +- src/pages/profile/profile.vue | 239 ------------------ src/store/card.ts | 64 ----- src/store/user.ts | 15 +- utils/util.js | 19 -- 27 files changed, 182 insertions(+), 966 deletions(-) delete mode 100644 app.js delete mode 100644 app.json delete mode 100644 app.wxss delete mode 100644 pages/index/index.js delete mode 100644 pages/index/index.json delete mode 100644 pages/index/index.wxml delete mode 100644 pages/index/index.wxss delete mode 100644 sitemap.json delete mode 100644 src/api/index.ts create mode 100644 src/components/McGlass.vue delete mode 100644 src/packages/user/pages/index/index.vue rename src/{packages/user => }/pages/profile/index.vue (98%) delete mode 100644 src/pages/profile/profile.vue delete mode 100644 src/store/card.ts delete mode 100644 utils/util.js diff --git a/.env.local b/.env.local index 466a285..e2bf5be 100644 --- a/.env.local +++ b/.env.local @@ -1,2 +1,2 @@ -VITE_API_BASE_URL=http://localhost:80 +VITE_API_BASE_URL=http://localhost:48080 VITE_APP_TITLE=湖南12301文旅专区 diff --git a/app.js b/app.js deleted file mode 100644 index 1ed57c4..0000000 --- a/app.js +++ /dev/null @@ -1,19 +0,0 @@ -// app.js -App({ - onLaunch() { - // 展示本地存储能力 - const logs = wx.getStorageSync('logs') || [] - logs.unshift(Date.now()) - wx.setStorageSync('logs', logs) - - // 登录 - wx.login({ - success: res => { - // 发送 res.code 到后台换取 openId, sessionKey, unionId - } - }) - }, - globalData: { - userInfo: null - } -}) diff --git a/app.json b/app.json deleted file mode 100644 index 042e029..0000000 --- a/app.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "pages": [ - "pages/index/index", - "pages/logs/logs" - ], - "window": { - "navigationBarTextStyle": "black", - "navigationBarTitleText": "Weixin", - "navigationBarBackgroundColor": "#ffffff" - }, - "style": "v2", - "componentFramework": "glass-easel", - "sitemapLocation": "sitemap.json", - "lazyCodeLoading": "requiredComponents" -} diff --git a/app.wxss b/app.wxss deleted file mode 100644 index 06c6fc9..0000000 --- a/app.wxss +++ /dev/null @@ -1,10 +0,0 @@ -/**app.wxss**/ -.container { - height: 100%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: space-between; - padding: 200rpx 0; - box-sizing: border-box; -} diff --git a/pages/index/index.js b/pages/index/index.js deleted file mode 100644 index a8d6aa5..0000000 --- a/pages/index/index.js +++ /dev/null @@ -1,49 +0,0 @@ -// index.js -const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0' - -Page({ - data: { - motto: 'Hello World', - userInfo: { - avatarUrl: defaultAvatarUrl, - nickName: '', - }, - hasUserInfo: false, - canIUseGetUserProfile: wx.canIUse('getUserProfile'), - canIUseNicknameComp: wx.canIUse('input.type.nickname'), - }, - bindViewTap() { - wx.navigateTo({ - url: '../logs/logs' - }) - }, - onChooseAvatar(e) { - const { avatarUrl } = e.detail - const { nickName } = this.data.userInfo - this.setData({ - "userInfo.avatarUrl": avatarUrl, - hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl, - }) - }, - onInputChange(e) { - const nickName = e.detail.value - const { avatarUrl } = this.data.userInfo - this.setData({ - "userInfo.nickName": nickName, - hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl, - }) - }, - getUserProfile(e) { - // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 - wx.getUserProfile({ - desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 - success: (res) => { - console.log(res) - this.setData({ - userInfo: res.userInfo, - hasUserInfo: true - }) - } - }) - }, -}) diff --git a/pages/index/index.json b/pages/index/index.json deleted file mode 100644 index b55b5a2..0000000 --- a/pages/index/index.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "usingComponents": { - } -} \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml deleted file mode 100644 index 0721ba0..0000000 --- a/pages/index/index.wxml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - 昵称 - - - - - - 请使用2.10.4及以上版本基础库 - - - - {{userInfo.nickName}} - - - - {{motto}} - - - diff --git a/pages/index/index.wxss b/pages/index/index.wxss deleted file mode 100644 index 1ebed4b..0000000 --- a/pages/index/index.wxss +++ /dev/null @@ -1,62 +0,0 @@ -/**index.wxss**/ -page { - height: 100vh; - display: flex; - flex-direction: column; -} -.scrollarea { - flex: 1; - overflow-y: hidden; -} - -.userinfo { - display: flex; - flex-direction: column; - align-items: center; - color: #aaa; - width: 80%; -} - -.userinfo-avatar { - overflow: hidden; - width: 128rpx; - height: 128rpx; - margin: 20rpx; - border-radius: 50%; -} - -.usermotto { - margin-top: 200px; -} - -.avatar-wrapper { - padding: 0; - width: 56px !important; - border-radius: 8px; - margin-top: 40px; - margin-bottom: 40px; -} - -.avatar { - display: block; - width: 56px; - height: 56px; -} - -.nickname-wrapper { - display: flex; - width: 100%; - padding: 16px; - box-sizing: border-box; - border-top: .5px solid rgba(0, 0, 0, 0.1); - border-bottom: .5px solid rgba(0, 0, 0, 0.1); - color: black; -} - -.nickname-label { - width: 105px; -} - -.nickname-input { - flex: 1; -} diff --git a/sitemap.json b/sitemap.json deleted file mode 100644 index ca02add..0000000 --- a/sitemap.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", - "rules": [{ - "action": "allow", - "page": "*" - }] -} \ No newline at end of file diff --git a/src/api/index.ts b/src/api/index.ts deleted file mode 100644 index 46ff3a6..0000000 --- a/src/api/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './types' -export * from './user' -export * from './card' -export * from './order' -export { get, post, put, del, getToken, setToken, removeToken } from './request' diff --git a/src/api/types.ts b/src/api/types.ts index d56dfda..12b2a7e 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -16,12 +16,6 @@ export interface WxLoginResult { expiresTime: string } -/** 账号密码登录参数(降级方案) */ -export interface LoginParams { - username: string - password: string -} - /** 年卡基本信息 */ export interface CardInfo { id: string diff --git a/src/api/user.ts b/src/api/user.ts index 7b4093a..bc911de 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,19 +1,14 @@ import { get, post } from './request' -import type { UserInfo, WxLoginResult, LoginParams } from './types' +import type { UserInfo, WxLoginResult } from './types' /** 微信小程序登录(loginCode + phoneCode) */ export function wxLogin(data: { loginCode: string; phoneCode: string }): Promise { return post('/auth/wx-login', data, false) } -/** 账号密码登录(降级方案) */ -export function login(params: LoginParams): Promise { - return post('/auth/login', params, false) -} - /** 获取当前用户信息 */ export function getUserInfo(): Promise { return get('/user/info') } -export type { UserInfo, WxLoginResult, LoginParams } +export type { UserInfo, WxLoginResult } diff --git a/src/components/McGlass.vue b/src/components/McGlass.vue new file mode 100644 index 0000000..4b2589c --- /dev/null +++ b/src/components/McGlass.vue @@ -0,0 +1,44 @@ + + + + diff --git a/src/manifest.json b/src/manifest.json index 98232c6..51e55d4 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1 +1,11 @@ { + "mp-weixin": { + "appid": "wx636bc46a6570e9fd", + "setting": { + "urlCheck": false, + "es6": true, + "postcss": false, + "minified": false + } + } +} diff --git a/src/packages/user/pages/card/activate.vue b/src/packages/user/pages/card/activate.vue index a3870ad..0deb0a2 100644 --- a/src/packages/user/pages/card/activate.vue +++ b/src/packages/user/pages/card/activate.vue @@ -32,10 +32,9 @@ - - diff --git a/src/pages.json b/src/pages.json index 33a0667..f5f3155 100644 --- a/src/pages.json +++ b/src/pages.json @@ -1,103 +1,97 @@ { - "easycom": { - "autoscan": true, - "custom": { - "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue" - } - }, - "pages": [ - { - "path": "pages/index/index", - "style": { - "navigationBarTitleText": "湖南12301" - } - }, - { - "path": "pages/login/login", - "style": { - "navigationBarTitleText": "登录" - } - } - ], - "subPackages": [ - { - "root": "packages/user", - "pages": [ - { - "path": "pages/index/index", - "style": { - "navigationBarTitleText": "文旅专区" - } - }, - { - "path": "pages/card/list", - "style": { - "navigationBarTitleText": "年卡列表" - } - }, - { - "path": "pages/card/detail", - "style": { - "navigationBarTitleText": "年卡详情" - } - }, - { - "path": "pages/card/buy", - "style": { - "navigationBarTitleText": "确认购买" - } - }, - { - "path": "pages/card/activate", - "style": { - "navigationBarTitleText": "激活年卡" - } - }, - { - "path": "pages/card/qrcode", - "style": { - "navigationBarTitleText": "入园码" - } - }, - { - "path": "pages/card/bind", - "style": { - "navigationBarTitleText": "绑定年卡" - } - }, - { - "path": "pages/profile/index", - "style": { - "navigationBarTitleText": "个人中心" - } - } - ] - } - ], - "globalStyle": { - "navigationBarTextStyle": "black", - "navigationBarTitleText": "湖南12301", - "navigationBarBackgroundColor": "#FFFFFF", - "backgroundColor": "#F5F5F5" - }, - "tabBar": { - "color": "#7A7E83", - "selectedColor": "#4A90D9", - "borderStyle": "white", - "backgroundColor": "#ffffff", - "list": [ - { - "pagePath": "packages/user/pages/index/index", - "text": "首页", - "iconPath": "static/tabbar/home.png", - "selectedIconPath": "static/tabbar/home-active.png" - }, - { - "pagePath": "packages/user/pages/profile/index", - "text": "我的", - "iconPath": "static/tabbar/profile.png", - "selectedIconPath": "static/tabbar/profile-active.png" - } - ] - } + "easycom": { + "autoscan": true, + "custom": { + "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue" + } + }, + "pages": [ + { + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "文旅专区" + } + }, + { + "path": "pages/login/login", + "style": { + "navigationBarTitleText": "登录" + } + }, + { + "path": "pages/profile/index", + "style": { + "navigationBarTitleText": "个人中心" + } + } + ], + "subPackages": [ + { + "root": "packages/user", + "pages": [ + { + "path": "pages/card/list", + "style": { + "navigationBarTitleText": "年卡列表" + } + }, + { + "path": "pages/card/detail", + "style": { + "navigationBarTitleText": "年卡详情" + } + }, + { + "path": "pages/card/buy", + "style": { + "navigationBarTitleText": "确认购买" + } + }, + { + "path": "pages/card/activate", + "style": { + "navigationBarTitleText": "激活年卡" + } + }, + { + "path": "pages/card/qrcode", + "style": { + "navigationBarTitleText": "入园码" + } + }, + { + "path": "pages/card/bind", + "style": { + "navigationBarTitleText": "绑定年卡" + } + } + ] + } + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "湖南12301", + "navigationBarBackgroundColor": "#FFFFFF", + "backgroundColor": "#F5F5F5" + }, + "tabBar": { + "color": "#7A7E83", + "selectedColor": "#4A90D9", + "borderStyle": "white", + "backgroundColor": "#ffffff", + "list": [ + { + "pagePath": "pages/index/index", + "text": "首页", + "iconPath": "static/tabbar/home.png", + "selectedIconPath": "static/tabbar/home-active.png" + }, + { + "pagePath": "pages/profile/index", + "text": "我的", + "iconPath": "static/tabbar/profile.png", + "selectedIconPath": "static/tabbar/profile-active.png" + } + ] + } } diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue index 10bde67..1dd8fe7 100644 --- a/src/pages/login/login.vue +++ b/src/pages/login/login.vue @@ -7,36 +7,12 @@ @@ -49,18 +25,12 @@ diff --git a/src/store/card.ts b/src/store/card.ts deleted file mode 100644 index fa89e13..0000000 --- a/src/store/card.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { defineStore } from 'pinia' -import { ref } from 'vue' -import * as cardApi from '../api/card' -import type { CardInfo, CardDetail, MyCard, ActivateParams, QrCodeInfo } from '../api/types' - -export const useCardStore = defineStore('card', () => { - const cardList = ref([]) - const currentCard = ref(null) - const myCards = ref([]) - const loading = ref(false) - - /** 获取年卡列表 */ - async function fetchCardList(params?: { keyword?: string; category?: string }) { - loading.value = true - try { - cardList.value = await cardApi.getCardList(params) - } finally { - loading.value = false - } - } - - /** 获取年卡详情 */ - async function fetchCardDetail(id: string) { - loading.value = true - try { - currentCard.value = await cardApi.getCardDetail(id) - } finally { - loading.value = false - } - } - - /** 获取我的年卡 */ - async function fetchMyCards() { - myCards.value = await cardApi.getMyCards() - } - - /** 激活年卡 */ - async function activateCard(cardId: string, data: ActivateParams) { - return await cardApi.activateCard(cardId, data) - } - - /** 绑定年卡 */ - async function bindCard(cardNo: string) { - return await cardApi.bindCard(cardNo) - } - - /** 获取入园码 */ - async function getEntryQrCode(cardId: string): Promise { - return await cardApi.getEntryQrCode(cardId) - } - - return { - cardList, - currentCard, - myCards, - loading, - fetchCardList, - fetchCardDetail, - fetchMyCards, - activateCard, - bindCard, - getEntryQrCode - } -}) diff --git a/src/store/user.ts b/src/store/user.ts index 6956b77..15682fb 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -1,8 +1,8 @@ import { defineStore } from 'pinia' import { ref, computed } from 'vue' import { getToken, setToken, removeToken } from '../api/request' -import { wxLogin as apiWxLogin, login as apiLogin, getUserInfo as apiGetUserInfo } from '../api/user' -import type { UserInfo, LoginParams } from '../api/types' +import { wxLogin as apiWxLogin, getUserInfo as apiGetUserInfo } from '../api/user' +import type { UserInfo } from '../api/types' import { TOKEN_KEY, REFRESH_TOKEN_KEY } from '../config' export const useUserStore = defineStore('user', () => { @@ -22,16 +22,6 @@ export const useUserStore = defineStore('user', () => { return result } - /** 账号密码登录(降级方案) */ - async function login(params: LoginParams) { - const result = await apiLogin(params) - token.value = result.accessToken - refreshToken.value = result.refreshToken - setToken(result.accessToken) - uni.setStorageSync(REFRESH_TOKEN_KEY, result.refreshToken) - return result - } - /** 获取用户信息 */ async function fetchUserInfo() { if (!token.value) return @@ -55,7 +45,6 @@ export const useUserStore = defineStore('user', () => { userInfo, isLogin, wxLogin, - login, fetchUserInfo, logout } diff --git a/utils/util.js b/utils/util.js deleted file mode 100644 index 764bc2c..0000000 --- a/utils/util.js +++ /dev/null @@ -1,19 +0,0 @@ -const formatTime = date => { - const year = date.getFullYear() - const month = date.getMonth() + 1 - const day = date.getDate() - const hour = date.getHours() - const minute = date.getMinutes() - const second = date.getSeconds() - - return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` -} - -const formatNumber = n => { - n = n.toString() - return n[1] ? n : `0${n}` -} - -module.exports = { - formatTime -}