diff --git a/api/modules/home.js b/api/modules/home.js index 0ceec34..c82340b 100644 --- a/api/modules/home.js +++ b/api/modules/home.js @@ -35,5 +35,22 @@ export default{ url: '/index/banner', method: 'GET', }) - } + }, + + // 查询文章列表 + async getArticle() { + return http({ + url: '/index/articleList', + method: 'GET', + }) + }, + + // 查询文章详情 + async getArticleDetail(data) { + return http({ + url: '/index/articleDetail', + method: 'GET', + data + }) + }, } \ No newline at end of file diff --git a/components/BookList.vue b/components/BookList.vue new file mode 100644 index 0000000..2580af1 --- /dev/null +++ b/components/BookList.vue @@ -0,0 +1,164 @@ + + + + + \ No newline at end of file diff --git a/components/articleList.vue b/components/articleList.vue new file mode 100644 index 0000000..de20729 --- /dev/null +++ b/components/articleList.vue @@ -0,0 +1,251 @@ + + + + + \ No newline at end of file diff --git a/mixins/list.js b/mixins/list.js index d2b7469..8619da7 100644 --- a/mixins/list.js +++ b/mixins/list.js @@ -1,138 +1,138 @@ // 简化版列表的混入 export default { - data() { - return { - list: [], - pageNo : 1, - pageSize : 8, - mixinListApi: '', - isLoading: false, - hasMore: true, - // 额外返回出去的数据 - extraData: null, - // 每次更新数据后执行的函数 可以进行数据处理 - afterUpdateDataFn: function() {}, - // 每次更新数据前执行的函数, - beforeUpdateDataFn: function() {}, - // 混入配置 - mixinListConfig: { - // 数据返回的直接路径 - responsePath: 'result.records', - // 列表是否需要下拉刷新 - isPullDownRefresh: true, - // 列表是否需要上拉加载 - isReachBottomLoad: true, - // 额外返回出去的数据的路径 - extraDataPath: '' , - // 自定义onShow - customOnShow: false, - } - } - }, - computed: { - // 自定义onShow前会执行的函数 - mixinFnBeforePageShow() { - return function() {} - } - }, - methods: { - // 获取文件的自定义传参 -- 可以在页面中重写 - mixinSetParams() { - return {} - }, - // 解析分路径获取嵌套值 - resolvePath(obj, path) { - if (path){ - return path.split('.').reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : null), obj) - }else { - return obj - } + data() { + return { + list: [], + pageNo: 1, + pageSize: 8, + mixinListApi: '', + isLoading: false, + hasMore: true, + // 额外返回出去的数据 + extraData: null, + // 每次更新数据后执行的函数 可以进行数据处理 + afterUpdateDataFn: function () { }, + // 每次更新数据前执行的函数, + beforeUpdateDataFn: function () { }, + // 混入配置 + mixinListConfig: { + // 数据返回的直接路径 + responsePath: 'result.records', + // 列表是否需要下拉刷新 + isPullDownRefresh: true, + // 列表是否需要上拉加载 + isReachBottomLoad: true, + // 额外返回出去的数据的路径 + extraDataPath: '', + // 自定义onShow + customOnShow: false, + } + } }, - // 初始化分页 - initPage(){ - this.pageNo = 1, - this.hasMore = true + computed: { + // 自定义onShow前会执行的函数 + mixinFnBeforePageShow() { + return function () { } + } }, - // 获取列表 - async getList(isRefresh = false) { - // console.log('本次请求的pageNo和pageSize', this.pageNo, this.pageSize) + methods: { + // 获取文件的自定义传参 -- 可以在页面中重写 + mixinSetParams() { + return {} + }, + // 解析分路径获取嵌套值 + resolvePath(obj, path) { + if (path) { + return path.split('.').reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : null), obj) + } else { + return obj + } + }, + // 初始化分页 + initPage() { + this.pageNo = 1 + this.hasMore = true + }, + // 获取列表 + async getList(isRefresh = false) { + // console.log('本次请求的pageNo和pageSize', this.pageNo, this.pageSize) - if (!this.hasMore) { - return - } - this.isLoading = true - const apiMethod = this.resolvePath(this.$api, this.mixinListApi) - if (typeof apiMethod !== 'function') { - console.log('mixinApi不存在', this.mixinListApi); - return - } - // 每次更新数据前执行的函数 - if (this.beforeUpdateDataFn) { - this.beforeUpdateDataFn(this.list) - } - - const res = await apiMethod({ - pageNo: this.pageNo, - pageSize: this.pageSize, - ...this.mixinSetParams() - }) - const resData = this.resolvePath(res, this.mixinListConfig.responsePath) || [] - if (res.code === 200) { - // 如果没有值了 - if (!resData.length) { - this.hasMore = false - // uni.showToast({ - // title: '暂无更多数据', - // icon: 'none' - // }) - }else { - this.pageNo++ - } + if (!this.hasMore) { + return + } + this.isLoading = true + const apiMethod = this.resolvePath(this.$api, this.mixinListApi) + if (typeof apiMethod !== 'function') { + console.log('mixinApi不存在', this.mixinListApi); + return + } + // 每次更新数据前执行的函数 + if (this.beforeUpdateDataFn) { + this.beforeUpdateDataFn(this.list) + } - if (isRefresh ) { - // 如果是刷新,直接覆盖 - this.list = resData - - } else { - this.list = [...this.list, ...resData] - } + const res = await apiMethod({ + pageNo: this.pageNo, + pageSize: this.pageSize, + ...this.mixinSetParams() + }) + const resData = this.resolvePath(res, this.mixinListConfig.responsePath) || [] + if (res.code === 200) { + // 如果没有值了 + if (!resData.length) { + this.hasMore = false + // uni.showToast({ + // title: '暂无更多数据', + // icon: 'none' + // }) + } else { + this.pageNo++ + } + + if (isRefresh) { + // 如果是刷新,直接覆盖 + this.list = resData - // 如果有额外数据的路径,刷新后,需要将额外数据也刷新 - if (this.mixinListConfig.extraDataPath !== '') { - this.extraData = this.resolvePath(res, this.mixinListConfig.extraDataPath) + } else { + this.list = [...this.list, ...resData] + } + + // 如果有额外数据的路径,刷新后,需要将额外数据也刷新 + if (this.mixinListConfig.extraDataPath !== '') { + this.extraData = this.resolvePath(res, this.mixinListConfig.extraDataPath) + } + } + // 每次更新数据后执行的函数 + if (this.afterUpdateDataFn) { + this.afterUpdateDataFn(this.list) + } + // 如果有在加载中 + if (this.isLoading) { + this.isLoading = false + } + // 有过有在下拉加载 + uni.stopPullDownRefresh() + }, + }, + async onShow() { + if (!this.mixinListConfig.customOnShow) { + if (this.mixinFnBeforePageShow) this.mixinFnBeforePageShow() + this.initPage() + await this.getList(true) } - } - // 每次更新数据后执行的函数 - if (this.afterUpdateDataFn) { - this.afterUpdateDataFn(this.list) - } - // 如果有在加载中 - if (this.isLoading) { - this.isLoading = false - } - // 有过有在下拉加载 - uni.stopPullDownRefresh() }, - }, - async onShow() { - if (!this.mixinListConfig.customOnShow) { - if (this.mixinFnBeforePageShow) this.mixinFnBeforePageShow() - this.initPage() - await this.getList(true) - } - }, - async onPullDownRefresh() { - // 在下拉还没结束前 不做任何操作 - if (this.isLoading) { - return - } - this.initPage() - await this.getList(true) - }, - async onReachBottom() { - if (this.isLoading) { - return + async onPullDownRefresh() { + // 在下拉还没结束前 不做任何操作 + if (this.isLoading) { + return + } + this.initPage() + await this.getList(true) + }, + async onReachBottom() { + if (this.isLoading) { + return + } + await this.getList() } - await this.getList() - } } \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..bc350fc --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "englishread-front", + "version": "1.0.0", + "description": "四零语境", + "main": "main.js", + "scripts": { + "dev:h5": "uni build --platform h5 --watch", + "build:h5": "uni build --platform h5", + "serve": "uni serve" + }, + "dependencies": { + "@dcloudio/uni-app": "^2.0.0", + "@dcloudio/uni-h5": "^2.0.0", + "@dcloudio/uni-helper-json": "*" + }, + "devDependencies": { + "@dcloudio/uni-cli-shared": "*", + "@dcloudio/webpack-uni-mp-loader": "*", + "@dcloudio/webpack-uni-pages-loader": "*" + }, + "browserslist": [ + "Android >= 4.4", + "ios >= 9" + ] +} \ No newline at end of file diff --git a/pages.json b/pages.json index 24f6b74..a8ea309 100644 --- a/pages.json +++ b/pages.json @@ -197,6 +197,13 @@ // #endif "navigationBarTitleText": "分享" } + }, + { + "path": "home/articleDetail", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "文章详情" + } } ] } diff --git a/pages/components/SplashScreen.vue b/pages/components/SplashScreen.vue index afddba3..6bc6e3d 100644 --- a/pages/components/SplashScreen.vue +++ b/pages/components/SplashScreen.vue @@ -79,9 +79,50 @@ export default { this.clearTimer() }, methods: { - // 初始化開動頁面 + // 檢查是否為H5环境 + isH5() { + // #ifdef H5 + return true + // #endif + // #ifndef H5 + return false + // #endif + }, + + // 檢查是否已显示过开屏 + hasShownSplash() { + if (this.isH5()) { + try { + return sessionStorage.getItem('splash_shown') === 'true' + } catch (error) { + console.error('读取sessionStorage失败:', error) + return false + } + } + return false + }, + + // 设置开屏已显示标记 + setSplashShown() { + if (this.isH5()) { + try { + sessionStorage.setItem('splash_shown', 'true') + } catch (error) { + console.error('设置sessionStorage失败:', error) + } + } + }, + + // 初始化开动頁面 async initSplash() { try { + // 在H5环境下检查是否已显示过开屏 + if (this.hasShownSplash()) { + console.log('开屏已显示过,跳过开屏动画') + this.$emit('close') + return + } + // 等待一小段時間確保 store 數據加載完成 await this.$nextTick() @@ -130,6 +171,10 @@ export default { // 關閉開動頁面 closeSplash() { this.showSplash = false + + // 在H5环境下设置开屏已显示标记 + this.setSplashShown() + uni.showTabBar({ animation: true }) diff --git a/pages/components/VideoPopup.vue b/pages/components/VideoPopup.vue new file mode 100644 index 0000000..11ca4b4 --- /dev/null +++ b/pages/components/VideoPopup.vue @@ -0,0 +1,113 @@ + + + + + \ No newline at end of file diff --git a/pages/index/home.vue b/pages/index/home.vue index 0c9ecf5..70fe2bc 100644 --- a/pages/index/home.vue +++ b/pages/index/home.vue @@ -1,935 +1,811 @@ diff --git a/stores/index.js b/stores/index.js index fe30112..e3b1647 100644 --- a/stores/index.js +++ b/stores/index.js @@ -9,134 +9,134 @@ import share from '@/utils/share.js' Vue.use(Vuex) const store = new Vuex.Store({ - state: { - // 存放状态 - configList: [], - departmentList: [], - categoryList: [], - userInfo:{}, - Qrcode: '' - }, - mutations: { - // 构造用于uv-picker的树状结构数组 - setCategoryList(state, data) { - // 将返回的平面数组data 根据pid和hasChild组装成两个数组,其一为pid为0的父级一维数组,其二为pid不为0的子级二维数组,其中pid相同的排一起 不同的分为不同子数组,并且按顺序排序,比如第一个为[中国,美国] 第二个按顺序为[[上海,福建],[纽约,华盛顿]] - - // 分离父级和子级数据 - const parentCategories = data.filter(item => item.pid === 0 || item.pid === '0') - const childCategories = data.filter(item => item.pid !== 0 && item.pid !== '0') - - // 构建父级一维数组 - const parentArray = parentCategories.map((item) => { - return { - label: item.name || item.title || item.categoryName, - value: item.id - } - }) - - // 构建子级二维数组 - const childArray = [] - parentCategories.forEach(parent => { - const children = childCategories - .filter(child => child.pid === parent.id) - .map(child => { - return { - label: child.name || child.title || child.categoryName, - value: child.id - } - }) - childArray.push(children.length > 0 ? children : [{ - label: '全部', - value: 0 - }]) - }) - - // 组装最终结果 - state.categoryList = [parentArray, childArray] - - }, - setConfigList(state, data) { - state.configList = data - }, - setDepartmentList(state, data) { - state.departmentList = data - }, - setUserInfo(state, data) { - state.userInfo = data - // #ifdef H5 - localStorage.setItem('userInfo', JSON.stringify(data)) - share() - // #endif - }, - setQrcode(state, data) { - state.Qrcode = data + state: { + // 存放状态 + configList: [], + departmentList: [], + categoryList: [], + userInfo: {}, + Qrcode: '' }, - // - }, - actions: { - // 查询配置列表 - async getConfig({ commit }) { - const res = await api.config.queryConfigList() - // 要求变成键值对的样子 - const config = res.result.reduce((acc, item) => { - if (!item.code) { - console.log('code为空', item); - return acc - } - acc[item.code] = item - return acc - }, {}) - console.log('configList列表为:', config); - - // 事先永久存儲首屏圖片的數據 - if (config.creen_image) { - uni.setStorageSync('screen_image', config.creen_image.content) - } - if (config.login_logo) { - uni.setStorageSync('login_logo', config.login_logo.content) - } + mutations: { + // 构造用于uv-picker的树状结构数组 + setCategoryList(state, data) { + // 将返回的平面数组data 根据pid和hasChild组装成两个数组,其一为pid为0的父级一维数组,其二为pid不为0的子级二维数组,其中pid相同的排一起 不同的分为不同子数组,并且按顺序排序,比如第一个为[中国,美国] 第二个按顺序为[[上海,福建],[纽约,华盛顿]] - commit('setConfigList', config) - - // #ifdef H5 - share() - // #endif - }, - // 查询部门列表 - async getDepartment({ commit }) { - const res = await api.config.queryDepartmentList() - commit('setDepartmentList', res.result.records) - }, - // 获取分类列表 - async getCategory({ commit }) { - const res = await api.config.queryCategoryList() - commit('setCategoryList', res.result.records) - }, - // 初始化数据 - async initData({ dispatch, state }) { - // 检查是否已初始化 - if (state.configList.length > 0) { + // 分离父级和子级数据 + const parentCategories = data.filter(item => item.pid === 0 || item.pid === '0') + const childCategories = data.filter(item => item.pid !== 0 && item.pid !== '0') - console.log('配置数据已初始化,无需重复初始化') - return - } + // 构建父级一维数组 + const parentArray = parentCategories.map((item) => { + return { + label: item.name || item.title || item.categoryName, + value: item.id + } + }) - try { - await Promise.all([ - dispatch('getConfig'), - // dispatch('getDepartment'), - // dispatch('getCategory'), - ]) - console.log('所有配置数据初始化完成') - } catch (error) { - console.error('配置数据初始化失败:', error) - } - }, - // 更新/存儲用戶最新數據 - updateUserInfo({ commit }, userInfo) { - commit('setUserInfo', userInfo) + // 构建子级二维数组 + const childArray = [] + parentCategories.forEach(parent => { + const children = childCategories + .filter(child => child.pid === parent.id) + .map(child => { + return { + label: child.name || child.title || child.categoryName, + value: child.id + } + }) + childArray.push(children.length > 0 ? children : [{ + label: '全部', + value: 0 + }]) + }) + + // 组装最终结果 + state.categoryList = [parentArray, childArray] + + }, + setConfigList(state, data) { + state.configList = data + }, + setDepartmentList(state, data) { + state.departmentList = data + }, + setUserInfo(state, data) { + state.userInfo = data + // #ifdef H5 + uni.setStorageSync('userInfo', data) + share() + // #endif + }, + setQrcode(state, data) { + state.Qrcode = data + }, + // }, - } + actions: { + // 查询配置列表 + async getConfig({ commit }) { + const res = await api.config.queryConfigList() + // 要求变成键值对的样子 + const config = res.result.reduce((acc, item) => { + if (!item.code) { + console.log('code为空', item); + return acc + } + acc[item.code] = item + return acc + }, {}) + console.log('configList列表为:', config); + + // 事先永久存儲首屏圖片的數據 + if (config.creen_image) { + uni.setStorageSync('screen_image', config.creen_image.content) + } + if (config.login_logo) { + uni.setStorageSync('login_logo', config.login_logo.content) + } + + commit('setConfigList', config) + + // #ifdef H5 + share() + // #endif + }, + // 查询部门列表 + async getDepartment({ commit }) { + const res = await api.config.queryDepartmentList() + commit('setDepartmentList', res.result.records) + }, + // 获取分类列表 + async getCategory({ commit }) { + const res = await api.config.queryCategoryList() + commit('setCategoryList', res.result.records) + }, + // 初始化数据 + async initData({ dispatch, state }) { + // 检查是否已初始化 + if (state.configList.length > 0) { + + console.log('配置数据已初始化,无需重复初始化') + return + } + + try { + await Promise.all([ + dispatch('getConfig'), + // dispatch('getDepartment'), + // dispatch('getCategory'), + ]) + console.log('所有配置数据初始化完成') + } catch (error) { + console.error('配置数据初始化失败:', error) + } + }, + // 更新/存儲用戶最新數據 + updateUserInfo({ commit }, userInfo) { + commit('setUserInfo', userInfo) + }, + } }) export default store \ No newline at end of file diff --git a/subPages/home/AudioControls.vue b/subPages/home/AudioControls.vue index fa8ed28..ec1a9b1 100644 --- a/subPages/home/AudioControls.vue +++ b/subPages/home/AudioControls.vue @@ -19,7 +19,7 @@ 正在加载更多音频... - + @@ -260,7 +260,7 @@ export default { if (currentPageData && !oldCurrentPageData && this.shouldLoadAudio && this.courseId) { console.log(`🎵 bookPages监听: 当前页面数据已加载,自动获取音频,页面=${this.currentPage}`); this.$nextTick(() => { - this.getCurrentPageAudio(); + this.getCurrentPageAudio(true); // 启用自动播放 }); } }, @@ -292,7 +292,7 @@ export default { const cachedAudio = this.audioCache[pageKey]; if (cachedAudio && cachedAudio.audios && cachedAudio.audios.length > 0) { - // 有缓存:直接显示控制栏 + // 有缓存:直接显示控制栏并自动播放 this.currentPageAudios = cachedAudio.audios; this.totalTime = cachedAudio.totalDuration || 0; this.hasAudioData = true; @@ -309,10 +309,21 @@ export default { isLoading: false, currentHighlightIndex: -1 }); + + // 自动播放缓存的音频 + this.$nextTick(() => { + if (this.currentPageAudios.length > 0 && !this.isVoiceChanging) { + const firstAudioData = this.currentPageAudios[0]; + console.log(`🎵 自动播放缓存音频: ${firstAudioData.url}`); + audioManager.playAudio(firstAudioData.url, 'sentence', { playbackRate: this.playSpeed }); + this.isPlaying = true; + this.updateHighlightIndex(); + } + }); } else { // 没有缓存:自动开始加载音频 console.log(`🎵 checkAndLoadPreloadedAudio: 无缓存,开始加载音频,页面=${this.currentPage}`); - this.getCurrentPageAudio(); + this.getCurrentPageAudio(true); // 启用自动播放 } }, diff --git a/subPages/home/articleDetail.vue b/subPages/home/articleDetail.vue new file mode 100644 index 0000000..fba6230 --- /dev/null +++ b/subPages/home/articleDetail.vue @@ -0,0 +1,385 @@ + + + + + \ No newline at end of file diff --git a/subPages/home/book.vue b/subPages/home/book.vue index 7b353d8..d46322c 100644 --- a/subPages/home/book.vue +++ b/subPages/home/book.vue @@ -129,6 +129,14 @@ + + + @@ -137,6 +145,7 @@ import AudioControls from './AudioControls.vue' import CustomTabbar from './components/CustomTabbar.vue' import CoursePopup from './components/CoursePopup.vue' import MeaningPopup from './components/MeaningPopup.vue' +import FloatingButtons from './components/FloatingButtons.vue' import audioManager from '@/utils/audioManager.js' export default { @@ -144,7 +153,8 @@ export default { AudioControls, CustomTabbar, CoursePopup, - MeaningPopup + MeaningPopup, + FloatingButtons }, data() { return { @@ -153,7 +163,7 @@ export default { voiceId: null, courseId: '', showNavbar: true, - currentPage: 1, + currentPage: 1, // 当前页面索引 currentCourse: 1, // 当前课程索引 currentWordMeaning: null, // 当前显示的单词释义 isReversed: false, // 是否倒序显示 @@ -252,6 +262,19 @@ export default { // 当前页面是否需要会员 currentPageRequiresMember() { return this.pagePay[this.currentPage - 1] === 'Y'; + }, + + // 判断是否为当前课程的最后一页 + isLastPage() { + return this.currentPage === this.bookPages.length; + }, + + // 判断是否有下一课 + hasNextCourse() { + if (!this.courseList || this.courseList.length === 0) return false; + // 使用 courseId 而不是 currentCourse,因为 courseId 是当前正在学习的课程ID + const currentCourseIndex = this.courseList.findIndex(course => course.id == this.courseId); + return currentCourseIndex >= 0 && currentCourseIndex < this.courseList.length - 1; } }, // watch: { @@ -918,6 +941,7 @@ export default { }, selectCourse(courseId) { this.currentCourse = courseId + this.courseId = courseId // 同时更新 courseId // 这里可以添加切换课程的逻辑 // console.log('选择课程:', courseId) this.getCourseList(courseId) @@ -1423,6 +1447,72 @@ export default { url: '/subPages/member/recharge' }) }, + + // 跳转到下一课 + async goToNextCourse() { + if (!this.hasNextCourse) { + uni.showToast({ + title: '已经是最后一课了', + icon: 'none', + duration: 2000 + }); + return; + } + + try { + // 找到当前课程在课程列表中的索引 + const currentCourseIndex = this.courseList.findIndex(course => course.id == this.courseId); + if (currentCourseIndex >= 0 && currentCourseIndex < this.courseList.length - 1) { + // 获取下一课的ID + const nextCourse = this.courseList[currentCourseIndex + 1]; + console.log('跳转到下一课:', nextCourse); + + // 切换到下一课 + await this.selectCourse(nextCourse.id); + + uni.showToast({ + title: `已切换到第${currentCourseIndex + 2}课`, + icon: 'success', + duration: 2000 + }); + } + } catch (error) { + console.error('跳转下一课失败:', error); + uni.showToast({ + title: '跳转失败,请重试', + icon: 'none', + duration: 2000 + }); + } + }, + + // 回到开始(当前课程的第一页) + async backToStart() { + try { + // 回到当前课程的第一页 + this.currentPage = 1; + console.log('回到开始,跳转到第一页'); + + // 获取第一页的数据(如果还没有获取过) + if (this.courseIdList[0] && this.bookPages[0].length === 0) { + await this.getBookPages(this.courseIdList[0]); + } + + uni.showToast({ + title: '已回到第一页', + icon: 'success', + duration: 2000 + }); + } catch (error) { + console.error('回到开始失败:', error); + uni.showToast({ + title: '操作失败,请重试', + icon: 'none', + duration: 2000 + }); + } + }, + async goToPage(page) { this.currentPage = page console.log('跳转到页面:', page) @@ -1714,6 +1804,7 @@ export default { }) this.courseId = args.courseId + this.currentCourse = args.courseId // 同时设置 currentCourse this.memberId = args.memberId // 先获取点进来的课程的页面列表 diff --git a/subPages/home/components/CoursePopup.vue b/subPages/home/components/CoursePopup.vue index 97ec3c9..f2bb5ec 100644 --- a/subPages/home/components/CoursePopup.vue +++ b/subPages/home/components/CoursePopup.vue @@ -25,7 +25,7 @@ @click="selectCourse(course.id)" > - {{ String(course.index).padStart(2, '0') }} + {{ String(course.index + 1).padStart(2, '0') }} diff --git a/subPages/home/components/FloatingButtons.vue b/subPages/home/components/FloatingButtons.vue new file mode 100644 index 0000000..c3e87d7 --- /dev/null +++ b/subPages/home/components/FloatingButtons.vue @@ -0,0 +1,147 @@ + + + + + \ No newline at end of file diff --git a/subPages/home/directory.vue b/subPages/home/directory.vue index 22d8c3d..8332d0d 100644 --- a/subPages/home/directory.vue +++ b/subPages/home/directory.vue @@ -1,659 +1,666 @@ \ No newline at end of file diff --git a/subPages/home/search.vue b/subPages/home/search.vue index 3bd3916..33525a0 100644 --- a/subPages/home/search.vue +++ b/subPages/home/search.vue @@ -1,321 +1,140 @@ \ No newline at end of file diff --git a/utils/share.js b/utils/share.js index 869cdcb..96a1aae 100644 --- a/utils/share.js +++ b/utils/share.js @@ -79,14 +79,19 @@ function share() { //微信分享 } function addQueryParams(url) { - if (url) { - //获取用户id - let userInfo = localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo')) : null - if (userInfo) { - url += `?inviter=${userInfo.id}` - } - } - return url + try{ + if (url) { + //获取用户id + let userInfo = uni.getStorageSync('userInfo') + if (userInfo?.id) { + url += `?inviter=${userInfo.id}` + } + } + return url + }catch(e){ + console.log(e); + return url + } } export default share \ No newline at end of file