From dc40bb34a164e6de2f9b40af767ea0f4550a3c9c Mon Sep 17 00:00:00 2001 From: hflllll Date: Tue, 16 Sep 2025 21:29:04 +0800 Subject: [PATCH] =?UTF-8?q?'=E5=BC=80=E5=A7=8B=E8=81=94=E8=B0=83'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 2 +- api/index.js | 11 +++-- api/modules/book.js | 5 +++ api/modules/config.js | 2 +- api/modules/exhibit.js | 95 -------------------------------------------- api/modules/home.js | 9 +++-- api/modules/login.js | 33 ++++++++++++--- api/modules/member.js | 32 +++++++++++++++ api/modules/promotion.js | 5 +++ api/request.js | 52 ++++++++++++++---------- config/index.js | 2 +- manifest.json | 4 +- mixins/config.js | 19 ++++----- pages/index/home.vue | 37 ++++++++--------- pages/index/member.vue | 4 +- pages/index/user.vue | 34 +++++++++++----- stores/index.js | 14 +++---- subPages/home/plan.vue | 27 +++++++++++-- subPages/home/submit.vue | 43 ++++++++++++++++---- subPages/login/login.vue | 6 +-- subPages/login/userInfo.vue | 64 ++++++++++++++--------------- subPages/member/recharge.vue | 90 ++++++++++++++++++++++++++--------------- subPages/user/discount.vue | 3 ++ subPages/user/profile.vue | 33 ++++++++++----- 24 files changed, 356 insertions(+), 270 deletions(-) create mode 100644 api/modules/book.js delete mode 100644 api/modules/exhibit.js create mode 100644 api/modules/member.js create mode 100644 api/modules/promotion.js diff --git a/App.vue b/App.vue index 7b0f2b7..d7b76a3 100644 --- a/App.vue +++ b/App.vue @@ -15,7 +15,7 @@ console.log(uni.getStorageSync('token')); console.log('App Show') - // await this.$store.dispatch('initData') + await this.$store.dispatch('initData') // console.log('配置数据初始化完成') }, onHide: function() { diff --git a/api/index.js b/api/index.js index 9916107..42ce6d6 100644 --- a/api/index.js +++ b/api/index.js @@ -1,13 +1,18 @@ import user from '@/api/modules/user' import config from '@/api/modules/config' -import exhibit from '@/api/modules/exhibit' import login from '@/api/modules/login' import home from '@/api/modules/home' +import member from '@/api/modules/member' +import book from '@/api/modules/book' +import promotion from '@/api/modules/promotion' + export { user, config, - exhibit, login, - home + home, + member, + book, + promotion } diff --git a/api/modules/book.js b/api/modules/book.js new file mode 100644 index 0000000..9dd301e --- /dev/null +++ b/api/modules/book.js @@ -0,0 +1,5 @@ +import request from "@/api/request"; + +export default { + +} \ No newline at end of file diff --git a/api/modules/config.js b/api/modules/config.js index 0ad0aa7..a9ea2c9 100644 --- a/api/modules/config.js +++ b/api/modules/config.js @@ -4,7 +4,7 @@ import http from "@/api/http"; export default { async queryConfigList() { return http({ - url: '/config/queryConfigList', + url: '/config/list', method: 'GET' }) }, diff --git a/api/modules/exhibit.js b/api/modules/exhibit.js deleted file mode 100644 index 6797280..0000000 --- a/api/modules/exhibit.js +++ /dev/null @@ -1,95 +0,0 @@ -import http from "@/api/http"; - -export default { - - // 查看展品信息列表 - async queryShowpieceList(data) { - return http({ - url: '/showpiece/queryShowpieceList', - method: 'GET', - data - }) - }, - - // 查看维修记录列表 - async queryRepairList(data) { - return http({ - url: '/showpiece/queryRepairList', - method: 'GET', - data - }) - }, - - // 查看保养记录 - async queryMaintenanceList(data) { - return http({ - url: '/showpiece/queryMaintenanceList', - method: 'GET', - data - }) - }, - - // 保养-新增保养记录 - async addMaintenance(data) { - return http({ - url: '/showpiece/addMaintenance', - method: 'POST', - data, - showLoading: true, - needToken: true - }) - }, - - // 报修- 查看报修单列表 - async queryMalfunctionList(data) { - return http({ - url: '/showpiece/queryMalfunctionList', - method: 'GET', - data - }) - }, - - // 报修- 新增报修单 - async addMalfunction(data) { - return http({ - url: '/showpiece/addMalfunction', - method: 'POST', - data, - showLoading: true, - needToken: true - }) - }, - - // 查看保修单详情 - async queryMalfunctionById(data) { - return http({ - url: '/showpiece/queryMalfunctionById', - method: 'GET', - data - }) - }, - - // 修改保修单 - async updateMalfunction(data) { - return http({ - url: '/showpiece/updateMalfunction', - method: 'POST', - data, - showLoading: true, - needToken: true - }) - }, - - // 新增维修记录 - async addRepair(data) { - return http({ - url: '/showpiece/addRepair', - method: 'POST', - data, - showLoading: true, - needToken: true - }) - }, - - -} diff --git a/api/modules/home.js b/api/modules/home.js index bc1cc2b..0ceec34 100644 --- a/api/modules/home.js +++ b/api/modules/home.js @@ -2,11 +2,13 @@ import http from "@/api/http"; export default{ - async getSignup() { + async getSignup(data) { // 首页底部内容添加报名 return http({ url: '/index/linkSignup', - method: 'GET', + method: 'POST', + data, + needToken: true }) }, @@ -19,10 +21,11 @@ export default{ }, // 首页底部内容链接详情 - async getLinkDetails() { + async getLinkDetails(data) { return http({ url: '/index/linkDetails', method: 'GET', + data }) }, diff --git a/api/modules/login.js b/api/modules/login.js index f2f63bb..dd8f53d 100644 --- a/api/modules/login.js +++ b/api/modules/login.js @@ -1,24 +1,45 @@ // import request from "@/api/request"; import http from "@/api/http"; export default { - // 程序-绑定手机号码 + // 绑定手机号码 async bindPhone(data) { return http({ - url: '/login/bindPhone', - method: 'GET', - data + url: '/login/getPhoneNumber', + method: 'POST', + data, + needToken: true }) }, + // 登录 async login(data) { return http({ - url: '/login/login', - method: 'GET', + url: '/login/wxLogin', + method: 'POST', data, // header: { // 'Content-Type': 'application/x-www-form-urlencoded' // }, showLoading: true }) + }, + + // 获取用户信息 + async getUserInfo() { + return http({ + url: '/login/getUserInfo', + method: 'GET', + needToken: true + }) + }, + + // 更新用户信息 + async updateUserInfo(data) { + return http({ + url: '/login/updateUserInfo', + method: 'POST', + data, + needToken: true + }) } } \ No newline at end of file diff --git a/api/modules/member.js b/api/modules/member.js new file mode 100644 index 0000000..c78e1af --- /dev/null +++ b/api/modules/member.js @@ -0,0 +1,32 @@ +import request from "@/api/request"; + +export default { + // 开通会员 + async openMember(data) { + return request({ + url: '/member/open', + method: 'POST', + data, + needToken: true, + showLoading: true + }) + }, + + // 取会员列表 + async getMemberList() { + return request({ + url: '/member/list', + method: 'GET' + }) + }, + + // 获取优惠卷 + async getCouponList(data) { + return request({ + url: '/member/coupon', + method: 'GET', + needToken: true, + data + }) + } +} \ No newline at end of file diff --git a/api/modules/promotion.js b/api/modules/promotion.js new file mode 100644 index 0000000..84c5c3e --- /dev/null +++ b/api/modules/promotion.js @@ -0,0 +1,5 @@ +import request from "@/api/request"; + +export default { + +} \ No newline at end of file diff --git a/api/request.js b/api/request.js index 9255aa3..314ae79 100644 --- a/api/request.js +++ b/api/request.js @@ -1,21 +1,24 @@ import config from "@/config"; -export default function request ( { - url = '', - method = 'GET', - data = {}, - showLoading = false, - header = {} , +export default function request({ + url = '', + method = 'GET', + data = {}, + showLoading = false, + header = {}, needToken = false, // 需要token showToast = true // 默认显示失败的提示 -} ) { - if (showLoading) uni.showLoading({title: '加载中'}) - if(needToken) { +}) { + if (showLoading) uni.showLoading({ title: '加载中' }) + if (needToken) { const token = uni.getStorageSync('token') if (token) { header['X-Access-Token'] = token - }else { + } else { + if (showLoading) { + uni.hideLoading() + } uni.showToast({ title: '请先登录', icon: 'none' @@ -39,18 +42,25 @@ export default function request ( { // 优先处理业务逻辑响应 if (res.statusCode === 200 && res.data) { // 业务成功 - if (res.data.code === 200 ) { + if (res.data.code === 200) { + if (showLoading) { + uni.hideLoading() + } resolve(res.data) return } - + // 业务失败但有具体错误信息 const errorMsg = res.data.message || '请求失败' - + if (showToast) { + if (showLoading) { + uni.hideLoading() + } uni.showToast({ title: errorMsg, - icon: 'none' + icon: 'none', + duration: 3000 }) } reject({ @@ -77,11 +87,14 @@ export default function request ( { case 404: error.message = '资源不存在' break; - case 500: + case 500: error.message = '服务器错误' break; } if (showToast) { + if (showLoading) { + uni.hideLoading() + } uni.showToast({ title: error.message, icon: 'none' @@ -93,6 +106,9 @@ export default function request ( { console.log(`Fail ${method} ${url}`, err); const errorMsg = err.errMsg || '请求失败' if (showToast) { + if (showLoading) { + uni.hideLoading() + } uni.showToast({ title: errorMsg, icon: 'none' @@ -105,11 +121,7 @@ export default function request ( { data: err }) }, - complete: () => { - if (showLoading) { - uni.hideLoading() - } - } + }) }) } \ No newline at end of file diff --git a/config/index.js b/config/index.js index 8702446..c8ac0d1 100644 --- a/config/index.js +++ b/config/index.js @@ -19,7 +19,7 @@ const config = { // 网络全局配置 netConfig: { development: { - baseURL: 'http://augcl.natapp1.cc/exhibit-admin/exhibit', + baseURL: 'http://h5.xzaiyp.top/englishread-admin/doc.html', }, testing: { baseURL: 'https://www.multipleculture.com/englishread-admin/appletApi', diff --git a/manifest.json b/manifest.json index 09dbf4c..09c4a72 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { - "name" : "展品维保", + "name" : "四零语境", "appid" : "__UNI__B264FE1", - "description" : "展品维保", + "description" : "四零语境", "versionName" : "1.0.0", "versionCode" : "100", "transformPx" : false, diff --git a/mixins/config.js b/mixins/config.js index 225a913..6446be6 100644 --- a/mixins/config.js +++ b/mixins/config.js @@ -21,23 +21,20 @@ export default { }, computed: { // 获取全局配置的文本 - configParamText() { - return key => this.$store.state.configList[key]?.paramText || '默认文本' + configParamInfo() { + return key => this.$store.state.configList[key]?.info || '默认资料' }, // 获取全局配置的图片 - configParamImage() { - return key => this.$store.state.configList[key]?.paramImage || '/static/默认图片.png' - }, - // 获取全局配置的富文本 - configParamTextarea() { - return key => this.$store.state.configList[key]?.paramTextarea || '默认富文本' + configParamContent() { + return key => this.$store.state.configList[key]?.content || '默认内容' }, + // 默认的全局分享参数 GShare() { return { - title: this.configParamText('app_name'), - desc: this.configParamText('share_desc'), - imageUrl: this.configParamImage('app_logo'), + title: this.configParamContent('app_name'), + desc: this.configParamContent('share_desc'), + imageUrl: this.configParamContent('app_logo'), path: '/pages/index/index' } } diff --git a/pages/index/home.vue b/pages/index/home.vue index 7d72119..0c45bde 100644 --- a/pages/index/home.vue +++ b/pages/index/home.vue @@ -152,12 +152,12 @@ - + @@ -174,8 +174,10 @@ export default { // 轮播图数据 bannerList: [ - + ], + + // 今日更新数据 todayUpdates: [ @@ -269,18 +271,7 @@ export default { // 推荐列表数据 recommendList: [ - { - image: '/static/默认图片.png' - }, - { - image: '/static/默认图片.png' - }, - { - image: '/static/默认图片.png' - }, - { - image: '/static/默认图片.png' - } + ] } }, @@ -297,9 +288,9 @@ export default { // 这里可以添加跳转逻辑 }, // 跳转计划定制 - goPlan() { + goPlan(id, type) { uni.navigateTo({ - url: '/subPages/home/plan' + url: '/subPages/home/plan?id=' + id + '&type=' + type }) }, goSearch() { @@ -321,10 +312,20 @@ export default { })) } }, + async getSignup() { + const signupRes = await this.$api.home.getLink() + if (signupRes.code === 200){ + this.recommendList = signupRes.result.map(item => ({ + img: item.img, + id: item.id, + type: item.type + })) + } + } }, async onShow() { - await this.getBanner() + Promise.all([this.getBanner(), this.getSignup()]) } } diff --git a/pages/index/member.vue b/pages/index/member.vue index 8597e82..c21d67b 100644 --- a/pages/index/member.vue +++ b/pages/index/member.vue @@ -238,8 +238,10 @@ export default{ uni.navigateTo({ url: '/subPages/member/recharge' }) - } + }, + }, + } diff --git a/pages/index/user.vue b/pages/index/user.vue index c9ccebd..d3177db 100644 --- a/pages/index/user.vue +++ b/pages/index/user.vue @@ -6,11 +6,11 @@ 我的 - + - + - {{ isLogin ? userInfo.nickName : displayInfo.name }} + {{ isLogin ? userInfo.name : displayInfo.name }} 手机号:{{ isLogin ? userInfo.phone || displayInfo.phone : displayInfo.phone }} {{ displayInfo.description }} @@ -142,15 +142,15 @@ export default { data() { return { userInfo: { - headImage: '/static/默认头像.png', - nickName: '请先登录', + avatar: '/static/默认头像.png', + name: '请先登录', id: 'XXXXX' }, isLogin: uni.getStorageSync('token'), // 用户展示信息 displayInfo: { - name: '战斗世界', - phone: '19989674531', + name: '点击登录', + phone: 'xxxxxxxxx', avatar: '/static/默认头像.png', description: '世界这么美,我想去看看~' } @@ -197,7 +197,7 @@ export default { // 获取用户信息 async getUserInfo() { - const res = await this.$api.user.queryUser(); + const res = await this.$api.login.getUserInfo(); if (res.code === 200) { this.userInfo = res.result; } @@ -246,6 +246,20 @@ export default { }) }, + // 跳转到登陆页面 + clickInfo() { + if (!this.isLogin){ + + uni.navigateTo({ + url: '/subPages/login/login' + }) + }else { + uni.navigateTo({ + url: '/subPages/user/profile' + }) + } + }, + // 退出登录 logout() { uni.showModal({ @@ -259,8 +273,8 @@ export default { // 重置用户信息 this.userInfo = { - headImage: '/static/默认头像.png', - nickName: '请先登录', + avatar: '/static/默认头像.png', + name: '请先登录', id: 'XXXXX' } diff --git a/stores/index.js b/stores/index.js index 52a0e12..1177b22 100644 --- a/stores/index.js +++ b/stores/index.js @@ -63,12 +63,12 @@ const store = new Vuex.Store({ async getConfig({ commit }) { const res = await api.config.queryConfigList() // 要求变成键值对的样子 - const config = res.result.records.reduce((acc, item) => { - if (!item.paramCode) { - console.log('paramCode为空', item); + const config = res.result.reduce((acc, item) => { + if (!item.code) { + console.log('code为空', item); return acc } - acc[item.paramCode] = item + acc[item.code] = item return acc }, {}) commit('setConfigList', config) @@ -86,7 +86,7 @@ const store = new Vuex.Store({ // 初始化数据 async initData({ dispatch, state }) { // 检查是否已初始化 - if (state.configList.length > 0 && state.departmentList.length > 0 && state.categoryList.length > 0) { + if (state.configList.length > 0) { console.log('配置数据已初始化,无需重复初始化') return @@ -95,8 +95,8 @@ const store = new Vuex.Store({ try { await Promise.all([ dispatch('getConfig'), - dispatch('getDepartment'), - dispatch('getCategory'), + // dispatch('getDepartment'), + // dispatch('getCategory'), ]) console.log('所有配置数据初始化完成') } catch (error) { diff --git a/subPages/home/plan.vue b/subPages/home/plan.vue index 339b25d..20eff13 100644 --- a/subPages/home/plan.vue +++ b/subPages/home/plan.vue @@ -15,7 +15,7 @@ - + diff --git a/subPages/home/submit.vue b/subPages/home/submit.vue index f74ec1e..845f71a 100644 --- a/subPages/home/submit.vue +++ b/subPages/home/submit.vue @@ -44,7 +44,7 @@ 个人期待 { + uni.navigateBack({ + delta: 2 + }) + }, 1000) + } else { + uni.showToast({ + title: subRes.msg, + icon: 'none' + }) + } + } catch (error) { + uni.showToast({ + title: error.msg, + icon: 'none' + }) + } + + // uni.showToast({ + // title: '提交成功', + // icon: 'success' + // }) } } } diff --git a/subPages/login/login.vue b/subPages/login/login.vue index ca2f551..d4b18cf 100644 --- a/subPages/login/login.vue +++ b/subPages/login/login.vue @@ -71,8 +71,8 @@ export default { // 授权登录 handleLogin() { - uni.redirectTo({ url: '/subPages/login/userInfo' }) - return + // uni.redirectTo({ url: '/subPages/login/userInfo' }) + // return if (!this.isAgreed) { this.$refs.serviceModal.open(); @@ -89,7 +89,7 @@ export default { uni.setStorageSync('token', loginRes.token) const userInfo = loginRes.userInfo - if ( !userInfo.department || !userInfo.headImage || !userInfo.nickName || !userInfo.phone ){ + if ( !userInfo.avatar || !userInfo.name || !userInfo.phone ){ uni.navigateTo({ url: '/subPages/login/userInfo' }) diff --git a/subPages/login/userInfo.vue b/subPages/login/userInfo.vue index 704d298..33d3c6f 100644 --- a/subPages/login/userInfo.vue +++ b/subPages/login/userInfo.vue @@ -19,7 +19,7 @@ @@ -30,15 +30,15 @@ 昵称 - + - + @@ -17,6 +17,9 @@ - - 赠送{{ item.gift }}天 + + {{ item.content }} {{ item.title }} - ¥{{ getInt(item.price) }}.{{ getDecimal(item.price) }} - ¥{{ item.originalPrice }} + ¥{{ getInt(item.discountedprice) }}.{{ getDecimal(item.discountedprice) }} + ¥{{ item.originalprice }} - + {{ selectedPackage === index ? '已选择' : '点击选择' }} @@ -126,36 +129,47 @@ data() { return { list: [ - '/static/会员1.png', - '/static/会员2.png', - '/static/会员3.png' + ], selectedPackage: 0, // 默认选择第一个套餐 - packageList: [ + selectedMember: 0, // 默认选择第一个会员 + defaultPackageList: [ { - title: '30天会员', - price: '36.00', - originalPrice: '128', - gift: null + title: '当前会员没有返回套餐', + discountedprice: '36.00', + originalprice: '128', + gift: null, + content: '赠送66天' }, { - title: '90天会员', - price: '88.00', - originalPrice: '384', - gift: '180' + title: '当前会员没有返回套餐', + discountedprice: '88.00', + originalprice: '384', + gift: '180', + content: '赠送666天' }, { - title: '180天会员', - price: '128.00', - originalPrice: '384', - gift: null + title: '当前会员没有返回套餐', + discountedprice: '128.00', + originalprice: '384', + gift: null, + content: '赠送9999天' } ] } }, + computed:{ + packageList(){ + return this.list[this.selectedMember].setmeals.length ? this.list[this.selectedMember].setmeals : this.defaultPackageList + } + }, methods: { + goBack(){ + uni.navigateBack() + }, // 截取价格的整数与小数部分 - getInt(price){ + getInt(pri){ + const price = String(pri) if (price.indexOf('.') === -1) { return price } @@ -164,10 +178,11 @@ } return String(price).split('.')[0] }, - getDecimal(price){ + getDecimal(pri){ + const price = String(pri) if (price === null) return '00' - const parts = String(price).split('.') - return parts[1] ? parts[1].padEnd(2, '0') : '00' + const parts = price.split('.') + return parts[1] ? parts[1].padEnd(2, '0') : '00' }, selectPackage(index) { this.selectedPackage = index @@ -177,8 +192,21 @@ title: '功能开发中', icon: 'none' }) - } - } + }, + async getMemberList(){ + const memberRes = await this.$api.member.getMemberList() + if (memberRes.code === 200){ + this.list = memberRes.result + } + }, + changeSwiper(e){ + this.selectedMember = e.current + this.selectedPackage = 0 + } + }, + onShow(){ + this.getMemberList() + } } @@ -271,13 +299,13 @@ .gift-tag { position: absolute; top: -10rpx; - left: 50%; - transform: translateX(-50%); + left: 0%; + // transform: translateX(-50%); background: #FF6B6B; color: #fff; font-size: 20rpx; padding: 8rpx 16rpx; - border-radius: 20rpx; + border-radius: 20rpx 20rpx 20rpx 0; white-space: nowrap; } diff --git a/subPages/user/discount.vue b/subPages/user/discount.vue index baecfd5..ede5885 100644 --- a/subPages/user/discount.vue +++ b/subPages/user/discount.vue @@ -80,9 +80,12 @@