From 4e191d6c39a36810c77bfa6809088ee0a006df6e Mon Sep 17 00:00:00 2001 From: zpc Date: Mon, 8 Sep 2025 12:47:02 +0800 Subject: [PATCH] 2232 --- common/com.js | 21 +- common/server/config.js | 7 +- common/server/interface/article.js | 28 ++ common/server/interface/user.js | 51 ++- common/server/login.js | 0 common/server/user.js | 18 ++ common/system/request.js | 9 +- common/system/router.js | 3 +- components.d.ts | 4 + components/com/page/container.vue | 132 ++++++++ components/com/page/no-data.vue | 58 ++++ components/uni-nav-bar/uni-nav-bar.vue | 360 ++++++++++++++++++++++ components/uni-nav-bar/uni-status-bar.vue | 31 ++ pages.json | 24 ++ pages/me/edit-info.vue | 202 +++++++++--- pages/me/login.vue | 230 +++++++++----- pages/me/me-page.vue | 107 ++++--- pages/other/agreement.vue | 155 ++++++++++ 18 files changed, 1246 insertions(+), 194 deletions(-) create mode 100644 common/server/interface/article.js create mode 100644 common/server/login.js create mode 100644 common/server/user.js create mode 100644 components/com/page/container.vue create mode 100644 components/com/page/no-data.vue create mode 100644 components/uni-nav-bar/uni-nav-bar.vue create mode 100644 components/uni-nav-bar/uni-status-bar.vue create mode 100644 pages/other/agreement.vue diff --git a/common/com.js b/common/com.js index 0fe3e98..7dbb3c9 100644 --- a/common/com.js +++ b/common/com.js @@ -4,8 +4,21 @@ import * as utils3 from './system/router'; import * as utils4 from './system/request'; // 动态合并所有导出到 yds 对象 export const com = { - ...utils1, - ...utils2, - ...utils3, - ...utils4, + ...utils1, + ...utils2, + ...utils3, + ...utils4, }; + + +export const useLogin = async () => { + return new Promise((resolve) => { + uni.login({ + provider: 'weixin', //使用微信登录 + success: function (loginRes) { + // console.log(loginRes); + resolve(loginRes.code) + } + }); + }); +} \ No newline at end of file diff --git a/common/server/config.js b/common/server/config.js index 38b5f99..0549a12 100644 --- a/common/server/config.js +++ b/common/server/config.js @@ -13,9 +13,12 @@ export const preloadConfigData = async () => { configData.value = { config: res }; - console.log("configData.value",configData.value); + console.log("configData.value", configData.value); }; -export const getConfigData = () => { +export const getConfigData = async () => { + if (configData.value == null) { + await preloadConfigData(); + } return configData.value; } \ No newline at end of file diff --git a/common/server/interface/article.js b/common/server/interface/article.js new file mode 100644 index 0000000..1a86481 --- /dev/null +++ b/common/server/interface/article.js @@ -0,0 +1,28 @@ +import request from '@/common/system/request'; + + +/** + * 获取单个文章内容 + * @param {number} id 文章ID + * @returns {Promise} + */ +export const getArticleDetail = async (id) => { + const res = await request.getOrCache("Article/GetArticleDetail", { id }); + if (res.code == 0) { + return res.data; + } + return null; +} + +/** + * 获取通知列表 + * @param {Object} params 查询参数 + * @returns {Promise} + */ +export const noticeList = async (params) => { + const res = await request.post("Article/NoticeList", params); + if (res.code == 0) { + return res.data; + } + return null; +} \ No newline at end of file diff --git a/common/server/interface/user.js b/common/server/interface/user.js index 6f95273..401b023 100644 --- a/common/server/interface/user.js +++ b/common/server/interface/user.js @@ -1,11 +1,12 @@ import request from '@/common/system/request'; + /** - * 查询用户是否可以成为分销商 + * 匿名登录 * @returns {Promise} */ -export const getDistributionInfo = async () => { - const res = await request.post("Distribution/Info"); +export const getAnonymousLogin = async (code) => { + const res = await request.post("user/UseAnonymousLogin", { code: code }); if (res.code == 0) { return res.data; } @@ -13,12 +14,13 @@ export const getDistributionInfo = async () => { } /** - * 申请成为分销商接口 - * @param {Object} data 分销商申请数据 - * @returns {Promise} + * 微信小程序授权拉取手机号码并登录 + * @param {*} code + * @param {*} sessionAuthId + * @returns */ -export const applyDistribution = async (data) => { - const res = await request.post("Distribution/ApplyDistribution", data); +export const ueWxPhoneNumberLogin = async (code, sessionAuthId) => { + const res = await request.post("user/UseWxPhoneNumberLogin", { code: code, sessionAuthId: sessionAuthId }); if (res.code == 0) { return res.data; } @@ -26,12 +28,13 @@ export const applyDistribution = async (data) => { } /** - * 获取分销商排行 - * @param {Object} params 分页参数 - * @returns {Promise} + * 微信小程序匿名授权登录,手机号已授权过 + * @param {*} code + * @param {*} sessionAuthId + * @returns */ -export const getDistributionRanking = async (params) => { - const res = await request.post("Distribution/GetDistributionRanking", params); +export const useWxAnonymousLogin = async (sessionAuthId) => { + const res = await request.post("user/UseWxAnonymousLogin", { sessionAuthId: sessionAuthId }); if (res.code == 0) { return res.data; } @@ -39,25 +42,13 @@ export const getDistributionRanking = async (params) => { } /** - * 获取我的订单统计 - * @returns {Promise} + * 获取用户信息 + * @returns */ -export const getOrderSum = async () => { - const res = await request.post("Distribution/GetOrderSum"); +export const getUserInfo = async () => { + const res = await request.post("user/GetUserInfo"); if (res.code == 0) { return res.data; } return null; -} - -/** - * 获取我的下级用户数量 - * @returns {Promise} - */ -export const getTeamSum = async () => { - const res = await request.post("Distribution/GetTeamSum"); - if (res.code == 0) { - return res.data; - } - return null; -} \ No newline at end of file +} \ No newline at end of file diff --git a/common/server/login.js b/common/server/login.js new file mode 100644 index 0000000..e69de29 diff --git a/common/server/user.js b/common/server/user.js new file mode 100644 index 0000000..cdea6c1 --- /dev/null +++ b/common/server/user.js @@ -0,0 +1,18 @@ +import { getUserInfo } from '@/common/server/interface/user' +import { ref } from 'vue' + +export var userInfo = ref(null); + +export const loadUserInfo = async () => { + const res = await getUserInfo(); + if (res == null) { + + userInfo.value = null; + uni.removeStorageSync('tokenInfo'); + uni.removeStorageSync('userInfo'); + return; + } + userInfo.value = res; + uni.setStorageSync('userInfo', res); +} + diff --git a/common/system/request.js b/common/system/request.js index 43a6bec..d7d9042 100644 --- a/common/system/request.js +++ b/common/system/request.js @@ -101,7 +101,7 @@ class request { return new Promise((resolve, reject) => { // 使用传入的method而不是重新声明 const requestMethod = method.toUpperCase(); - const token = uni.getStorageSync('token'); + let data = { ...fromData }; // 创建数据的深拷贝,避免修改原数据 // 构建请求URL和提取主机名 @@ -122,9 +122,10 @@ class request { const header = { 'content-type': 'application/json' }; - if(token!=null&&token!=""){ - header['Authorization']='Bearer ' + token; - } + const tokenInfo = uni.getStorageSync('tokenInfo'); + if (tokenInfo != null && tokenInfo != "") { + header['Authorization'] = 'Bearer ' + tokenInfo.token; + } const startDate = Date.now(); diff --git a/common/system/router.js b/common/system/router.js index c3c35bd..5555325 100644 --- a/common/system/router.js +++ b/common/system/router.js @@ -29,5 +29,6 @@ export const navigateToAccountLogin = (page = "") => { * @param {String} type 协议类型 */ export const navigateToAgreement = (type) => { - // navigateTo(`/pages/other/agreement?type=${type}`); + + navigateTo(`/pages/other/agreement?type=${type}`); }; \ No newline at end of file diff --git a/components.d.ts b/components.d.ts index 09a1487..00a4aca 100644 --- a/components.d.ts +++ b/components.d.ts @@ -8,8 +8,12 @@ export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { + Container: typeof import('./components/com/page/container.vue')['default'] MahjongCard: typeof import('./components/index/MahjongCard.vue')['default'] + NoData: typeof import('./components/com/page/no-data.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] + UniNavBar: typeof import('./components/uni-nav-bar/uni-nav-bar.vue')['default'] + UniStatusBar: typeof import('./components/uni-nav-bar/uni-status-bar.vue')['default'] } } diff --git a/components/com/page/container.vue b/components/com/page/container.vue new file mode 100644 index 0000000..cb615ee --- /dev/null +++ b/components/com/page/container.vue @@ -0,0 +1,132 @@ + + + + + + \ No newline at end of file diff --git a/components/com/page/no-data.vue b/components/com/page/no-data.vue new file mode 100644 index 0000000..2a34753 --- /dev/null +++ b/components/com/page/no-data.vue @@ -0,0 +1,58 @@ + + + + + \ No newline at end of file diff --git a/components/uni-nav-bar/uni-nav-bar.vue b/components/uni-nav-bar/uni-nav-bar.vue new file mode 100644 index 0000000..acf4731 --- /dev/null +++ b/components/uni-nav-bar/uni-nav-bar.vue @@ -0,0 +1,360 @@ + + + + + diff --git a/components/uni-nav-bar/uni-status-bar.vue b/components/uni-nav-bar/uni-status-bar.vue new file mode 100644 index 0000000..3a8f3fb --- /dev/null +++ b/components/uni-nav-bar/uni-status-bar.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/pages.json b/pages.json index 07c3477..a14f84f 100644 --- a/pages.json +++ b/pages.json @@ -1,4 +1,12 @@ { + "easycom": { + "autoscan": true, + "custom": { + // 通用规则:匹配 guyu 下任意子目录的组件,格式 <目录名>-<组件名> + "^com-([a-z]+)-(.*)": "@/components/com/$1/$2.vue" + + } + }, "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { "path" : "pages/index/loading", @@ -55,6 +63,22 @@ "navigationBarTitleText": "", "navigationStyle": "custom" } + }, + { + "path" : "pages/other/agreement", + "style" : + { + "navigationBarTitleText" : "", + "navigationStyle": "custom" + } + }, + { + "path" : "components/com/page/container", + "style" : + { + "navigationBarTitleText" : "", + "navigationStyle": "custom" + } } ], "globalStyle": { diff --git a/pages/me/edit-info.vue b/pages/me/edit-info.vue index 59db9b6..1b98192 100644 --- a/pages/me/edit-info.vue +++ b/pages/me/edit-info.vue @@ -9,71 +9,193 @@ - - - 我的头像 - - + + 我的UID + {{ user.id }} - + + + 我的头像 + + + + + + + 我的昵称 - + - - - + + + 我的年龄 - - + + + + {{ ageOptions[ageIndex] }}岁 + + - + - - - 我的UID - {{userId}} + + + + 我的性别 + + + + {{ genderOptions[genderIndex] }} + + - + + + - \ No newline at end of file diff --git a/pages/me/login.vue b/pages/me/login.vue index f4074ec..e61a95d 100644 --- a/pages/me/login.vue +++ b/pages/me/login.vue @@ -21,16 +21,26 @@