海报:完善小程序码(添加前缀 data:image/png;base64,)

pull/54/head
puhui999 2024-05-25 22:20:19 +08:00
parent f46bfc6ee1
commit 2dfe61503f
9 changed files with 29 additions and 36 deletions

View File

@ -1,6 +1,6 @@
<!-- 分销中心 -->
<template>
<s-layout navbar="inner" class="index-wrap" title="分销中心" :bgStyle="bgStyle" onShareAppMessage>
<s-layout navbar="inner" class="index-wrap" title="分销中心" :bgStyle="bgStyle" :onShareAppMessage="shareInfo">
<!-- 分销商信息 -->
<commission-info />
<!-- 账户信息 -->
@ -16,14 +16,23 @@
</template>
<script setup>
import { reactive } from 'vue';
import { computed } from 'vue';
import commissionInfo from './components/commission-info.vue';
import accountInfo from './components/account-info.vue';
import commissionLog from './components/commission-log.vue';
import commissionMenu from './components/commission-menu.vue';
import commissionAuth from './components/commission-auth.vue';
import sheep from '@/sheep';
const state = reactive({});
const shareInfo = computed(() => {
return sheep.$platform.share.getShareInfo({
params: {
page: '6',
},
}, {
type: 'user',
});
});
const bgStyle = {
color: '#F7D598',

View File

@ -1,6 +1,14 @@
import request from '@/sheep/request';
const BrokerageApi = {
// 绑定推广员
bindBrokerageUser: (data)=>{
return request({
url: '/trade/brokerage-user/bind',
method: 'PUT',
data
});
},
// 获得个人分销信息
getBrokerageUser: () => {
return request({

View File

@ -5,7 +5,7 @@ import { formatImageUrlProtocol } from './index';
const goods = async (poster) => {
const width = poster.width;
const userInfo = sheep.$store('user').userInfo;
const wxa_qrcode = (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
return [
{
type: 'image',

View File

@ -5,7 +5,7 @@ import third from '@/sheep/api/migration/third';
const groupon = async (poster) => {
const width = poster.width;
const userInfo = sheep.$store('user').userInfo;
const wxa_qrcode = (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
return [
{
type: 'image',

View File

@ -30,30 +30,3 @@ export function formatImageUrlProtocol(url) {
return url;
}
export function getBase64Src(base64data, appType) {
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64data) || [];
switch (appType) {
case 'wechat':
const filePath = `${wx.env.USER_DATA_PATH}/tmp_base64src.${format}`;
return new Promise((resolve, reject) => {
const fileManager = uni.getFileSystemManager();
fileManager.writeFile({
filePath: filePath,
data: bodyData, // base64 数据
encoding: 'base64', // 字符编码
success: () => {
resolve(filePath);
},
file: (err) => {
console.log('base64 保存失败', err);
},
});
});
default:
console.warn('获得 base64 图片地址只做了微信小程序端的转换,其它端请自行实现!!!');
break;
}
}

View File

@ -5,7 +5,7 @@ import third from '@/sheep/api/migration/third';
const user = async (poster) => {
const width = poster.width;
const userInfo = sheep.$store('user').userInfo;
const wxa_qrcode = (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
return [
{
type: 'image',

View File

@ -92,6 +92,7 @@
showAuthModal();
return;
}
console.log(props.shareInfo);
unref(SharePosterRef).getPoster();
state.showPosterModal = true;
};

View File

@ -1,5 +1,5 @@
// 登录
// import third from '@/sheep/api/third';
import third from '@/sheep/api/migration/third';
import SocialApi from '@/sheep/api/member/social';
// TODO 芋艿:等后面搞 App 再弄

View File

@ -73,7 +73,7 @@ const buildSpmQuery = (params) => {
shareId = user.userInfo.id;
}
}
let page = '1'; // 页面类型: 1=首页(默认),2=商品,3=拼团商品,4=秒杀商品,5=邀请参团...按需扩展
let page = '1'; // 页面类型: 1=首页(默认),2=商品,3=拼团商品,4=秒杀商品,5=邀请参团,6=分销邀请...按需扩展
if (typeof params.page !== 'undefined') {
page = params.page;
}
@ -152,6 +152,8 @@ const decryptSpm = (spm) => {
id: shareParamsArray[2],
};
break;
case '6': // 分销
// TODO puhui999: 如果用户未登录想想怎么搞
}
shareParams.platform = platformMap[shareParamsArray[3] - 1];
shareParams.from = fromMap[shareParamsArray[4] - 1];