diff --git a/miniprogram/app.js b/miniprogram/app.js
index cc86b263..2bd161cf 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -7,9 +7,9 @@ App({
globalData: {
// API基础地址 - 连接真实后端
// baseUrl: 'https://soulapi.quwanzhi.com',
- baseUrl: 'https://souldev.quwanzhi.com',
+ // baseUrl: 'https://souldev.quwanzhi.com',
// baseUrl: 'http://localhost:3006',
- // baseUrl: 'http://localhost:8080',
+ baseUrl: 'http://localhost:8080',
// 小程序配置 - 真实AppID
appId: 'wxb8bbb2b10dec74aa',
diff --git a/miniprogram/pages/match/match.js b/miniprogram/pages/match/match.js
index fe9d7b4d..6054c1b8 100644
--- a/miniprogram/pages/match/match.js
+++ b/miniprogram/pages/match/match.js
@@ -66,6 +66,17 @@ Page({
// 解锁弹窗
showUnlockModal: false,
+ // 手机号绑定弹窗(一键加好友前校验)
+ showBindPhoneModal: false,
+ pendingAddWechatAfterBind: false,
+ bindPhoneInput: '',
+ showMatchPhoneManualInput: false,
+
+ // 登录弹窗(未登录时点击匹配弹出)
+ showLoginModal: false,
+ isLoggingIn: false,
+ agreeProtocol: false,
+
// 匹配价格(可配置)
matchPrice: 1,
extraMatches: 0
@@ -90,6 +101,7 @@ Page({
tabBar.setData({ selected: 2 })
}
}
+ this.loadStoredContact()
this.initUserStatus()
},
@@ -123,10 +135,11 @@ Page({
}
},
- // 加载本地存储的联系方式
+ // 加载本地存储的联系方式(含用户资料的手机号、微信号)
loadStoredContact() {
- const phone = wx.getStorageSync('user_phone') || ''
- const wechat = wx.getStorageSync('user_wechat') || ''
+ const ui = app.globalData.userInfo || {}
+ const phone = wx.getStorageSync('user_phone') || ui.phone || ''
+ const wechat = wx.getStorageSync('user_wechat') || ui.wechat || ui.wechatId || ''
this.setData({
phoneNumber: phone,
wechatId: wechat,
@@ -192,25 +205,16 @@ Page({
// 点击匹配按钮
handleMatchClick() {
+ // 检测是否登录,未登录则弹出登录弹窗
+ if (!this.data.isLoggedIn) {
+ this.setData({ showLoginModal: true, agreeProtocol: false })
+ return
+ }
+
const currentType = MATCH_TYPES.find(t => t.id === this.data.selectedType)
- // 资源对接类型需要登录+购买章节才能使用
+ // 资源对接类型需要购买章节才能使用
if (currentType && currentType.id === 'investor') {
- // 检查是否登录
- if (!this.data.isLoggedIn) {
- wx.showModal({
- title: '需要登录',
- content: '请先登录后再使用资源对接功能',
- confirmText: '去登录',
- success: (res) => {
- if (res.confirm) {
- wx.switchTab({ url: '/pages/my/my' })
- }
- }
- })
- return
- }
-
// 检查是否购买过章节
const hasPurchased = app.globalData.purchasedSections?.length > 0 || app.globalData.hasFullBook
if (!hasPurchased) {
@@ -235,7 +239,8 @@ Page({
const hasWechat = !!this.data.wechatId
if (!hasPhone && !hasWechat) {
- // 没有绑定联系方式,先显示绑定提示
+ // 没有绑定联系方式,先显示绑定提示(仍尝试加载已有资料填充)
+ this.loadStoredContact()
this.setData({
showJoinModal: true,
joinType: currentType.id,
@@ -279,6 +284,8 @@ Page({
const delay = Math.random() * 2000 + 1000
setTimeout(() => {
clearInterval(timer)
+ // 打开弹窗前调取用户资料填充手机号、微信号
+ this.loadStoredContact()
this.setData({
isMatching: false,
showJoinModal: true,
@@ -435,26 +442,78 @@ Page({
this.setData({ currentMatch: null })
},
- // 添加微信好友
+ // 添加微信好友(先校验手机号绑定)
handleAddWechat() {
if (!this.data.currentMatch) return
+ // 未登录需先登录
+ if (!app.globalData.isLoggedIn) {
+ wx.showModal({
+ title: '需要登录',
+ content: '请先登录后再添加好友',
+ confirmText: '去登录',
+ success: (res) => {
+ if (res.confirm) wx.switchTab({ url: '/pages/my/my' })
+ }
+ })
+ return
+ }
+
+ // 判断是否已绑定手机号(本地缓存或用户资料)
+ const hasPhone = !!(
+ wx.getStorageSync('user_phone') ||
+ app.globalData.userInfo?.phone
+ )
+
+ if (!hasPhone) {
+ this.setData({
+ showBindPhoneModal: true,
+ pendingAddWechatAfterBind: true
+ })
+ return
+ }
+
+ this.doCopyWechat()
+ },
+
+ // 执行复制联系方式(优先微信号,无则复制手机号)
+ doCopyWechat() {
+ if (!this.data.currentMatch) return
+ const wechat = (this.data.currentMatch.wechat || this.data.currentMatch.wechatId || '').trim()
+ const phone = (this.data.currentMatch.phone || '').trim()
+ const toCopy = wechat || phone
+ if (!toCopy) {
+ wx.showModal({
+ title: '暂无可复制',
+ content: '该用户未提供微信号或手机号,请通过其他方式联系',
+ showCancel: false,
+ confirmText: '知道了'
+ })
+ return
+ }
+ const label = wechat ? '微信号' : '手机号'
wx.setClipboardData({
- data: this.data.currentMatch.wechat,
+ data: toCopy,
success: () => {
wx.showModal({
- title: '微信号已复制',
- content: `微信号:${this.data.currentMatch.wechat}\n\n请打开微信添加好友,备注"创业合作"即可`,
+ title: wechat ? '微信号已复制' : '手机号已复制',
+ content: wechat
+ ? `${label}:${toCopy}\n\n请打开微信添加好友,备注"创业合作"即可`
+ : `${label}:${toCopy}\n\n可通过微信搜索该手机号添加好友`,
showCancel: false,
confirmText: '知道了'
})
+ },
+ fail: () => {
+ wx.showToast({ title: '复制失败,请重试', icon: 'none' })
}
})
},
- // 切换联系方式类型
+ // 切换联系方式类型(同步刷新用户资料填充)
switchContactType(e) {
const type = e.currentTarget.dataset.type
+ this.loadStoredContact()
this.setData({ contactType: type, joinError: '' })
},
@@ -565,6 +624,149 @@ Page({
this.setData({ showJoinModal: false, joinError: '' })
},
+ // 关闭手机绑定弹窗
+ closeBindPhoneModal() {
+ this.setData({
+ showBindPhoneModal: false,
+ pendingAddWechatAfterBind: false,
+ bindPhoneInput: '',
+ showMatchPhoneManualInput: false
+ })
+ },
+
+ // 关闭登录弹窗
+ closeLoginModal() {
+ if (this.data.isLoggingIn) return
+ this.setData({ showLoginModal: false })
+ },
+
+ // 切换协议勾选
+ toggleAgree() {
+ this.setData({ agreeProtocol: !this.data.agreeProtocol })
+ },
+
+ // 打开用户协议
+ openUserProtocol() {
+ wx.navigateTo({ url: '/pages/agreement/agreement' })
+ },
+
+ // 打开隐私政策
+ openPrivacy() {
+ wx.navigateTo({ url: '/pages/privacy/privacy' })
+ },
+
+ // 微信登录(匹配页)
+ async handleMatchWechatLogin() {
+ if (!this.data.agreeProtocol) {
+ wx.showToast({ title: '请先阅读并同意用户协议和隐私政策', icon: 'none' })
+ return
+ }
+ this.setData({ isLoggingIn: true })
+ try {
+ const result = await app.login()
+ if (result) {
+ this.initUserStatus()
+ this.setData({ showLoginModal: false, agreeProtocol: false })
+ wx.showToast({ title: '登录成功', icon: 'success' })
+ } else {
+ wx.showToast({ title: '登录失败,请重试', icon: 'none' })
+ }
+ } catch (e) {
+ console.error('[Match] 微信登录错误:', e)
+ wx.showToast({ title: '登录失败,请重试', icon: 'none' })
+ } finally {
+ this.setData({ isLoggingIn: false })
+ }
+ },
+
+ // 一键获取手机号(匹配页加好友前绑定)
+ async onMatchGetPhoneNumber(e) {
+ if (e.detail.errMsg !== 'getPhoneNumber:ok') {
+ wx.showToast({ title: '授权失败', icon: 'none' })
+ return
+ }
+ const code = e.detail.code
+ if (!code) {
+ this.setData({ showMatchPhoneManualInput: true })
+ return
+ }
+ try {
+ wx.showLoading({ title: '获取中...', mask: true })
+ const userId = app.globalData.userInfo?.id
+ const res = await app.request('/api/miniprogram/phone', {
+ method: 'POST',
+ data: { code, userId }
+ })
+ wx.hideLoading()
+ if (res.success && res.phoneNumber) {
+ await this.saveMatchPhoneAndContinue(res.phoneNumber)
+ } else {
+ this.setData({ showMatchPhoneManualInput: true })
+ }
+ } catch (err) {
+ wx.hideLoading()
+ this.setData({ showMatchPhoneManualInput: true })
+ }
+ },
+
+ // 切换为手动输入
+ onMatchShowManualInput() {
+ this.setData({ showMatchPhoneManualInput: true })
+ },
+
+ // 手动输入手机号
+ onMatchPhoneInput(e) {
+ this.setData({
+ bindPhoneInput: e.detail.value.replace(/\D/g, '').slice(0, 11)
+ })
+ },
+
+ // 确认手动绑定手机号
+ async confirmMatchPhoneBind() {
+ const { bindPhoneInput } = this.data
+ if (!bindPhoneInput || bindPhoneInput.length !== 11) {
+ wx.showToast({ title: '请输入正确的11位手机号', icon: 'none' })
+ return
+ }
+ if (!/^1[3-9]\d{9}$/.test(bindPhoneInput)) {
+ wx.showToast({ title: '请输入正确的手机号', icon: 'none' })
+ return
+ }
+ await this.saveMatchPhoneAndContinue(bindPhoneInput)
+ },
+
+ // 保存手机号到本地+服务器,并继续加好友
+ async saveMatchPhoneAndContinue(phone) {
+ wx.setStorageSync('user_phone', phone)
+ if (app.globalData.userInfo) {
+ app.globalData.userInfo.phone = phone
+ wx.setStorageSync('userInfo', app.globalData.userInfo)
+ }
+ this.setData({
+ phoneNumber: phone,
+ userPhone: phone,
+ bindPhoneInput: ''
+ })
+ this.loadStoredContact()
+ try {
+ const userId = app.globalData.userInfo?.id
+ if (userId) {
+ await app.request('/api/miniprogram/user/profile', {
+ method: 'POST',
+ data: { userId, phone }
+ })
+ }
+ } catch (e) {
+ console.log('[Match] 同步手机号到服务器失败:', e)
+ }
+ const pending = this.data.pendingAddWechatAfterBind
+ this.closeBindPhoneModal()
+ if (pending) {
+ wx.showToast({ title: '绑定成功', icon: 'success' })
+ setTimeout(() => this.doCopyWechat(), 500)
+ }
+ },
+
// 显示解锁弹窗
showUnlockModal() {
this.setData({ showUnlockModal: true })
diff --git a/miniprogram/pages/match/match.wxml b/miniprogram/pages/match/match.wxml
index 3585aee0..df47b547 100644
--- a/miniprogram/pages/match/match.wxml
+++ b/miniprogram/pages/match/match.wxml
@@ -265,6 +265,75 @@
+
+
+
+ ✕
+ 🔐
+ 登录 Soul创业实验
+ 登录后可使用找伙伴功能
+
+
+ 取消
+
+
+ {{agreeProtocol ? '✓' : ''}}
+ 我已阅读并同意
+ 《用户协议》
+ 和
+ 《隐私政策》
+
+
+
+
+
+
+
+
+
+
+
+
+ 手动输入手机号
+
+
+
+
+
+
+ +86
+
+
+
+ 确认绑定
+
+
+
+
diff --git a/miniprogram/pages/match/match.wxss b/miniprogram/pages/match/match.wxss
index 378e1c99..3719ae27 100644
--- a/miniprogram/pages/match/match.wxss
+++ b/miniprogram/pages/match/match.wxss
@@ -584,6 +584,133 @@
overflow: hidden;
}
+/* ===== 登录弹窗 ===== */
+.login-modal-content {
+ padding: 48rpx;
+ position: relative;
+}
+
+.login-modal-content .modal-close {
+ position: absolute;
+ top: 24rpx;
+ right: 24rpx;
+ width: 64rpx;
+ height: 64rpx;
+ border-radius: 50%;
+ background: rgba(255, 255, 255, 0.1);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 28rpx;
+ color: rgba(255, 255, 255, 0.6);
+}
+
+.login-icon {
+ font-size: 96rpx;
+ text-align: center;
+ display: block;
+ margin-bottom: 24rpx;
+}
+
+.login-title {
+ font-size: 36rpx;
+ font-weight: 700;
+ color: #ffffff;
+ text-align: center;
+ display: block;
+ margin-bottom: 16rpx;
+}
+
+.login-desc {
+ font-size: 26rpx;
+ color: rgba(255, 255, 255, 0.6);
+ text-align: center;
+ display: block;
+ margin-bottom: 48rpx;
+}
+
+.btn-wechat {
+ width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 16rpx;
+ padding: 28rpx;
+ background: #07C160;
+ color: #ffffff;
+ font-size: 28rpx;
+ font-weight: 500;
+ border-radius: 24rpx;
+ margin-bottom: 24rpx;
+ border: none;
+}
+
+.btn-wechat::after {
+ border: none;
+}
+
+.btn-wechat-icon {
+ width: 40rpx;
+ height: 40rpx;
+ background: rgba(255, 255, 255, 0.2);
+ border-radius: 8rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 24rpx;
+}
+
+.login-modal-cancel {
+ margin-top: 24rpx;
+ padding: 24rpx;
+ font-size: 28rpx;
+ color: rgba(255, 255, 255, 0.5);
+ text-align: center;
+}
+
+.login-agree-row {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: center;
+ margin-top: 32rpx;
+ font-size: 22rpx;
+ color: rgba(255, 255, 255, 0.5);
+}
+
+.agree-checkbox {
+ width: 32rpx;
+ height: 32rpx;
+ border: 2rpx solid rgba(255, 255, 255, 0.5);
+ border-radius: 6rpx;
+ margin-right: 12rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 22rpx;
+ color: #fff;
+ flex-shrink: 0;
+}
+
+.agree-checked {
+ background: #00CED1;
+ border-color: #00CED1;
+}
+
+.agree-text {
+ color: rgba(255, 255, 255, 0.6);
+}
+
+.agree-link {
+ color: #00CED1;
+ text-decoration: underline;
+ padding: 0 4rpx;
+}
+
+.btn-wechat-disabled {
+ opacity: 0.6;
+}
+
/* ===== 加入弹窗 ===== */
.join-modal {
padding: 40rpx;
@@ -705,7 +832,7 @@
.join-header {
position: relative;
- padding: 48rpx 40rpx 32rpx;
+ padding: 48rpx 48rpx 32rpx;
background: linear-gradient(135deg, rgba(0, 206, 209, 0.15) 0%, rgba(123, 97, 255, 0.1) 100%);
text-align: center;
}
@@ -754,10 +881,39 @@
color: rgba(255, 255, 255, 0.6);
}
+/* 手机号绑定弹窗 */
+.bind-phone-actions {
+ padding: 32rpx 40rpx 48rpx;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 24rpx;
+}
+
+.get-phone-btn-modal {
+ width: 100%;
+ padding: 28rpx 48rpx;
+ background: linear-gradient(135deg, #00CED1 0%, #20B2AA 100%);
+ color: #fff;
+ font-size: 32rpx;
+ font-weight: 600;
+ border-radius: 20rpx;
+ border: none;
+}
+
+.get-phone-btn-modal::after {
+ border: none;
+}
+
+.manual-bind-link {
+ font-size: 28rpx;
+ color: rgba(0, 206, 209, 0.9);
+}
+
.contact-switch {
display: flex;
gap: 16rpx;
- padding: 24rpx 40rpx;
+ padding: 24rpx 48rpx;
}
.switch-item {
@@ -785,7 +941,7 @@
}
.input-area {
- padding: 0 40rpx 24rpx;
+ padding: 0 48rpx 24rpx;
}
.input-wrapper {
@@ -824,7 +980,7 @@
}
.submit-btn-new {
- margin: 8rpx 40rpx 24rpx;
+ margin: 8rpx 48rpx 24rpx;
padding: 28rpx;
background: linear-gradient(135deg, #00CED1 0%, #20B2AA 100%);
color: #ffffff;
@@ -843,7 +999,7 @@
text-align: center;
font-size: 22rpx;
color: rgba(255, 255, 255, 0.3);
- padding-bottom: 32rpx;
+ padding: 0 48rpx 32rpx;
}
/* ===== 新版加入成功 ===== */
@@ -1181,7 +1337,7 @@
display: flex;
flex-direction: column;
gap: 20rpx;
- margin-bottom: 24rpx;
+ margin: 0 48rpx 24rpx;
}
.resource-form .form-item {
display: flex;
diff --git a/miniprogram/pages/my/my.wxml b/miniprogram/pages/my/my.wxml
index 2a5e74d2..0fd009b3 100644
--- a/miniprogram/pages/my/my.wxml
+++ b/miniprogram/pages/my/my.wxml
@@ -90,46 +90,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- 累计收益
- {{earningsLoading ? '-' : '¥' + earnings}}
-
-
- 可提现
- {{earningsLoading ? '-' : '¥' + pendingEarnings}}
-
-
-
-
-
- 🎁
- 推广中心 / 提现
-
-
-
-
-
-
+
+