commit
						6550441bc9
					
				| 
						 | 
				
			
			@ -29,6 +29,7 @@
 | 
			
		|||
    <!--  海报画板:默认隐藏只用来生成海报。生成方式为主动调用  -->
 | 
			
		||||
    <l-painter
 | 
			
		||||
      isCanvasToTempFilePath
 | 
			
		||||
      pathType="url"
 | 
			
		||||
      @success="setPainterImageUrl"
 | 
			
		||||
      hidden
 | 
			
		||||
      ref="painterRef"
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +66,7 @@
 | 
			
		|||
    css: {
 | 
			
		||||
      // 根节点若无尺寸,自动获取父级节点
 | 
			
		||||
      width: sheep.$platform.device.windowWidth * 0.9,
 | 
			
		||||
      height: 600,
 | 
			
		||||
      height: 550,
 | 
			
		||||
    },
 | 
			
		||||
    views: [],
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			@ -92,6 +93,7 @@
 | 
			
		|||
      sheep.$helper.toast('请长按图片保存');
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 非H5 保存到相册
 | 
			
		||||
    uni.saveImageToPhotosAlbum({
 | 
			
		||||
      filePath: painterImageUrl.value,
 | 
			
		||||
| 
						 | 
				
			
			@ -108,6 +110,7 @@
 | 
			
		|||
 | 
			
		||||
  // 获得海报数据
 | 
			
		||||
  async function getPoster() {
 | 
			
		||||
    painterImageUrl.value = undefined
 | 
			
		||||
    poster.views = await getPosterData({
 | 
			
		||||
      width: poster.css.width,
 | 
			
		||||
      shareInfo: props.shareInfo,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,10 @@
 | 
			
		|||
import sheep from '@/sheep';
 | 
			
		||||
import third from '@/sheep/api/migration/third';
 | 
			
		||||
import { formatImageUrlProtocol } from './index';
 | 
			
		||||
import { formatImageUrlProtocol, getWxaQrcode } from './index';
 | 
			
		||||
 | 
			
		||||
const goods = async (poster) => {
 | 
			
		||||
  const width = poster.width;
 | 
			
		||||
  const userInfo = sheep.$store('user').userInfo;
 | 
			
		||||
  const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
 | 
			
		||||
  const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query);
 | 
			
		||||
  return [
 | 
			
		||||
    {
 | 
			
		||||
      type: 'image',
 | 
			
		||||
| 
						 | 
				
			
			@ -62,7 +61,7 @@ const goods = async (poster) => {
 | 
			
		|||
        top: width * 1.18,
 | 
			
		||||
        color: '#333',
 | 
			
		||||
        fontSize: 14,
 | 
			
		||||
        lineHeight: 5,
 | 
			
		||||
        lineHeight: 15,
 | 
			
		||||
        maxWidth: width * 0.91,
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +71,7 @@ const goods = async (poster) => {
 | 
			
		|||
      css: {
 | 
			
		||||
        position: 'fixed',
 | 
			
		||||
        left: width * 0.04,
 | 
			
		||||
        top: width * 1.3,
 | 
			
		||||
        top: width * 1.31,
 | 
			
		||||
        fontSize: 20,
 | 
			
		||||
        fontFamily: 'OPPOSANS',
 | 
			
		||||
        color: '#333',
 | 
			
		||||
| 
						 | 
				
			
			@ -87,7 +86,7 @@ const goods = async (poster) => {
 | 
			
		|||
      css: {
 | 
			
		||||
        position: 'fixed',
 | 
			
		||||
        left: width * 0.3,
 | 
			
		||||
        top: width * 1.32,
 | 
			
		||||
        top: width * 1.33,
 | 
			
		||||
        color: '#999',
 | 
			
		||||
        fontSize: 10,
 | 
			
		||||
        fontFamily: 'OPPOSANS',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,10 @@
 | 
			
		|||
import sheep from '@/sheep';
 | 
			
		||||
import { formatImageUrlProtocol } from './index';
 | 
			
		||||
import third from '@/sheep/api/migration/third';
 | 
			
		||||
import { formatImageUrlProtocol, getWxaQrcode } from './index';
 | 
			
		||||
 | 
			
		||||
const groupon = async (poster) => {
 | 
			
		||||
  const width = poster.width;
 | 
			
		||||
  const userInfo = sheep.$store('user').userInfo;
 | 
			
		||||
  const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
 | 
			
		||||
  const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query);
 | 
			
		||||
  return [
 | 
			
		||||
    {
 | 
			
		||||
      type: 'image',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
import user from './user';
 | 
			
		||||
import goods from './goods';
 | 
			
		||||
import groupon from './groupon';
 | 
			
		||||
import third from '@/sheep/api/migration/third';
 | 
			
		||||
 | 
			
		||||
export function getPosterData(options) {
 | 
			
		||||
  switch (options.shareInfo.poster.type) {
 | 
			
		||||
| 
						 | 
				
			
			@ -30,3 +31,9 @@ export function formatImageUrlProtocol(url) {
 | 
			
		|||
 | 
			
		||||
  return url;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 获得微信小程序码 (Base64 image)
 | 
			
		||||
export async function getWxaQrcode(path, query) {
 | 
			
		||||
  const res = await third.wechat.getWxacode(path, query);
 | 
			
		||||
  return 'data:image/png;base64,' + res.data;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,10 @@
 | 
			
		|||
import sheep from '@/sheep';
 | 
			
		||||
import { formatImageUrlProtocol } from './index';
 | 
			
		||||
import third from '@/sheep/api/migration/third';
 | 
			
		||||
import { formatImageUrlProtocol, getWxaQrcode } from './index';
 | 
			
		||||
 | 
			
		||||
const user = async (poster) => {
 | 
			
		||||
  const width = poster.width;
 | 
			
		||||
  const userInfo = sheep.$store('user').userInfo;
 | 
			
		||||
  const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
 | 
			
		||||
  const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query);
 | 
			
		||||
  return [
 | 
			
		||||
    {
 | 
			
		||||
      type: 'image',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
// 登录
 | 
			
		||||
import third from '@/sheep/api/migration/third';
 | 
			
		||||
import SocialApi from '@/sheep/api/member/social';
 | 
			
		||||
import $share from '@/sheep/platform/share';
 | 
			
		||||
 | 
			
		||||
// TODO 芋艿:等后面搞 App 再弄
 | 
			
		||||
const socialType = 32; // 社交类型 - 微信开放平台
 | 
			
		||||
| 
						 | 
				
			
			@ -16,6 +17,7 @@ const login = () => {
 | 
			
		|||
    });
 | 
			
		||||
    debugger
 | 
			
		||||
    if (loginRes.errMsg == 'login:ok') {
 | 
			
		||||
      // TODO third.wechat.login 函数未实现
 | 
			
		||||
      const res = await third.wechat.login({
 | 
			
		||||
        platform: 'openPlatform',
 | 
			
		||||
        shareInfo: uni.getStorageSync('shareLog') || {},
 | 
			
		||||
| 
						 | 
				
			
			@ -27,6 +29,7 @@ const login = () => {
 | 
			
		|||
      });
 | 
			
		||||
 | 
			
		||||
      if (res.error === 0) {
 | 
			
		||||
        $share.bindBrokerageUser()
 | 
			
		||||
        resolve(true);
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@ import $store from '@/sheep/store';
 | 
			
		|||
import $platform from '@/sheep/platform';
 | 
			
		||||
import $router from '@/sheep/router';
 | 
			
		||||
import $url from '@/sheep/url';
 | 
			
		||||
import BrokerageApi from '@/sheep/api/trade/brokerage';
 | 
			
		||||
// #ifdef H5
 | 
			
		||||
import $wxsdk from '@/sheep/libs/sdk-h5-weixin';
 | 
			
		||||
// #endif
 | 
			
		||||
| 
						 | 
				
			
			@ -152,18 +153,16 @@ const decryptSpm = (spm) => {
 | 
			
		|||
        id: shareParamsArray[2],
 | 
			
		||||
      };
 | 
			
		||||
      break;
 | 
			
		||||
    case '6': // 分销
 | 
			
		||||
      // TODO puhui999: 如果用户未登录想想怎么搞
 | 
			
		||||
  }
 | 
			
		||||
  shareParams.platform = platformMap[shareParamsArray[3] - 1];
 | 
			
		||||
  shareParams.from = fromMap[shareParamsArray[4] - 1];
 | 
			
		||||
  if (shareParams.shareId != 0) {
 | 
			
		||||
    // 已登录 立即添加分享记录
 | 
			
		||||
  if (shareParams.shareId !== 0) {
 | 
			
		||||
    // 已登录 绑定推广员
 | 
			
		||||
    if (user.isLogin) {
 | 
			
		||||
      user.addShareLog(shareParams);
 | 
			
		||||
      bindBrokerageUser(shareParams.shareId);
 | 
			
		||||
    } else {
 | 
			
		||||
      // 未登录 待用户登录后添加分享记录
 | 
			
		||||
      uni.setStorageSync('shareLog', shareParams);
 | 
			
		||||
      // 记录分享者编号
 | 
			
		||||
      uni.setStorageSync('shareId', shareParams.shareId);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -173,6 +172,19 @@ const decryptSpm = (spm) => {
 | 
			
		|||
  return shareParams;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// 绑定推广员
 | 
			
		||||
const bindBrokerageUser = async (val= undefined) => {
 | 
			
		||||
  try {
 | 
			
		||||
    const shareId = val || uni.getStorageSync('shareId');
 | 
			
		||||
    if (!shareId) {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    await BrokerageApi.bindBrokerageUser({ bindUserId: shareId });
 | 
			
		||||
    uni.removeStorageSync('shareId');
 | 
			
		||||
  } catch {
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// 更新公众号分享sdk
 | 
			
		||||
const updateShareInfo = (shareInfo) => {
 | 
			
		||||
  // #ifdef H5
 | 
			
		||||
| 
						 | 
				
			
			@ -186,4 +198,5 @@ export default {
 | 
			
		|||
  getShareInfo,
 | 
			
		||||
  updateShareInfo,
 | 
			
		||||
  decryptSpm,
 | 
			
		||||
  bindBrokerageUser,
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,17 +1,9 @@
 | 
			
		|||
import {
 | 
			
		||||
	defineStore
 | 
			
		||||
} from 'pinia';
 | 
			
		||||
import { defineStore } from 'pinia';
 | 
			
		||||
import $share from '@/sheep/platform/share';
 | 
			
		||||
import {
 | 
			
		||||
	isEmpty,
 | 
			
		||||
	cloneDeep,
 | 
			
		||||
	clone
 | 
			
		||||
} from 'lodash';
 | 
			
		||||
import { clone, cloneDeep } from 'lodash';
 | 
			
		||||
import cart from './cart';
 | 
			
		||||
import app from './app';
 | 
			
		||||
import {
 | 
			
		||||
	showAuthModal
 | 
			
		||||
} from '@/sheep/hooks/useModal';
 | 
			
		||||
import { showAuthModal } from '@/sheep/hooks/useModal';
 | 
			
		||||
import UserApi from '@/sheep/api/member/user';
 | 
			
		||||
import PayWalletApi from '@/sheep/api/pay/wallet';
 | 
			
		||||
import OrderApi from '@/sheep/api/trade/order';
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +21,7 @@ const defaultUserInfo = {
 | 
			
		|||
// 默认钱包信息
 | 
			
		||||
const defaultUserWallet = {
 | 
			
		||||
  balance: 0, // 余额
 | 
			
		||||
}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// 默认订单、优惠券等其他资产信息
 | 
			
		||||
const defaultNumData = {
 | 
			
		||||
| 
						 | 
				
			
			@ -90,19 +82,19 @@ const user = defineStore({
 | 
			
		|||
 | 
			
		||||
    // 添加分享记录
 | 
			
		||||
    // TODO 芋艿:整理下;
 | 
			
		||||
    async addShareLog(params) {
 | 
			
		||||
			const {
 | 
			
		||||
				error
 | 
			
		||||
			} = await userApi.addShareLog(params);
 | 
			
		||||
			if (error === 0) uni.removeStorageSync('shareLog');
 | 
			
		||||
		},
 | 
			
		||||
    // async addShareLog(params) {
 | 
			
		||||
    // 	const {
 | 
			
		||||
    // 		error
 | 
			
		||||
    // 	} = await userApi.addShareLog(params);
 | 
			
		||||
    // 	if (error === 0) uni.removeStorageSync('shareLog');
 | 
			
		||||
    // },
 | 
			
		||||
 | 
			
		||||
    // 设置 token
 | 
			
		||||
    setToken(token = '', refreshToken = '') {
 | 
			
		||||
      if (token === '') {
 | 
			
		||||
        this.isLogin = false;
 | 
			
		||||
        uni.removeStorageSync('token');
 | 
			
		||||
        uni.removeStorageSync('refresh-token')
 | 
			
		||||
        uni.removeStorageSync('refresh-token');
 | 
			
		||||
      } else {
 | 
			
		||||
        this.isLogin = true;
 | 
			
		||||
        uni.setStorageSync('token', token);
 | 
			
		||||
| 
						 | 
				
			
			@ -159,14 +151,16 @@ const user = defineStore({
 | 
			
		|||
        showAuthModal('changeMobile');
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // 绑定推广员
 | 
			
		||||
      $share.bindBrokerageUser()
 | 
			
		||||
      // 添加分享记录
 | 
			
		||||
      // TODO 芋艿:整理下;
 | 
			
		||||
      const shareLog = uni.getStorageSync('shareLog');
 | 
			
		||||
			if (!isEmpty(shareLog)) {
 | 
			
		||||
				this.addShareLog({
 | 
			
		||||
					...shareLog,
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
      // const shareLog = uni.getStorageSync('shareLog');
 | 
			
		||||
      // if (!isEmpty(shareLog)) {
 | 
			
		||||
      // 	this.addShareLog({
 | 
			
		||||
      // 		...shareLog,
 | 
			
		||||
      // 	});
 | 
			
		||||
      // }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 登出系统
 | 
			
		||||
| 
						 | 
				
			
			@ -179,7 +173,7 @@ const user = defineStore({
 | 
			
		|||
    enabled: true,
 | 
			
		||||
    strategies: [{
 | 
			
		||||
      key: 'user-store',
 | 
			
		||||
		}, ],
 | 
			
		||||
    }]
 | 
			
		||||
  },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue