2026-01-14 12:50:00 +08:00
|
|
|
|
const app = getApp()
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
const MATCH_TYPES = [
|
|
|
|
|
|
{ id: 'partner', label: '创业合伙', matchLabel: '创业伙伴', icon: '⭐' },
|
|
|
|
|
|
{ id: 'investor', label: '资源对接', matchLabel: '资源对接', icon: '👥' },
|
|
|
|
|
|
{ id: 'mentor', label: '导师顾问', matchLabel: '商业顾问', icon: '❤️' },
|
|
|
|
|
|
{ id: 'team', label: '团队招募', matchLabel: '加入项目', icon: '🎮' }
|
2026-01-21 15:49:12 +08:00
|
|
|
|
]
|
2026-02-02 18:16:15 +08:00
|
|
|
|
const FREE_MATCH_LIMIT = 1
|
|
|
|
|
|
|
|
|
|
|
|
function getStoredContact() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
return {
|
|
|
|
|
|
phone: wx.getStorageSync('user_phone') || '',
|
|
|
|
|
|
wechat: wx.getStorageSync('user_wechat') || ''
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (e) { return { phone: '', wechat: '' } }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getTodayMatchCount() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const today = new Date().toISOString().split('T')[0]
|
|
|
|
|
|
const stored = wx.getStorageSync('match_count_data')
|
|
|
|
|
|
if (stored) {
|
|
|
|
|
|
const data = typeof stored === 'string' ? JSON.parse(stored) : stored
|
|
|
|
|
|
if (data.date === today) return data.count || 0
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
return 0
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function saveTodayMatchCount(count) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const today = new Date().toISOString().split('T')[0]
|
|
|
|
|
|
wx.setStorageSync('match_count_data', JSON.stringify({ date: today, count }))
|
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
}
|
2026-01-21 15:49:12 +08:00
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
function saveContact(phone, wechat) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (phone) wx.setStorageSync('user_phone', phone)
|
|
|
|
|
|
if (wechat) wx.setStorageSync('user_wechat', wechat)
|
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
}
|
2026-01-21 15:49:12 +08:00
|
|
|
|
|
2026-01-14 12:50:00 +08:00
|
|
|
|
Page({
|
|
|
|
|
|
data: {
|
2026-01-21 15:49:12 +08:00
|
|
|
|
statusBarHeight: 44,
|
2026-02-02 18:16:15 +08:00
|
|
|
|
navBarHeight: 88,
|
|
|
|
|
|
matchEnabled: false,
|
2026-01-21 15:49:12 +08:00
|
|
|
|
matchTypes: MATCH_TYPES,
|
|
|
|
|
|
selectedType: 'partner',
|
2026-02-02 18:16:15 +08:00
|
|
|
|
currentMatchLabel: '创业伙伴',
|
2026-01-21 15:49:12 +08:00
|
|
|
|
hasPurchased: false,
|
|
|
|
|
|
todayMatchCount: 0,
|
2026-02-02 18:16:15 +08:00
|
|
|
|
totalMatchesAllowed: 1,
|
|
|
|
|
|
matchesRemaining: 0,
|
2026-01-21 15:49:12 +08:00
|
|
|
|
needPayToMatch: false,
|
2026-01-14 12:50:00 +08:00
|
|
|
|
isMatching: false,
|
2026-01-21 15:49:12 +08:00
|
|
|
|
currentMatch: null,
|
2026-02-02 18:16:15 +08:00
|
|
|
|
matchAttempts: 0,
|
|
|
|
|
|
showUnlockModal: false,
|
2026-01-21 15:49:12 +08:00
|
|
|
|
showJoinModal: false,
|
|
|
|
|
|
joinType: null,
|
|
|
|
|
|
phoneNumber: '',
|
|
|
|
|
|
wechatId: '',
|
2026-02-02 18:16:15 +08:00
|
|
|
|
contactType: 'phone',
|
2026-01-21 15:49:12 +08:00
|
|
|
|
isJoining: false,
|
|
|
|
|
|
joinSuccess: false,
|
|
|
|
|
|
joinError: '',
|
2026-02-02 18:16:15 +08:00
|
|
|
|
isUnlocking: false
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onLoad() {
|
2026-02-02 18:16:15 +08:00
|
|
|
|
this.setNavBarHeight()
|
|
|
|
|
|
const contact = getStoredContact()
|
|
|
|
|
|
this.setData({ phoneNumber: contact.phone, wechatId: contact.wechat })
|
|
|
|
|
|
app.loadFeatureConfig().then(() => this.syncState())
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-21 15:49:12 +08:00
|
|
|
|
onShow() {
|
2026-02-02 18:16:15 +08:00
|
|
|
|
if (typeof this.getTabBar === 'function' && this.getTabBar()) this.getTabBar().setData({ selected: 2 })
|
|
|
|
|
|
this.setNavBarHeight()
|
|
|
|
|
|
app.loadFeatureConfig().then(() => this.syncState())
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
setNavBarHeight() {
|
|
|
|
|
|
const statusBarHeight = app.globalData.statusBarHeight || 44
|
|
|
|
|
|
const navBarHeight = app.globalData.navBarHeight || (statusBarHeight + 44)
|
|
|
|
|
|
this.setData({ statusBarHeight, navBarHeight })
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
syncState() {
|
|
|
|
|
|
const matchEnabled = app.globalData.matchEnabled === true
|
|
|
|
|
|
const user = app.globalData.userInfo
|
|
|
|
|
|
const hasFullBook = !!app.globalData.hasFullBook
|
|
|
|
|
|
const purchasedSections = app.globalData.purchasedSections || []
|
|
|
|
|
|
const hasPurchased = hasFullBook || purchasedSections.length > 0
|
|
|
|
|
|
const todayMatchCount = getTodayMatchCount()
|
|
|
|
|
|
const totalMatchesAllowed = hasFullBook ? 999999 : FREE_MATCH_LIMIT + purchasedSections.length
|
|
|
|
|
|
const matchesRemaining = hasFullBook ? 999999 : Math.max(0, totalMatchesAllowed - todayMatchCount)
|
2026-01-21 15:49:12 +08:00
|
|
|
|
const needPayToMatch = !hasFullBook && matchesRemaining <= 0
|
2026-02-02 18:16:15 +08:00
|
|
|
|
if (user && user.phone) this.setData({ phoneNumber: user.phone })
|
2026-01-14 12:50:00 +08:00
|
|
|
|
this.setData({
|
2026-02-02 18:16:15 +08:00
|
|
|
|
matchEnabled,
|
|
|
|
|
|
hasPurchased,
|
|
|
|
|
|
todayMatchCount,
|
2026-01-21 15:49:12 +08:00
|
|
|
|
totalMatchesAllowed,
|
|
|
|
|
|
matchesRemaining,
|
2026-02-02 18:16:15 +08:00
|
|
|
|
needPayToMatch
|
2026-01-14 12:50:00 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-21 15:49:12 +08:00
|
|
|
|
selectType(e) {
|
2026-02-02 18:16:15 +08:00
|
|
|
|
const id = e.currentTarget.dataset.id
|
|
|
|
|
|
const t = MATCH_TYPES.find(x => x.id === id)
|
|
|
|
|
|
this.setData({ selectedType: id, currentMatchLabel: t ? t.matchLabel : '创业伙伴' })
|
2026-01-21 15:49:12 +08:00
|
|
|
|
},
|
2026-01-14 12:50:00 +08:00
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
startMatch() {
|
|
|
|
|
|
if (!this.data.hasPurchased) {
|
|
|
|
|
|
wx.showToast({ title: '购买书籍后可使用', icon: 'none' })
|
2026-01-21 15:49:12 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.data.needPayToMatch) {
|
|
|
|
|
|
this.setData({ showUnlockModal: true })
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-02-02 18:16:15 +08:00
|
|
|
|
this.setData({ isMatching: true, currentMatch: null, matchAttempts: 0 })
|
|
|
|
|
|
let attempts = 0
|
2026-01-21 15:49:12 +08:00
|
|
|
|
const timer = setInterval(() => {
|
2026-02-02 18:16:15 +08:00
|
|
|
|
attempts++
|
|
|
|
|
|
this.setData({ matchAttempts: attempts })
|
2026-01-21 15:49:12 +08:00
|
|
|
|
}, 1000)
|
2026-02-02 18:16:15 +08:00
|
|
|
|
const delay = 3000 + Math.random() * 3000
|
2026-01-21 15:49:12 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
clearInterval(timer)
|
2026-02-02 18:16:15 +08:00
|
|
|
|
const matched = this.getMockMatch()
|
2026-01-21 15:49:12 +08:00
|
|
|
|
const newCount = this.data.todayMatchCount + 1
|
2026-02-02 18:16:15 +08:00
|
|
|
|
saveTodayMatchCount(newCount)
|
|
|
|
|
|
this.reportMatchToCKB(matched)
|
|
|
|
|
|
const currentType = MATCH_TYPES.find(t => t.id === this.data.selectedType)
|
|
|
|
|
|
const showJoinAfter = currentType && (currentType.id === 'investor' || currentType.id === 'mentor' || currentType.id === 'team')
|
2026-01-21 15:49:12 +08:00
|
|
|
|
this.setData({
|
|
|
|
|
|
isMatching: false,
|
2026-02-02 18:16:15 +08:00
|
|
|
|
currentMatch: matched,
|
2026-01-21 15:49:12 +08:00
|
|
|
|
todayMatchCount: newCount,
|
2026-02-02 18:16:15 +08:00
|
|
|
|
matchesRemaining: this.data.hasFullBook ? 999999 : Math.max(0, this.data.totalMatchesAllowed - newCount),
|
|
|
|
|
|
needPayToMatch: !this.data.hasFullBook && (this.data.totalMatchesAllowed - newCount) <= 0
|
2026-01-21 15:49:12 +08:00
|
|
|
|
})
|
2026-02-02 18:16:15 +08:00
|
|
|
|
if (showJoinAfter) {
|
|
|
|
|
|
this.setData({ showJoinModal: true, joinType: this.data.selectedType, joinSuccess: false, joinError: '' })
|
|
|
|
|
|
}
|
2026-01-21 15:49:12 +08:00
|
|
|
|
}, delay)
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
getMockMatch() {
|
2026-01-21 15:49:12 +08:00
|
|
|
|
const nicknames = ['创业先锋', '资源整合者', '私域专家', '商业导师', '连续创业者']
|
2026-01-14 12:50:00 +08:00
|
|
|
|
const concepts = [
|
2026-01-21 15:49:12 +08:00
|
|
|
|
'专注私域流量运营5年,帮助100+品牌实现从0到1的增长。',
|
|
|
|
|
|
'连续创业者,擅长商业模式设计和资源整合。',
|
|
|
|
|
|
'在Soul分享真实创业故事,希望找到志同道合的合作伙伴。'
|
2026-01-14 12:50:00 +08:00
|
|
|
|
]
|
2026-01-21 15:49:12 +08:00
|
|
|
|
const wechats = ['soul_partner_1', 'soul_business_2024', 'soul_startup_fan']
|
2026-02-02 18:16:15 +08:00
|
|
|
|
const i = Math.floor(Math.random() * nicknames.length)
|
|
|
|
|
|
const typeLabel = MATCH_TYPES.find(t => t.id === this.data.selectedType)
|
2026-01-14 12:50:00 +08:00
|
|
|
|
return {
|
2026-02-02 18:16:15 +08:00
|
|
|
|
id: 'user_' + Date.now(),
|
|
|
|
|
|
nickname: nicknames[i],
|
|
|
|
|
|
avatar: '',
|
|
|
|
|
|
tags: ['创业者', '私域运营', typeLabel ? typeLabel.label : ''],
|
|
|
|
|
|
matchScore: 80 + Math.floor(Math.random() * 20),
|
|
|
|
|
|
concept: concepts[i % concepts.length],
|
|
|
|
|
|
wechat: wechats[i % wechats.length],
|
2026-01-14 12:50:00 +08:00
|
|
|
|
commonInterests: [
|
2026-02-02 18:16:15 +08:00
|
|
|
|
{ icon: '📚', text: '都在读《创业实验》' },
|
2026-01-14 12:50:00 +08:00
|
|
|
|
{ icon: '💼', text: '对私域运营感兴趣' },
|
2026-01-21 15:49:12 +08:00
|
|
|
|
{ icon: '🎯', text: '相似的创业方向' }
|
2026-01-14 12:50:00 +08:00
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
reportMatchToCKB(matched) {
|
|
|
|
|
|
app.request('/api/ckb/match', {
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
data: {
|
|
|
|
|
|
matchType: this.data.selectedType,
|
|
|
|
|
|
phone: this.data.phoneNumber || (app.globalData.userInfo && app.globalData.userInfo.phone) || '',
|
|
|
|
|
|
wechat: this.data.wechatId || (app.globalData.userInfo && app.globalData.userInfo.wechat) || '',
|
|
|
|
|
|
userId: (app.globalData.userInfo && app.globalData.userInfo.id) || '',
|
|
|
|
|
|
nickname: (app.globalData.userInfo && app.globalData.userInfo.nickname) || '',
|
|
|
|
|
|
matchedUser: { id: matched.id, nickname: matched.nickname, matchScore: matched.matchScore }
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(() => {})
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
cancelMatch() {
|
2026-02-02 18:16:15 +08:00
|
|
|
|
this.setData({ isMatching: false })
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
nextMatch() {
|
|
|
|
|
|
if (this.data.needPayToMatch) {
|
|
|
|
|
|
this.setData({ showUnlockModal: true })
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-01-21 15:49:12 +08:00
|
|
|
|
this.setData({ currentMatch: null })
|
2026-02-02 18:16:15 +08:00
|
|
|
|
this.startMatch()
|
2026-01-21 15:49:12 +08:00
|
|
|
|
},
|
2026-01-14 12:50:00 +08:00
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
addWechat() {
|
|
|
|
|
|
const m = this.data.currentMatch
|
|
|
|
|
|
if (!m || !m.wechat) return
|
2026-01-14 12:50:00 +08:00
|
|
|
|
wx.setClipboardData({
|
2026-02-02 18:16:15 +08:00
|
|
|
|
data: m.wechat,
|
2026-01-14 12:50:00 +08:00
|
|
|
|
success: () => {
|
|
|
|
|
|
wx.showModal({
|
2026-02-02 18:16:15 +08:00
|
|
|
|
title: '已复制微信号',
|
|
|
|
|
|
content: '请打开微信添加好友,备注"创业合作"即可。',
|
|
|
|
|
|
showCancel: false
|
2026-01-14 12:50:00 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
closeUnlockModal() {
|
|
|
|
|
|
if (!this.data.isUnlocking) this.setData({ showUnlockModal: false })
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
goBuySection() {
|
|
|
|
|
|
this.setData({ showUnlockModal: false })
|
|
|
|
|
|
wx.switchTab({ url: '/pages/chapters/chapters' })
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
2026-02-02 18:16:15 +08:00
|
|
|
|
|
|
|
|
|
|
closeJoinModal() {
|
|
|
|
|
|
if (!this.data.isJoining) this.setData({ showJoinModal: false })
|
2026-01-29 15:50:45 +08:00
|
|
|
|
},
|
2026-02-02 18:16:15 +08:00
|
|
|
|
|
|
|
|
|
|
setContactType(e) {
|
|
|
|
|
|
const t = e.currentTarget.dataset.type
|
|
|
|
|
|
this.setData({ contactType: t })
|
2026-01-29 15:50:45 +08:00
|
|
|
|
},
|
2026-02-02 18:16:15 +08:00
|
|
|
|
|
|
|
|
|
|
onPhoneInput(e) {
|
|
|
|
|
|
this.setData({ phoneNumber: (e.detail && e.detail.value) || '' })
|
2026-01-29 15:50:45 +08:00
|
|
|
|
},
|
2026-01-14 12:50:00 +08:00
|
|
|
|
|
2026-01-21 15:49:12 +08:00
|
|
|
|
onWechatInput(e) {
|
2026-02-02 18:16:15 +08:00
|
|
|
|
this.setData({ wechatId: (e.detail && e.detail.value) || '' })
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
submitJoin() {
|
|
|
|
|
|
const { contactType, phoneNumber, wechatId } = this.data
|
|
|
|
|
|
if (contactType === 'phone' && (!phoneNumber || phoneNumber.length !== 11)) {
|
|
|
|
|
|
this.setData({ joinError: '请输入正确的11位手机号' })
|
|
|
|
|
|
return
|
2026-01-21 15:49:12 +08:00
|
|
|
|
}
|
2026-02-02 18:16:15 +08:00
|
|
|
|
if (contactType === 'wechat' && (!wechatId || wechatId.length < 6)) {
|
|
|
|
|
|
this.setData({ joinError: '请输入正确的微信号(至少6位)' })
|
|
|
|
|
|
return
|
2026-01-29 17:15:00 +08:00
|
|
|
|
}
|
2026-01-21 15:49:12 +08:00
|
|
|
|
this.setData({ isJoining: true, joinError: '' })
|
2026-02-02 18:16:15 +08:00
|
|
|
|
app.request('/api/ckb/join', {
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
data: {
|
|
|
|
|
|
type: this.data.joinType,
|
|
|
|
|
|
phone: contactType === 'phone' ? phoneNumber : '',
|
|
|
|
|
|
wechat: contactType === 'wechat' ? wechatId : '',
|
|
|
|
|
|
userId: app.globalData.userInfo && app.globalData.userInfo.id
|
|
|
|
|
|
}
|
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
|
if (res && res.success) {
|
|
|
|
|
|
saveContact(phoneNumber, wechatId)
|
2026-01-21 15:49:12 +08:00
|
|
|
|
this.setData({ joinSuccess: true })
|
2026-02-02 18:16:15 +08:00
|
|
|
|
setTimeout(() => this.setData({ showJoinModal: false, joinSuccess: false }), 2000)
|
2026-01-21 15:49:12 +08:00
|
|
|
|
} else {
|
2026-02-02 18:16:15 +08:00
|
|
|
|
this.setData({ joinError: (res && res.message) || '加入失败,请稍后重试' })
|
2026-01-14 12:50:00 +08:00
|
|
|
|
}
|
2026-02-02 18:16:15 +08:00
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
this.setData({ joinError: '网络错误,请检查网络后重试' })
|
|
|
|
|
|
}).finally(() => {
|
2026-01-21 15:49:12 +08:00
|
|
|
|
this.setData({ isJoining: false })
|
2026-02-02 18:16:15 +08:00
|
|
|
|
})
|
2026-01-23 16:31:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-21 15:49:12 +08:00
|
|
|
|
goToChapters() {
|
|
|
|
|
|
wx.switchTab({ url: '/pages/chapters/chapters' })
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
goToIndex() {
|
|
|
|
|
|
wx.switchTab({ url: '/pages/index/index' })
|
|
|
|
|
|
}
|
2026-01-14 12:50:00 +08:00
|
|
|
|
})
|