Commit 87a0f380 authored by wildfirecode13's avatar wildfirecode13

1

parent 31edc578
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const app = getApp();
const { tbcc, cloudName, cloud, requestType } = app;
const { utils: { generateAPI }, request: tbccRequest, capi } = tbcc;
const apicfg_1 = require("./apicfg");
const request = tbccRequest({
cloud,
cloudName,
requestType
});
// api handle 列表
const apiList = Object.assign(Object.assign({}, capi), apicfg_1.default);
const apiList = {
...capi,
getIndex: {
handle: 'index',
isShowLoading: true
},
login: 'login'
};
// 生成API
const API = generateAPI(apiList, request);
exports.default = API;
//# sourceMappingURL=api.js.map
\ No newline at end of file
export default API;
page {
background: #f7f7f7;
font-family: 'Helvetica Neue', Helvetica, Hiragino Sans GB, 'Microsoft Yahei', STHeiTi, Arial, sans-serif;
}
* {
box-sizing: border-box;
}
.d-flex {
display: flex
}
.d-flex__item {
flex: 1;
}
.d-flex--aligncenter {
align-items: center;
}
.modal-animate-fade-in {
opacity: 0;
animation: modalAnimateFadeIn .3s forwards;
}
.modal-animate-zoom-in {
transform: scale(0);
animation: modalAnimateZoomIn .3s forwards;
}
.modal-animate-fly-in {
transform: translateY(100%);
animation: modalAnimateFlyIn .3s forwards;
}
.btn-animate-pulse {
animation: btnAnimatePulse .8s infinite;
}
@keyframes modalAnimateFadeIn {
to {
opacity: 1;
}
}
@keyframes modalAnimateZoomIn {
to {
transform: scale(1);
}
}
@keyframes modalAnimateFlyIn {
to {
transform: translateY(0);
}
}
@keyframes btnAnimatePulse {
from {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
to {
transform: scale(1);
}
}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mp_cloud_sdk_1 = require("@tbmp/mp-cloud-sdk");
mp_cloud_sdk_1.default.init({
import cloud from '@tbmp/mp-cloud-sdk';
import tbcc from './tbcc-sdk';
cloud.init({
env: 'test' // 云函数环境 test 测试环境 online 线上环境
});
App({
requestType: 'cloud',
cloudName: '',
cloud: // 主云函数项目名
mp_cloud_sdk_1.default,
activityId: "",
requestType: 'cloud', // ams:ams接口,cloud: 云函数
cloudName: 'skechRun', // 主云函数项目名 base clientTemplate2C
cloud,
tbcc,
onLaunch(options) {
this.handleQuery(options.query || {});
},
onShow(options) {
// 从后台被 scheme 重新打开
console.log('执行了app onshow')
},
/**
* 处理链接参数
......@@ -22,7 +23,6 @@ App({
*/
handleQuery(query) {
const { activityId } = query;
activityId && (this.activityId = activityId);
this.activityId = activityId || '5f4605629897b44ce119d8f1';
}
});
//# sourceMappingURL=app.js.map
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tb = require("./lib/tb");
const tbMock = require("./lib/tbMock");
const utils = require("./lib/utils");
const constants = require("./lib/constants");
const capi_1 = require("./lib/capi");
const request_1 = require("./lib/request");
import * as tb from './lib/tb';
import * as tbMock from './lib/tbMock';
import * as utils from './lib/utils';
import * as constants from './lib/constants';
import capi from './lib/capi';
import request from './lib/request';
const isH5 = 'undefined' !== typeof window;
// 如果为h5环境走mock数据
let _tb = {};
Object.entries(tb).forEach(([key, value]) => {
_tb[key] = isH5 ? tbMock[key] : value;
});
exports.default = {
capi: capi_1.default,
export default {
capi,
tb: _tb,
utils,
request: request_1.default,
request,
constants
};
\ No newline at end of file
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/index.js"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,uCAAuC;AACvC,qCAAqC;AACrC,6CAA6C;AAC7C,qCAA8B;AAC9B,2CAAoC;AAEpC,MAAM,IAAI,GAAG,WAAW,KAAK,OAAO,MAAM,CAAC;AAE3C,iBAAiB;AACjB,IAAI,GAAG,GAAG,EAAE,CAAC;AACb,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;IAC1C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACxC,CAAC,CAAC,CAAC;AAEH,kBAAe;IACb,IAAI,EAAJ,cAAI;IACJ,EAAE,EAAE,GAAG;IACP,KAAK;IACL,OAAO,EAAP,iBAAO;IACP,SAAS;CACV,CAAC"}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const capi = {
getMyPrizeList: {
handle: 'getMyPrizeList',
isShowLoading: true
},
getMyPrizeList:'getMyPrizeList',
receiveObjectPrize: 'receiveObjectPrize',
receiveEnamePrize: 'receiveEnamePrize'
receiveEnamePrize: 'receiveEnamePrize',
getItemListByItemIds: 'getItemListByItemIds',
getCollectItemList: 'getCollectItemList',
doCollectGoodsTask: 'doCollectGoodsTask',
getVipInfo:'getVipInfo'
};
exports.default = capi;
//# sourceMappingURL=capi.js.map
\ No newline at end of file
export default capi;
{"version":3,"file":"capi.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/capi.js"],"names":[],"mappings":";;AAAA,MAAM,IAAI,GAAG;IACX,cAAc,EAAE;QACd,MAAM,EAAE,gBAAgB;QACxB,aAAa,EAAE,IAAI;KACpB;IACD,kBAAkB,EAAE,oBAAoB;IACxC,iBAAiB,EAAE,mBAAmB;CACvC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
\ No newline at end of file
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const tb_1 = require("./tb");
const utils_1 = require("./utils");
import { getUserAddress, commonToast } from './tb';
import { getRequestParams } from './utils';
// 通用API封装方法
const capiFn = (apiList, request) => {
return {
receiveObjectPrize(params) {
return __awaiter(this, void 0, void 0, function* () {
const { handle, method, ext } = utils_1.getRequestParams(apiList['receiveObjectPrize']);
const userAddress = yield tb_1.getUserAddress().catch(err => {
tb_1.commonToast(err.errorMessage);
async receiveObjectPrize(params) {
const { handle, method, ext } = getRequestParams(apiList['receiveObjectPrize']);
const userAddress = await getUserAddress().catch(err => {
commonToast(err.errorMessage);
});
if (userAddress) {
const { name, phone, address } = userAddress.duibaAddress;
commonConfirm('提示', '确认使用该收货地址:' + name + phone + address, () => __awaiter(this, void 0, void 0, function* () {
params = Object.assign({ name,
commonConfirm('提示', '确认使用该收货地址:' + name + phone + address, async () => {
params = {
name,
phone,
address }, params);
const result = yield request(handle, method, params, ext).catch(res => {
tb_1.commonToast(res && res.message);
address,
...params
}
const result = await request(handle, method, params, ext).catch(res => {
commonToast(res && res.message);
});
if (result && result.success) {
return true;
}
}));
});
}
return false;
});
},
receiveEnamePrize(params) {
return __awaiter(this, void 0, void 0, function* () {
const { handle, method, ext } = utils_1.getRequestParams(apiList['receiveEnamePrize']);
const result = yield request(handle, method, params, ext).catch(res => {
tb_1.commonToast(res && res.message);
async receiveEnamePrize(params) {
const { handle, method, ext } = getRequestParams(apiList['receiveEnamePrize']);
const result = await request(handle, method, params, ext).catch(res => {
commonToast(res && res.message);
});
if (result && result.success) {
return true;
}
return false;
});
}
};
}
};
exports.default = capiFn;
//# sourceMappingURL=capiFn.js.map
\ No newline at end of file
export default capiFn;
{"version":3,"file":"capiFn.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/capiFn.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAAmD;AACnD,mCAA2C;AAE3C,YAAY;AACZ,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,EAA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EAAE;oBACpE,gBAAW,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;gBAClC,CAAC,CAAC,CAAC;gBACH,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;oBAC5B,OAAO,IAAI,CAAC;iBACb;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SAAA;KACF,CAAA;AACH,CAAC,CAAC;AAGF,kBAAe,MAAM,CAAC"}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PRIZE_TYPE = exports.DRAW_STATUS = void 0;
// 领取奖品状态
exports.DRAW_STATUS = {
// 待领取
WAITAWARD: 1,
// 处理中
PROCESSING: 2,
// 领取成功
SUCCESS: 3,
// 领取失败
FAIL: 4,
// 已过期
EXPIRED: 5,
// 重新领取
RETRY: 6
// 分享配置
export const SHARE_CONFIG = {
title: '分享测试标题',
desc: '分享测试描述',
imageUrl: '', // 分享图片URL
path: 'pages/index/index'
};
// 奖品类型
exports.PRIZE_TYPE = {
ENAME: 1,
CREDITS: 2,
OBJECT: 3,
THANKS: 5
// 链接配置
export const REDIRECT_URL = {
'testpage': '/pages/testPage/testPage',
'tmall': 'https://www.tmall.com'
};
//# sourceMappingURL=constants.js.map
\ No newline at end of file
// 我的奖品状态
export const PRIZE_DRAW_STATUS_MAP = {
RECEIVE: 1, // 待领取
DEALING: 2, // 处理中
SUCCESS: 3, // 领取成功
FAILURE: 4, // 领取失败
FINISHED: 5, // 已过期
REPEAT: 6, // 重新领取
}
// 奖品类型
export const PRIZE_TYPE_MAP = {
EQUITY: 1, // 权益
INTEGRATION: 2, // 积分
ENTITY: 3, // 实物
THANKS: 5 // 谢谢参与
}
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/constants.js"],"names":[],"mappings":";;;AAAA,SAAS;AACI,QAAA,WAAW,GAAG;IACzB,MAAM;IACN,SAAS,EAAE,CAAC;IACZ,MAAM;IACN,UAAU,EAAE,CAAC;IACb,OAAO;IACP,OAAO,EAAE,CAAC;IACV,OAAO;IACP,IAAI,EAAE,CAAC;IACP,MAAM;IACN,OAAO,EAAE,CAAC;IACV,OAAO;IACP,KAAK,EAAE,CAAC;CACT,CAAA;AAED,OAAO;AACM,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;CACV,CAAC"}
\ No newline at end of file
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const AMS_URL = 'https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=';
const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
if (!cloud) {
console.error('请传入cloud');
......@@ -19,10 +9,10 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
console.error('请传入云函数名称');
return false;
}
return (handle, method, params, ext = {}) => __awaiter(void 0, void 0, void 0, function* () {
return async (handle, method, params, ext = {}) => {
const { activityId } = getApp();
// 默认注入activityId
params = Object.assign({ activityId }, params);
params = { activityId, ...params };
if (!params.activityId) {
console.error(`${handle}:请传入activityId`);
return false;
......@@ -37,6 +27,7 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
if (isShowLoading) {
my.showLoading();
}
const requestAms = () => {
return new Promise((resolve, reject) => {
my.request({
......@@ -48,16 +39,16 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
hideMyLoading();
if (res && res.success) {
resolve(res);
}
else {
} else {
reject(res);
}
}).catch(() => {
hideMyLoading();
reject();
});
});
})
};
const requestCloud = () => {
return new Promise((resolve, reject) => {
cloud.function.invoke(_cloudName, params, handle).then(res => {
......@@ -65,8 +56,7 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
hideMyLoading();
if (res && res.success) {
resolve(res);
}
else {
} else {
reject(res);
}
return res;
......@@ -76,8 +66,10 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
});
});
};
return requestType === 'ams' ? requestAms() : requestCloud();
});
};
};
exports.default = request;
//# sourceMappingURL=request.js.map
\ No newline at end of file
export default request;
\ No newline at end of file
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/request.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,MAAM,OAAO,GAAG,iFAAiF,CAAC;AAElG,MAAM,OAAO,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,GAAG,OAAO,EAAE,EAAE,EAAE;IAC9D,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;KACd;IACD,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;KACd;IACD,OAAO,CAAO,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE;QAChD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,EAAE,CAAC;QAChC,iBAAiB;QACjB,MAAM,mBAAK,UAAU,IAAK,MAAM,CAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YACtB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,gBAAgB,CAAC,CAAC;YACzC,OAAO,KAAK,CAAC;SACd;QACD,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,IA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AAC;oBAChB,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE;wBACtB,OAAO,CAAC,GAAG,CAAC,CAAC;qBACd;yBAAM;wBACL,MAAM,CAAC,GAAG,CAAC,CAAC;qBACb;oBACD,OAAO,GAAG,CAAC;gBACb,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;oBACZ,aAAa,EAAE,CAAC;oBAChB,MAAM,EAAE,CAAC;gBACX,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IAC/D,CAAC,CAAA,CAAC;AAEJ,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
\ No newline at end of file
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.textRiskIdentification = exports.chattingSendCard = exports.uploadImage = exports.getImageInfo = exports.chooseImage = exports.getUserAddress = exports.createAudio = exports.openDetail = exports.checkGoodsCollectedStatus = exports.collectGoods = exports.getServerTime = exports.redirectTo = exports.navigateTo = exports.navigateToOutside = exports.checkShopFavoredStatus = exports.favorShop = exports.getSystemInfo = exports.getAuthUserInfo = exports.commonConfirm = exports.simpleAlert = exports.commonToast = void 0;
/**
* 通用toast
* @param {string} content toast内容
* @param {number} duration 显示时长
* @param {function} successCb 成功回调
*/
exports.commonToast = (content, duration = 3000, successCb) => {
export const commonToast = (content, duration = 3000, successCb) => {
my.showToast({
content: content || '换个姿势再试一次~',
duration,
success: successCb
});
};
/**
* 简易alert
* @param {string} content toast内容
*/
exports.simpleAlert = content => {
export const simpleAlert = content => {
my.alert({
content
});
};
/**
* 通用确认弹窗
* @param {string} title 标题
* @param {string} content 内容
* @param {function} successCb 成功回调
*/
exports.commonConfirm = (title = '提示', content, successCb) => {
export const commonConfirm = (title = '提示', content, successCb) => {
my.confirm({
title,
content,
......@@ -52,11 +42,12 @@ exports.commonConfirm = (title = '提示', content, successCb) => {
}
});
};
/**
* 获取授权用户信息
* @returns {object} 用户登录信息
*/
exports.getAuthUserInfo = () => __awaiter(void 0, void 0, void 0, function* () {
export const getAuthUserInfo = async () => {
return new Promise((resolve, reject) => {
my.authorize({
scopes: 'scope.userInfo',
......@@ -75,12 +66,13 @@ exports.getAuthUserInfo = () => __awaiter(void 0, void 0, void 0, function* () {
}
});
});
});
};
/**
* 获取系统信息
* @returns {object} 小程序系统信息
*/
exports.getSystemInfo = () => __awaiter(void 0, void 0, void 0, function* () {
export const getSystemInfo = async () => {
return new Promise((resolve, reject) => {
my.getSystemInfo({
success: res => {
......@@ -91,13 +83,14 @@ exports.getSystemInfo = () => __awaiter(void 0, void 0, void 0, function* () {
}
});
});
});
};
/**
* 执行关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
exports.favorShop = (sellerId) => __awaiter(void 0, void 0, void 0, function* () {
export const favorShop = async sellerId => {
if (!sellerId) {
console.error('favorShop: 请传入卖家Id');
return false;
......@@ -117,13 +110,14 @@ exports.favorShop = (sellerId) => __awaiter(void 0, void 0, void 0, function* ()
}
});
});
});
};
/**
* 判断是否关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
exports.checkShopFavoredStatus = (sellerId) => __awaiter(void 0, void 0, void 0, function* () {
export const checkShopFavoredStatus = async sellerId => {
if (!sellerId) {
console.error('checkShopFavoredStatus: 请传入卖家Id');
return false;
......@@ -139,45 +133,49 @@ exports.checkShopFavoredStatus = (sellerId) => __awaiter(void 0, void 0, void 0,
}
});
});
});
};
/**
* 跳转到外部链接
* @param {string} url 跳转链接
*/
exports.navigateToOutside = url => {
export const navigateToOutside = url => {
if (!url) {
console.error('navigateToOutside: 请传入url');
return false;
}
my.call('navigateToOutside', { url });
};
/**
* 跳转到内部链接(新开窗口)
* @param {string} url 跳转链接
*/
exports.navigateTo = url => {
export const navigateTo = url => {
if (!url) {
console.error('navigateTo: 请传入url');
return false;
}
my.navigateTo({ url });
};
/**
* 跳转到内部链接(不新开窗口)
* @param {string} url 跳转链接
*/
exports.redirectTo = url => {
export const redirectTo = url => {
if (!url) {
console.error('redirectTo: 请传入url');
return false;
}
my.redirectTo({ url });
};
/**
* 获取服务器时间
* @returns {number} 服务器时间戳
*/
exports.getServerTime = () => __awaiter(void 0, void 0, void 0, function* () {
export const getServerTime = async () => {
return new Promise((resolve, reject) => {
my.getServerTime({
success: res => {
......@@ -188,13 +186,14 @@ exports.getServerTime = () => __awaiter(void 0, void 0, void 0, function* () {
}
});
});
});
};
/**
* 收藏商品
* @param {number} 商品id
* @returns {object} 收藏结果
*/
exports.collectGoods = (id) => __awaiter(void 0, void 0, void 0, function* () {
export const collectGoods = async id => {
if (!id) {
console.error('collectGoods: 请传入商品id');
return false;
......@@ -214,13 +213,14 @@ exports.collectGoods = (id) => __awaiter(void 0, void 0, void 0, function* () {
}
});
});
});
};
/**
* 查询商品收藏状态
* @param {number} 商品id
* @returns {boolean} 商品收场状态
*/
exports.checkGoodsCollectedStatus = (id) => __awaiter(void 0, void 0, void 0, function* () {
export const checkGoodsCollectedStatus = async id => {
if (!id) {
console.error('checkGoodsCollectedStatus: 请传入商品id');
return false;
......@@ -233,12 +233,13 @@ exports.checkGoodsCollectedStatus = (id) => __awaiter(void 0, void 0, void 0, fu
}
});
});
});
};
/**
* 跳转到淘宝商品页
* @param {string} itemId 商品ID
*/
exports.openDetail = (itemId) => __awaiter(void 0, void 0, void 0, function* () {
export const openDetail = async itemId => {
if (!itemId) {
console.error('openDetail: 请传入商品id');
return false;
......@@ -254,7 +255,8 @@ exports.openDetail = (itemId) => __awaiter(void 0, void 0, void 0, function* ()
}
});
});
});
};
/**
* 创建音频类
*/
......@@ -271,8 +273,7 @@ class AudioModel {
innerAudioContext[item] = opts[item];
});
return innerAudioContext;
}
catch (e) {
} catch (e) {
console.error('当前版本不支持音频');
}
}
......@@ -281,14 +282,15 @@ class AudioModel {
* 创建音频实例
* @param {object} opts 配置对象 例 { src: '音频链接', autoplay: false }
*/
exports.createAudio = opts => {
export const createAudio = opts => {
const audioInstance = new AudioModel(opts);
return audioInstance;
};
/**
* 获取淘宝用户收货地址
*/
exports.getUserAddress = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
export const getUserAddress = async (opts = {}) => {
let defaults = {
addAddress: 'show',
searchAddress: 'hide',
......@@ -308,34 +310,41 @@ exports.getUserAddress = (opts = {}) => __awaiter(void 0, void 0, void 0, functi
});
return false;
}
my.tb.chooseAddress({
my.tb.chooseAddress(
{
addAddress,
searchAddress,
locateAddress
}, res => {
},
res => {
const { error, provinceName, countyName, cityName, streetName, detailInfo, name, telNumber } = res;
// 如果有error为用户取消操作不做操作
if (error) {
resolve(false);
}
else {
resolve(Object.assign(Object.assign({}, res), { duibaAddress: {
} else {
resolve({
...res,
duibaAddress: {
name,
phone: telNumber,
address: [provinceName, cityName, countyName, streetName, detailInfo].join(joinTag)
} }));
}
}, res => {
reject(res);
});
}
},
res => {
reject(res);
}
);
}
});
});
});
};
/**
* 选择图片
*/
exports.chooseImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
export const chooseImage = async (opts = {}) => {
let defaults = {
count: 1,
sourceType: ['camera', 'album'],
......@@ -370,19 +379,19 @@ exports.chooseImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function*
// error code 2001 为摄像头授权取消、ios 11为用户取消操作不认作失败场景 、安卓 为1
if (err.error !== 2001 && err.error !== 11 && err.error !== 1) {
reject(err);
}
else {
} else {
resolve(false);
}
}
});
});
});
};
/**
* 获取图片信息
* @param {string} src 图片地址
*/
exports.getImageInfo = (src) => __awaiter(void 0, void 0, void 0, function* () {
export const getImageInfo = async src => {
return new Promise((resolve, reject) => {
my.getImageInfo({
src,
......@@ -394,32 +403,33 @@ exports.getImageInfo = (src) => __awaiter(void 0, void 0, void 0, function* () {
}
});
});
});
};
/**
* 获取图片信息
* @param {*} opts chooseImage配置参数
*/
exports.uploadImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
export const uploadImage = async (opts = {}) => {
const { cloud } = getApp();
if (!cloud) {
console.error('chattingSendCard: 请传入app.cloud');
return false;
}
const chooseImageResult = yield exports.chooseImage(opts).catch(err => {
exports.commonToast(err && (err.errorMessage || '选择图片失败'));
const chooseImageResult = await chooseImage(opts).catch(err => {
commonToast(err && (err.errorMessage || '选择图片失败'));
});
if (chooseImageResult) {
const { apFilePaths } = chooseImageResult;
const filePath = apFilePaths[0];
const imageInfo = yield exports.getImageInfo(filePath).catch(err => {
exports.commonToast(err && err.errorMessage);
const imageInfo = await getImageInfo(filePath).catch(err => {
commonToast(err && err.errorMessage);
});
// 找不到图片信息
if (!imageInfo) {
return false;
}
const { path: imagePath } = imageInfo;
const { url } = yield cloud.file.uploadFile({
const { url } = await cloud.file.uploadFile({
filePath,
fileType: 'image',
fileName: imagePath.split('/').pop()
......@@ -427,17 +437,19 @@ exports.uploadImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function*
return url;
}
return false;
});
}
/**
* 分享到群聊卡片
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
exports.chattingSendCard = (requestInfo) => __awaiter(void 0, void 0, void 0, function* () {
export const chattingSendCard = async (requestInfo) => {
const { cloud } = getApp();
if (!cloud) {
console.error('chattingSendCard: 请传入app.cloud');
return false;
}
if (!requestInfo) {
console.error('chattingSendCard: 请传入卡片请求参数');
return false;
......@@ -445,8 +457,8 @@ exports.chattingSendCard = (requestInfo) => __awaiter(void 0, void 0, void 0, fu
return new Promise((resolve, reject) => {
my.authorize({
scopes: 'scope.groupChat',
success: () => __awaiter(void 0, void 0, void 0, function* () {
const result = yield cloud.topApi
success: async () => {
const result = await cloud.topApi
.invoke({
api: 'taobao.chatting.platform.message.sendcard',
data: { request_info: JSON.stringify(requestInfo) }
......@@ -458,12 +470,11 @@ exports.chattingSendCard = (requestInfo) => __awaiter(void 0, void 0, void 0, fu
const { error } = result;
if (error) {
resolve(false);
}
else {
} else {
resolve(result);
}
}
}),
},
fail: err => {
if (err.error === 11) {
// error code 11 为用户取消操作不认作失败场景
......@@ -473,13 +484,14 @@ exports.chattingSendCard = (requestInfo) => __awaiter(void 0, void 0, void 0, fu
}
});
});
});
};
/**
* 分享到群聊卡片
* @param {*} cloud 小程序云
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
exports.textRiskIdentification = (text) => __awaiter(void 0, void 0, void 0, function* () {
export const textRiskIdentification = async (text) => {
return new Promise((resolve, reject) => {
if (!my.tb.textRiskIdentification) {
reject({
......@@ -488,12 +500,12 @@ exports.textRiskIdentification = (text) => __awaiter(void 0, void 0, void 0, fun
});
}
my.tb.textRiskIdentification({
data: {
data:{
text
},
success: res => {
if (res.data && res.data.result) {
const { suggestion } = res.data.result;
const { suggestion }= res.data.result;
if (suggestion === 'pass') {
resolve(true);
}
......@@ -501,9 +513,28 @@ exports.textRiskIdentification = (text) => __awaiter(void 0, void 0, void 0, fun
resolve(false);
},
fail: err => {
reject(err);
reject(err)
},
});
});
});
//# sourceMappingURL=tb.js.map
\ No newline at end of file
})
})
}
// 剪切板
export function setClipboard(params) {
return promisifyMyApi('setClipboard', params)
};
function promisifyMyApi(methodName, params = {}) {
return new Promise((resolve, reject) => {
my[methodName]({
...params,
success: res => {
resolve(res)
},
fail: err => {
reject(err)
}
})
})
}
{"version":3,"file":"tb.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/tb.js"],"names":[],"mappings":";;;;;;;;;;;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C;gBACH,IAAI;aACL;YACD,OAAO,EAAE,GAAG,CAAC,EAAE;gBACb,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE;oBAC/B,MAAM,EAAE,UAAU,EAAE,GAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;oBACtC,IAAI,UAAU,KAAK,MAAM,EAAE;wBACzB,OAAO,CAAC,IAAI,CAAC,CAAC;qBACf;iBACF;gBACD,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YACD,IAAI,EAAE,GAAG,CAAC,EAAE;gBACV,MAAM,CAAC,GAAG,CAAC,CAAA;YACb,CAAC;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA,CAAA"}
\ No newline at end of file
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.textRiskIdentification = exports.chattingSendCard = exports.uploadImage = exports.getImageInfo = exports.chooseImage = exports.getUserAddress = exports.openDetail = exports.checkGoodsCollectedStatus = exports.collectGoods = exports.getServerTime = exports.redirectTo = exports.navigateTo = exports.navigateToOutside = exports.checkShopFavoredStatus = exports.favorShop = exports.getSystemInfo = exports.getAuthUserInfo = exports.commonConfirm = exports.simpleAlert = exports.commonToast = void 0;
/**
* 通用toast
* @param {string} content toast内容
* @param {number} duration 显示时长
* @param {function} successCb 成功回调
*/
exports.commonToast = (content, duration = 3000, successCb) => {
export const commonToast = (content, duration = 3000, successCb) => {
return '暂不支持toast';
};
/**
* 简易alert
* @param {string} content toast内容
*/
exports.simpleAlert = content => {
export const simpleAlert = content => {
alert(content);
};
/**
* 通用确认弹窗
* @param {string} title 标题
* @param {string} content 内容
* @param {function} successCb 成功回调
*/
exports.commonConfirm = (title = '提示', content, successCb) => {
export const commonConfirm = (title = '提示', content, successCb) => {
my.confirm({
title,
content,
......@@ -46,139 +36,176 @@ exports.commonConfirm = (title = '提示', content, successCb) => {
}
});
};
/**
* 获取授权用户信息
* @returns {object} 用户登录信息
*/
exports.getAuthUserInfo = () => __awaiter(void 0, void 0, void 0, function* () {
export const getAuthUserInfo = async () => {
return {
nickName: 'nickName',
avatar: '123',
mixNick: '1234'
};
});
};
/**
* 获取系统信息
* @returns {object} 小程序系统信息
*/
exports.getSystemInfo = () => __awaiter(void 0, void 0, void 0, function* () {
export const getSystemInfo = async () => {
return {
version: '9.5.0'
};
});
};
/**
* 执行关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
exports.favorShop = (sellerId) => __awaiter(void 0, void 0, void 0, function* () {
export const favorShop = async sellerId => {
if (!sellerId) {
console.error('favorShop: 请传入卖家Id');
return false;
}
return {};
});
};
/**
* 判断是否关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
exports.checkShopFavoredStatus = (sellerId) => __awaiter(void 0, void 0, void 0, function* () {
export const checkShopFavoredStatus = async sellerId => {
if (!sellerId) {
console.error('checkShopFavoredStatus: 请传入卖家Id');
return false;
}
return true;
});
};
/**
* 跳转到外部链接
* @param {string} url 跳转链接
*/
exports.navigateToOutside = url => {
export const navigateToOutside = url => {
if (!url) {
console.error('navigateToOutside: 请传入url');
return false;
}
window.location = url;
};
/**
* 跳转到内部链接(新开窗口)
* @param {string} url 跳转链接
*/
exports.navigateTo = url => {
export const navigateTo = url => {
if (!url) {
console.error('navigateTo: 请传入url');
return false;
}
window.location = url;
};
/**
* 跳转到内部链接(不新开窗口)
* @param {string} url 跳转链接
*/
exports.redirectTo = url => {
export const redirectTo = url => {
if (!url) {
console.error('redirectTo: 请传入url');
return false;
}
window.replace(url);
};
/**
* 获取服务器时间
* @returns {number} 服务器时间戳
*/
exports.getServerTime = () => __awaiter(void 0, void 0, void 0, function* () {
export const getServerTime = async () => {
return +new Date();
});
};
/**
* 收藏商品
* @param {number} 商品id
* @returns {object} 收藏结果
*/
exports.collectGoods = (id) => __awaiter(void 0, void 0, void 0, function* () {
export const collectGoods = async id => {
if (!id) {
console.error('collectGoods: 请传入商品id');
return false;
}
return {};
});
return new Promise((resolve, reject) => {
my.tb.collectGoods({
id,
success: res => {
resolve(res);
},
fail: err => {
if (err.errorMessage === '该商品已收藏') {
// 已收藏没有给到errorCode,只能通过message判断
// 返回收藏成功,并且给到标记代表是已收藏的
resolve({ success: true, hasCollected: true, errorMessage: err.errorMessage });
} else if (err.error !== 11) {
// error code 11 为用户取消操作不认作失败场景
reject(err);
}
}
});
});
};
/**
* 查询商品收藏状态
* @param {number} 商品id
* @returns {boolean} 商品收场状态
*/
exports.checkGoodsCollectedStatus = (id) => __awaiter(void 0, void 0, void 0, function* () {
export const checkGoodsCollectedStatus = async id => {
if (!id) {
console.error('checkGoodsCollectedStatus: 请传入商品id');
return false;
}
return true;
});
return new Promise((resolve) => {
my.tb.checkGoodsCollectedStatus({
id,
success: res => {
resolve(res.isCollect);
}
});
});
};
/**
* 跳转到淘宝商品页
* @param {string} itemId 商品ID
*/
exports.openDetail = (itemId) => __awaiter(void 0, void 0, void 0, function* () {
export const openDetail = async itemId => {
if (!itemId) {
console.error('openDetail: 请传入商品id');
return false;
}
window.location = 'https://item.taobao.com/item.htm?id=' + itemId;
});
};
/**
* 获取淘宝用户收货地址
*/
exports.getUserAddress = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
export const getUserAddress = async (opts = {}) => {
return {
name: 1,
phone: 1,
address: 123
};
});
}
};
/**
* 选择图片
*/
exports.chooseImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
export const chooseImage = async (opts = {}) => {
let defaults = {
count: 1,
sourceType: ['camera', 'album'],
......@@ -213,19 +240,19 @@ exports.chooseImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function*
// error code 2001 为摄像头授权取消、ios 11为用户取消操作不认作失败场景 、安卓 为1
if (err.error !== 2001 && err.error !== 11 && err.error !== 1) {
reject(err);
}
else {
} else {
resolve(false);
}
}
});
});
});
};
/**
* 获取图片信息
* @param {string} src 图片地址
*/
exports.getImageInfo = (src) => __awaiter(void 0, void 0, void 0, function* () {
export const getImageInfo = async src => {
return new Promise((resolve, reject) => {
my.getImageInfo({
src,
......@@ -237,32 +264,33 @@ exports.getImageInfo = (src) => __awaiter(void 0, void 0, void 0, function* () {
}
});
});
});
};
/**
* 获取图片信息
* @param {*} opts chooseImage配置参数
*/
exports.uploadImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
export const uploadImage = async (opts = {}) => {
const { cloud } = getApp();
if (!cloud) {
console.error('chattingSendCard: 请传入app.cloud');
return false;
}
const chooseImageResult = yield exports.chooseImage(opts).catch(err => {
exports.commonToast(err && (err.errorMessage || '选择图片失败'));
const chooseImageResult = await chooseImage(opts).catch(err => {
commonToast(err && (err.errorMessage || '选择图片失败'));
});
if (chooseImageResult) {
const { apFilePaths } = chooseImageResult;
const filePath = apFilePaths[0];
const imageInfo = yield exports.getImageInfo(filePath).catch(err => {
exports.commonToast(err && err.errorMessage);
const imageInfo = await getImageInfo(filePath).catch(err => {
commonToast(err && err.errorMessage);
});
// 找不到图片信息
if (!imageInfo) {
return false;
}
const { path: imagePath } = imageInfo;
const { url } = yield cloud.file.uploadFile({
const { url } = await cloud.file.uploadFile({
filePath,
fileType: 'image',
fileName: imagePath.split('/').pop()
......@@ -270,21 +298,22 @@ exports.uploadImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function*
return url;
}
return false;
});
}
/**
* 分享到群聊卡片
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
exports.chattingSendCard = (requestInfo) => __awaiter(void 0, void 0, void 0, function* () {
export const chattingSendCard = async (requestInfo) => {
alert('无法模拟');
return false;
});
};
/**
* 分享到群聊卡片
* @param {*} cloud 小程序云
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
exports.textRiskIdentification = (text) => __awaiter(void 0, void 0, void 0, function* () {
export const textRiskIdentification = async (text) => {
return true;
});
//# sourceMappingURL=tbMock.js.map
\ No newline at end of file
}
\ No newline at end of file
{"version":3,"file":"tbMock.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/tbMock.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;GAKG;AACU,QAAA,WAAW,GAAG,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,EAAE,SAAS,EAAE,EAAE;IACjE,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,WAAW,GAAG,OAAO,CAAC,EAAE;IACnC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;GAKG;AACU,QAAA,aAAa,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;IAChE,EAAE,CAAC,OAAO,CAAC;QACT,KAAK;QACL,OAAO;QACP,iBAAiB,EAAE,IAAI;QACvB,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,MAAM,CAAC,EAAE;YAChB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;YAC3B,IAAI,OAAO,EAAE;gBACX,SAAS,IAAI,SAAS,EAAE,CAAC;aAC1B;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,eAAe,GAAG,GAAS,EAAE;IACxC,OAAO;QACL,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,MAAM;KAChB,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF;;;GAGG;AACU,QAAA,aAAa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,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;SACrC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAA;AAED;;;GAGG;AACU,QAAA,gBAAgB,GAAG,CAAO,WAAW,EAAE,EAAE;IACpD,KAAK,CAAC,MAAM,CAAC,CAAC;IACd,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAC;AAEF;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,CAAO,IAAI,EAAE,EAAE;IACnD,OAAO,IAAI,CAAC;AACd,CAAC,CAAA,CAAA"}
\ No newline at end of file
"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateAPI = exports.getRequestParams = exports.versionCompare = exports.dateFormatter = void 0;
const capiFn_1 = require("./capiFn");
import capiFn from './capiFn';
/**
* 时间格式化
* @param date 接收可以被new Date()方法转换的内容
* @param format 字符串,需要的格式例如:'yyyy/MM/dd hh:mm:ss'
* @returns {String}
*/
exports.dateFormatter = (date, format = 'yyyy/MM/dd') => {
if (!date)
return '-';
date = new Date(typeof date === 'string' && isNaN(date) ? date.replace(/-/g, '/') : date);
export const dateFormatter = (date, format = 'yyyy/MM/dd') => {
if (!date) return '-';
date = new Date(
typeof date === 'string' && isNaN(date) ? date.replace(/-/g, '/') : date
);
let o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
......@@ -33,70 +21,75 @@ exports.dateFormatter = (date, format = 'yyyy/MM/dd') => {
S: date.getMilliseconds()
};
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
format = format.replace(
RegExp.$1,
(date.getFullYear() + '').substr(4 - RegExp.$1.length)
);
}
for (let k in o) {
if (new RegExp('(' + k + ')').test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
format = format.replace(
RegExp.$1,
RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
);
}
}
return format;
};
/**
* 版本比较
* @param {string} cur 当前版本
* @param {string} compare 比较版本
*/
exports.versionCompare = (cur, compare) => {
export const versionCompare = (cur, compare) => {
const _cur = cur.split('.');
const _compare = compare.split('.');
if (+_cur[0] < +_compare[0]) {
return false;
}
else if (+_cur[0] === +_compare[0] && +_cur[1] < +_compare[1]) {
} else if ( +_cur[0] === +_compare[0] && +_cur[1] < +_compare[1] ) {
return false;
}
else if (+_cur[0] === +_compare[0] && +_cur[1] === +_compare[1] && +_cur[2] < +_compare[2]) {
} else if (+_cur[0] === +_compare[0] && +_cur[1] === +_compare[1] && +_cur[2] < +_compare[2]) {
return false;
}
return true;
};
/**
* 获取request请求所需参数
* @param {object/string} value API项配置
*/
exports.getRequestParams = value => {
export const getRequestParams = value => {
if (typeof value === 'string') {
return {
handle: value,
method: 'POST',
ext: {}
};
}
else if (typeof value === 'object') {
const { handle, method = 'POST' } = value, ext = __rest(value, ["handle", "method"]);
} else if (typeof value === 'object') {
const { handle, method = 'POST', ...ext } = value;
return {
handle,
method,
ext: Object.assign({}, ext)
};
ext: { ...ext }
}
else {
} else {
console.error('getRequestParams: 传参有误');
}
};
/**
* 生成API
* @param {array} apiList API数据数组
* @param {function} request 请求
*/
exports.generateAPI = (apiList, request) => {
export const generateAPI = (apiList, request) => {
const api = {};
Object.entries(apiList).forEach(([key, value]) => {
const { handle, method, ext } = exports.getRequestParams(value);
const { handle, method, ext } = getRequestParams(value);
api[key] = params => request(handle, method, params, ext);
});
api.fn = capiFn_1.default(apiList, request);
api.fn = capiFn(apiList, request);
return api;
};
\ No newline at end of file
//# sourceMappingURL=utils.js.map
\ No newline at end of file
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/utils.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qCAA8B;AAC9B;;;;;GAKG;AACU,QAAA,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,EAAE;IAC3D,IAAI,CAAC,IAAI;QAAE,OAAO,GAAG,CAAC;IAEtB,IAAI,GAAG,IAAI,IAAI,CACb,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CACzE,CAAC;IACF,IAAI,CAAC,GAAG;QACN,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;QACzB,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;QACpB,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE;QACrB,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE;QACvB,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE;QACvB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAC3C,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE;KAC1B,CAAC;IACF,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACvB,MAAM,GAAG,MAAM,CAAC,OAAO,CACrB,MAAM,CAAC,EAAE,EACT,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CACvD,CAAC;KACH;IACD,KAAK,IAAI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AE;QAC5F,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,gBAAgB,GAAG,KAAK,CAAC,EAAE;IACtC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO;YACL,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,EAAE;SACR,CAAA;KACF;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACpC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,KAAa,KAAK,EAAb,GAAG,UAAK,KAAK,EAA3C,oBAAmC,CAAQ,CAAC;QAClD,OAAO;YACL,MAAM;YACN,MAAM;YACN,GAAG,oBAAO,GAAG,CAAE;SAChB,CAAA;KACF;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;KACzC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACU,QAAA,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IAC9C,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC/C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,wBAAgB,CAAC,KAAK,CAAC,CAAC;QACxD,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,GAAG,gBAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
\ No newline at end of file
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