PDF2需求修复 - v1.16
## 修复 1. 资源对接:去掉"擅长什么"只保留两项 2. 资源对接:需登录+购买章节才能使用 3. 手机号API:修复AppSecret配置错误 4. 小程序码API:修复AppSecret配置错误 5. 获取地址:增强错误处理 ## AppSecret统一 - qrcode/phone API统一使用正确的AppSecret Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,7 +7,7 @@ import { NextRequest, NextResponse } from 'next/server'
|
|||||||
import { query } from '@/lib/db'
|
import { query } from '@/lib/db'
|
||||||
|
|
||||||
const APPID = process.env.WECHAT_APPID || 'wxb8bbb2b10dec74aa'
|
const APPID = process.env.WECHAT_APPID || 'wxb8bbb2b10dec74aa'
|
||||||
const APPSECRET = process.env.WECHAT_APPSECRET || '25b7e7fdb7998e5107e242ebb6ddabd0'
|
const APPSECRET = process.env.WECHAT_APPSECRET || '3c1fb1f63e6e052222bbcead9d07fe0c'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST - 解密手机号
|
* POST - 解密手机号
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import { NextRequest, NextResponse } from 'next/server'
|
import { NextRequest, NextResponse } from 'next/server'
|
||||||
|
|
||||||
const APPID = process.env.WECHAT_APPID || 'wxb8bbb2b10dec74aa'
|
const APPID = process.env.WECHAT_APPID || 'wxb8bbb2b10dec74aa'
|
||||||
const APPSECRET = process.env.WECHAT_APPSECRET || '25b7e7fdb7998e5107e242ebb6ddabd0'
|
const APPSECRET = process.env.WECHAT_APPSECRET || '3c1fb1f63e6e052222bbcead9d07fe0c'
|
||||||
|
|
||||||
// 获取access_token
|
// 获取access_token
|
||||||
async function getAccessToken() {
|
async function getAccessToken() {
|
||||||
|
|||||||
@@ -185,6 +185,40 @@ Page({
|
|||||||
handleMatchClick() {
|
handleMatchClick() {
|
||||||
const currentType = MATCH_TYPES.find(t => t.id === this.data.selectedType)
|
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) {
|
||||||
|
wx.showModal({
|
||||||
|
title: '需要购买章节',
|
||||||
|
content: '购买任意章节后即可使用资源对接功能',
|
||||||
|
confirmText: '去购买',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
wx.switchTab({ url: '/pages/catalog/catalog' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 如果是需要填写联系方式的类型(资源对接、导师顾问、团队招募)
|
// 如果是需要填写联系方式的类型(资源对接、导师顾问、团队招募)
|
||||||
if (currentType && currentType.showJoinAfterMatch) {
|
if (currentType && currentType.showJoinAfterMatch) {
|
||||||
// 先检查是否已绑定联系方式
|
// 先检查是否已绑定联系方式
|
||||||
|
|||||||
@@ -207,20 +207,16 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 资源对接专用输入 -->
|
<!-- 资源对接专用输入(只有两项) -->
|
||||||
<block wx:if="{{joinType === 'investor'}}">
|
<block wx:if="{{joinType === 'investor'}}">
|
||||||
<view class="resource-form">
|
<view class="resource-form">
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
<text class="form-label">我能帮到什么</text>
|
<text class="form-label">我能帮到你什么</text>
|
||||||
<input class="form-input-new" placeholder="例如:私域运营、品牌策划..." value="{{canHelp}}" bindinput="onCanHelpInput"/>
|
<input class="form-input-new" placeholder="例如:私域运营、品牌策划、流量资源..." value="{{canHelp}}" bindinput="onCanHelpInput"/>
|
||||||
</view>
|
</view>
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
<text class="form-label">我需要什么帮助</text>
|
<text class="form-label">我需要什么帮助</text>
|
||||||
<input class="form-input-new" placeholder="例如:流量、技术支持..." value="{{needHelp}}" bindinput="onNeedHelpInput"/>
|
<input class="form-input-new" placeholder="例如:技术支持、资金、人脉..." value="{{needHelp}}" bindinput="onNeedHelpInput"/>
|
||||||
</view>
|
|
||||||
<view class="form-item">
|
|
||||||
<text class="form-label">我擅长什么</text>
|
|
||||||
<input class="form-input-new" placeholder="例如:电商运营、内容创作..." value="{{goodAt}}" bindinput="onGoodAtInput"/>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ Page({
|
|||||||
|
|
||||||
// 生成推广海报
|
// 生成推广海报
|
||||||
async generatePoster() {
|
async generatePoster() {
|
||||||
wx.showLoading({ title: '生成中...' })
|
wx.showLoading({ title: '生成中...', mask: true })
|
||||||
this.setData({ showPosterModal: true, isGeneratingPoster: true })
|
this.setData({ showPosterModal: true, isGeneratingPoster: true })
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -196,16 +196,29 @@ Page({
|
|||||||
// 获取小程序码(带推荐人参数)
|
// 获取小程序码(带推荐人参数)
|
||||||
let qrcodeImage = null
|
let qrcodeImage = null
|
||||||
try {
|
try {
|
||||||
|
// scene格式:ref=用户ID前20位
|
||||||
const scene = userId ? `ref=${userId.slice(0,20)}` : 'ref=soul'
|
const scene = userId ? `ref=${userId.slice(0,20)}` : 'ref=soul'
|
||||||
|
console.log('[Poster] 请求小程序码, scene:', scene)
|
||||||
|
|
||||||
const qrRes = await app.request('/api/miniprogram/qrcode', {
|
const qrRes = await app.request('/api/miniprogram/qrcode', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { scene, page: 'pages/index/index', width: 280 }
|
data: {
|
||||||
|
scene,
|
||||||
|
page: 'pages/index/index',
|
||||||
|
width: 280
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (qrRes.success && qrRes.image) {
|
|
||||||
|
console.log('[Poster] 小程序码响应:', qrRes?.success, qrRes?.image?.length)
|
||||||
|
|
||||||
|
if (qrRes && qrRes.success && qrRes.image) {
|
||||||
qrcodeImage = qrRes.image
|
qrcodeImage = qrRes.image
|
||||||
|
console.log('[Poster] 小程序码获取成功')
|
||||||
|
} else {
|
||||||
|
console.log('[Poster] 响应无效:', qrRes)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('[Poster] 获取小程序码失败,使用占位符')
|
console.error('[Poster] 获取小程序码失败:', e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 海报尺寸 300x450
|
// 海报尺寸 300x450
|
||||||
|
|||||||
@@ -64,38 +64,63 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 一键获取收货地址
|
// 一键获取收货地址
|
||||||
async getAddress() {
|
getAddress() {
|
||||||
try {
|
wx.chooseAddress({
|
||||||
const res = await wx.chooseAddress()
|
success: (res) => {
|
||||||
if (res) {
|
console.log('[Settings] 获取地址成功:', res)
|
||||||
const fullAddress = `${res.provinceName}${res.cityName}${res.countyName}${res.detailInfo}`
|
const fullAddress = `${res.provinceName || ''}${res.cityName || ''}${res.countyName || ''}${res.detailInfo || ''}`
|
||||||
|
|
||||||
wx.setStorageSync('user_address', fullAddress)
|
if (fullAddress.trim()) {
|
||||||
this.setData({ address: fullAddress })
|
wx.setStorageSync('user_address', fullAddress)
|
||||||
|
this.setData({ address: fullAddress })
|
||||||
|
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
if (app.globalData.userInfo) {
|
if (app.globalData.userInfo) {
|
||||||
app.globalData.userInfo.address = fullAddress
|
app.globalData.userInfo.address = fullAddress
|
||||||
wx.setStorageSync('userInfo', app.globalData.userInfo)
|
wx.setStorageSync('userInfo', app.globalData.userInfo)
|
||||||
}
|
|
||||||
|
|
||||||
// 同步到服务器
|
|
||||||
this.syncProfileToServer()
|
|
||||||
|
|
||||||
wx.showToast({ title: '地址已获取', icon: 'success' })
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('[Settings] 获取地址失败:', e)
|
|
||||||
if (e.errMsg?.includes('auth deny')) {
|
|
||||||
wx.showModal({
|
|
||||||
title: '需要授权',
|
|
||||||
content: '请允许获取收货地址',
|
|
||||||
confirmText: '去设置',
|
|
||||||
success: (res) => {
|
|
||||||
if (res.confirm) wx.openSetting()
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
// 同步到服务器
|
||||||
|
this.syncAddressToServer(fullAddress)
|
||||||
|
|
||||||
|
wx.showToast({ title: '地址已获取', icon: 'success' })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (e) => {
|
||||||
|
console.log('[Settings] 获取地址失败:', e)
|
||||||
|
if (e.errMsg?.includes('cancel')) {
|
||||||
|
// 用户取消,不提示
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (e.errMsg?.includes('auth deny') || e.errMsg?.includes('authorize')) {
|
||||||
|
wx.showModal({
|
||||||
|
title: '需要授权',
|
||||||
|
content: '请在设置中允许获取收货地址',
|
||||||
|
confirmText: '去设置',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) wx.openSetting()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
wx.showToast({ title: '获取失败,请重试', icon: 'none' })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 同步地址到服务器
|
||||||
|
async syncAddressToServer(address) {
|
||||||
|
try {
|
||||||
|
const userId = app.globalData.userInfo?.id
|
||||||
|
if (!userId) return
|
||||||
|
|
||||||
|
await app.request('/api/user/update', {
|
||||||
|
method: 'POST',
|
||||||
|
data: { userId, address }
|
||||||
|
})
|
||||||
|
console.log('[Settings] 地址已同步到服务器')
|
||||||
|
} catch (e) {
|
||||||
|
console.log('[Settings] 同步地址失败:', e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -334,10 +359,11 @@ Page({
|
|||||||
|
|
||||||
wx.showLoading({ title: '获取中...', mask: true })
|
wx.showLoading({ title: '获取中...', mask: true })
|
||||||
|
|
||||||
// 调用服务器解密手机号
|
// 调用服务器解密手机号(传入userId以便同步到数据库)
|
||||||
|
const userId = app.globalData.userInfo?.id
|
||||||
const res = await app.request('/api/miniprogram/phone', {
|
const res = await app.request('/api/miniprogram/phone', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { code }
|
data: { code, userId }
|
||||||
})
|
})
|
||||||
|
|
||||||
wx.hideLoading()
|
wx.hideLoading()
|
||||||
|
|||||||
BIN
开发文档/10、项目管理/小程序20260129-2.pdf
Normal file
BIN
开发文档/10、项目管理/小程序20260129-2.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user