分享页面缩略图自定义
This commit is contained in:
@@ -184,6 +184,7 @@ class Common extends Api
|
||||
$toLabels = function ($value) {
|
||||
return array_values(array_filter(array_map('trim', explode(',', $value ?? ''))));
|
||||
};
|
||||
$shareImage = config('site.promotion_share_image') ?? '';
|
||||
$config = [
|
||||
'languageLabels' => $toLabels($code_languages),
|
||||
'frontLabels' => $toLabels($front_techs),
|
||||
@@ -192,6 +193,8 @@ class Common extends Api
|
||||
'developTypes' => $developTypes,
|
||||
// 平台服务费比例(0~1),前端据此计算开发者预计到手金额
|
||||
'platform_commission_ratio' => (float)DemandService::getPlatformCommissionRatio(),
|
||||
// 推广分享卡片预览图,未配置时为空
|
||||
'promotion_share_image' => $shareImage ? cdnurl($shareImage, true) : '',
|
||||
];
|
||||
|
||||
$this->success('', $config);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// pages/promoter/index/index.js
|
||||
import { fetchPromoterInfo, fetchPromoterOrders, fetchPromoterQrcode } from '../../../services/promoter/fetchPromoter';
|
||||
import { fetchConfig } from '../../../services/home/home';
|
||||
import { withPromoter } from '../../../utils/promoter';
|
||||
|
||||
const PAGE_SIZE = 10;
|
||||
@@ -21,11 +22,24 @@ Page({
|
||||
qrcode: '', // 推广小程序码 data URL
|
||||
qrcodeLoading: false, // 推广码生成中
|
||||
saving: false, // 保存推广码中
|
||||
shareImage: '', // 分享卡片预览图(后台配置 site.promotion_share_image),为空时微信默认截取当前页
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadOverview();
|
||||
this.loadList(true);
|
||||
this.loadShareImage();
|
||||
},
|
||||
|
||||
async loadShareImage() {
|
||||
try {
|
||||
const res = await fetchConfig();
|
||||
if (res.code === 1 && res.data?.promotion_share_image) {
|
||||
this.setData({ shareImage: res.data.promotion_share_image });
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('loadShareImage failed:', err);
|
||||
}
|
||||
},
|
||||
|
||||
async onPullDownRefresh() {
|
||||
@@ -40,10 +54,14 @@ Page({
|
||||
},
|
||||
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
const share = {
|
||||
title: '代码帮 - 软件商城与定制开发平台',
|
||||
path: withPromoter('/pages/home/home'),
|
||||
};
|
||||
if (this.data.shareImage) {
|
||||
share.imageUrl = this.data.shareImage;
|
||||
}
|
||||
return share;
|
||||
},
|
||||
|
||||
async loadOverview() {
|
||||
|
||||
Reference in New Issue
Block a user