## 一、支付:改由已安装的 epay 插件承载(不再自研签名)
- 下单:\addons\epay\library\Service::submitOrder($amount 元, $orderNo, 'wechat', $body, $notifyUrl, null, 'miniapp', $openid)
- 验签:Service::checkNotify('wechat')(内部 $pay->verify());应答:$pay->success()(v2 = XML)
- 业务编排仍在 application/api/controller/Pay.php,不改插件源码:
POST /pay/prepay(取调起参数,下发前剔除 appId);POST /pay/notify(公开路由:插件验签 → 金额核对 → 幂等分派)
- 配置真源 = addons/epay/config.php(后台「插件管理 → 微信支付宝整合插件 → 配置」);
fc_config 的 wx.mchId / wx.apiKey / wx.payNotifyUrl 废弃;后台「系统设置」支付表单改只读并跳插件配置页
- 插件 API 保持 version=v2(PHP 7.4 可跑);certs/* 为 0 字节占位,不含任何真实密钥
- 修复 BUG-015:Pay::notify() 与基类站内信同名且签名不兼容导致 /pay/* 全 500,动作改名 notifyCallback()
## 二、插件纳入 Git 版本管理
- .gitignore 移除 /addons/* 与 /public/assets/addons/*(保留 .gitkeep 占位)
- 入库 addons/epay、addons/wechat、public/assets/addons/*、addons/.htaccess(deny from all)
- config.php 入库为空白模板;服务器请在填好密钥后执行
git update-index --skip-worktree addons/epay/config.php,避免真实密钥回传仓库
## 三、安全修复:余额充值资损(高危,已实测复现)
- 现象:POST /order/recharge {payType:'balance'} 只加余额不扣款(余额 134.50 → 1022.50),等于凭空增发余额,
可再去买会员 / 付费发布 / 解锁联系方式
- 修复:/order/recharge 仅接受 payType=wxpay,balance → 「余额充值仅支持微信支付」,其它 → 「支付方式不支持」;
订单恒为 status=pending、pay_type=wxpay、paytime=null;入账只发生在 /pay/notify 回调(Order::creditRecharge)
或后台「会员管理 → 余额充值」(fc/userext/recharge)
- 小程序充值页同步为「仅微信支付」+ 防重复提交 + onShow 刷新资产;mock / 用例 / 文档同步
## 四、其他 v1.1.0 能力
- 媒体上传:POST /post/upload(图片 ≤10MB / 视频 ≤50MB,真落盘),发布页 uni.uploadFile 真上传
- LBS:fc_post.lat/lng、首页 sort=nearby(距离升序、无坐标排最后)、卡片 distance、详情页地图
- 互动:举报 POST /report(原因字典)、收藏 / 关注(fc_favorite / fc_follow、/favorite/*、/follow/toggle)
- 交易:余额充值 POST /order/recharge、优惠券 /coupon/list|receive(fc_coupon / fc_user_coupon、我的资产券)
- 发布计费:会员发布折扣(discountRate/discountText)+ 免费发布条数(freeQuota*)
- 后台新增:数据总览 fc/dashboard、系统设置 fc/setting、优惠券管理 fc/coupon(含菜单与权限节点)
## 五、本批审核修复
- 详情页:游客不再请求登录态接口(避免 401 被清 token 踢去登录);微信付费查看改为支付后轮询解锁,
不再读取 wxpay 分支未返回的 contact;加防重复提交
- 发布页:freeLeftToday → freeQuotaLeft / freeQuotaCycle / freeUnlimited(对齐后端出参);
上传图预览拼后端域名(新增 format.js#assetUrl,后端返回相对路径)
- 收藏空态「去首页」:switchTab → reLaunch(项目用自绘 fc-tabbar,无 tabBar,switchTab 必然失败)
- 会员券 days=0 显示「永久有效」;manifest.json 补 requiredPrivateInfos(getLocation / chooseLocation)
- 后端:publishConfig 补 discountRate/discountText 与 memberPostDiscountText();优惠券总开关 coupon.enabled
真生效(关闭后 list/receive 拒绝);后台 fc/Coupon 的 add/edit 补 strip_tags 过滤(防存储型 XSS)、
补 searchFields='name',列表 name 列再做一次 HTML 转义
- FcInstall:补清理后台菜单缓存 __menu__(否则新菜单要等缓存过期才显示),并同步 README 说明
- 后台语言包 fc/setting.php 按「支付只读 + 跳插件配置」的新页面重写
- 文档同步:uniapp/docs/{01,03,04}、uniapp/README.md、docs/05-后端实现规范.md、后台 README 上线步骤
## 六、校验结果(全部通过)
- 后端端到端:tools/verify-api.mjs 226/226(含新增「拒绝余额充值(资损防护)」用例)
- 小程序:uniapp/tests/run.mjs 167/167;validate.mjs 0 错 0 警;check-scss 19/19
- 后台:check-admin-i18n 0 错 0 警;check-theme 0 错 0 警;9 个页面 HTTP 200 全中文
- php -l 改动/新增 PHP 文件 0 语法错误;探针复测:余额不再增长、epay 插件下单/验签链路通
809 行
24 KiB
Vue
809 行
24 KiB
Vue
<template>
|
||
<view class="create fc-page">
|
||
<!-- 分类 -->
|
||
<view class="fc-card create__section">
|
||
<view class="create__label">选择分类<text class="create__required">*</text></view>
|
||
<view class="create__cats">
|
||
<view v-for="c in categories" :key="c.id" class="create__cat"
|
||
:class="{ 'create__cat--active': form.categoryId === c.id }" @click="form.categoryId = c.id">
|
||
<image class="create__cat-icon" :src="catIcon(c)" mode="aspectFit" />
|
||
<text class="create__cat-name">{{ c.name }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 表单 -->
|
||
<view class="fc-card create__section">
|
||
<view class="create__label">标题<text class="create__required">*</text></view>
|
||
<input v-model="form.title" class="create__input" placeholder="一句话说明你的信息(如:急招快递分拣员日结)"
|
||
maxlength="40" placeholder-class="create__ph" @input="autoSave" />
|
||
|
||
<view class="create__label create__label--mt">详细内容<text class="create__required">*</text></view>
|
||
<textarea v-model="form.content" class="create__textarea" placeholder="补充价格、时间、要求等细节,描述越详细越容易成交"
|
||
maxlength="500" placeholder-class="create__ph" @input="autoSave" />
|
||
<text class="create__count">{{ (form.content || '').length }}/500</text>
|
||
|
||
<view class="create__label create__label--mt">图片 / 视频</view>
|
||
<view class="create__media">
|
||
<view v-for="(m, i) in form.media" :key="m + i" class="create__media-item fc-thumb">
|
||
<image v-if="!isVideo(m)" class="create__media-img" :src="assetUrl(m)" mode="aspectFill" />
|
||
<view v-else class="create__media-video">
|
||
<image class="fc-icon fc-icon--md" :src="iconUrl('plus-ink')" mode="aspectFit" />
|
||
<text class="create__media-video-txt">视频</text>
|
||
</view>
|
||
<view class="create__media-del" @click.stop="removeMedia(i)">
|
||
<text>×</text>
|
||
</view>
|
||
</view>
|
||
<view v-if="!uploading && imageCount < 6" class="create__upload" @click="chooseImage">
|
||
<image class="fc-icon fc-icon--md" :src="iconUrl('plus-ink')" mode="aspectFit" />
|
||
<text class="create__upload-txt">图片 {{ imageCount }}/6</text>
|
||
</view>
|
||
<view v-if="!uploading && videoCount < 1" class="create__upload" @click="chooseVideo">
|
||
<image class="fc-icon fc-icon--md" :src="iconUrl('plus-ink')" mode="aspectFit" />
|
||
<text class="create__upload-txt">视频 {{ videoCount }}/1</text>
|
||
</view>
|
||
</view>
|
||
<text v-if="uploading" class="create__uploading">媒体上传中,请稍候…</text>
|
||
</view>
|
||
|
||
<!-- 联系方式 -->
|
||
<view class="fc-card create__section">
|
||
<view class="create__row">
|
||
<text class="create__row-label">联系人</text>
|
||
<input v-model="form.contact" class="create__input create__input--row" placeholder="请输入称呼"
|
||
placeholder-class="create__ph" />
|
||
</view>
|
||
<view class="create__row create__row--line">
|
||
<text class="create__row-label">联系电话</text>
|
||
<input v-model="form.phone" class="create__input create__input--row" type="number" maxlength="11"
|
||
placeholder="请输入手机号" placeholder-class="create__ph" />
|
||
</view>
|
||
<view class="create__row create__row--line" @click="chooseLocation">
|
||
<text class="create__row-label">所在区域</text>
|
||
<view class="create__location">
|
||
<image class="fc-icon fc-icon--sm" :src="iconUrl('location')" mode="aspectFit" />
|
||
<text class="create__location-text fc-ellipsis">{{ form.address || '点击定位/选择区域' }}</text>
|
||
<text class="create__location-arrow">›</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 发布方式:由后台「发布与费用配置」决定(免费发布 / 付费发布 + 套餐额度) -->
|
||
<view class="fc-card create__section">
|
||
<view class="create__label-row">
|
||
<text class="create__label">发布方式</text>
|
||
<text v-if="publish.mode === 'paid'" class="create__quota">
|
||
套餐额度:剩余 {{ publish.quotaLeft }} 条
|
||
</text>
|
||
</view>
|
||
|
||
<view v-if="publish.mode === 'free'" class="create__free-tip">
|
||
<text>当前为免费发布,所有用户均可免费发布信息</text>
|
||
</view>
|
||
|
||
<view v-else class="create__plans">
|
||
<view v-for="p in plans" :key="p.key" class="create__plan"
|
||
:class="{ 'create__plan--active': form.plan === p.key }" @click="form.plan = p.key">
|
||
<text class="create__plan-name">{{ p.name }}</text>
|
||
<text class="create__plan-price">{{ p.price }}</text>
|
||
<text class="create__plan-desc">{{ p.desc }}</text>
|
||
<text v-if="p.tag" class="create__plan-tag">{{ p.tag }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view v-if="needPay" class="create__pay">
|
||
<text class="create__pay-label">支付方式</text>
|
||
<view class="create__pay-types">
|
||
<view class="create__pay-type" :class="{ 'create__pay-type--active': form.payType === 'wxpay' }"
|
||
@click="form.payType = 'wxpay'">
|
||
<image class="fc-icon fc-icon--sm" :src="iconUrl('paywechat')" mode="aspectFit" />
|
||
<text class="create__pay-text">微信支付</text>
|
||
</view>
|
||
<view class="create__pay-type" :class="{ 'create__pay-type--active': form.payType === 'balance' }"
|
||
@click="form.payType = 'balance'">
|
||
<image class="fc-icon fc-icon--sm" :src="iconUrl('wallet')" mode="aspectFit" />
|
||
<text class="create__pay-text">余额支付(¥{{ balance }})</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 草稿箱 -->
|
||
<view v-if="drafts.length" class="fc-card create__section">
|
||
<view class="create__draft-head">
|
||
<text class="create__label">草稿箱</text>
|
||
<text class="create__draft-tip">自动保存,可再次编辑发布</text>
|
||
</view>
|
||
<view v-for="d in drafts" :key="d.draftId" class="create__draft" @click="restoreDraft(d)">
|
||
<text class="create__draft-title fc-ellipsis">{{ d.title }}</text>
|
||
<text class="create__draft-arrow">编辑 ›</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="create__bar">
|
||
<view class="create__bar-ghost" @click="saveDraft">
|
||
<text>存草稿</text>
|
||
</view>
|
||
<view class="create__bar-main" :class="{ 'create__bar-main--disabled': submitting }" @click="submit">
|
||
<text>{{ submitting ? '提交中…' : (needPay ? '支付并发布' : '免费发布') }}</text>
|
||
</view>
|
||
</view>
|
||
<view class="fc-safe-bottom"></view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import homeApi from '@/common/api/home.js'
|
||
import postApi from '@/common/api/post.js'
|
||
import memberApi from '@/common/api/member.js'
|
||
import { useUserStore } from '@/common/store/index.js'
|
||
import { iconUrl, categoryIconUrl, loadUiConfig } from '@/common/store/ui.js'
|
||
import { pay } from '@/common/utils/pay.js'
|
||
import { assetUrl } from '@/common/utils/format.js'
|
||
import config from '@/common/config/index.js'
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
categories: [],
|
||
drafts: [],
|
||
submitting: false,
|
||
uploading: false,
|
||
draftTimer: null,
|
||
form: {
|
||
categoryId: 0,
|
||
title: '',
|
||
content: '',
|
||
media: [],
|
||
contact: '',
|
||
phone: '',
|
||
address: '',
|
||
lat: null,
|
||
lng: null,
|
||
plan: 'free',
|
||
payType: config.defaultPayType,
|
||
},
|
||
// 发布配置(后台「发布与费用配置」下发:发布模式 / 价格 / 我的剩余额度 / 会员折扣率)
|
||
publish: {
|
||
mode: 'paid',
|
||
singlePrice: 5,
|
||
discountRate: 1,
|
||
discountText: '',
|
||
monthPrice: 19.9,
|
||
monthQuota: 30,
|
||
yearPrice: 168,
|
||
yearQuota: 500,
|
||
quotaLeft: 0,
|
||
freePerDay: 0,
|
||
freeUsedToday: 0,
|
||
// 免费发布条数剩余(后端 post.freeQuota / freeQuotaCycle;-1 = 不限制)
|
||
freeQuotaLeft: 0,
|
||
freeQuotaCycle: 'daily',
|
||
freeUnlimited: false,
|
||
isMember: false,
|
||
},
|
||
}
|
||
},
|
||
computed: {
|
||
balance() {
|
||
try {
|
||
return useUserStore().state.userInfo?.balance ?? 0
|
||
} catch (e) {
|
||
return 0
|
||
}
|
||
},
|
||
/** 已选图片数量(视频单独计数,最多 1 个) */
|
||
imageCount() {
|
||
return this.form.media.filter((m) => !this.isVideo(m)).length
|
||
},
|
||
videoCount() {
|
||
return this.form.media.filter((m) => this.isVideo(m)).length
|
||
},
|
||
/** 会员折扣率(服务端下发,未下发时视作 1;不得前端写死) */
|
||
discountRate() {
|
||
const r = Number(this.publish.discountRate)
|
||
return r > 0 && r <= 1 ? r : 1
|
||
},
|
||
/** 单条发布折后金额(展示用;实付金额仍由服务端计算) */
|
||
singlePriceFinal() {
|
||
return Math.round(Number(this.publish.singlePrice || 0) * this.discountRate * 100) / 100
|
||
},
|
||
/** 折扣文案(如「8 折」),无折扣时为空 */
|
||
discountLabel() {
|
||
return this.discountRate < 1 ? this.publish.discountText || `${Math.round(this.discountRate * 100) / 10} 折` : ''
|
||
},
|
||
/** 发布方式选项:由后台配置生成(免费模式不展示;付费模式按剩余额度插入「套餐额度」) */
|
||
plans() {
|
||
const p = this.publish
|
||
if (p.mode === 'free') return []
|
||
const list = []
|
||
// 免费发布条数:字段名与后端 publishConfig 对齐(freeQuotaLeft / freeQuotaCycle / freeUnlimited)
|
||
const freeLeft = Number(p.freeQuotaLeft)
|
||
const freeUnlimited = p.freeUnlimited === true || freeLeft === -1
|
||
if (p.quotaLeft > 0) {
|
||
list.push({ key: 'quota', name: '套餐额度', price: '免费', desc: `剩余 ${p.quotaLeft} 条`, tag: '可用' })
|
||
} else if (freeUnlimited || freeLeft > 0) {
|
||
const cycle = { daily: '今日', monthly: '本月', total: '累计' }[p.freeQuotaCycle] || '本期'
|
||
list.push({
|
||
key: 'quota',
|
||
name: `${cycle}免费`,
|
||
price: '免费',
|
||
desc: freeUnlimited ? '不限条数' : `${cycle}剩余 ${freeLeft} 条`,
|
||
tag: '可用',
|
||
})
|
||
}
|
||
list.push({
|
||
key: 'single',
|
||
name: '会员单条',
|
||
price: `¥${this.money(this.singlePriceFinal)}`,
|
||
desc: this.discountLabel ? `${this.discountLabel}(原价 ¥${this.money(p.singlePrice)})` : '发布 1 条',
|
||
tag: this.discountLabel ? '会员价' : '',
|
||
})
|
||
list.push({ key: 'month', name: '按月发布', price: `¥${this.money(p.monthPrice)}`, desc: `含 ${p.monthQuota} 条`, tag: '推荐' })
|
||
list.push({ key: 'year', name: '按年发布', price: `¥${this.money(p.yearPrice)}`, desc: `含 ${p.yearQuota} 条`, tag: '更划算' })
|
||
return list
|
||
},
|
||
needPay() {
|
||
return this.publish.mode === 'paid' && this.form.plan !== 'quota'
|
||
},
|
||
},
|
||
onLoad(query) {
|
||
if (query && query.categoryId) this.form.categoryId = Number(query.categoryId)
|
||
loadUiConfig()
|
||
this.init()
|
||
},
|
||
methods: {
|
||
iconUrl,
|
||
// 上传/后端返回的是相对路径,展示前拼后端域名(否则小程序按包内路径解析 → 裂图)
|
||
assetUrl,
|
||
// 分类图标:优先用后端下发的 iconKey(支持后台自定义覆盖),
|
||
// 否则按分类 ID 映射内置配图(与 post/list.vue 保持同一套逻辑)
|
||
catIcon(c) {
|
||
return (c.iconKey && iconUrl(c.iconKey)) || categoryIconUrl(c.id)
|
||
},
|
||
async init() {
|
||
try {
|
||
const [cats, drafts] = await Promise.all([homeApi.categories(), postApi.drafts()])
|
||
this.categories = cats
|
||
this.drafts = drafts
|
||
if (!this.form.categoryId && cats.length) this.form.categoryId = cats[0].id
|
||
} catch (e) {
|
||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||
}
|
||
this.loadPublish()
|
||
},
|
||
/** 读取后台发布的「发布模式 / 价格 / 我的剩余额度」 */
|
||
async loadPublish() {
|
||
try {
|
||
const p = await postApi.publishConfig()
|
||
this.publish = { ...this.publish, ...p }
|
||
// 默认选中:免费模式→免费;付费模式有额度/每日免费次数→用免费额度,否则按单条
|
||
if (p.mode === 'free') {
|
||
this.form.plan = 'free'
|
||
} else {
|
||
const freeAvailable = p.quotaLeft > 0 || p.freeUnlimited === true || Number(p.freeQuotaLeft) > 0
|
||
this.form.plan = freeAvailable ? 'quota' : 'single'
|
||
}
|
||
} catch (e) {
|
||
// 配置读取失败时保持付费模式默认值,由后端兜底校验(不会漏收费)
|
||
}
|
||
},
|
||
money(v) {
|
||
const n = Number(v || 0)
|
||
return Number.isInteger(n) ? String(n) : n.toFixed(2)
|
||
},
|
||
/** 是否为视频地址(按扩展名判定,用于缩略图/计数) */
|
||
isVideo(url) {
|
||
return /\.(mp4|mov|m4v|avi|webm|mkv)(\?|$)/i.test(String(url || ''))
|
||
},
|
||
/** 选图片(最多 6 张)→ 逐张真上传 */
|
||
chooseImage() {
|
||
if (this.uploading) return
|
||
const remain = 6 - this.imageCount
|
||
if (remain <= 0) return uni.showToast({ title: '最多上传 6 张图片', icon: 'none' })
|
||
uni.chooseImage({
|
||
count: remain,
|
||
success: async (res) => {
|
||
await this.uploadFiles(res.tempFilePaths || [], 'image')
|
||
},
|
||
})
|
||
},
|
||
/** 选视频(最多 1 个)→ 真上传 */
|
||
chooseVideo() {
|
||
if (this.uploading) return
|
||
if (this.videoCount >= 1) return uni.showToast({ title: '最多上传 1 个视频', icon: 'none' })
|
||
uni.chooseVideo({
|
||
maxDuration: 60,
|
||
success: async (res) => {
|
||
await this.uploadFiles([res.tempFilePath], 'video')
|
||
},
|
||
})
|
||
},
|
||
/**
|
||
* 真上传:uni.uploadFile → POST /post/upload(Authorization: Bearer <token>)
|
||
* 上传中显示 loading;成功把返回的 url 存入 form.media;失败 Toast 且不入列表。
|
||
*/
|
||
async uploadFiles(paths, type) {
|
||
if (!paths.length) return
|
||
this.uploading = true
|
||
uni.showLoading({ title: '上传中…', mask: true })
|
||
try {
|
||
for (const p of paths) {
|
||
const up = await postApi.uploadMedia(p, type)
|
||
if (up && up.url) this.form.media.push(up.url)
|
||
}
|
||
this.autoSave()
|
||
uni.hideLoading()
|
||
uni.showToast({ title: '上传成功', icon: 'none' })
|
||
} catch (e) {
|
||
// 失败:Toast 且不写入 form.media(不再使用 local://demo.jpg 这类假兜底)
|
||
uni.hideLoading()
|
||
uni.showToast({ title: e.message || '上传失败', icon: 'none' })
|
||
} finally {
|
||
this.uploading = false
|
||
}
|
||
},
|
||
removeMedia(i) {
|
||
this.form.media.splice(i, 1)
|
||
this.autoSave()
|
||
},
|
||
chooseLocation() {
|
||
uni.chooseLocation({
|
||
success: (res) => {
|
||
this.form.address = res.address || res.name
|
||
// 契约 §2.1:发布可带 lat/lng,用于首页「附近」排序与详情地图导航
|
||
this.form.lat = typeof res.latitude === 'number' ? res.latitude : null
|
||
this.form.lng = typeof res.longitude === 'number' ? res.longitude : null
|
||
this.autoSave()
|
||
},
|
||
fail: () => {
|
||
uni.showActionSheet({
|
||
itemList: ['云岩区', '南明区', '观山湖区', '花溪区'],
|
||
success: (r) => {
|
||
this.form.address = ['云岩区', '南明区', '观山湖区', '花溪区'][r.tapIndex]
|
||
this.autoSave()
|
||
},
|
||
fail: () => {},
|
||
})
|
||
},
|
||
})
|
||
},
|
||
autoSave() {
|
||
if (this.draftTimer) clearTimeout(this.draftTimer)
|
||
// 草稿箱:编辑中自动保存(防抖 800ms)
|
||
this.draftTimer = setTimeout(() => {
|
||
if (this.form.title || this.form.content) this.saveDraft(true)
|
||
}, 800)
|
||
},
|
||
async saveDraft(silent = false) {
|
||
if (!this.form.title && !this.form.content) {
|
||
if (!silent) uni.showToast({ title: '内容为空,无法保存', icon: 'none' })
|
||
return
|
||
}
|
||
try {
|
||
await postApi.saveDraft({ ...this.form })
|
||
if (!silent) {
|
||
uni.showToast({ title: '已存入草稿箱', icon: 'none' })
|
||
this.drafts = await postApi.drafts()
|
||
}
|
||
} catch (e) {
|
||
if (!silent) uni.showToast({ title: e.message, icon: 'none' })
|
||
}
|
||
},
|
||
restoreDraft(d) {
|
||
this.form = { ...this.form, ...d }
|
||
uni.showToast({ title: '草稿已恢复', icon: 'none' })
|
||
},
|
||
validate() {
|
||
if (!this.form.categoryId) return '请选择分类'
|
||
if (!this.form.title) return '请填写标题'
|
||
if (!this.form.content) return '请填写详细内容'
|
||
if (this.form.phone && !/^1\d{10}$/.test(this.form.phone)) return '手机号格式不正确'
|
||
return ''
|
||
},
|
||
async submit() {
|
||
if (this.submitting) return
|
||
if (this.uploading) {
|
||
uni.showToast({ title: '媒体上传中,请稍候', icon: 'none' })
|
||
return
|
||
}
|
||
const err = this.validate()
|
||
if (err) {
|
||
uni.showToast({ title: err, icon: 'none' })
|
||
return
|
||
}
|
||
this.submitting = true
|
||
try {
|
||
const plan = this.publish.mode === 'free' ? 'free' : this.form.plan
|
||
// 月卡/年卡:先开通会员套餐(含发布条数,复用会员开通接口),额度到账后再按「额度内免费」发布
|
||
if (plan === 'month' || plan === 'year') {
|
||
const opened = await memberApi.open({
|
||
planId: plan === 'month' ? 'M1' : 'M12',
|
||
payType: this.form.payType,
|
||
})
|
||
// 微信支付:下单拿到 orderNo 后先 /pay/prepay 再 requestPayment
|
||
if (this.form.payType === config.constants.PAY_TYPE.WXPAY && opened && opened.orderNo) {
|
||
await pay({ orderNo: opened.orderNo, payType: this.form.payType })
|
||
}
|
||
await useUserStore().fetchProfile()
|
||
}
|
||
// 传给后端只两种:free(免费/额度内/刚开通套餐)与 single(单条付费);金额由服务端算
|
||
const apiPlan = (plan === 'free' || plan === 'quota' || plan === 'month' || plan === 'year') ? 'free' : plan
|
||
const res = await postApi.create({
|
||
...this.form,
|
||
// media 为上传后的 URL 数组;lat/lng 为选择定位时的坐标
|
||
media: this.form.media,
|
||
plan: apiPlan,
|
||
payType: this.form.payType,
|
||
})
|
||
if (res.order) {
|
||
await pay(res.order)
|
||
}
|
||
if (typeof res.quotaLeft === 'number') this.publish.quotaLeft = res.quotaLeft
|
||
uni.showToast({ title: '发布成功,等待审核', icon: 'none' })
|
||
// 发布后直接进「我的发布」,可立刻看到审核状态(原先跳首页看不到自己的发布)
|
||
setTimeout(() => uni.reLaunch({ url: '/pages/post/mine' }), 800)
|
||
} catch (e) {
|
||
uni.showToast({ title: e.message || '发布失败', icon: 'none' })
|
||
} finally {
|
||
this.submitting = false
|
||
}
|
||
},
|
||
},
|
||
}
|
||
</script>
|
||
|
||
|
||
<style lang="scss" scoped>
|
||
.create {
|
||
padding-bottom: 200rpx;
|
||
}
|
||
.create__section {
|
||
margin-top: 24rpx;
|
||
}
|
||
.create__label {
|
||
font-size: $fc-font-lg;
|
||
font-weight: 700;
|
||
color: $fc-text;
|
||
&--mt {
|
||
margin-top: 32rpx;
|
||
}
|
||
}
|
||
.create__label-row {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
.create__quota {
|
||
font-size: $fc-font-sm;
|
||
color: $fc-primary-text;
|
||
font-weight: 600;
|
||
}
|
||
.create__free-tip {
|
||
margin-top: 18rpx;
|
||
padding: 20rpx 24rpx;
|
||
border-radius: $fc-radius;
|
||
background: $fc-primary-lighter;
|
||
font-size: $fc-font-sm;
|
||
color: $fc-primary-text;
|
||
line-height: 1.5;
|
||
}
|
||
.create__required {
|
||
color: $fc-danger;
|
||
margin-left: 6rpx;
|
||
}
|
||
.create__cats {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
margin-top: 20rpx;
|
||
}
|
||
.create__cat {
|
||
width: 23%;
|
||
margin: 0 1% 18rpx;
|
||
padding: 18rpx 0;
|
||
border-radius: $fc-radius;
|
||
background: $fc-bg;
|
||
border: 2rpx solid transparent;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
&--active {
|
||
background: $fc-primary-lighter;
|
||
border-color: $fc-primary-text;
|
||
}
|
||
}
|
||
.create__cat-icon {
|
||
width: 64rpx;
|
||
height: 64rpx;
|
||
margin-bottom: 6rpx;
|
||
}
|
||
.create__cat-name {
|
||
margin-top: 8rpx;
|
||
font-size: $fc-font-xs;
|
||
color: $fc-text-regular;
|
||
}
|
||
.create__input {
|
||
margin-top: 16rpx;
|
||
height: 84rpx;
|
||
background: $fc-bg;
|
||
border-radius: $fc-radius;
|
||
padding: 0 24rpx;
|
||
font-size: $fc-font;
|
||
&--row {
|
||
margin-top: 0;
|
||
background: transparent;
|
||
flex: 1;
|
||
text-align: right;
|
||
}
|
||
}
|
||
.create__ph {
|
||
color: $fc-text-placeholder;
|
||
font-size: $fc-font-sm;
|
||
}
|
||
.create__textarea {
|
||
margin-top: 16rpx;
|
||
width: 100%;
|
||
height: 240rpx;
|
||
background: $fc-bg;
|
||
border-radius: $fc-radius;
|
||
padding: 22rpx 24rpx;
|
||
font-size: $fc-font;
|
||
}
|
||
.create__count {
|
||
display: block;
|
||
text-align: right;
|
||
margin-top: 8rpx;
|
||
font-size: $fc-font-xs;
|
||
color: $fc-text-placeholder;
|
||
}
|
||
.create__media {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
margin-top: 16rpx;
|
||
}
|
||
.create__media-item {
|
||
width: 150rpx;
|
||
height: 150rpx;
|
||
margin: 0 16rpx 16rpx 0;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
position: relative;
|
||
background: $fc-bg;
|
||
border-radius: 20rpx;
|
||
overflow: hidden;
|
||
}
|
||
.create__media-img {
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
.create__media-video {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
.create__media-video-txt {
|
||
margin-top: 6rpx;
|
||
font-size: $fc-font-xs;
|
||
color: $fc-primary-text;
|
||
}
|
||
.create__media-del {
|
||
position: absolute;
|
||
top: 0;
|
||
right: 0;
|
||
width: 40rpx;
|
||
height: 40rpx;
|
||
border-radius: 0 0 0 20rpx;
|
||
background: rgba(4, 48, 30, 0.6);
|
||
color: #ffffff;
|
||
font-size: 28rpx;
|
||
line-height: 40rpx;
|
||
text-align: center;
|
||
}
|
||
.create__uploading {
|
||
display: block;
|
||
margin-top: 8rpx;
|
||
font-size: $fc-font-xs;
|
||
color: $fc-primary-text;
|
||
}
|
||
.create__upload {
|
||
width: 150rpx;
|
||
height: 150rpx;
|
||
border-radius: 20rpx;
|
||
border: 2rpx dashed $fc-primary-text;
|
||
background: $fc-bg;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
.create__upload-txt {
|
||
margin-top: 6rpx;
|
||
font-size: $fc-font-xs;
|
||
color: $fc-primary-text;
|
||
}
|
||
.create__row {
|
||
display: flex;
|
||
align-items: center;
|
||
height: 92rpx;
|
||
&--line {
|
||
border-top: 2rpx solid $fc-border;
|
||
}
|
||
}
|
||
.create__row-label {
|
||
width: 170rpx;
|
||
font-size: $fc-font;
|
||
color: $fc-text-regular;
|
||
}
|
||
.create__location {
|
||
flex: 1;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
}
|
||
.create__location-text {
|
||
font-size: $fc-font;
|
||
color: $fc-text;
|
||
max-width: 380rpx;
|
||
margin-left: 8rpx;
|
||
}
|
||
.create__location-arrow {
|
||
margin-left: 8rpx;
|
||
color: $fc-text-placeholder;
|
||
}
|
||
.create__plans {
|
||
display: flex;
|
||
margin-top: 20rpx;
|
||
}
|
||
.create__plan {
|
||
flex: 1;
|
||
position: relative;
|
||
border: 2rpx solid $fc-border;
|
||
border-radius: $fc-radius-lg;
|
||
padding: 24rpx 16rpx;
|
||
background: $fc-bg;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
&:not(:last-child) {
|
||
margin-right: 16rpx;
|
||
}
|
||
&--active {
|
||
border-color: $fc-primary-text;
|
||
background: $fc-primary-lighter;
|
||
}
|
||
}
|
||
.create__plan-name {
|
||
font-size: $fc-font-sm;
|
||
color: $fc-text-regular;
|
||
}
|
||
.create__plan-price {
|
||
margin-top: 8rpx;
|
||
font-size: 34rpx;
|
||
font-weight: 700;
|
||
color: $fc-price;
|
||
}
|
||
.create__plan-desc {
|
||
margin-top: 4rpx;
|
||
font-size: 20rpx;
|
||
color: $fc-text-secondary;
|
||
}
|
||
.create__plan-tag {
|
||
position: absolute;
|
||
top: -12rpx;
|
||
right: 12rpx;
|
||
padding: 2rpx 12rpx;
|
||
border-radius: $fc-radius-pill;
|
||
background: $fc-gradient-warm;
|
||
color: #ffffff;
|
||
font-size: 18rpx;
|
||
}
|
||
.create__pay {
|
||
margin-top: 28rpx;
|
||
}
|
||
.create__pay-label {
|
||
font-size: $fc-font-sm;
|
||
color: $fc-text-secondary;
|
||
}
|
||
.create__pay-types {
|
||
display: flex;
|
||
margin-top: 14rpx;
|
||
}
|
||
.create__pay-type {
|
||
flex: 1;
|
||
height: 80rpx;
|
||
border-radius: $fc-radius;
|
||
border: 2rpx solid $fc-border;
|
||
background: $fc-bg;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-size: $fc-font-sm;
|
||
color: $fc-text-regular;
|
||
&:first-child {
|
||
margin-right: 16rpx;
|
||
}
|
||
&--active {
|
||
border-color: $fc-primary-text;
|
||
background: $fc-primary-lighter;
|
||
color: $fc-primary-text;
|
||
font-weight: 600;
|
||
}
|
||
}
|
||
.create__pay-text {
|
||
margin-left: 10rpx;
|
||
}
|
||
.create__draft-head {
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
}
|
||
.create__draft-tip {
|
||
font-size: $fc-font-xs;
|
||
color: $fc-text-placeholder;
|
||
}
|
||
.create__draft {
|
||
margin-top: 18rpx;
|
||
height: 84rpx;
|
||
border-radius: $fc-radius;
|
||
background: $fc-bg;
|
||
padding: 0 24rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
.create__draft-title {
|
||
flex: 1;
|
||
font-size: $fc-font;
|
||
color: $fc-text;
|
||
margin-right: 16rpx;
|
||
}
|
||
.create__draft-arrow {
|
||
font-size: $fc-font-sm;
|
||
color: $fc-primary-text;
|
||
}
|
||
.create__bar {
|
||
position: fixed;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 16rpx 24rpx;
|
||
background: #ffffff;
|
||
border-top: 2rpx solid $fc-border;
|
||
box-shadow: 0 -6rpx 24rpx rgba(4, 48, 30, 0.08);
|
||
}
|
||
.create__bar-ghost {
|
||
width: 190rpx;
|
||
height: 88rpx;
|
||
margin-right: 20rpx;
|
||
border-radius: $fc-radius-pill;
|
||
border: 2rpx solid $fc-primary-text;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
color: $fc-primary-text;
|
||
font-size: $fc-font;
|
||
}
|
||
.create__bar-main {
|
||
flex: 1;
|
||
height: 88rpx;
|
||
border-radius: $fc-radius-pill;
|
||
background: $fc-gradient-primary;
|
||
color: $fc-primary-ink;
|
||
font-size: 30rpx;
|
||
font-weight: 700;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-shadow: 0 8rpx 24rpx rgba(4, 48, 30, 0.3);
|
||
&--disabled {
|
||
opacity: 0.7;
|
||
}
|
||
}
|
||
</style>
|
||
|