hookehuyr

feat(微信步数): 添加微信步数同步功能及相关配置

添加微信步数同步API接口及页面跳转逻辑
移除模拟数据生成代码,优化授权流程
更新路由配置和请求参数,添加用户信息权限
1 +/*
2 + * @Date: 2023-12-22 10:29:37
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2025-09-01 13:53:17
5 + * @FilePath: /lls_program/src/api/points.js
6 + * @Description: 文件描述
7 + */
8 +import { fn, fetch } from './fn';
9 +
10 +const Api = {
11 + SYNC_WX_STEP: '/srv/?a=point&t=sync_wx_step',
12 +}
13 +
14 +/**
15 + * @description: 同步微信步数
16 + * @returns
17 + */
18 +export const syncWxStepAPI = (params) => fn(fetch.post(Api.SYNC_WX_STEP, params));
1 /* 1 /*
2 * @Date: 2025-06-28 10:33:00 2 * @Date: 2025-06-28 10:33:00
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-09-01 13:08:15 4 + * @LastEditTime: 2025-09-01 14:31:43
5 * @FilePath: /lls_program/src/app.config.js 5 * @FilePath: /lls_program/src/app.config.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
8 export default { 8 export default {
9 pages: [ 9 pages: [
10 // 'pages/index/index', 10 // 'pages/index/index',
11 - // 'pages/auth/index',
12 'pages/Welcome/index', 11 'pages/Welcome/index',
12 + 'pages/auth/index',
13 'pages/Dashboard/index', 13 'pages/Dashboard/index',
14 'pages/MyFamily/index', 14 'pages/MyFamily/index',
15 'pages/CreateFamily/index', 15 'pages/CreateFamily/index',
...@@ -51,6 +51,9 @@ export default { ...@@ -51,6 +51,9 @@ export default {
51 }, 51 },
52 'scope.werun': { 52 'scope.werun': {
53 desc: '您的微信运动数据将用于记录步数和健康统计' 53 desc: '您的微信运动数据将用于记录步数和健康统计'
54 + },
55 + 'scope.userInfo': {
56 + desc: '您的用户信息将用于个人中心和活动打卡'
54 } 57 }
55 } 58 }
56 } 59 }
......
1 /* 1 /*
2 * @Date: 2025-06-28 10:33:00 2 * @Date: 2025-06-28 10:33:00
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-06-28 11:04:17 4 + * @LastEditTime: 2025-09-01 14:32:25
5 * @FilePath: /lls_program/src/app.js 5 * @FilePath: /lls_program/src/app.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -9,32 +9,22 @@ import { createApp } from 'vue' ...@@ -9,32 +9,22 @@ import { createApp } from 'vue'
9 import { createPinia } from 'pinia' 9 import { createPinia } from 'pinia'
10 import './app.less' 10 import './app.less'
11 import { routerStore } from '@/stores/router' 11 import { routerStore } from '@/stores/router'
12 -import Taro from '@tarojs/taro'
13 12
14 const App = createApp({ 13 const App = createApp({
15 // 对应 onLaunch 14 // 对应 onLaunch
16 onLaunch(options) { 15 onLaunch(options) {
17 // 未授权状态跳转授权页面,首页不需要权限 16 // 未授权状态跳转授权页面,首页不需要权限
18 const path = options.path; 17 const path = options.path;
19 - const query = options.query;
20 // 缓存没有权限的地址 18 // 缓存没有权限的地址
21 const router = routerStore(); 19 const router = routerStore();
22 router.add(path); 20 router.add(path);
23 - // if (path !== 'pages/index/index' && !wx.getStorageSync("sessionid")) {
24 if (!wx.getStorageSync("sessionid")) { 21 if (!wx.getStorageSync("sessionid")) {
25 - console.warn("没有权限"); 22 + wx.navigateTo({
26 - // if (path === 'pages/detail/index') { 23 + url: '/pages/auth/index'
27 - // Taro.navigateTo({ 24 + })
28 - // url: `./pages/auth/index?url=${path}&id=${query.id}&start_date=${query.start_date}&end_date=${query.end_date}`,
29 - // })
30 - // } else {
31 - // Taro.navigateTo({
32 - // url: './pages/auth/index?url=' + path,
33 - // })
34 - // }
35 } 25 }
36 }, 26 },
37 - onShow(options) { 27 + onShow() {
38 }, 28 },
39 // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖 29 // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
40 }); 30 });
......
...@@ -206,11 +206,6 @@ const collectAll = async () => { ...@@ -206,11 +206,6 @@ const collectAll = async () => {
206 206
207 floatingItems.value = []; 207 floatingItems.value = [];
208 isCollecting.value = false; 208 isCollecting.value = false;
209 -
210 - // 模拟2秒后重新生成
211 - // setTimeout(() => {
212 - // floatingItems.value = generateMockData();
213 - // }, 2000);
214 }, totalAnimationTime); 209 }, totalAnimationTime);
215 } 210 }
216 211
...@@ -243,7 +238,7 @@ defineExpose({ ...@@ -243,7 +238,7 @@ defineExpose({
243 /** 238 /**
244 * 初始化数据 239 * 初始化数据
245 */ 240 */
246 -const initData = () => { 241 +const initData = async () => {
247 floatingItems.value = generateMockData(); 242 floatingItems.value = generateMockData();
248 console.warn('初始化数据') 243 console.warn('初始化数据')
249 } 244 }
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
35 import { ref, onMounted, defineEmits } from 'vue' 35 import { ref, onMounted, defineEmits } from 'vue'
36 import Taro from '@tarojs/taro' 36 import Taro from '@tarojs/taro'
37 37
38 +import { syncWxStepAPI } from '@/api/points'
39 +
38 // 定义事件 40 // 定义事件
39 const emit = defineEmits(['auth-change', 'steps-update']) 41 const emit = defineEmits(['auth-change', 'steps-update'])
40 42
...@@ -141,19 +143,17 @@ const getWeRunData = async () => { ...@@ -141,19 +143,17 @@ const getWeRunData = async () => {
141 code: loginRes.code 143 code: loginRes.code
142 }) 144 })
143 145
146 + // 同步微信步数
147 + const { code, data } = await syncWxStepAPI({ encryptedData: weRunRes.encryptedData, iv: weRunRes.iv });
148 + if (code) {
144 // 提示获取步数成功 149 // 提示获取步数成功
145 // Taro.showToast({ 150 // Taro.showToast({
146 // title: `获取步数成功:${mockSteps}步`, 151 // title: `获取步数成功:${mockSteps}步`,
147 // icon: 'none' 152 // icon: 'none'
148 // }) 153 // })
149 - 154 + console.warn('同步微信步数成功', data);
150 - // TODO: 实际项目中需要将 encryptedData, iv, code 发送到后端解密
151 - // const decryptedData = await api.decryptWeRunData({
152 - // encryptedData: weRunRes.encryptedData,
153 - // iv: weRunRes.iv,
154 - // code: loginRes.code
155 - // })
156 // todaySteps.value = decryptedData.todaySteps 155 // todaySteps.value = decryptedData.todaySteps
156 + }
157 157
158 } catch (error) { 158 } catch (error) {
159 console.error('获取微信运动数据失败:', error) 159 console.error('获取微信运动数据失败:', error)
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-05-26 10:17:04 4 + * @LastEditTime: 2025-09-01 13:57:13
5 - * @FilePath: /meihuaApp/src/pages/auth/index.vue 5 + * @FilePath: /lls_program/src/pages/auth/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
8 <template> 8 <template>
...@@ -60,15 +60,9 @@ export default { ...@@ -60,15 +60,9 @@ export default {
60 // } 60 // }
61 // TAG:处理分享跳转问题 61 // TAG:处理分享跳转问题
62 const params = getCurrentPageParam(); 62 const params = getCurrentPageParam();
63 - if (getCurrentPageParam().url === 'pages/detail/index') { // 详情页的分享跳转处理 63 + Taro.reLaunch({
64 - Taro.reLaunch({ 64 + url: `/pages/Dashboard/index`
65 - url: `../../${params.url}?id=${params.id}&start_date=${params.start_date}&end_date=${params.end_date}` 65 + })
66 - })
67 - } else { // 其他页面分享跳首页
68 - Taro.reLaunch({
69 - url: `/pages/index/index?first_in=${wx.getStorageSync("first_in")}`
70 - })
71 - }
72 Taro.hideLoading(); 66 Taro.hideLoading();
73 } 67 }
74 } else { 68 } else {
......
1 /* 1 /*
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-07-01 11:17:49 4 + * @LastEditTime: 2025-09-01 13:47:06
5 * @FilePath: /lls_program/src/utils/request.js 5 * @FilePath: /lls_program/src/utils/request.js
6 * @Description: 简单axios封装,后续按实际处理 6 * @Description: 简单axios封装,后续按实际处理
7 */ 7 */
...@@ -60,8 +60,7 @@ const service = axios.create({ ...@@ -60,8 +60,7 @@ const service = axios.create({
60 }) 60 })
61 61
62 service.defaults.params = { 62 service.defaults.params = {
63 - f: 'room', 63 + f: 'walk',
64 - client_id: '772428',
65 }; 64 };
66 65
67 // request interceptor 66 // request interceptor
...@@ -161,7 +160,7 @@ service.interceptors.response.use( ...@@ -161,7 +160,7 @@ service.interceptors.response.use(
161 */ 160 */
162 setTimeout(() => { 161 setTimeout(() => {
163 Taro.navigateTo({ 162 Taro.navigateTo({
164 - url: '../../pages/auth/index?url=' + routerStore().url 163 + url: '/pages/auth/index?url=' + routerStore().url
165 }); 164 });
166 }, 1000); 165 }, 1000);
167 } 166 }
......