Commit 41b179d2 authored by wangnf's avatar wangnf

新增任务模块及tbcc-sdk-ts

parent 3373bfd2
No preview for this file type
const app = getApp();
const { tbcc, cloudName, cloud, requestType } = app;
const { tbccTs, cloudName, cloud, requestType } = app;
const { utils: { generateAPI }, request: tbccRequest, capi } = tbcc;
const { utils: { generateAPI }, request: tbccRequest, capi, capiFn } = tbccTs;
const request = tbccRequest({
cloud,
......@@ -15,12 +15,18 @@ const apiList = {
getActivityBaseInfoById: {
handle: 'getActivityBaseInfoById',
method: 'GET',
isShowLoading: true
isShowLoading: false
},
login: 'login'
login: 'login',
getTaskList: 'getTaskList',
doCompleteTask: 'doCompleteTask',
receiveTaskRewards: 'receiveTaskRewards',
addStat: 'addStat',
doHelp: 'doHelp',
};
// 生成API
const API = generateAPI(apiList, request);
API['fn'] = capiFn(apiList, request);
export default API;
import cloud from '@tbmp/mp-cloud-sdk';
import tbcc from './tbcc-sdk';
import tbccTs from './tbcc-sdk-ts';
cloud.init({
env: 'test' // 云函数环境 test 测试环境 online 线上环境
});
App({
requestType: 'yapi', // cloud: 云函数, yapi: yapi 接口, ams: ams接口,tornadoAPI: 风驰台接口
cloudName: 'CommonToC', // 主云函数项目名
requestType: 'cloud', // cloud : 云函数, yapi: yapi 接口, ams: ams接口,tornadoAPI: 风驰台接口
cloudName: 'hlnBox', // 主云函数项目名 CommonToC
tornadoAPI: 'https://tornado.duibadev.com.cn/tbServer/api?db=xxx&proxyIp=xxx', // 新增:当requestType: 'tornadoAPI'时,找服务端提供地址
cloud,
tbcc,
onLaunch(options) {
tbccTs,
async onLaunch(options) {
this.handleQuery(options.query || {});
},
onShow(options) {
async onShow(options) {
// 从后台被 scheme 重新打开
},
/**
......@@ -23,6 +23,7 @@ App({
*/
handleQuery(query) {
const { activityId } = query;
this.activityId = activityId || '5f8550a3964f97be3647a635';
this.isOnlineActivity = true// !!activityId // 性能检测不过可使用此方法(需修改活动开始时间)
this.activityId = activityId || '601b9eef9897b41ad0f26834';
}
});
......@@ -8,6 +8,12 @@
"pages/orderGoods/orderGoods",
"pages/endPage/endPage"
],
"plugins": {
"cemMember": {
"version":"*",
"provider":"3000000026642582"
}
},
"window": {
"allowsBounceVertical": "NO",
"defaultTitle": "C端模板",
......
### 注意!
assets文件夹只做本地开发测试使用
因为淘宝打包有体积限制,最大不超过1M,所以打包提审请同步图片等资源到CDN上,然后删除assets文件夹再打包提审。
\ No newline at end of file
.common-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 20;
}
.common-modal__shade {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.75);
}
.common-modal__container {
position: absolute;
width: 500rpx;
height: 300rpx;
background: #4eafd7;
background-size: 100% 100%;
left: 50%;
top: 50%;
margin-left: -250rpx;
margin-top: -150rpx;
padding: 30rpx;
}
.common-modal__bd {
font-size: 28rpx;
text-align: center;
color: #fff;
padding: 50rpx 0;
}
.common-modal__close {
position: absolute;
right: -20rpx;
top: -80rpx;
height: 86rpx;
width: 86rpx;
background: url('../../assets/modal_close_btn.png') center center no-repeat;
background-size: 48rpx 48rpx;
z-index: 9;
}
.common-modal__confirm-btn {
margin: 0 auto;
text-align: center;
width: 341rpx;
height: 77rpx;
line-height: 77rpx;
background: #FFF;
background-size: 100% 100%;
font-size: 30rpx;
color: #0077a9;
font-weight: bold;
}
<view class="common-modal">
<view class="common-modal__shade modal-animate-fade-in" />
<view class="common-modal__container modal-animate-zoom-in">
<view class="common-modal__close" onTap="onModalClose" />
<view class="common-modal__bd">
<text>{{data.content}}</text>
</view>
<view class="common-modal__ft" a:if="{{data.btnText}}">
<view onTap="onModalConfirm" class="common-modal__confirm-btn">{{data.btnText}}</view>
</view>
</view>
</view>
Component({
methods: {
onModalClose() {
const { onModalClose } = this.props;
onModalClose && onModalClose();
},
onModalConfirm () {
const { onModalConfirm } = this.props;
onModalConfirm && onModalConfirm();
}
}
});
\ No newline at end of file
.dialog-container {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 20;
}
.dialog-modal__shade {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.75);
}
.dialog-modal__container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.dialog-modal__container-bottom {
animation: bottom-up 1s linear forwards;
}
.dialog-modal__container-center {
transform: scale(0);
animation: modalAnimateZoomIn .3s forwards;
}
.dialog-modal__close {
position: absolute;
right: -20rpx;
top: -80rpx;
height: 48rpx;
width: 48rpx;
background: url('//yun.dui88.com/taobaomini/clientCTest/modal_close_btn.png') center center no-repeat;
background-size: 48rpx 48rpx;
}
@keyframes bottom-up {
from {
transform: translate(0,100vh);
}
to {
transform: translate(0,0);
}
}
@keyframes modalAnimateZoomIn {
to {
transform: scale(1);
}
}
\ No newline at end of file
<view class="dialog-container">
<view class="dialog-modal__shade modal-animate-fade-in" />
<view class="dialog-modal__container {{ 'dialog-modal__container-'+position}} ">
<slot />
</view>
</view>
\ No newline at end of file
......@@ -2,13 +2,7 @@ Component({
mixins: [],
data: {},
props: {
data: {
image: {
bg: '//yun.dui88.com/taobaomini/clientCTest/end_bg@2x.png',
end_icon: '//yun.dui88.com/taobaomini/clientCTest/end_icon@2x.png',
},
text: '活动未开始'
}
position: 'center', // bottom 底部 center 居中
},
didMount() {},
didUpdate() {},
......
.end-modal-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
min-height: 100vh;
/* background: url('//yun.dui88.com/taobaomini/clientCTest/end_bg@2x.png') no-repeat; */
background-size: 750rpx 1624rpx;
overflow: hidden;
z-index: 20;
}
.end-modal-container-content {
position: absolute;
width: 750rpx;
height: 480rpx;
top: 50%;
left: 0;
margin-top: -240rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
.end-modal-container-content__icon {
width: 478rpx;
height: 340rpx;
}
.end-modal-container-content__icon image {
width: 100%;
height: 100%;
}
.end-modal-container-content__desc {
font-size: 36rpx;
font-family: Source Han Sans CN;
font-weight: 400;
color: #ADADAD;
}
\ No newline at end of file
<view class="end-modal-container" style="{{{'background':`url(${data.image.bg}) no-repeat`}}}">
<view class="end-modal-container-content">
<view class="end-modal-container-content__icon">
<image mode="scaleToFill" src="{{data.image.end_icon}}"/>
</view>
<view class="end-modal-container-content__desc">{{data.text}}</view>
</view>
</view>
\ No newline at end of file
{
"component": true
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
.goods-modal-container__title {
width: 750rpx;
height: 120rpx;
margin: 96rpx 0 11rpx;
margin: 209rpx 0 11rpx;
}
.goods-modal-container__banner {
width: 750rpx;
......
......@@ -4,7 +4,7 @@
class="goods-modal-container__title">
</view>
<view a:else class="goods-modal-container__banner" style="{{{'background':`url(${task.image.banner}) no-repeat`,'backgroundSize': '100% 100%','height':task.bannerHeight+'rpx'}}}"></view>
<view class="goods-modal-container__content" style="{{{'top':task.type == '02'?task.bannerHeight+'rpx':'209rpx'}}}">
<view class="goods-modal-container__content" style="{{{'top':task.type == '02'?task.bannerHeight+'rpx':'280rpx'}}}">
<scroll-view scroll-y="{{true}}" class="goods-modal-container__scroll">
<view class="goods-modal-container__content-list">
<view class="goods-modal-container__content-item" a:for="{{goodsList}}" a:for-item="item">
......
......@@ -2,8 +2,8 @@
* 任务类型(taskType):collectGoods、orderGoods、browseGoods、
*/
const app = getApp();
const { tbcc } = app;
const { openDetail, collectGoods, checkGoodsCollectedStatus, commonToast } = tbcc.tb;
const { tbccTs } = app;
const { openDetail, collectGoods, checkGoodsCollectedStatus, commonToast } = tbccTs.tb;
Component({
mixins: [],
......@@ -11,7 +11,7 @@ Component({
},
props: {
isBackFlag: 0,
goodsList: [1,2,3],
goodsList: [],
task: {
itemId: '617724147979,617724563528,617300295119',
taskType: 'browseGoods',
......
const app = getApp();
const { tbcc } = app;
const { commonToast } = tbcc.tb;
const { tbccTs } = app;
const { commonToast } = tbccTs.tb;
Component({
mixins: [],
......@@ -20,7 +20,6 @@ Component({
closeModal() {
this.props.onCloseModal()
},
//复制运单号
copyCode() {
let { shipNum } = this.props.prizeItem
......
<view class="member-shop-container">
<member-shop-center
expend="{{expend}}"
sellerId="{{sellerId}}"
onClose="onClose"
onAuthFail="onAuthFail"
onAuthSuccess="onAuthSuccess" />
</view>
\ No newline at end of file
import { SELLER_ID } from '../../constants';
Component({
mixins: [],
data: {
sellerId: SELLER_ID
},
props: {
dataName: '',
expend: false,
onSuccess: () => {},
onFail: () => {},
onClose: () => {}
},
didMount() {},
didUpdate() {},
didUnmount() {},
methods: {
onClose() {
const { onClose, dataName } = this.props
onClose && onClose(dataName)
},
onAuthFail() {
const { onFail, dataName } = this.props
onFail && onFail(dataName)
},
onAuthSuccess() {
const { onSuccess, dataName } = this.props
onSuccess && onSuccess(dataName)
}
},
});
{
"component": true,
"usingComponents": {
"member-shop-center": "plugin://cemMember/member-shop-center"
}
}
\ No newline at end of file
.prize-modal__container {
position: absolute;
width: 580rpx;
height: 542rpx;
background-size: 100% 100%;
left: 50%;
top: 50%;
margin-left: calc(-580rpx / 2);
margin-top: calc(-542rpx / 2);
background-color: #eee;
background-image: url("//yun.duiba.com.cn/taobaomini/hlnBox/hln_prize_dialog_bg.png");
padding-bottom: 40rpx;
display: flex;
justify-content: space-between;
align-items: center;
flex-direction: column;
}
.prize-modal__container-has {
height: 742rpx;
margin-top: -371rpx;
}
.prize-modal__title {
text-align: center;
margin-top: 43rpx;
font-size: 48rpx;
color: #fff;
}
.prize-modal__content {
flex: 1;
}
.prize-modal__has-prize, .prize-modal__no-prize {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.prize-modal__img {
width: 250rpx;
height: 250rpx;
}
.prize-modal__name {
font-size: 24rpx;
color: #FFF8F0;
text-align: center;
margin-top: 32rpx;
}
.prize-modal__no-prize {
font-size: 32rpx;
color: #fff;
}
.prize-modal__btn {
width: 343rpx;
height: 62rpx;
background-image: url('//yun.duiba.com.cn/taobaomini/hlnBox/hln_prize_continue_full.png');
background-size: cover;
margin-bottom: 20rpx;
}
.prize-modal__btn-prize {
background-image: url('//yun.duiba.com.cn/taobaomini/hlnBox/hln-prize-continue.png');
background-size: cover
}
.prize-modal__desc {
text-align: center;
color: #fff;
font-size: 20rpx;
margin-top: 20rpx;
}
\ No newline at end of file
<dialog>
<view class="prize-modal__container {{ prize.image ? 'prize-modal__container-has': ''}}">
<view class="dialog-modal__close" onTap="onModalClose" />
<view class="prize-modal__title">
<text>{{prize.image ? '恭喜中奖' : '很遗憾\n未中奖'}}</text>
</view>
<view class="prize-modal__content">
<block a:if="{{prize.image}}">
<view class="prize-modal__has-prize">
<image class="prize-modal__img" src="{{prize.image}}" />
<view class="prize-modal__name">{{prize.name}}</view>
</view>
</block>
<block a:else>
<view class="prize-modal__no-prize">不要气馁 继续加油</view>
</block>
</view>
<view class="prize-modal__btn {{ prize.image ? 'prize-modal__btn-prize': ''}}" onTap="handleConfirm"></view>
<view class="prize-modal__desc" a:if="{{prize.image}}">权益可在【我的奖品】中查看</view>
</view>
</dialog>
<member-shop
a:if="{{memberShopVisible}}"
expend="{{memberShopVisible}}"
onSuccess="onSuccess"
onFail="closeCommonModal"
onClose="closeCommonModal" />
\ No newline at end of file
/**
* receiveType 1 点击领取关闭弹窗跳转我的奖品页面 2 点击领取直接领取奖励 3 领取跳转商品支付页面
*/
import API from '../../api';
import { SELLER_ID } from '../../constants';
const app = getApp();
const { tbccTs } = app;
const { navigateTo, openDetail, commonToast } = tbccTs.tb;
const { throttleHandle, checkMember } = tbccTs.utils;
//mock数据
const configPrize = {
receiveType: 1,// receiveType 1 点击领取关闭弹窗跳转我的奖品页面 2 点击领取直接领取奖励 3 领取跳转商品支付页面
prize: {
image: 'https://img.alicdn.com/imgextra/i3/2374579403/O1CN011TUe7Y2JKcrllQt0c_!!2374579403-0-miniprogram.jpg',
name: '测试奖品',
id: '601bb55d8e6a085deb71bf65',
itemId: 617724147979,
type: 3
}
}
Component({
mixins: [],
data: {
memberShopVisible: false
},
props: {
receiveType: configPrize.receiveType,
prize: {}
},
didMount() {},
didUpdate() {},
didUnmount() {},
methods: {
onModalClose() {
const { onModalClose, dataName } = this.props
onModalClose && onModalClose(dataName)
},
handleConfirm: throttleHandle(async function() {
const { activityId } = app
const { prize: { image, id, type, itemId }, receiveType } = this.props
// 未中奖
if(!image) {
this.onModalClose()
return;
}
// 点击领取关闭弹窗跳转我的奖品页面
if(receiveType === 1) {
this.onModalClose()
navigateTo('/pages/myprize/myprize')
return;
}
// 领取跳转商品支付页面
if(receiveType === 3) {
this.onModalClose()
openDetail(String(itemId))
return;
}
// 点击领取直接领取奖励
if(receiveType === 2) {
const params = { activityId, id }
if(type == 2) {
this.receiveCreditPrize(params)
return;
}
const success = type === 1 ? (await API.fn.receiveEnamePrize(params)) :
type === 3 ? (await API.fn.receiveObjectPrize(params)) : false
if(success) {
commonToast('领取成功')
this.onModalClose()
return;
}
this.onModalClose()
}
},2000),
// 领取积分
async receiveCreditPrize() {
const { activityId } = app
const { prize: { id }, receiveType } = this.props
// const isVip = await API.fn.getVipInfo({ activityId })
const isMember = await checkMember(SELLER_ID)
if(!isMember) {
this.setData({ memberShopVisible: true })
return;
}
const success = await API.fn.receiveEnamePrize({ activityId, id })
if(success) {
commonToast('领取成功')
this.onModalClose()
return;
}
this.onModalClose()
},
// 关闭入会组件
closeCommonModal() {
this.setData({ memberShopVisible: false })
},
// 入会成功
onSuccess() {
this.receiveCreditPrize()
this.setData({ memberShopVisible: false })
}
},
});
{
"component": true,
"usingComponents": {
"dialog": "/components/dialog/dialog",
"member-shop":"/components/memberShop/memberShop"
}
}
\ No newline at end of file
.rule-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 20;
}
.rule-modal__shade {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.75);
}
.rule-modal__container {
position: absolute;
width: 500rpx;
height: 600rpx;
background: #4eafd7;
width: 592rpx;
height: 733rpx;
background: url(//yun.dui88.com/taobaomini/clientCTest/rule_bg.png);
background-size: 100% 100%;
left: 50%;
top: 50%;
margin-left: -250rpx;
margin-top: -300rpx;
margin-left: calc(-592rpx / 2);
margin-top: calc(-733rpx / 2);
}
.rule-modal__title {
text-align: center;
margin: 30rpx;
font-size: 28rpx;
color: #fff;
}
.rule-modal__bd {
position: absolute;
top: 40rpx;
top: 140rpx;
left: 40rpx;
right: 40rpx;
bottom: 40rpx;
......@@ -39,14 +26,3 @@
color: #fff;
line-height: 1.5;
}
.rule-modal__close {
position: absolute;
right: -20rpx;
top: -80rpx;
height: 86rpx;
width: 86rpx;
background: url('../../assets/modal_close_btn.png') center center no-repeat;
background-size: 48rpx 48rpx;
z-index: 9;
}
<view class="rule-modal">
<view class="rule-modal__shade modal-animate-fade-in" />
<view class="rule-modal__container modal-animate-zoom-in">
<view class="rule-modal__close" onTap="onModalClose" />
<dialog>
<view class="rule-modal__container">
<view class="dialog-modal__close" onTap="onModalClose" />
<view class="rule-modal__bd">
<slot />
</view>
</view>
</view>
</dialog>
Component({
methods: {
onModalClose() {
const { onModalClose } = this.props;
onModalClose && onModalClose();
const { onModalClose, dataName } = this.props;
onModalClose && onModalClose(dataName);
}
}
});
\ No newline at end of file
{
"component": true
"component": true,
"usingComponents": {
"dialog": "/components/dialog/dialog"
}
}
\ No newline at end of file
.task-modal-container {
width: 100%;
height: 700rpx;
position: absolute;
bottom: 0;
left: 0;
background-color: #ffffff;
}
.task-modal__close {
right: 20rpx;
}
.task-modal-content__title {
text-align: center;
margin: 30rpx 0;
}
.task-modal-content__list {
width: 100%;
height: 600rpx;
padding: 0 16rpx;
}
.task-modal-content__scroll {
width: 100%;
height: 100%;
}
.task-modal-content-item {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
padding: 16rpx;
border: 1rpx solid #eee;
}
.task-modal-content-item__left {
width: 120rpx;
height: 120rpx;
display: flex;
justify-content: center;
align-items: center;
background-color: #eee;
}
.task-modal-content-item__left image {
width: 80rpx;
}
.task-modal-content-item__left-label {
flex: 1;
flex-direction: column;
align-items: center;
margin: 0 16rpx;
}
.task-modal-content-item__left-title {
}
.task-modal-content-item__left-reward {
margin-top: 10rpx;
}
.task-modal-content__list-item__right {
display: flex;
justify-content: center;
align-items: center;
width: 150rpx;
height: 60rpx;
background-color: #eee;
border-radius: 30rpx;
}
.task-item__status-1 {
}
.task-item__status-2 {
}
.task-item__status-3 {
}
\ No newline at end of file
<dialog position="bottom">
<view class="task-modal-container">
<view class="dialog-modal__close task-modal__close" onTap="onModalClose" />
<view class="task-modal-content">
<view class="task-modal-content__title">任务模块</view>
<view class="task-modal-content__list">
<scroll-view scroll-y="{{true}}" class="task-modal-content__scroll">
<view class="task-modal-content-item" a:for="{{taskList}}">
<view class="task-modal-content-item__left">
<image src="{{taskIcon[item.taskType]}}" mode="widthFix" />
</view>
<view class="task-modal-content-item__left-label">
<view class="task-modal-content-item__left-title">{{item.title}}</view>
<view class="task-modal-content-item__left-reward">抽盒次数+{{item.rewards}}</view>
</view>
<view class="task-modal-content__list-item__right {{'task-item__status-'+item.status}}" data-item="{{item}}" onTap="handleTapItem">
{{
item.status == 1 ? doTaskTxt[item.taskType] : commonTaskTxt[taskType]
}}
</view>
</view>
</scroll-view>
</view>
</view>
</view>
</dialog>
<member-shop
a:if="{{memberShopVisible}}"
expend="{{memberShopVisible}}"
onSuccess="onSuccess"
onFail="closeCommonModal"
onClose="closeCommonModal" />
\ No newline at end of file
import API from '../../api';
import { SELLER_ID, STAT_TYPE } from '../../constants';
const app = getApp();
const { tbccTs } = app;
const { throttleHandle } = tbccTs.utils;
const { commonToast, favorShop, navigateTo, navigateToOutside, showSharePanel } = tbccTs.tb;
const taskConfig = {
taskStatus: { // 任务状态
1: '//yun.duiba.com.cn/baicaoweiFarmer/task_btn_01.png',
2: '//yun.duiba.com.cn/baicaoweiFarmer/task_btn_02.png',
3: '//yun.duiba.com.cn/baicaoweiFarmer/task_btn_03.png'
},
taskIcon: {// 任务图标
follow: '//yun.duiba.com.cn/baicaoweiFarmer/follow.png',
member: '//yun.duiba.com.cn/baicaoweiFarmer/memberStar1.png',
invites: '//yun.duiba.com.cn/baicaoweiFarmer/invites.png',
jumpLink: '//yun.duiba.com.cn/baicaoweiFarmer/browseGoodsLink.png',
browseGoods: '//yun.duiba.com.cn/baicaoweiFarmer/browseGoods.png',
orderGoods: '//yun.duiba.com.cn/baicaoweiFarmer/orderGoods.png',
collectGoods: '//yun.duiba.com.cn/baicaoweiFarmer/orderGoods.png',
sign: '//yun.duiba.com.cn/baicaoweiFarmer/orderGoods.png',
},
commonTaskTxt: {
1: '去完成',
2: '待领取',
3: '已完成'
},
doTaskTxt: {
follow: '立即关注',
invites: '去邀请',
member: '1秒入会',
sign: '立即签到',
jumpLink: '去完成',
browseGoods: '去完成',
orderGoods: '去完成',
collectGoods: '去完成',
},
browseType: 1, // 1 跳转即算完成 2 跳转浏览15s 才算完成
browseTime: 15, // 浏览时间
}
Component({
mixins: [],
data: {
taskStatus: taskConfig.taskStatus,
taskIcon: taskConfig.taskIcon,
commonTaskTxt: taskConfig.commonTaskTxt,
doTaskTxt: taskConfig.doTaskTxt,
taskList: [
{
taskType: 'follow',
title: '关注店铺',
taskRateType: 1,
times: 1,
completeTimes: 0,
status: 1,
rewards: 1
},
{
taskType: 'member',
title: '加入会员',
taskRateType: 1,
times: 1,
completeTimes: 0,
status: 1,
rewards: 1
},
{
taskType: 'invites',
title: '邀请好友入会',
taskRateType: 1,
times: 3,
completeTimes: 0,
status: 1,
rewards: 1
},
{
taskType: 'jumpLink',
title: '浏览店铺15s',
taskRateType: 2,
times: 1,
completeTimes: 0,
status: 1,
rewards: 1
},
{
taskType: 'browseGoods',
title: '浏览商品',
taskRateType: 2,
times: 1,
completeTimes: 0,
status: 1,
rewards: 1
},
{
taskType: 'orderGoods',
title: '下单任务',
taskRateType: 2,
times: 1,
completeTimes: 0,
status: 1,
rewards: 1
},
{
taskType: 'collectGoods',
title: '收藏商品',
taskRateType: 2,
times: 1,
todayCompleteTimes: 0,
status: 1,
rewards: 1
},
{
taskType: 'sign',
title: '每日签到',
taskRateType: 2,
times: 1,
todayCompleteTimes: 0,
status: 1,
rewards: 1
}
],
memberShopVisible: false,
currentTaskType: null,
preBrowseTime: null
},
props: {
taskFlag: 1,
dataName: '',
onModalClose: () => {},
onUpdate: () => {}
},
didMount() {
this.getTaskList()
},
didUpdate(preProps,preData) {
const { taskFlag } = this.props
const { isFlashTask = false } = app
const { browseTime } = taskConfig
const { preBrowseTime, currentTaskType } = this.data
if(preProps.taskFlag !== taskFlag && isFlashTask) {
// console.log((Date.now() - preBrowseTime)/1000)
if(preBrowseTime && ((Date.now() - preBrowseTime) / 1000) >= browseTime) {
this.doCompleteTask(currentTaskType,true)
}
else {
this.getTaskList(true)
}
}
},
didUnmount() {
},
methods: {
// 关闭弹窗
onModalClose() {
const { onModalClose, dataName } = this.props;
onModalClose && onModalClose(dataName);
},
// 按钮
handleTapItem: throttleHandle(async function(e) {
const { activityId } = app
const { status, taskType, url, rewards, itemIds, keepTime } = e.target.dataset.item
if(status == 3) return;
if(status == 2) {
const { success, data } = await API.receiveTaskRewards({ activityId, taskType }).catch(res => {
commonToast(res && res.message);
}) || {};
if (success && data) {
const { rewards, receiveTimes } = data
let message = taskType == 'invites' ?
`成功邀请${receiveTimes}名好友,抽盒次数+${rewards}`:`抽盒次数+${rewards}`
commonToast(message)
this.getTaskList()
this.props.onUpdate()
}
}
else {
this.goToComplete(taskType,url,itemIds,keepTime)
}
},2000),
// 做任务
async goToComplete(taskType,url,itemIds,keepTime) {
const { activityId } = app
const { browseType } = taskConfig
switch(taskType) {
case 'member':
// 去加入会员
this.setData({ memberShopVisible: true })
break;
case 'follow':
let isFollow = await favorShop(SELLER_ID)
if(isFollow) {
this.doCompleteTask(taskType)
}
break;
case 'invites':
// 邀请好友
showSharePanel();
await API.fn.addStat(activityId, STAT_TYPE.GO_TO_INVITE)
break;
case 'jumpLink':
// 跳转任务
navigateToOutside(url || 'https://www.feizhu.com')
if(browseType === 1) {
this.doCompleteTask(taskType)
}
else {
app.isFlashTask = true
this.setData({ preBrowseTime: Date.now(), currentTaskType: taskType})
}
break;
case 'browseGoods':
// 跳转浏览页面
app.isFlashTask = true
navigateTo(`/pages/browseGoods/browseGoods?itemIds=${itemIds}&keepTime=${keepTime}`)
break;
case 'orderGoods':
// 跳转下单页面
app.isFlashTask = true
navigateTo(`/pages/orderGoods/orderGoods?itemIds=${itemIds}`)
break;
case 'collectGoods':
// 跳转收藏页面
app.isFlashTask = true
navigateTo(`/pages/collectGoods/collectGoods?itemIds=${itemIds}`)
break;
case 'sign':
// 签到
this.doCompleteTask(taskType)
break;
}
},
// 完成任务
async doCompleteTask(taskType, flag) {
const { activityId } = app
let { success, data } = await API.doCompleteTask({ activityId, taskType }) || {}
if(success) {
this.getTaskList()
flag && this.setData({ preBrowseTime: null })
}
},
// 获取任务列表
async getTaskList(flag) {
const { activityId } = app
const { success, data } = await API.getTaskList({ activityId }).catch(res => {
commonToast(res && res.message);
}) || {};
if (success && data) {
const { list } = data
app.isFlashTask = flag ? false : true
// this.setData({ taskList: list })
}
},
// 关闭入会组件
closeCommonModal() {
this.setData({ memberShopVisible: false })
},
// 入会成功
onSuccess() {
this.getTaskList()
this.setData({ memberShopVisible: false })
}
},
});
{
"component": true,
"usingComponents": {
"dialog": "/components/dialog/dialog",
"member-shop":"/components/memberShop/memberShop"
}
}
\ No newline at end of file
const { tbcc } = getApp();
const { constants: tbccConstants } = tbcc;
const { tbccTs } = getApp();
const { constants: tbccConstants } = tbccTs;
// 分享配置
export const SHARE_CONFIG = {
title: '分享测试标题',
title: '哈哈哈哈哈哈',
desc: '分享测试描述',
imageUrl: '', // 分享图片URL
path: 'pages/index/index'
......@@ -18,5 +18,14 @@ export const REDIRECT_URL = {
export const DRAW_STATUS = tbccConstants.DRAW_STATUS;
export const PRIZE_TYPE = tbccConstants.PRIZE_TYPE;
// 数据埋点
export const STAT_TYPE = {
GO_TO_INVITE: 2, // 点击邀请按钮的uv
}
export const SHARE_IMG_FILE_ID = 'cloud://09C241349017A4A1F67E4FE7AF2B3520//share_new_02.png' // 分享图片fileId
export const SELLER_ID = 2374579403 // 商家sellerId
......@@ -16,8 +16,8 @@
*/
import API from '../../api';
const app = getApp();
const { tbcc } = app;
const { commonToast } = tbcc.tb;
const { tbccTs } = app;
const { commonToast } = tbccTs.tb;
const completeType = 1 // 1 浏览完成 2 点击任意商品完成
const completeTime = 10 // 浏览时间(s)
const taskConfig = {
......@@ -35,6 +35,7 @@ const taskConfig = {
}
Page({
timer: null,
isJumpLink: false,
data: {
completeType: completeType,
usePercent: 0, // 已进行的进度条
......@@ -50,7 +51,7 @@ Page({
},
onShow() {
//重新回到页面开启倒计时
if(!this.timer && completeType == 1) {
if(!this.timer && completeType == 1 && this.isJumpLink) {
this.setData({ usePercent: this.data.percent })
this.browseGoodsTimes()
}
......@@ -58,6 +59,7 @@ Page({
onHide() {
// 页面隐藏
if (this.timer) {
this.isJumpLink = true
clearInterval(this.timer)
}
},
......@@ -72,20 +74,24 @@ Page({
const { itemIds } = this.query
const { success, data } = await API.getItemListByItemIds({ activityId, itemIds }).catch(res => {
res && commonToast(res)
res && commonToast(res.message)
}) || {}
if(success) {
this.setData({ goodsList: data.list || [] })
const { list = [] } = data
this.setData({ goodsList: list })
// 开启浏览倒计时
list.length > 0 && this.browseGoodsTimes()
}
},
//任务完成
async onCompleteTask(itemId) {
const { activityId } = app
let browsResult = await API.doBrowseGoodsTask({ activityId, itemId }).catch(res => {
res && commonToast(res)
res && commonToast(res.message)
}) || {}
if(browsResult.success) {
commonToast('浏览成功')
this.isJumpLink = false
}
},
/**
......@@ -97,6 +103,7 @@ Page({
percent: this.data.usePercent,
}, () => {
clearInterval(this.timer)
this.isJumpLink = true
})
}
else {
......@@ -111,7 +118,8 @@ Page({
this.setData({
usePercent: this.data.usePercent + 1
}, () => {
if (this.data.usePercent >= completeTime) {
const keepTime = this.query.keepTime || completeTime
if (this.data.usePercent >= keepTime) {
this.onCompleteTask()
clearInterval(this.timer)
}
......
......@@ -16,8 +16,8 @@
*/
import API from '../../api';
const app = getApp();
const { tbcc } = app;
const { commonToast } = tbcc.tb;
const { tbccTs } = app;
const { commonToast } = tbccTs.tb;
const taskConfig = {
taskType: 'collectGoods',
type: '01',
......@@ -61,7 +61,7 @@ Page({
const { activityId } = app
let { success, data } = await API.doCollectGoodsTask({ activityId, itemId }).catch(res => {
res && commonToast(res)
res && commonToast(res.message)
}) || {}
if(success) {
commonToast('收藏成功')
......
.end-modal-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
min-height: 100vh;
/* background: url('//yun.dui88.com/taobaomini/clientCTest/end_bg@2x.png') no-repeat; */
background-size: 750rpx 1624rpx;
overflow: hidden;
}
.end-modal-container-content {
position: absolute;
width: 750rpx;
height: 480rpx;
top: 50%;
left: 0;
margin-top: -240rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
.end-modal-container-content__icon {
width: 478rpx;
height: 340rpx;
}
.end-modal-container-content__icon image {
width: 100%;
height: 100%;
}
.end-modal-container-content__desc {
font-size: 36rpx;
font-family: Source Han Sans CN;
font-weight: 400;
color: #ADADAD;
}
\ No newline at end of file
<view class="end-page-container">
<end-modal data="{{endData}}" />
<view class="end-modal-container" style="{{{'background':`url(${image.bg}) no-repeat`}}}">
<view class="end-modal-container-content">
<view class="end-modal-container-content__icon">
<image mode="scaleToFill" src="{{image.end_icon}}"/>
</view>
<view class="end-modal-container-content__desc">{{text}}</view>
</view>
</view>
\ No newline at end of file
Page({
data: {
endData: {
image: {
bg: '//yun.dui88.com/taobaomini/clientCTest/end_bg@2x.png',
end_icon: '//yun.dui88.com/taobaomini/clientCTest/end_icon@2x.png',
},
text: '活动未开始'
},
onLoad(query) {
if(query.activityStatus == 2) { // activityStatus: 1 未开始 2 已结束
this.setData({ text: '活动已结束' })
}
},
onLoad() {},
});
{
"usingComponents": {
"end-modal": "/components/endModal/endModal"
}
}
\ No newline at end of file
.index-page {
min-height: 100vh;
padding-top: 200rpx;
}
.index-rule-btn, .index-myprize-btn {
......@@ -26,24 +27,6 @@
border-radius: 48rpx 0 0 48rpx;
}
.index-page__title {
font-size: 50rpx;
text-align: center;
padding: 100rpx 0 50rpx 0;
}
.index-page__content {
text-align: center;
font-size: 30rpx;
}
.index-page__tips {
padding-top: 40rpx;
text-align: center;
font-size: 22rpx;
}
.index-start-btn {
background: #0077a9;
color: #FFF;
......@@ -52,7 +35,7 @@
line-height: 80rpx;
text-align: center;
border-radius: 10rpx;
margin: 100rpx auto 50rpx auto;
margin: 0 auto 50rpx;
font-size: 30rpx;
}
......
<view class="index-page">
<view class="index-rule-btn" onTap="showRuleModal">活动规则</view>
<view class="index-rule-btn" data-dataName="ruleModalVisible" onTap="openModalHandle">活动规则</view>
<navigator open-type="navigate" url="/pages/myprize/myprize" class="index-myprize-btn">我的奖品</navigator>
<view class="index-page__title">{{title}}</view>
<view class="index-page__content">{{content}}</view>
<view class="index-page__tips">mock接口只支持PC端预览,手机淘宝预览需要使用云函数模式</view>
<view class="index-start-btn" onTap="doStart">开始</view>
<view class="index-start-btn" data-dataName="taskModalVisible" onTap="openModalHandle">任务模块</view>
<navigator open-type="navigate" url="/pages/tbccDemo/tbccDemo" class="index-tbcc-btn">tbcc demo</navigator>
<navigator style="{{{'marginTop':'16rpx'}}}" open-type="navigate" url="/pages/goodsPage/goodsPage?itemId=617724147979,617724563528" class="index-tbcc-btn">商品集合页面</navigator>
<navigator style="{{{'marginTop':'16rpx'}}}" open-type="navigate" url="/pages/browseGoods/browseGoods?itemIds=617724147979,617724563528" class="index-tbcc-btn">商品集合页面</navigator>
</view>
<!-- 规则弹窗 -->
<rule-modal
a:if="{{ruleModalVisible}}"
dataName="ruleModalVisible"
onModalClose="closeModalHandle">
<text>{{rule}}</text>
</rule-modal>
<rule-modal a:if="{{ruleModalVisible}}" onModalClose="closeRuleModal"><text>{{rule}}</text></rule-modal>
<!-- 任务弹窗 -->
<task-modal
a:if="{{taskModalVisible}}"
dataName="taskModalVisible"
onUpdate="getGameInfo"
taskFlag="{{taskFlag}}"
onModalClose="closeModalHandle" />
<common-modal a:if="{{commonModalVisible}}" data="{{commonModalData}}" onModalClose="closeCommonModal" onModalConfirm="confirmCommonModal" />
\ No newline at end of file
<!-- 中奖弹窗 -->
<prize-modal
a:if="{{prizeModalVisible}}"
dataName="prizeModalVisible"
onModalClose="closeModalHandle" />
<!-- 入会插件 -->
<member-shop
a:if="{{memberShopVisible}}"
expend="{{memberShopVisible}}"
onSuccess="onSuccess"
onFail="closeCommonModal"
onClose="closeCommonModal" />
\ No newline at end of file
import { SHARE_CONFIG, REDIRECT_URL } from '../../constants';
import { SHARE_CONFIG, REDIRECT_URL, SHARE_IMG_FILE_ID, SELLER_ID } from '../../constants';
import API from '../../api';
const app = getApp();
const { tbcc } = app;
const { commonToast, getAuthUserInfo, navigateToOutside } = tbcc.tb;
const { tbccTs } = app;
const { commonToast, getAuthUserInfo, navigateToOutside, checkShopFavoredStatus, navigateTo } = tbccTs.tb;
const { getImgShareUrl, checkMember, validateActivityStatus } = tbccTs.utils
Page({
shareImgUrl: null,
openId: null,
isDoHelpFlag: false,
data: {
title: '',
content: '',
startTime: '',
endTime: '',
rule: '',
commonModalData: {
content: '',
btnText: ''
},
commonModalConfirm: null,
commonModalVisible: false,
ruleModalVisible: false
ruleModalVisible: false,// 规则弹窗
taskModalVisible: false,// 任务弹窗
memberShopVisible: false,// 入会弹窗
prizeModalVisible: false,// 奖品弹窗
taskFlag: 1
},
onLoad(query) {
// 页面加载
this.getAuth();
app.inviteId = query.inviteId
console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
},
init() {
this.getActivityBaseInfoById();
this.getImgShareUrl()
},
onReady() {
// 页面加载完成
},
onShow() {
// 页面显示
if(app.isFlashTask) { // 任务数据更新
this.setData({ taskFlag: Math.floor(Math.random() * 1000)})
}
},
onHide() {
// 页面隐藏
......@@ -66,94 +73,120 @@ Page({
* 获取主接口
*/
async getActivityBaseInfoById() {
const { isOnlineActivity } = app
const { success, data } = await API.getActivityBaseInfoById().catch(res => {
commonToast(res && res.message);
}) || {};
if (success && data) {
const { title, content, rule } = data;
this.setData({ title, content, rule });
const { startTime, endTime, rule } = data;
this.setData({ startTime, endTime, rule });
// 性能检测使用
if(Date.now() < startTime && !isOnlineActivity) {
navigateTo(`/pages/endPage/endPage`)
}
}
},
/**
* 登录接口
*/
async login() {
const { nickName, avatar } = app;
const { success } = await API.login({
userNick: nickName, avatar, isFollow: true,entry:1
const { nickName, avatar, inviteId = undefined } = app;
const isFollow = await checkShopFavoredStatus(SELLER_ID).catch(err => {
console.log('查询关注店铺状态失败', err);
})
const { success, data } = await API.login({
userNick: nickName, avatar, isFollow: !!isFollow, inviteId
}).catch(res => {
commonToast(res && res.message);
}) || {};
console.warn(success,data)
if (success) {
const { openId } = data || {}
this.openId = openId
this.init();
}
},
/**
* 显示规则弹层
* 跳转到天猫页面
*/
showRuleModal() {
this.setData({
ruleModalVisible: true
});
goTmallPage() {
navigateToOutside(REDIRECT_URL['tmall']);
},
/**
* 通用弹出确认按钮回调
*/
confirmCommonModal() {
const { commonModalConfirm } = this.data;
commonModalConfirm && commonModalConfirm();
// 打开弹窗
async openModalHandle(e) {
const { startTime, endTime } = this.data
const key = typeof e === 'string' ? e : e.target.dataset.dataName
if(key !== 'ruleModalVisible') {
const canPass = await validateActivityStatus(startTime, endTime, true)
if(!canPass) return;
}
// 可根据key值处理相应逻辑
switch(key) {
default:
this.setData({ [key]: true })
break;
}
},
/**
* 执行开始
*/
doStart() {
this.showCommonModal({
content: '活动还未开始\n请稍后',
btnText: '我知道了',
commonModalVisible: true,
confirmCallback: () => {
this.closeCommonModal();
// 关闭弹窗
closeModalHandle(key) {
// 可根据key值处理相应逻辑
switch(key) {
default:
this.setData({ [key]: false })
break;
}
});
},
/**
* 显示通用弹层
* @param {object} options content: 通用弹层内容 btnText:按钮文案 confirmCallback: 按钮确认回调
*/
showCommonModal({ content, btnText, confirmCallback }) {
this.setData({
commonModalConfirm: confirmCallback || null,
commonModalVisible: true,
commonModalData: { content, btnText }
});
onShareAppMessage(from) {
// 返回自定义分享信息
return {
...SHARE_CONFIG,
imageUrl: this.shareImgUrl,
path: `/pages/index/index?inviteId=${this.openId}`
}
},
/**
* 跳转到天猫页面
*/
goTmallPage() {
navigateToOutside(REDIRECT_URL['tmall']);
// 任务模块-助力(逻辑:仅活动内入会才可助力成功),其他自行替换
async doHelpHandle() {
const { activityId, inviteId } = app
this.setData({ helpModalVisible: false })
// 判断是否邀请链接进来
if(!inviteId) return;
// 助力拦截 若已经助力不在调用
if(this.isDoHelpFlag) return;
// 判断是否是会员
// const isVip = await API.fn.getVipInfo({ activityId })
const isMember = await checkMember(SELLER_ID)
if(isMember) {
commonToast('只有新会员才可助力成功哦')
return;
}
this.setData({ memberShopVisible: true })
},
/**
* 关闭通用弹层
*/
async doHelp() {
const { activityId, inviteId } = app
let { success, data } = await API.doHelp({ activityId, inviteId }).catch(res => {
commonToast(res.message)
}) || {}
if(success) {
commonToast('助力成功')
this.isDoHelpFlag = true
}
},
// 关闭入会组件
closeCommonModal() {
this.setData({
commonModalVisible: false
});
this.setData({ memberShopVisible: false })
},
/**
* 关闭活动规则弹层
*/
closeRuleModal() {
this.setData({
ruleModalVisible: false
});
// 入会成功
onSuccess() {
this.setData({ memberShopVisible: false })
this.doHelp()
},
onShareAppMessage(res) {
console.log(res)
// 返回自定义分享信息
return SHARE_CONFIG;
// 获取分享图地址
async getImgShareUrl() {
this.shareImgUrl = await getImgShareUrl(SHARE_IMG_FILE_ID)
},
});
{
"usingComponents": {
"rule-modal": "/components/ruleModal/ruleModal",
"common-modal": "/components/commonModal/commonModal"
"task-modal":"/components/taskModal/taskModal",
"member-shop":"/components/memberShop/memberShop",
"prize-modal":"/components/prizeModal/prizeModal"
}
}
\ No newline at end of file
.my-prize-container {
width: 100vw;
height: 100vh;
opacity: 1;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
/* background: url('') no-repeat center top/cover; */
box-sizing: border-box;
}
.my-prize-container .my-prize-label {
width: 208rpx;
height: 36rpx;
margin: 140rpx auto 40rpx;
margin: 209rpx auto 40rpx;
background: url('//yun.dui88.com/duiba-components-c-myprizeprize_title.png') no-repeat;
background-size: 100% 100%;
background-size: contain;
}
.my-prize-content {
......
<view class="my-prize-container" style="{{{'background':`url(${prizeConfig.bg}) no-repeat center top/cover`}}}">
<view class="my-prize-label" style="{{{'background':`url(${prizeConfig.title}) no-repeat`,'backgroundSize':'100% 100%'}}}"></view>
<view class="my-prize-label" style="{{{'background':`url(${prizeConfig.title}) no-repeat`,'backgroundSize':'contain'}}}"></view>
<view class="my-prize-content" style="{{ {'top': prizeConfig.contentTop }}}">
<scroll-view scroll-y="{{true}}" class="my-prize-content__scroll">
......@@ -36,9 +36,17 @@
</scroll-view>
</view>
</view>
<!-- 物流单号 -->
<logistics-modal
a:if="{{isLogisticModal}}"
prizeItem="{{currentPrize}}"
onCloseModal="closeLogisticModal"
task="{{logisticsImage}}" />
<!-- 入会差插件 -->
<member-shop
a:if="{{memberShopVisible}}"
expend="{{memberShopVisible}}"
onSuccess="onSuccess"
onFail="closeCommonModal"
onClose="closeCommonModal" />
\ No newline at end of file
'use strict';
import API from "/api";
import { SELLER_ID } from '../../constants';
const app = getApp();
const { tbcc } = app;
const { commonToast, navigateToOutside, getUserAddress, setClipboard } = tbcc.tb;
const { dateFormatter, throttleHandle } = tbcc.utils;
const { PRIZE_TYPE, DRAW_STATUS } = tbcc.constants;
const { tbccTs } = app;
const { commonToast, navigateToOutside, getUserAddress, setClipboard } = tbccTs.tb;
const { dateFormatter, throttleHandle, checkMember } = tbccTs.utils;
const { PRIZE_TYPE, DRAW_STATUS } = tbccTs.constants;
// 我的奖品配置项
const prizeConfig = {
bg: '//yun.duiba.com.cn/aurora/assets/e13fab3165d3a6bb4cbe8827e8f0fd41084b0091.png', //背景图
......@@ -29,13 +30,14 @@ const prizeConfig = {
shipped: '//yun.dui88.com/duiba-components-c-myprizeprize_shipped.png', // 已发货物理弹窗
notShipped: '//yun.dui88.com/duiba-components-c-myprizenotshipped.png', // 待发货物流弹窗
},
btnStyle: {
btnStyle: {// 按钮宽度
width: '150rpx'
},
contentTop: '210rpx',
contentTop: '260rpx',// 列表距离头部高度
blankTxt: '暂无奖品',
hasLogistic: true, // 是否展示物流信息
isShowPirzeId: true // 是否显示奖品编号
isShowPirzeId: true, // 是否显示奖品编号
memberShopVisible: false, // 入会插件
}
Page({
data: {
......@@ -112,69 +114,19 @@ Page({
if(!(drawStatus == 6 || drawStatus == 1)) {
return;
}
// 领取权益
const prizeId = id || _id
if (type === PRIZE_TYPE.ENAME) return this.handleGetEquity(prizeId)
// 领取实物
if (type === PRIZE_TYPE.OBJECT) return this.handleGetEntity(prizeId)
if (type === PRIZE_TYPE.ENAME || type === PRIZE_TYPE.OBJECT) return this.handleGetPrize(type,prizeId)
// 领取积分
if (type === PRIZE_TYPE.CREDITS) return this.handleGetIntergation(prizeId)
},2000),
// 优惠券
async handleGetEquity(id) {
const { activityId } = app;
const { success, data, message } = await API.receiveEnamePrize({ activityId, id }).catch(res => {
this.getMyPrize()
commonToast(res && res.message)
}) || {};
if (success && data) {
commonToast('领取成功')
this.getMyPrize()
}
},
// 领取实物前询问
async handleGetEntity(id) {
// 优惠券 实物
async handleGetPrize(type,id) {
const { activityId } = app;
const userAddress = await getUserAddress().catch(err => {
commonToast(err && err.errorMessage);
});
if (!userAddress) return
const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {};
const params = {
activityId,
name,
phone: telNumber,
addressDetail: detailInfo,
cityCode,
city: cityName,
province: provinceName,
area: countyName,
streetName,
id
}
my.confirm({
title: '提示',
content: '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address,
confirmButtonText: '确定',
cancelButtonText: '取消',
success: (result) => {
console.log(result)
const { confirm } = result;
const success = type === PRIZE_TYPE.ENAME ? (await API.fn.receiveEnamePrize({ activityId, id })) :
type === PRIZE_TYPE.OBJECT ? (await API.fn.receiveObjectPrize({ activityId, id })) : false
if (confirm) {
this.receiveObjectPrize(params);
}
},
});
},
// 领取实物
async receiveObjectPrize(params) {
const { success, data } = await API.receiveObjectPrize(params).catch(res => {
commonToast(res && res.message)
}) || {}
if (success && data) {
if (success) {
commonToast('领取成功')
}
this.getMyPrize()
......@@ -182,32 +134,22 @@ Page({
// 积分
async handleGetIntergation(id) {
// 判断是否为会员
const { isVip, url } = await this.getUserInfo() || {}
if (!isVip) {
commonToast('需加入会员才能领取成功哦', 2000,() => { navigateToOutside(url) });
// const isVip = await API.fn.getVipInfo({ activityId })
const isMember = await checkMember(SELLER_ID)
if (!isMember) {
// commonToast('需加入会员才能领取成功哦', 2000,() => { navigateToOutside(url) });
commonToast('需加入会员才能领取成功哦', 2000,() => { this.setData({ memberShopVisible: true }) });
return;
}
const { activityId } = app;
const { success, data } = await API.receiveEnamePrize({ activityId, id }).catch(res => {
commonToast(res && res.message)
}) || {};
if (success && data) {
const success = await API.fn.receiveEnamePrize({ activityId, id })
if (success) {
commonToast('领取成功')
}
this.getMyPrize()
},
//获取用户vip信息
async getUserInfo() {
const { activityId } = app;
const { success, data } = await API.getVipInfo({ activityId }).catch(res => {
commonToast(res && res.message)
}) || {};
if (success && data) {
return data
}
},
// 复制编码
async handleCopyId(e) {
const { text } = e.target.dataset || {}
......@@ -220,4 +162,13 @@ Page({
closeLogisticModal() {
this.setData({ isLogisticModal: false })
},
// 关闭入会组件
closeCommonModal() {
this.setData({ memberShopVisible: false })
},
// 入会成功
onSuccess() {
this.setData({ memberShopVisible: false })
}
});
\ No newline at end of file
{
"usingComponents": {
"logistics-modal": "/components/logisticsModal/logisticsModal"
"logistics-modal": "/components/logisticsModal/logisticsModal",
"member-shop":"/components/memberShop/memberShop"
}
}
\ No newline at end of file
......@@ -16,8 +16,8 @@
*/
import API from '../../api';
const app = getApp();
const { tbcc } = app;
const { commonToast } = tbcc.tb;
const { tbccTs } = app;
const { commonToast } = tbccTs.tb;
const taskConfig = {
taskType: 'orderGoods',
type: '01',
......@@ -49,7 +49,7 @@ Page({
const { itemIds } = this.query
const { success, data } = await API.getItemListByItemIds({ activityId, itemIds }).catch(res => {
res && commonToast(res)
res && commonToast(res.message)
}) || {}
if(success) {
this.setData({ goodsList: data.list || [] })
......
......@@ -48,4 +48,16 @@
<button onTap="receiveEnamePrize">领取权益奖励</button>
<button onTap="setClipboard">复制到剪切板</button>
<button onTap="setStorage">设置缓存数据</button>
<button onTap="getStorage">获取缓存数据</button>
<button onTap="showSkuModal">显示指定商品 SKU 选择器</button>
<button onTap="confirmCustomOrder">跳转订单页</button>
<button onTap="openMessage">打开BC客服聊天</button>
</view>
import API from '../../api';
const app = getApp();
const { tbcc } = app;
const { tbccTs } = app;
const {
commonToast,
simpleAlert,
......@@ -19,10 +19,19 @@ const {
redirectTo,
uploadImage,
chattingSendCard,
textRiskIdentification
} = tbcc.tb;
textRiskIdentification,
setClipboard,
getStorage,
setStorage,
navigateToTaobaoPage,
taobaoReportClick, // 自定义分析数据的上报接口
openMessage,// 打开BC客服聊天
showSkuModal, // 显示指定商品 SKU 选择器
hideSkuModal,// 隐藏正在展示的商品 SKU 选择器
confirmCustomOrder,// 跳转订单页
} = tbccTs.tb;
const { dateFormatter, versionCompare } = tbcc.utils;
const { dateFormatter, versionCompare } = tbccTs.utils;
Page({
data: {
......@@ -243,5 +252,47 @@ Page({
if (success) {
commonToast('领取成功');
}
}
},
/**
* 复制到剪切板
*/
async setClipboard() {
await setClipboard('text')
commonToast('复制成功')
},
/**
* 获取缓存数据
*/
async getStorage() {
let text = await getStorage('test')
console.log(text)
commonToast(text)
},
/**
* 设置缓存数据
*/
async setStorage() {
await setStorage('test','test storage')
},
/**
* 跳转店铺首页 shopId
*/
async navigateToTaobaoPage() {
await navigateToTaobaoPage()
},
async showSkuModal() {
let result = await showSkuModal(String(615356100592))
console.log(result)
},
async confirmCustomOrder() {
console.log(confirmCustomOrder)
await confirmCustomOrder(615356100592, 4337070448206)
},
async openMessage() {
await openMessage()
},
});
const fns = require('./lib/index')
module.exports = fns.default
export declare const DRAW_STATUS: {
WAITAWARD: number;
PROCESSING: number;
SUCCESS: number;
FAIL: number;
EXPIRED: number;
RETRY: number;
};
export declare const PRIZE_TYPE: {
ENAME: number;
CREDITS: number;
OBJECT: number;
THANKS: number;
};
"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
};
// 奖品类型
exports.PRIZE_TYPE = {
ENAME: 1,
CREDITS: 2,
OBJECT: 3,
THANKS: 5
};
//# sourceMappingURL=constants.js.map
\ No newline at end of file
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"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
import { AudioModel } from '../helpers';
/**
* 通用toast
* @param {string} content toast内容
* @param {number} duration 显示时长
* @param {function} successCb 成功回调
*/
export declare const commonToast: (content: string, duration?: number, successCb?: () => any) => void;
/**
* 简易alert
* @param {string} content toast内容
*/
export declare const simpleAlert: (content: string) => void;
/**
* 通用确认弹窗
* @param {string} title 标题
* @param {string} content 内容
* @param {function} successCb 成功回调
*/
export declare const commonConfirm: (title: string, content: string, successCb?: () => any) => Promise<void>;
/**
* 获取系统信息
*/
export declare const getSystemInfo: () => Promise<unknown>;
/**
* 执行关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
export declare const favorShop: (sellerId: number) => Promise<false | {
error?: number;
}>;
/**
* 判断是否关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
export declare const checkShopFavoredStatus: (sellerId: number) => Promise<boolean | {
isFavor?: boolean;
}>;
/**
* 跳转到外部链接
* @param {string} url 跳转链接
*/
export declare const navigateToOutside: (url: any) => boolean;
/**
* 跳转到内部链接(新开窗口)
* @param {string} url 跳转链接
*/
export declare const navigateTo: (url: any) => boolean;
/**
* 返回页面
* @param {number} delta
*/
export declare const navigateBack: (delta?: number) => void;
/**
* 跳转到内部链接(不新开窗口)
* @param {string} url
*/
export declare const redirectTo: (url: string) => boolean;
/**
* 获取服务器时间
* @returns {number} 服务器时间戳
*/
export declare const getServerTime: () => Promise<string | {
time?: string;
}>;
/**
* 收藏商品
* @param {number} 商品id
* @returns {object} 收藏结果
*/
export declare const collectGoods: (id: number) => Promise<false | {
error?: number;
}>;
/**
* 查询商品收藏状态
* @param {number} 商品id
* @returns {boolean} 商品收场状态
*/
export declare const checkGoodsCollectedStatus: (id: number) => Promise<boolean | {
isCollect?: boolean;
}>;
/**
* 跳转到淘宝商品页
* @param {string} itemId 商品ID
*/
export declare const openDetail: (itemId: string) => Promise<unknown>;
/**
* 创建音频实例
* @param {object} opts 配置对象 例 { src: '音频链接', autoplay: false }
*/
export declare const createAudio: (opts: {
src: string;
autoplay?: boolean;
}) => AudioModel;
/**
* 获取图片信息
* @param {string} src 图片地址
*/
export declare const getImageInfo: (src: string) => Promise<unknown>;
/**
* 剪切板
* @param {text: string}
*/
export declare const setClipboard: (text: string) => Promise<unknown>;
/**
* 调起分享面板
*/
export declare const showSharePanel: () => Promise<void>;
/**
* 获取缓存数据
* @param key
*/
export declare const getStorage: (key: string) => Promise<string | {
data?: string;
}>;
/**
* 设置缓存数据
* @param key
* @param value
*/
export declare const setStorage: (key: string, value: any) => Promise<unknown>;
/**
* 清除缓存数据
* @param key
*/
export declare const removeStorage: (key: string) => Promise<unknown>;
/**
* 自定义分析数据的上报接口
* @param eventType
* @param logkey
*/
export declare const taobaoReportClick: (eventType: string, logkey: string) => void;
/**
* 打开BC客服聊天
* @param sellerNick
* @param itemId
*/
export declare const openMessage: (sellerNick: string, itemId: string) => Promise<unknown>;
/**
* 显示指定商品 SKU 选择器
* @param itemId
*/
export declare const showSkuModal: (itemId: string) => Promise<unknown>;
/**
* 隐藏正在展示的商品 SKU 选择器
*/
export declare const hideSkuModal: () => Promise<unknown>;
/**
* 跳转订单页
* @param itemId
* @param skuId
* @param quantity
*/
export declare const confirmCustomOrder: (itemId: number, skuId?: number, quantity?: number) => Promise<unknown>;
This diff is collapsed.
{"version":3,"file":"tb.js","sourceRoot":"","sources":["../../src/core/tb.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAKmB;AACnB;;;;;GAKG;AACU,QAAA,WAAW,GAAG,UAAC,OAAe,EAAE,QAAiB,EAAE,SAAqB;IACjF,4BAAkB,CAAC,WAAW,EAAC;QAC3B,OAAO,EAAE,OAAO,IAAI,WAAW;QAC/B,QAAQ,EAAE,QAAQ,IAAI,IAAI;QAC1B,OAAO,EAAE,SAAS;KACrB,CAAC,CAAA;AACN,CAAC,CAAC;AACF;;;GAGG;AACU,QAAA,WAAW,GAAG,UAAC,OAAe;IACvC,4BAAkB,CAAC,OAAO,EAAC;QACvB,OAAO,SAAA;KACV,CAAC,CAAA;AACN,CAAC,CAAC;AACF;;;;;GAKG;AACU,QAAA,aAAa,GAAG,UAAO,KAAY,EAAE,OAAe,EAAE,SAAqB;IAApD,sBAAA,EAAA,YAAY;;;YAC5C,4BAAkB,CAAC,SAAS,EAAC;gBACzB,K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ACN,CAAC,CAAC;AACF;;;;GAIG;AACU,QAAA,WAAW,GAAG,UAAO,UAAkB,EAAE,MAAc;;;;oBACnD,qBAAM,0BAAgB,CAAC,aAAa,EAAC,EAAE,UAAU,YAAA,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,QAAA,EAAE,EAAE,CAAC,EAAA;;gBAAjG,MAAM,GAAG,SAAwF;gBACrG,sBAAO,MAAM,EAAA;;;KAChB,CAAA;AACD;;;GAGG;AACU,QAAA,YAAY,GAAG,UAAO,MAAc;;;;oBAChC,qBAAM,0BAAgB,CAAC,SAAS,EAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;;gBAArD,MAAM,GAAG,SAA4C;gBACzD,sBAAO,MAAM,EAAA;;;KAChB,CAAA;AACD;;GAEG;AACU,QAAA,YAAY,GAAG;;;;oBACX,qBAAM,0BAAgB,CAAC,SAAS,EAAC,EAAE,CAAC,EAAA;;gBAA7C,MAAM,GAAG,SAAoC;gBACjD,sBAAO,MAAM,EAAA;;;KAChB,CAAA;AACD;;;;;GAKG;AACU,QAAA,kBAAkB,GAAG,UAAO,MAAc,EAAE,KAAc,EAAE,QAAiB;;;;oBACzE,qBAAM,0BAAgB,CAAC,oBAAoB,EAAC;oBACrD,IAAI,EAAE;wBACF,MAAM,QAAA;wBACN,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC;wBAClB,QAAQ,EAAE,QAAQ,IAAI,CAAC;wBACvB,aAAa,EAAE,EAAE;qBACpB;iBACJ,CAAC,EAAA;;gBAPE,MAAM,GAAG,SAOX;gBACF,sBAAO,MAAM,EAAA;;;KAChB,CAAA"}
\ No newline at end of file
/**
* 获取淘宝用户收货地址
*/
export declare const getUserAddress: (opts?: {}) => Promise<unknown>;
/**
* 选择图片
* @param opts
*/
export declare const chooseImage: (opts?: {}) => Promise<unknown>;
/**
* 获取图片信息
* @param {*} opts chooseImage配置参数
*/
export declare const uploadImage: (opts?: {}) => Promise<any>;
/**
* 获取授权用户信息
* @returns {object} 用户登录信息
*/
export declare const getAuthUserInfo: () => Promise<unknown>;
/**
* 获取用户会员状态(Tmall使用)
*/
export declare const getUserStatus: () => Promise<unknown>;
/**
* 拉菲奖品发放(Tmall使用)
* @param params
*/
export declare const cloudTBIssue: (params: {
channel: string;
strategyCode: string;
code: string;
}) => Promise<unknown>;
/**
* 分享到群聊卡片
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
export declare const chattingSendCard: (requestInfo: IRequestInfo) => Promise<unknown>;
/**
* 文本风险校验
* @param {string} text 文本
*/
export declare const textRiskIdentification: (text: string) => Promise<unknown>;
/**
* 跳转店铺首页
* @param {string} shopId
*/
export declare const navigateToTaobaoPage: (shopId: string) => Promise<unknown>;
This diff is collapsed.
{"version":3,"file":"tbFn.js","sourceRoot":"","sources":["../../src/core/tbFn.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAImB;AACnB;;GAEG;AACU,QAAA,cAAc,GAAG,UAAO,IAAS;IAAT,qBAAA,EAAA,SAAS;;;;YACtC,QAAQ,GAAG;gBACb,UAAU,EAAE,MAAM;gBAClB,aAAa,EAAE,MAAM;gBACrB,aAAa,EAAE,MAAM;gBACrB,OAAO,EAAE,EAAE,CAAC,wBAAwB;aACrC,CAAC;YACE,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC9C,sBAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;oBAC/B,aAAa;oBACb,EAAE,CAAC,SAAS,CAAC;wBACb,MAAM,EAAE,mBAAmB;wBAC3B,OAAO,EAAE;4BACC,IAAA,UAAU,GAA4C,KAAK,WAAjD,EAAE,aAAa,GAA6B,KAAK,cAAlC,EAAE,aAAa,GAAc,KAAK,cAAnB,EAAE,OAAO,GAAK,KAAK,QAAV,CAAW;4BACpE,aAAa;4BACb,IAAI,C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AAM,CAAC;gBACtB,WAAW,EAAC,cAAc;gBAC1B,cAAc,EAAC,WAAW;aAC1B;YACD,OAAO,EAAE,UAAC,GAAG;gBACZ,OAAO,CAAC,IAAI,CAAC,CAAA;YACd,CAAC;YACD,IAAI,EAAE,UAAC,GAAG;gBACT,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YAClB,CAAC;SACD,CAAC,CAAC;IACJ,CAAC,CAAC,CAAA;AACH,CAAC,CAAA"}
\ No newline at end of file
/**
* 通用toast
* @param {string} content toast内容
* @param {number} duration 显示时长
* @param {function} successCb 成功回调
*/
export declare const commonToast: (content: any, duration: number, successCb: any) => string;
/**
* 简易alert
* @param {string} content toast内容
*/
export declare const simpleAlert: (content: any) => void;
/**
* 获取授权用户信息
* @returns {object} 用户登录信息
*/
export declare const getAuthUserInfo: () => Promise<{
nickName: string;
avatar: string;
mixNick: string;
}>;
/**
* 获取系统信息
* @returns {object} 小程序系统信息
*/
export declare const getSystemInfo: () => Promise<{
version: string;
}>;
/**
* 执行关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
export declare const favorShop: (sellerId: any) => Promise<boolean>;
/**
* 判断是否关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
export declare const checkShopFavoredStatus: (sellerId: any) => Promise<boolean>;
/**
* 跳转到外部链接
* @param {string} url 跳转链接
*/
export declare const navigateToOutside: (url: any) => boolean;
/**
* 跳转到内部链接(新开窗口)
* @param {string} url 跳转链接
*/
export declare const navigateTo: (url: any) => boolean;
/**
* 跳转到内部链接(不新开窗口)
* @param {string} url 跳转链接
*/
export declare const redirectTo: (url: any) => boolean;
/**
* 获取服务器时间
* @returns {number} 服务器时间戳
*/
export declare const getServerTime: () => Promise<number>;
/**
* 收藏商品
* @param {number} 商品id
* @returns {object} 收藏结果
*/
export declare const collectGoods: (id: any) => Promise<boolean>;
/**
* 查询商品收藏状态
* @param {number} 商品id
* @returns {boolean} 商品收场状态
*/
export declare const checkGoodsCollectedStatus: (id: any) => Promise<boolean>;
/**
* 跳转到淘宝商品页
* @param {string} itemId 商品ID
*/
export declare const openDetail: (itemId: any) => Promise<boolean>;
/**
* 获取淘宝用户收货地址
*/
export declare const getUserAddress: (opts?: {}) => Promise<{
name: number;
phone: number;
address: number;
}>;
/**
* 分享到群聊卡片
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
export declare const chattingSendCard: (requestInfo: any) => Promise<boolean>;
/**
* 分享到群聊卡片
* @param {*} cloud 小程序云
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
export declare const textRiskIdentification: (text: any) => Promise<boolean>;
"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());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.textRiskIdentification = exports.chattingSendCard = 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.simpleAlert = exports.commonToast = void 0;
/**
* 通用toast
* @param {string} content toast内容
* @param {number} duration 显示时长
* @param {function} successCb 成功回调
*/
exports.commonToast = function (content, duration, successCb) {
if (duration === void 0) { duration = 3000; }
return '暂不支持toast';
};
/**
* 简易alert
* @param {string} content toast内容
*/
exports.simpleAlert = function (content) {
alert(content);
};
/**
* 获取授权用户信息
* @returns {object} 用户登录信息
*/
exports.getAuthUserInfo = function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, {
nickName: 'nickName',
avatar: '123',
mixNick: '1234'
}];
});
}); };
/**
* 获取系统信息
* @returns {object} 小程序系统信息
*/
exports.getSystemInfo = function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, {
version: '9.5.0'
}];
});
}); };
/**
* 执行关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
exports.favorShop = function (sellerId) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!sellerId) {
console.error('favorShop: 请传入卖家Id');
return [2 /*return*/, false];
}
return [2 /*return*/, true];
});
}); };
/**
* 判断是否关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
exports.checkShopFavoredStatus = function (sellerId) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!sellerId) {
console.error('checkShopFavoredStatus: 请传入卖家Id');
return [2 /*return*/, false];
}
return [2 /*return*/, true];
});
}); };
/**
* 跳转到外部链接
* @param {string} url 跳转链接
*/
exports.navigateToOutside = function (url) {
if (!url) {
console.error('navigateToOutside: 请传入url');
return false;
}
window.location = url;
};
/**
* 跳转到内部链接(新开窗口)
* @param {string} url 跳转链接
*/
exports.navigateTo = function (url) {
if (!url) {
console.error('navigateTo: 请传入url');
return false;
}
window.location = url;
};
/**
* 跳转到内部链接(不新开窗口)
* @param {string} url 跳转链接
*/
exports.redirectTo = function (url) {
if (!url) {
console.error('redirectTo: 请传入url');
return false;
}
// @ts-ignore
window.replace(url);
};
/**
* 获取服务器时间
* @returns {number} 服务器时间戳
*/
exports.getServerTime = function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, +new Date()];
});
}); };
/**
* 收藏商品
* @param {number} 商品id
* @returns {object} 收藏结果
*/
exports.collectGoods = function (id) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!id) {
console.error('collectGoods: 请传入商品id');
return [2 /*return*/, false];
}
return [2 /*return*/, true];
});
}); };
/**
* 查询商品收藏状态
* @param {number} 商品id
* @returns {boolean} 商品收场状态
*/
exports.checkGoodsCollectedStatus = function (id) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!id) {
console.error('checkGoodsCollectedStatus: 请传入商品id');
return [2 /*return*/, false];
}
return [2 /*return*/, true];
});
}); };
/**
* 跳转到淘宝商品页
* @param {string} itemId 商品ID
*/
exports.openDetail = function (itemId) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!itemId) {
console.error('openDetail: 请传入商品id');
return [2 /*return*/, false];
}
// @ts-ignore
window.location = 'https://item.taobao.com/item.htm?id=' + itemId;
return [2 /*return*/];
});
}); };
/**
* 获取淘宝用户收货地址
*/
exports.getUserAddress = function (opts) {
if (opts === void 0) { opts = {}; }
return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, {
name: 1,
phone: 1,
address: 123
}];
});
});
};
/**
* 分享到群聊卡片
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
exports.chattingSendCard = function (requestInfo) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
alert('无法模拟');
return [2 /*return*/, false];
});
}); };
/**
* 分享到群聊卡片
* @param {*} cloud 小程序云
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
exports.textRiskIdentification = function (text) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, true];
});
}); };
//# sourceMappingURL=tbMock.js.map
\ No newline at end of file
{"version":3,"file":"tbMock.js","sourceRoot":"","sources":["../../src/core/tbMock.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACU,QAAA,WAAW,GAAG,UAAC,OAAO,EAAE,QAAe,EAAE,SAAS;IAA1B,yBAAA,EAAA,eAAe;IAChD,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC;AACF;;;GAGG;AACU,QAAA,WAAW,GAAG,UAAA,OAAO;IAC9B,KAAK,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC,CAAC;AACF;;;GAGG;AACU,QAAA,eAAe,GAAG;;QAC3B,sBAAO;gBACH,QAAQ,EAAE,UAAU;gBACpB,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,MAAM;aAClB,EAAC;;KACL,CAAC;AAEF;;;GAGG;AACU,QAAA,aAAa,GAAG;;QACzB,sBAAO;gBACH,O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QAAA,YAAY,GAAG,UAAM,EAAE;;QAChC,IAAI,CAAC,EAAE,EAAE;YACL,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACvC,sBAAO,KAAK,EAAC;SAChB;QACD,sBAAO,IAAI,EAAC;;KACf,CAAC;AACF;;;;GAIG;AACU,QAAA,yBAAyB,GAAG,UAAM,EAAE;;QAC7C,IAAI,CAAC,EAAE,EAAE;YACL,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACpD,sBAAO,KAAK,EAAC;SAChB;QACD,sBAAO,IAAI,EAAC;;KACf,CAAC;AACF;;;GAGG;AACU,QAAA,UAAU,GAAG,UAAM,MAAM;;QAClC,IAAI,CAAC,MAAM,EAAE;YACT,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACrC,sBAAO,KAAK,EAAC;SAChB;QACD,aAAa;QACb,MAAM,CAAC,QAAQ,GAAG,sCAAsC,GAAG,MAAM,CAAC;;;KACrE,CAAC;AACF;;GAEG;AACU,QAAA,cAAc,GAAG,UAAO,IAAS;IAAT,qBAAA,EAAA,SAAS;;;YAC1C,sBAAO;oBACH,IAAI,EAAE,CAAC;oBACP,KAAK,EAAE,CAAC;oBACR,OAAO,EAAE,GAAG;iBACf,EAAA;;;CACJ,CAAC;AACF;;;GAGG;AACU,QAAA,gBAAgB,GAAG,UAAO,WAAW;;QAC9C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,sBAAO,KAAK,EAAC;;KAChB,CAAC;AACF;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,UAAO,IAAI;;QAC7C,sBAAO,IAAI,EAAC;;KACf,CAAA"}
\ No newline at end of file
/**
* 简易API封装
* @param methodName
* @param params
* @param name
*/
export declare const promisifyApiSimple: (methodName: string, params: IParamJSAPI, name?: string) => void;
/**
* 通用API封装
* @param methodName
* @param params
*/
export declare const promisifyApi: (methodName: string, params?: {}) => Promise<unknown>;
/**
* 通用API封装
* @param methodName
* @param params
*/
export declare const promisifyApiToTb: (methodName: string, params?: {}) => Promise<unknown>;
/**
* 创建音频类
*/
export declare class AudioModel {
constructor(opts: {
src: string;
});
}
/**
* 获取天猫会员状态
*/
export declare const getTmallMemberStatus: () => Promise<any>;
/**
* 拉菲奖品发放
* @param params
*/
export declare const strategyEname: (params: {
channel: string;
strategyCode: string;
code: string;
}) => Promise<any>;
/**
* loading
* @param methodName
* @param params
* @param name
*/
export declare const isLoading: (methodName: string) => void;
/**
* 数据请求
* @param params
* @param loading
*/
export declare const myRequest: (params: any, loading: boolean) => Promise<unknown>;
/**
* 云函数接口请求
* @param _cloudName
* @param handle
* @param params
* @param loading
*/
export declare const cloudRequest: (cloud: any, _cloudName: string, handle: string, params: any, loading: boolean) => Promise<unknown>;
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
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());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloudRequest = exports.myRequest = exports.isLoading = exports.strategyEname = exports.getTmallMemberStatus = exports.AudioModel = exports.promisifyApiToTb = exports.promisifyApi = exports.promisifyApiSimple = void 0;
/**
* 简易API封装
* @param methodName
* @param params
* @param name
*/
exports.promisifyApiSimple = function (methodName, params, name) {
if (name) {
// @ts-ignore
my[methodName](name, params);
return;
}
// @ts-ignore
my[methodName](params);
};
/**
* 通用API封装
* @param methodName
* @param params
*/
exports.promisifyApi = function (methodName, params) {
if (params === void 0) { params = {}; }
return new Promise(function (resolve, reject) {
// @ts-ignore
my[methodName](__assign(__assign({}, params), { success: function (res) {
resolve(res);
}, fail: function (err) {
reject(err);
} }));
});
};
/**
* 通用API封装
* @param methodName
* @param params
*/
exports.promisifyApiToTb = function (methodName, params) {
if (params === void 0) { params = {}; }
return new Promise(function (resolve, reject) {
// @ts-ignore
my.tb[methodName](__assign(__assign({}, params), { success: function (res) {
resolve(res);
}, fail: function (err) {
reject(err);
} }));
});
};
/**
* 创建音频类
*/
var AudioModel = /** @class */ (function () {
function AudioModel(opts) {
var src = opts.src;
if (!src) {
console.error('请输入音频链接');
return false;
}
try {
// @ts-ignore
var innerAudioContext_1 = my.createInnerAudioContext();
Object.keys(opts).forEach(function (item) {
innerAudioContext_1[item] = opts[item];
});
return innerAudioContext_1;
}
catch (e) {
console.error('当前版本不支持音频');
}
}
return AudioModel;
}());
exports.AudioModel = AudioModel;
/**
* 获取天猫会员状态
*/
exports.getTmallMemberStatus = function () { return __awaiter(void 0, void 0, void 0, function () {
var cloud;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cloud = app.cloud;
return [4 /*yield*/, cloud.topApi.invoke({
api: "tmall.campus.industry.app.audit.query",
data: {
source: "duibajk",
},
}).catch(function (err) {
console.log(err);
})];
case 1: return [2 /*return*/, (_a.sent()) || {}];
}
});
}); };
/**
* 拉菲奖品发放
* @param params
*/
exports.strategyEname = function (params) { return __awaiter(void 0, void 0, void 0, function () {
var cloud;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cloud = app.cloud;
return [4 /*yield*/, cloud.topApi.invoke({
api: "alibaba.latour.strategy.issue",
data: {
channel: params.channel || "",
strategy_code: params.strategyCode || "",
selected_benefit_code: params.code || "",
},
}).catch(function (err) {
console.log("err", err);
})];
case 1: return [2 /*return*/, (_a.sent()) || {}];
}
});
}); };
/**
* loading
* @param methodName
* @param params
* @param name
*/
exports.isLoading = function (methodName) {
// @ts-ignore
my[methodName]();
};
/**
* 数据请求
* @param params
* @param loading
*/
exports.myRequest = function (params, loading) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) {
// @ts-ignore
my.request(params).then(function (_a) {
var res = _a.data;
console.log("\u8C03\u7528mock\u63A5\u53E3\u8FD4\u56DE\u7ED3\u679C", res);
loading && exports.isLoading('hideLoading');
if (res && res.success) {
resolve(res);
}
else {
reject(res);
}
}).catch(function (e) {
loading && exports.isLoading('hideLoading');
console.log(e);
reject();
});
})];
});
}); };
/**
* 云函数接口请求
* @param _cloudName
* @param handle
* @param params
* @param loading
*/
exports.cloudRequest = function (cloud, _cloudName, handle, params, loading) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) {
// @ts-ignore
cloud.function.invoke(_cloudName, params, handle).then(function (res) {
console.log("\u8C03\u7528" + handle + "\u63A5\u53E3\u8FD4\u56DE\u7ED3\u679C", res);
loading && exports.isLoading('hideLoading');
if (res && res.success) {
resolve(res);
}
else {
reject(res);
}
return res;
}).catch(function () {
loading && exports.isLoading('hideLoading');
reject();
});
})];
});
}); };
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACU,QAAA,kBAAkB,GAAG,UAAC,UAAkB,EAAE,MAAmB,EAAE,IAAa;IACrF,IAAG,IAAI,EAAE;QACL,aAAa;QACb,EAAE,CAAC,UAAU,CAAC,CAAC,IAAI,EAAC,MAAM,CAAC,CAAC;QAC5B,OAAO;KACV;IACD,aAAa;IACb,EAAE,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAA;AACD;;;;GAIG;AACU,QAAA,YAAY,GAAI,UAAC,UAAkB,EAAE,MAAW;IAAX,uBAAA,EAAA,WAAW;IAC5D,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QAC5B,aAAa;QACnB,EAAE,CAAC,UAAU,CAAC,uBACV,MAAM,KACT,OAAO,EAAE,UAAA,GAAG;gBACX,OAAO,CAAC,GAAG,CAAC,CAAA;YACb,CAAC,EACD,IAAI,EAAE,UAAA,GAAG;gBACR,MAAM,CAAC,GAAG,CAAC,CAAA;YACZ,CAAC,IACA,CAAA;IACH,CAAC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I,GAAG,CAAC,OAAO,EAAE;wBACtB,OAAO,CAAC,GAAG,CAAC,CAAC;qBACd;yBAAM;wBACL,MAAM,CAAC,GAAG,CAAC,CAAC;qBACb;gBACH,CAAC,CAAC,CAAC,KAAK,CAAC,UAAC,CAAC;oBACT,OAAO,IAAI,iBAAS,CAAC,aAAa,CAAC,CAAA;oBACnC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;oBACd,MAAM,EAAE,CAAC;gBACX,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,EAAA;;KACH,CAAA;AACD;;;;;;GAMG;AACU,QAAA,YAAY,GAAG,UAAO,KAAU,EAAE,UAAiB,EAAE,MAAc,EAAE,MAAW,EAAE,OAAgB;;QAC7G,sBAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;gBACjC,aAAa;gBACb,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG;oBACxD,OAAO,CAAC,GAAG,CAAC,iBAAK,MAAM,yCAAQ,EAAE,GAAG,CAAC,CAAA;oBACrC,OAAO,IAAI,iBAAS,CAAC,aAAa,CAAC,CAAA;oBACnC,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;oBACP,OAAO,IAAI,iBAAS,CAAC,aAAa,CAAC,CAAA;oBACnC,MAAM,EAAE,CAAC;gBACX,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,EAAC;;KACJ,CAAA"}
\ No newline at end of file
/**
* 加密
* @param data
*/
export declare const md5: (data: any) => any;
/**
* my.request请求接口
* @param params
* @param res
* @param loading
* @param tornadoAPI
*/
export declare const tornadoAPICb: (params: any, res: any, loading: boolean, tornadoAPI: string) => Promise<unknown>;
/**
* 请求风池台接口数据
* @param tornadoAPI
* @param nickName
* @param handle
* @param loading
* @param params
*/
export declare const tornadoAPIFn: (tornadoAPI: string, nickName: string, handle: string, loading: boolean, params: any) => Promise<unknown>;
/**
* 请求mock数据
* @param reqConfig
* @param initConfig
* @param params
*/
export declare const requestMock: (reqConfig: IReqConfig, initConfig: IInitConfig, params: any) => Promise<unknown>;
"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());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.requestMock = exports.tornadoAPIFn = exports.tornadoAPICb = exports.md5 = void 0;
var tbFn_1 = require("../core/tbFn");
var tb_1 = require("../core/tb");
var index_1 = require("./index");
var Buffer = require("buffer").Buffer;
var crypto = require("crypto");
/**
* 加密
* @param data
*/
exports.md5 = function (data) {
var buf = new Buffer(data);
var str = buf.toString("binary");
return crypto.createHash("md5").update(str).digest("hex").slice(0, 30);
};
/**
* my.request请求接口
* @param params
* @param res
* @param loading
* @param tornadoAPI
*/
exports.tornadoAPICb = function (params, res, loading, tornadoAPI) { return __awaiter(void 0, void 0, void 0, function () {
var nickName, params_;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
nickName = res.nickName;
params.openId = exports.md5(nickName);
params_ = {
url: tornadoAPI,
method: 'post',
data: params,
dataType: 'json'
};
return [4 /*yield*/, index_1.myRequest(params_, loading)];
case 1: return [2 /*return*/, _a.sent()];
}
});
}); };
/**
* 请求风池台接口数据
* @param tornadoAPI
* @param nickName
* @param handle
* @param loading
* @param params
*/
exports.tornadoAPIFn = function (tornadoAPI, nickName, handle, loading, params) { return __awaiter(void 0, void 0, void 0, function () {
var matchRes, db, proxyIp, data_, params_;
return __generator(this, function (_a) {
matchRes = tornadoAPI.match(/db=(\w*)&proxyIp=([\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3})/);
db = matchRes[1];
proxyIp = matchRes[2];
data_ = {
handler: handle,
data: params
};
console.log("data_", data_);
params_ = {
db: db,
proxyIp: proxyIp,
data: data_
};
if (!db || !proxyIp) {
tb_1.commonConfirm('风驰台地址错误', '请确认风驰台的地址是否正确,未查找到db和proxyIp');
return [2 /*return*/, false];
}
// nickName 转 md5 作为唯一的openId
if (!nickName) {
return [2 /*return*/, tbFn_1.getAuthUserInfo().catch(function (err) {
console.log('未授权成功', err);
}).then(function (res) {
return exports.tornadoAPICb(params_, res, loading, tornadoAPI);
})];
}
return [2 /*return*/];
});
}); };
/**
* 请求mock数据
* @param reqConfig
* @param initConfig
* @param params
*/
exports.requestMock = function (reqConfig, initConfig, params) { return __awaiter(void 0, void 0, void 0, function () {
var cloudName, handle, method, isShowLoading, requestType, tornadoAPI, nickName, mockUrlPrefix, mockUrl, requestPrefix, params_;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cloudName = reqConfig.cloudName, handle = reqConfig.handle, method = reqConfig.method, isShowLoading = reqConfig.isShowLoading;
requestType = initConfig.requestType, tornadoAPI = initConfig.tornadoAPI, nickName = initConfig.nickName, mockUrlPrefix = initConfig.mockUrlPrefix, mockUrl = initConfig.mockUrl;
if (!(requestType === 'tornadoAPI')) return [3 /*break*/, 2];
return [4 /*yield*/, exports.tornadoAPIFn(tornadoAPI, nickName, handle, isShowLoading, params)];
case 1: return [2 /*return*/, _a.sent()];
case 2:
requestPrefix = mockUrl || mockUrlPrefix[requestType];
params_ = {
url: requestPrefix + cloudName + '.' + handle,
method: 'get',
data: params,
dataType: 'json'
};
return [4 /*yield*/, index_1.myRequest(params_, isShowLoading)];
case 3: return [2 /*return*/, _a.sent()];
}
});
}); };
//# sourceMappingURL=requestFn.js.map
\ No newline at end of file
{"version":3,"file":"requestFn.js","sourceRoot":"","sources":["../../src/helpers/requestFn.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA+C;AAC/C,iCAA0C;AAC1C,iCAAmC;AACnC,IAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;AACvC,IAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,C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C,MAAM,EAAE,KAAK;oBACb,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,MAAM;iBACnB,CAAA;gBACM,qBAAM,iBAAS,CAAC,OAAO,EAAE,aAAa,CAAC,EAAA;oBAA9C,sBAAO,SAAuC,EAAA;;;KACjD,CAAA"}
\ No newline at end of file
import * as utils from './utils';
import * as constants from './constants';
declare const _default: {
capi: {
getMyPrizeList: {
method: string;
handle: string;
isShowLoading: boolean;
};
receiveObjectPrize: {
method: string;
handle: string;
};
receiveEnamePrize: {
method: string;
handle: string;
};
getItemListByItemIds: {
method: string;
handle: string;
};
getCollectGoodsList: {
method: string;
handle: string;
};
doCollectGoodsTask: {
method: string;
handle: string;
defaultParams: {
taskType: string;
};
};
doBrowseGoodsTask: {
method: string;
handle: string;
defaultParams: {
taskType: string;
};
};
doJumpLinkTask: {
method: string;
handle: string;
defaultParams: {
taskType: string;
};
};
doExchangeCreditsTask: {
method: string;
handle: string;
defaultParams: {
taskType: string;
};
};
getVipInfo: {
method: string;
handle: string;
};
};
capiFn: (apiList: any, request: any) => {
receiveObjectPrize(params: any): Promise<boolean>;
getVipInfo(params: any): Promise<any>;
receiveEnamePrize(params: any): Promise<boolean>;
addStat(activityId: string, type: string | number): Promise<boolean>;
};
tb: {};
utils: typeof utils;
request: (header: IRequest) => false | ((handle: any, method: string, params: any, ext?: {
cloudName?: string;
isShowLoading?: boolean;
}) => Promise<unknown>);
constants: typeof constants;
};
export default _default;
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var tb = require("./core/tb");
var tbFn = require("./core/tbFn");
var tbMock = require("./core/tbMock");
var utils = require("./utils");
var constants = require("./constants");
var capi_1 = require("./request/capi");
var capiFn_1 = require("./request/capiFn");
var request_1 = require("./request");
var isH5 = 'undefined' !== typeof window;
// 如果为h5环境走mock数据
var _tb = {};
Object.entries(__assign(__assign({}, tb), tbFn)).forEach(function (_a) {
var key = _a[0], value = _a[1];
_tb[key] = isH5 ? tbMock[key] : value;
});
exports.default = {
capi: capi_1.default,
capiFn: capiFn_1.default,
tb: _tb,
utils: utils,
request: request_1.default,
constants: constants
};
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,8BAAgC;AAChC,kCAAoC;AACpC,sCAAwC;AACxC,+BAAiC;AACjC,uCAAyC;AACzC,uCAAkC;AAClC,2CAAsC;AACtC,qCAAgC;AAChC,IAAM,IAAI,GAAG,WAAW,KAAK,OAAO,MAAM,CAAC;AAE3C,iBAAiB;AACjB,IAAI,GAAG,GAAG,EAAE,CAAC;AACb,MAAM,CAAC,OAAO,uBAAM,EAAE,GAAK,IAAI,EAAG,CAAC,OAAO,CAAC,UAAC,EAAY;QAAX,GAAG,QAAA,EAAE,KAAK,QAAA;IACrD,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACxC,CAAC,CAAC,CAAC;AACH,kBAAe;IACb,IAAI,gBAAA;IACJ,MAAM,kBAAA;IACN,EAAE,EAAE,GAAG;IACP,KAAK,OAAA;IACL,OAAO,mBAAA;IACP,SAAS,WAAA;CACV,CAAA"}
\ No newline at end of file
declare const capi: {
getMyPrizeList: {
method: string;
handle: string;
isShowLoading: boolean;
};
receiveObjectPrize: {
method: string;
handle: string;
};
receiveEnamePrize: {
method: string;
handle: string;
};
getItemListByItemIds: {
method: string;
handle: string;
};
getCollectGoodsList: {
method: string;
handle: string;
};
doCollectGoodsTask: {
method: string;
handle: string;
defaultParams: {
taskType: string;
};
};
doBrowseGoodsTask: {
method: string;
handle: string;
defaultParams: {
taskType: string;
};
};
doJumpLinkTask: {
method: string;
handle: string;
defaultParams: {
taskType: string;
};
};
doExchangeCreditsTask: {
method: string;
handle: string;
defaultParams: {
taskType: string;
};
};
getVipInfo: {
method: string;
handle: string;
};
};
export default capi;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var capi = {
getMyPrizeList: {
method: 'GET',
handle: 'getMyPrizeList',
isShowLoading: true
},
receiveObjectPrize: { method: 'GET', handle: 'receiveObjectPrize' },
receiveEnamePrize: { method: 'GET', handle: 'receiveEnamePrize' },
getItemListByItemIds: { method: 'GET', handle: 'getItemListByItemIds' },
getCollectGoodsList: { method: 'GET', handle: 'getCollectGoodsList' },
doCollectGoodsTask: { method: 'GET', handle: 'doCompleteTask', defaultParams: { taskType: 'collectGoods' } },
doBrowseGoodsTask: { method: 'GET', handle: 'doCompleteTask', defaultParams: { taskType: 'browseGoods' } },
doJumpLinkTask: { method: 'GET', handle: 'doCompleteTask', defaultParams: { taskType: 'jumpLink' } },
doExchangeCreditsTask: { method: 'GET', handle: 'doCompleteTask', defaultParams: { taskType: 'exchangeCredits' } },
getVipInfo: { method: 'GET', handle: 'getVipInfo' }
};
exports.default = capi;
//# sourceMappingURL=capi.js.map
\ No newline at end of file
{"version":3,"file":"capi.js","sourceRoot":"","sources":["../../src/request/capi.ts"],"names":[],"mappings":";;AAAA,IAAM,IAAI,GAAG;IACT,cAAc,EAAE;QACd,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,gBAAgB;QACxB,aAAa,EAAE,IAAI;KACpB;IACD,kBAAkB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE;IACnE,iBAAiB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE;IACjE,oBAAoB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE;IACvE,mBAAmB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE;IACrE,kBAAkB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAC,EAAE;IAC3G,iBAAiB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAC,EAAE;IACzG,cAAc,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAC,EAAE;IACnG,qBAAqB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAC,EAAE;IACjH,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE;CACpD,CAAC;AAEF,kBAAe,IAAI,CAAC"}
\ No newline at end of file
declare const capiFn: (apiList: any, request: any) => {
receiveObjectPrize(params: any): Promise<boolean>;
getVipInfo(params: any): Promise<any>;
receiveEnamePrize(params: any): Promise<boolean>;
addStat(activityId: string, type: number | string): Promise<boolean>;
};
export default capiFn;
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
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());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var tb_1 = require("../core/tb");
var tbFn_1 = require("../core/tbFn");
var utils_1 = require("../utils");
// 通用API封装方法
var capiFn = function (apiList, request) {
return {
receiveObjectPrize: function (params) {
return __awaiter(this, void 0, void 0, function () {
var _a, handle, method, ext, userAddress, _b, name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_a = utils_1.getRequestParams(apiList['receiveObjectPrize']), handle = _a.handle, method = _a.method, ext = _a.ext;
return [4 /*yield*/, tbFn_1.getUserAddress().catch(function (err) {
tb_1.commonToast(err.errorMessage);
})];
case 1:
userAddress = _c.sent();
if (!userAddress)
return [2 /*return*/, false];
_b = userAddress || {}, name = _b.name, telNumber = _b.telNumber, provinceName = _b.provinceName, cityName = _b.cityName, cityCode = _b.cityCode, countyName = _b.countyName, detailInfo = _b.detailInfo, streetName = _b.streetName;
params = __assign({ name: name, phone: telNumber, addressDetail: detailInfo, cityCode: cityCode, city: cityName, province: provinceName, area: countyName, streetName: streetName }, params);
return [4 /*yield*/, tb_1.commonConfirm('提示', '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address, function () {
return __awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, request(handle, method, params, ext).catch(function (res) {
tb_1.commonToast(res && res.message);
})];
case 1:
result = _a.sent();
if (result && result.success) {
return [2 /*return*/, true];
}
return [2 /*return*/];
}
});
});
})];
case 2:
_c.sent();
return [2 /*return*/, false];
}
});
});
},
getVipInfo: function (params) {
return __awaiter(this, void 0, void 0, function () {
var _a, handle, method, ext, result, isVip;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = utils_1.getRequestParams(apiList['getVipInfo']), handle = _a.handle, method = _a.method, ext = _a.ext;
return [4 /*yield*/, request(handle, method, params, ext).catch(function (res) {
tb_1.commonToast(res && res.message);
})];
case 1:
result = _b.sent();
if (result && result.success) {
isVip = result.data.isVip;
return [2 /*return*/, isVip];
}
return [2 /*return*/, false];
}
});
});
},
receiveEnamePrize: function (params) {
return __awaiter(this, void 0, void 0, function () {
var _a, handle, method, ext, result;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = utils_1.getRequestParams(apiList['receiveEnamePrize']), handle = _a.handle, method = _a.method, ext = _a.ext;
return [4 /*yield*/, request(handle, method, params, ext).catch(function (res) {
tb_1.commonToast(res && res.message);
})];
case 1:
result = _b.sent();
if (result && result.success) {
return [2 /*return*/, true];
}
return [2 /*return*/, false];
}
});
});
},
addStat: function (activityId, type) {
return __awaiter(this, void 0, void 0, function () {
var _a, handle, method, ext, result;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = utils_1.getRequestParams(apiList['addStat']), handle = _a.handle, method = _a.method, ext = _a.ext;
return [4 /*yield*/, request(handle, method, {
activityId: activityId,
type: type
}, ext).catch(function (res) {
tb_1.commonToast(res && res.message);
})];
case 1:
result = _b.sent();
if (result && result.success) {
return [2 /*return*/, true];
}
return [2 /*return*/, false];
}
});
});
},
};
};
exports.default = capiFn;
//# sourceMappingURL=capiFn.js.map
\ No newline at end of file
{"version":3,"file":"capiFn.js","sourceRoot":"","sources":["../../src/request/capiFn.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAwD;AACxD,qCAA8C;AAC9C,kCAA4C;AAE5C,YAAY;AACZ,IAAM,MAAM,GAAG,UAAC,OAAO,EAAE,OAAO;IAC9B,OAAO;QACC,kBAAkB,EAAxB,UAAyB,MAAM;;;;;;4BACvB,KAA0B,wBAAgB,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,EAAvE,MAAM,YAAA,EAAE,MAAM,YAAA,EAAE,GAAG,SAAA,CAAqD;4BAClD,qBAAM,qBAAc,EAAE,CAAC,KAAK,CAAC,UAAA,GAAG;oCAC5D,gBAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;gCAChC,CAAC,CAAC,EAAA;;4BAFI,WAAW,GAAa,SAE5B;4BACF,IAAG,CAAC,WAAW;gCAAE,sBAAO,KAAK,EAAA;4BACvB,KAA4F,WAAW,IAAI,EAAE,EAA3G,IAAI,UAAA,EAAE,SAAS,eAAA,EAAE,YAAY,kBAAA,EAAE,QAAQ,cAAA,EAAE,QAAQ,cAAA,EAAE,UAAU,gBAAA,EAAE,UAAU,gBAAA,EAAE,UAAU,g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O,KAAK,EAAC;;;;SACd;QAEK,iBAAiB,YAAC,MAAM;;;;;;4BACtB,KAA0B,wBAAgB,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,EAAtE,MAAM,YAAA,EAAE,MAAM,YAAA,EAAE,GAAG,SAAA,CAAoD;4BAChE,qBAAM,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,UAAA,GAAG;oCACjE,gBAAW,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;gCAClC,CAAC,CAAC,EAAA;;4BAFI,MAAM,GAAG,SAEb;4BACF,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;gCAC5B,sBAAO,IAAI,EAAC;6BACb;4BACD,sBAAO,KAAK,EAAC;;;;SACd;QAEK,OAAO,EAAb,UAAc,UAAkB,EAAE,IAAqB;;;;;;4BAC/C,KAA0B,wBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAA5D,MAAM,YAAA,EAAE,MAAM,YAAA,EAAE,GAAG,SAAA,CAA0C;4BACtD,qBAAM,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE;oCAC3C,UAAU,YAAA;oCACV,IAAI,MAAA;iCACL,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,UAAA,GAAG;oCACf,gBAAW,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;gCAClC,CAAC,CAAC,EAAA;;4BALI,MAAM,GAAG,SAKb;4BACF,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;gCAC5B,sBAAO,IAAI,EAAC;6BACb;4BACD,sBAAO,KAAK,EAAC;;;;SACd;KACF,CAAA;AACH,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
\ No newline at end of file
/**
* 接口请求封装
* @param { cloud, cloudName, requestType, mockUrl }
*/
declare const request: (header: IRequest) => false | ((handle: any, method: string, params: any, ext?: {
cloudName?: string;
isShowLoading?: boolean;
}) => Promise<unknown>);
export default request;
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
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());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var requestFn_1 = require("../helpers/requestFn");
var helpers_1 = require("../helpers");
/**
* 接口请求封装
* @param { cloud, cloudName, requestType, mockUrl }
*/
var request = function (header) {
var cloud = header.cloud, cloudName = header.cloudName, _a = header.requestType, requestType = _a === void 0 ? 'cloud' : _a, mockUrl = header.mockUrl;
if (!cloud) {
console.error('请传入cloud');
return false;
}
if (!cloudName) {
console.error('请传入云函数名称');
return false;
}
return function (handle, method, params, ext) {
if (method === void 0) { method = 'POST'; }
return __awaiter(void 0, void 0, void 0, function () {
var _a, activityId, tornadoAPI, _b, nickName, _cloudName, _c, isShowLoading, mockUrlPrefix, reqConfig, initConfig, params_;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_a = getApp(), activityId = _a.activityId, tornadoAPI = _a.tornadoAPI, _b = _a.nickName, nickName = _b === void 0 ? '' : _b;
_cloudName = ext.cloudName || cloudName;
_c = ext.isShowLoading, isShowLoading = _c === void 0 ? false : _c;
mockUrlPrefix = {
ams: 'https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=',
yapi: 'https://docs.dui88.com/mock/140/'
};
reqConfig = { cloudName: _cloudName, handle: handle, method: method, isShowLoading: isShowLoading };
initConfig = { requestType: requestType, tornadoAPI: tornadoAPI, nickName: nickName, mockUrlPrefix: mockUrlPrefix, mockUrl: mockUrl };
params_ = __assign({ activityId: activityId }, params);
if (!['ams', 'yapi', 'tornadoAPI'].includes(requestType)) return [3 /*break*/, 2];
return [4 /*yield*/, requestFn_1.requestMock(reqConfig, initConfig, params_)];
case 1: return [2 /*return*/, _d.sent()];
case 2: return [4 /*yield*/, helpers_1.cloudRequest(cloud, _cloudName, handle, params_, isShowLoading)];
case 3: return [2 /*return*/, _d.sent()];
}
});
});
};
};
exports.default = request;
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/request/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAmD;AACnD,sCAA0C;AAC1C;;;GAGG;AACH,IAAM,OAAO,GAAG,UAAC,MAAe;IACpB,IAAA,KAAK,GAAgD,MAAM,MAAtD,EAAE,SAAS,GAAqC,MAAM,UAA3C,EAAE,KAAmC,MAAM,YAApB,EAArB,WAAW,mBAAG,OAAO,KAAA,EAAE,OAAO,GAAK,MAAM,QAAX,CAAW;IACnE,IAAI,CAAC,KAAK,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;KAChB;IACD,IAAI,CAAC,SAAS,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;KAChB;IAED,OAAO,UAAO,MAAM,EAAE,MAAe,EAAE,MAAM,EAAE,GAAqD;QAA9E,uBAAA,EAAA,eAAe;;;;;;wBAE3B,KAA4C,MAAM,EAAE,EAAlD,UAAU,gBAAA,EAAE,UAAU,gBAAA,EAAE,gBAAa,EAAb,QAAQ,mBAAG,EAAE,KAAA,CAAc;wBACrD,UAAU,GAAG,GAAG,CAAC,SAAS,IAAI,SAAS,CAAC;wBACtC,KAA0B,GAAG,cAAR,EAArB,aAAa,mBAAG,KAAK,KAAA,CAAS;wBAChC,aAAa,GAAG;4BAClB,GAAG,EAAE,iFAAiF;4BACtF,IAAI,EAAE,kCAAkC;yBAC3C,CAAC;wBACI,SAAS,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAA,EAAE,MAAM,QAAA,EAAE,aAAa,eAAA,EAAE,CAAA;wBACpE,UAAU,GAAG,EAAE,WAAW,aAAA,EAAE,UAAU,YAAA,EAAE,QAAQ,UAAA,EAAE,aAAa,eAAA,EAAE,OAAO,SAAA,EAAE,CAAA;wBAC1E,OAAO,cAAK,UAAU,YAAA,IAAK,MAAM,CAAE,CAAA;6BAEtC,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAnD,wBAAmD;wBAAS,qBAAM,uBAAW,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,EAAA;4BAAxD,sBAAO,SAAiD,EAAC;4BAE1G,qBAAM,sBAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,EAAA;4BAA5E,sBAAO,SAAqE,EAAC;;;;KAChF,CAAA;AACL,CAAC,CAAA;AACD,kBAAe,OAAO,CAAA"}
\ No newline at end of file
/**
* 时间格式化
* @param date 接收可以被new Date()方法转换的内容
* @param format 字符串,需要的格式例如:'yyyy/MM/dd hh:mm:ss'
* @returns {String}
*/
export declare const dateFormatter: (dateTxt: string, format?: string) => string;
/**
* 版本比较
* @param {string} cur 当前版本
* @param {string} compare 比较版本
*/
export declare const versionCompare: (cur: string, compare: string) => boolean;
/**
* 获取request请求所需参数
* @param {object/string} value API项配置
*/
export declare const getRequestParams: (value: any) => {
handle: string;
method: string;
ext: {};
defaultParams?: undefined;
} | {
handle: any;
method: any;
defaultParams: any;
ext: any;
};
/**
* 生成API
* @param {array} apiList API数据数组
* @param {function} request 请求
*/
export declare const generateAPI: (apiList: any, request: any) => {};
/**
* 函数节流,普通防连点
* @param {fun} fun 函数
* @param {delay} delay 时间
*/
export declare const throttleHandle: (fun: (t: any) => any, delay?: number) => () => void;
/**
* 根据fileId获取图片地址
* @param fileId
*/
export declare const getImgShareUrl: (fileId: string | Array<string>) => Promise<any>;
/**
* 根据sellerId判断入会状态
* @param sellerId
*/
export declare const checkMember: (sellerId: number) => Promise<unknown>;
/**
* 毫秒转换成00:00:00格式
* @param ms 毫秒
*/
export declare const formatTimeStamp: (ms: number) => string;
/**
* 活动状态验证
* @param startTime
* @param endTime
* @param noCheck
*/
export declare const validateActivityStatus: (startTime: number, endTime: number, noCheck: boolean) => Promise<unknown>;
This diff is collapsed.
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAwD;AACxD;;;;;GAKG;AACU,QAAA,aAAa,GAAG,UAAC,OAAe,EAAE,MAAqB;IAArB,uBAAA,EAAA,qBAAqB;IAChE,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,CAAC;IAEzB,IAAM,IAAI,GAAG,IAAI,IAAI,CACnB,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CACtF,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,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OAAgB;;;;oBAC/E,qBAAM,kBAAa,EAAE,EAAA;;gBAA/B,OAAO,GAAG,SAAqB;gBACrC,sBAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAC,MAAM;wBAChC,IAAG,OAAO,GAAG,SAAS,EAAG;4BACvB,gBAAW,CAAC,OAAO,CAAC,CAAA;4BACpB,OAAO,CAAC,KAAK,CAAC,CAAA;yBACf;6BACI,IAAG,OAAO,GAAG,OAAO,IAAI,CAAC,OAAO,EAAE;4BACrC,gBAAW,CAAC,OAAO,CAAC,CAAA;4BACpB,OAAO,CAAC,KAAK,CAAC,CAAA;yBACf;6BACI;4BACH,OAAO,CAAC,IAAI,CAAC,CAAA;yBACd;oBACH,CAAC,CAAC,EAAA;;;KACH,CAAA"}
\ No newline at end of file
{
"name": "tbcc-sdk-ts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsc"
},
"config": {
"notNeedLogin": []
},
"optionalDependencies": {
"@types/lodash": "^4.14.160",
"@types/node": "^14.6.0",
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.9.1",
"eslint": "^7.7.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"prettier": "^2.0.5",
"ts-node": "^9.0.0",
"typescript": "^3.9.7"
},
"keywords": [],
"author": "",
"license": "ISC"
}
// 领取奖品状态
export const DRAW_STATUS = {
// 待领取
WAITAWARD: 1,
// 处理中
PROCESSING: 2,
// 领取成功
SUCCESS: 3,
// 领取失败
FAIL: 4,
// 已过期
EXPIRED: 5,
// 重新领取
RETRY: 6
}
// 奖品类型
export const PRIZE_TYPE = {
ENAME: 1,
CREDITS: 2,
OBJECT: 3,
THANKS: 5
};
\ No newline at end of file
import {
promisifyApiSimple,
promisifyApi,
promisifyApiToTb,
AudioModel
} from '../helpers'
/**
* 通用toast
* @param {string} content toast内容
* @param {number} duration 显示时长
* @param {function} successCb 成功回调
*/
export const commonToast = (content: string, duration?: number, successCb?: () => any) => {
promisifyApiSimple('showToast',{
content: content || '换个姿势再试一次~',
duration: duration || 3000,
success: successCb
})
};
/**
* 简易alert
* @param {string} content toast内容
*/
export const simpleAlert = (content: string) => {
promisifyApiSimple('alert',{
content
})
};
/**
* 通用确认弹窗
* @param {string} title 标题
* @param {string} content 内容
* @param {function} successCb 成功回调
*/
export const commonConfirm = async (title = '提示', content: string, successCb?: () => any) => {
promisifyApiSimple('confirm',{
title,
content,
confirmButtonText: '确定',
cancelButtonText: '取消',
success: result => {
const { confirm } = result;
if (confirm) {
successCb && successCb();
}
}
})
};
/**
* 获取系统信息
*/
export const getSystemInfo = async () => {
return await promisifyApi('getSystemInfo', {})
};
/**
* 执行关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
export const favorShop = async (sellerId: number) => {
if (!sellerId) {
return false;
}
let result: { error?: number } = await promisifyApiToTb('favorShop',{ id: +sellerId })
if(result?.error === 11) return false
return result
};
/**
* 判断是否关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
export const checkShopFavoredStatus = async (sellerId: number) => {
if (!sellerId) {
return false;
}
let result: { isFavor?: boolean } = await promisifyApiToTb('checkShopFavoredStatus',{ id: +sellerId })
if(result?.isFavor) return result.isFavor
return result
};
/**
* 跳转到外部链接
* @param {string} url 跳转链接
*/
export const navigateToOutside = url => {
if (!url) {
console.error('navigateToOutside: 请传入url');
return false;
}
promisifyApiSimple('call',{
url
}, 'navigateToOutside')
};
/**
* 跳转到内部链接(新开窗口)
* @param {string} url 跳转链接
*/
export const navigateTo = url => {
if (!url) {
console.error('navigateTo: 请传入url');
return false;
}
promisifyApiSimple('navigateTo',{
url
})
};
/**
* 返回页面
* @param {number} delta
*/
export const navigateBack = (delta?: number) => {
promisifyApiSimple('navigateBack',{
delta
})
};
/**
* 跳转到内部链接(不新开窗口)
* @param {string} url
*/
export const redirectTo = (url: string) => {
if (!url) {
console.error('redirectTo: 请传入url');
return false;
}
promisifyApiSimple('redirectTo',{
url
})
};
/**
* 获取服务器时间
* @returns {number} 服务器时间戳
*/
export const getServerTime = async () => {
const result: { time?: string } = await promisifyApi('getServerTime', {})
if(result?.time) return result.time
return result
};
/**
* 收藏商品
* @param {number} 商品id
* @returns {object} 收藏结果
*/
export const collectGoods = async (id: number) => {
if (!id) {
console.error('collectGoods: 请传入商品id');
return false;
}
let result: { error?: number } = await promisifyApiToTb('collectGoods',{ id: +id })
if(result?.error === 11) return false
return result
};
/**
* 查询商品收藏状态
* @param {number} 商品id
* @returns {boolean} 商品收场状态
*/
export const checkGoodsCollectedStatus = async (id: number) => {
if (!id) {
console.error('checkGoodsCollectedStatus: 请传入商品id');
return false;
}
let result: { isCollect?: boolean } = await promisifyApiToTb('checkGoodsCollectedStatus',{ id: +id })
if(result?.isCollect) return result.isCollect
return result
};
/**
* 跳转到淘宝商品页
* @param {string} itemId 商品ID
*/
export const openDetail = async (itemId: string) => {
if (!itemId) {
console.error('openDetail: 请传入商品id');
return false;
}
return await promisifyApiToTb('openDetail',{ itemId: String(itemId) })
};
/**
* 创建音频实例
* @param {object} opts 配置对象 例 { src: '音频链接', autoplay: false }
*/
export const createAudio = (opts: { src: string, autoplay?: boolean}) => {
const audioInstance = new AudioModel(opts);
return audioInstance;
};
/**
* 获取图片信息
* @param {string} src 图片地址
*/
export const getImageInfo = async (src: string) => {
return await promisifyApi('getImageInfo', { src })
};
/**
* 剪切板
* @param {text: string}
*/
export const setClipboard = async (text: string) => {
return await promisifyApi('setClipboard', { text })
};
/**
* 调起分享面板
*/
export const showSharePanel = async () => {
promisifyApiSimple('showSharePanel',{})
}
/**
* 获取缓存数据
* @param key
*/
export const getStorage = async (key: string) => {
const result: { data?: string} = await promisifyApi('getStorage', { key })
if(result?.data) return result.data
return result
}
/**
* 设置缓存数据
* @param key
* @param value
*/
export const setStorage = async (key: string, value: any) => {
return await promisifyApi('setStorage', { key, data: value })
}
/**
* 清除缓存数据
* @param key
*/
export const removeStorage = async (key: string) => {
return await promisifyApi('removeStorage', { key })
}
/**
* 自定义分析数据的上报接口
* @param eventType
* @param logkey
*/
export const taobaoReportClick = (eventType: string,logkey: string) => {
// @ts-ignore
my.reportAnalytics(eventType, {
// 标志某一类事件,方便数据分析进行分组
'logkey': logkey
})
};
/**
* 打开BC客服聊天
* @param sellerNick
* @param itemId
*/
export const openMessage = async (sellerNick: string, itemId: string) => {
let result = await promisifyApiToTb('openMessage',{ sellerNick, forceH5: false, params: { itemId } })
return result
}
/**
* 显示指定商品 SKU 选择器
* @param itemId
*/
export const showSkuModal = async (itemId: string) => {
let result = await promisifyApiToTb('showSku',{ itemId })
return result
}
/**
* 隐藏正在展示的商品 SKU 选择器
*/
export const hideSkuModal = async () => {
let result = await promisifyApiToTb('hideSku',{})
return result
}
/**
* 跳转订单页
* @param itemId
* @param skuId
* @param quantity
*/
export const confirmCustomOrder = async (itemId: number, skuId?: number, quantity?: number) => {
let result = await promisifyApiToTb('confirmCustomOrder',{
data: {
itemId,
skuId: skuId || -1,
quantity: quantity || 1,
customization: {}
}
})
return result
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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