nomadro/apps/miniprogram/weapp/ai-pkg/socialSkill/apis/joinSocialCommunity.js
Eric 92bbee3c6c Ship native social weapp: immersive hall chat, SRS live, join pay.
Wire Taro social pages to social_svc (Centrifugo + live RTMP), drop multi-channel chat chrome, and add weapp WXSS sanitize/deploy helpers.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-02 12:33:35 +08:00

71 lines
2.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 原子接口:加群收费(虚拟支付)— 接力到 /pages/social/index 拉起 JoinPaySheet
* 可用 API:wx.getStorageSync / wx.setStorageSync / wx.request / wx.login
*/
const API = 'https://api.nomadro.cn'
function text(t) {
return [{ type: 'text', text: t }]
}
async function joinSocialCommunity({ email } = {}) {
if (email) {
try {
wx.setStorageSync('userEmail', String(email).trim().toLowerCase())
} catch (e) {
/* ignore */
}
}
let isMember = false
let priceFen = 4900
try {
const token = wx.getStorageSync('nomadro_token') || ''
if (token) {
const res = await new Promise((resolve, reject) => {
wx.request({
url: `${API}/api/ebook/pay/social-join-status`,
method: 'GET',
header: { Authorization: `Bearer ${token}` },
success: resolve,
fail: reject,
})
})
if (res.statusCode < 400 && res.data) {
isMember = Boolean(res.data.isMember)
if (res.data.priceFen) priceFen = Number(res.data.priceFen) || priceFen
}
} else {
isMember = Boolean(wx.getStorageSync('nomadro_social_join_member'))
}
} catch (e) {
isMember = Boolean(wx.getStorageSync('nomadro_social_join_member'))
}
const priceLabel = `¥${(priceFen / 100).toFixed(0)}`
const pagePath = '/pages/social/index'
const structuredContent = {
title: isMember ? '你已在游民社区' : '加入游民社区 · 加群收费',
priceLabel,
isMember,
pagePath,
linkText: isMember ? '打开游民社区' : '去支付加群',
}
return {
isError: false,
content: text(
isMember
? '你已经加过群了。点卡片进游民社区继续逛。'
: `加群是一次性入群费(${priceLabel}),走微信虚拟支付,不是 VIP。点卡片填写邮箱并支付。`,
),
structuredContent,
handoff: () => ({
query: 'join=1',
payload: { openJoinPay: true, email: email || '', priceFen, isMember },
}),
}
}
module.exports = joinSocialCommunity