Commit 3dbd64ac by yuzhenWang

Merge branch 'uat' into 'master'

Uat

See merge request !60
parents b04da0a6 ae1170b8
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import {interceptor} from "@/util/interceptor"; import {interceptor} from "@/util/interceptor";
import {baseURL,apiURL,cffpURL,companyInfo} from "@/environments/environment"; import {baseURL,apiURL,cffpURL,companyInfo} from "@/environments/environment";
import api from './api/api'; import api from './api/api';
import {hshare} from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -12,6 +13,7 @@ ...@@ -12,6 +13,7 @@
onLaunch: function() { onLaunch: function() {
console.log('App Launch'); console.log('App Launch');
if(!uni.getStorageSync('loginType')){ if(!uni.getStorageSync('loginType')){
console.log('走进来了');
uni.clearStorageSync(); uni.clearStorageSync();
uni.setStorageSync('loginType','visitor'); uni.setStorageSync('loginType','visitor');
} }
...@@ -115,7 +117,8 @@ ...@@ -115,7 +117,8 @@
'/pages/courseDetail/courseDetail', '/pages/courseDetail/courseDetail',
'/pages/orderDetail/orderDetail', '/pages/orderDetail/orderDetail',
'/pages/orderStatus/orderStatus', '/pages/orderStatus/orderStatus',
'/pages/index/index' '/pages/index/index',
'/myPackageA/poster/poster',
] // 根据需要调整 ] // 根据需要调整
if(!whiteList.includes(currentRoute)) { if(!whiteList.includes(currentRoute)) {
uni.navigateTo({ uni.navigateTo({
...@@ -130,20 +133,38 @@ ...@@ -130,20 +133,38 @@
mobile: res['data']['mobile'], mobile: res['data']['mobile'],
partnerType:res['data']['partnerType'], partnerType:res['data']['partnerType'],
nickName:res['data']['nickName'], nickName:res['data']['nickName'],
levelCode:res['data']['levelCode'],
} }
uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo)) uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo))
uni.setStorageSync('userinfodataForm', res.data);
} }
} catch (err) { } catch (err) {
console.error('检查用户状态失败:', err); console.error('检查用户状态失败:', err);
} }
} return
}else {
this.checkToken()
}
}, },
// 清除登录状态 // 清除登录状态
clearLoginState() { clearLoginState() {
uni.clearStorageSync(); uni.clearStorageSync();
uni.setStorageSync('loginType', 'visitor'); uni.setStorageSync('loginType', 'visitor');
this.checkToken()
// 可以在这里添加其他需要清除的状态 // 可以在这里添加其他需要清除的状态
}, },
// 未登录状态下需要重新获取token
checkToken(){
api.checkToken().then(res=>{
if(res['success']){}else{
api.obtainToken().then(res=>{
if(res.success){
uni.setStorageSync('uni-token',res.data['token']);
}
})
}
})
},
// 处理外部链接参数 // 处理外部链接参数
handleExternalUrlParams() { handleExternalUrlParams() {
// #ifdef H5 // #ifdef H5
......
...@@ -175,6 +175,7 @@ ...@@ -175,6 +175,7 @@
mobile: res['data']['mobile'], mobile: res['data']['mobile'],
partnerType:res['data']['partnerType'], partnerType:res['data']['partnerType'],
nickName:res['data']['nickName'], nickName:res['data']['nickName'],
levelCode:res['data']['levelCode'],
} }
uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo)) uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo))
this.closebootpage() this.closebootpage()
......
/** 从 0x20 开始到 0x80 的字符宽度数据 */
export declare const CHAR_WIDTH_SCALE_MAP: number[];
import { ObjectFit, ObjectPosition, Size } from "../value";
/**
* 用于计算图片的宽高比例
* @see https://drafts.csswg.org/css-images-3/#sizing-terms
*
* ## 名词解释
* ### intrinsic dimensions
* 图片本身的尺寸
*
* ### specified size
* 用户指定的元素尺寸
*
* ### concrete object size
* 应用了 `objectFit` 之后图片的显示尺寸
*
* ### default object size
*/
export declare function calculateConcreteRect(style: {
/** @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/object-fit */
objectFit?: ObjectFit;
/** @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/object-position */
objectPosition?: ObjectPosition;
}, intrinsicSize: Size, specifiedSize: Size): {
sx: number;
sy: number;
sw: number;
sh: number;
dx: number;
dy: number;
dw: number;
dh: number;
};
<template>
<!-- 微信小程序专用 -->
<!-- #ifdef MP-WEIXIN -->
<painter
:palette="finalPalette"
@imgOK="onImgOK"
@imgErr="onImgErr"
:customStyle="customStyle"
/>
<!-- #endif -->
<!-- H5和APP端使用Canvas兼容 -->
<!-- #ifndef MP-WEIXIN -->
<view class="painter-container">
<canvas
id="posterCanvas"
canvas-id="posterCanvas"
:style="{
width: customStyle.width,
height: customStyle.height,
position: 'fixed',
left: '-9999px'
}"
></canvas>
<image v-if="posterUrl" :src="posterUrl" mode="widthFix" class="poster-image" />
<view v-if="generating" class="loading">海报生成中...</view>
</view>
<!-- #endif -->
</template>
<script>
// 小程序端直接使用原生组件
// #ifdef MP-WEIXIN
import Painter from './painter.js';
export default {
components: { Painter },
props: {
palette: Object,
customStyle: {
type: Object,
default: () => ({ width: '750rpx', height: '1334rpx' })
}
},
computed: {
finalPalette() {
return this.palette;
}
},
methods: {
onImgOK(e) {
this.$emit('imgOK', e);
},
onImgErr(err) {
this.$emit('imgErr', err);
}
}
};
// #endif
// H5和APP端兼容实现
// #ifndef MP-WEIXIN
import QRCode from 'qrcode';
export default {
props: {
palette: Object,
customStyle: Object
},
data() {
return {
posterUrl: '',
generating: false
};
},
mounted() {
this.generateH5Poster();
},
methods: {
async generateH5Poster() {
this.generating = true;
try {
console.log('开始生成海报');
// 1. 生成二维码
const qrCodeUrl = await this.generateQRCode();
console.log('二维码生成完成', qrCodeUrl ? '成功' : '失败');
// 2. 获取Canvas上下文
const ctx = uni.createCanvasContext('posterCanvas', this);
// 3. 绘制背景
ctx.setFillStyle('#ffffff');
ctx.fillRect(0, 0, 750, 1334);
// 4. 绘制背景图
const bg = this.palette.views.find(v => v.type === 'image');
if (bg) {
console.log('开始绘制背景图:', bg.url);
try {
await this.drawImage(ctx, bg.url, 0, 0, 750, 1334);
} catch (err) {
console.warn('背景图绘制失败:', err);
}
}
// 5. 绘制文字
const texts = this.palette.views.filter(v => v.type === 'text');
texts.forEach(text => {
ctx.setFontSize(parseInt(text.css.fontSize));
ctx.setFillStyle(text.css.color || '#000000');
ctx.setTextAlign(text.css.left === 'center' ? 'center' : 'left');
const x = text.css.left === 'center' ? 375 : parseInt(text.css.left);
const y = parseInt(text.css.top);
ctx.fillText(text.text, x, y);
});
// 6. 绘制二维码
const qrView = this.palette.views.find(v => v.type === 'qrcode');
if (qrView && qrCodeUrl) {
console.log('开始绘制二维码');
try {
await this.drawImage(ctx, qrCodeUrl,
parseInt(qrView.css.left),
parseInt(qrView.css.top),
parseInt(qrView.css.width),
parseInt(qrView.css.height)
);
} catch (err) {
console.warn('二维码绘制失败:', err);
}
}
// 7. 生成最终图片
console.log('开始生成最终图片');
await new Promise(resolve => {
ctx.draw(false, () => {
setTimeout(() => {
uni.canvasToTempFilePath({
canvasId: 'posterCanvas',
success: (res) => {
console.log('图片生成成功', res);
this.posterUrl = res.tempFilePath;
this.$emit('imgOK', { detail: { path: res.tempFilePath } });
resolve();
},
fail: (err) => {
console.error('图片生成失败:', err);
this.$emit('imgErr', err);
resolve();
}
}, this);
}, 300);
});
});
} catch (err) {
console.error('海报生成失败:', err);
this.$emit('imgErr', err);
} finally {
this.generating = false;
}
},
drawImage(ctx, url, x, y, width, height) {
return new Promise((resolve, reject) => {
// 如果是base64数据,直接绘制
if (url.startsWith('data:image')) {
console.log('绘制base64图片');
const img = new Image();
img.onload = () => {
ctx.drawImage(img, x, y, width, height);
resolve();
};
img.onerror = (err) => {
console.warn('base64图片加载失败', err);
reject(err);
};
img.src = url;
return;
}
console.log('加载网络图片:', url);
uni.getImageInfo({
src: url,
success: (res) => {
console.log('图片加载成功', res);
const img = new Image();
img.onload = () => {
ctx.drawImage(img, x, y, width, height);
resolve();
};
img.onerror = (err) => {
console.warn('图片绘制失败', err);
reject(err);
};
img.src = res.path;
},
fail: (err) => {
console.warn('图片加载失败:', err);
reject(err);
}
});
});
},
generateQRCode() {
return new Promise((resolve) => {
const qrView = this.palette.views.find(v => v.type === 'qrcode');
if (!qrView || !qrView.content) {
console.warn('未找到有效的二维码配置');
resolve(null);
return;
}
console.log('开始生成二维码,内容:', qrView.content);
// 创建临时Canvas用于生成二维码
const canvas = document.createElement('canvas');
canvas.width = 200;
canvas.height = 200;
// 使用Promise风格的API
QRCode.toCanvas(canvas, qrView.content, {
width: 200,
margin: 2,
color: {
dark: '#000000',
light: '#ffffff'
}
}, (error) => {
if (error) {
console.error('二维码生成失败:', error);
resolve(null);
} else {
console.log('二维码生成成功');
resolve(canvas.toDataURL('image/png'));
}
});
});
}
}
};
// #endif
</script>
<style scoped>
.painter-container {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
canvas {
display: none;
}
.poster-image {
width: 100%;
max-width: 750rpx;
display: block;
margin: 0 auto;
}
.loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 20rpx 40rpx;
background-color: rgba(0, 0, 0, 0.7);
color: white;
border-radius: 10rpx;
font-size: 28rpx;
}
</style>
\ No newline at end of file
import Painter from "./painter";
import { PainterContext } from "./painter-context/index";
interface ILineSpliterContextOption {
fontSize: number;
lineClamp: number;
width: number;
painter: Painter;
content: string;
}
export default class LineSpliterContext {
fontSize: number;
lineClamp: number;
width: number;
ctx: PainterContext;
painter: Painter;
content: string;
lines: string[];
currentLineText: string;
position: number;
endPostion: number;
isOverflow: boolean;
isDry: boolean;
isFull: boolean;
constructor(option: ILineSpliterContextOption);
split(): string[];
minCharNumberInWidth(width: number): number;
freeSpaceInCurrentLine(): number;
adjustCharNumberInCurrentLine(charNumber: number): void;
commitLine(): void;
handleOverflow(): void;
fillText(): void;
}
export {};
import Painter from "../painter";
import { BaseLine, FillStrokeStyle, TextAlign } from "../value";
import { PainterContext } from "./index";
declare const PainterH5Context_base: new (prototype: CanvasRenderingContext2D) => CanvasRenderingContext2D & {
context: CanvasRenderingContext2D;
};
export declare class PainterH5Context extends PainterH5Context_base implements PainterContext {
private painter;
constructor(painter: Painter, context: CanvasRenderingContext2D);
draw(reserve: boolean, callback: () => void): void;
setFillStyle(color: FillStrokeStyle): void;
setStrokeStyle(color: FillStrokeStyle): void;
drawImageWithSrc(imageResource: string, sx: number, sy: number, sWidth: number, sHeight: number, dx?: number, dy?: number, dWidth?: number, dHeight?: number): Promise<void>;
setTextAlign(align: TextAlign): void;
setTextBaseline(baseline: BaseLine): void;
setFontSize(fontSize: number): void;
measureTextWidth(text: string, fontSize: number): number;
}
export declare function normalizeImageResource(src: string): Promise<HTMLImageElement>;
export {};
import { PainterUniContext } from "./context-uni";
import { PainterContext } from "./index";
export declare class PainterUniMpAlipayContext extends PainterUniContext implements PainterContext {
measureTextWidth(text: string, fontSize: number): number;
}
import { PainterUniContext } from "./context-uni";
import { PainterContext } from "./index";
export declare class PainterUniMpBaiduContext extends PainterUniContext implements PainterContext {
measureTextWidth(text: string, fontSize: number): number;
drawImageWithSrc(imageResource: string, sx: number, sy: number, sWidth: number, sHeigt: number, dx?: number, dy?: number, dWidth?: number, dHeight?: number): Promise<void>;
}
import { PainterUniContext } from "./context-uni";
import { PainterContext } from "./index";
export declare class PainterUniMpWeixinContext extends PainterUniContext implements PainterContext {
/** 兼容地,根据控制点和半径绘制圆弧路径 */
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
measureTextWidth(text: string, fontSize: number): number;
}
/// <reference types="uni-app" />
import Painter from "../painter";
import { PainterContext } from "./index";
declare const CanvasContext: new (prototype: CanvasContext) => CanvasContext & {
context: CanvasContext;
};
export declare class PainterUniContext extends CanvasContext implements PainterContext {
private painter;
constructor(painter: Painter, context: CanvasContext);
drawImageWithSrc(imageResource: string, sx: number, sy: number, sWidth: number, sHeight: number, dx?: number, dy?: number, dWidth?: number, dHeight?: number): Promise<void>;
measureTextWidth(text: string, fontSize: number): number;
}
export {};
export declare function createClass<T extends object>(): new (prototype: T) => T & {
context: T;
};
/// <reference types="uni-app" />
import Painter from "../painter";
export declare type CompatableContext = CanvasContext | CanvasRenderingContext2D;
export declare type PainterContext = Pick<CanvasContext, "arcTo" | "clip" | "draw" | "fillStyle" | "font" | "lineTo" | "restore" | "save" | "setFillStyle" | "setFontSize" | "setStrokeStyle" | "setTextAlign" | "setTextBaseline" | "strokeStyle" | "beginPath" | "closePath" | "moveTo" | "createLinearGradient" | "stroke" | "fill" | "strokeRect" | "fillRect" | "lineWidth" | "setLineDash" | "fillText" | "setTransform" | "scale" | "rotate" | "translate"> & {
measureTextWidth(text: string, fontSize: number): number;
drawImageWithSrc(imageResource: string, sx: number, sy: number, sWidth: number, sHeigt: number): Promise<void>;
drawImageWithSrc(imageResource: string, sx: number, sy: number, sWidth: number, sHeigt: number, dx: number, dy: number, dWidth: number, dHeight: number): Promise<void>;
};
export declare function adaptContext(painter: Painter, ctx: CompatableContext): PainterContext;
import Painter from "../painter";
import { Size, Position } from "../value";
export interface PainterElementOption {
type: string;
/** 定位方式 */
position: Position;
left: number;
top: number;
}
export declare abstract class PainterElement {
parent?: PainterElement;
offsetTop: number;
offsetLeft: number;
left: number;
top: number;
contentHeight: number;
contentWidth: number;
position: Position;
painter: Painter;
constructor(painter: Painter, option: Partial<PainterElementOption>, parent?: PainterElement);
protected abstract _layout(): Promise<Size> | Size;
layout(): Promise<Size>;
abstract paint(): void;
get anchorX(): number;
get anchorY(): number;
get elementX(): number;
get elementY(): number;
get offsetHeight(): number;
get offsetWidth(): number;
}
import Painter from "../painter";
import { PainterElementOption, PainterElement } from "./base";
import { BuiltInPainterElementOption } from "./index";
import { BuiltInPainterPathOption } from "../painter-path/index";
import { PainterPath } from "../painter-path/base";
export interface PainterClipElementOption extends PainterElementOption {
type: "clip";
/** 裁剪使用的路径 */
path: BuiltInPainterPathOption;
/** 被裁剪的内容 */
content: BuiltInPainterElementOption;
}
export declare class PainterClipElement extends PainterElement {
contentElement: PainterElement;
clipPath: PainterPath;
constructor(painter: Painter, option: PainterClipElementOption, parent?: PainterElement);
_layout(): Promise<import("../value").Size>;
paint(): Promise<void>;
}
import Painter from "../painter";
import { PainterElementOption, PainterElement } from "./base";
import { OmitBaseOption } from "../value";
import { BuiltInPainterElementOption } from "./index";
export interface PainterContainerElementOption extends PainterElementOption {
type: "container";
/** 子元素的排列方式 */
direction: "vertical" | "horizontal";
width: number | "auto";
height: number | "auto";
/** 子元素 */
children: BuiltInPainterElementOption[];
}
export declare class PainterContainerElement extends PainterElement {
option: OmitBaseOption<PainterContainerElementOption>;
children: PainterElement[];
childOffsetTop: number;
childOffsetLeft: number;
constructor(painter: Painter, option: PainterContainerElementOption, parent?: PainterElement);
_layout(): Promise<{
width: number;
height: number;
}>;
private layoutChildren;
private layoutChild;
private calcContainerWidth;
private calcContainerHeight;
paint(): Promise<void>;
childrenMaxWidth(): number;
childrenMaxHeight(): number;
}
import Painter from "../painter";
import { PainterElementOption, PainterElement } from "./base";
import { ObjectFit, OmitBaseOption, ObjectPosition } from "../value";
export interface PainterImageElementOption extends PainterElementOption {
type: "image";
/**
* 图片地址
*
* 可以使用网络图片地址或下载后的临时图片地址
*/
src: string;
width: number;
height: number;
/**
* 图片的适应方式
* - fill 拉伸图片以铺满容器
* - contain 等比缩放,使图片刚好能完整显示出来
* - cover 等比缩放,使图片刚好能占满容器
*/
objectFit?: ObjectFit;
/**
* 图片的位置
* 默认为 `["center","center"]`
*/
objectPosition?: ObjectPosition;
}
export declare class PainterImageElement extends PainterElement {
option: OmitBaseOption<PainterImageElementOption>;
constructor(painter: Painter, option: PainterImageElementOption, parent?: PainterElement);
_layout(): {
width: number;
height: number;
};
paint(): Promise<void>;
}
import Painter from "../painter";
import { PainterElementOption, PainterElement } from "./base";
import { OmitBaseOption } from "../value";
import { BuiltInPainterFillStrokeOption } from "../painter-fill-stroke/index";
export interface PainterLineElementOption extends PainterElementOption {
type: "line";
/** 直线终点距离起点在水平方向上的距离 */
dx: number;
/** 直线终点距离起点在垂直方向上的距离 */
dy: number;
/** 直线的颜色 */
color: BuiltInPainterFillStrokeOption;
/** 直线的宽度 */
lineWidth: number;
/** 虚线样式,默认为实线 */
dashPattern: number[];
}
export declare class PainterLineElement extends PainterElement {
option: OmitBaseOption<PainterLineElementOption>;
constructor(painter: Painter, option: Partial<PainterLineElementOption>, parent?: PainterElement);
_layout(): {
width: number;
height: number;
};
paint(): void;
}
import Painter from "../painter";
import { PainterElementOption, PainterElement } from "./base";
import { OmitBaseOption, BorderRadius, BorderStyle, Color } from "../value";
import { BuiltInPainterFillStrokeOption } from "../painter-fill-stroke/index";
export interface PainterRectagleElementOption extends PainterElementOption {
type: "rect";
width: number;
height: number;
/**
* 圆角
*
* - `number` 一个数字,四个角的圆角都使用设置的值
* - `[number, number, number, number]` 四个数字的元组分别代表 **左上**、**右上**、**右下** 和 **左下** 的圆角值。
*/
borderRadius: BorderRadius;
/**
* 背景颜色
*/
background: BuiltInPainterFillStrokeOption;
borderWidth: number;
borderStyle: BorderStyle;
borderColor: Color;
}
export declare class PainterRectagleElement extends PainterElement {
option: OmitBaseOption<PainterRectagleElementOption>;
constructor(painter: Painter, option: PainterRectagleElementOption, parent?: PainterElement);
_layout(): {
width: number;
height: number;
};
paint(): void;
private get shouldFill();
private get shouldStroke();
private applyFillStyle;
private applyStrokeStyle;
private paintByRect;
private paintByPath;
}
import Painter from "../painter";
import { PainterTextElementOption } from "./element-text";
import { PainterElement } from "./base";
import { OmitBaseOption } from "../value";
export interface PainterTextBlockElementOption extends Omit<PainterTextElementOption, "type"> {
type: "text-block";
/** 行高 */
lineHeight: number;
/** 文本块的最大行数 */
lineClamp: number;
/** 文本块的宽度 */
width: number;
height: number | "auto";
}
export declare class PainterTextBlockElement extends PainterElement {
option: OmitBaseOption<Partial<PainterTextBlockElementOption> & Pick<PainterTextBlockElementOption, "fontSize" | "width" | "height" | "lineClamp" | "content" | "lineHeight" | "top" | "color">>;
lines: string[];
constructor(painter: Painter, option: PainterTextBlockElementOption, parent?: PainterElement);
_layout(): {
width: number;
height: number;
};
paint(): Promise<void>;
}
import Painter from "../painter";
import { FontWeight, BaseLine, TextAlign, OmitBaseOption, FontStyle, TextDecoration } from "../value";
import { PainterElementOption, PainterElement } from "./base";
import { BuiltInPainterFillStrokeOption } from "../painter-fill-stroke/index";
export interface PainterTextElementOption extends PainterElementOption {
type: "text";
/** 文字的颜色 */
color: BuiltInPainterFillStrokeOption;
/** 文字的字号 */
fontSize: number;
/** 文字的字重 */
fontWeight: FontWeight;
/** 文字的字型 */
fontStyle: FontStyle;
/** 文字的字体 */
fontFamily: string;
/** 锚点在垂直方向相对文字的位置 */
baseline: BaseLine;
/** 锚点在水平方向相对文字的位置 */
align: TextAlign;
/** 文本内容 */
content: string;
/** 文字的宽度,为空则根据文本内容及字号自动计算宽度 */
width?: number;
textDecoration: TextDecoration;
}
export declare class PainterTextElement extends PainterElement {
option: OmitBaseOption<PainterTextElementOption>;
constructor(painter: Painter, option: PainterTextElementOption, parent?: PainterElement);
_layout(): {
width: number;
height: number;
};
paint({ inTextBlock }?: {
inTextBlock?: boolean | undefined;
}): void;
private paintTextDecoration;
}
import Painter from "../painter";
import { PainterElementOption, PainterElement } from "./base";
import { BuiltInPainterElementOption } from "./index";
export interface PainterTransformElementOption extends PainterElementOption {
type: "transform";
/** 变换的内容 */
content: BuiltInPainterElementOption;
/** 变换的选项 */
transform: BuiltInPainterTransformOption[];
/** 变换的原点、默认为元素的中心 */
transformOrigin: PaitnerTransformOriginOption;
}
declare type BuiltInPainterTransformOption = PainterTransformTranslateOption | PainterTransformRotateOption | PainterTransformScaleOption | PainterTransformMatrixOption;
interface PainterTransformTranslateOption {
type: "translate";
x?: number;
y?: number;
}
interface PainterTransformRotateOption {
type: "rotate";
/** degree */
rotate: number;
}
interface PainterTransformScaleOption {
type: "scale";
scaleWidth?: number;
scaleHeight?: number;
}
interface PainterTransformMatrixOption {
type: "set-matrix";
translateX: number;
translateY: number;
scaleX: number;
scaleY: number;
skewX: number;
skewY: number;
}
declare type PaitnerTransformOriginOption = [
PaitnerTransformOriginHorizontalOption,
PaitnerTransformOriginVerticalOption
];
declare type PaitnerTransformOriginHorizontalOption = "left" | "center" | "right";
declare type PaitnerTransformOriginVerticalOption = "top" | "center" | "bottom";
/**
* - fixme: Cascade transform not supported yet.
* Cause when we set tansform origin in `withTransformOrigin`,
* We don't know the transform state of outer element.
*/
export declare class PainterTransformElement extends PainterElement {
transformOrigin: PaitnerTransformOriginOption;
transformOptions: BuiltInPainterTransformOption[];
contentElement: PainterElement;
constructor(painter: Painter, option: PainterTransformElementOption, parent?: PainterElement);
_layout(): Promise<import("../value").Size>;
paint(): Promise<void>;
private transform;
private singleTransform;
private withTransformOrigin;
}
export {};
import { PainterTextElementOption, PainterTextElement } from "./element-text";
import { PainterTextBlockElementOption, PainterTextBlockElement } from "./element-text-block";
import { PainterImageElementOption, PainterImageElement } from "./element-image";
import { PainterLineElementOption, PainterLineElement } from "./element-line";
import { PainterRectagleElementOption, PainterRectagleElement } from "./element-rect";
import { PainterContainerElementOption, PainterContainerElement } from "./element-container";
import { PainterClipElementOption, PainterClipElement } from "./element-clip";
import { PainterTransformElementOption, PainterTransformElement } from "./element-transform";
import Painter from "../painter";
import { PainterElement } from "./base";
export declare type BuiltInPainterElementOption = PainterTextElementOption | PainterTextBlockElementOption | PainterImageElementOption | PainterLineElementOption | PainterRectagleElementOption | PainterContainerElementOption | PainterClipElementOption | PainterTransformElementOption;
export declare function createElement(painter: Painter, option: BuiltInPainterElementOption, parent?: PainterElement): PainterTextElement | PainterTextBlockElement | PainterImageElement | PainterLineElement | PainterRectagleElement | PainterContainerElement | PainterClipElement | PainterTransformElement;
import { PainterLinearGradientOption } from "./linear-gradient";
import { PainterElement } from "../painter-element/base";
export interface PainterGradientPatternOption {
type: string;
}
export declare type BuiltInPainterGradientPatternOption = PainterLinearGradientOption;
export declare abstract class PainterGradientPatternStyle {
element: PainterElement;
constructor(element: PainterElement);
get painter(): import("../painter").default;
abstract get style(): CanvasGradient | CanvasPattern;
}
import { Color } from "../value";
import { PainterLinearGradientOption } from "./linear-gradient";
import { PainterElement } from "../painter-element/base";
export declare type BuiltInPainterFillStrokeOption = Color | PainterLinearGradientOption;
export declare function createFillStrokeStyle(element: PainterElement, option: BuiltInPainterFillStrokeOption): string | CanvasGradient;
import { ColorStop } from "../value";
import { PainterGradientPatternOption, PainterGradientPatternStyle } from "./base";
import { PainterElement } from "../painter-element/base";
export interface PainterLinearGradientOption extends PainterGradientPatternOption {
type: "linear-gradient";
colorStops: ColorStop[];
x1: number;
y1: number;
x2: number;
y2: number;
}
export declare class PainterLinearGradientStyle extends PainterGradientPatternStyle {
option: PainterLinearGradientOption;
constructor(element: PainterElement, option: PainterLinearGradientOption);
get style(): CanvasGradient;
}
import { PainterElement } from "../painter-element/base";
export interface PainterPathOption {
type: string;
left?: number;
top?: number;
}
export declare abstract class PainterPath {
element: PainterElement;
left: number;
top: number;
constructor(element: PainterElement, option: PainterPathOption);
get painter(): import("../painter").default;
get pathX(): number;
get pathY(): number;
abstract paint(): void;
}
import { PainterElement } from "../painter-element/base";
import { PainterRoundedRectanglePath, PainterRoundedRectanglePathOption } from "./path-rounded-rect";
export declare type BuiltInPainterPathOption = PainterRoundedRectanglePathOption;
export declare function createPath(element: PainterElement, option: BuiltInPainterPathOption): PainterRoundedRectanglePath;
import { PainterPath, PainterPathOption } from "./base";
import { BorderRadius } from "../value";
import { PainterElement } from "../painter-element/base";
export interface PainterRoundedRectanglePathOption extends PainterPathOption {
type: "rounded-rect";
/** 路径的宽度 */
width: number;
/** 路径的高度 */
height: number;
/** 路径的圆角 */
borderRadius: BorderRadius;
}
export declare class PainterRoundedRectanglePath extends PainterPath {
option: PainterRoundedRectanglePathOption;
constructor(element: PainterElement, option: PainterRoundedRectanglePathOption);
private assertBorderRadius;
paint(): void;
private get normalizedBorderRadius();
/**
* @see https://www.w3.org/TR/css-backgrounds-3/#corner-overlap
* Corner curves must not overlap: When the sum of any two adjacent border
* radii exceeds the size of the border box, UAs must proportionally reduce
* the used values of all border radii until none of them overlap.
*/
private reduceBorderRadius;
}
/// <reference types="uni-app" />
import { UniPlatforms } from "../utils/platform";
import { BuiltInPainterElementOption } from "./painter-element/index";
import { PainterContext } from "./painter-context/index";
interface IPanterOption {
platform?: UniPlatforms;
upx2px?: (upx: number) => number;
}
/** 单次绘制选项 */
interface IDrawOption {
}
export default class Painter {
ctx: PainterContext;
upx2px: NonNullable<IPanterOption["upx2px"]>;
platform: NonNullable<IPanterOption["platform"]>;
constructor(ctx: CanvasContext, { platform, upx2px }?: IPanterOption);
draw(elementOption: BuiltInPainterElementOption, drawOption?: IDrawOption): Promise<import("./value").Size>;
/** 创建元素对象 */
createElement(elementOption: BuiltInPainterElementOption): import("./painter-element/element-text").PainterTextElement | import("./painter-element/element-text-block").PainterTextBlockElement | import("./painter-element/element-image").PainterImageElement | import("./painter-element/element-line").PainterLineElement | import("./painter-element/element-rect").PainterRectagleElement | import("./painter-element/element-container").PainterContainerElement | import("./painter-element/element-clip").PainterClipElement | import("./painter-element/element-transform").PainterTransformElement;
/** 获取指定元素的内部尺寸, 结果不包含元素的 left 和 top */
layout(elementOption: BuiltInPainterElementOption): Promise<import("./value").Size>;
/** 兼容将 painter 实例保存在 uniapp this 上, 勿手动调用 */
toJSON(): string;
}
export {};
module.exports=function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";i.r(e);const n="object"==typeof swan?"mp-baidu":"object"==typeof my?"mp-alipay":"object"==typeof wx?"mp-weixin":"object"==typeof window?"h5":"mp-weixin",o=function(){if("undefined"!=typeof uni)return uni;if("undefined"!=typeof wx)return wx;if("undefined"!=typeof window)return{upx2px:t=>t,getSystemInfoSync:()=>({screenWidth:window.innerWidth}),downloadFile:t=>{var e;return null===(e=t.success)||void 0===e?void 0:e.call(t,{tempFilePath:t.url})}};throw new Error("enviroment not support")}();var r=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function h(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}l((n=n.apply(t,e||[])).next())}))};class s{constructor(t,e,i){var n,o,r;this.offsetTop=0,this.offsetLeft=0,this.contentHeight=0,this.contentWidth=0,this.painter=t,this.parent=i,this.position=null!==(n=e.position)&&void 0!==n?n:"static",this.left=null!==(o=e.left)&&void 0!==o?o:0,this.top=null!==(r=e.top)&&void 0!==r?r:0}layout(){return r(this,void 0,void 0,(function*(){let t=yield this._layout();return this.contentHeight=t.height,this.contentWidth=t.width,t}))}get anchorX(){var t,e;return null!==(e=null===(t=this.parent)||void 0===t?void 0:t.elementX)&&void 0!==e?e:0}get anchorY(){var t,e;return null!==(e=null===(t=this.parent)||void 0===t?void 0:t.elementY)&&void 0!==e?e:0}get elementX(){switch(this.position){case"absolute":return this.left+this.anchorX;case"static":return this.left+this.offsetLeft+this.anchorX;default:throw new TypeError("unknown position type")}}get elementY(){switch(this.position){case"absolute":return this.top+this.anchorY;case"static":return this.top+this.offsetTop+this.anchorY;default:throw new TypeError("unknown position type")}}get offsetHeight(){return this.top+this.contentHeight}get offsetWidth(){return this.left+this.contentWidth}}class h extends class{constructor(t){this.element=t}get painter(){return this.element.painter}}{constructor(t,e){super(t),this.option=e}get style(){const{ctx:t,upx2px:e}=this.painter,{x1:i,x2:n,y1:o,y2:r}=this.option,s=t.createLinearGradient(e(this.element.elementX+i),e(this.element.elementY+o),e(this.element.elementX+n),e(this.element.elementY+r));return this.option.colorStops.forEach(t=>{s.addColorStop(t.offset,t.color)}),s}}function l(t,e){if("string"==typeof e)return e;switch(e.type){case"linear-gradient":return new h(t,e).style;default:throw new Error("Unkwon option type")}}function a(t,e,i=1){return i%2?[Math.floor(t)+.5,Math.floor(e)+.5]:[Math.round(t),Math.round(e)]}class c extends s{constructor(t,e,i){var n,o,r,s,h;super(t,e,i),this.option={dx:null!==(n=e.dx)&&void 0!==n?n:0,dy:null!==(o=e.dy)&&void 0!==o?o:0,color:null!==(r=e.color)&&void 0!==r?r:"#000",dashPattern:null!==(s=e.dashPattern)&&void 0!==s?s:[1,0],lineWidth:null!==(h=e.lineWidth)&&void 0!==h?h:1}}_layout(){return{width:this.option.dx,height:this.option.dy}}paint(){let t=this.painter.upx2px(this.elementX),e=this.painter.upx2px(this.elementY),i=this.painter.upx2px(this.elementX+this.option.dx),n=this.painter.upx2px(this.elementY+this.option.dy),o=this.painter.upx2px(this.option.lineWidth);this.painter.ctx.beginPath(),this.painter.ctx.moveTo(...a(t,e,o)),this.painter.ctx.lineTo(...a(i,n,o)),this.painter.ctx.setLineDash(this.option.dashPattern.map(t=>this.painter.upx2px(t))),this.painter.ctx.setStrokeStyle(l(this,this.option.color)),this.painter.ctx.lineWidth=o,this.painter.ctx.stroke()}}function u(t){return t.replace(/[\n\r]/g,"")}class p extends s{constructor(t,e,i){var n,o,r,s,h,l,a,c,p,d;super(t,e,i),this.option={color:null!==(n=e.color)&&void 0!==n?n:"#000",align:null!==(o=e.align)&&void 0!==o?o:"left",fontWeight:null!==(r=e.fontWeight)&&void 0!==r?r:"normal",fontStyle:null!==(s=e.fontStyle)&&void 0!==s?s:"normal",fontFamily:null!==(h=e.fontFamily)&&void 0!==h?h:"serial",fontSize:null!==(l=e.fontSize)&&void 0!==l?l:30,baseline:null!==(a=e.baseline)&&void 0!==a?a:"top",content:null!==(c=e.content)&&void 0!==c?c:"",width:null!==(p=e.width)&&void 0!==p?p:void 0,textDecoration:null!==(d=e.textDecoration)&&void 0!==d?d:"none"},this.option.content=u(this.option.content)}_layout(){var t;return{width:null!==(t=this.option.width)&&void 0!==t?t:this.painter.ctx.measureTextWidth(this.option.content,this.option.fontSize),height:this.option.fontSize}}paint({inTextBlock:t=!1}={}){this.painter.ctx.font=["normal"!=this.option.fontWeight&&this.option.fontWeight,"normal"!=this.option.fontStyle&&this.option.fontStyle,this.painter.upx2px(this.option.fontSize)+"px",this.option.fontFamily].filter(Boolean).join(" "),t||this.painter.ctx.setFillStyle(l(this,this.option.color)),this.painter.ctx.setFontSize(this.painter.upx2px(this.option.fontSize)),this.painter.ctx.setTextBaseline(this.option.baseline),this.painter.ctx.setTextAlign(this.option.align),this.painter.ctx.fillText(this.option.content,this.painter.upx2px(this.elementX),this.painter.upx2px(this.elementY)),console.debug("mp-painter:fillText:",this.option.content,"x=",this.elementX,"y=",this.elementY),this.paintTextDecoration()}paintTextDecoration(){"line-through"==this.option.textDecoration&&new c(this.painter,{top:this.elementY+.4*this.option.fontSize,left:this.elementX,dx:this.contentWidth,dy:0,color:this.option.color}).paint()}}class d{constructor(t){this.fontSize=t.fontSize,this.lineClamp=t.lineClamp||1/0,this.width=t.width,this.ctx=t.painter.ctx,this.painter=t.painter,this.content=t.content,this.lines=[],this.currentLineText="",this.position=0,this.endPostion=this.position,this.isOverflow=!1,this.isDry=!1,this.isFull=!1}split(){return this.painter.ctx.setFontSize(this.fontSize),this.fillText(),this.lines}minCharNumberInWidth(t){return Math.ceil(t/this.fontSize)}freeSpaceInCurrentLine(){if(this.currentLineText.length){let t=this.painter.ctx.measureTextWidth(this.currentLineText,this.fontSize);return this.width-(t||0)}return this.width}adjustCharNumberInCurrentLine(t){let e=this.currentLineText.length+t,i=this.content.length;e=Math.min(e,i),this.isDry=e==i,this.currentLineText=this.content.slice(0,e)}commitLine(){this.content=this.content.slice(this.currentLineText.length),this.lines.push(this.currentLineText),this.currentLineText="",this.lines.length==this.lineClamp&&(this.isFull=!0,0==this.isDry&&(this.isOverflow=!0))}handleOverflow(){let t=this.lines.pop();t=t.substring(0,Math.max(0,t.length-1))+"...",this.lines.push(t)}fillText(){let t=this.freeSpaceInCurrentLine();if(t<=0){if(this.adjustCharNumberInCurrentLine(-1),this.commitLine(),this.isOverflow&&this.handleOverflow(),this.isFull)return;t=this.freeSpaceInCurrentLine()}else if(this.isDry)return void this.commitLine();let e=this.minCharNumberInWidth(t);this.adjustCharNumberInCurrentLine(e),this.fillText()}}var f=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function h(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}l((n=n.apply(t,e||[])).next())}))};class m extends s{constructor(t,e,i){var n,o,r,s,h,l,a;super(t,e,i),this.option=Object.assign(Object.assign({},e),{width:null!==(n=e.width)&&void 0!==n?n:100,height:null!==(o=e.height)&&void 0!==o?o:"auto",fontSize:null!==(r=e.fontSize)&&void 0!==r?r:30,content:null!==(s=e.content)&&void 0!==s?s:"",lineHeight:null!==(h=e.lineHeight)&&void 0!==h?h:40,lineClamp:null!==(l=e.lineClamp)&&void 0!==l?l:0,color:null!==(a=e.color)&&void 0!==a?a:"black"}),this.lines=[],this.option.content=u(this.option.content)}_layout(){return this.lines=new d({fontSize:this.option.fontSize,lineClamp:this.option.lineClamp,width:this.option.width,painter:this.painter,content:this.option.content}).split(),{width:this.option.width,height:"auto"==this.option.height?(this.lines.length-1)*this.option.lineHeight+this.option.fontSize:this.option.height}}paint(){return f(this,void 0,void 0,(function*(){this.painter.ctx.setFillStyle(l(this,this.option.color)),this.lines.map((t,e)=>{const i=Object.assign(Object.assign({},this.option),{type:"text",top:this.elementY+e*this.option.lineHeight,left:this.elementX,position:this.position,content:t});return new p(this.painter,i)}).forEach(t=>t.paint({inTextBlock:!0}))}))}}function x(t){let e=new Map;return function(i){return e.has(i)||e.set(i,t(i)),e.get(i)}}function w(){let t=!1;const e=t=>{let e=Object.getOwnPropertyDescriptors(Object.getPrototypeOf(t)),i={};for(let t in e){const n=e[t],o={};o.enumerable=n.enumerable,o.configurable=n.configurable,n.value&&"function"==typeof n.value&&(o.value=function(...t){return n.value.call(this.context,...t)}),n.value&&"function"!=typeof n.value&&(o.get=function(){return this.context[t]},o.set=function(e){this.context[t]=e}),n.get&&(o.get=function(){var t;return null===(t=n.get)||void 0===t?void 0:t.call(this.context)}),n.set&&(o.set=function(t){var e;null===(e=n.set)||void 0===e||e.call(this.context,t)}),i[t]=o}return Object.defineProperties({},i)},i=function(n){if(!(this instanceof i))throw new Error("mp-painter: `this` is not instance of `constructor`");if(this.context=n,!t)for(let n=this,o=Object.getPrototypeOf(n);null!==o;n=o,o=Object.getPrototypeOf(n))if(n.constructor===i){Object.setPrototypeOf(n,e(this.context)),t=!0;break}};return i}var v=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function h(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}l((n=n.apply(t,e||[])).next())}))};class y extends(w()){constructor(t,e){super(e),this.painter=t}draw(t,e){e()}setFillStyle(t){super.fillStyle=t}setStrokeStyle(t){super.strokeStyle=t}drawImageWithSrc(t,e,i,n,o,r,s,h,l){const a=Object.create(null,{drawImage:{get:()=>super.drawImage}});return v(this,void 0,void 0,(function*(){let c=yield g(t);"number"==typeof r&&"number"==typeof s&&"number"==typeof h&&"number"==typeof l?a.drawImage.call(this,c,e,i,n,o,r,s,h,l):a.drawImage.call(this,c,e,i,n,o)}))}setTextAlign(t){super.textAlign=t}setTextBaseline(t){super.textBaseline="normal"===t?"alphabetic":t}setFontSize(t){var e,i;console.debug("set font size for h5, before is %s after is %s",super.font,null===(e=super.font)||void 0===e?void 0:e.replace(/\b\w+px\b/,this.painter.upx2px(t)+"px sans-serif")),super.font=null===(i=super.font)||void 0===i?void 0:i.replace(/\b\w+px\b/,this.painter.upx2px(t)+"px")}measureTextWidth(t,e){this.setFontSize(e);let i=this.measureText(t).width;return console.debug('measureText: result of measure text "%s" with font size %s is %s',t,this.font,i),null!=i?i:0}}function g(t){let e=new Image;return e.src=t,new Promise(t=>e.addEventListener("load",i=>t(e),{once:!0}))}var b=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function h(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}l((n=n.apply(t,e||[])).next())}))};const S=x((function(t){return b(this,void 0,void 0,(function*(){try{let{width:i=100,height:n=100}=yield(e=uni.getImageInfo,function(t={}){return new Promise((i,n)=>{t.success=i,t.fail=n,e(t)})})({src:t});return{width:i,height:n}}catch(t){return console.log("mp-painter:getImageOriginSize: fail, use default size: width = 100, height = 100"),{width:100,height:100}}var e}))})),T=x((function(t){return b(this,void 0,void 0,(function*(){let e=yield g(t);return{width:e.naturalWidth,height:e.naturalHeight}}))}));class W extends s{constructor(t,e,i){var n,o,r,s;super(t,e,i),this.option={width:null!==(n=e.width)&&void 0!==n?n:100,height:null!==(o=e.height)&&void 0!==o?o:100,objectFit:null!==(r=e.objectFit)&&void 0!==r?r:"fill",objectPosition:null!==(s=e.objectPosition)&&void 0!==s?s:["center","center"],src:e.src}}_layout(){return{width:this.option.width,height:this.option.height}}paint(){return b(this,void 0,void 0,(function*(){let t=this.painter.upx2px;if(!this.option.src)return;let e=yield function(t,e){return b(this,void 0,void 0,(function*(){let i=t.platform;return"h5"!=i&&/^\./.test(e.src)||"h5"!=i&&/^\/static/.test(e.src)||"h5"!=i&&/^data:image\//.test(e.src)||"mp-alipay"==i&&/^https:\/\/resource\//.test(e.src)||"mp-weixin"==i&&/^wxfile:/.test(e.src)||"mp-baidu"==i&&/^bdfile:\/\/tmp/.test(e.src)?e.src:(console.log("mp-painter:绘制图片: 下载图片文件:",e.src),"h5"==i?e.src:yield(n=e.src,new Promise((t,e)=>o.downloadFile({url:n,success:e=>t(e.tempFilePath),fail:e}))).catch(t=>(console.log("mp-painter:下载错误: ",t),"")));var n}))}(this.painter,this.option);if(e)if(console.log("mp-painter:调用小程序drawImage,使用:",e),"fill"!=this.option.objectFit){let{sx:i,sy:n,sh:o,sw:r,dx:s,dy:h,dh:l,dw:a}=function(t,e,i){var n,o;let r=e.width/e.height,s=i.width/i.height,h=1;if(r>s&&"contain"==t.objectFit||r<=s&&"cover"==t.objectFit)h=i.width/e.width;else{if(!(r>s&&"cover"==t.objectFit||r<=s&&"contain"==t.objectFit))throw new Error("Unkonwn concreteScale");h=i.height/e.height}let l=e.width*h,a=e.height*h,c={left:0,center:.5,right:1}[(null===(n=t.objectPosition)||void 0===n?void 0:n[0])||"center"],u={top:0,center:.5,bottom:1}[(null===(o=t.objectPosition)||void 0===o?void 0:o[1])||"center"],p=(i.width-l)*c,d=(i.height-a)*u,f=(t,e)=>[(t-p)/h,(e-d)/h],[m,x]=f(0,0),[w,v]=f(i.width,i.height);return{sx:Math.max(m,0),sy:Math.max(x,0),sw:Math.min(w-m,e.width),sh:Math.min(v-x,e.height),dx:Math.max(p,0),dy:Math.max(d,0),dw:Math.min(l,i.width),dh:Math.min(a,i.height)}}({objectFit:this.option.objectFit,objectPosition:this.option.objectPosition},yield("h5"==this.painter.platform?T:S)(e),{width:this.option.width,height:this.option.height});this.painter.ctx.drawImageWithSrc(e,i,n,r,o,t(s+this.elementX),t(h+this.elementY),t(a),t(l))}else this.painter.ctx.drawImageWithSrc(e,t(this.elementX),t(this.elementY),t(this.option.width),t(this.option.height))}))}}class O extends class{constructor(t,e){var i,n;this.element=t,this.left=null!==(i=e.left)&&void 0!==i?i:0,this.top=null!==(n=e.top)&&void 0!==n?n:0}get painter(){return this.element.painter}get pathX(){return this.element.elementX+this.left}get pathY(){return this.element.elementY+this.top}}{constructor(t,e){super(t,e),this.option=e,this.option.borderRadius&&this.assertBorderRadius()}assertBorderRadius(){this.normalizedBorderRadius.some(t=>t<0)&&(console.warn("mp-painter:border radius must greater than 0, got:",this.normalizedBorderRadius.join(",")),this.option.borderRadius=0)}paint(){this.reduceBorderRadius();const{ctx:t,upx2px:e}=this.painter,i=e(this.pathX),n=e(this.pathY),o=e(this.option.height),r=e(this.option.width),[s,h,l,a]=this.normalizedBorderRadius.map(t=>e(t));t.beginPath(),t.moveTo(i,n+s),t.arcTo(i,n,i+s,n,s),t.arcTo(i+r,n,i+r,n+h,h),t.arcTo(i+r,n+o,i+r-l,n+o,l),t.arcTo(i,n+o,i,n+o-a,a),t.closePath()}get normalizedBorderRadius(){return"number"==typeof this.option.borderRadius?Array.from({length:4}).fill(this.option.borderRadius):[...this.option.borderRadius]}reduceBorderRadius(){let[t,e,i,n]=this.normalizedBorderRadius,o=Math.min(this.option.width/(t+e),this.option.height/(e+i),this.option.width/(n+i),this.option.height/(t+n));o>=1||(this.option.borderRadius=this.normalizedBorderRadius.map(t=>t*o))}}function P(t,e){switch(e.type){case"rounded-rect":return new O(t,e);default:throw new Error("Unkwon option type")}}class j extends s{constructor(t,e,i){var n,o,r,s,h,l,a;super(t,e,i),this.option={width:null!==(n=e.width)&&void 0!==n?n:100,height:null!==(o=e.height)&&void 0!==o?o:100,borderRadius:null!==(r=e.borderRadius)&&void 0!==r?r:0,background:null!==(s=e.background)&&void 0!==s?s:"transparent",borderStyle:null!==(h=e.borderStyle)&&void 0!==h?h:"solid",borderWidth:null!==(l=e.borderWidth)&&void 0!==l?l:0,borderColor:null!==(a=e.borderColor)&&void 0!==a?a:"#000"}}_layout(){return{width:this.option.width,height:this.option.height}}paint(){(this.shouldFill||this.shouldStroke)&&(this.option.borderRadius?this.paintByPath():this.paintByRect())}get shouldFill(){return"trasparent"!==this.option.background}get shouldStroke(){return this.option.borderWidth>0}applyFillStyle(){this.painter.ctx.setFillStyle(l(this,this.option.background))}applyStrokeStyle(){var t,e;this.painter.ctx.setLineDash((t=this.option.borderStyle,{dashed:[e=this.option.borderWidth,e],solid:[10,0]}[t])),this.painter.ctx.lineWidth=this.painter.upx2px(this.option.borderWidth),this.painter.ctx.setStrokeStyle(this.option.borderColor)}paintByRect(){let t=[this.painter.upx2px(this.elementX),this.painter.upx2px(this.elementY),this.painter.upx2px(this.option.width),this.painter.upx2px(this.option.height)];this.shouldFill&&(this.applyFillStyle(),this.painter.ctx.fillRect(...t)),this.shouldStroke&&(this.applyStrokeStyle(),this.painter.ctx.strokeRect(...t))}paintByPath(){P(this,{type:"rounded-rect",height:this.option.height,width:this.option.width,borderRadius:this.option.borderRadius}).paint(),this.shouldFill&&(this.painter.ctx.setFillStyle(l(this,this.option.background)),this.painter.ctx.fill()),this.shouldStroke&&(this.applyStrokeStyle(),this.painter.ctx.stroke())}}var k=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function h(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}l((n=n.apply(t,e||[])).next())}))};class F extends s{constructor(t,e,i){var n,o,r,s;super(t,e,i),this.childOffsetTop=0,this.childOffsetLeft=0,this.option={direction:null!==(n=e.direction)&&void 0!==n?n:"vertical",width:null!==(o=e.width)&&void 0!==o?o:"auto",height:null!==(r=e.height)&&void 0!==r?r:"auto",children:null!==(s=e.children)&&void 0!==s?s:[]},this.children=this.option.children.map(t=>M(this.painter,t,this))}_layout(){return k(this,void 0,void 0,(function*(){return yield this.layoutChildren(),{width:this.calcContainerWidth(),height:this.calcContainerHeight()}}))}layoutChildren(){return k(this,void 0,void 0,(function*(){for(let t of this.children)yield this.layoutChild(t)}))}layoutChild(t){return k(this,void 0,void 0,(function*(){yield t.layout(),"absolute"!=t.position&&("vertical"==this.option.direction?(t.offsetTop=this.childOffsetTop,this.childOffsetTop+=t.offsetHeight):(t.offsetLeft=this.childOffsetLeft,this.childOffsetLeft+=t.offsetWidth))}))}calcContainerWidth(){if("number"==typeof this.option.width)return this.option.width;switch(this.option.direction){case"vertical":return this.childrenMaxWidth();case"horizontal":return this.childOffsetLeft;default:throw new TypeError("Unknown direction")}}calcContainerHeight(){if("number"==typeof this.option.height)return this.option.height;switch(this.option.direction){case"vertical":return this.childOffsetTop;case"horizontal":return this.childrenMaxHeight();default:throw new TypeError("Unknown direction")}}paint(){return k(this,void 0,void 0,(function*(){for(let t of this.children)yield t.paint()}))}childrenMaxWidth(){return Math.max(...this.children.map(t=>t.offsetWidth),0)}childrenMaxHeight(){return Math.max(...this.children.map(t=>t.offsetHeight),0)}}var z=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function h(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}l((n=n.apply(t,e||[])).next())}))};class I extends s{constructor(t,e,i){super(t,e,i),this.contentElement=M(t,e.content,this),this.clipPath=P(this,e.path)}_layout(){return this.contentElement.layout()}paint(){return z(this,void 0,void 0,(function*(){this.painter.ctx.save(),yield this.clipPath.paint(),this.painter.ctx.clip(),yield this.contentElement.paint(),this.painter.ctx.restore()}))}}var C=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function h(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}l((n=n.apply(t,e||[])).next())}))};class L extends s{constructor(t,e,i){var n,o;super(t,e,i),this.contentElement=M(t,e.content,this),this.transformOptions=null!==(n=e.transform)&&void 0!==n?n:[],this.transformOrigin=null!==(o=e.transformOrigin)&&void 0!==o?o:["center","center"]}_layout(){return this.contentElement.layout()}paint(){return C(this,void 0,void 0,(function*(){this.painter.ctx.save(),this.withTransformOrigin(()=>this.transform()),yield this.contentElement.paint(),this.painter.ctx.restore()}))}transform(){this.transformOptions.forEach(t=>this.singleTransform(t))}singleTransform(t){var e,i,n,o;switch(t.type){case"translate":return this.painter.ctx.translate(this.painter.upx2px(null!==(e=t.x)&&void 0!==e?e:0),this.painter.upx2px(null!==(i=t.y)&&void 0!==i?i:0));case"rotate":return this.painter.ctx.rotate(t.rotate/180*Math.PI);case"scale":return this.painter.ctx.scale(null!==(n=t.scaleWidth)&&void 0!==n?n:1,null!==(o=t.scaleHeight)&&void 0!==o?o:1);case"set-matrix":return this.painter.ctx.setTransform(t.scaleX,t.skewX,t.skewY,t.scaleY,this.painter.upx2px(t.translateX),this.painter.upx2px(t.translateY));default:throw new Error("Unknown transform type.")}}withTransformOrigin(t){const e={x:this.elementX+this.contentWidth*{left:0,center:.5,right:1}[this.transformOrigin[0]],y:this.elementY+this.contentHeight*{top:0,center:.5,bottom:1}[this.transformOrigin[1]]};this.singleTransform({type:"translate",x:e.x,y:e.y}),t(),this.singleTransform({type:"translate",x:-e.x,y:-e.y})}}function M(t,e,i){switch(e.type){case"text":return new p(t,e,i);case"text-block":return new m(t,e,i);case"image":return new W(t,e,i);case"line":return new c(t,e,i);case"rect":return new j(t,e,i);case"container":return new F(t,e,i);case"clip":return new I(t,e,i);case"transform":return new L(t,e,i);default:throw new TypeError("Unkown painter element type")}}let R=function(){var t;if("function"==typeof o.upx2px)return o.upx2px;let e=(null!==(t=o.getSystemInfoSync().screenWidth)&&void 0!==t?t:375)/750;return function(t){return t*e}}();const E=[.296,.313,.436,.638,.586,.89,.87,.256,.334,.334,.455,.742,.241,.433,.241,.427,.586,.586,.586,.586,.586,.586,.586,.586,.586,.586,.241,.241,.742,.742,.742,.483,1.031,.704,.627,.669,.762,.55,.531,.744,.773,.294,.396,.635,.513,.977,.813,.815,.612,.815,.653,.577,.573,.747,.676,1.018,.645,.604,.62,.334,.416,.334,.742,.448,.295,.553,.639,.501,.64,.567,.347,.64,.616,.266,.267,.544,.266,.937,.616,.636,.639,.64,.382,.463,.373,.616,.525,.79,.507,.529,.492,.334,.269,.334,.742,.296];var X=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function h(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}l((n=n.apply(t,e||[])).next())}))};const Y=w();class B extends Y{constructor(t,e){super(e),this.painter=t}drawImageWithSrc(t,e,i,n,o,r,s,h,l){const a=Object.create(null,{drawImage:{get:()=>super.drawImage}});return X(this,void 0,void 0,(function*(){"number"==typeof r&&"number"==typeof s&&"number"==typeof h&&"number"==typeof l?a.drawImage.call(this,t,e,i,n,o,r,s,h,l):a.drawImage.call(this,t,e,i,n,o)}))}measureTextWidth(t,e){var i;return this.setFontSize(e),null!==(i=this.measureText(t).width)&&void 0!==i?i:0}}class H extends B{measureTextWidth(t,e){return t.split("").reduce((t,e)=>{let i=e.charCodeAt(0);return t+(E[i-32]||1)},0)*e}}var _=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function h(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}l((n=n.apply(t,e||[])).next())}))};class D extends B{measureTextWidth(t,e){var i;return"top"==t&&console.log("measureText("+t+").width=",super.measureText(t).width),(null!==(i=super.measureText(t).width)&&void 0!==i?i:0)/10*e}drawImageWithSrc(t,e,i,n,o,r,s,h,l){const a=Object.create(null,{drawImageWithSrc:{get:()=>super.drawImageWithSrc}});return _(this,void 0,void 0,(function*(){"number"==typeof r&&"number"==typeof s&&"number"==typeof h&&"number"==typeof l?a.drawImageWithSrc.call(this,t,r,s,h,l,e,i,n,o):a.drawImageWithSrc.call(this,t,e,i,n,o)}))}}class U extends B{arcTo(t,e,i,n,o){return o<2?this.lineTo(t,e):super.arcTo(t,e,i,n,o)}measureTextWidth(t,e){return(t.includes("\n")||t.includes("\r"))&&console.warn(`mp-painter:measureText:字符串 "${t}" 中包含换行符,结果在 iPhone 上可能不准确`),super.measureTextWidth(t,e)}}i.d(e,"default",(function(){return A}));var N=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function h(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}l((n=n.apply(t,e||[])).next())}))};class A{constructor(t,{platform:e=n,upx2px:i}={}){this.platform=e,this.upx2px=null!=i?i:R,"mp-alipay"==e&&(this.upx2px=t=>(null!=i?i:R)(2*t)),this.ctx=function(t,e){switch(t.platform){case"h5":return new y(t,e);case"mp-weixin":return new U(t,e);case"mp-alipay":return new H(t,e);case"mp-baidu":return new D(t,e);default:throw new Error("mp-painter: unexpect platform :"+t.platform)}}(this,t)}draw(t,e={}){return N(this,void 0,void 0,(function*(){let e=M(this,t),i=yield e.layout();return yield e.paint(),yield new Promise(t=>this.ctx.draw(!0,t)),yield function(t=0){return new Promise(e=>setTimeout(e,t))}(100),i}))}createElement(t){return M(this,t)}layout(t){return N(this,void 0,void 0,(function*(){return yield this.createElement(t).layout()}))}toJSON(){return"Painter Instance"}}}]);
\ No newline at end of file
import { PainterElementOption } from "./painter-element/base";
export interface Size {
width: number;
height: number;
}
export interface Rect {
top: number;
left: number;
width: number;
height: number;
}
export declare type BaseLine = "top" | "middle" | "bottom" | "normal";
export declare type BorderRadius = number | BorderRadius4;
export declare type BorderRadius4 = [topLeft: number, topRight: number, bottomLeft: number, bottomRight: number];
export declare type BorderStyle = "solid" | "dashed";
/** @example "#rrggbb" | "#rgb" | "colorName" */
export declare type Color = string;
export interface ColorStop {
offset: number;
color: Color;
}
export declare type FillStrokeStyle = string | CanvasGradient | CanvasPattern;
export declare type FontWeight = "normal" | "bold";
export declare type FontStyle = "normal" | "italic";
export declare type ObjectFit = "fill" | "contain" | "cover";
export declare type ObjectPosition = ["left" | "center" | "right", "top" | "center" | "bottom"];
export declare type Position = "static" | "absolute";
export declare type TextAlign = "left" | "right" | "center";
export declare type TextDecoration = "none" | "line-through";
/** left-top right-top right-bottom left-bottom */
export declare type OmitBaseOption<T> = Omit<T, keyof PainterElementOption>;
export declare function cssBorderStyleToLinePattern(borderStyle: BorderStyle, borderWidth: number): [number, number];
...@@ -265,6 +265,7 @@ ...@@ -265,6 +265,7 @@
mobile: res['data']['mobile'], mobile: res['data']['mobile'],
partnerType:res['data']['partnerType'], partnerType:res['data']['partnerType'],
nickName:res['data']['nickName'], nickName:res['data']['nickName'],
levelCode:res['data']['levelCode'],
} }
uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo)) uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo))
......
...@@ -6,6 +6,7 @@ const dev = { ...@@ -6,6 +6,7 @@ const dev = {
cffp_url:'https://mdev.anjibao.cn/cffpApi/cffp', cffp_url:'https://mdev.anjibao.cn/cffpApi/cffp',
share_url:'https://mdev.anjibao.cn/cffp', share_url:'https://mdev.anjibao.cn/cffp',
sfp_url:'https://mdev.anjibao.cn/sfpApi', sfp_url:'https://mdev.anjibao.cn/sfpApi',
img_url:'https://mdev.zuihuibi.cn'
} }
const stage = { const stage = {
base_url:'https://mstage.zuihuibi.cn', base_url:'https://mstage.zuihuibi.cn',
...@@ -20,7 +21,8 @@ const prod = { ...@@ -20,7 +21,8 @@ const prod = {
api_url:'https://app.ydhomeoffice.cn/appApi', api_url:'https://app.ydhomeoffice.cn/appApi',
cffp_url:'https://app.ydhomeoffice.cn/appApi/cffp', cffp_url:'https://app.ydhomeoffice.cn/appApi/cffp',
share_url:'https://app.ydhomeoffice.cn/appYdhomeoffice', share_url:'https://app.ydhomeoffice.cn/appYdhomeoffice',
sfp_url:'https://hoservice.ydhomeoffice.cn/hoserviceApi' sfp_url:'https://hoservice.ydhomeoffice.cn/hoserviceApi',
img_url:'https://app.ydhomeoffice.cn'
} }
// companyType: '1', cffp // companyType: '1', cffp
// companyType: '2', appYdhomeoffice // companyType: '2', appYdhomeoffice
...@@ -51,6 +53,7 @@ let apiURL = config[env].api_url; ...@@ -51,6 +53,7 @@ let apiURL = config[env].api_url;
let cffpURL = config[env].cffp_url; let cffpURL = config[env].cffp_url;
let shareURL = config[env].share_url; let shareURL = config[env].share_url;
let sfpUrl = config[env].sfp_url; let sfpUrl = config[env].sfp_url;
let imgUrl = config[env].img_url;
export{ export{
baseURL, baseURL,
...@@ -59,4 +62,6 @@ export{ ...@@ -59,4 +62,6 @@ export{
companyInfo, companyInfo,
shareURL, shareURL,
sfpUrl, sfpUrl,
env,
imgUrl
} }
\ No newline at end of file
...@@ -118,6 +118,7 @@ ...@@ -118,6 +118,7 @@
import * as environment from "@/environments/environment"; import * as environment from "@/environments/environment";
import common from '@/common/common'; import common from '@/common/common';
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components:{ components:{
everyJoinPopup, everyJoinPopup,
...@@ -177,8 +178,9 @@ ...@@ -177,8 +178,9 @@
if(uni.getStorageSync('cffp_userId')){ if(uni.getStorageSync('cffp_userId')){
this.userId = uni.getStorageSync('cffp_userId') this.userId = uni.getStorageSync('cffp_userId')
} }
if(!uni.getStorageSync('loginType')){ if(!uni.getStorageSync('loginType') || this.loginType == 'visitor'){
this.loginType = 'visitor' this.loginType = 'visitor'
this.checkToken()
} }
// 非邀请状态 // 非邀请状态
if(!this.inviteUserId&&this.loginType == 'codelogin'&&this.userInfo.mobile){ if(!this.inviteUserId&&this.loginType == 'codelogin'&&this.userInfo.mobile){
...@@ -189,9 +191,34 @@ ...@@ -189,9 +191,34 @@
if(!this.inviteUserId&&this.loginType == 'codelogin'&&!this.form.nickName){ if(!this.inviteUserId&&this.loginType == 'codelogin'&&!this.form.nickName){
this.queryInfo() this.queryInfo()
} }
// 登录状态
if(this.loginType == 'codelogin'){
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}
}, },
methods: { methods: {
// 未登录状态下需要重新获取token
checkToken(){
api.checkToken().then(res=>{
if(res['success']){}else{
api.obtainToken().then(res=>{
if(res.success){
uni.setStorageSync('uni-token',res.data['token']);
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}
})
}
})
},
getqueryById(shareId){ getqueryById(shareId){
api.queryById({id:shareId}).then(res =>{ api.queryById({id:shareId}).then(res =>{
this.form.nickName = res.data.data.name this.form.nickName = res.data.data.name
...@@ -348,6 +375,7 @@ ...@@ -348,6 +375,7 @@
mobile: res['data']['mobile'], mobile: res['data']['mobile'],
partnerType:res['data']['partnerType'], partnerType:res['data']['partnerType'],
nickName:res['data']['nickName'], nickName:res['data']['nickName'],
levelCode:res['data']['levelCode'],
} }
uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo)) uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo))
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
import api from '../../api/api'; import api from '../../api/api';
import common from '../../common/common'; import common from '../../common/common';
import {companyInfo} from "@/environments/environment"; import {companyInfo} from "@/environments/environment";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -350,6 +351,11 @@ ...@@ -350,6 +351,11 @@
api.obtainToken().then(res=>{ api.obtainToken().then(res=>{
if(res.success){ if(res.success){
uni.setStorageSync('uni-token',res.data['token']); uni.setStorageSync('uni-token',res.data['token']);
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
} }
}) })
} }
...@@ -359,6 +365,7 @@ ...@@ -359,6 +365,7 @@
}, },
onShow() { onShow() {
this.checkToken(); this.checkToken();
}, },
destroyed() { destroyed() {
uni.hideToast(); uni.hideToast();
......
<template>
<view class="container">
<!-- 添加ref以便获取DOM -->
<view class="imgBox" ref="captureElement" v-if="!generatedImage">
<view class="imgContainer">
<image
style="display: block;"
src="@/static/images/sharePoster.png"
mode="widthFix"
@load="handleBgImageLoad"
@error="handleBgImageError"
></image>
<!-- 二维码容器 -->
<view class="qrcode-container">
<canvas
canvas-id="qrcode"
class="qrcode-canvas"
:style="{width: qrcodeSize + 'px', height: qrcodeSize + 'px'}"
></canvas>
</view>
</view>
</view>
<!-- 添加生成的图片预览 -->
<view class="preview-container" v-if="generatedImage">
<image :src="generatedImage" mode="widthFix" class="preview-image"></image>
</view>
</view>
</template>
<script>
import * as environment from "@/environments/environment";
import UQRCode from 'uqrcodejs';
import { elementToImage } from '@/util/htmlToImage';
import registerBg from '@/static/registerBg.png'
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default {
data() {
return {
companyInfo: environment.companyInfo,
imgType: environment.companyInfo.imgType,
baseURL: environment.baseURL,
shareId: '',
invitationCode: '',
codeUrl: '',
loginType: '',
userInfo: {},
qrcodeSize: 100, // 二维码大小(单位px)
generatedImage: '', // 生成的图片
isBgImageReady: false, // 背景图片是否准备就绪
retryCount: 0, // 重试次数
maxRetryCount: 3 // 最大重试次数
}
},
onShow() {
this.userInfo = uni.getStorageSync('userinfodataForm')
this.loginType = uni.getStorageSync('loginType')
if(!this.loginType || this.loginType == 'visitor'){
this.codeUrl = `${this.baseURL}/pages/index/index`
} else {
this.codeUrl = `${this.baseURL}/pages/index/index?invitationCode=${this.userInfo.invitationCode}&inviteUserId=${this.userInfo.userId}&sharePoster=1`
}
// 1. 首先检查是否有缓存的图片
const cachedImage = uni.getStorageSync('savedShareImage');
if (cachedImage) {
this.generatedImage = cachedImage;
return; // 如果有缓存,直接使用,不再执行后续生成逻辑
}
// 重置状态
this.isBgImageReady = false;
this.retryCount = 0;
// 开始加载背景图片(由@load事件触发后续流程)
console.log('开始加载背景图片...');
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods: {
// 背景图片加载成功
handleBgImageLoad() {
console.log('背景图片加载完成');
this.isBgImageReady = true;
this.generateQrcodeAndCapture();
},
// 背景图片加载失败
handleBgImageError() {
console.error('背景图片加载失败');
// 即使失败也继续流程,可能会有默认背景
this.isBgImageReady = true;
this.generateQrcodeAndCapture();
},
// 顺序执行:生成二维码 -> 截图
async generateQrcodeAndCapture() {
// 再次检查缓存(防止并发情况)
if (uni.getStorageSync('savedShareImage')) {
return;
}
try {
uni.showLoading({
title: '准备生成分享图...'
});
// 1. 先生成二维码
console.log('开始生成二维码...');
await this.makeQrcode();
console.log('二维码生成完成');
// 2. 等待500ms确保渲染完成
await new Promise(resolve => setTimeout(resolve, 500));
// 3. 执行截图
console.log('开始截图...');
await this.captureImage();
console.log('截图完成');
uni.hideLoading();
} catch (error) {
console.error('生成分享图失败:', error);
uni.hideLoading();
this.retryGenerate();
}
},
// 重试机制
retryGenerate() {
if (this.retryCount < this.maxRetryCount) {
this.retryCount++;
const delay = 1000 * this.retryCount;
console.log(`第${this.retryCount}次重试,${delay}ms后重试...`);
// uni.showToast({
// title: `生成中,请稍候...(${this.retryCount}/${this.maxRetryCount})`,
// icon: 'none',
// duration: delay
// });
setTimeout(() => {
this.generateQrcodeAndCapture();
}, delay);
} else {
// uni.showToast({
// title: '生成分享图失败,请稍后再试',
// icon: 'none'
// });
}
},
// 生成二维码
makeQrcode() {
return new Promise((resolve, reject) => {
// 创建实例
const qr = new UQRCode();
// 设置二维码内容
qr.data = this.codeUrl;
// 设置二维码大小
qr.size = this.qrcodeSize;
// 设置前景色(二维码颜色)
qr.foregroundColor = '#000000';
// 设置背景色
qr.backgroundColor = '#FFFFFF';
// 设置边距
qr.margin = 10;
// 设置纠错等级
qr.errorCorrectLevel = UQRCode.errorCorrectLevel.H;
try {
// 调用制作二维码方法
qr.make();
// 获取canvas上下文
const ctx = uni.createCanvasContext('qrcode', this);
// 清空画布
ctx.clearRect(0, 0, this.qrcodeSize, this.qrcodeSize);
// 将二维码绘制到canvas上
qr.canvasContext = ctx;
qr.drawCanvas();
// 绘制完成
ctx.draw(true, () => {
console.log('二维码绘制完成');
resolve();
});
} catch (err) {
reject(err);
}
});
},
// 截图方法
async captureImage() {
try {
uni.showLoading({
title: '正在生成图片...'
});
// 获取DOM元素(在H5环境下)
const element = this.$refs.captureElement.$el;
// 调用工具函数生成图片
const imageData = await elementToImage(element);
// 压缩图片
const compressedImage = await this.compressImage(imageData);
this.generatedImage = compressedImage;
uni.setStorageSync('savedShareImage', compressedImage);
// this.generatedImage = imageData;
// // 将生成的图片保存到本地存储
// uni.setStorageSync('savedShareImage', imageData);
} catch (error) {
console.error('截图失败:', error);
throw error; // 抛出错误以便外部捕获
} finally {
uni.hideLoading();
}
},
compressImage(base64) {
return new Promise((resolve) => {
const img = new Image();
img.src = base64;
img.onload = () => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// 设置压缩后的宽高
const maxWidth = 800;
const maxHeight = 1200;
let width = img.width;
let height = img.height;
if (width > maxWidth) {
height *= maxWidth / width;
width = maxWidth;
}
if (height > maxHeight) {
width *= maxHeight / height;
height = maxHeight;
}
canvas.width = width;
canvas.height = height;
ctx.drawImage(img, 0, 0, width, height);
// 降低质量
resolve(canvas.toDataURL('image/jpeg', 0.7));
};
});
},
saveImage(base64Data) {
// 实现保存图片到相册的逻辑
// 注意:在H5中可能需要不同的处理方式
if (uni.downloadFile) {
uni.downloadFile({
url: base64Data,
success: (res) => {
if (res.statusCode === 200) {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
uni.showToast({
title: '保存成功',
icon: 'success'
});
},
fail: (err) => {
console.error('保存失败:', err);
uni.showToast({
title: '保存失败',
icon: 'none'
});
}
});
}
},
fail: (err) => {
console.error('下载图片失败:', err);
}
});
} else {
// H5环境下的处理方式
const link = document.createElement('a');
link.href = base64Data;
link.download = 'share-image.png';
link.click();
}
}
}
}
</script>
<style lang="scss" scoped>
// .container {
// display: flex;
// flex-direction: column;
// height: 100vh;
// width: 100vw;
// .imgBox {
// position: relative;
// .imgContainer {
// position: relative;
// .qrcode-container {
// position: absolute;
// bottom: 10rpx;
// right: 10rpx;
// background: #fff;
// padding: 10rpx;
// border-radius: 10rpx;
// box-shadow: 0 0 10rpx rgba(0,0,0,0.1);
// .qrcode-canvas {
// display: block;
// }
// }
// }
// }
// .preview-container{
// box-sizing: border-box;
// flex: 1;
// padding: 30rpx;
// width: 100%;
// height: 100%;
// .preview-image {
// width: 100%;
// height: auto;
// max-height: 100%;
// object-fit: contain;
// }
// }
// }
.container {
display: flex;
flex-direction: column;
height: 100vh;
width: 100vw;
overflow: hidden;
.imgBox {
width: 100%;
height: auto;
.imgContainer {
width: 100%;
position: relative;
image {
width: 100%;
height: auto;
display: block;
}
.qrcode-container {
position: absolute;
bottom: 10rpx;
right: 10rpx;
background: #fff;
padding: 10rpx;
border-radius: 10rpx;
box-shadow: 0 0 10rpx rgba(0,0,0,0.1);
.qrcode-canvas {
display: block;
}
}
}
}
.preview-container {
flex: 1;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
.preview-image {
height: 100%; /* 让高度占满屏幕 */
width: auto; /* 宽度自动调整 */
object-fit: fill;
}
}
}
</style>
\ No newline at end of file
...@@ -81,11 +81,19 @@ ...@@ -81,11 +81,19 @@
</template> </template>
<script> <script>
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
} }
},
onShow(){
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
} }
} }
</script> </script>
......
...@@ -287,6 +287,7 @@ ...@@ -287,6 +287,7 @@
<script> <script>
import {companyInfo} from "@/environments/environment"; import {companyInfo} from "@/environments/environment";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default{ export default{
data(){ data(){
return { return {
...@@ -300,10 +301,14 @@ ...@@ -300,10 +301,14 @@
this.type = options.type; this.type = options.type;
this.isBack = options.isBack this.isBack = options.isBack
}, },
// onLoad(options){ onShow(){
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
// },
methods:{ methods:{
callCustomerService() { callCustomerService() {
const phoneNumber = '400-921-9290'; const phoneNumber = '400-921-9290';
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
</template> </template>
<script> <script>
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default{ export default{
data(){ data(){
return { return {
...@@ -64,8 +65,12 @@ ...@@ -64,8 +65,12 @@
} }
}, },
components:{}, components:{},
onLoad(){ onShow(){
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
methods:{ methods:{
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
import everyJoinPopup from "@/components/commonPopup/everyJoinPopup.vue"; import everyJoinPopup from "@/components/commonPopup/everyJoinPopup.vue";
import eSignature from '@/components/eSignature/eSignature.vue'; import eSignature from '@/components/eSignature/eSignature.vue';
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components:{eSignature,everyJoinPopup}, components:{eSignature,everyJoinPopup},
data() { data() {
...@@ -100,6 +101,11 @@ ...@@ -100,6 +101,11 @@
}, },
onShow(){ onShow(){
this.lockScroll() this.lockScroll()
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
beforeDestroy() { beforeDestroy() {
console.log('组件销毁'); console.log('组件销毁');
...@@ -259,6 +265,7 @@ ...@@ -259,6 +265,7 @@
} }
}) })
this.releaseScroll() this.releaseScroll()
this.checkToken()
} }
}) })
}, },
...@@ -267,6 +274,19 @@ ...@@ -267,6 +274,19 @@
delta: 1 delta: 1
}); });
}, },
// 未登录状态下需要重新获取token
checkToken(){
api.checkToken().then(res=>{
if(res['success']){}else{
api.obtainToken().then(res=>{
if(res.success){
uni.setStorageSync('uni-token',res.data['token']);
uni.setStorageSync('loginType', 'visitor');
}
})
}
})
},
cancel(){ cancel(){
uni.navigateBack({delta:1}) uni.navigateBack({delta:1})
}, },
......
...@@ -8,16 +8,97 @@ ...@@ -8,16 +8,97 @@
"name": "验证码输入框", "name": "验证码输入框",
"version": "2.0", "version": "2.0",
"dependencies": { "dependencies": {
"@dcloudio/uni-ui": "^1.5.10",
"@uqrcode/js": "^4.0.7",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"echarts": "^5.4.1", "echarts": "^5.4.1",
"html2canvas": "^1.4.1",
"js-sha256": "^0.11.1", "js-sha256": "^0.11.1",
"nanoid": "^4.0.0" "mp-painter": "^1.0.1",
"nanoid": "^4.0.0",
"qrcode": "^1.5.4",
"qrcodejs2": "^0.0.2",
"uqrcodejs": "^4.0.7"
}, },
"devDependencies": { "devDependencies": {
"less": "^4.3.0" "less": "^4.3.0"
} }
}, },
"node_modules/@dcloudio/uni-ui": {
"version": "1.5.10",
"resolved": "https://registry.npmmirror.com/@dcloudio/uni-ui/-/uni-ui-1.5.10.tgz",
"integrity": "sha512-v6ylkGSUF6hhgSerm8aVEQE9SBkKz3oNDzorkVC0KLHfulMbkacJQ92YFSQ0kCGeudupVqXuPwNTFjKJF5Qolw=="
},
"node_modules/@uqrcode/js": {
"version": "4.0.7",
"resolved": "https://registry.npmmirror.com/@uqrcode/js/-/js-4.0.7.tgz",
"integrity": "sha512-4lIVp0mBrZw3yltc3C0/JuxMyNcqh7olX95xQYttrotITAxCL1AA0/RdcsBTSMP1M6TcKvJSuDDNUurDKyNuNw=="
},
"node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/base64-arraybuffer": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz",
"integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==",
"engines": {
"node": ">= 0.6.0"
}
},
"node_modules/camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmmirror.com/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"engines": {
"node": ">=6"
}
},
"node_modules/cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmmirror.com/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/copy-anything": { "node_modules/copy-anything": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmmirror.com/copy-anything/-/copy-anything-2.0.6.tgz", "resolved": "https://registry.npmmirror.com/copy-anything/-/copy-anything-2.0.6.tgz",
...@@ -37,12 +118,33 @@ ...@@ -37,12 +118,33 @@
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/css-line-break": {
"version": "2.1.0",
"resolved": "https://registry.npmmirror.com/css-line-break/-/css-line-break-2.1.0.tgz",
"integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==",
"dependencies": {
"utrie": "^1.0.2"
}
},
"node_modules/dayjs": { "node_modules/dayjs": {
"version": "1.11.13", "version": "1.11.13",
"resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.13.tgz", "resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.13.tgz",
"integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==", "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/dijkstrajs": {
"version": "1.0.3",
"resolved": "https://registry.npmmirror.com/dijkstrajs/-/dijkstrajs-1.0.3.tgz",
"integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA=="
},
"node_modules/echarts": { "node_modules/echarts": {
"version": "5.6.0", "version": "5.6.0",
"resolved": "https://registry.npmmirror.com/echarts/-/echarts-5.6.0.tgz", "resolved": "https://registry.npmmirror.com/echarts/-/echarts-5.6.0.tgz",
...@@ -53,6 +155,11 @@ ...@@ -53,6 +155,11 @@
"zrender": "5.6.1" "zrender": "5.6.1"
} }
}, },
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmmirror.com/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
},
"node_modules/errno": { "node_modules/errno": {
"version": "0.1.8", "version": "0.1.8",
"resolved": "https://registry.npmmirror.com/errno/-/errno-0.1.8.tgz", "resolved": "https://registry.npmmirror.com/errno/-/errno-0.1.8.tgz",
...@@ -67,6 +174,26 @@ ...@@ -67,6 +174,26 @@
"errno": "cli.js" "errno": "cli.js"
} }
}, },
"node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmmirror.com/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmmirror.com/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/graceful-fs": { "node_modules/graceful-fs": {
"version": "4.2.11", "version": "4.2.11",
"resolved": "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.11.tgz", "resolved": "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.11.tgz",
...@@ -75,6 +202,18 @@ ...@@ -75,6 +202,18 @@
"license": "ISC", "license": "ISC",
"optional": true "optional": true
}, },
"node_modules/html2canvas": {
"version": "1.4.1",
"resolved": "https://registry.npmmirror.com/html2canvas/-/html2canvas-1.4.1.tgz",
"integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==",
"dependencies": {
"css-line-break": "^2.1.0",
"text-segmentation": "^1.0.3"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/iconv-lite": { "node_modules/iconv-lite": {
"version": "0.6.3", "version": "0.6.3",
"resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.6.3.tgz", "resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.6.3.tgz",
...@@ -103,6 +242,14 @@ ...@@ -103,6 +242,14 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmmirror.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"engines": {
"node": ">=8"
}
},
"node_modules/is-what": { "node_modules/is-what": {
"version": "3.14.1", "version": "3.14.1",
"resolved": "https://registry.npmmirror.com/is-what/-/is-what-3.14.1.tgz", "resolved": "https://registry.npmmirror.com/is-what/-/is-what-3.14.1.tgz",
...@@ -143,6 +290,17 @@ ...@@ -143,6 +290,17 @@
"source-map": "~0.6.0" "source-map": "~0.6.0"
} }
}, },
"node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmmirror.com/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/make-dir": { "node_modules/make-dir": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmmirror.com/make-dir/-/make-dir-2.1.0.tgz", "resolved": "https://registry.npmmirror.com/make-dir/-/make-dir-2.1.0.tgz",
...@@ -172,6 +330,11 @@ ...@@ -172,6 +330,11 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/mp-painter": {
"version": "1.0.1",
"resolved": "https://registry.npmmirror.com/mp-painter/-/mp-painter-1.0.1.tgz",
"integrity": "sha512-qq7Pt2o4MEbfM0XVfuObQTnhq5rAprudLexNvQ4nBQL/dgQPq1BvBzwhRYGrUEMB0UpOcKTw+xpaEW0ZMyL89Q=="
},
"node_modules/nanoid": { "node_modules/nanoid": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-4.0.2.tgz", "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-4.0.2.tgz",
...@@ -208,6 +371,39 @@ ...@@ -208,6 +371,39 @@
"node": ">= 4.4.x" "node": ">= 4.4.x"
} }
}, },
"node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmmirror.com/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmmirror.com/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmmirror.com/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"engines": {
"node": ">=6"
}
},
"node_modules/parse-node-version": { "node_modules/parse-node-version": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmmirror.com/parse-node-version/-/parse-node-version-1.0.1.tgz", "resolved": "https://registry.npmmirror.com/parse-node-version/-/parse-node-version-1.0.1.tgz",
...@@ -218,6 +414,14 @@ ...@@ -218,6 +414,14 @@
"node": ">= 0.10" "node": ">= 0.10"
} }
}, },
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmmirror.com/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"engines": {
"node": ">=8"
}
},
"node_modules/pify": { "node_modules/pify": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmmirror.com/pify/-/pify-4.0.1.tgz", "resolved": "https://registry.npmmirror.com/pify/-/pify-4.0.1.tgz",
...@@ -229,6 +433,14 @@ ...@@ -229,6 +433,14 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/pngjs": {
"version": "5.0.0",
"resolved": "https://registry.npmmirror.com/pngjs/-/pngjs-5.0.0.tgz",
"integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==",
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/prr": { "node_modules/prr": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmmirror.com/prr/-/prr-1.0.1.tgz", "resolved": "https://registry.npmmirror.com/prr/-/prr-1.0.1.tgz",
...@@ -237,6 +449,40 @@ ...@@ -237,6 +449,40 @@
"license": "MIT", "license": "MIT",
"optional": true "optional": true
}, },
"node_modules/qrcode": {
"version": "1.5.4",
"resolved": "https://registry.npmmirror.com/qrcode/-/qrcode-1.5.4.tgz",
"integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==",
"dependencies": {
"dijkstrajs": "^1.0.1",
"pngjs": "^5.0.0",
"yargs": "^15.3.1"
},
"bin": {
"qrcode": "bin/qrcode"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/qrcodejs2": {
"version": "0.0.2",
"resolved": "https://registry.npmmirror.com/qrcodejs2/-/qrcodejs2-0.0.2.tgz",
"integrity": "sha512-+Y4HA+cb6qUzdgvI3KML8GYpMFwB24dFwzMkS/yXq6hwtUGNUnZQdUnksrV1XGMc2mid5ROw5SAuY9XhI3ValA=="
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmmirror.com/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmmirror.com/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
},
"node_modules/safer-buffer": { "node_modules/safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz", "resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz",
...@@ -264,6 +510,11 @@ ...@@ -264,6 +510,11 @@
"semver": "bin/semver" "semver": "bin/semver"
} }
}, },
"node_modules/set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmmirror.com/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw=="
},
"node_modules/source-map": { "node_modules/source-map": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz",
...@@ -275,12 +526,113 @@ ...@@ -275,12 +526,113 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/text-segmentation": {
"version": "1.0.3",
"resolved": "https://registry.npmmirror.com/text-segmentation/-/text-segmentation-1.0.3.tgz",
"integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==",
"dependencies": {
"utrie": "^1.0.2"
}
},
"node_modules/tslib": { "node_modules/tslib": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz", "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz",
"integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==",
"license": "0BSD" "license": "0BSD"
}, },
"node_modules/uqrcodejs": {
"version": "4.0.7",
"resolved": "https://registry.npmmirror.com/uqrcodejs/-/uqrcodejs-4.0.7.tgz",
"integrity": "sha512-84+aZmD2godCVI+93lxE3YUAPNY8zAJvNA7xRS7R7U+q57KzMDepBSfNCwoRUhWOfR6eHFoAOcHRPwsP6ka1cA=="
},
"node_modules/utrie": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/utrie/-/utrie-1.0.2.tgz",
"integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==",
"dependencies": {
"base64-arraybuffer": "^1.0.2"
}
},
"node_modules/which-module": {
"version": "2.0.1",
"resolved": "https://registry.npmmirror.com/which-module/-/which-module-2.0.1.tgz",
"integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ=="
},
"node_modules/wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/y18n": {
"version": "4.0.3",
"resolved": "https://registry.npmmirror.com/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ=="
},
"node_modules/yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmmirror.com/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"dependencies": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
},
"engines": {
"node": ">=8"
}
},
"node_modules/yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmmirror.com/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"dependencies": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/zrender": { "node_modules/zrender": {
"version": "5.6.1", "version": "5.6.1",
"resolved": "https://registry.npmmirror.com/zrender/-/zrender-5.6.1.tgz", "resolved": "https://registry.npmmirror.com/zrender/-/zrender-5.6.1.tgz",
......
...@@ -15,11 +15,18 @@ ...@@ -15,11 +15,18 @@
] ]
}, },
"dependencies": { "dependencies": {
"@dcloudio/uni-ui": "^1.5.10",
"@uqrcode/js": "^4.0.7",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"echarts": "^5.4.1", "echarts": "^5.4.1",
"html2canvas": "^1.4.1",
"js-sha256": "^0.11.1", "js-sha256": "^0.11.1",
"nanoid": "^4.0.0" "mp-painter": "^1.0.1",
"nanoid": "^4.0.0",
"qrcode": "^1.5.4",
"qrcodejs2": "^0.0.2",
"uqrcodejs": "^4.0.7"
}, },
"devDependencies": { "devDependencies": {
"less": "^4.3.0" "less": "^4.3.0"
......
...@@ -539,6 +539,11 @@ ...@@ -539,6 +539,11 @@
"style": { "style": {
"navigationBarTitleText": "协议" "navigationBarTitleText": "协议"
} }
},{
"path": "poster/poster",
"style": {
"navigationBarTitleText": "分销海报"
}
} }
] ]
},{ },{
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
import courseItem from "@/components/courseItem/courseItem.vue"; import courseItem from "@/components/courseItem/courseItem.vue";
import api from "@/api/api"; import api from "@/api/api";
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components:{courseItem}, components:{courseItem},
data() { data() {
...@@ -147,6 +148,13 @@ ...@@ -147,6 +148,13 @@
this.afterSalesFlag = option.afterSalesFlag; this.afterSalesFlag = option.afterSalesFlag;
this.userAfterSalesDtl() this.userAfterSalesDtl()
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
mounted() { mounted() {
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import api from "@/api/api"; import api from "@/api/api";
import courseItem from "@/components/courseItem/courseItem.vue"; import courseItem from "@/components/courseItem/courseItem.vue";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components:{ components:{
courseItem courseItem
...@@ -70,7 +71,14 @@ ...@@ -70,7 +71,14 @@
}, },
onLoad() { onLoad() {
this.userAfterSales() this.userAfterSales()
} },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
} }
</script> </script>
......
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
import courseItem from "@/components/courseItem/courseItem.vue"; import courseItem from "@/components/courseItem/courseItem.vue";
import commonSelect from '@/components/commonSelect/commonSelect.vue'; import commonSelect from '@/components/commonSelect/commonSelect.vue';
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components:{ components:{
courseItem, courseItem,
...@@ -223,6 +224,11 @@ ...@@ -223,6 +224,11 @@
}, },
onShow() { onShow() {
this.userRefundCourseDtl(); this.userRefundCourseDtl();
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
} }
} }
</script> </script>
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<script> <script>
// import myListItem from "@/components/my-list-item/my-list-item.vue"; // import myListItem from "@/components/my-list-item/my-list-item.vue";
import api from "@/api/api"; import api from "@/api/api";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
// components:{ // components:{
// myListItem // myListItem
...@@ -76,6 +77,13 @@ ...@@ -76,6 +77,13 @@
this.readId = option.readId; this.readId = option.readId;
this.queryDate = option.queryDate; this.queryDate = option.queryDate;
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
mounted() { mounted() {
if(this.type=='1'){ if(this.type=='1'){
this.typeName = '分享'; this.typeName = '分享';
......
...@@ -54,7 +54,8 @@ ...@@ -54,7 +54,8 @@
<view class="courseTitleContent"> <view class="courseTitleContent">
<view class="courseTitle"> <view class="courseTitle">
<view class="" style="width: 100%;"> <view class="" style="width: 100%;">
<h4>{{courseInfo.fileTitle}}</h4> <h4>{{courseInfo.fileSynopsis}}</h4>
<view>{{courseInfo.fileTitle}}</view>
</view> </view>
</view> </view>
...@@ -190,11 +191,11 @@ ...@@ -190,11 +191,11 @@
import VerifyPopup from "@/components/unipopup/verifyPopup.vue"; import VerifyPopup from "@/components/unipopup/verifyPopup.vue";
import UniShareWx from "@/uni_modules/uni-share-wx/index.vue"; import UniShareWx from "@/uni_modules/uni-share-wx/index.vue";
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import {hshare} from '@/util/fiveshare'; import {hshare,setWechatShare,initJssdkShare} from '@/util/fiveshare';
import {nanoid} from 'nanoid'; import {nanoid} from 'nanoid';
import common from '../../common/common'; import common from '../../common/common';
import {baseURL,apiURL,cffpURL,companyInfo,shareURL} from "@/environments/environment"; import {baseURL,apiURL,cffpURL,companyInfo,shareURL} from "@/environments/environment";
export default { export default {
components: { components: {
UniShareWx, UniShareWx,
...@@ -317,6 +318,7 @@ ...@@ -317,6 +318,7 @@
this.continueShare() this.continueShare()
}, },
continueShare(){ continueShare(){
this.userId = uni.getStorageSync('cffp_userId')
const shareCode = nanoid() + this.userId const shareCode = nanoid() + this.userId
const jumptime = Date.parse(new Date()) / 1000 const jumptime = Date.parse(new Date()) / 1000
//app分享 //app分享
...@@ -626,7 +628,7 @@ ...@@ -626,7 +628,7 @@
//this.courseInfo.serviceContent = res['data']['data']['filePathOss']; //this.courseInfo.serviceContent = res['data']['data']['filePathOss'];
this.lecturerId = res['data']['data']['fileLecturerId']; this.lecturerId = res['data']['data']['fileLecturerId'];
// this.lecturerQuery(); // this.lecturerQuery();
this.relatedCoursesList(); // this.relatedCoursesList();
if (uni.getStorageSync('h5_coursesharing')) { if (uni.getStorageSync('h5_coursesharing')) {
this.coursesharing = uni.getStorageSync('h5_coursesharing') this.coursesharing = uni.getStorageSync('h5_coursesharing')
this.getshareData() this.getshareData()
...@@ -1028,7 +1030,12 @@ ...@@ -1028,7 +1030,12 @@
if(uni.getStorageSync('cffp_userInfo')){ if(uni.getStorageSync('cffp_userInfo')){
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo')) this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
} }
this.userId = uni.getStorageSync('cffp_userId')
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
mounted() { mounted() {
let _this = this; let _this = this;
...@@ -1076,6 +1083,11 @@ ...@@ -1076,6 +1083,11 @@
clearInterval(this.timer) clearInterval(this.timer)
} }
} }
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
} }
} }
</script> </script>
......
...@@ -26,6 +26,12 @@ ...@@ -26,6 +26,12 @@
</view> </view>
<view class="productBox"> <view class="productBox">
<view class="productList" :style="{marginTop}"> <view class="productList" :style="{marginTop}">
<view class="tabBox">
<!-- @click="courseClassify=4;courseList()" -->
<view :class="{'actived': courseClassify==4}" @click="transform('consult')"><text>咨询产品</text></view>
<!-- @click="courseClassify=3;courseList()" -->
<view :class="{'actived': courseClassify==3}" @click="transform('plan')"><text>规划产品</text></view>
</view>
<view class="productItem" v-for="item in localCourseInfos" :key="item.fileId" > <view class="productItem" v-for="item in localCourseInfos" :key="item.fileId" >
<view class="top" @click="goDetail(item)"> <view class="top" @click="goDetail(item)">
<view class="left"> <view class="left">
...@@ -33,10 +39,10 @@ ...@@ -33,10 +39,10 @@
</view> </view>
<view class="right"> <view class="right">
<view class="one"> <view class="one">
{{item.fileTitle}} {{item.fileSynopsis}}
</view> </view>
<view class="two"> <view class="two">
{{item.fileSynopsis}} {{item.fileTitle}}
</view> </view>
<view class="three"> <view class="three">
<text style="font-size: 28rpx;color: rgba(32, 39, 155, 1);">{{Number(item.coursePrice).toFixed(2)}}</text> <text style="font-size: 28rpx;color: rgba(32, 39, 155, 1);">{{Number(item.coursePrice).toFixed(2)}}</text>
...@@ -102,6 +108,7 @@ ...@@ -102,6 +108,7 @@
</template> </template>
<script> <script>
import BootPage from "@/components/bootpage/bootpage.vue"; import BootPage from "@/components/bootpage/bootpage.vue";
import PartnerTipPopup from "@/components/commonPopup/PartnerTipPopup.vue"; import PartnerTipPopup from "@/components/commonPopup/PartnerTipPopup.vue";
import api from "../../api/api"; import api from "../../api/api";
...@@ -111,7 +118,7 @@ ...@@ -111,7 +118,7 @@
import search from '@/components/search/search.vue'; import search from '@/components/search/search.vue';
import {baseURL,apiURL,cffpURL,companyInfo,shareURL} from "@/environments/environment"; import {baseURL,apiURL,cffpURL,companyInfo,shareURL} from "@/environments/environment";
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import {hshare} from '@/util/fiveshare'; import {hshare,setWechatShare,initJssdkShare} from '@/util/fiveshare';
import UniShareWx from "@/uni_modules/uni-share-wx/index.vue"; import UniShareWx from "@/uni_modules/uni-share-wx/index.vue";
import {nanoid} from 'nanoid'; import {nanoid} from 'nanoid';
export default{ export default{
...@@ -158,6 +165,7 @@ ...@@ -158,6 +165,7 @@
env:dataHandling.getRuntimeEnv2(), env:dataHandling.getRuntimeEnv2(),
shareItem:{},//分享的产品 shareItem:{},//分享的产品
sharelogin: false, sharelogin: false,
courseClassify:4,
} }
}, },
...@@ -173,7 +181,12 @@ ...@@ -173,7 +181,12 @@
if(uni.getStorageSync('cffp_userInfo')){ if(uni.getStorageSync('cffp_userInfo')){
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo')) this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
} }
this.userId = uni.getStorageSync('cffp_userId')
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
created(){ created(){
this.queryName = uni.getStorageSync('queryName') || ''; this.queryName = uni.getStorageSync('queryName') || '';
...@@ -195,6 +208,15 @@ ...@@ -195,6 +208,15 @@
} }
}, },
methods:{ methods:{
transform(value){
if(value == 'consult'){
this.courseClassify = 4
}else if(value == 'plan'){
this.courseClassify = 3
}
this.$emit('changeCourseClassify',this.courseClassify)
this.courseList()
},
gotoJoinPartner(){ gotoJoinPartner(){
dataHandling.pocessTracking( dataHandling.pocessTracking(
'点击', '点击',
...@@ -255,7 +277,7 @@ ...@@ -255,7 +277,7 @@
this.continueShare() this.continueShare()
}, },
continueShare(){ continueShare(){
console.log('this.shareItem',this.shareItem); this.userId = uni.getStorageSync('cffp_userId')
const shareCode = nanoid() + this.userId const shareCode = nanoid() + this.userId
const jumptime = Date.parse(new Date()) / 1000 const jumptime = Date.parse(new Date()) / 1000
//app分享 //app分享
...@@ -310,7 +332,13 @@ ...@@ -310,7 +332,13 @@
url = window.sessionStorage.getItem('firstEntryUrl').split('#')[0]; url = window.sessionStorage.getItem('firstEntryUrl').split('#')[0];
} }
} }
hshare(data, url) setTimeout(()=>{
initJssdkShare(() => {
setWechatShare(data);
}, url);
},500)
// hshare(data, url)
this.submitsuessc(shareCode,jumptime,item) this.submitsuessc(shareCode,jumptime,item)
dataHandling.pocessTracking( dataHandling.pocessTracking(
...@@ -339,6 +367,11 @@ ...@@ -339,6 +367,11 @@
} }
api.userShare(UserShareRequestVO).then(res => { api.userShare(UserShareRequestVO).then(res => {
if (res['success']) { if (res['success']) {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
// uni.showToast({ // uni.showToast({
// title: '分享成功', // title: '分享成功',
// duration: 2000 // duration: 2000
...@@ -397,7 +430,8 @@ ...@@ -397,7 +430,8 @@
}, },
courseList(){ courseList(){
const param = { const param = {
queryName:this.queryName queryName:this.queryName,
courseClassify:this.courseClassify
} }
api.courseList(param).then(res=>{ api.courseList(param).then(res=>{
if(res['success']){ if(res['success']){
...@@ -416,7 +450,8 @@ ...@@ -416,7 +450,8 @@
const cffp_userInfo = { const cffp_userInfo = {
name: res['data']['userReName'], name: res['data']['userReName'],
mobile: res['data']['mobile'], mobile: res['data']['mobile'],
partnerType:res['data']['partnerType'] partnerType:res['data']['partnerType'],
levelCode:res['data']['levelCode'],
} }
uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo)); uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo));
this.fileUploadItemCFFPList = uni.getStorageSync('fileUploadItemCFFPList'); this.fileUploadItemCFFPList = uni.getStorageSync('fileUploadItemCFFPList');
...@@ -450,6 +485,26 @@ ...@@ -450,6 +485,26 @@
width: 100%; width: 100%;
height: auto; height: auto;
box-sizing: border-box; box-sizing: border-box;
.tabBox{
display: flex;
align-items: center;
height: 88rpx;
margin-bottom: 20rpx;
background: #fafafa;
border-bottom: 1px solid #262088;
view{
color: #000;
width: 160rpx;
height: 100%;
text-align: center;
margin-right:30rpx ;
line-height: 88rpx;
&.actived{
background-color: #262088;
color: #fff;
}
}
}
.homeHeader{ .homeHeader{
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
......
...@@ -64,7 +64,11 @@ ...@@ -64,7 +64,11 @@
</view> </view>
</view> --> </view> -->
<view class="productList" v-if="cffpCourseInfos.length>0"> <view class="productList" v-if="cffpCourseInfos.length>0">
<courselist :showFlag="false" :cffpCourseInfos="cffpCourseInfos"></courselist> <courselist
:showFlag="false"
:cffpCourseInfos="cffpCourseInfos"
@changeCourseClassify="changeCourseClassify"
></courselist>
<view class="productListBox"> <view class="productListBox">
<!-- <view class="productListItem" v-for="item in cffpCourseInfos" :key="item.fileId" @click="goDetail(item)"> --> <!-- <view class="productListItem" v-for="item in cffpCourseInfos" :key="item.fileId" @click="goDetail(item)"> -->
...@@ -196,9 +200,21 @@ ...@@ -196,9 +200,21 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<!-- 不是新锐合伙人提示 -->
<partner-tip-popup
ref="PartnerTipPopup"
content="您还未升级为新锐合伙人,团队成员销售成功您不能拿到收益。购买产品升级为新锐合伙人 "
joinText="暂不升级,继续邀请"
continueText="购买产品,立即升级"
btnType="vertical"
:tipIcon="true"
@join="jumpPage('2')"
@continue="jumpPage('1')"
/>
</template> </template>
<script> <script>
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import courselist from '@/pages/courselist/courselist.vue'; import courselist from '@/pages/courselist/courselist.vue';
import api from "../../api/api"; import api from "../../api/api";
...@@ -206,11 +222,14 @@ ...@@ -206,11 +222,14 @@
import carousel from '@/components/carousel/carousel.vue'; import carousel from '@/components/carousel/carousel.vue';
import search from '@/components/search/search.vue'; import search from '@/components/search/search.vue';
import courseItem from "@/components/courseItem/courseItem.vue"; import courseItem from "@/components/courseItem/courseItem.vue";
import {companyInfo} from "@/environments/environment"; import {companyInfo,baseURL,shareURL} from "@/environments/environment";
import JoinPopup from '@/components/commonPopup/JoinPopup.vue'; import JoinPopup from '@/components/commonPopup/JoinPopup.vue';
import PartnerTipPopup from "@/components/commonPopup/PartnerTipPopup.vue";
import {hshare} from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
productType: 4,
partnerStatistic:{}, //申请加盟统计 partnerStatistic:{}, //申请加盟统计
showSearch: true, showSearch: true,
searchQuery: '', searchQuery: '',
...@@ -267,7 +286,8 @@ ...@@ -267,7 +286,8 @@
loginornot: true, loginornot: true,
queryName: '', queryName: '',
loginType : uni.getStorageSync('loginType'), loginType : uni.getStorageSync('loginType'),
userInfo:{} //用户信息 userInfo:{} ,//用户信息,
productItem:{}
} }
}, },
components: { components: {
...@@ -276,11 +296,11 @@ ...@@ -276,11 +296,11 @@
carousel, carousel,
search, search,
courseItem, courseItem,
JoinPopup JoinPopup,
PartnerTipPopup
}, },
onShow() { onShow() {
console.log('11111');
this.loginType = uni.getStorageSync('loginType') this.loginType = uni.getStorageSync('loginType')
this.init(); this.init();
this.showSearch = false; this.showSearch = false;
...@@ -292,12 +312,21 @@ ...@@ -292,12 +312,21 @@
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo')) this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
} }
if(uni.getStorageSync('cffp_userId')){ if(uni.getStorageSync('cffp_userId')){
this.userInfo = uni.getStorageSync('cffp_userId') this.userId = uni.getStorageSync('cffp_userId')
} }
}, },
onLoad(options) { onLoad(options) {
if(options.sharePoster){
dataHandling.pocessTracking(
'进入',
`用户通过分享海报进入系统,邀请码为${options.invitationCode},邀请人userId为${options.inviteUserId}`,
'进入',
2,
'首页',
'pages/index/index'
)
}
//如果用户在其他的地方快捷登录,没有返回到首页,执行此监听方法 //如果用户在其他的地方快捷登录,没有返回到首页,执行此监听方法
uni.$on('loginUpdate',()=>{ uni.$on('loginUpdate',()=>{
this.queryAreaCenterInfo(); this.queryAreaCenterInfo();
...@@ -314,6 +343,32 @@ ...@@ -314,6 +343,32 @@
uni.$off('loginUpdate', this.queryAreaCenterInfo); uni.$off('loginUpdate', this.queryAreaCenterInfo);
}, },
methods: { methods: {
// 初始化首页分享 注意sdk时序问题。传递的url一定要是当前页面的url window.location.href.split('#')[0]
// 不是window.location.href.split('#')[0]很可能不成功
initShare() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href.split('#')[0]);
// #endif
},
jumpPage(type){
console.log('type',type);
if(type=='1'){
uni.navigateTo({
url:'/pages/inviteJoin/inviteJoin'
})
}else {
uni.navigateTo({
url: `/pages/courseDetail/courseDetail?fileId=${this.productItem.fileId}`
});
}
},
changeCourseClassify(val){
this.productType = val
},
queryInfo() { queryInfo() {
api.queryInfo({userId:uni.getStorageSync('cffp_userId')}).then(res=>{ api.queryInfo({userId:uni.getStorageSync('cffp_userId')}).then(res=>{
...@@ -324,6 +379,7 @@ ...@@ -324,6 +379,7 @@
mobile: res['data']['mobile'], mobile: res['data']['mobile'],
partnerType:res['data']['partnerType'], partnerType:res['data']['partnerType'],
nickName:res['data']['nickName'], nickName:res['data']['nickName'],
levelCode:res['data']['levelCode'],
} }
uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo)); uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo));
console.log('cffp_userInfo.partnerType',cffp_userInfo.partnerType); console.log('cffp_userInfo.partnerType',cffp_userInfo.partnerType);
...@@ -391,6 +447,9 @@ ...@@ -391,6 +447,9 @@
if(loginType == 'codelogin'){ if(loginType == 'codelogin'){
this.querySystemMessage() this.querySystemMessage()
this.queryInfo() this.queryInfo()
this.courseList()
this.initShare();
this.getOneProduct()
}else { }else {
this.featureLists =[ this.featureLists =[
{ {
...@@ -419,7 +478,6 @@ ...@@ -419,7 +478,6 @@
}, },
] ]
console.log('this.featureLists',this.featureLists);
uni.removeTabBarBadge({ index: 3 }); uni.removeTabBarBadge({ index: 3 });
} }
if (uni.getStorageSync('isLogin')) { if (uni.getStorageSync('isLogin')) {
...@@ -445,6 +503,8 @@ ...@@ -445,6 +503,8 @@
this.queryAreaCenterInfo(); this.queryAreaCenterInfo();
this.announcementQuery(); this.announcementQuery();
this.courseList(); this.courseList();
this.getOneProduct()
this.initShare();
} else { } else {
uni.showToast({ uni.showToast({
title: res['message'], title: res['message'],
...@@ -504,7 +564,8 @@ ...@@ -504,7 +564,8 @@
}, },
courseList() { courseList() {
const param = { const param = {
queryName: this.queryName queryName: this.queryName,
courseClassify: this.productType
} }
api.courseList(param).then(res => { api.courseList(param).then(res => {
if (res['success']) { if (res['success']) {
...@@ -512,6 +573,22 @@ ...@@ -512,6 +573,22 @@
if(this.cffpCourseInfos.length>0){ if(this.cffpCourseInfos.length>0){
this.cffpCourseInfos.forEach(item=>{ this.cffpCourseInfos.forEach(item=>{
item.coursePrice =Number(item.coursePrice).toFixed(2) || '0.00' item.coursePrice =Number(item.coursePrice).toFixed(2) || '0.00'
if(item.productCode&&item.productCode=='C09'){
this.productItem = item
uni.setStorageSync('productItem',this.productItem );
}
})
}
}
})
},
getOneProduct() {
api.courseList().then(res => {
if (res['success']) {
let result = res['data']['data'];
if(result.length>0){
result.forEach(item=>{
item.coursePrice =Number(item.coursePrice).toFixed(2) || '0.00'
}) })
} }
} }
...@@ -547,7 +624,19 @@ ...@@ -547,7 +624,19 @@
return return
} }
// 未登录状态,不允许未登录状态跳转的,直接去登录页
if(!this.loginType||this.loginType=='visitor'){
if (featureItem.key == '07') {
uni.switchTab({
url: featureItem.link
})
}else {
uni.navigateTo({
url:'/myPackageA/login/login'
})
}
return
}
if(featureItem.isApply&& this.userInfo.partnerType){ if(featureItem.isApply&& this.userInfo.partnerType){
dataHandling.pocessTracking( dataHandling.pocessTracking(
'点击', '点击',
...@@ -560,23 +649,12 @@ ...@@ -560,23 +649,12 @@
this.getPartnerStatistic() this.getPartnerStatistic()
return return
} }
//当为见习合伙人的时候,弹出框提示
if (this.loginornot == false && featureItem.name != "学习认证" && featureItem.name != "更多功能") { if(featureItem.key == '04'&& this.userInfo.levelCode == 'P1'){
dataHandling.pocessTracking( this.$refs.PartnerTipPopup.open()
'点击', return
`用户在首页未登录时点击${featureItem.name}`,
'点击',
2,
'首页',
'pages/index/index'
)
uni.clearStorageSync();
uni.setStorageSync('loginType','visitor');
uni.redirectTo({
url: '/myPackageA/login/login?from=index'
})
return
} }
if (featureItem.key == '02') { if (featureItem.key == '02') {
if (this.cffpUserInfo.levelCode == 'C1' || this.cffpUserInfo.levelCode == 'C2' || this.cffpUserInfo if (this.cffpUserInfo.levelCode == 'C1' || this.cffpUserInfo.levelCode == 'C2' || this.cffpUserInfo
.levelCode == 'C3') { .levelCode == 'C3') {
...@@ -674,9 +752,23 @@ ...@@ -674,9 +752,23 @@
onChange: function(e) { onChange: function(e) {
this.old.x = e.detail.x this.old.x = e.detail.x
this.old.y = e.detail.y this.old.y = e.detail.y
} },
getOneProduct() {
api.courseList().then(res => {
if (res['success']) {
let result = res['data']['data'];
if(result.length>0){
result.forEach(item=>{
if(item.productCode&&item.productCode=='C09'){
this.productItem = item
uni.setStorageSync('productItem',this.productItem );
}
})
}
}
})
},
}, },
mounted() {}
} }
</script> </script>
......
...@@ -154,9 +154,8 @@ ...@@ -154,9 +154,8 @@
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import api from "@/api/api" import api from "@/api/api"
import common from '../../common/common'; import common from '../../common/common';
import {hshare } from '@/util/fiveshare'; import {hshare ,setWechatShare,initJssdkShare} from '@/util/fiveshare';
import {baseURL,apiURL,cffpURL,companyInfo,shareURL} from "@/environments/environment"; import {baseURL,apiURL,cffpURL,companyInfo,shareURL} from "@/environments/environment";
export default { export default {
data() { data() {
return { return {
...@@ -207,6 +206,13 @@ ...@@ -207,6 +206,13 @@
this.queryInfo(); this.queryInfo();
} }
}, },
onShow(){
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods: { methods: {
goBack() { goBack() {
uni.navigateBack({ uni.navigateBack({
...@@ -346,6 +352,14 @@ ...@@ -346,6 +352,14 @@
'邀请加盟', '邀请加盟',
'pages/inviteJoin/inviteJoin' 'pages/inviteJoin/inviteJoin'
) )
// setTimeout(()=>{
// // #ifdef H5
// initJssdkShare(() => {
// setWechatShare();
// }, window.location.href);
// // #endif
// },500)
}, },
closeShare() { closeShare() {
this.$refs.share.close() this.$refs.share.close()
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import CommonTimePicker from '@/components/commonTimePicker/commonTimePicker.vue'; import CommonTimePicker from '@/components/commonTimePicker/commonTimePicker.vue';
import JoinPopup from '@/components/commonPopup/JoinPopup.vue'; import JoinPopup from '@/components/commonPopup/JoinPopup.vue';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
import { import {
fmdata fmdata
} from '@/util/currentDate.js' } from '@/util/currentDate.js'
...@@ -232,6 +233,13 @@ ...@@ -232,6 +233,13 @@
this.userShareCount(); this.userShareCount();
this.userShareQuery(); this.userShareQuery();
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
mounted() { mounted() {
} }
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
<!-- 课程详情 --> <!-- 课程详情 -->
<template v-if="courseInfoItem"> <template v-if="courseInfoItem">
<view class="courseItemBox" > <view class="courseItemBox" >
<course-item :thumbnailPath="courseInfoItem.displayImage" :title="courseInfoItem.fileTitle" <course-item :thumbnailPath="courseInfoItem.displayImage" :title="courseInfoItem.fileSynopsis"
:summaryBox="courseInfoItem.fileSynopsis" :summaryBox="courseInfoItem.fileTitle"
:dataList="{coursePrice:courseInfoItem.coursePrice,salesNumber:courseInfoItem.salesNumber}" :dataList="{coursePrice:courseInfoItem.coursePrice,salesNumber:courseInfoItem.salesNumber}"
:fileLecturerId="courseInfoItem.fileLecturerId" :fileId="fileId"></course-item> :fileLecturerId="courseInfoItem.fileLecturerId" :fileId="fileId"></course-item>
</view> </view>
...@@ -177,6 +177,7 @@ ...@@ -177,6 +177,7 @@
import {apiURL,companyInfo} from "@/environments/environment"; import {apiURL,companyInfo} from "@/environments/environment";
import {nextTick} from "vue"; import {nextTick} from "vue";
import common from '../../common/common'; import common from '../../common/common';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components: { components: {
courseItem courseItem
...@@ -531,7 +532,13 @@ ...@@ -531,7 +532,13 @@
this.courseDetailLoad(option); this.courseDetailLoad(option);
} }
}, },
mounted() {} onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
} }
</script> </script>
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
import api from "@/api/api"; import api from "@/api/api";
import common from "@/common/common"; import common from "@/common/common";
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -232,6 +233,13 @@ ...@@ -232,6 +233,13 @@
this.Withdrawal = option.Withdrawal this.Withdrawal = option.Withdrawal
this.commissionType = option.commissionType; this.commissionType = option.commissionType;
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
mounted() { mounted() {
uni.showLoading({ uni.showLoading({
title: '加载中...' title: '加载中...'
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
import {apiURL} from "@/environments/environment"; import {apiURL} from "@/environments/environment";
import courseItem from "@/components/courseItem/courseItem.vue"; import courseItem from "@/components/courseItem/courseItem.vue";
import tabBar from '../../components/tabBar/tabBar.vue'; import tabBar from '../../components/tabBar/tabBar.vue';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components:{tabBar,courseItem}, components:{tabBar,courseItem},
data() { data() {
...@@ -71,6 +72,11 @@ ...@@ -71,6 +72,11 @@
}; };
}, },
onShow() { onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
// let loginType = uni.getStorageSync('loginType') // let loginType = uni.getStorageSync('loginType')
// if(loginType !== "visitor" ){ // if(loginType !== "visitor" ){
// this.querySystemMessage() // this.querySystemMessage()
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
<script> <script>
import {companyInfo} from "@/environments/environment"; import {companyInfo} from "@/environments/environment";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -65,6 +66,11 @@ ...@@ -65,6 +66,11 @@
}else if(this.companyType == '2'){ }else if(this.companyType == '2'){
this.companyLogo='../../../static/logo2.png' this.companyLogo='../../../static/logo2.png'
} }
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
methods:{ methods:{
goBack() { goBack() {
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
<script> <script>
import questionsData from "@/util/questions"; import questionsData from "@/util/questions";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -65,6 +66,13 @@ ...@@ -65,6 +66,13 @@
} }
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
computed:{ computed:{
newQuestionData(){ newQuestionData(){
let result = questionsData.filter(item=>item.id==this.currentTab) let result = questionsData.filter(item=>item.id==this.currentTab)
......
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
import CommonTimePicker from '@/components/commonTimePicker/commonTimePicker.vue'; import CommonTimePicker from '@/components/commonTimePicker/commonTimePicker.vue';
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import api from "@/api/api"; import api from "@/api/api";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components: { components: {
CommonTimePicker CommonTimePicker
...@@ -263,6 +264,13 @@ ...@@ -263,6 +264,13 @@
this.getmyseatem() this.getmyseatem()
this.getqueryTeamAchievement() this.getqueryTeamAchievement()
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods: { methods: {
sortswitch(obj) { sortswitch(obj) {
this.currentFilterBtn = obj.id this.currentFilterBtn = obj.id
......
...@@ -119,6 +119,7 @@ ...@@ -119,6 +119,7 @@
import CommonTimePicker from '@/components/commonTimePicker/commonTimePicker.vue'; import CommonTimePicker from '@/components/commonTimePicker/commonTimePicker.vue';
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import api from "@/api/api"; import api from "@/api/api";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components: { components: {
CommonTimePicker CommonTimePicker
...@@ -229,6 +230,13 @@ ...@@ -229,6 +230,13 @@
this.getmyseatem() this.getmyseatem()
this.getqueryTeamAchievement() this.getqueryTeamAchievement()
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods: { methods: {
sortswitch(obj) { sortswitch(obj) {
this.currentFilterBtn = obj.id this.currentFilterBtn = obj.id
......
...@@ -60,6 +60,11 @@ ...@@ -60,6 +60,11 @@
</view> </view>
</view> </view>
<view class="shareBtn" :class="{'shareBottom':shareBtnBottom}" @click="gotoPoster">
<view class="shareBox">
分享给好友
</view>
</view>
</view> </view>
<!-- 使用封装后的弹窗组件 --> <!-- 使用封装后的弹窗组件 -->
<join-popup <join-popup
...@@ -146,6 +151,17 @@ ...@@ -146,6 +151,17 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<!-- 不是新锐合伙人提示 -->
<partner-tip-popup
ref="PartnerTipPopup"
content="您还未升级为新锐合伙人,团队成员销售成功您不能拿到收益。购买产品升级为新锐合伙人 "
joinText="暂不升级,继续邀请"
continueText="购买产品,立即升级"
btnType="vertical"
:tipIcon="true"
@join="jumpPage('2')"
@continue="jumpPage('1')"
/>
</view> </view>
</template> </template>
...@@ -157,7 +173,8 @@ ...@@ -157,7 +173,8 @@
import {companyInfo} from "@/environments/environment"; import {companyInfo} from "@/environments/environment";
import FloatingButton from '@/components/FloatingButton/FloatingButton.vue'; import FloatingButton from '@/components/FloatingButton/FloatingButton.vue';
import JoinPopup from '@/components/commonPopup/JoinPopup.vue'; import JoinPopup from '@/components/commonPopup/JoinPopup.vue';
import PartnerTipPopup from "@/components/commonPopup/PartnerTipPopup.vue";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -186,7 +203,7 @@ ...@@ -186,7 +203,7 @@
{id:'01',categoryName:'团队', {id:'01',categoryName:'团队',
children:[ children:[
{title:'申请加盟',icon:'icon-hezuo',link:'/myPackageA/applyFranchise/applyFranchise?',isOpen:true,isShow:true,isApply:true}, {title:'申请加盟',icon:'icon-hezuo',link:'/myPackageA/applyFranchise/applyFranchise?',isOpen:true,isShow:true,isApply:true},
{title:'邀请加盟',icon:'icon-yaoqing',link:'/pages/inviteJoin/inviteJoin',isOpen:true,isShow:true,identity: true}, {key:'06',title:'邀请加盟',icon:'icon-yaoqing',link:'/pages/inviteJoin/inviteJoin',isOpen:true,isShow:true,identity: true},
{title:'我的团队',icon:'icon-tuandui',link:'/pages/personalCenter/myTeam',isOpen:true,isShow:true,identity: true}, {title:'我的团队',icon:'icon-tuandui',link:'/pages/personalCenter/myTeam',isOpen:true,isShow:true,identity: true},
{title:'育成团队',icon:'icon-yuchengguanxi',link:'/pages/personalCenter/myTeamIncubate',isOpen:true,isShow:true,identity: true}, {title:'育成团队',icon:'icon-yuchengguanxi',link:'/pages/personalCenter/myTeamIncubate',isOpen:true,isShow:true,identity: true},
], ],
...@@ -206,12 +223,16 @@ ...@@ -206,12 +223,16 @@
{title:'我的消息',icon:'message',link:'/pages/systemMsg/system_msg',isOpen:true,isShow:true,islogin:true}, {title:'我的消息',icon:'message',link:'/pages/systemMsg/system_msg',isOpen:true,isShow:true,islogin:true},
{title:'系统设置',icon:'setting',link:'/pages/personalCenter/system/settings',isOpen:true,isShow:true} {title:'系统设置',icon:'setting',link:'/pages/personalCenter/system/settings',isOpen:true,isShow:true}
], ],
partnerStatistic:{} //申请加盟统计 partnerStatistic:{}, //申请加盟统计
userInfo:{} ,//用户信息,
shareBtnBottom:false,
productItem:{}
} }
}, },
components:{ components:{
tabBar, tabBar,
JoinPopup JoinPopup,
PartnerTipPopup
}, },
onShow() { onShow() {
this.loginType = uni.getStorageSync('loginType') this.loginType = uni.getStorageSync('loginType')
...@@ -230,6 +251,7 @@ ...@@ -230,6 +251,7 @@
if(this.loginType == 'codelogin'){ if(this.loginType == 'codelogin'){
this.querySystemMessage() this.querySystemMessage()
this.queryInfo(); this.queryInfo();
this.courseList()
}else { }else {
this.messageInfo = [] this.messageInfo = []
uni.removeTabBarBadge({ index: 3 }); uni.removeTabBarBadge({ index: 3 });
...@@ -247,9 +269,61 @@ ...@@ -247,9 +269,61 @@
// 移除监听事件 // 移除监听事件
uni.$off('handClick'); uni.$off('handClick');
}); });
if(uni.getStorageSync('cffp_userInfo')){
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
}
// #ifdef H5
const systemInfo = uni.getSystemInfoSync();
this.shareBtnBottom = systemInfo.platform === 'ios'
console.log('this.shareBtnBottom',this.shareBtnBottom);
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
methods: { methods: {
courseList() {
api.courseList().then(res => {
if (res['success']) {
let cffpCourseInfos = res['data']['data'];
if(cffpCourseInfos.length>0){
cffpCourseInfos.forEach(item=>{
if(item.productCode&&item.productCode=='C09'){
this.productItem = item
uni.setStorageSync('productItem',this.productItem );
}
})
}
}
})
},
gotoPoster(){
if(!uni.getStorageSync('loginType') || uni.getStorageSync('loginType')=='visitor'){
uni.setStorageSync('loginType','visitor')
uni.setStorageSync('islogin','1')
}
uni.navigateTo({
url:'/myPackageA/poster/poster?from=personalCenter'
})
},
jumpPage(type){
if(type=='1'){
uni.navigateTo({
url:'/pages/inviteJoin/inviteJoin'
})
}else {
let productItem = {}
if(uni.getStorageSync('productItem')){
productItem = JSON.parse(JSON.stringify(uni.getStorageSync('productItem')))
}
uni.navigateTo({
url: `/pages/courseDetail/courseDetail?fileId=${productItem.fileId}`
});
}
},
getPartnerStatistic(){ getPartnerStatistic(){
if(this.userId){ if(this.userId){
api.partnerStatisticsGrade({userId:uni.getStorageSync('cffp_userId')}).then((res)=>{ api.partnerStatisticsGrade({userId:uni.getStorageSync('cffp_userId')}).then((res)=>{
...@@ -340,6 +414,9 @@ ...@@ -340,6 +414,9 @@
}, },
// 菜单跳转页面 // 菜单跳转页面
goDetail(item){ goDetail(item){
if(uni.getStorageSync('cffp_userInfo')){
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
}
if(item.isApply&&(!uni.getStorageSync('loginType')||uni.getStorageSync('loginType')=='visitor')){ if(item.isApply&&(!uni.getStorageSync('loginType')||uni.getStorageSync('loginType')=='visitor')){
dataHandling.pocessTracking( dataHandling.pocessTracking(
'申请加盟', '申请加盟',
...@@ -405,6 +482,11 @@ ...@@ -405,6 +482,11 @@
return return
} }
//当为见习合伙人的时候,弹出框提示
if(item.key == '06'&& this.userInfo.levelCode == 'P1' && uni.getStorageSync('loginType') == 'codelogin'){
this.$refs.PartnerTipPopup.open()
return
}
// 说明不需要登录就可以进 // 说明不需要登录就可以进
if(item.isLogin){ if(item.isLogin){
dataHandling.pocessTracking( dataHandling.pocessTracking(
...@@ -702,6 +784,25 @@ ...@@ -702,6 +784,25 @@
.kuaiBox:last-child{ .kuaiBox:last-child{
margin-bottom: 100rpx; margin-bottom: 100rpx;
} }
.shareBtn{
width: 100%;
display: flex;
align-items: center;
justify-content: center;
padding: 50rpx 0rpx;
.shareBox{
background-color: #20269B;
color: #fff;
font-size: 30rpx;
border-radius: 60rpx;
width: 50%;
text-align: center;
padding: 20rpx 30rpx;
}
}
.shareBottom{
padding-bottom: 150rpx;
}
} }
.joinContent{ .joinContent{
width: 500rpx; width: 500rpx;
...@@ -814,5 +915,31 @@ ...@@ -814,5 +915,31 @@
} }
} }
} }
/* 新增:iPad mini 和 iPad Air 竖屏的媒体查询 */
/* iPad mini 竖屏 */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 1) {
.container {
.myContent .shareBtn{
padding-bottom: 120rpx;
}
}
}
/* iPad Air 竖屏 */
@media only screen
and (min-device-width: 820px)
and (max-device-width: 1180px)
and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 1) {
.container {
.myContent .shareBtn{
padding-bottom: 120rpx !important;
}
}
}
</style> </style>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<script> <script>
import MenuList from "@/components/menuList/menuList.vue" import MenuList from "@/components/menuList/menuList.vue"
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components:{ components:{
MenuList MenuList
...@@ -53,6 +53,13 @@ ...@@ -53,6 +53,13 @@
] ]
} }
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods:{ methods:{
goBack() { goBack() {
uni.navigateBack({ uni.navigateBack({
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
</template> </template>
<script> <script>
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
props: { props: {
menuList: { menuList: {
...@@ -28,6 +29,13 @@ ...@@ -28,6 +29,13 @@
data() { data() {
return {} return {}
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
mounted() { mounted() {
console.log(this.minorMenuLists, 7412) console.log(this.minorMenuLists, 7412)
}, },
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
import MenuList from "@/components/menuList/menuList.vue" import MenuList from "@/components/menuList/menuList.vue"
import {companyInfo} from "@/environments/environment"; import {companyInfo} from "@/environments/environment";
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components:{ MenuList }, components:{ MenuList },
data() { data() {
...@@ -53,6 +54,13 @@ ...@@ -53,6 +54,13 @@
] ]
} }
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
destroyed() { destroyed() {
uni.hideToast(); uni.hideToast();
}, },
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
import common from '../../common/common'; import common from '../../common/common';
import {companyInfo} from "@/environments/environment"; import {companyInfo} from "@/environments/environment";
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -100,6 +101,13 @@ ...@@ -100,6 +101,13 @@
} }
this.optionForm = JSON.parse(options.customerBasicInfo) this.optionForm = JSON.parse(options.customerBasicInfo)
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods: { methods: {
handleKeyDown(e) { handleKeyDown(e) {
console.log('this.isComposing',this.isComposing); console.log('this.isComposing',this.isComposing);
......
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
import api from '../../api/api'; import api from '../../api/api';
import CustomDatePop from './customDatePop.vue'; import CustomDatePop from './customDatePop.vue';
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
let nowTime = dataHandling.getMonthRange(dataHandling.getDateParts().year, dataHandling.getDateParts().month) let nowTime = dataHandling.getMonthRange(dataHandling.getDateParts().year, dataHandling.getDateParts().month)
export default{ export default{
data(){ data(){
...@@ -182,7 +183,11 @@ ...@@ -182,7 +183,11 @@
this.queryByUserIdFortuneStatistic(); this.queryByUserIdFortuneStatistic();
this.getCommissionType() this.getCommissionType()
this.getDetail() this.getDetail()
console.log(11111); // #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
methods:{ methods:{
// 查看订单详情 // 查看订单详情
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import tabBar from '../../components/tabBar/tabBar.vue'; import tabBar from '../../components/tabBar/tabBar.vue';
import courseItem from "@/components/courseItem/courseItem.vue"; import courseItem from "@/components/courseItem/courseItem.vue";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -71,6 +72,13 @@ ...@@ -71,6 +72,13 @@
] ]
} }
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods:{ methods:{
goDetail(item) { goDetail(item) {
if (item.isShow == true && item.isOpen == true) { if (item.isShow == true && item.isOpen == true) {
......
...@@ -115,6 +115,7 @@ ...@@ -115,6 +115,7 @@
import CommonTimePicker from '@/components/commonTimePicker/commonTimePicker.vue'; import CommonTimePicker from '@/components/commonTimePicker/commonTimePicker.vue';
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import JoinPopup from '@/components/commonPopup/JoinPopup.vue'; import JoinPopup from '@/components/commonPopup/JoinPopup.vue';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
components:{ components:{
courseItem, courseItem,
...@@ -264,6 +265,11 @@ ...@@ -264,6 +265,11 @@
let app22 = getCurrentPages().length let app22 = getCurrentPages().length
this.userCourseCount() this.userCourseCount()
this.userCourseList() this.userCourseList()
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
} }
} }
</script> </script>
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
<script> <script>
import api from '../../api/api'; import api from '../../api/api';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default{ export default{
data(){ data(){
return{ return{
...@@ -49,6 +50,11 @@ ...@@ -49,6 +50,11 @@
}, },
onShow(){ onShow(){
this.querySystemMessage(); this.querySystemMessage();
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
methods:{ methods:{
querySystemMessage() { querySystemMessage() {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<script> <script>
import api from "../../api/api"; import api from "../../api/api";
import common from '../../common/common'; import common from '../../common/common';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default{ export default{
data(){ data(){
return{ return{
...@@ -39,6 +40,13 @@ ...@@ -39,6 +40,13 @@
this.id = options.id; this.id = options.id;
this.getSystemMsgDetail(); this.getSystemMsgDetail();
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods:{ methods:{
getSystemMsgDetail(){ getSystemMsgDetail(){
api.querySystemMessageDetail({systemMessageId:this.id}).then((res)=>{ api.querySystemMessageDetail({systemMessageId:this.id}).then((res)=>{
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
</template> </template>
<script> <script>
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default{ export default{
data(){ data(){
return { return {
...@@ -64,8 +65,12 @@ ...@@ -64,8 +65,12 @@
} }
}, },
components:{}, components:{},
onLoad(){ onShow(){
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
methods:{ methods:{
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
<script> <script>
import api from '../../api/api'; import api from '../../api/api';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default{ export default{
data(){ data(){
return { return {
...@@ -91,6 +92,13 @@ ...@@ -91,6 +92,13 @@
this.partnerTradeNo = options.partnerTradeNo; this.partnerTradeNo = options.partnerTradeNo;
this.goFortuneWithdrawal() this.goFortuneWithdrawal()
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods:{ methods:{
goBack() { goBack() {
uni.navigateBack({ uni.navigateBack({
......
...@@ -172,7 +172,7 @@ ...@@ -172,7 +172,7 @@
import dataHandling from "../../util/dataHandling"; import dataHandling from "../../util/dataHandling";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue'; import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -205,6 +205,13 @@ ...@@ -205,6 +205,13 @@
option:{} option:{}
} }
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods: { methods: {
goBack(){ goBack(){
uni.navigateBack({ uni.navigateBack({
......
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
<script> <script>
import api from "../../api/api"; import api from "../../api/api";
import {reactive,provide} from "vue"; import {reactive,provide} from "vue";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -108,6 +109,13 @@ ...@@ -108,6 +109,13 @@
this.bindPickerChange({detail:{value:this.index}}); this.bindPickerChange({detail:{value:this.index}});
this.calcuteData = uni.getStorageSync('calcuteData') ? JSON.parse(uni.getStorageSync('calcuteData')) : null; this.calcuteData = uni.getStorageSync('calcuteData') ? JSON.parse(uni.getStorageSync('calcuteData')) : null;
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods:{ methods:{
// 选择间隔 // 选择间隔
bindPickerChange(e){ bindPickerChange(e){
......
...@@ -278,6 +278,7 @@ ...@@ -278,6 +278,7 @@
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
// import Echarts from '../../components/echarts/echarts' // import Echarts from '../../components/echarts/echarts'
import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue'; import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default{ export default{
data(){ data(){
...@@ -355,6 +356,13 @@ ...@@ -355,6 +356,13 @@
onLoad(){ onLoad(){
this.provCityQry(); this.provCityQry();
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
methods:{ methods:{
goBack(){ goBack(){
uni.navigateBack({ uni.navigateBack({
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
<script> <script>
import { ref,toRefs,reactive } from "vue"; import { ref,toRefs,reactive } from "vue";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default{ export default{
props: ['isReadonly','loanType','a','b'], props: ['isReadonly','loanType','a','b'],
emits:['getData'], emits:['getData'],
...@@ -92,6 +93,13 @@ ...@@ -92,6 +93,13 @@
components:{ components:{
}, },
onShow() {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
},
setup(props,content) { setup(props,content) {
const a = reactive({value:props.a}); const a = reactive({value:props.a});
const b = reactive({value:props.b}); const b = reactive({value:props.b});
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
import {toRefs} from "vue"; import {toRefs} from "vue";
import api from '../../api/api'; import api from '../../api/api';
import common from '../../common/common' import common from '../../common/common'
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default{ export default{
props:['cityInfo','planningParams'], props:['cityInfo','planningParams'],
emits:['getData'], emits:['getData'],
...@@ -60,7 +61,12 @@ ...@@ -60,7 +61,12 @@
components:{ components:{
}, },
onLoad(){ onShow(){
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
setup(props,content){ setup(props,content){
const cityInfo = props.cityInfo ? props.cityInfo : null; const cityInfo = props.cityInfo ? props.cityInfo : null;
......
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
import foot from '../footer/footer.vue'; import foot from '../footer/footer.vue';
import { toRefs, ref } from 'vue'; import { toRefs, ref } from 'vue';
import commonHead from '../header/header.vue'; import commonHead from '../header/header.vue';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
export default { export default {
data() { data() {
return { return {
...@@ -638,6 +638,11 @@ ...@@ -638,6 +638,11 @@
this.calcuteMethod = '2'; this.calcuteMethod = '2';
this.resultShowFlag = true; this.resultShowFlag = true;
} }
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
}, window.location.href);
// #endif
}, },
mounted() { mounted() {
//this.checkToken(); //this.checkToken();
......
...@@ -364,4 +364,33 @@ export default{ ...@@ -364,4 +364,33 @@ export default{
} }
}) })
}, },
/**
* 检测是否是iOS刘海屏设备
* @returns {boolean} true-是刘海屏, false-不是刘海屏
*/
isNotchIOS() {
// 1. 先判断是否是iOS设备
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) ||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
if (!isIOS) return false;
// 2. 通过CSS环境变量检测
// 创建一个测试元素
const div = document.createElement('div');
div.style.position = 'fixed';
div.style.top = '0';
div.style.left = '0';
div.style.width = '1px';
div.style.height = 'constant(safe-area-inset-top)'; // 兼容旧版iOS
div.style.height = 'env(safe-area-inset-top)'; // 新版iOS
document.body.appendChild(div);
// 获取计算的高度值
const computedHeight = parseInt(window.getComputedStyle(div).height, 10);
document.body.removeChild(div);
// 3. 刘海屏设备safe-area-inset-top通常大于20(非刘海屏为0)
return computedHeight > 20;
}
} }
\ No newline at end of file
...@@ -3,48 +3,123 @@ ...@@ -3,48 +3,123 @@
// import wx from 'weixin-js-sdk' // import wx from 'weixin-js-sdk'
import api from "../api/api"; import api from "../api/api";
import {companyInfo,baseURL,shareURL} from "@/environments/environment";
let userInfo = {name:''}
if(uni.getStorageSync('cffp_userInfo')){
userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
}
//初始化 //初始化
export function initJssdkShare(callback, url) { // export function initJssdkShare(callback, url) {
var url = url // console.log('签名',url);
// var url = url
//这一步需要调用后台接口,返回需要的签名 签名时间戳 随机串 和公众号appid // //这一步需要调用后台接口,返回需要的签名 签名时间戳 随机串 和公众号appid
//注意url:window.location.href.split('#')[0] // // //注意url:window.location.href.split('#')[0] //
// request.post("", { // // request.post("", {
// url // url是当前页面的url // // url // url是当前页面的url
// }, // // },
let WxConfigRequestVO = { // let WxConfigRequestVO = {
url:url, // url:url,
systemType:uni.getStorageSync('addSystemType')?uni.getStorageSync('addSystemType'):'1' // systemType:uni.getStorageSync('addSystemType')?uni.getStorageSync('addSystemType'):'1'
} // }
// @ts-ignore // // @ts-ignore
api.Wxshare(WxConfigRequestVO).then(res => { // api.Wxshare(WxConfigRequestVO).then(res => {
jWeixin.config({ // jWeixin.config({
debug: false,//调试的时候需要 在app上回弹出errmg:config ok 的时候就证明没问题了 这时候就可以改为false // debug: false,//调试的时候需要 在app上回弹出errmg:config ok 的时候就证明没问题了 这时候就可以改为false
appId: res.data.appId,//appid // appId: res.data.appId,//appid
timestamp: res.data.timestamp,//时间戳 // timestamp: res.data.timestamp,//时间戳
nonceStr: res.data.nonceStr,//随机串 // nonceStr: res.data.nonceStr,//随机串
signature: res.data.signature,//签名 // signature: res.data.signature,//签名
jsApiList: res.data.jsApiList//必填 是下面需要用到的方法集合 // jsApiList: res.data.jsApiList//必填 是下面需要用到的方法集合
}) // })
if(callback){ // if(callback){
callback() // callback()
} // }
}) // })
} // }
// 初始化SDK
export function initJssdkShare(callback, url) {
const WxConfigRequestVO = {
url: url,
systemType: uni.getStorageSync('addSystemType') || '1'
};
api.Wxshare(WxConfigRequestVO).then(res => {
jWeixin.config({
debug: false, // 生产环境关闭调试
appId: res.data.appId,
timestamp: res.data.timestamp,
nonceStr: res.data.nonceStr,
signature: res.data.signature,
jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareAppMessage']
});
jWeixin.ready(() => {
console.log('微信SDK初始化完成');
if (callback) callback();
});
jWeixin.error(err => {
console.error('微信SDK初始化失败', err);
});
});
}
// 设置微信分享内容(不自动覆盖,需手动调用)
export function setWechatShare(data) {
if (!jWeixin) {
console.error('微信SDK未初始化');
return;
}
if(!data){
const currentUrl = `${shareURL}/pages/index/index`;
data = {
title: '成为银盾合伙人,分享商品赚不停',
// desc: `${userInfo.name || ''}邀您加入【家庭财策师联盟】,资源+伙伴,共赢未来!`,
desc: `资源+伙伴,共赢未来!`,
link: currentUrl,
imgUrl: `${shareURL}/static/images/shareBg.png`
};
}
jWeixin.ready(() => {
// 新API(推荐)
jWeixin.updateAppMessageShareData({
title: data.title,
desc: data.desc,
link: data.link,
imgUrl: data.imgUrl,
success: () => console.log('好友分享设置成功')
});
jWeixin.updateTimelineShareData({
title: data.title,
link: data.link,
imgUrl: data.imgUrl,
success: () => console.log('朋友圈分享设置成功')
});
// 旧API(兼容)
jWeixin.onMenuShareAppMessage({
title: data.title,
desc: data.desc,
link: data.link,
imgUrl: data.imgUrl,
success: () => console.log('旧版分享设置成功')
});
});
}
// data是穿的参数 url是当前页面的链接 // data是穿的参数 url是当前页面的链接
export function hshare(data,url){ export function hshare(data,url){
console.log('data,url',data,url); console.log('data,url',data,url);
// 确保分享的链接不包含时间戳 // 确保分享的链接不包含时间戳
const cleanLink = data.link.split('&t_reload=')[0];
// initJssdkShare(data, url) // initJssdkShare(data, url)
initJssdkShare(function(){ initJssdkShare(function(){
jWeixin.ready(function(){ jWeixin.ready(function(){
var sharedata={ var sharedata={
title: data.title, //标题 title: data.title, //标题
desc: data.desc, //描述 desc: data.desc, //描述
link: cleanLink ,//分享链接 link: data.link ,//分享链接
imgUrl:data.imgUrl, //图片 imgUrl:data.imgUrl, //图片
success:(res=>{ success:(res=>{
}) })
...@@ -54,4 +129,5 @@ export function initJssdkShare(callback, url) { ...@@ -54,4 +129,5 @@ export function initJssdkShare(callback, url) {
jWeixin.onMenuShareAppMessage(sharedata);//获取“分享给朋友”按钮点击状态及自定义分享内容接口(即将废弃) jWeixin.onMenuShareAppMessage(sharedata);//获取“分享给朋友”按钮点击状态及自定义分享内容接口(即将废弃)
}) })
},url) },url)
} }
\ No newline at end of file
\ No newline at end of file
import html2canvas from 'html2canvas';
/**
* 将DOM元素转换为图片
* @param {HTMLElement} element DOM元素
* @param {Object} options html2canvas配置选项
* @returns {Promise<string>} 返回图片的base64数据
*/
export const elementToImage = async (element, options = {}) => {
try {
// 默认配置
const defaultOptions = {
backgroundColor: null, // 透明背景
scale: 2, // 提高缩放以获得更清晰的图片
useCORS: true, // 允许跨域图片
allowTaint: true, // 允许污染图片
logging: false // 关闭日志
};
const canvas = await html2canvas(element, { ...defaultOptions, ...options });
return canvas.toDataURL('image/png');
} catch (error) {
console.error('生成图片失败:', error);
throw error;
}
};
\ No newline at end of file
import api from "@/api/api"; import api from "@/api/api";
import dataHandling from './dataHandling' import dataHandling from './dataHandling'
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
//只要是未登录状态,想要跳转到名单内的路径时,直接跳到登录页 //只要是未登录状态,想要跳转到名单内的路径时,直接跳到登录页
// 页面白名单,不受拦截 // 页面白名单,不受拦截
const whiteList = [ const whiteList = [
...@@ -12,7 +13,8 @@ const whiteList = [ ...@@ -12,7 +13,8 @@ const whiteList = [
'/pages/courseDetail/courseDetail', '/pages/courseDetail/courseDetail',
'/pages/courselist/courselist', '/pages/courselist/courselist',
'/pages/personalCenter/helpCenter', '/pages/personalCenter/helpCenter',
'/pages/index/index' '/pages/index/index',
'/myPackageA/poster/poster',
] ]
export default function initApp(){ export default function initApp(){
let date = Date.now() let date = Date.now()
...@@ -21,10 +23,10 @@ export default function initApp(){ ...@@ -21,10 +23,10 @@ export default function initApp(){
uni.addInterceptor('navigateTo', { uni.addInterceptor('navigateTo', {
// 页面跳转前进行拦截, invoke根据返回值进行判断是否继续执行跳转 // 页面跳转前进行拦截, invoke根据返回值进行判断是否继续执行跳转
invoke (e) { invoke (e) {
console.log(e);
let pages = getCurrentPages() let pages = getCurrentPages()
let pagesLength = pages.length let pagesLength = pages.length
if(whiteList.indexOf(e.url)==-1&&!uni.getStorageSync('loginType')){ if(whiteList.indexOf(e.url)==-1&&!uni.getStorageSync('loginType')){
uni.clearStorageSync(); uni.clearStorageSync();
uni.setStorageSync('loginType','visitor') uni.setStorageSync('loginType','visitor')
...@@ -50,6 +52,7 @@ export default function initApp(){ ...@@ -50,6 +52,7 @@ export default function initApp(){
mobile: res['data']['mobile'], mobile: res['data']['mobile'],
partnerType:res['data']['partnerType'], partnerType:res['data']['partnerType'],
nickName:res['data']['nickName'], nickName:res['data']['nickName'],
levelCode:res['data']['levelCode'],
} }
uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo)) uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo))
} }
...@@ -66,6 +69,7 @@ export default function initApp(){ ...@@ -66,6 +69,7 @@ export default function initApp(){
}; };
const fromParam = getQueryParam(e.url, 'from'); const fromParam = getQueryParam(e.url, 'from');
console.log('2222',!hasPermission(e.url));
if(!hasPermission(e.url)){ if(!hasPermission(e.url)){
// 如果 from 参数在 whiteArr 中,说明是tabbar页带着tabbar的标志参数跳转到登录页,以便未登录状态下回到对应的tabbar页 // 如果 from 参数在 whiteArr 中,说明是tabbar页带着tabbar的标志参数跳转到登录页,以便未登录状态下回到对应的tabbar页
if (fromParam && whiteArr.includes(fromParam)) { if (fromParam && whiteArr.includes(fromParam)) {
...@@ -73,6 +77,7 @@ export default function initApp(){ ...@@ -73,6 +77,7 @@ export default function initApp(){
url: `/myPackageA/login/login?from=${fromParam}` url: `/myPackageA/login/login?from=${fromParam}`
}) })
}else { }else {
console.log('zoujinlaile');
uni.redirectTo({ uni.redirectTo({
url: '/myPackageA/login/login' url: '/myPackageA/login/login'
}) })
...@@ -103,8 +108,10 @@ export default function initApp(){ ...@@ -103,8 +108,10 @@ export default function initApp(){
success (e) {} success (e) {}
}) })
uni.addInterceptor('switchTab', { uni.addInterceptor('switchTab', {
// tabbar页面跳转前进行拦截 // tabbar页面跳转前进行拦截
invoke(e) { invoke(e) {
if (date) { if (date) {
//如果时间戳存在 那么记录此页面的停留时间 //如果时间戳存在 那么记录此页面的停留时间
dataHandling.pocessTracking( dataHandling.pocessTracking(
...@@ -122,6 +129,7 @@ export default function initApp(){ ...@@ -122,6 +129,7 @@ export default function initApp(){
uni.addInterceptor('reLaunch', { uni.addInterceptor('reLaunch', {
//页面跳转前拦截 //页面跳转前拦截
invoke(e) { invoke(e) {
if (date) { if (date) {
//如果时间戳存在 那么记录此页面的停留时间 //如果时间戳存在 那么记录此页面的停留时间
dataHandling.pocessTracking( dataHandling.pocessTracking(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment