分享页面缩略图自定义
This commit is contained in:
@@ -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