diff --git a/api/auth.js b/api/auth.js index 86fcdef..d7fb49b 100644 --- a/api/auth.js +++ b/api/auth.js @@ -24,14 +24,15 @@ export function login(data) { /** * 小程序一键授权手机号登录 * @param {Object} data 登录数据 - * @param {String} data.code 微信授权code - * @param {String} data.encryptedData 加密数据 - * @param {String} data.iv 初始向量 + * @param {String} data.phoneCode 手机 code, 小程序通过 wx.getPhoneNumber 方法获得 + * @param {String} data.loginCode 登录 code, 小程序通过 wx.login 方法获得 + * @param {String} data.state state 参数,必填,用于回调的随机值 + * @param {String} data.inviteCode 邀请码,可选(第一位是类型第二位是用户id,例如:1-1, 0-1) * @returns {Promise} 返回登录结果(包含token等) */ export function loginByPhone(data) { return request({ - url: '/app-api/member/auth/login', + url: '/app-api/member/auth/weixin-mini-app-login', method: 'POST', data: data, showLoading: true, diff --git a/api/service.js b/api/service.js index 66d8a22..faaefd3 100644 --- a/api/service.js +++ b/api/service.js @@ -37,4 +37,13 @@ export function getGuildCoupon(params = {}) { method: 'GET', data: params, }) +} + +// 获得图文消息分页 +export function getMessagePage(params = {}) { + return request({ + url: '/app-api/member/labor-union-message/page', + method: 'GET', + data: params, + }) } \ No newline at end of file diff --git a/manifest.json b/manifest.json index 3a78ffa..8ca22dc 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name" : "demo", - "appid" : "__UNI__B358CDA", + "appid" : "wxa3c0e1381f643f59", "description" : "", "versionName" : "1.0.0", "versionCode" : "100", @@ -50,7 +50,7 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "", + "appid" : "wxa3c0e1381f643f59", "setting" : { "urlCheck" : false }, diff --git a/pages.json b/pages.json index 7d91f20..84d6a36 100644 --- a/pages.json +++ b/pages.json @@ -1,141 +1,160 @@ -{ - "pages": [ - { - "path": "pages/login/login", - "style": { - "navigationBarTitleText": "登录", - "navigationStyle": "custom" - } - }, - { - "path": "pages/index/index", - "style": { - "navigationBarTitleText": "首页", - "navigationStyle": "custom" - } - }, - { - "path": "pages/service/service", - "style": { - "navigationBarTitleText": "服务", - "navigationStyle": "custom" - } - }, - { - "path": "pages/profile/profile", - "style": { - "navigationBarTitleText": "个人中心", - "navigationStyle": "custom" - } - }, - { - "path": "pages/profile/realNameAuth", - "style": { - "navigationBarTitleText": "实名认证", - "navigationStyle": "custom" - } - }, - { - "path": "pages/profile/serviceRecords", - "style": { - "navigationBarTitleText": "服务记录", - "navigationStyle": "custom" - } - } - ], - "subPackages": [ - { - "root": "pages/detail", - "pages": [ - { - "path": "serviceDetail", - "style": { - "navigationBarTitleText": "店铺详情", - "navigationStyle": "custom" - } - }, - { - "path": "activitiesDetail", - "style": { - "navigationBarTitleText": "工会详情", - "navigationStyle": "custom" - } - }, - { - "path": "mapDetail", - "style": { - "navigationBarTitleText": "地图", - "navigationStyle": "custom" - } - } - ] - }, - { - "root": "pages/activities", - "pages": [ - { - "path": "list", - "style": { - "navigationBarTitleText": "工会活动", - "navigationStyle": "custom" - } - }, - { - "path": "myCollect", - "style": { - "navigationBarTitleText": "我的收藏", - "navigationStyle": "custom" - } - }, - { - "path": "complaints", - "style": { - "navigationBarTitleText": "投诉建议", - "navigationStyle": "custom" - } - }, - { - "path": "postMessage", - "style": { - "navigationBarTitleText": "发布消息", - "navigationStyle": "custom" - } - } - ] - } - ], - "globalStyle": { - "navigationBarTextStyle": "black", - "navigationBarTitleText": "uni-app", - "navigationBarBackgroundColor": "#F8F8F8", - "backgroundColor": "#F8F8F8" - }, - "tabBar": { - "color": "#7A7E83", - "selectedColor": "#004294", - "borderStyle": "black", - "backgroundColor": "#ffffff", - "iconWidth": "41rpx", - "list": [ - { - "pagePath": "pages/index/index", - "iconPath": "static/tabbar/home.png", - "selectedIconPath": "static/tabbar/home-active.png", - "text": "首页" - }, - { - "pagePath": "pages/service/service", - "iconPath": "static/tabbar/service.png", - "selectedIconPath": "static/tabbar/service-active.png", - "text": "服务" - }, - { - "pagePath": "pages/profile/profile", - "iconPath": "static/tabbar/profile.png", - "selectedIconPath": "static/tabbar/profile-active.png", - "text": "我的" - } - ] - }, - "uniIdRouter": {} -} +{ + "pages": [ + { + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "首页", + "navigationStyle": "custom" + } + }, + { + "path": "pages/login/login", + "style": { + "navigationBarTitleText": "登录", + "navigationStyle": "custom" + } + }, + { + "path": "pages/service/service", + "style": { + "navigationBarTitleText": "服务", + "navigationStyle": "custom" + } + }, + { + "path": "pages/profile/profile", + "style": { + "navigationBarTitleText": "个人中心", + "navigationStyle": "custom" + } + }, + { + "path": "pages/webview/webview", + "style": { + "navigationBarTitleText": "网页", + "navigationStyle": "custom" + } + } + ], + "subPackages": [ + { + "root": "pages/detail", + "pages": [ + { + "path": "serviceDetail", + "style": { + "navigationBarTitleText": "店铺详情", + "navigationStyle": "custom" + } + }, + { + "path": "activitiesDetail", + "style": { + "navigationBarTitleText": "工会详情", + "navigationStyle": "custom" + } + }, + { + "path": "mapDetail", + "style": { + "navigationBarTitleText": "地图", + "navigationStyle": "custom" + } + }, + { + "path": "richTextDetail", + "style": { + "navigationBarTitleText": "详情", + "navigationStyle": "custom" + } + } + ] + }, + { + "root": "pages/activities", + "pages": [ + { + "path": "list", + "style": { + "navigationBarTitleText": "工会活动", + "navigationStyle": "custom" + } + }, + { + "path": "myCollect", + "style": { + "navigationBarTitleText": "我的收藏", + "navigationStyle": "custom" + } + }, + { + "path": "complaints", + "style": { + "navigationBarTitleText": "投诉建议", + "navigationStyle": "custom" + } + }, + { + "path": "postMessage", + "style": { + "navigationBarTitleText": "发布消息", + "navigationStyle": "custom" + } + } + ] + }, + { + "root": "pages/profileSub", + "pages": [ + { + "path": "realNameAuth", + "style": { + "navigationBarTitleText": "实名认证", + "navigationStyle": "custom" + } + }, + { + "path": "serviceRecords", + "style": { + "navigationBarTitleText": "服务记录", + "navigationStyle": "custom" + } + } + ] + } + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "uni-app", + "navigationBarBackgroundColor": "#F8F8F8", + "backgroundColor": "#F8F8F8" + }, + "tabBar": { + "color": "#7A7E83", + "selectedColor": "#004294", + "borderStyle": "black", + "backgroundColor": "#ffffff", + "iconWidth": "41rpx", + "list": [ + { + "pagePath": "pages/index/index", + "iconPath": "static/tabbar/home.png", + "selectedIconPath": "static/tabbar/home-active.png", + "text": "首页" + }, + { + "pagePath": "pages/service/service", + "iconPath": "static/tabbar/service.png", + "selectedIconPath": "static/tabbar/service-active.png", + "text": "服务" + }, + { + "pagePath": "pages/profile/profile", + "iconPath": "static/tabbar/profile.png", + "selectedIconPath": "static/tabbar/profile-active.png", + "text": "我的" + } + ] + }, + "uniIdRouter": {} +} diff --git a/pages/activities/list.vue b/pages/activities/list.vue index 5530e70..182172d 100644 --- a/pages/activities/list.vue +++ b/pages/activities/list.vue @@ -107,7 +107,7 @@ export default { const res = await getHomeData({ page: this.page, pageSize: this.pageSize, - noticeType: 2, // 活动类型 + noticeType: 21, // 活动类型 }); if (res) { @@ -159,10 +159,10 @@ export default { // 活动项点击 handleActivityClick(item) { - // 后续可以跳转到活动详情页 - // uni.navigateTo({ - // url: `/pages/activities/detail?id=${item.id}` - // }) + // 点击活动项跳转到详情页 + uni.navigateTo({ + url: `/pages/detail/activitiesDetail?id=${item.id}` + }); }, // 参与活动 diff --git a/pages/detail/activitiesDetail.vue b/pages/detail/activitiesDetail.vue index cf11e0f..a34e41f 100644 --- a/pages/detail/activitiesDetail.vue +++ b/pages/detail/activitiesDetail.vue @@ -10,9 +10,21 @@ 加载中... - - - + + + + + + + + + + @@ -40,6 +52,7 @@ export default { return { activityId: null, activityDetail: null, + parsedContent: [], // 解析后的内容数组 loading: false, }; }, @@ -69,6 +82,10 @@ export default { const res = await getGuildDetail(this.activityId); if (res) { this.activityDetail = res; + // 解析 HTML,分离图片和文本 + if (res.content) { + this.parsedContent = this.parseHtmlContent(res.content); + } } } catch (error) { console.error("加载活动详情失败:", error); @@ -80,6 +97,64 @@ export default { this.loading = false; } }, + // 解析 HTML 内容,将图片和文本分离 + parseHtmlContent(html) { + if (!html) return []; + + const result = []; + let currentIndex = 0; + + // 匹配所有 img 标签 + const imgRegex = /]*)>/gi; + let match; + let lastIndex = 0; + + while ((match = imgRegex.exec(html)) !== null) { + // 添加图片之前的文本内容 + if (match.index > lastIndex) { + const textContent = html.substring(lastIndex, match.index); + if (textContent.trim()) { + result.push({ + type: 'text', + html: textContent + }); + } + } + + // 提取图片 src + const imgAttrs = match[1]; + const srcMatch = imgAttrs.match(/src=["']([^"']+)["']/i); + if (srcMatch && srcMatch[1]) { + result.push({ + type: 'image', + src: srcMatch[1] + }); + } + + lastIndex = match.index + match[0].length; + } + + // 添加最后剩余的文本内容 + if (lastIndex < html.length) { + const textContent = html.substring(lastIndex); + if (textContent.trim()) { + result.push({ + type: 'text', + html: textContent + }); + } + } + + // 如果没有匹配到图片,直接返回整个内容作为文本 + if (result.length === 0 && html.trim()) { + result.push({ + type: 'text', + html: html + }); + } + + return result; + } }, }; @@ -106,60 +181,40 @@ export default { border-radius: 20rpx; min-height: 200rpx; box-sizing: border-box; - overflow: hidden; + overflow-x: hidden; + overflow-y: visible; + word-wrap: break-word; + word-break: break-all; - // 富文本内容样式 - :deep(rich-text) { + // 图片容器样式 + .rich-text-image-wrapper { + width: 100%; + margin: 20rpx 0; + display: flex; + justify-content: center; + align-items: center; + box-sizing: border-box; + + .rich-text-image { + width: 100%; + height: auto; + display: block; + max-width: 100%; + } + } + + // 文本内容样式 + .rich-text-content { + width: 100%; + display: block; font-family: PingFang-SC, PingFang-SC; font-size: 28rpx; line-height: 1.8; color: #333333; word-wrap: break-word; word-break: break-all; - display: block; - width: 100%; box-sizing: border-box; } - - // 富文本内容中的元素样式 - :deep(img) { - max-width: 100% !important; - width: auto !important; - height: auto !important; - display: block; - margin: 20rpx auto; - box-sizing: border-box; - } - - :deep(p) { - margin: 20rpx 0; - line-height: 1.8; - } - - :deep(h1), - :deep(h2), - :deep(h3), - :deep(h4), - :deep(h5), - :deep(h6) { - margin: 30rpx 0 20rpx 0; - font-weight: bold; - } - - :deep(ul), - :deep(ol) { - margin: 20rpx 0; - padding-left: 40rpx; - } - - :deep(li) { - margin: 10rpx 0; - } - - :deep(a) { - color: #004294; - text-decoration: underline; - } } /* 加载状态 */ diff --git a/pages/detail/richTextDetail.vue b/pages/detail/richTextDetail.vue new file mode 100644 index 0000000..2cddb89 --- /dev/null +++ b/pages/detail/richTextDetail.vue @@ -0,0 +1,239 @@ + + + + + + diff --git a/pages/detail/serviceDetail.vue b/pages/detail/serviceDetail.vue index dc0af5d..7173f9e 100644 --- a/pages/detail/serviceDetail.vue +++ b/pages/detail/serviceDetail.vue @@ -65,10 +65,10 @@ 现价¥ - {{ item.salePrice || 0 }} + {{ formatPrice(item.salePrice) }} 原价¥{{ item.originalPrice }}原价¥{{ formatPrice(item.originalPrice) }} { if (item.selected && item.quantity > 0) { - const price = item.salePrice || item.currentPrice || item.price || 0; + // 价格是以分为单位,需要转换为元 + const price = (item.salePrice || item.currentPrice || item.price || 0) / 100; return total + price * item.quantity; } return total; @@ -253,6 +254,17 @@ export default { } }, + // 格式化价格:将分转换为元(除以100,保留两位小数) + formatPrice(price) { + if (!price && price !== 0) { + return '0.00'; + } + // 将分转换为元 + const yuan = price / 100; + // 保留两位小数 + return yuan.toFixed(2); + }, + // 去结算 handleCheckout() { if (this.totalAmount <= 0) { @@ -272,14 +284,9 @@ export default { return; } - // TODO: 跳转到结算页面或提交订单 - console.log("结算商品:", selectedItems); - console.log("总金额:", this.totalAmount); - uni.showToast({ - title: `结算金额:¥${this.totalAmount.toFixed(2)}`, + title: "该功能正在开发中", icon: "none", - duration: 2000, }); }, }, @@ -487,7 +494,7 @@ export default { .price-text { font-family: PingFang-SC, PingFang-SC; font-weight: bold; - font-size: 50rpx; + font-size: 48rpx; color: #d51c3c; } } diff --git a/pages/index/index.vue b/pages/index/index.vue index d2b2113..40acc78 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -157,12 +157,55 @@ export default { this.getSystemInfo(); this.loadHomeData(); this.loadActivities(); + + // 启用分享功能 + // #ifdef MP-WEIXIN + uni.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage', 'shareTimeline'] + }); + // #endif + }, + onShow() { + // 每次显示页面时刷新数据 + this.loadHomeData(); + this.loadActivities(); }, onPullDownRefresh() { this.loadHomeData().finally(() => { uni.stopPullDownRefresh(); }); }, + + // 分享给朋友 + onShareAppMessage() { + // 使用第一个banner作为分享图片,如果没有则使用默认logo + const shareImage = this.bannerList && this.bannerList.length > 0 + ? this.bannerList[0].coverUrl + : '/static/home/logo.png'; + + return { + title: '广厦千万间司机公会 - 加入工会,权益保障,福利升级', + path: '/pages/index/index', + imageUrl: shareImage + }; + }, + + // 分享到朋友圈(微信小程序) + // #ifdef MP-WEIXIN + onShareTimeline() { + // 使用第一个banner作为分享图片,如果没有则使用默认logo + const shareImage = this.bannerList && this.bannerList.length > 0 + ? this.bannerList[0].coverUrl + : '/static/home/logo.png'; + + return { + title: '广厦千万间司机公会 - 加入工会,权益保障,福利升级', + query: '', + imageUrl: shareImage + }; + }, + // #endif methods: { // 获取系统信息 getSystemInfo() { @@ -179,7 +222,7 @@ export default { async loadHomeData() { try { // 获取首页banner - const res = await getHomeData({ noticeType: 1 }); + const res = await getHomeData({ noticeType: 22 }); if (res) { this.bannerList = res.list || []; } @@ -209,7 +252,7 @@ export default { async loadActivities() { try { // 后续补充接口调用 - const res = await getHomeData({ page: 1, pageSize: 3, noticeType: 2 }); + const res = await getHomeData({ page: 1, pageSize: 3, noticeType: 21 }); if (res) { this.activitiesList = res.list || []; } @@ -221,24 +264,10 @@ export default { // 格式化时间戳 formatTime, - // 菜单点击 - handleMenuClick() { - uni.showToast({ - title: "菜单功能", - icon: "none", - }); - }, - - // 聚焦/关注点击 - handleFocusClick() { - uni.showToast({ - title: "关注功能", - icon: "none", - }); - }, // banner点击跳转 handleBannerClick(item) { + console.log(item, 222); if (item.jumpUrl) { // 判断跳转类型 if ( @@ -265,31 +294,21 @@ export default { url: item.jumpUrl, }); } + } else if (item.content) { + // 如果 jumpUrl 为空但有 content,展示富文本内容 + const title = item.title || '详情'; + uni.navigateTo({ + url: `/pages/detail/richTextDetail?title=${encodeURIComponent(title)}&content=${encodeURIComponent(item.content)}` + }); } }, // 加入工会 async handleJoinGuild() { - try { - // 后续补充接口调用 - // const res = await joinGuild() - // if (res.statusCode === 200) { - // uni.showToast({ - // title: '加入成功', - // icon: 'success' - // }) - // } - uni.showToast({ - title: "加入工会", - icon: "none", - }); - } catch (error) { - console.error("加入工会失败:", error); - uni.showToast({ - title: "操作失败,请重试", - icon: "none", - }); - } + uni.showToast({ + title: "该功能正在开发中", + icon: "none", + }); }, // 查看全部福利 @@ -340,10 +359,10 @@ export default { // 活动项点击 handleActivityClick(item) { - // 后续可以跳转到活动详情页 - // uni.navigateTo({ - // url: `/pages/activities/detail?id=${item.id}` - // }) + // 点击活动项跳转到详情页 + uni.navigateTo({ + url: `/pages/detail/activitiesDetail?id=${item.id}` + }); }, // 参与活动 diff --git a/pages/login/login.vue b/pages/login/login.vue index 67f1eca..3981003 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -1,27 +1,20 @@ + + + + + diff --git a/static/home/banner.png b/static/home/banner.png deleted file mode 100644 index f0b5190..0000000 Binary files a/static/home/banner.png and /dev/null differ diff --git a/static/logo.png b/static/logo.png deleted file mode 100644 index b5771e2..0000000 Binary files a/static/logo.png and /dev/null differ diff --git a/static/profile/二维码 (1)@2x.png b/static/profile/二维码 (1)@2x.png deleted file mode 100644 index 797fa8c..0000000 Binary files a/static/profile/二维码 (1)@2x.png and /dev/null differ diff --git a/static/profile/会员权益@2x.png b/static/profile/会员权益@2x.png deleted file mode 100644 index 9ebee58..0000000 Binary files a/static/profile/会员权益@2x.png and /dev/null differ diff --git a/static/profile/服务记录@2x.png b/static/profile/服务记录@2x.png deleted file mode 100644 index 7ad3207..0000000 Binary files a/static/profile/服务记录@2x.png and /dev/null differ