From b9fc064ccf1e3c593fddc7fdcf69297f1cb2c309 Mon Sep 17 00:00:00 2001 From: 小川 费 <449111130@qq.com> Date: Tue, 24 Sep 2019 14:00:21 +0800 Subject: [PATCH] 1 --- tools/sdk-share-tools-1.0.1.zip | Bin 0 -> 4516 bytes tools/sdk-share-tools-1.0.1/SDKTools.ts | 49 ------------------------------------------------- tools/sdk-share-tools-1.0.1/ShareVideoTools.ts | 150 ------------------------------------------------------------------------------------------------------------------------------------------------------ 3 files changed, 0 insertions(+), 199 deletions(-) create mode 100644 tools/sdk-share-tools-1.0.1.zip delete mode 100644 tools/sdk-share-tools-1.0.1/SDKTools.ts delete mode 100644 tools/sdk-share-tools-1.0.1/ShareVideoTools.ts diff --git a/tools/sdk-share-tools-1.0.1.zip b/tools/sdk-share-tools-1.0.1.zip new file mode 100644 index 0000000..b13c983 Binary files /dev/null and b/tools/sdk-share-tools-1.0.1.zip differ diff --git a/tools/sdk-share-tools-1.0.1/SDKTools.ts b/tools/sdk-share-tools-1.0.1/SDKTools.ts deleted file mode 100644 index 63100c1..0000000 --- a/tools/sdk-share-tools-1.0.1/SDKTools.ts +++ /dev/null @@ -1,49 +0,0 @@ -import ShareVideoTools, { ShareVideoKeys, ShareVideoType } from "./ShareVideoTools"; - -/* -* SDK工具类库; -*/ -export default class SDKTools { - // 判断PCSDK是否支持 - static get isSupported() { - return typeof PCSDK === 'object'; - } - - /** - * 检测普通不是返回值为Promise的 api接口:在浏览器中或其他不支持的平台不至于报错 - * @param callback 接口 api函数 - * @param defaltVal 返回的默认值 - */ - private static checkNormal(callback: Function, defaltVal?: T): T { - if (!this.isSupported) return defaltVal; - return callback(); - } - - /** - * 检测普返回值为Promise的 api接口:在浏览器中或其他不支持的平台不至于报错 - * @param callback 接口 api函数 - * @param defaltVal 返回的默认值 - */ - private static checkPromise(callback: Function, defaultVal: Promise = Promise.resolve()): Promise { - return this.checkNormal>(callback, defaultVal); - } - - static getType(shareVideoKey: ShareVideoKeys): ShareVideoType { - return this.checkNormal(() => ShareVideoTools.getType(shareVideoKey), ShareVideoType.Share); - } - - static share(shareVideoKey: ShareVideoKeys, params?: any, opts?: any): void { - return this.checkNormal(() => ShareVideoTools.share(shareVideoKey, params, opts), null); - } - - static dispatch(shareVideoKey: ShareVideoKeys, params?: { type?: number, success?: Function, fail?: Function, context?: any }): void { - if (!this.isSupported) - return params && params.success && params.success.call(params.context || this); - else - return this.checkNormal(() => ShareVideoTools.dispatch(shareVideoKey, params), null); - } - - static dispatchType(shareVideoType: ShareVideoType, shareVideoKey: ShareVideoKeys, opts?: { success?: Function, fail?: Function, context?: any }): void { - return this.checkNormal(() => ShareVideoTools.dispatchType(shareVideoType, shareVideoKey, opts), null); - } -} \ No newline at end of file diff --git a/tools/sdk-share-tools-1.0.1/ShareVideoTools.ts b/tools/sdk-share-tools-1.0.1/ShareVideoTools.ts deleted file mode 100644 index 9b3fe0e..0000000 --- a/tools/sdk-share-tools-1.0.1/ShareVideoTools.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* 分享与视频工具类; -*/ -export default class ShareVideoTools { - /** - * @param key - * @param params - */ - static getType(key: ShareVideoKeys): ShareVideoType { - return PCSDK.shareVideo.getType(key.toString()); - } - - /** - * 普通分享,不进行处理回调 - * @param key - * @param params 分享参数 - * @param opts 扩展参数 - */ - static share(key: ShareVideoKeys, params: any, opts?: any) { - PCSDK.shareVideo.share(key.toString(), params, opts).then(ret => this.handleSuccess(ShareVideoFrom.Share, ret)); - } - - /** - * 验证分享:可处理成功、失败 - * @param key - * @param params - */ - static dispatch(key: ShareVideoKeys, params?: { type?: number, success?: Function, fail?: Function, context?: any }) { - PCSDK.shareVideo.shareDispatch(key.toString(), this.buildParams(params)); - } - - /** - * 可自定义类型的验证分享:例如后台配的shareVideoKey是分享,但是这个key临时想要看视频,可传递shareVideoType Video类型强制使用视频 - * @param shareVideoType - * @param key - * @param params - */ - static dispatchType(shareType: ShareVideoType, key: ShareVideoKeys, params?: { type?: number, success?: Function, fail?: Function, context?: any }) { - PCSDK.shareVideo.dispatchType(shareType, key.toString(), this.buildParams(params)); - } - - /** - * 对参数进行处理 - * @param params - */ - private static buildParams(params: any = {}) { - let { isOveride } = params; - let { success, fail, context } = params; - // 设置成功处理 - params = { - ...params, - success: (from: ShareVideoFrom, ret) => { - success && success.call(context, from, ret); - this.handleSuccess(from, ret); - } - }; - - if (isOveride) - // 覆盖:失败默认处理 - return { - ...params, - fail: (from: ShareVideoFrom, err) => { - fail && fail.call(context, from, err); - } - }; - else - // 不覆盖:失败默认处理 - return { - ...params, - fail: (from: ShareVideoFrom, err) => { - fail && fail.call(context, from, err); - this.handleError(from, err); - } - }; - } - - /** - * 成功默认处理:分享和视频统计 - * @param from 来源 - * @param ret? - */ - private static handleSuccess(from: ShareVideoFrom, ret: any | null) { - switch (from) { - case ShareVideoFrom.Share: // 同步分享 - case ShareVideoFrom.ShareAysnc: // 异步分享 - break; - - case ShareVideoFrom.Video: // 看视频 - break; - } - } - - /** - * 失败默认设置(可覆盖) - * @param from 来源 - * @param error: 失败消息对象 - */ - private static handleError(from: ShareVideoFrom, error: { code: number, msg: string } | null) { - if (!error) return; - // 开发者自定义处理 error msg - if (error.code) { - // wx.showToast({ - // title: error.msg - // }); - // ViewManager.I.showModal(ComTipFull, error.msg); - } - } -} - -// 分享视频类型(与后台一一对应) -export enum ShareVideoType { - None = -1, // -1无分享无视频 - Share = 0, // 0同步分享 - ShareAysnc = 1, // 1异步分享 - ShareIntegral = 5, // 5分享积分 - Video = 2, // 2看视频 - VideoToShare = 3, // 3无视频则分享 - VideoAndShare = 4, // 4视频和分享(控制分享和视频两个按钮的显示) , -} - -// 分享或者视频来源 -export enum ShareVideoFrom { - None, // 无分享 - Share, // 同步分享 - ShareAysnc, // 异步分享 - Video // 看视频 -} - -// 分享视频keysKeys -export enum ShareVideoKeys { - Forward = 'forward', // 右上角三点转发 - CoinTip = 'coin_tip', // 金币不足弹出框 - DiamondDouble = 'diamond_double', // 钻石再来一份 - SuccessDouble = 'success_double', // 成功界面双倍 - LevelUpDiamond = 'levelup_diamond', // 升级活动钻石 - FailRewardDouble = 'fail_reward_double' // 失败获得双倍奖励 -} - -// 分享和视频错误 -export enum ShareVideoError { - VideoQuit = 1000, // { code: 1000, msg: '要看完视频哦!' }, - VideoFail = 1001, // { code: 1001, msg: '加载视频广告失败!' }, - VideoNotOpen = 1002, // { code: 1002, msg: '微信版本过低,暂不支持看视频!' }, - VideoPlaying = 1003, // { code: 1003, msg: '正在观看视频中...' }, - VideoInvalid = 999, // { code: 999, msg: '视频UID不存在!' }, - ShareFail = 1004, // { code: 1004, msg: '失败,发给其他好友试试!' }, - ShareSame = 1005, // { code: 1005, msg: '别总骚扰这个群,换个群分享吧!' }, - ShareNotGroup = 1006, // { code: 1006, msg: '请分享到群哦!' } - ShareAsyncNotGroup = 1007 // { code: 1007, msg: '分享到群才能领取更多~' } -} \ No newline at end of file -- libgit2 0.21.0