feat: 小程序统一走 Go 后台,咨询与登录切到 /api/v1
去掉协会 WebView 和魔方账密页,微信登录与咨询接口共用同一 token 和拦截器。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
<template>
|
||||
<yxg-page title="合盘邀请">
|
||||
<text v-if="loading" class="hint">加载邀请…</text>
|
||||
<template v-else-if="meta">
|
||||
<view class="card">
|
||||
<text class="h1">{{ meta.host_name || '好友' }} 邀请你合盘</text>
|
||||
<text class="desc">填写生日,一起看见彼此的星盘互动与相处参考</text>
|
||||
<view v-if="meta.already_accepted">
|
||||
<text class="meta">该邀请已使用,可直接去合盘页再测。</text>
|
||||
<view class="btn" @click="yxgGo('/synastry')"><text>回合盘页</text></view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<input class="inp" v-model="name" placeholder="你的称呼" />
|
||||
<view class="date-row">
|
||||
<input class="inp sm" type="number" v-model="ty" placeholder="年" />
|
||||
<input class="inp sm" type="number" v-model="tm" placeholder="月" />
|
||||
<input class="inp sm" type="number" v-model="td" placeholder="日" />
|
||||
</view>
|
||||
<text v-if="error" class="err">{{ error }}</text>
|
||||
<view class="btn" :class="{ off: submitting }" @click="accept">
|
||||
<text>{{ submitting ? '生成中…' : '接受并合盘' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<view v-else class="card">
|
||||
<text class="desc">{{ error || '邀请无效或已过期' }}</text>
|
||||
<view class="btn" @click="yxgGo('/synastry')"><text>去合盘页</text></view>
|
||||
</view>
|
||||
</yxg-page>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import YxgPage from '@/components/yxg/yxg-page.vue'
|
||||
import { yxgApi } from '@/util/yxgApi.js'
|
||||
import { ensureAccount } from '@/util/yxgAuth.js'
|
||||
import { yxgGo } from '@/util/yxgNav.js'
|
||||
|
||||
const token = ref('')
|
||||
const loading = ref(true)
|
||||
const submitting = ref(false)
|
||||
const error = ref('')
|
||||
const name = ref('我')
|
||||
const ty = ref('')
|
||||
const tm = ref('')
|
||||
const td = ref('')
|
||||
const meta = ref(null)
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
if (!(await ensureAccount(`/synastry/invite/${token.value}`))) {
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
try {
|
||||
meta.value = await yxgApi.getSynastryInvite(token.value)
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : '邀请无效'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function accept() {
|
||||
const y = Number(ty.value), m = Number(tm.value), d = Number(td.value)
|
||||
if (!y || !m || !d) {
|
||||
error.value = '请填写完整生日'
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const report = await yxgApi.acceptSynastryInvite(token.value, {
|
||||
display_name: name.value.trim() || '我',
|
||||
birth_date: `${y}-${String(m).padStart(2, '0')}-${String(d).padStart(2, '0')}`,
|
||||
})
|
||||
const id = report.id || report.report?.id
|
||||
if (id) yxgGo(`/reports/${id}`)
|
||||
else yxgGo('/synastry')
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : '接受失败'
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onLoad((q) => {
|
||||
token.value = q.token || ''
|
||||
load()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
page { background-color: #ffd1c7; }
|
||||
</style>
|
||||
<style scoped>
|
||||
.hint, .err { display: block; padding: 12px 16px; font-size: 13px; color: #999; }
|
||||
.err { color: #e54d42; }
|
||||
.card { margin: 12px 16px; padding: 18px 16px; background: #fff; border-radius: 18px; }
|
||||
.h1 { display: block; font-size: 20px; font-weight: 700; color: #333; }
|
||||
.desc, .meta { display: block; margin-top: 8px; font-size: 14px; color: #555; }
|
||||
.inp { width: 100%; height: 42px; background: #fdfaf8; border-radius: 12px; padding: 0 12px; box-sizing: border-box; margin-top: 12px; }
|
||||
.date-row { display: flex; gap: 8px; }
|
||||
.inp.sm { flex: 1; text-align: center; }
|
||||
.btn {
|
||||
margin-top: 14px; height: 42px; border-radius: 999px; background: #e54d42; color: #fff;
|
||||
display: flex; align-items: center; justify-content: center; font-weight: 700;
|
||||
}
|
||||
.btn.off { opacity: 0.5; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user