Commit b4cb02cc authored by wildfirecode13's avatar wildfirecode13

1

parent a63c385f
No preview for this file type
No preview for this file type
.DS_Store
node_modules/
.tea/
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const app = getApp();
const { tbcc, cloudName, cloud, requestType } = app;
const { utils: { generateAPI }, request: tbccRequest, capi } = tbcc;
const apicfg_1 = require("./apicfg");
const request = tbccRequest({
cloud,
cloudName,
requestType
});
// api handle 列表
const apiList = Object.assign(Object.assign({}, capi), apicfg_1.default);
// 生成API
const API = generateAPI(apiList, request);
exports.default = API;
//# sourceMappingURL=api.js.map1
\ No newline at end of file
import request from './utils/request';
const API = {
// 获取首页接口
getCollectItemList: params => request('getCollectItemList', 'POST', params),
doTaskComplete: params => request('doTaskComplete', 'POST', params),
// 经验排行榜
getExpRankList: params => request('getExpRankList', 'POST', params, { isShowLoading: true }),
// 登录接口
login: params => request('login', 'POST', params, { cloudName: 'bubbleSurviva' }),
//领取任务奖励 takeTaskPrize
takeTaskPrize: params => request('takeTaskPrize', 'POST', params),
// 获取我的奖品
getMyPrizeList: params => request('getMyPrizeList', 'POST', params, { cloudName: 'bubbleSurviva' }),
// 购买商品
getGoodsList: params => request('getGoodsList', 'POST', params, { cloudName: 'bubbleSurviva' }),
// 实物领取
receiveObjectPrize: params => request('receiveObjectPrize', 'POST', params, { cloudName: 'bubbleSurviva' }),
// 非实物领取
receivePrize: params => request('receiveEnamePrize', 'POST', params, { cloudName: 'bubbleSurviva' }),
//是否可助力
canAssist: params => request('canAssist', 'POST', params, { cloudName: 'bubbleSurviva' }),
//邮费标识
postageMark: params => request('postageMark', 'POST', params, { cloudName: 'bubbleSurviva' }),
//是否可助力
canAssist: params => request('canAssist', 'POST', params, { cloudName: 'bubbleSurviva' }),
//助力
assist: params => request('assist', 'POST', params, { cloudName: 'bubbleSurviva' }),
//小样奖品弹框提示
samplePop: params => request('samplePop', 'POST', params, { cloudName: 'bubbleSurviva' }),
//数据埋点
addDataUv: params => request('addDataUv', 'POST', params, { cloudName: 'bubbleSurviva' }),
};
export default API;
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../../src/packages/jsx2taobao/template/api/api.js"],"names":[],"mappings":";;AAAA,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;AACrB,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC;AAEpD,MAAM,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;AACpE,qCAA8B;AAC9B,MAAM,OAAO,GAAG,WAAW,CAAC;IAC1B,KAAK;IACL,SAAS;IACT,WAAW;CACZ,CAAC,CAAC;AAEH,gBAAgB;AAChB,MAAM,OAAO,mCACR,IAAI,GACJ,gBAAM,CACV,CAAC;AAEF,QAAQ;AACR,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAE1C,kBAAe,GAAG,CAAC"}
\ No newline at end of file
let projectId = window.CFG.projectId || '';
const apiCfg = {
getRule:`/projectx/${projectId}/projectRule.query`,
doJoin: {
uri: `/projectx/${projectId}/join.do`,
method: "post"
}
}
export default apiCfg;
\ No newline at end of file
page {
background: #f7f7f7;
font-family: 'Helvetica Neue', Helvetica, Hiragino Sans GB, 'Microsoft Yahei', STHeiTi, Arial, sans-serif;
}
* {
box-sizing: border-box;
}
.d-flex {
display: flex
}
.d-flex__item {
flex: 1;
}
.d-flex--aligncenter {
align-items: center;
}
.modal-animate-fade-in {
opacity: 0;
animation: modalAnimateFadeIn .3s forwards;
}
.modal-animate-zoom-in {
transform: scale(0);
animation: modalAnimateZoomIn .3s forwards;
}
.modal-animate-fly-in {
transform: translateY(100%);
animation: modalAnimateFlyIn .3s forwards;
}
.btn-animate-pulse {
animation: btnAnimatePulse .8s infinite;
}
@keyframes modalAnimateFadeIn {
to {
opacity: 1;
}
}
@keyframes modalAnimateZoomIn {
to {
transform: scale(1);
}
}
@keyframes modalAnimateFlyIn {
to {
transform: translateY(0);
}
}
@keyframes btnAnimatePulse {
from {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
to {
transform: scale(1);
}
}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mp_cloud_sdk_1 = require("@tbmp/mp-cloud-sdk");
const tbcc_sdk_1 = require("./tbcc-sdk");
mp_cloud_sdk_1.default.init({
env: 'test' // 云函数环境 test 测试环境 online 线上环境
import cloud from '@tbmp/mp-cloud-sdk';
cloud.init({
env: 'online' // 云函数环境 test 测试环境 online 线上环境
});
App({
requestType: 'cloud',
cloudName: '',
cloud: // 主云函数项目名
mp_cloud_sdk_1.default,
tbcc: tbcc_sdk_1.default,
activityId: "",
onLaunch(options) {
this.handleQuery(options.query || {});
console.log('onLauch')
},
onShow(options) {
// 从后台被 scheme 重新打开
},
/**
* 处理链接参数
* @param {object} query 小程序链接上的参数
*/
handleQuery(query) {
const { activityId } = query;
activityId && (this.activityId = activityId);
}
requestType: 'cloud', // ams:ams接口,cloud: 云函数
cloudName: 'bubbleSurviva', // 主云函数项目名 duiba
cloud,
sellerId: 880734502,//固定
smallKidItemId: '625760427170',//小样商品ID
onLaunch(options) {
this.handleQuery(options.query || {});
console.log('onLaunch')
},
onShow(options) {
// 从后台被 scheme 重新打开
},
/**
* 处理链接参数
* @param {object} query 小程序链接上的参数
*/
handleQuery(query) {
const { activityId,isAssist,inviteId } = query;
this.activityId = activityId || '5f34e1c4964f9706aa7d803c';//5ef1903a9897b43b31bb651a
this.isAssist=isAssist;
this.inviteId=inviteId;
}
});
//# sourceMappingURL=app.js.map
\ No newline at end of file
{
"pages": ["pages/pagecanvas/pagecanvas", "pages/pagemycanvaspage/pagemycanvaspage"],
"window": {
"enableSkia": "true",
"allowsBounceVertical":"NO"
}
}
\ No newline at end of file
"pages": [
"pages/index/index",
"pages/myPrize/myPrize",
"pages/goodsPage/goodsPage",
"pages/helpPage/helpPage"
],
"window": {
"navigationBarForceEnable": true,
"defaultTitle": "",
"enableSkia": "true"
}
}
.adopt-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 20;
}
.adopt-modal__shade {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.75);
}
.adopt-modal__container {
position: absolute;
top: 50%;
left: 50%;
margin-left: -325rpx;
margin-top: -324rpx;
width: 650rpx;
height: 648rpx;
background: url("//yun.duiba.com.cn/duiba-h5/tb/adopt/adoptBg.png") no-repeat;
background-size: 100%;
}
.adopt_xj {
background: url("//yun.duiba.com.cn/duiba-h5/tb/adopt/adopt_xj.png") no-repeat;
background-size: 100%;
}
.adopt_xm {
background: url("//yun.duiba.com.cn/duiba-h5/tb/adopt/adopt_xm.png") no-repeat;
background-size: 100%;
}
.adopt_xk {
background: url("//yun.duiba.com.cn/duiba-h5/tb/adopt/adopt_xk.png") no-repeat;
background-size: 100%;
}
.adopt-modal__bd {
font-size: 28rpx;
text-align: center;
color: #fff;
padding: 50rpx 0;
}
.adopt-modal__close {
position: absolute;
right: -20rpx;
top: -80rpx;
height: 75rpx;
width: 85rpx;
/* background: url('../../assets/modal_close_btn.png') center center no-repeat; */
background: url("//yun.duiba.com.cn/duiba-h5/tb/adopt/close.png") no-repeat;
background-size: 100%;
z-index: 9;
}
.adopt-modal_introduce{
position: absolute;
left: 0;
top: 378rpx;
width: 100%;
color: #4d2716;
font-size: 29rpx;
text-align: center;
}
.adopt-modal_input{
border:0;
position: absolute;
left: 78rpx;
top: 300rpx;
/* margin-left: -225rpx; */
width: 450rpx;
height: 66rpx;
background: url("//yun.duiba.com.cn/duiba-h5/tb/adopt/inputBg.png") no-repeat;
background-size: 100%;
}
.adopt-modal_input input {
/* position: absolute;
top: 0;
width: 631px;
height: 91px; */
width: 450rpx;
height: 66rpx;
border: 0;
background-color: rgba(0, 0, 0, 0);
font-size: 12px;
text-align: left;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
color: #4d2716;
}
input::-webkit-input-placeholder {
color: #4d2716;
font-size: 12px;
text-align: center;
}
.adopt-modal_resetBtn{
position: absolute;
left: 0;
bottom: 34rpx;
width: 100%;
color: #4d2716;
font-size: 32rpx;
text-align: center;
}
.adopt-modal__tz {
position: absolute;
left: 545rpx;
top: 291rpx;
width: 68rpx;
height: 77rpx;
background: url("//yun.duiba.com.cn/duiba-h5/tb/adopt/tz.png") no-repeat;
background-size: 100%;
}
.adopt-modal__confirm-btn {
position: absolute;
left: 50%;
margin-left: -165rpx;
bottom: 84rpx;
width: 330rpx;
height: 104rpx;
background: url("//yun.duiba.com.cn/duiba-h5/tb/adopt/adoptBtn.png") no-repeat;
background-size: 100%;
}
<view class="adopt-modal">
<view class="adopt-modal__shade modal-animate-fade-in" />
<view class="adopt-modal__container modal-animate-zoom-in {{type==1?'adopt_xj':type==2?'adopt_xm':'adopt_xk'}} ">
<view class="adopt-modal__close" onTap="onModalClose" />
<view class="adopt-modal_input">
<input placeholder="给你的松鼠取个名字吧!(6字以内)" value="{{randomName}}" maxlength="6" onInput="onChangeInput" />
</view>
<view class="adopt-modal_introduce">快快领它回家,陪它长大吧!</view>
<view class="adopt-modal__tz" onTap="handelRandomName"></view>
<view onTap="onModalConfirm" class="adopt-modal__confirm-btn"></view>
<view class="adopt-modal_resetBtn" onTap="onModalClose">重新选择</view>
</view>
</view>
import { commonToast } from "../../utils/utils";
const SYSTEMNAME = [
"鼠苹果",
"鼠蜜桃",
"鼠木瓜",
"鼠香橙",
"鼠葡萄",
"鼠冻梨",
"鼠狮子",
"鼠猴子",
"鼠悟空",
"鼠八戒",
"鼠白雪",
"鼠雪花",
"鼠吐吐",
"鼠典典",
"鼠璐璐",
"鼠奔奔",
"鼠蜡烛",
"鼠宁宁",
"鼠卡卡",
"鼠艾西",
"鼠蓝宝",
"鼠麒麟",
"鼠淘淘",
"鼠泰山",
"鼠帅哥",
"鼠西瓜",
"鼠瑞拉",
"鼠妞妞",
"鼠圆圆",
"鼠盐盐",
"鼠太子",
"鼠恺撒",
"鼠哈哈",
"鼠公子",
"鼠洛忧",
"鼠迪尔",
"鼠洛洛",
"鼠七喜",
"鼠四傻",
"鼠乖乖",
"鼠米奇",
"鼠柯基",
"鼠跳跳",
"鼠淘气",
"鼠豹子",
"鼠扑扑",
"鼠麻团",
"鼠来福",
"鼠波利",
"鼠安琪",
"鼠瑞瑞",
"鼠洛克",
"鼠基诺",
"鼠莎莉",
"鼠绵绵",
"鼠仙缔",
"鼠长毛",
"鼠米菲",
"鼠公爵",
"鼠宝马",
"鼠柯弟",
"鼠贝贝",
"鼠金金",
"鼠导弹",
"鼠西西",
"鼠阿郎",
"鼠本伟",
"鼠彦祖",
"鼠棉花",
"鼠丝丝",
"鼠安娜",
"鼠玛吉",
"鼠优卡",
"鼠耐克",
"鼠尼卡",
"鼠元帅",
"鼠懒懒",
"鼠兰兰",
"鼠艾米",
"鼠团团",
"鼠贝塔",
"鼠雪郎",
"鼠罗杰",
"鼠伯通",
"鼠满意",
"鼠大象",
"鼠天天",
"鼠妖妖",
"鼠小杰",
"鼠傻傻",
"鼠鼎鼎",
"鼠钢炮",
"鼠果冻",
"鼠依恋",
"鼠思诺",
"鼠白宫",
"鼠萨萨",
"鼠贝茜",
"鼠苏拉",
"鼠黑虎",
"鼠格格",
"鼠梅西",
"鼠肥肥",
"鼠饭团",
"鼠米莉",
"鼠绅士",
"鼠旋风",
"鼠白龙",
"鼠泪恩",
"鼠多多",
"鼠彼利",
"鼠巴特",
"鼠丸子",
"鼠拉索",
"鼠苏苏",
"鼠灵宝",
"鼠卡索",
"鼠晨晨",
"鼠露露",
"鼠黑狼",
"鼠盒子",
"鼠大款",
"鼠大海",
"鼠正男",
"鼠咪咪",
"鼠肉肉",
"鼠莱多",
"鼠棒棒",
"鼠乐乐",
"鼠康熙",
"鼠米可",
"鼠辛缔",
"鼠白虎",
"鼠路路",
"鼠巴顿"
];
Component({
data: {
inputVal: "",
randomName: "",
type:1
},
didMount() {
// 页面显示
let { type } = this.props
console.log("typetypetype-=-=-",type)
// this.type = type;
this.setData({
type
});
},
methods: {
onModalClose() {
const { onModalClose } = this.props;
onModalClose && onModalClose();
},
randNum(a, b) {
return Math.floor(Math.random() * (b - a) + a);
},
onModalConfirm() {
const { onModalConfirm, onModalClose } = this.props;
var reg = /^\s*$/g;
if (
reg.test(this.data.inputVal) ||
this.data.inputVal == null ||
this.data.inputVal == ""
) {
commonToast("松鼠名字不能为空");
} else {
onModalConfirm && onModalConfirm(this.data.inputVal);
// onModalClose && onModalClose();
}
},
onChangeInput(e) {
console.log(e);
let { value } = e.detail;
this.setData({
inputVal: value
});
console.log(this.data.inputVal);
},
handelRandomName() {
let numRand = Math.floor((Math.random() * 999)) + 1;
let str = SYSTEMNAME[this.randNum(0, 135)] + numRand;
this.setData({
randomName: str,
inputVal: str
});
console.log(str)
}
}
});
{
"component": true
}
\ No newline at end of file
.exp-rank-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 20;
background-color: rgba(0, 0, 0, 0.75);
}
.exp-rank-wrap {
width: 100%;
/* height: 900rpx; */
position: fixed;
bottom: 0;
left: 0;
background-color: #e9dab6;
border-top-right-radius: 20rpx;
border-top-left-radius: 20rpx;
padding: 0 25rpx;
animation: mallmodalIn 0.5s ease-out;
}
.exp-rank-title {
font-size: 48rpx;
line-height: 1;
color: #4d2716;
text-align: center;
padding-top: 50rpx;
padding-bottom: 30rpx;
font-weight: bold;
}
.exp-rank-content {
background-color: #fff;
border-top-right-radius: 20rpx;
border-top-left-radius: 20rpx;
height: 784rpx;
}
.exp-rank-header {
width: 100%;
height: 70rpx;
line-height: 70rpx;
font-size: 24rpx;
color: #4d2716;
display: flex;
justify-content: space-around;
text-align: center;
border-bottom: 1rpx solid #e9dab6;
}
.exp-rank-list {
height: 713rpx;
}
.exp-rank-list .exp-rank-item {
width: 100%;
height: 88rpx;
line-height: 88rpx;
font-size: 30rpx;
color: #4d2716;
display: flex;
justify-content: space-around;
text-align: center;
border-bottom: 1rpx solid #e9dab6;
}
.exp-rank-list .exp-rank-item:nth-child(1) .exp-rank-item-rank {
font-size: 0;
background: url('//yun.duiba.com.cn/taobaomini/squirrelAdopt/exp-rank1.png') no-repeat;
background-size: 37rpx 42rpx;
background-position: 32rpx 23rpx;
}
.exp-rank-list .exp-rank-item:nth-child(2) .exp-rank-item-rank {
font-size: 0;
background: url('//yun.duiba.com.cn/taobaomini/squirrelAdopt/exp-rank2.png') no-repeat;
background-size: 37rpx 42rpx;
background-position: 32rpx 23rpx;
}
.exp-rank-list .exp-rank-item:nth-child(3) .exp-rank-item-rank {
font-size: 0;
background: url('//yun.duiba.com.cn/taobaomini/squirrelAdopt/exp-rank3.png') no-repeat;
background-size: 37rpx 42rpx;
background-position: 32rpx 23rpx;
}
.exp-rank-list .exp-rank-item-rank {
font-weight: bold;
}
.exp-rank-item-rank {
width: 100rpx;
display: inline-block;
}
.exp-rank-item-name {
width: 200rpx;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
display: inline-block;
}
.exp-rank-item-level {
width: 100rpx;
display: inline-block;
}
.exp-rank-item-exp {
width: 150rpx;
display: inline-block;
}
.exp-rank-content .exp-rank-nodata {
color: #4d2716;
font-size: 28rpx;
text-align: center;
padding-top: 240rpx;
}
.exp-rank-modal .close {
position: absolute;
right: 25rpx;
top: -92rpx;
height: 75rpx;
width: 85rpx;
background: url("//yun.duiba.com.cn/duiba-h5/tb/adopt/close.png") no-repeat;
background-size: 100% 100%;
z-index: 9;
}
@keyframes mallmodalIn {
from {
transform: translateY(100%)
}
to {
transform: translateY(0)
}
}
\ No newline at end of file
<view class="exp-rank-modal">
<view class="exp-rank-wrap">
<view class="close" onTap="onModalClose"></view>
<view class="exp-rank-title">等级排行榜</view>
<view class="exp-rank-content">
<view class="exp-rank-header">
<text class="exp-rank-item-rank">排名</text>
<text class="exp-rank-item-name">昵称</text>
<text class="exp-rank-item-level">等级</text>
<text class="exp-rank-item-exp">经验值</text>
</view>
<view class="exp-rank-list" a:if="{{list && list.length>0}}">
<scroll-view scroll-y="{{true}}" style="height: 100%">
<view class="exp-rank-item" a:for="{{list}}">
<text class="exp-rank-item-rank">{{item.rank}}</text>
<text class="exp-rank-item-name">{{item.squirrelName}}</text>
<text class="exp-rank-item-level">{{item.level}}</text>
<text class="exp-rank-item-exp">{{item.exp}}</text>
</scroll-view>
</view>
<view class="exp-rank-nodata" a:else>暂无人上榜</view>
</view>
</view>
</view>
\ No newline at end of file
import API from '../../api';
import { commonToast } from '../../utils/utils';
const app = getApp();
Component({
mixins: [],
data: {
},
props: {},
didMount() {
this.getExpRankList();
},
didUpdate() {},
didUnmount() {},
methods: {
onModalClose() {
const { onExpModalClose } = this.props;
console.log('onExpModalClose', onExpModalClose)
onExpModalClose && onExpModalClose();
},
async getExpRankList(){
const { activityId } = app;
const { success, data } = await API.getExpRankList({ activityId }).catch(res => {
commonToast(res && res.message);
}) || {};
if (success && data){
const { list = [] } = data;
this.setData({
list
})
console.log(list)
}
}
},
});
{
"component": true
}
\ No newline at end of file
.get-small-modal-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.7);
z-index: 20;
}
.get-small-modal-container__content {
position: absolute;
width:703rpx;
height:445rpx;
background: url("//yun.duiba.com.cn/taobaomini/aupresViva/samplePanelBg.png") no-repeat;
background-size: 100%;
position: absolute;
top: 50%;
left: 50%;
margin-left: -352rpx;
margin-top: -222rpx;
}
.get-small-modal-container__close {
position: absolute;
right: 30rpx;
top: -60rpx;
height: 48rpx;
width: 48rpx;
background: url("//yun.duiba.com.cn/taobaomini/aupresViva/tc_close.png") no-repeat;
background-size: 100% 100%;
}
.get-small-modal-container__btn {
position: absolute;
bottom: 60rpx;
width: 436rpx;
height: 86rpx;
left: 50%;
margin-left: -218rpx;
background: url("//yun.duiba.com.cn/taobaomini/aupresViva/samplePanelBtn.png") no-repeat;
background-size: 100% 100%;
}
\ No newline at end of file
<view class="get-small-modal-container">
<view class="get-small-modal-container__content">
<view class="get-small-modal-container__close" onTap="closeModal"></view>
<view class="get-small-modal-container__btn" onTap="closeModal"></view>
</view>
</view>
\ No newline at end of file
Component({
mixins: [],
data: {},
props: {
onCloseModal: () => {}
},
didMount() {},
didUpdate() {},
didUnmount() {},
methods: {
closeModal() {
this.props.onCloseModal()
}
},
});
{
"component": true
}
\ No newline at end of file
.logistics-modal-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.7);
z-index: 20;
}
.logistics-modal-container__content {
width:645rpx;
height:243rpx;
border:2rpx solid rgba(239,234,255,1);
border-radius:20rpx;
padding: 11rpx 10rpx;
background: #B09BFF;
position: absolute;
left: 50%;
top: 50%;
margin-left: -322rpx;
margin-top: -121rpx;
}
.logistics-modal-container__close {
position: absolute;
right: -10rpx;
top: -70rpx;
height: 48rpx;
width: 48rpx;
background: url("//yun.duiba.com.cn/taobaomini/aupresViva/tc_close.png") no-repeat;
background-size: 100% 100%;
}
.logistics-modal-container__content-item {
width:621rpx;
height:217rpx;
background:rgba(255,255,255,1);
border-radius:10rpx;
padding: 34rpx 0 0 34rpx;
display: flex;
}
.logistics-modal-container__content-left {
width: 120rpx;
height:120rpx;
background:rgba(244,244,244,1);
}
.logistics-modal-container__content-left image {
width: 100%;
height: 100%;
}
.logistics-modal-container__content-right {
margin-left: 40rpx;
display: flex;
flex-direction: column;
}
.logistics-modal-container__content-name view{
font-size:28rpx;
font-family:SourceHanSansSC;
font-weight:400;
color:rgba(51,51,51,1);
}
.logistics-modal-container__content-desc {
font-size:20rpx;
margin-top: 15rpx;
}
.logistics-modal-container__content-copy {
display: flex;
align-items: center;
height: 30rpx;
margin-top: 15rpx;
}
.logistics-modal-container__content-copy__code {
font-size:20rpx;
}
.logistics-modal-container__content-copy__img {
width: 20rpx;
height: 20rpx;
background: url("//yun.duiba.com.cn/taobaomini/aupresViva/icon_copy_1.png") no-repeat;
background-size: 100% 100%;
margin-left: 20rpx;
}
\ No newline at end of file
<view class="logistics-modal-container">
<view class="logistics-modal-container__content">
<view class="logistics-modal-container__close" onTap="closeModal"></view>
<view class="logistics-modal-container__content-item">
<view class="logistics-modal-container__content-left">
<image mode="scaleToFill" src="{{prizeItem.image}}"/>
</view>
<view class="logistics-modal-container__content-right">
<view class="logistics-modal-container__content-name">{{prizeItem.name}}</view>
<view class="logistics-modal-container__content-desc">{{(prizeItem.shipStatus - 0) == 2?'发货状态:已发货':'发货状态:未发货'}}</view>
<view class="logistics-modal-container__content-desc" a:if="{{prizeItem.shipStatus != 2}}">温馨提示:奖品将在活动结束7天内陆续发出</view>
<view class="logistics-modal-container__content-copy" a:else>
<view class="logistics-modal-container__content-copy__code">{{'物流单号:'+prizeItem.shipNum}}</view>
<view class="logistics-modal-container__content-copy__img" onTap="copyCode"></view>
</view>
</view>
</view>
</view>
</view>
\ No newline at end of file
import { commonToast } from '../../utils/utils';
Component({
mixins: [],
data: {},
props: {
prizeItem: {},
onCloseModal: () => {}
},
didMount() {},
didUpdate() {},
didUnmount() {},
methods: {
closeModal() {
this.props.onCloseModal()
},
//复制运单号
copyCode() {
let { shipNum } = this.props.prizeItem
my.setClipboard({
text: shipNum+'',
success: () =>{
commonToast('复制成功')
}
});
}
},
});
{
"component": true
}
\ No newline at end of file
.small-kid-modal-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.7);
z-index: 20;
}
.small-kid-modal-container__content {
width:750rpx;
height:762rpx;
background: url("//yun.duiba.com.cn/taobaomini/aupresViva/tc_xy_icon.png") no-repeat;
background-size: 100%;
position: absolute;
top: 50%;
margin-top: -431rpx;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
}
.small-kid-modal-container__close {
position: absolute;
right: 40rpx;
top: 0;
height: 48rpx;
width: 48rpx;
background: url("//yun.duiba.com.cn/taobaomini/aupresViva/tc_close.png") no-repeat;
background-size: 100% 100%;
}
.small-kid-modal-container__title {
margin-top: 140rpx;
}
.small-kid-modal-container__title view {
font-size:24rpx;
font-family:SourceHanSansSC;
font-weight:300;
color:rgba(92,89,177,1);
line-height:36rpx;
text-align: center;
}
.small-kid-modal-container__prize {
width:220rpx;
height:219rpx;
background:rgba(255,255,255,1);
border:1rpx solid rgba(92,89,177,1);
margin: 20rpx 0 60rpx;
}
.small-kid-modal-container__prize image{
width: 100%;
height: 100%;
}
.small-kid-modal-container__desc {
font-size:24rpx;
font-family:SourceHanSansSC;
font-weight:300;
color:rgba(92,89,177,1);
line-height:36rpx;
text-align: center;
}
.small-kid-modal-container__btn {
margin-top: 20rpx;
display: flex;
justify-content: center;
align-items: center;
}
.small-kid-modal-container__btn-left,.small-kid-modal-container__btn-right {
width:256rpx;
height:85rpx;
background: url("//yun.duiba.com.cn/taobaomini/aupresViva/kid_btn_01.png") no-repeat;
background-size: 100% 100%;
font-size:36rpx;
font-family:SourceHanSansSC;
font-weight:300;
color:rgba(255,255,255,1);
text-shadow:0px 3rpx 8rpx rgba(245,154,71,0.67);
display: flex;
justify-content: center;
align-items: center;
line-height: 86rpx;
}
.small-kid-modal-container__btn-right {
background: url("//yun.duiba.com.cn/taobaomini/aupresViva/kid_icon_02.png") no-repeat;
background-size: 100% 100%;
}
\ No newline at end of file
<view class="small-kid-modal-container">
<view class="small-kid-modal-container__content">
<view class="small-kid-modal-container__close" onTap="closeModal"></view>
<view class="small-kid-modal-container__title">
<view>您的好友赠送了你一份84元小样, </view>
<view>现在购买88元及以上商品即可随单包邮寄送,</view>
<view>或支付14.9元邮费即可带回家~ </view>
</view>
<view class="small-kid-modal-container__prize">
<image mode="scaleToFill" src="//yun.duiba.com.cn/aurora/assets/c5f66927bb6fb83b832bb5fbed106c72c63b4967.png"/>
</view>
<view class="small-kid-modal-container__desc">图片仅供参考,具体以收到的实物为准</view>
<view class="small-kid-modal-container__btn">
<view class="small-kid-modal-container__btn-left" onTap="goToBuy">去下单</view>
<view class="small-kid-modal-container__btn-right" onTap="goToPay">支付邮费</view>
</view>
</view>
</view>
\ No newline at end of file
Component({
mixins: [],
data: {},
props: {
onCloseModal: () => {},
onGoToBuy: () => {},
onGoToPay: () => {},
},
didMount() {},
didUpdate() {},
didUnmount() {},
methods: {
closeModal() {
this.props.onCloseModal()
},
//去下单
goToBuy() {
this.props.onGoToBuy()
},
//支付邮费
goToPay() {
this.props.onGoToPay()
},
},
});
{
"component": true
}
\ No newline at end of file
// 分享配置
export const SHARE_CONFIG = {
title: '分享测试标题',
desc: '分享测试描述',
imageUrl: '', // 分享图片URL
path: 'pages/index/index'
};
// 链接配置
export const REDIRECT_URL = {
'testpage': '/pages/testPage/testPage',
'tmall': 'https://www.tmall.com'
};
// 领取状态 (1待领取,2处理中,3领取成功,4领取失败,5已过期,6重新领取) 针对小样奖品:(0待解锁,7:淘宝查看)
export const DRAW_STATUS_PARAMS = {
'stock': 0,
'wait': 1,
'processing': 2,
'done': 3,
'fail': 4,
'expired': 5,
'retry': 6,
'view': 7
};
// 我的奖品页-领取按钮状态 (1待领取,2处理中,3领取成功,4领取失败,5已过期,6重新领取)
export const DRAW_STATUS_MAP = {
[DRAW_STATUS_PARAMS.stock]: {
btnText: '领取奖品',
},
[DRAW_STATUS_PARAMS.wait]: {
btnText: '立即领取',
},
[DRAW_STATUS_PARAMS.processing]: {
btnText: '处理中',
btnDisabled: 'myprize-btn-status-disabled'
},
[DRAW_STATUS_PARAMS.done]: {
btnText: '已领取',
btnDisabled: 'myprize-btn-status-get'
},
[DRAW_STATUS_PARAMS.fail]: {
btnText: '领取失败',
btnDisabled: 'myprize-btn-status-disabled'
},
[DRAW_STATUS_PARAMS.expired]: {
btnText: '已失效',
btnDisabled: 'myprize-btn-status-disabled'
},
[DRAW_STATUS_PARAMS.retry]: {
btnText: '重新领取',
btnUse: 'myprize-btn-status-use'
},
[DRAW_STATUS_PARAMS.view]: {
btnText: '淘宝查看',
btnDisabled: 'myprize-btn-status-disabled'
},
};
// 奖品类型(1 权益(优惠券/红包),2积分,3实物,5谢谢参与)
export const PRIZE_TYPE = {
1: 'coupon',
2: 'credits',
3: 'object',
5: 'thanks'
};
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.cloud={})}(this,function(t){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function e(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var h=function(){return(h=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function n(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;0<=s;s--)(o=t[s])&&(a=(i<3?o(a):3<i?o(e,n,a):o(e,n))||a);return 3<i&&a&&Object.defineProperty(e,n,a),a}function p(t,a,s,c){return new(s=s||Promise)(function(n,e){function r(t){try{i(c.next(t))}catch(t){e(t)}}function o(t){try{i(c.throw(t))}catch(t){e(t)}}function i(t){var e;t.done?n(t.value):((e=t.value)instanceof s?e:new s(function(t){t(e)})).then(r,o)}i((c=c.apply(t,a||[])).next())})}function k(n,r){var o,i,a,t,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,i&&(a=2&e[0]?i.return:e[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,e[1])).done)return a;switch(i=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,i=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=r.call(n,s)}catch(t){e=[6,t],i=0}finally{o=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function o(){return function(t,e,n){var l=n.value;n.value=function(t){var e,n=t||{},r=n.success,o=void 0===r?null:r,i=n.fail,a=void 0===i?null:i,s=n.complete,c=void 0===s?null:s,u=!c&&!a&&!o;try{e=l.apply(this,arguments)}catch(t){return u?Promise.reject(t):(a&&a(t),void(c&&c(t)))}if(e=e.then?e:Promise.resolve(e),u)return e;e.then(function(t){try{o&&o(t),c&&c(t)}catch(t){throw t}}).catch(function(t){a&&a(t),c&&c(t)})}}}function T(t,e,n){Array.isArray(e)||(e=e.split("."));var r=e.reduce(function(t,e){return t?t[e]:null},t);return n?r||n:r}function i(t,e){return t(e={exports:{}},e.exports),e.exports}var d,a,s=i(function(t,e){var n;t.exports=(n=n||function(l){var n=Object.create||function(t){var e;return r.prototype=t,e=new r,r.prototype=null,e};function r(){}var t={},e=t.lib={},o=e.Base={extend:function(t){var e=n(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),(e.init.prototype=e).$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},p=e.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||a).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var a=n[i>>>2]>>>24-i%4*8&255;e[r+i>>>2]|=a<<24-(r+i)%4*8}else for(i=0;i<o;i+=4)e[r+i>>>2]=n[i>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=l.ceil(e/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e,n=[],r=function(e){e=e;var n=987654321,r=4294967295;return function(){var t=((n=36969*(65535&n)+(n>>16)&r)<<16)+(e=18e3*(65535&e)+(e>>16)&r)&r;return t/=4294967296,(t+=.5)*(.5<l.random()?1:-1)}},o=0;o<t;o+=4){var i=r(4294967296*(e||l.random()));e=987654071*i(),n.push(4294967296*i()|0)}return new p.init(n,t)}}),i=t.enc={},a=i.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new p.init(n,e/2)}},s=i.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new p.init(n,e)}},c=i.Utf8={stringify:function(t){try{return decodeURIComponent(escape(s.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return s.parse(unescape(encodeURIComponent(t)))}},u=e.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new p.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,n=e.words,r=e.sigBytes,o=this.blockSize,i=r/(4*o),a=(i=t?l.ceil(i):l.max((0|i)-this._minBufferSize,0))*o,s=l.min(4*a,r);if(a){for(var c=0;c<a;c+=o)this._doProcessBlock(n,c);var u=n.splice(0,a);e.sigBytes-=s}return new p.init(u,s)},clone:function(){var t=o.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),d=(e.Hasher=u.extend({cfg:o.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){u.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(n){return function(t,e){return new n.init(e).finalize(t)}},_createHmacHelper:function(n){return function(t,e){return new d.HMAC.init(n,e).finalize(t)}}}),t.algo={});return t}(Math),n)}),c=(i(function(t,e){var c;t.exports=(c=s,function(o){var t=c,e=t.lib,n=e.WordArray,r=e.Hasher,i=t.algo,a=[],g=[];!function(){function t(t){for(var e=o.sqrt(t),n=2;n<=e;n++)if(!(t%n))return;return 1}function e(t){return 4294967296*(t-(0|t))|0}for(var n=2,r=0;r<64;)t(n)&&(r<8&&(a[r]=e(o.pow(n,.5))),g[r]=e(o.pow(n,1/3)),r++),n++}();var b=[],s=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(a.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],a=n[3],s=n[4],c=n[5],u=n[6],l=n[7],p=0;p<64;p++){if(p<16)b[p]=0|t[e+p];else{var d=b[p-15],h=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,f=b[p-2],v=(f<<15|f>>>17)^(f<<13|f>>>19)^f>>>10;b[p]=h+b[p-7]+v+b[p-16]}var y=r&o^r&i^o&i,m=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),w=l+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&c^~s&u)+g[p]+b[p];l=u,u=c,c=s,s=a+w|0,a=i,i=o,o=r,r=w+(m+y)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+a|0,n[4]=n[4]+s|0,n[5]=n[5]+c|0,n[6]=n[6]+u|0,n[7]=n[7]+l|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[14+(64+r>>>9<<4)]=o.floor(n/4294967296),e[15+(64+r>>>9<<4)]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA256=r._createHelper(s),t.HmacSHA256=r._createHmacHelper(s)}(Math),c.SHA256)}),i(function(t,e){var n;t.exports=(n=s,void function(){var t=n.lib.Base,u=n.enc.Utf8;n.algo.HMAC=t.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=u.parse(e));var n=t.blockSize,r=4*n;e.sigBytes>r&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),i=this._iKey=e.clone(),a=o.words,s=i.words,c=0;c<n;c++)a[c]^=1549556828,s[c]^=909522486;o.sigBytes=i.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})}())}),i(function(t,e){t.exports=s.HmacSHA256})),u=i(function(t,e){var n;t.exports=(n=s,function(){var c=n.lib.WordArray;n.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var o=[],i=0;i<n;i+=3)for(var a=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;s<4&&i+.75*s<n;s++)o.push(r.charAt(a>>>6*(3-s)&63));var c=r.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(t){var e=t.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var o=0;o<n.length;o++)r[n.charCodeAt(o)]=o}var i=n.charAt(64);if(i){var a=t.indexOf(i);-1!==a&&(e=a)}return function(t,e,n){for(var r=[],o=0,i=0;i<e;i++)if(i%4){var a=n[t.charCodeAt(i-1)]<<i%4*2,s=n[t.charCodeAt(i)]>>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return c.create(r,o)}(t,e,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),n.enc.Base64)}),l=i(function(t,e){var a;t.exports=(a=s,function(l){var t=a,e=t.lib,n=e.WordArray,r=e.Hasher,o=t.algo,S=[];!function(){for(var t=0;t<64;t++)S[t]=4294967296*l.abs(l.sin(t+1))|0}();var i=o.MD5=r.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var n=0;n<16;n++){var r=e+n,o=t[r];t[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var i=this._hash.words,a=t[e+0],s=t[e+1],c=t[e+2],u=t[e+3],l=t[e+4],p=t[e+5],d=t[e+6],h=t[e+7],f=t[e+8],v=t[e+9],y=t[e+10],m=t[e+11],w=t[e+12],g=t[e+13],b=t[e+14],_=t[e+15],A=i[0],x=i[1],q=i[2],R=i[3];A=k(A,x,q,R,a,7,S[0]),R=k(R,A,x,q,s,12,S[1]),q=k(q,R,A,x,c,17,S[2]),x=k(x,q,R,A,u,22,S[3]),A=k(A,x,q,R,l,7,S[4]),R=k(R,A,x,q,p,12,S[5]),q=k(q,R,A,x,d,17,S[6]),x=k(x,q,R,A,h,22,S[7]),A=k(A,x,q,R,f,7,S[8]),R=k(R,A,x,q,v,12,S[9]),q=k(q,R,A,x,y,17,S[10]),x=k(x,q,R,A,m,22,S[11]),A=k(A,x,q,R,w,7,S[12]),R=k(R,A,x,q,g,12,S[13]),q=k(q,R,A,x,b,17,S[14]),A=T(A,x=k(x,q,R,A,_,22,S[15]),q,R,s,5,S[16]),R=T(R,A,x,q,d,9,S[17]),q=T(q,R,A,x,m,14,S[18]),x=T(x,q,R,A,a,20,S[19]),A=T(A,x,q,R,p,5,S[20]),R=T(R,A,x,q,y,9,S[21]),q=T(q,R,A,x,_,14,S[22]),x=T(x,q,R,A,l,20,S[23]),A=T(A,x,q,R,v,5,S[24]),R=T(R,A,x,q,b,9,S[25]),q=T(q,R,A,x,u,14,S[26]),x=T(x,q,R,A,f,20,S[27]),A=T(A,x,q,R,g,5,S[28]),R=T(R,A,x,q,c,9,S[29]),q=T(q,R,A,x,h,14,S[30]),A=M(A,x=T(x,q,R,A,w,20,S[31]),q,R,p,4,S[32]),R=M(R,A,x,q,f,11,S[33]),q=M(q,R,A,x,m,16,S[34]),x=M(x,q,R,A,b,23,S[35]),A=M(A,x,q,R,s,4,S[36]),R=M(R,A,x,q,l,11,S[37]),q=M(q,R,A,x,h,16,S[38]),x=M(x,q,R,A,y,23,S[39]),A=M(A,x,q,R,g,4,S[40]),R=M(R,A,x,q,a,11,S[41]),q=M(q,R,A,x,u,16,S[42]),x=M(x,q,R,A,d,23,S[43]),A=M(A,x,q,R,v,4,S[44]),R=M(R,A,x,q,w,11,S[45]),q=M(q,R,A,x,_,16,S[46]),A=E(A,x=M(x,q,R,A,c,23,S[47]),q,R,a,6,S[48]),R=E(R,A,x,q,h,10,S[49]),q=E(q,R,A,x,b,15,S[50]),x=E(x,q,R,A,p,21,S[51]),A=E(A,x,q,R,w,6,S[52]),R=E(R,A,x,q,u,10,S[53]),q=E(q,R,A,x,y,15,S[54]),x=E(x,q,R,A,s,21,S[55]),A=E(A,x,q,R,f,6,S[56]),R=E(R,A,x,q,_,10,S[57]),q=E(q,R,A,x,d,15,S[58]),x=E(x,q,R,A,g,21,S[59]),A=E(A,x,q,R,l,6,S[60]),R=E(R,A,x,q,m,10,S[61]),q=E(q,R,A,x,c,15,S[62]),x=E(x,q,R,A,v,21,S[63]),i[0]=i[0]+A|0,i[1]=i[1]+x|0,i[2]=i[2]+q|0,i[3]=i[3]+R|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;e[r>>>5]|=128<<24-r%32;var o=l.floor(n/4294967296),i=n;e[15+(64+r>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),e[14+(64+r>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process();for(var a=this._hash,s=a.words,c=0;c<4;c++){var u=s[c];s[c]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return a},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});function k(t,e,n,r,o,i,a){var s=t+(e&n|~e&r)+o+a;return(s<<i|s>>>32-i)+e}function T(t,e,n,r,o,i,a){var s=t+(e&r|n&~r)+o+a;return(s<<i|s>>>32-i)+e}function M(t,e,n,r,o,i,a){var s=t+(e^n^r)+o+a;return(s<<i|s>>>32-i)+e}function E(t,e,n,r,o,i,a){var s=t+(n^(e|~r))+o+a;return(s<<i|s>>>32-i)+e}t.MD5=r._createHelper(i),t.HmacMD5=r._createHmacHelper(i)}(Math),a.MD5)});(a=d=d||{})[a.MTOP=1]="MTOP",a[a.MY=2]="MY",a[a.GATEWAY=3]="GATEWAY";var f,v=(e(y,f=Error),y);function y(){return null!==f&&f.apply(this,arguments)||this}function m(t){this.options=t||{},this.options.dataProxyGatewayUrl=this.options.dataProxyGatewayUrl||this.options.gatewayUrl}var w=(g.prototype.init=function(e,n){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return this.options=h({},e),this.proxy=n,this.tasks=[],this.inited=!0,[4,this.listenNetworkChange()];case 1:return t.sent(),this.flushGatewayRequestQueue(),this.pauseExecTask=!1,[2]}})})},g.prototype.listenNetworkChange=function(){return p(this,void 0,void 0,function(){var e,n=this;return k(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.exec({url:"my.getNetworkType"})];case 1:return e=t.sent(),this.networkType=e.networkType,window.my&&window.my.onNetworkStatusChange&&window.my.onNetworkStatusChange(function(t){t&&t.networkType&&(n.networkType=t.networkType)}),[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}})})},g.getRequestType=function(t){return 0===t.indexOf("mtop.")?d.MTOP:0===t.indexOf("my.")?d.MY:d.GATEWAY},g.prototype.verifyResponse=function(e,n,r){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:if(T(r,"mc-code")||T(e,"errCode")||T(e,"error_response.code"),n.__is_retry_task__)return this.tryThrowError(e,r),[2,e];t.label=1;case 1:return t.trys.push([1,3,,4]),this.tryThrowError(e,r),[2,e];case 2:return[2,t.sent()];case 3:throw t.sent();case 4:return[2]}})})},g.prototype.tryThrowError=function(t,e){var n=T(e,"mc-msg")||T(t,"errMsg")||T(t,"error_response.msg"),r=T(e,"mc-code")||T(t,"errCode")||T(t,"error_response.code");if(r&&"200"!=r){var o=new v(r+":::"+n);throw o.code=r,o.msg=n,o}},g.prototype.sendGatewayRequest=function(r){return p(this,void 0,void 0,function(){var e,n=this;return k(this,function(t){switch(t.label){case 0:return this.pauseExecTask?[2,new Promise(function(t,e){n.tasks.push({detail:r,success:t,fail:e})})]:[3,1];case 1:return r=this.createGatewayRequest(r),[4,this.proxy.apply(h({},r),d.GATEWAY)];case 2:return e=t.sent(),[4,this.verifyResponse(T(e,"data"),r,T(e,"headers"))];case 3:return[2,t.sent()]}})})},g.prototype.flushGatewayRequestQueue=function(o){var i=this;void 0===o&&(o=!1),this.tasks.forEach(function(t){var e=t.detail,n=t.success,r=t.fail;if(o)return r("初始化失败");i.exec(e,d.GATEWAY).then(n).catch(r)}),this.tasks=[]},g.prototype.exec=function(e,n){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:if(n=n||g.getRequestType(e.url),!this.inited)throw new Error("请先调用cloud.init()");return n!==d.GATEWAY?[3,2]:[4,this.sendGatewayRequest(e)];case 1:return[2,t.sent()];case 2:return[4,this.proxy.apply(e,n)];case 3:return[2,t.sent()]}})})},g.prototype.getHttpRequestSign=function(t,e,n,r,o){if(this.options.signSecret){var i=o;delete r["mc-sign"];var a=e+"\n"+u.stringify(l(i))+"\napplication/json\n"+Object.keys(r).filter(function(t){return/^mc-/.test(t)}).sort().map(function(t){return t.toLowerCase()+":"+r[t]}).join("\n")+"\n"+t+(n?"?"+n:"");return u.stringify(c(a,this.options.signSecret))}},g.prototype.createGatewayRequest=function(t){var e=this.options,n=e.sessionKey,r=e.appKey,o=e.requestId,i=e.miniappId,a=e.openId,s=e.unionId,c=e.cloudId;t.method="POST";var u=h(h({},t.headers),{"Content-Type":"application/json","mc-timestamp":""+Date.now(),"mc-session":n});a&&(u["mc-open-id"]=a),c&&(u["mc-cloud-id"]=c),s&&(u["mc-union-id"]=s),r&&(u["mc-appKey"]=r),i&&(u["mc-miniapp-id"]=i),o&&(u["mc-request-id"]=o),t.env&&(u["mc-env"]=t.env),this.networkType&&(u["mc-network"]=this.networkType),u["mc-session"]||delete u["mc-session"],t.rawData=t.rawData||t.data,"object"==typeof t.data&&(t.data=JSON.stringify(t.data));var l=this.getHttpRequestSign(t.url,t.method,"",u,t.data);return h(h({},t),{url:""+t.url,headers:h(h({},u),{sign:l,"eagleeye-traceid":o})})},g);function g(){this.inited=!1,this.pauseExecTask=!1}function b(t,e){this.request=e,this.options=t}new w;var _,A=(e(x,_=b),x.prototype.invoke=function(e,n,r,o){return void 0===r&&(r="main"),p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.fcRequest({fcName:e,handler:r,data:n,options:o})];case 1:return[2,t.sent()]}})})},x.prototype.fcRequest=function(e){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.request.exec({env:this.options.env||"online",url:"fc",data:e},d.GATEWAY)];case 1:return[2,t.sent()]}})})},n([o()],x.prototype,"invoke",null),x);function x(){return null!==_&&_.apply(this,arguments)||this}var q,M="mtop.taobao.miniapp.cloud.store.config.v2.get",E="mtop.taobao.miniapp.cloud.store.config.v2.seller.get",O="mtop.taobao.miniapp.cloud.store.file.v2.save",P="mtop.taobao.miniapp.cloud.store.file.v2.seller.save",R="mtop.taobao.miniapp.cloud.store.file.v2.delete",S="mtop.taobao.miniapp.cloud.store.file.v2.seller.delete",I="mtop.taobao.miniapp.cloud.store.file.v2.list",B="mtop.taobao.miniapp.cloud.store.file.v2.seller.list",H="other",C=(e(D,q=b),D.prototype.parseUploadResult=function(t,e){return this.parsePostUploadResult(t,e)},D.prototype.parsePostUploadResult=function(t,e){var n,r,o;try{var i=JSON.parse(e.data);r=i.fileId,n=i.url,o=i.message}catch(t){}return{imageUrl:n,specialId:r,message:o}},D.prototype.uploadFile=function(S){return p(this,void 0,void 0,function(){var e,n,r,o,i,a,s,c,u,l,p,d,h,f,v,y,m,w,g,b,_,A,x,q,R;return k(this,function(t){switch(t.label){case 0:e=S.filePath,n=S.fileType,r=void 0===n?H:n,o=S.fileName,i=void 0===o?"miniappfile":o,a=S.seller,s=void 0!==a&&a,c=S.dirId,t.label=1;case 1:return t.trys.push([1,3,,4]),l=s?E:M,[4,this.storageRequest(l,{newContainer:!0,cloudPath:i,fileType:r,sellerSpace:s,dirId:c})];case 2:return u=t.sent(),[3,4];case 3:throw p=t.sent(),new Error("获取配置错误"+(p.message||p.toString()));case 4:return d=T(u,["data","model",r],{}),h=d.url,f=void 0===h?"":h,v=d.formData,y=void 0===v?null:v,m=d.headers,(w={url:f,fileType:r,header:void 0===m?null:m,formData:y,filePath:e,fileName:"file"}).header&&w.header.Authorization&&(w.formData.Authorization=w.header.Authorization),i&&(w.formData.localFileName=Date.now()+"-"+function(t){if(!t)return"file";var e=t.lastIndexOf("/");return 0<=e?t.substr(e+1):t}(i)),w.header?"image"!==r&&(w.header.origin=w.header.origin||"https://miniapp-cloud.taobao.com",w.header.referer=w.header.referer||"https://miniapp-cloud.taobao.com"):delete w.header,w.formData||delete w.formData,[4,this.storageRequest("my.uploadFile",w)];case 5:if(g=t.sent(),b=this.parseUploadResult(r,g),_=b.imageUrl,A=b.specialId,x=b.message,!A)throw new Error(x||"upload exception:unknown error");return q={fileType:r,specialId:A,url:_,cloudPath:i,sellerSpace:s},[4,this.storageRequest(s?P:O,q)];case 6:if(!T(R=t.sent(),"data.model.fileId"))throw new Error(T(R,["result","msgInfo"],"上传文件失败"));return[2,T(R,"data.model")]}})})},D.prototype.deleteFile=function(c){return p(this,void 0,void 0,function(){var e,n,r,o,i,a,s;return k(this,function(t){switch(t.label){case 0:return e=c.fileId,n=c.fileType,r=void 0===n?H:n,o=c.seller,i=void 0!==o&&o,a=Array.isArray(e)?e:[e],a=JSON.stringify(a),[4,this.storageRequest(i?S:R,{fileType:r,fileIds:a,sellerSpace:i})];case 1:if(T(s=t.sent(),["data","model"]))return[2,!0];throw new Error(T(s,["data","msgInfo"]))}})})},D.prototype.getTempFileURL=function(s){return p(this,void 0,void 0,function(){var e,n,r,o,i,a;return k(this,function(t){switch(t.label){case 0:if(e=s.fileId,n=s.seller,r=void 0!==n&&n,!e)throw new Error("缺少fileId,请检查参数");return o=Array.isArray(e)?e:[e],o=JSON.stringify(o),[4,this.storageRequest(r?B:I,{fileIds:o,sellerSpace:r})];case 1:if(i=t.sent(),a=T(i,["data","model"]))return[2,a];throw new Error(T(i,["data","msgInfo"]))}})})},D.prototype.downloadByFileId=function(l){return p(this,void 0,void 0,function(){var e,n,r,o,i,a,s,c,u;return k(this,function(t){switch(t.label){case 0:if(e=l.fileId,n=l.cache,!e)throw new Error("缺少fileId,请检查参数");return r=Array.isArray(e)?e:[e],[4,this.storageRequest(I,{fileIds:JSON.stringify(r)})];case 1:o=t.sent(),i=T(o,["data","model"])||[],a=[],s=0,t.label=2;case 2:return s<i.length?(c=(i[s]||{}).url,[4,this._downloadByUrl(c,n)]):[3,5];case 3:(u=t.sent())&&a.push(u),t.label=4;case 4:return s++,[3,2];case 5:return[2,a]}})})},D.prototype.storageRequest=function(n,r,o){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e="test"===this.options.env?"test":"online",(r=r||{}).env=e,[4,this.request.exec({url:n,data:r},o)];case 1:return[2,t.sent()]}})})},D.prototype._downloadByUrl=function(r,o){return p(this,void 0,void 0,function(){var e,n;return k(this,function(t){switch(t.label){case 0:return r?o?[4,this.request.proxy.apply({url:"my.getStorage",data:{key:r}})]:[3,2]:[2,null];case 1:if(e=t.sent().data)return[2,e];t.label=2;case 2:return[4,this.request.exec({url:"my.downloadFile",data:{url:r}})];case 3:return n=t.sent().apFilePath,o?[4,this.request.exec({url:"my.setStorage",data:{key:r,data:n}})]:[3,5];case 4:t.sent(),t.label=5;case 5:return[2,n]}})})},n([o()],D.prototype,"uploadFile",null),n([o()],D.prototype,"deleteFile",null),n([o()],D.prototype,"getTempFileURL",null),n([o()],D.prototype,"downloadByFileId",null),D);function D(){return null!==q&&q.apply(this,arguments)||this}var j=(Object.defineProperty(G.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),G.prototype.aggregate=function(n){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return Array.isArray(n)||(n=[n]),e={aggregate_pipelines:n,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.aggregate",e)];case 1:return[2,t.sent()]}})})},G.prototype.count=function(n){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={filter:n,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.count",e)];case 1:return[2,t.sent()]}})})},G.prototype.deleteMany=function(n){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={filter:n,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.remove",e)];case 1:return[2,t.sent()]}})})},G.prototype.find=function(n,r){return void 0===r&&(r={}),p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={displayed_fields:r.projection,order_by:r.sort,skip:r.skip,limit:r.limit,filter:n,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.get",e)];case 1:return[2,t.sent()]}})})},G.prototype.replaceOne=function(n,r){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={filter:n,new_record:r,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.replace",e)];case 1:return[2,t.sent()]}})})},G.prototype.insertOne=function(n){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={record:n,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.add",e)];case 1:return[2,t.sent()]}})})},G.prototype.insertMany=function(n){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:if(e={records:n,collection_name:this._coll},!Array.isArray(n))throw new Error("带插入的数据只能为数组");return[4,this._db.dbRequest("miniapp.cloud.db.collection.addMany",e)];case 1:return[2,t.sent()]}})})},G.prototype.updateMany=function(n,r,o){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={filter:n,action:r,arrayFilters:o,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.update",e)];case 1:return[2,t.sent()]}})})},G.prototype.createIndex=function(n,r,o){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={index_name:n,unique:r,fields:o,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.index.create",e)];case 1:return[2,t.sent()]}})})},n([o()],G.prototype,"aggregate",null),n([o()],G.prototype,"count",null),n([o()],G.prototype,"deleteMany",null),n([o()],G.prototype,"find",null),n([o()],G.prototype,"replaceOne",null),n([o()],G.prototype,"insertOne",null),n([o()],G.prototype,"insertMany",null),n([o()],G.prototype,"updateMany",null),n([o()],G.prototype,"createIndex",null),G);function G(t,e){this._db=t,this._coll=e}var U,N=(e(z,U=b),z.prototype.collection=function(t){if(!t)throw new Error("集合名称不能为空");return new j(this,t)},z.prototype.createCollection=function(n,t){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={collection_name:n},[4,this.dbRequest("miniapp.cloud.db.collection.create",e)];case 1:return[2,t.sent()]}})})},z.prototype.dbRequest=function(n,r){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return"test"!==(e=this.options.env)&&(e="online"),r=h(h({},r),{env:e}),[4,this.request.exec({env:e,url:"db/"+n,data:r},d.GATEWAY)];case 1:return[2,t.sent()]}})})},n([o()],z.prototype,"createCollection",null),z);function z(){return null!==U&&U.apply(this,arguments)||this}var W,Y=(e(F,W=b),F.prototype.invoke=function(d){return p(this,void 0,void 0,function(){var e,i,a,s,c,u,l,p;return k(this,function(t){switch(t.label){case 0:return e=d.data,i=d.headers,a=d.authScope,s=d.api,e=e||{},Object.keys(e).forEach(function(t){e[t]="string"==typeof e[t]?e[t]:JSON.stringify(e[t])}),c={apiName:s,httpHeaders:i,data:e},[4,this.topRequest(c)];case 1:if(!T(u=t.sent(),"error_response"))return[2,u];if(l=T(u,"error_response.code"),(p=my&&my.canIUse("qn.cleanToken"))&&!a&&(a="*"),26!=l&&27!=l&&53!=l||!a)return[3,9];t.label=2;case 2:return t.trys.push([2,8,,9]),p?(console.log("call my.qn.cleanToken"),[4,my.qn.cleanToken()]):[3,4];case 3:t.sent(),t.label=4;case 4:return[4,(n=my.authorize,r={scopes:a},n?(r=r||{},new Promise(function(t,e){n.call(o||my,h(h({},r),{success:t,fail:e}))})):Promise.reject("未实现my.api"))];case 5:return[4,t.sent()];case 6:return t.sent(),[4,this.topRequest(c)];case 7:return T(u=t.sent(),"error_response")?[3,9]:[2,u];case 8:return t.sent(),[3,9];case 9:throw new Error(""+JSON.stringify(T(u,"error_response")))}var n,r,o})})},F.prototype.topRequest=function(e){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.request.exec({env:this.options.env||"online",url:"top",data:e},d.GATEWAY)];case 1:return[2,t.sent()]}})})},n([o()],F.prototype,"invoke",null),F);function F(){return null!==W&&W.apply(this,arguments)||this}var J,K=(e(L,J=b),L.prototype.invoke=function(o){return p(this,void 0,void 0,function(){var e,n,r;return k(this,function(t){switch(t.label){case 0:return e=o.data,n=o.headers,r=o.api,[4,this.topRequest({apiName:r,httpHeaders:n,data:e})];case 1:return[2,t.sent()]}})})},L.prototype.topRequest=function(e){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.request.exec({url:"process",data:e},d.GATEWAY)];case 1:return[2,t.sent()]}})})},n([o()],L.prototype,"invoke",null),L);function L(){return null!==J&&J.apply(this,arguments)||this}var Q,X=(e($,Q=b),$.prototype.invoke=function(i){return p(this,void 0,void 0,function(){var e,n,r,o;return k(this,function(t){switch(t.label){case 0:return e=i.data,n=i.headers,r=i.api,o=i.targetAppKey,[4,this.qimenRequest({apiName:r,httpHeaders:n,targetAppKey:o,data:e})];case 1:return[2,t.sent()]}})})},$.prototype.qimenRequest=function(e){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.request.exec({env:this.options.env||"online",url:"qimen",data:e},d.GATEWAY)];case 1:return[2,t.sent()]}})})},n([o()],$.prototype,"invoke",null),$);function $(){return null!==Q&&Q.apply(this,arguments)||this}var V,Z=(e(tt,V=b),tt.prototype.httpRequest=function(s){return p(this,void 0,void 0,function(){var e,n,r,o,i,a;return k(this,function(t){switch(t.label){case 0:return e=s.body,n=s.params,r=s.headers,o=s.path,i=s.method,a=s.exts,[4,this.innerRequest({path:o,headers:r,body:e,queryString:n,method:i,options:a})];case 1:return[2,t.sent()]}})})},tt.prototype.innerRequest=function(e){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.request.exec({env:this.options.env||"online",url:"cloudHttp",data:e},d.GATEWAY)];case 1:return[2,t.sent()]}})})},n([o()],tt.prototype,"httpRequest",null),tt);function tt(){return null!==V&&V.apply(this,arguments)||this}var et,nt=(e(rt,et=Error),rt.prototype.toString=function(){return(this.code||"")+" "+(this.message||"")},rt);function rt(){return null!==et&&et.apply(this,arguments)||this}var ot,it=(e(at,ot=m),at.getMtopErrorMsg=function(t){var e=new nt;if(!t)return e.code="500",e.message="mtop请求错误",e;var n,r,o=t.ret&&t.ret[0]&&t.ret[0].split("::");return t.data=t.data||T(t,["err","data"]),t.data&&t.data.errCode&&(n=t.data.errCode,r=t.data.errMessage||t.data.errMsg),t.data&&t.data.errorCode&&(n=t.data.errorCode),t.data&&t.data.errorMessage&&(r=t.data.errorMessage),t.data&&t.data.success||o&&"SUCCESS"===o[0]&&!n?void 0:(n=n||(o&&"FAIL_SYS_SESSION_EXPIRED"===o[0]?"904":"500"),r=r||o&&o[1]||"mtop请求错误",e.code=n,e.message=r,e)},at.GATEWAY_APIS={"db/miniapp.cloud.db.collection.create":"mtop.taobao.dataproxy.collection.create","db/miniapp.cloud.db.index.create":"mtop.taobao.dataproxy.index.create","db/miniapp.cloud.db.collection.aggregate":"mtop.taobao.dataproxy.record.aggregate","db/miniapp.cloud.db.collection.count":"mtop.taobao.dataproxy.record.count","db/miniapp.cloud.db.collection.remove":"mtop.taobao.dataproxy.record.delete","db/miniapp.cloud.db.collection.get":"mtop.taobao.dataproxy.record.select","db/miniapp.cloud.db.collection.replace":"mtop.taobao.dataproxy.record.replace","db/miniapp.cloud.db.collection.add":"mtop.taobao.dataproxy.record.insert","db/miniapp.cloud.db.collection.addMany":"mtop.taobao.dataproxy.record.batch.insert","db/miniapp.cloud.db.collection.update":"mtop.taobao.dataproxy.record.update",fc:"mtop.miniapp.cloud.invoke.fc",top:"mtop.miniapp.cloud.invoke.top",qimen:"mtop.miniapp.cloud.invoke.qimen.cloud",process:"mtop.miniapp.cloud.invoke.process",cloudHttp:"mtop.miniapp.cloud.application.request"},at);function at(){var t=null!==ot&&ot.apply(this,arguments)||this;return t.sendMtop=function(i,a,s){return p(t,void 0,void 0,function(){return k(this,function(t){return console.log("sendMtop",a),[2,new Promise(function(n,r){var e=1,o=function(){my.sendMtop(h(h({api:i,v:"1.0",data:a,method:"POST",needLogin:!0,sessionOption:"AutoLoginAndManualLogin"},s),{success:function(t){var e=at.getMtopErrorMsg(t);e?r(e):n(t)},fail:function(t){if(1===t.error_type&&0<e)return--e,o();r(at.getMtopErrorMsg(t))}}))};o()})]})})},t.invokeMyApi=function(n,r){return p(t,void 0,void 0,function(){return k(this,function(t){return[2,new Promise(function(t,e){return n=n.replace(/^my\./,""),my[n](h(h({},r),{success:t,fail:e}))})]})})},t.sendHttpRequest=function(r,o,i,a){return p(t,void 0,void 0,function(){var e=this;return k(this,function(t){return[2,new Promise(function(n,t){my.httpRequest({url:e.options.gatewayUrl+"/"+r,data:o,dataType:"text",method:a,headers:i,success:function(e){try{n(h(h({},e),{data:JSON.parse(e.data)}))}catch(t){n(h(h({},e),{data:e.data}))}},fail:t})})]})})},t.apply=function(u,l){return p(t,void 0,void 0,function(){var e,n,r,o,i,a,s,c;return k(this,function(t){switch(t.label){case 0:return e=u.url,n=u.data,r=u.headers,o=u.mtopOptions,i=u.method,l!==d.MTOP?[3,2]:[4,this.sendMtop(e,n,o)];case 1:return[2,t.sent()];case 2:return l!==d.GATEWAY?[3,8]:this.options.gatewayUrl?[4,this.sendHttpRequest(e,n,r,i)]:[3,4];case 3:return[2,t.sent()];case 4:return t.trys.push([4,6,,7]),u.rawData&&Object.keys(u.rawData).forEach(function(t){"object"==typeof u.rawData[t]&&(u.rawData[t]=JSON.stringify(u.rawData[t]))}),[4,this.sendMtop(at.GATEWAY_APIS[e],h(h({},u.rawData),{protocols:JSON.stringify(r)}),o)];case 5:return a=t.sent(),(s=a&&a.data||{}).errCode?[2,{headers:{"mc-code":s.errCode,"mc-msg":s.errMessage},data:{}}]:[2,{headers:{"mc-code":200,"mc-msg":"请求成功"},data:T(s,["data"])||{}}];case 6:return(c=t.sent())&&c.code?[2,{headers:{"mc-code":c.code,"mc-msg":c.message}}]:[2,{headers:{"mc-code":500,"mc-msg":c.message||c}}];case 7:return[3,10];case 8:return[4,this.invokeMyApi(e,n)];case 9:return[2,t.sent()];case 10:return[2]}})})},t}var st=(ct.prototype.init=function(i,a){return p(this,void 0,void 0,function(){var n,r,o;return k(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=i.env,n="string"==typeof(e=e||"online")?{database:e,file:e,function:e,message:e}:(e.database=e.database||"online",e.file=e.file||"online",e.function=e.function||"online",e.message=e.message||"online",e),r=new w,this.db=new N({env:n.database},r),this.function=new A({env:n.function},r),this.file=new C({env:n.file},r),this.qimenApi=new X({env:n.database},r),this.topApi=new Y({env:n.database},r),this.processApi=new K({env:n.database},r),this.application=new Z({env:n.database},r),[4,r.init(h({},i),a||new it({gatewayUrl:i.__gatewayUrl}))];case 1:return t.sent(),[2,!0];case 2:return o=t.sent(),console.error("SDK初始化失败 ",o),[3,3];case 3:return[2,!1]}var e})})},ct);function ct(){}var ut=new st;t.Cloud=st,t.default=ut,Object.defineProperty(t,"__esModule",{value:!0})});
{
"_args": [
[
"@tbmp/mp-cloud-sdk@1.4.1",
"/Users/wanghongyuan/taobao_mini/aupres_bubbleSurviva/aupres_c_client/client"
]
],
"_from": "@tbmp/mp-cloud-sdk@1.4.1",
"_id": "@tbmp/mp-cloud-sdk@1.4.1",
"_inBundle": false,
"_integrity": "sha512-h3xz4q22WGgxlSe5kqkaHK3C1fjWVlXHRQWKbIiecRJQPPoa5jok0LAkZlsLxvfa24ub4Pi34+a8Xjja2hlFTw==",
"_location": "/@tbmp/mp-cloud-sdk",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@tbmp/mp-cloud-sdk@1.4.1",
"name": "@tbmp/mp-cloud-sdk",
"escapedName": "@tbmp%2fmp-cloud-sdk",
"scope": "@tbmp",
"rawSpec": "1.4.1",
"saveSpec": null,
"fetchSpec": "1.4.1"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/@tbmp/mp-cloud-sdk/-/mp-cloud-sdk-1.4.1.tgz",
"_spec": "1.4.1",
"_where": "/Users/wanghongyuan/taobao_mini/aupres_bubbleSurviva/aupres_c_client/client",
"author": "",
"description": "",
"gitHead": "f69d455f62dcf8b82983b291a0de742bc91b3390",
"license": "ISC",
"main": "index.js",
"name": "@tbmp/mp-cloud-sdk",
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"types": "./types/platforms/mp/index.d.ts",
"version": "1.4.1"
}
import { Db } from "./db";
export interface IFindOptions {
/**
* 查询的文档数量限制
*/
limit?: number;
/**
* 跳过的文档数量
*/
skip?: number;
/**
* 排序规则
*/
sort?: object;
/**
* 查询后过滤的字段
*/
projection?: object;
}
export declare class CollectionReference {
/**
* 初始化
*
* @internal
*
* @param db - 数据库的引用
* @param coll - 集合名称
*/
private _db;
private _coll;
constructor(db: Db, coll: string);
/**
* 读取集合名字
*/
readonly name: string;
/**
* 对集合执行聚合查询
* @param pipeline 聚合查询对象
*/
aggregate(pipeline: object | object[]): Promise<any>;
/**
* 获取集合中复合条件的记录数量
* @param filter 过滤条件
*/
count(filter: object): Promise<any>;
/**
* 删除集合中的一批记录
* @param filter 过滤条件
*/
deleteMany(filter: object): Promise<any>;
/**
* 查找集合中符合条件的所有记录
* @param filter 过滤条件
* @param options 查询配置项
*/
find(filter: any, options?: IFindOptions): Promise<any>;
/**
* 替换一条数据
* @param filter 过滤条件
* @param data 新数据
*/
replaceOne(filter: object, data: object): Promise<any>;
/**
* 在集合中添加一条记录
* @param data 带插入的数据
*/
insertOne(data: object): Promise<any>;
/**
* 在集合中添加一批记录
* @param data 待插入的数据,只能为数组
*/
insertMany(data: object[]): Promise<any>;
/**
*
* @param filter 过滤条件
* @param data 更新规则
*
*/
updateMany(filter: object, data: object): Promise<any>;
}
import { CollectionReference } from "./collection";
import { IAsyncInvokeOptions } from "../../shared/types";
import { ICloudService } from "../interface/cloudService";
export declare class Db extends ICloudService {
/**
* 获取集合的引用
*
* @param collName - 集合名称
*/
collection(collName: string): CollectionReference;
/**
* 创建集合
*/
createCollection(name: string, options: {
collName: string;
} & IAsyncInvokeOptions): Promise<any>;
dbRequest(action?: string, params?: any): Promise<any>;
}
import { IAsyncInvokeOptions } from '../../shared/types';
import { ICloudService } from '../interface/cloudService';
export interface ICallFunctionOptions extends IAsyncInvokeOptions {
name: string;
data: any;
}
export interface IInvokeMethod {
(IAsyncInvokeOptions: any): void;
}
export default class CloudFunction extends ICloudService {
invoke(name: string, data?: object, handler?: string): Promise<any>;
private fcRequest;
}
import { Request } from "../../shared/request";
export interface ICloudServiceOptions {
env?: 'test' | 'online' | 'pre';
}
export declare abstract class ICloudService {
options: ICloudServiceOptions;
request: Request;
constructor(options: ICloudServiceOptions, request: Request);
init?(): void;
}
import Powermsg from '@ali/lib-powermsg-sdk';
import { Env } from '../../shared/types';
export default class Client {
env: Env;
pmg: Powermsg;
deviceId: string;
initing: boolean;
queue: (() => void)[];
config: any;
constructor(env: Env);
init: () => Promise<any>;
onMessage: (callback: any) => Promise<() => void>;
private createPwgInstance;
}
import { ICloudService, ICloudServiceOptions } from "../interface/cloudService";
import Client from './client';
import Server from './server';
export default class Message extends ICloudService {
server: Server;
client: Client;
constructor(options: ICloudServiceOptions);
}
import { Request } from '../../shared/request';
import { Env } from "../../../packages/mp-cloud-node-sdk/types/shared/types";
interface IPushOptions {
subType: number;
deviceId?: string;
data: object;
pushType: string;
}
export default class Server {
env: Env;
request: Request;
constructor(env: Env, request: Request);
push(options: IPushOptions): Promise<any>;
}
export {};
import {ICloudService} from "../../interface/cloudService";
export default class Application extends ICloudService {
httpRequest(options: {path: string, params?: any, body?: any, headers?: any, method?: string, exts?: any}): Promise<any>;
}
import {ICloudService} from "../../interface/cloudService";
export default class Process extends ICloudService {
invoke(options: { api: string, data?: any, headers?: any }): Promise<any>;
private topRequest;
}
import {ICloudService} from "../../interface/cloudService";
export default class Qimen extends ICloudService {
invoke(options: { api: string, data?: any, targetAppKey?: any, headers?: any }): Promise<any>;
private topRequest;
}
import {ICloudService} from "../../interface/cloudService";
export default class Top extends ICloudService {
invoke(options: { api: string, data?: any, headers?: any, authScope?: string }): Promise<any>;
private topRequest;
}
import { IAsyncInvokeOptions } from "../../shared/types";
import { ICloudService } from "../interface/cloudService";
export interface IUploadFileOptions extends IAsyncInvokeOptions {
/**
* 选择到的本地文件路径
*/
filePath: string;
/**
* 文件类型, image/audio/video
*/
fileType: FileTypes;
/**
* 云存储文件名可带路径, 如a/xxx.jpg
*/
fileName?: string;
/**
* web环境上传 file对象
*/
file?: any;
}
export interface IDownloadFileOptions extends IAsyncInvokeOptions {
fileType?: FileTypes;
fileId: string;
}
export interface ITempFileURLOptions extends IAsyncInvokeOptions {
fileList: string[];
}
export declare type IDeleteFileOptions = IDownloadFileOptions;
export declare type FileTypes = "image" | "video" | "audio";
export default class CloudStorage extends ICloudService {
private parseUploadResult;
private parsePostUploadResult;
private parseAusUploadResult;
/**
* 文件上传
* 1.获取上传配置
* 2.调用my.api上传
* 3.建立存储关系
* @param options
*/
uploadFile(options: IUploadFileOptions): Promise<any>;
/**
* 删除文件
* @param options
*/
deleteFile(options: IDeleteFileOptions): Promise<boolean>;
/**
* 根据文件id(cloud://)获取授权的url
* @param options
*/
getTempFileURL(options: IAsyncInvokeOptions & {
fileType: string;
fileId: string | string[];
}): Promise<any>;
/**
* 从服务端获取文件并在本地读取
* @param options
*/
readRemoteFile(options: IAsyncInvokeOptions & {
url: string;
}): Promise<ArrayBuffer>;
/**
* 存储的请求代理, 统一sdk环境和存储环境
* @param action
* @param data
* @param requestType
*/
private storageRequest;
}
import { Cloud } from '../mp';
declare const cloudInstance: Cloud;
export default cloudInstance;
import { Cloud as MpCloud } from '../mp';
import { ICloudOptions } from '../../shared/types';
import Client from '../../core/message/client';
import { IProxy } from '../../shared/request';
export declare class Cloud extends MpCloud {
message: {
client: Client;
};
init(options: ICloudOptions, proxy: IProxy): Promise<boolean>;
}
declare const _default: Cloud;
export default _default;
import {IProxy} from '../../shared/request';
import {ICloudOptions} from '../../shared/types';
import CloudFunction from '../../core/functions';
import CloudStorage from '../../core/storage';
import Db from '../../core/db';
import Top from '../../core/openApi/client/top';
import Qimen from '../../core/openApi/client/qimen';
import Process from '../../core/openApi/client/process';
import Application from '../../core/openApi/client/application';
export declare class Cloud {
function: CloudFunction;
file: CloudStorage;
db: Db;
topApi: Top;
qimenApi: Qimen;
processApi: Process;
application: Application;
init(options: ICloudOptions, proxy?: IProxy): Promise<boolean>;
}
declare const _default: Cloud;
export default _default;
import { IProxy, IRequestOptions } from '../../shared/request';
import { ICloudOptions } from '../../shared/types';
import CloudFunction from '../../core/functions';
import Database from '../../core/db';
import Server from '../../core/message/server';
import Top from '../../core/openApi/server/top';
export declare class Cloud {
private _options;
db: Database;
function: CloudFunction;
message: {
server: Server;
};
private request;
topApi: Top;
setEnv(env: any): void;
init(options: ICloudOptions & IRequestOptions, proxy: IProxy): void;
}
export declare function cloud(context: any, options: ICloudOptions): Cloud;
export declare const BASE_APIS: {
GET_SESSION: string;
GET_SECRET: string;
};
export declare const STORAGE_KEYS: {
SECRET: string;
};
export declare const ENV_CONFIG: {
pre: {
gw: string;
};
online: {
gw: string;
};
};
import { IAsyncInvokeOptions } from "./types";
export declare function invokeCallback(options: IAsyncInvokeOptions, asyncTask: Promise<any>): Promise<void>;
export declare function myApiPromisify(method: (options: any) => void, options?: any): Promise<any>;
export declare function getUserId(): Promise<string>;
export declare function noop(): void;
export declare function invokeTaskCallback(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
export declare function safeAccess(props: any, keys: string[] | string, def?: any): any;
export declare function getValue(key: string): Promise<any>;
export declare function setValue(key: string, data: any): Promise<any>;
export interface IRequestOptions {
appKey?: string,
sourceAppKey?: string,
requestAppKey?:string,
miniappId?: string,
sourceMiniAppId?: string,
appOwnerOpenId?: string,
signSecret?: string;
sessionKey?: string;
requestId?: string;
cloudId?: string;
openId?: string;
unionId?: string;
userNick?: string,
mixNick?: string,
session?: string;
accessToken?: string;
env?: string;
}
export declare enum RequestTypes {
MTOP = 1,
MY = 2,
GATEWAY = 3
}
export interface IGatewayResponse {
error_response: {
code: string;
};
}
export interface IRequestDetail {
url: string;
data?: any;
rawData?: any;
method?: string;
headers?: any;
dataType?: string;
v?: string;
__is_retry_task__?: boolean;
env?: string;
mtopOptions?: any;
}
export interface IProxyOptions {
gatewayUrl?: string;
dataProxyGatewayUrl?: string;
}
export declare abstract class IProxy {
options: IProxyOptions;
abstract apply(task: IRequestDetail, requestType?: RequestTypes): Promise<any>;
constructor(options?: IProxyOptions);
}
export declare class Request {
networkType?: string;
options: IRequestOptions;
tasks: {
detail: IRequestDetail;
success?: (res: any) => void;
fail?: (res: any) => void;
}[];
proxy: IProxy;
inited: boolean;
pauseExecTask: boolean;
init(options: IRequestOptions, proxy: IProxy): Promise<void>;
listenNetworkChange(): Promise<void>;
static getRequestType(url: string): RequestTypes;
/**
* 验证响应结果, 特定情况下重试请求
* @param res
*/
private verifyResponse;
private tryThrowError;
private sendGatewayRequest;
flushGatewayRequestQueue(reject?: boolean): void;
exec(detail: IRequestDetail, requestType?: RequestTypes): Promise<any>;
/**
*
* @param url 网关请求
* @param method 请求方法
* @param queryString
* @param headers mc_开头的http header
* @param content json body
*/
private getHttpRequestSign;
/**
* 对网关请求签名
* @param detail
*/
private createGatewayRequest;
}
export declare const request: Request;
export interface ICallback {
(res: any): void;
}
export interface IHttpRequestOptions extends IAsyncInvokeOptions {
url: string;
method?: string;
headers?: any;
data?: any;
dataType?: string;
}
export declare type Env = 'test' | 'pre' | 'online';
export declare type Envs = {
database: Env;
file: Env;
function: Env;
message: Env;
};
export interface ICloudOptions {
env?: Env | Envs;
appKey?: string;
}
declare global {
interface Window {
}
var my: {
httpRequest: (options: IHttpRequestOptions) => void;
sendMtop: (options: any) => void;
alert: (options: {
title?: string;
content?: string;
}) => void;
};
var NODE_PLATFORM: boolean;
var SDK_VERSION: string;
}
export interface IAsyncInvokeOptions {
success?: ICallback;
fail?: ICallback;
complete?: ICallback;
}
export declare type AsyncInvokeResult = Promise<any> | void;
export declare type Constructor<T = {}> = new (...args: any[]) => T;
import { IAsyncInvokeOptions, Env, Envs } from "./types";
export declare function noop(): void;
export declare function invokeTaskCallback(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
export declare function safeAccess(props: any, keys: string[] | string, def?: any): any;
export declare function invokeCallback(options: IAsyncInvokeOptions, asyncTask: Promise<any>): Promise<void>;
export declare function myApiPromisify(method: (options: any) => void, options?: any): Promise<any>;
export declare function getUserId(): Promise<string>;
export declare function getEnvs(env: Env | Envs): Envs;
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"_args": [
[
"fyge-tbmini@1.2.8",
"/Users/wanghongyuan/taobao_mini/aupres_bubbleSurviva/aupres_c_client/client"
]
],
"_from": "fyge-tbmini@1.2.8",
"_id": "fyge-tbmini@1.2.8",
"_inBundle": false,
"_integrity": "sha512-Gf/RRC7qNZ0fMkb1xL9Rl+y8isK1noGoDrm2UVdAQsxCa+Mn8o7CMHaf+AkNvJcitsh0kgXqI/bQVioSF3PQIg==",
"_location": "/fyge-tbmini",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "fyge-tbmini@1.2.8",
"name": "fyge-tbmini",
"escapedName": "fyge-tbmini",
"rawSpec": "1.2.8",
"saveSpec": null,
"fetchSpec": "1.2.8"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/fyge-tbmini/-/fyge-tbmini-1.2.8.tgz",
"_spec": "1.2.8",
"_where": "/Users/wanghongyuan/taobao_mini/aupres_bubbleSurviva/aupres_c_client/client",
"author": {
"name": "MrKwon"
},
"dependencies": {},
"description": "淘宝小程序canvas渲染引擎",
"devDependencies": {
"dts-bundle": "^0.7.3",
"glob": "^7.1.6",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-progress": "^1.1.2",
"rollup-plugin-typescript": "^1.0.1",
"rollup-plugin-typescript2": "^0.25.2",
"rollup-plugin-uglify": "^6.0.3",
"ts-loader": "^4.0.0",
"typescript": "^2.7.2",
"uglifyjs-webpack-plugin": "^2.1.2",
"webpack": "^4.1.0",
"webpack-cli": "^3.3.2"
},
"keywords": [
"淘宝小程序,canvas,webgl"
],
"license": "ISC",
"main": "./build/fyge.min.js",
"name": "fyge-tbmini",
"scripts": {
"build": "webpack",
"declare": "node scripts/declare.js src/index.ts",
"dev": "webpack -w",
"dev1": "rollup -c -m -w",
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "webpack --watch"
},
"types": "./build/FYGE.d.ts",
"version": "1.2.8"
}
# SvgaParser
1.0.2版本支持web版本解析,包体小,web应用尽量用这个
1.1.0及以后版本同时支持web和微信小程序及淘宝小程序解析
(淘宝小程序使用,链接必须使用阿里系的白名单域名,或者云存储cloud://链接)
其他版本都是坏的
单纯将svga文件解析成动画图片及动画数据。
### 网页使用
```html
<script type="text/javascript" src="../build/svgaParser.min.js"></script>
<script>
SvgaParser.loadSvga("./svga/step1-1.svga", (v) => {
console.log(v)
}, (err) => { console.log(err) })
</script>
```
### npm使用
```js
npm install svga-parser
import { loadSvga } from "svga-parser";
loadSvga("./svga/step1-1.svga", (v) => {
console.log(v)
}, (err) => { console.log(err) })
```
declare module SvgaParser {
/**
* 加载方法
* @param url 资源路径
* @param success
* @param failure
*/
export function loadSvga(url: string, success: (videoItem: VideoEntity) => void, failure: (err: string) => void): void;
/**
* 导出只是当作类型接口用
*/
export interface VideoEntity {
/**
* SVGA 文件版本
*/
version: string;
/**
* 影片尺寸
*/
videoSize: {
width: number;
height: number;
};
/**
* 帧率,60,30等每秒
*/
FPS: number;
/**
* 总帧数
*/
frames: number;
/**
* base64图片数据记录
*/
images: {
[key: string]: string
};
/**
* 图片是否已被缓存,缓存全局,注意名字覆盖
*/
hasBeenCached: boolean;
/**
* sprite对象数据
*/
sprites: SpriteEntity[];
}
interface SpriteEntity {
/**
* 标识
*/
matteKey: string;
/**
* 图片key值
*/
imageKey: string;
/**
* 帧数据数组
*/
frames: FrameEntity[];
}
/**
* 还有很多其他数据,暂不需要,比如矢量路径和遮罩路径暂时都无
*/
interface FrameEntity {
/**
* 透明度
*/
alpha: number;
/**
* 2维矩阵数据
*/
transform: {
a: number,
b: number,
c: number,
d: number,
tx: number,
ty: number,
};
}
}
declare module "svga-parser" { export = SvgaParser; }
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"_args": [
[
"svga-parser@1.1.0",
"/Users/wanghongyuan/taobao_mini/aupres_bubbleSurviva/aupres_c_client/client"
]
],
"_from": "svga-parser@1.1.0",
"_id": "svga-parser@1.1.0",
"_inBundle": false,
"_integrity": "sha512-OjjtzPGC1ZdCWSWvldhXcB0CAz4ZOeoWEp0P9l4Lz7UtLM9f+DAYAYXKCXBWnRZvJevgkY/gniO/Bt89X0cKKw==",
"_location": "/svga-parser",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "svga-parser@1.1.0",
"name": "svga-parser",
"escapedName": "svga-parser",
"rawSpec": "1.1.0",
"saveSpec": null,
"fetchSpec": "1.1.0"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/svga-parser/-/svga-parser-1.1.0.tgz",
"_spec": "1.1.0",
"_where": "/Users/wanghongyuan/taobao_mini/aupres_bubbleSurviva/aupres_c_client/client",
"author": {
"name": "MrKwon"
},
"dependencies": {},
"description": "1.0.2版本支持web版本解析,包体小,web应用尽量用这个",
"devDependencies": {
"eval5": "^1.4.5",
"protobufjs": "^6.8.0",
"ts-loader": "^4.0.0",
"typescript": "^2.7.2",
"uglifyjs-webpack-plugin": "^2.1.2",
"webpack": "^4.1.0",
"webpack-cli": "^3.3.2"
},
"keywords": [
"svga"
],
"license": "ISC",
"main": "build/svgaParser.min.js",
"name": "svga-parser",
"scripts": {
"build": "webpack",
"dev": "webpack -w",
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "webpack --watch"
},
"types": "build/SvgaParser.d.ts",
"version": "1.1.0"
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="full-screen" content="true" />
<meta name="screen-orientation" content="portrait" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<!-- <meta name="viewport" content="width=device-width,minimum-scale=1.0,user-scalable=no"> -->
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: white;
}
/* .top {
width: 100%;
height: 100px;
} */
</style>
</head>
<body>
<script type="text/javascript" src="../build/svgaParser.min.js"></script>
<script>
SvgaParser.loadSvga("./svga/step1-1.svga", (v) => {
console.log(v)
}, (err) => { console.log(err) })
</script>
</body>
</html>
\ No newline at end of file
{
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@tbmp/mp-cloud-sdk": {
"version": "1.4.2",
"resolved": "https://registry.npm.taobao.org/@tbmp/mp-cloud-sdk/download/@tbmp/mp-cloud-sdk-1.4.2.tgz",
"integrity": "sha1-/49BtdDaNJ6H9+f9DDBMPgt/BbQ="
}
"name": "threeSquirrel",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@tbmp/mp-cloud-sdk": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/@tbmp/mp-cloud-sdk/-/mp-cloud-sdk-1.4.1.tgz",
"integrity": "sha512-h3xz4q22WGgxlSe5kqkaHK3C1fjWVlXHRQWKbIiecRJQPPoa5jok0LAkZlsLxvfa24ub4Pi34+a8Xjja2hlFTw=="
},
"fyge-tbmini": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/fyge-tbmini/-/fyge-tbmini-1.2.8.tgz",
"integrity": "sha512-Gf/RRC7qNZ0fMkb1xL9Rl+y8isK1noGoDrm2UVdAQsxCa+Mn8o7CMHaf+AkNvJcitsh0kgXqI/bQVioSF3PQIg=="
},
"svga-parser": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/svga-parser/-/svga-parser-1.1.0.tgz",
"integrity": "sha512-OjjtzPGC1ZdCWSWvldhXcB0CAz4ZOeoWEp0P9l4Lz7UtLM9f+DAYAYXKCXBWnRZvJevgkY/gniO/Bt89X0cKKw=="
}
}
}
{
"name": "",
"name": "threeSquirrel",
"version": "1.0.0",
"main": "",
"license": "MIT",
"dependencies": {
"@tbmp/mp-cloud-sdk": "*",
"fyge-tbmini": "^1.3.7"
"fyge-tbmini": "^1.2.8",
"svga-parser": "^1.1.0"
}
}
.goods-page-container {
width: 100%;
min-height: 100vh;
background: url('//yun.duiba.com.cn/taobaomini/aupresViva/page_bg.png') no-repeat;
background-size: 100% 1624rpx;
overflow: hidden;
}
.goods-page-container__title {
width: 750rpx;
height: 103rpx;
background: url('//yun.duiba.com.cn/taobaomini/aupresViva/goods_bg.png') no-repeat;
background-size: 100% 100%;
display: table-cell;
text-align: center;
vertical-align: middle;
}
.goods-page-container__title text {
display: inline-block;
font-size:40rpx;
font-family:SourceHanSansSC;
font-weight:400;
color:rgba(92,89,177,1);
}
.goods-page-container-scroll {
width: 100%;
height: 90vh;
}
.goods-page-container__content {
width: 100%;
padding: 0 32rpx;
display: flex;
flex-wrap: wrap;
}
.goods-page-container__content-item {
width:326rpx;
height:410rpx;
background: #F7F5FF;
border-radius:14rpx 13rpx 14rpx 14rpx;
margin-bottom: 37rpx;
}
.goods-page-container__content-item:nth-child(even) {
margin-left: 16rpx;
}
.goods-page-container__content-item__img {
width:326rpx;
height: 281rpx;
}
.goods-page-container__content-item__img image {
width: 100%;
height: 100%;
}
.goods-page-container__content-item__desc {
width: 100%;
height: 129rpx;
background:rgba(243,240,255,1);
padding: 20rpx 0 0 20rpx;
}
.goods-page-container__content-item__desc-name {
width: 100%;
font-size:24rpx;
font-family:SourceHanSansSC;
font-weight:300;
color:rgba(107,107,107,1);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.goods-page-container__content-item__desc-prize {
margin-top: 22rpx;
font-size:36rpx;
font-family:SourceHanSansSC;
font-weight:bold;
color:rgba(239,82,95,1);
}
\ No newline at end of file
<view class="goods-page-container">
<view class="goods-page-container__title"><text>购买商品得游戏次数</text></view>
<scroll-view scroll-y="{{true}}" class="goods-page-container-scroll">
<view class="goods-page-container__content">
<view class="goods-page-container__content-item" a:for="{{goodsList}}" data-item="{{item}}" onTap="goToBuy">
<view class="goods-page-container__content-item__img">
<image mode="scaleToFill" src="{{item.image}}"/>
</view>
<view class="goods-page-container__content-item__desc">
<view class="goods-page-container__content-item__desc-name">{{item.name}}</view>
<view class="goods-page-container__content-item__desc-prize">{{'¥'+item.price || 0.00}}</view>
</view>
</view>
</view>
</scroll-view>
</view>
\ No newline at end of file
import {
commonToast,
openDetail,
navigateToOutside,
navigateTo, } from '../../utils/utils';
import API from '../../api'
const app = getApp();
Page({
data: {
goodsList: []
},
onLoad() {
this.initPage()
},
async initPage() {
let { activityId } = app
let { success, data } = await API.getGoodsList({ activityId }).catch(res => {
res && commonToast(res)
}) || {}
if(success) {
this.setData({ goodsList: data })
}
},
/**跳转购买商品页 */
async goToBuy(e) {
let { item: { id, url } } = e.target.dataset
let { success } = await openDetail(id+'')
}
});
{
"window": {
"defaultTitle": "商品详情"
}
}
\ No newline at end of file
.help-page-container {
width: 100%;
min-height: 100vh;
background: url('//yun.duiba.com.cn/taobaomini/aupresViva/help_bg.png') no-repeat;
background-size: 100% 1624rpx;
overflow: hidden;
}
.help-page-blank{
position: absolute;
width: 100%;
height: 100vh;
overflow: hidden;
}
.help-page-content {
position: absolute;
top: -208rpx;
left: 0;
right: 0;
bottom: -208rpx;
width: 100%;
background: url('//yun.duiba.com.cn/taobaomini/aupresViva/help_content_bg.png') no-repeat;
background-size: 100% 1664rpx;
}
.help-page-content__card {
width: 672rpx;
height: 580rpx;
background: url('//yun.duiba.com.cn/taobaomini/aupresViva/card_bg_05.png') no-repeat;
background-size: 100% 100%;
position: absolute;
left: 50%;
margin-left: -336rpx;
top: 632rpx;
display: flex;
justify-content: flex-start;
flex-direction: column;
align-items: center;
}
.help-page-content__card-title {
height: 40rpx;
width: 100%;
text-align: center;
font-size:40rpx;
font-family:SourceHanSansSC;
font-weight:400;
color:rgba(92,89,177,1);
margin: 74rpx auto 48rpx;
}
.help-page-content__card-content {
width:455rpx;
height:76rpx;
font-size:30rpx;
margin: 0 auto;
font-family:SourceHanSansSC;
font-weight:300;
line-height: 48rpx;
color:rgba(92,89,177,1);
text-align: center;
}
.help-page-content__card-btn {
width: 100%;
position: absolute;
bottom: 72rpx;
left: 0;
}
.help-page-content__card-btn-succes,.help-page-content__card-btn-fails {
display: flex;
justify-content: center;
align-content: center;
}
.help-page-content__card-btn-left,.help-page-content__card-btn-right,.help-page-content__card-btn-box {
width:251rpx;
height:79rpx;
background:#C386FF;
border-radius:40rpx;
border: 3rpx solid #ffffff;
display: flex;
justify-content: center;
align-content: center;
font-size:30rpx;
font-family:SourceHanSansSC;
font-weight:300;
color:rgba(255,255,255,1);
text-shadow:0px 3px 8px rgba(245,154,71,0.67);
line-height: 73rpx;
}
.help-page-content__card-btn-right {
background: #F3A867;
margin-left: 37rpx;
}
.help-page-content__card-btn-box {
width: 436rpx;
background: #F3A867;
}
\ No newline at end of file
<view class="help-page-container">
<view class="help-page-blank">
<view class="help-page-content">
<view class="help-page-content__card">
<view class="help-page-content__card-title">{{isMember?'助力成功!':''}}</view>
<view class="help-page-content__card-content">{{isMember?'精美小样已收入~':'你的集美为你准备了一份精美小样,领取就可助力成功哦~'}}</view>
<view class="help-page-content__card-btn">
<view a:if="{{isMember}}" class="help-page-content__card-btn-succes">
<view class="help-page-content__card-btn-left" onTap="getMyPrize">查看奖励</view>
<view class="help-page-content__card-btn-right" onTap="goToIndex">我也要赢大奖</view>
</view>
<view a:if="{{!isMember}}" class="help-page-content__card-btn-fails">
<view class="help-page-content__card-btn-box" onTap="getSmallKid">领取助力小样</view>
</view>
</view>
</view>
</view>
</view>
<!-- 获取小样 -->
<small-kid-modal a:if="{{isSmallKid}}" onGoToBuy="onGoToBuy" onGoToPay="onGoToPay" onCloseModal="onCloseModal" />
</view>
\ No newline at end of file
import {
commonToast,
navigateToOutside,
navigateTo,
openDetail,
getAuthUserInfo } from '../../utils/utils';
import API from '../../api'
const app = getApp();
Page({
inviteId: '',
isStock: false,
data: {
isInvite: false,
isSmallKid: false,
isMember: false,
inviteId: '',
objText: {}
},
async onLoad(query) {
let { inviteId } = query
if(inviteId) this.inviteId = inviteId;
await this.login()
await this.canAssistHandle()
},
onShow() {
if(this.isInvite) {
this.initPage()
}
if(this.isStock) {
this.getSamplePop()
}
},
//登陆
async login() {
const { activityId } = app
const userInfo = await getAuthUserInfo().catch(() => {
commonToast('未授权成功');
})
if (!userInfo) return
const { nickName, avatar } = userInfo
let result = await API.login({ activityId, userNick: nickName, avatar, inviteId: this.inviteId })
},
//是否可助力
async canAssistHandle() {
let { activityId } = app
let { success, data, message } = await API.canAssist({ activityId, inviteId: this.inviteId }).catch(res => {
my.showToast({
content: res.message,
success: () => {
navigateTo(`/pages/index/index?inviteId=${this.inviteId}`)
}
});
}) || {}
if(success) {
let { isvip, url } = data || {}
this.setData({ isMember: isvip || false, url })
if(isvip) {
this.initPage()
}
}
},
//小样奖品弹框提示
async getSamplePop() {
let { activityId } = app
let { success, data } = await API.samplePop({ activityId }).catch(res => {
}) || {}
if(success) {
let { sampleStatus} = data
if(sampleStatus == 2 || sampleStatus == 3) {
this.isStock = false
navigateTo(`/pages/index/index?page=help`)
}
}
},
async initPage() {
let { activityId } = app
let { success, data } = await API.assist({ activityId, inviteId: this.inviteId }).catch(res => {
}) || {}
if(success) {
this.setData({ isMember: true })
}
let objText = {
0: {
titile: '',
content: '你的集美为你准备了一份精美小样领取就可助力成功哦~',
leftText: '',
rightText: '领取助力小样',
},
1: {
titile: '助力成功!',
content: '精美小样已收入~',
leftText: '查看奖励',
rightText: '我也要赢大奖',
},
2: {
titile: '',
content: '你的集美为你准备了一份精美小样领取就可助力成功哦~',
leftText: '',
rightText: '领取助力小样',
}
}
},
//查看奖励
getMyPrize() {
this.setData({ isSmallKid: true })
this.addDataUv(1010)
},
onCloseModal() {
this.setData({ isSmallKid: false })
},
//我也要赢大奖
goToIndex() {
this.addDataUv(1011)
navigateTo(`/pages/index/index?inviteId=${this.inviteId}`)
},
//会员判断
async getSmallKid() {
this.isInvite = true
my.showToast({
content: '加入会员才能完成助力哦~',
success: () => {
navigateToOutside(this.data.url)
}
});
this.addDataUv(1008)
},
//去下单
onGoToBuy() {
this.setData({ isSmallKid: false })
this.isStock = true
navigateTo('/pages/goodsPage/goodsPage')
this.addDataUv(1012)
},
//支付邮票
async onGoToPay() {
let { activityId, smallKidItemId } = app
let { success, data } = await API.postageMark({ activityId, itemId:smallKidItemId }) || {}
if(success) {
this.isStock = true
this.setData({ isSmallKid: false })
let result = await openDetail(smallKidItemId)
}
this.addDataUv(1013)
},
//数据埋点
async addDataUv(type) {
let { activityId } = app
await API.addDataUv({ activityId, type })
}
});
{
"usingComponents": {
"small-kid-modal": "/components/smallKidModal/smallKidModal"
}
}
\ No newline at end of file
<view disable-scroll="true" class="page-game">
<canvas disable-scroll="true" id="canvas" type="2d" class="canvas" onTouchStart="onMouseEvent" onTouchMove="onMouseEvent" onTouchEnd="onMouseEvent" onReady="onCanvasReady">
</canvas>
</view>
\ No newline at end of file
import { Main } from './output';
import { playBgMusic, getUserAddress, favorShop, getAuthUserInfo, checkShopFavoredStatus, openDetail, reportAnalytics, commonToast, navigateTo } from '../../utils/utils';
import { getSystemInfo } from '/utils/utils';
const checkSystem = async () => {
const { version } = await getSystemInfo();
console.log('version', version);
return versionCompare(version, '9.8.0');
}
const versionCompare = (cur, compare) => {
const _cur = cur.split('.');
const _compare = compare.split('.');
if (+_cur[0] < +_compare[0]) {
return false;
} else if (+_cur[0] === +_compare[0] && +_cur[1] < +_compare[1]) {
return false;
} else if (+_cur[0] === +_compare[0] && +_cur[1] === +_compare[1] && +_cur[2] < +_compare[2]) {
return false;
}
return true;
}
const app = getApp();
const SHARE_CONFIG = { // TODO待写
title: '欧泊莱泡泡大作战',
desc: '快来领取我为你准备的超值小样吧',
imageUrl: "https://yun.duiba.com.cn/db_games/activity/pacman/share.jpg",
path: 'pages/index/index'
}
Page({
//暂时先不用吧,有问题
data: {
},
onLoad(query) {
// 页面加载
console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
//带参数的
if (query.inviteId) this.inviteId = query.inviteId;
if (query.isAssist) this.isAssist = query.isAssist;
checkSystem().then(r => {
if (!r) {
my.showToast({
content: "请升级最新版本的淘宝",
duration: 5000
});
}
});
},
async onReady() {
const resultSrc = await app.cloud.file.getTempFileURL({
fileId: 'cloud://A72CDCA869A0F7422ED947B8C0572B4D//bgm.mp3'
});
if (resultSrc[0]) this.musicUrl = resultSrc[0].url;
//navigateTo('/pages/myPrize/myPrize?inviteId='+this.inviteId)
const gameMusic = await app.cloud.file.getTempFileURL({
fileId: 'cloud://EF02A6A2B9B4E53989F2B893255ACDE1//bgm+shoot.mp3'
});
if (gameMusic[0]) this.gameMusicUrl = gameMusic[0].url;
},
onCanvasReady() {
console.log('onCanvasReady')
//授权和登录先搞
checkSystem().then(r => {
if (r) {
this.getAuth();
}
});
// this.createMain();
},
createMain() {
var self = this;
my.createCanvas({
id: 'canvas',
success: (ccc) => {
const dpr = my.getSystemInfoSync().pixelRatio
const windowWidth = my.getSystemInfoSync().windowWidth;
const windowHeight = my.getSystemInfoSync().windowHeight;
ccc.width = windowWidth * dpr + dpr;//重新修改会有误差
ccc.height = windowHeight * dpr + dpr;
// console.log(Main)
console.log(ccc.width, ccc.height)
if (!this.main) {
try {
this.main = new Main(ccc)
//添加事件,为了和main里的通信
this.main.addGlobalEvent("onMessage", self.onMessage, self)
} catch (err) {
console.error(err)
}
}
// console.log(this.main)
}
})
},
/**
* 跳转至我的奖品、商品购买页
*/
fuck_openDetail(itemId) {
my.tb.openDetail({
itemId,
success: (res) => {
// resolve(res)
},
fail: (res) => {
// reject(res)
},
});
},
navigateToPage(page) {
console.log('navigateToPage', page)
switch (page) {
case 1: navigateTo('/pages/myPrize/myPrize'); break;//我的奖品页面
case 2: navigateTo('/pages/goodsPage/goodsPage'); break;//购买商品页面
case 3: navigateTo('/pages/helpPage/helpPage?inviteId=' + app.inviteId); break;//助力页面(需要携带邀请人ID)
}
},
//授权
async getAuth() {
const userInfo = await getAuthUserInfo().catch(() => {
commonToast('未授权成功');
this.postMessage('mine.authorize', { success: false })
})
if (!userInfo) return
const { nickName, avatar } = userInfo
app.nickName = nickName
app.avatar = avatar;
// 检查是否关注的
// const isFollow = await checkShopFavoredStatus(app.sellerId).catch(() => { })
// app.isFollow = isFollow;//app上也挂一个
// 下面是自定义的,获取授权信息后发登录接口,也可自行处理
const { function: fc } = app.cloud
// 登录的接口,到时用
fc.invoke(
"bubbleSurviva",
{
"avatar": avatar,
"userNick": nickName,
"activityId": app.activityId,
"inviteId": this.inviteId
},
"login"
).then(async res => {//登录完才显示页面
console.log('bubbleSurviva login回调了')
app.openId = res.data.inviteId
if (res.code == 220003) {
// 活动已结束
app.isEnd = true;
}
// app.sellerId = res.data.sellerId;
// 创建Main,授权登录完后才创建
this.createMain();
// 后续可以通过getAppData接口获取信息了
// this.postMessage('mine.authorize', { success: true })
});
console.log('bubbleSurviva login执行了')
//分享图片
const result1 = await app.cloud.file.getTempFileURL({ fileId: 'cloud://DB912D609BCC82A3DFFF668FEC84D841//img_share_v_2.jpg' });
if (result1[0]) SHARE_CONFIG.imageUrl = result1[0].url
},
/**
* 获取及选择用户收货地址
* @param {*} prizeId
*/
async getUserAddress(prizeId) {
const userAddress = await getUserAddress().catch(res => {
commonToast(res.errorMessage)
this.postMessage('mine.getUserAddress', { success: false })
})
if (userAddress) {//格式需要修改具体
const { name, phone, address } = userAddress.duibaAddress
my.confirm({
title: '提示',
content: '确认使用该收货地址:' + name + phone + address,
confirmButtonText: '确定',
cancelButtonText: '取消',
success: (result) => {
const { confirm } = result
if (confirm) {
//发接口提交地址
const { cloud, activityId, cloudName } = app
cloud.function.invoke(/*cloudName*/"squirrelsAdoptRest2c", {//定制
activityId,
id: prizeId,
address,
name,
phone,
// address: JSON.stringify(userAddress.duibaAddress)
}, "receiveObjectPrize")
.then(res => {
if (res && res.success) {
//确认发送成功信息
this.postMessage('mine.getUserAddress', { success: true })
} else {
//新增失败0514
this.postMessage('mine.getUserAddress', { success: false })
}
})
.catch(() => {
//新增失败0514
this.postMessage('mine.getUserAddress', { success: false })
})
} else {
//新增失败0514
this.postMessage('mine.getUserAddress', { success: false })
}
},
})
}
},
/**
* 关注店铺
*/
async doFavorShop() {
const { sellerId } = getApp()
const success = await favorShop(sellerId).catch(err => {
// commonToast(err.errorMessage || '活动太火爆,请稍后重试')
//新增失败0514
this.postMessage('mine.favorShop', { success: false })
})
if (success) {
this.postMessage('mine.favorShop', { success: true })
}
// else {
// this.postMessage('mine.favorShop', { success: false })
// }
},
//和main通信的方法,接收main的信息
onMessage(e) {
//接口名字
let netName = e.data.netName;
//接口参数
let parameter = e.data.parameter;
//暂时发现3个需要用户操作的接口
//定制的授权
if (netName == "mine.authorize") {
this.getAuth()
}
//获取地址
else if (netName == "mine.getUserAddress") {
this.getUserAddress(parameter.prizeId)
}
//关注店铺的操作
else if (netName == "mine.favorShop") {
this.doFavorShop()
}
//领养名字,有弹框的
else if (netName == "mine.getAdoptName") {
this.setData({ "adoptModalVisible": true, type: parameter.type })
}
//打开详情页,还有成功失败
else if (netName == "mine.openDetail") {
openDetail(parameter.itemId).then(
() => {
this.postMessage(netName, { success: true })
},
() => {
this.postMessage(netName, { success: false })
}
)
}
//前端接口
else if (netName.indexOf("mine") == 0) {
var data = { success: true }
switch (netName) {
case "mine.getAppData"://获取信息
data = {
success: true,
data: {
activityId: app.activityId,//|| "5e7c40e98564b57d7fb95812",
nickName: app.nickName,
avatar: app.avatar,
openId: app.openId,
isEnd: app.isEnd,
isAssist: app.isAssist,
smallKidItemId: app.smallKidItemId,
inviteId: app.inviteId,//判断是否要发助力用
}
}
break;
case "mine.openMusic": //音频
if (parameter.isGame) {
playBgMusic(parameter.isOn, this.gameMusicUrl);
} else {
playBgMusic(parameter.isOn, this.musicUrl);
}
break;
case "mine.navigateToOutside"://跳转小程序外的页面
my.call("navigateToOutside", {
url: parameter.url
}, (res) => {
// my.alert({ content: "success - " + JSON.stringify(res)})
})
console.log(parameter.url)
break;
case "mine.navigateTo"://跳转小程序内的页面
my.navigateTo({
url: parameter.url
})
break;
case "mine.navigateBack"://返回页面
my.navigateBack({
delta: parameter.delta || 1
})
break;
case "mine.showSharePanel"://分享
//多一个参数
this.openId = parameter.openId//1是任务分享,2是复活液分享
my.showSharePanel()
break;
case "mine.navigateToPage"://navigateToPage
//多一个参数
this.navigateToPage(parameter.id)
break;
case "mine.fuck_openDetail"://navigateToPage
//多一个参数
this.fuck_openDetail(parameter.smallKidItemId)
break;
case "mine.reportAnalytics": ////淘宝自定义埋点
reportAnalytics(parameter.logkey);
break;
case "mine.openRankPanel": //打开排行榜
this.setData({ "expRankModalVisible": true });
break;
}
// this.webViewContext.postMessage({ netName: netName, data: data })
this.postMessage(netName, data)
} else {
// var app = getApp();
//获取后端接口
const { function: fc } = app.cloud;
if (!parameter) parameter = {};
console.log(netName)
parameter.activityId = app.activityId;
//netName得分割下
fc.invoke(netName.split(".")[0], parameter, netName.split(".")[1])
.then(res => {
// console.log("返回数据" + JSON.stringify(res));
//发送消息
// this.webViewContext.postMessage({ netName: netName, data: res })
this.postMessage(netName, res)
})
}
},
postMessage(netName, data) {
// this.main.dispatchGlobalEvent(netName, data)
this.main.dispatchGlobalEvent({ type: netName }, data)//以防复用事件event串了,就用这种方式
},
onShow() {
// 页面显示
if (this.main) {
this.main.run();
// this.main.dispatchGlobalEvent("onShow")//run里调用了
}
},
onHide() {
// 页面隐藏
if (this.main) {
this.main.pause();
// this.main.dispatchGlobalEvent("onHide")//pause里调用了
}
},
onUnload() {
// 页面被关闭
if (this.main) {
this.main.destroy();
}
},
onTitleClick() {
// 标题被点击
},
onPullDownRefresh() {
// 页面被下拉
},
onReachBottom() {
// 页面被拉到底部
},
onShareAppMessage() {
// 返回自定义分享信息
// const { activityId, openId } = app
// 发送分享记录,记录数据用
// API.getShareId({ activityId });
let { path, ...rest } = SHARE_CONFIG
if (this.openId) {
// path = path + '?inviteId=' + this.openId
/// TODO 分享邀请页
path = '/pages/helpPage/helpPage' + '?inviteId=' + this.openId;
this.openId = null //用完清掉
}
console.log(path)
return {
...rest,
path
}
},
//鼠标事件
onMouseEvent(e) {
if (this.main) this.main.stage.onMouseEvent(e)
},
});
{
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
.my-prize-container {
width: 100%;
min-height: 100vh;
background: url('//yun.duiba.com.cn/taobaomini/aupresViva/page_bg.png') no-repeat;
background-size: 100% 1624rpx;
overflow: hidden;
padding-top: 40rpx;
}
.my-prize-container__title {
width: 750rpx;
height: 68rpx;
background: url('//yun.duiba.com.cn/taobaomini/aupresViva/titile_bg.png') no-repeat;
background-size: 100% 100%;
display: table-cell;
text-align: center;
vertical-align: middle;
}
.my-prize-container__title text {
display: inline-block;
font-size:40rpx;
font-family:SourceHanSansSC;
font-weight:400;
color:rgba(92,89,177,1);
}
.my-prize-container-scroll {
margin-top: 30rpx;
width: 100%;
height: 90vh;
}
.my-prize-container__content {
width: 100%;
padding: 0 25rpx;
}
.my-prize-container__content-item {
width:100%;
height:160rpx;
background:rgba(255,255,255,1);
border-radius:10px;
margin-bottom: 24rpx;
padding: 20rpx 27rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
.my-prize-container__content-item-left {
display: flex;
max-width: 470rpx;
}
.my-prize-container__content-item__img {
width:120rpx;
height:120rpx;
background:rgba(244,244,244,1);
}
.my-prize-container__content-item__img image {
width: 100%;
height: 100%;
}
.my-prize-container__content-item__desc {
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
}
.my-prize-container__content-item__name {
font-size:28rpx;
font-family:SourceHanSansSC;
font-weight:400;
color:rgba(51,51,51,1);
margin-bottom: 15rpx;
}
.my-prize-container__content-item__code {
font-size:18rpx;
font-family:SourceHanSansSC;
font-weight:300;
color:rgba(51,51,51,1);
}
.my-prize-container__content-item__time {
font-size:18rpx;
font-family:SourceHanSansSC;
font-weight:300;
color:rgba(51,51,51,1);
margin-top: 5rpx;
width: 310rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.my-prize-container__content-item__btn {
width:150rpx;
height:40rpx;
background:linear-gradient(90deg,rgba(255,101,174,1) 0%,rgba(255,152,208,1) 100%);
border-radius:20rpx;
display: flex;
justify-content: center;
align-items: center;
}
.myprize-btn-status-disabled {
width:150rpx;
height:40rpx;
background:#E9E9E9;
border-radius:20rpx;
display: flex;
justify-content: center;
align-items: center;
}
.my-prize-container__content-item__btn text{
font-size:24rpx;
font-family:SourceHanSansSC;
font-weight:400;
color:rgba(255,255,255,1);
}
\ No newline at end of file
<view class="my-prize-container">
<view class="my-prize-container__title"><text>我的奖品</text></view>
<scroll-view scroll-y="{{true}}" class="my-prize-container-scroll">
<view class="my-prize-container__content">
<view class="my-prize-container__content-item" a:for="{{myPrizeList}}">
<view class="my-prize-container__content-item-left">
<view class="my-prize-container__content-item__img">
<image mode="scaleToFill" src="{{item.image}}"/>
</view>
<view class="my-prize-container__content-item__desc">
<view class="my-prize-container__content-item__name">{{item.name}}</view>
<view class="my-prize-container__content-item__code" a:if="{{item.endPrizeDesc}}">{{item.endPrizeDesc}}</view>
<view class="my-prize-container__content-item__time" a:if="{{item.remark}}">{{item.remark}}</view>
</view>
</view>
<view class="my-prize-container__content-item__btn {{item.btnDisabled}}" data-item="{{item}}" onTap="prizeHandle"><text>{{item.btnText}}</text></view>
</view>
</view>
</scroll-view>
<!-- 物流信息 -->
<logistic-modal a:if="{{isLogistic}}" prizeItem="{{currentPrize}}" onCloseModal="closeLogisticModal" />
<!-- 领取小样 -->
<small-kid-modal a:if="{{isSmallKid}}" onCloseModal="closeSmallModal" onGoToBuy="onGoToBuy" onGoToPay="onGoToPay" />
<!-- 获得小样 -->
<get-small-modal a:if="{{isGetSmallModal}}" onCloseModal="closeGetSmallModal" />
</view>
\ No newline at end of file
import {
getSystemInfo,
versionCompare,
commonToast,
dateFormatter,
getServerTime,
navigateToOutside,
navigateTo,
openDetail,
getUserAddress } from '../../utils/utils';
import { DRAW_STATUS_MAP } from '../../constants'
import API from '../../api'
const app = getApp();
Page({
data: {
isGetSmall: false,
myPrizeList: [],
isLogistic: false,
isSmallKid: false,
isGetSmallModal: false
},
onLoad() {
this.initPage()
},
onShow() {
if(this.isGetSmall) {
this.getSamplePop()
}
},
//小样奖品弹框提示
async getSamplePop() {
let { activityId } = app
let { success, data } = await API.samplePop({ activityId }).catch(res => {
}) || {}
if(success) {
let { sampleStatus} = data
if(sampleStatus == 2 || sampleStatus == 3) {
this.setData({ isGetSmallModal: true })
this.initPage()
this.isGetSmall = false
}
}
},
//关闭获得小样弹窗
closeGetSmallModal() {
this.setData({ isGetSmallModal: false })
},
//初始化页面数据
async initPage() {
let { activityId } = app
let { success, data: { endPrizeTime, list } } = await API.getMyPrizeList({ activityId }).catch( res => {
res && commonToast(res)
}) || {}
if(success) {
let nowTime = await getServerTime()
let myPrizeList = list && list.map(el => {
el.btnText = DRAW_STATUS_MAP[el.drawStatus].btnText
if(el.drawStatus == 1 && (el.type == 3 || el.type == 6)) {
el.btnText = '填写地址'
}
if(el.drawStatus == 3 && el.type == 3) {
el.btnText = '查看物流'
}
if(el.type !== 3) {
el.btnText = DRAW_STATUS_MAP[el.drawStatus].btnText
if(el.type == 6 && el.drawStatus == 0) {
el.btnText = '领取奖品'
}
if(el.type == 6 && el.drawStatus == 1) {
el.btnText = '填写地址'
}
if(el.type == 6 && el.drawStatus == 3) {
el.btnText = '查看物流'
}
}
if((el.drawStatus == 1 || el.drawStatus == 5) && nowTime > endPrizeTime) {
el.endPrizeDesc = '奖品已过期'
}
else {
el.endPrizeDesc = el.drawStatus == 1 ? `请于${dateFormatter(endPrizeTime,'yyyy-MM-dd hh:mm:ss')}前领取`:''
}
el.btnDisabled = DRAW_STATUS_MAP[el.drawStatus].btnDisabled
if(el.drawStatus == 3) {
if(el.type == 1) {
el.btnDisabled = 'myprize-btn-status-disabled'
}
}
el.remark = el.remark ? el.remark : ''
return el
})
console.warn(myPrizeList)
this.setData({
myPrizeList,
endPrizeTime
})
}
},
/**
* 关闭物流弹窗
*/
closeLogisticModal() {
this.setData({ isLogistic: false })
},
//奖品操作
async prizeHandle(e) {
let { item } = e.target.dataset
let { type,drawStatus } = item
this.setData({ currentPrize:item })
switch(drawStatus) {
case 0: this.setData({ isSmallKid:true });break;
case 6:
case 1: this.receivePrize(item);break;
case 3: this.handleStatus(type);break;
case 7: commonToast('请前往淘宝查看');break;
}
},
//已领取奖品操作
handleStatus(type) {
switch(type) {
case 6:
case 3: this.setData({ isLogistic: true });break;
case 1: this.couponsHandle();
}
},
//使用优惠券
couponsHandle() {
//navigateToOutside()
},
/**
* 奖品领取
*/
async receivePrize() {
const { activityId } = app;
const { type, _id } = this.data.currentPrize;
switch(+type) {
// 实物
case 6:
case 3:
const isValid = await this.checkSystem()
if (!isValid) {
commonToast('请升级淘宝版本');
return;
}
const userAddress = await getUserAddress().catch(res => {
commonToast(res && res.errorMessage);
});
if (userAddress) {
const { name, phone, address } = userAddress.duibaAddress;
this.setData({ userAddress })
my.confirm({
title: '温馨提示',
content: `确认使用该地址:${name},${phone},${address}`,
confirmButtonText: '确认',
cancelButtonText: '取消',
success: (result) => {
this.receiveObject()
},
});
}
break;
// 优惠券
case 1:
const {success} = await API.receivePrize({_id, activityId}).catch(res => {
commonToast(res && res.message);
this.initPage()
}) || {};
if (success) {
commonToast('奖品领取成功,已发放至我的卡包');
this.initPage()
}
break;
default:
break;
}
},
// TODO: 确认天猫是否也是9.3.0以下有问题
async checkSystem() {
const { version, app } = await getSystemInfo();
return versionCompare(version, '9.3.0');
},
async receiveObject() {
const { activityId } = app;
const { _id } = this.data.currentPrize;
const { name, phone, address } = this.data.userAddress.duibaAddress;
let { provinceName, cityName, countyName, cityCode, streetName } = this.data.userAddress
const {success} = await API.receiveObjectPrize({name, phone, detailInfo:address, cityCode, provinceName, cityName, countyName, streetName, _id, activityId}).catch(res => {
commonToast(res && res.message);
this.initPage()
}) || {};
if (success) {
commonToast('领取成功');
this.initPage();
}
},
/**关闭小样弹窗 */
closeSmallModal() {
this.setData({ isSmallKid:false })
},
//去下单
onGoToBuy() {
this.isGetSmall = true
this.setData({ isSmallKid:false })
navigateTo('/pages/goodsPage/goodsPage')
this.addDataUv(1012)
},
//支付邮票
async onGoToPay() {
let { activityId, smallKidItemId } = app
let { success, data } = await API.postageMark({ activityId, itemId:smallKidItemId })
if(success) {
this.isGetSmall = true
this.setData({ isSmallKid:false })
let result = await openDetail(smallKidItemId)
}
this.addDataUv(1013)
},
//数据埋点
async addDataUv(type) {
let { activityId } = app
await API.addDataUv({ activityId, type })
}
});
{
"usingComponents": {
"logistic-modal": "/components/logisticsModal/logisticsModal",
"small-kid-modal": "/components/smallKidModal/smallKidModal",
"get-small-modal": "/components/getSmallModal/getSmallModal"
}
}
\ No newline at end of file
import * as FYGE from "fyge-tbmini";
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else {
var a = factory();
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/Main.ts");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./module/RES.ts":
/*!***********************!*\
!*** ./module/RES.ts ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RES = void 0;
var RES;
(function (RES) {
var resData;
var videoEntityHash = {};
var soundHash = {};
var groupsCompleteHash = {};
var groupsPromiseHash = {};
var singleResPromiseHash = {};
function loadConfig(res) {
resData = res;
RES.resPath = res.path;
}
RES.loadConfig = loadConfig;
function loadSparkAssets(resList) {
var list = [];
for (var key in resList) {
list.push(resList[key]);
}
var p = new Promise(function (resolve, reject) {
loadResList(function (s) {
if (s) {
resolve();
}
else {
reject();
}
}, list);
});
return p;
}
RES.loadSparkAssets = loadSparkAssets;
function loadGroup(name) {
if (groupsCompleteHash[name]) {
return new Promise(function (resolve) {
resolve();
});
}
if (groupsPromiseHash[name]) {
return groupsPromiseHash[name];
}
var arr = getGroupResByName(name);
if (!arr || !arr.length) {
groupsCompleteHash[name] = true;
return new Promise(function (resolve) {
resolve();
});
}
var p = new Promise(function (resolve, reject) {
loadResList(function (s) {
delete groupsPromiseHash[name];
if (s) {
groupsCompleteHash[name] = true;
resolve();
}
else {
reject();
}
}, arr);
});
groupsPromiseHash[name] = p;
return p;
}
RES.loadGroup = loadGroup;
function getResAsync(str, comFun, thisObj) {
var type = str.substring(str.lastIndexOf(".") + 1, str.length);
if (type == "png" || type == "jpg") {
if (FYGE.TextureCache[str]) {
comFun && comFun.call(thisObj, FYGE.TextureCache[str], str);
new Promise(function (r) {
r(FYGE.TextureCache[str]);
});
}
else {
return new Promise(function (resolve, reject) {
FYGE.GlobalLoader.loadImage(function (s, image) {
if (s) {
FYGE.Texture.addToCache(FYGE.Texture.from(image), str);
comFun && comFun.call(thisObj, FYGE.TextureCache[str], str);
resolve(FYGE.TextureCache[str]);
}
else {
comFun && comFun.call(thisObj, null, str);
reject();
}
}, str);
});
}
}
}
RES.getResAsync = getResAsync;
function getResByUrl() {
}
RES.getResByUrl = getResByUrl;
function getRes(str) {
var type = str.substring(str.lastIndexOf(".") + 1, str.length);
if (type == "png" || type == "jpg") {
return FYGE.TextureCache[str] || null;
}
}
RES.getRes = getRes;
function hasRes(str) {
for (var i = 0; i < resData.groups.length; i++) {
var group = resData.groups[i];
var keys = group.keys;
if (keys && keys.split(",").indexOf(str) > -1) {
return group.name;
}
if (group.atlas && group.name + ".json" == str) {
return group.name;
}
}
return null;
}
function getGroupResByName(name) {
var group = getGroupByName(name);
if (!group)
return null;
if (group.atlas) {
var arr = [name + ".json"];
if (group.keys) {
arr = arr.concat(group.keys.split(",").filter(function (k) {
return k.substr(-4) != ".png";
}));
}
return arr;
}
else if (group.keys) {
return group.keys.split(",");
}
else {
return null;
}
}
function getGroupByName(name) {
var groups = resData.groups;
var group;
for (var i = 0; i < groups.length; i++) {
if (groups[i].name === name) {
group = groups[i];
break;
}
}
return group;
}
function loadResList(callback, arr) {
var count = 0;
var countAll = arr.length;
if (!countAll)
callback(true);
var mark = true;
for (var i = 0; i < countAll; i++) {
var resName = arr[i]['url'];
getResAsync(resName, function (res, str) {
if (!res)
mark = false;
if (++count == countAll)
callback(mark);
}, this);
}
}
RES.loadResList = loadResList;
function returnSingleResPromise(str, comFun, thisObj) {
singleResPromiseHash[str].then(function (r) {
comFun && comFun.call(thisObj, r, str);
}, function () {
comFun && comFun.call(thisObj, null, str);
});
return singleResPromiseHash[str];
}
var skinData;
function loadSkinConfig(skinJson) {
skinData = skinJson;
}
RES.loadSkinConfig = loadSkinConfig;
function initSkinDisplay(con, skin, root) {
var data = typeof (skin) == 'string' ? getSkinDataByName(skin) : skin;
if (!data.children || !data.children.length)
return;
for (var i = 0; i < data.children.length; i++) {
var child = data.children[i];
if (child.type == "skin")
continue;
var dis = con.addChild(getDisplayByData(child));
if (root && child.id)
root[child.id] = dis;
if (child.type == "container")
initSkinDisplay(dis, child, root);
}
}
RES.initSkinDisplay = initSkinDisplay;
function getSkinDataByName(skinName, skinNode) {
if (skinNode === void 0) { skinNode = skinData; }
if (!skinNode || !skinNode.children || !skinNode.children.length)
return null;
for (var i = 0; i < skinNode.children.length; i++) {
var child = skinNode.children[i];
if (child.name == skinName && (child.type == "container" || child.type == "skin"))
return child;
var gson = getSkinDataByName(skinName, child);
if (gson)
return gson;
}
return null;
}
RES.getSkinDataByName = getSkinDataByName;
function getSrcByUuid(resList, uuid) {
resList = resList || [];
for (var i = 0; i < resList.length; i++) {
if (resList[i].uuid == uuid) {
return resList[i].url;
}
}
return "";
}
RES.getSrcByUuid = getSrcByUuid;
function getDisplayByData(data) {
var dis;
switch (data.type) {
case "container":
dis = new FYGE.Container();
break;
case "button":
dis = new FYGE.Button(getRes(data.props.tUp), data.props.tDown ? getRes(data.props.tDown) : null, data.props.tDisable ? getRes(data.props.tDisable) : null);
break;
case "text":
dis = new FYGE.TextField();
for (var key in data.props)
dis[key] = data.props[key];
break;
case "sprite":
dis = new FYGE.Sprite(getRes(data.props.source));
break;
case "rect":
dis = new FYGE.Shape();
dis.beginFill(FYGE.string2hex(data.props.fillColor));
dis.drawRect(0, 0, data.props.width, data.props.height);
dis.endFill();
break;
}
dis.name = data.name;
dis.alpha = data.alpha || 1;
dis.position.set(data.x, data.y);
return dis;
}
function destroyRES() {
}
})(RES = exports.RES || (exports.RES = {}));
/***/ }),
/***/ "./module/ctrls/index.ts":
/*!*******************************!*\
!*** ./module/ctrls/index.ts ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.destroyAllCtrls = exports.removeTweens = exports.clearWait = exports.wait = exports.showAlert = exports.getCurrentScene = exports.changeScene = exports.closeCurrentPanel = exports.closeAllPanels = exports.showConfirm = exports.showPanel = exports.showToast = void 0;
var waitingCtrl_1 = __webpack_require__(/*! ./waitingCtrl */ "./module/ctrls/waitingCtrl.ts");
var panelCtrl_1 = __webpack_require__(/*! ./panelCtrl */ "./module/ctrls/panelCtrl.ts");
var sceneCtrl_1 = __webpack_require__(/*! ./sceneCtrl */ "./module/ctrls/sceneCtrl.ts");
var toastCtrl_1 = __webpack_require__(/*! ./toastCtrl */ "./module/ctrls/toastCtrl.ts");
var toastCtrl_2 = __webpack_require__(/*! ./toastCtrl */ "./module/ctrls/toastCtrl.ts");
Object.defineProperty(exports, "showToast", { enumerable: true, get: function () { return toastCtrl_2.showToast; } });
__exportStar(__webpack_require__(/*! ./waitingCtrl */ "./module/ctrls/waitingCtrl.ts"), exports);
exports.showPanel = function (panel, data) {
return panelCtrl_1.default.instance.show(panel, data);
};
exports.showConfirm = function (panel, data) {
var confirmPanel = panelCtrl_1.default.instance.show(panel, data);
return confirmPanel.makePromise();
};
exports.closeAllPanels = function () {
panelCtrl_1.default.instance.closeAll();
};
exports.closeCurrentPanel = function () {
panelCtrl_1.default.instance.closeCurrent();
};
exports.changeScene = function (scene, data) {
sceneCtrl_1.default.instance.change(scene, data);
};
function getCurrentScene() {
return sceneCtrl_1.default.instance.currentScene;
}
exports.getCurrentScene = getCurrentScene;
exports.showAlert = function (title, content) {
if (my) {
my.alert({
title: title || "",
content: content || ""
});
}
else {
console.log(title, content);
}
};
function wait(callback, time) {
var obj = {};
FYGE.Tween.get(obj)
.wait(time)
.call(callback);
return obj;
}
exports.wait = wait;
function clearWait(obj) {
obj && FYGE.Tween.removeTweens(obj);
}
exports.clearWait = clearWait;
function removeTweens(obj, isRecursive) {
if (isRecursive === void 0) { isRecursive = true; }
if (!obj)
return;
FYGE.Tween.removeTweens(obj);
if (!isRecursive || !obj.children || !obj.children.length)
return;
obj.children.forEach(function (child) {
removeTweens(child);
});
}
exports.removeTweens = removeTweens;
function destroyAllCtrls() {
toastCtrl_1.destroyToast();
waitingCtrl_1.destroyWaiting();
panelCtrl_1.default.instance.destroy();
sceneCtrl_1.default.instance.destroy();
}
exports.destroyAllCtrls = destroyAllCtrls;
/***/ }),
/***/ "./module/ctrls/panelCtrl.ts":
/*!***********************************!*\
!*** ./module/ctrls/panelCtrl.ts ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var layers_1 = __webpack_require__(/*! ../views/layers */ "./module/views/layers.ts");
var waitingCtrl_1 = __webpack_require__(/*! ./waitingCtrl */ "./module/ctrls/waitingCtrl.ts");
var toastCtrl_1 = __webpack_require__(/*! ./toastCtrl */ "./module/ctrls/toastCtrl.ts");
var PanelCtrl = (function () {
function PanelCtrl() {
this.stacks = [];
}
Object.defineProperty(PanelCtrl, "instance", {
get: function () {
return PanelCtrl._instance || (PanelCtrl._instance = new PanelCtrl());
},
enumerable: false,
configurable: true
});
PanelCtrl.prototype.init = function (parent) {
this._parent = parent;
var bg = new FYGE.Shape();
bg.beginFill(0);
bg.drawRect(layers_1.layers.stageOffsetX - parent.x, layers_1.layers.stageOffsetY - parent.y, layers_1.layers.stageWidth, layers_1.layers.stageHeight);
bg.endFill();
bg.hitTestByPixel = false;
bg.visible = false;
this._parent.addChild(bg);
this._bg = bg;
};
PanelCtrl.prototype.closeAll = function () {
this.stacks.forEach(function (e) { return e.hidePanel(); });
};
PanelCtrl.prototype.show = function (cls, data) {
var _this = this;
waitingCtrl_1.showWaiting();
var panel = new cls(data);
this.add(panel);
this.stacks.push(panel);
panel.onLoaded = function () {
waitingCtrl_1.hideWaiting();
_this.updateView(false);
panel.start(data);
if (panel.visible)
panel.showAni();
};
panel.onLoadError = function () {
waitingCtrl_1.hideWaiting();
toastCtrl_1.showToast("资源加载失败");
panel.removeEventListener('onDestroy', _this.onPanelHide, _this);
_this.remove(panel);
};
return panel;
};
PanelCtrl.prototype.updateView = function (showPanelAni) {
var _this = this;
if (showPanelAni === void 0) { showPanelAni = true; }
if (!this.stacks.length) {
if (this._bg.visible) {
this.bgAni = "hide";
FYGE.Tween.removeTweens(this._bg);
FYGE.Tween.get(this._bg)
.to({ alpha: 0 }, 200, FYGE.Ease.cubicOut)
.call(function () {
_this._bg.visible = false;
_this._current = null;
_this._parent.visible = false;
});
}
}
else {
this._parent.visible = true;
if (this.bgAni == "hide") {
this.bgAni = "show";
FYGE.Tween.removeTweens(this._bg);
this._bg.alpha = 0.7;
}
if (this._bg.visible === false) {
this._bg.visible = true;
this._bg.alpha = 0;
FYGE.Tween.get(this._bg).to({ alpha: 0.7 }, 200, FYGE.Ease.cubicOut);
}
}
for (var i = 0; i < this.stacks.length; i++) {
if (i < this.stacks.length - 1) {
this.stacks[i].visible = false;
}
else {
this.stacks[i].visible = true;
if (showPanelAni)
this.stacks[i].showAni();
this._current = this.stacks[i];
}
}
};
PanelCtrl.prototype.add = function (panel) {
this._parent.addChild(panel);
panel.addEventListener('onDestroy', this.onPanelHide, this);
};
PanelCtrl.prototype.remove = function (panel) {
this._parent.removeChild(panel);
this.stacks = this.stacks.filter(function (e) { return e != panel; });
};
PanelCtrl.prototype.onPanelHide = function (e) {
var panel = e.target;
panel.removeEventListener('onDestroy', this.onPanelHide, this);
this.remove(panel);
this.updateView();
};
PanelCtrl.prototype.closeCurrent = function () {
if (this._current) {
this._current.hidePanel();
}
};
PanelCtrl.prototype.destroy = function () {
PanelCtrl._instance = null;
this.stacks = null;
this._current = null;
this._parent = null;
FYGE.Tween.removeTweens(this._bg);
this._bg = null;
};
return PanelCtrl;
}());
exports.default = PanelCtrl;
/***/ }),
/***/ "./module/ctrls/sceneCtrl.ts":
/*!***********************************!*\
!*** ./module/ctrls/sceneCtrl.ts ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var waitingCtrl_1 = __webpack_require__(/*! ./waitingCtrl */ "./module/ctrls/waitingCtrl.ts");
var toastCtrl_1 = __webpack_require__(/*! ./toastCtrl */ "./module/ctrls/toastCtrl.ts");
var SceneCtrl = (function () {
function SceneCtrl() {
}
Object.defineProperty(SceneCtrl, "instance", {
get: function () {
return SceneCtrl._instance || (SceneCtrl._instance = new SceneCtrl());
},
enumerable: false,
configurable: true
});
SceneCtrl.prototype.init = function (parent) {
this._parent = parent;
};
SceneCtrl.prototype.change = function (cls, data) {
var _this = this;
var scene = new cls(data);
scene.visible = false;
waitingCtrl_1.showWaiting();
var preScene = this._currentScene;
scene.onLoaded = function () {
waitingCtrl_1.hideWaiting();
scene.showAni(function () {
if (preScene)
preScene.destroy();
});
scene.visible = true;
scene.start(data);
};
scene.onLoadError = function () {
waitingCtrl_1.hideWaiting();
toastCtrl_1.showToast("资源加载失败");
_this._currentScene = preScene || null;
_this._parent.removeChild(scene);
};
this._currentScene = scene;
this._parent.addChild(scene);
};
Object.defineProperty(SceneCtrl.prototype, "currentScene", {
get: function () {
return this._currentScene;
},
enumerable: false,
configurable: true
});
SceneCtrl.prototype.destroy = function () {
SceneCtrl._instance = null;
this._currentScene = null;
this._parent = null;
};
return SceneCtrl;
}());
exports.default = SceneCtrl;
/***/ }),
/***/ "./module/ctrls/toastCtrl.ts":
/*!***********************************!*\
!*** ./module/ctrls/toastCtrl.ts ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.destroyToast = exports.showToast = void 0;
var layers_1 = __webpack_require__(/*! ../views/layers */ "./module/views/layers.ts");
var RES_1 = __webpack_require__(/*! ../RES */ "./module/RES.ts");
var inited = false;
var _toast;
var _parent;
var startY;
var endY;
var initToast = function () {
if (!inited) {
inited = true;
_toast = new Toast();
_parent = layers_1.layers.toastLayer;
_toast.alpha = 0;
_toast.x = layers_1.layers.stageOffsetX - _parent.x + (layers_1.layers.stageWidth - _toast.width) / 2;
var h = _toast.height;
var y = layers_1.layers.stageOffsetY - _parent.y;
startY = y - h;
endY = y + (layers_1.layers.stageHeight - h) / 2;
}
};
exports.showToast = function (msg) {
initToast();
_toast.show(msg);
_parent.addChild(_toast);
FYGE.Tween.removeTweens(_toast);
FYGE.Tween.get(_toast)
.set({ y: startY, alpha: 1 })
.to({ y: endY }, 500, FYGE.Ease.quartOut)
.wait(800)
.to({ alpha: 0 }, 300)
.call(function () {
_parent.removeChild(_toast);
});
};
exports.destroyToast = function () {
if (inited && _toast && !_toast.destroyed) {
_toast.destroy();
_toast = null;
_parent = null;
inited = false;
}
};
var Toast = (function (_super) {
__extends(Toast, _super);
function Toast() {
var _this = _super.call(this) || this;
_this.PADDING = 40;
_this.mouseChildren = false;
_this.mouseEnable = false;
var toastBgTexture = RES_1.RES.getRes("toastBg.png");
if (toastBgTexture) {
_this.bg = new FYGE.Sprite(toastBgTexture);
_this.addChild(_this.bg);
}
_this.msg = new FYGE.TextField();
_this.msg.size = 28;
_this.msg.fillColor = "0xffffff";
_this.msg.text = "";
_this.msg.verticalAlign = FYGE.VERTICAL_ALIGN.MIDDLE;
_this.msg.textHeight = toastBgTexture ? toastBgTexture.height : 200;
_this.msg.textAlign = FYGE.TEXT_ALIGN.CENTER;
_this.addChild(_this.msg);
return _this;
}
Toast.prototype.show = function (msg) {
this.msg.text = msg;
this.msg.x = ((this.bg ? this.bg.width : 0) - this.msg.textWidth) / 2;
};
Toast.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.msg = null;
this.bg = null;
};
return Toast;
}(FYGE.Container));
/***/ }),
/***/ "./module/ctrls/waitingCtrl.ts":
/*!*************************************!*\
!*** ./module/ctrls/waitingCtrl.ts ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.destroyWaiting = exports.hideWaiting = exports.showWaiting = void 0;
var RES_1 = __webpack_require__(/*! ../RES */ "./module/RES.ts");
var layers_1 = __webpack_require__(/*! ../views/layers */ "./module/views/layers.ts");
var inited = false;
var _waiting;
var _parent;
var initWaiting = function () {
if (!inited) {
inited = true;
var waiting = new Waiting();
_parent = layers_1.layers.topLayer;
_waiting = waiting;
var offX = (layers_1.layers.stageWidth - 160) / 2;
var offY = (layers_1.layers.stageHeight - _waiting.height) / 2;
_waiting.x = layers_1.layers.stageOffsetX - _parent.x + offX;
_waiting.y = layers_1.layers.stageOffsetY - _parent.y + offY;
var bg = new FYGE.Graphics()
.beginFill(0x000000)
.drawRect(-offX, -offY, layers_1.layers.stageWidth, layers_1.layers.stageHeight)
.endFill();
bg.alpha = 0;
_waiting.addChildAt(bg, 0);
}
};
exports.showWaiting = function (msg) {
initWaiting();
_waiting.show(msg);
_parent.addChild(_waiting);
};
exports.hideWaiting = function () {
_parent.removeChild(_waiting);
};
exports.destroyWaiting = function () {
if (inited && _waiting && !_waiting.destroyed) {
_waiting.destroy();
_waiting = null;
_parent = null;
inited = false;
}
};
var Waiting = (function (_super) {
__extends(Waiting, _super);
function Waiting() {
var _this = _super.call(this) || this;
var rectBgTexture = RES_1.RES.getRes("waitingBg.png");
if (rectBgTexture) {
var rectBg = new FYGE.Sprite(rectBgTexture);
_this.addChild(rectBg);
var rotTexture = RES_1.RES.getRes("waitingRot.png");
var rot_1 = new FYGE.Sprite(rotTexture);
rot_1.x = (rectBgTexture.width - rotTexture.width) / 2;
rot_1.y = 47;
rot_1.anchorX = rotTexture.width / 2;
rot_1.anchorY = rotTexture.height / 2;
_this.addChild(rot_1);
var count_1 = 0;
rot_1.addEventListener(FYGE.Event.ENTER_FRAME, function () {
count_1++;
if (count_1 % 30 == 0)
rot_1.rotation += 45;
}, _this);
}
_this.msg = new FYGE.TextField();
_this.msg.y = 125;
_this.msg.textWidth = rectBgTexture ? rectBgTexture.width : 200;
_this.msg.textAlign = FYGE.TEXT_ALIGN.CENTER;
_this.msg.size = 26;
_this.msg.fillColor = "#ffffff";
_this.addChild(_this.msg);
return _this;
}
Waiting.prototype.show = function (msg) {
if (msg === void 0) { msg = "加载中"; }
this.msg.text = msg;
};
Waiting.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.msg = null;
};
return Waiting;
}(FYGE.Container));
/***/ }),
/***/ "./module/views/Module.ts":
/*!********************************!*\
!*** ./module/views/Module.ts ***!
\********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Module = void 0;
var RES_1 = __webpack_require__(/*! ../RES */ "./module/RES.ts");
var ctrls_1 = __webpack_require__(/*! ../ctrls */ "./module/ctrls/index.ts");
var Module = (function (_super) {
__extends(Module, _super);
function Module(data) {
var _this = _super.call(this) || this;
_this.data = data;
_this.init();
return _this;
}
Module.prototype.init = function () {
var _this = this;
this.preLoadRes().then(function () {
if (_this.skinName)
RES_1.RES.initSkinDisplay(_this, _this.skinName, _this);
_this.initUi();
_this.onLoaded && _this.onLoaded();
}, function () {
_this.onLoadError && _this.onLoadError();
});
};
Module.prototype.preLoadRes = function () {
var _this = this;
return new Promise(function (resolve, reject) {
if (_this.groupNames && _this.groupNames.length) {
var arr = [];
for (var i = 0; i < _this.groupNames.length; i++) {
arr.push(RES_1.RES.loadGroup(_this.groupNames[i]));
}
Promise.all(arr).then(resolve, reject);
}
else {
resolve();
}
});
};
Module.prototype.initUi = function () {
};
Object.defineProperty(Module.prototype, "groupNames", {
get: function () { return null; },
enumerable: false,
configurable: true
});
Object.defineProperty(Module.prototype, "skinName", {
get: function () { return null; },
enumerable: false,
configurable: true
});
;
Module.prototype.start = function (data) {
this.initEvents();
};
Module.prototype.initEvents = function () {
};
Module.prototype.removeEvents = function () {
};
Module.prototype.enableMouseEvt = function (enable) {
this.mouseEnable = enable;
this.mouseChildren = enable;
};
Module.prototype.btnDelay = function (target, delay) {
if (delay === void 0) { delay = 2000; }
target.mouseEnable = false;
target.mouseChildren = false;
setTimeout(function () {
target.mouseEnable = true;
target.mouseChildren = true;
}, delay);
};
Module.prototype.destroy = function () {
ctrls_1.removeTweens(this);
this.removeEvents();
this.dispatchEvent("onDestroy");
_super.prototype.destroy.call(this);
};
return Module;
}(FYGE.Container));
exports.Module = Module;
/***/ }),
/***/ "./module/views/Scene.ts":
/*!*******************************!*\
!*** ./module/views/Scene.ts ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Scene = void 0;
var Module_1 = __webpack_require__(/*! ./Module */ "./module/views/Module.ts");
var Scene = (function (_super) {
__extends(Scene, _super);
function Scene() {
return _super !== null && _super.apply(this, arguments) || this;
}
Scene.prototype.showAni = function (callback) {
callback();
};
Scene.prototype.updateScene = function () {
};
return Scene;
}(Module_1.Module));
exports.Scene = Scene;
/***/ }),
/***/ "./module/views/layers.ts":
/*!********************************!*\
!*** ./module/views/layers.ts ***!
\********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.destroyLayers = exports.layers = void 0;
var panelCtrl_1 = __webpack_require__(/*! ../ctrls/panelCtrl */ "./module/ctrls/panelCtrl.ts");
var sceneCtrl_1 = __webpack_require__(/*! ../ctrls/sceneCtrl */ "./module/ctrls/sceneCtrl.ts");
var Layers = (function (_super) {
__extends(Layers, _super);
function Layers() {
return _super !== null && _super.apply(this, arguments) || this;
}
Layers.prototype.init = function (stage) {
stage.addChild(this);
var arr = [
"_bottomLayer",
"_sceneLayer",
"_popupLayer",
"_toastLayer",
"_topLayer",
"_shareLayer"
];
for (var i = 0; i < arr.length; i++) {
this[arr[i]] = new FYGE.Container();
this.addChild(this[arr[i]]);
}
this.sceneLayer.y = this.stageOffsetY;
this.shareLayer.y = -this.stageOffsetY;
sceneCtrl_1.default.instance.init(this.sceneLayer);
panelCtrl_1.default.instance.init(this.popupLayer);
};
Object.defineProperty(Layers.prototype, "bottomLayer", {
get: function () { return this._bottomLayer; },
enumerable: false,
configurable: true
});
Object.defineProperty(Layers.prototype, "sceneLayer", {
get: function () { return this._sceneLayer; },
enumerable: false,
configurable: true
});
Object.defineProperty(Layers.prototype, "popupLayer", {
get: function () { return this._popupLayer; },
enumerable: false,
configurable: true
});
Object.defineProperty(Layers.prototype, "toastLayer", {
get: function () { return this._toastLayer; },
enumerable: false,
configurable: true
});
Object.defineProperty(Layers.prototype, "topLayer", {
get: function () { return this._topLayer; },
enumerable: false,
configurable: true
});
Object.defineProperty(Layers.prototype, "shareLayer", {
get: function () { return this._shareLayer; },
enumerable: false,
configurable: true
});
Object.defineProperty(Layers.prototype, "stageHeight", {
get: function () {
if (!this.stage)
return 0;
return this.stage.viewRect.height;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Layers.prototype, "stageWidth", {
get: function () {
if (!this.stage)
return 0;
return this.stage.viewRect.width;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Layers.prototype, "stageOffsetX", {
get: function () {
if (!this.stage)
return 0;
return this.stage.viewRect.x;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Layers.prototype, "stageOffsetY", {
get: function () {
if (!this.stage)
return 0;
return this.stage.viewRect.y;
},
enumerable: false,
configurable: true
});
return Layers;
}(FYGE.Container));
exports.layers = new Layers();
function destroyLayers() {
exports.layers.removeChildren();
if (exports.layers.parent)
exports.layers.parent.removeChild(exports.layers);
}
exports.destroyLayers = destroyLayers;
/***/ }),
/***/ "./resCanvasList.js":
/*!**************************!*\
!*** ./resCanvasList.js ***!
\**************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
const resCanvasList = {
'4ee17a9c-5deb-43be-b205-16fb7593d172': {
name: 'spark',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/spark.810e94665ad6f7d7684f9b25b764e040a0cce7bf.png',
uuid: '4ee17a9c-5deb-43be-b205-16fb7593d172'
},
'cb54f3b5-0469-46d1-99ea-734153b92078': {
name: 'bg',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/bg.c4359b9ea9e843cd8d929567b2fb52ed5518e105.png',
uuid: 'cb54f3b5-0469-46d1-99ea-734153b92078'
},
'593e9d74-4944-496a-b6c1-8316756f8bf7': {
name: '宝箱2',
ext: '.png',
uuid: '593e9d74-4944-496a-b6c1-8316756f8bf7',
url: '//yun.duiba.com.cn/spark/assets/022e25a3984ff122fbf960bd0cb87bff48f8c3bf.png'
}
};
/* harmony default export */ __webpack_exports__["default"] = (resCanvasList);
/***/ }),
/***/ "./src/Main.ts":
/*!*********************!*\
!*** ./src/Main.ts ***!
\*********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"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.Main = exports.GDispatcher = void 0;
var RES_1 = __webpack_require__(/*! ../module/RES */ "./module/RES.ts");
var layers_1 = __webpack_require__(/*! ../module/views/layers */ "./module/views/layers.ts");
var G_EVENT_1 = __webpack_require__(/*! ./common/G_EVENT */ "./src/common/G_EVENT.ts");
var ctrls_1 = __webpack_require__(/*! ../module/ctrls */ "./module/ctrls/index.ts");
var StartScene_1 = __webpack_require__(/*! ./scenes/StartScene */ "./src/scenes/StartScene.ts");
var TaoBaoNet_1 = __webpack_require__(/*! ./TaoBaoNet */ "./src/TaoBaoNet.ts");
var resCanvasList_1 = __webpack_require__(/*! ../resCanvasList */ "./resCanvasList.js");
var stage_1 = __webpack_require__(/*! ./scenes/stage */ "./src/scenes/stage.ts");
exports.GDispatcher = new FYGE.EventDispatcher();
var Main = (function () {
function Main(canvas) {
var sysInfo;
if (my) {
FYGE.initedByCanvas(canvas);
sysInfo = my.getSystemInfoSync();
}
var stage = new FYGE.Stage(canvas, 750, 1624, sysInfo && sysInfo.windowWidth || document.body.clientWidth, sysInfo && sysInfo.windowHeight || document.body.clientHeight, FYGE.RENDERER_TYPE.CANVAS);
this.stage = stage;
stage_1.setStage(stage);
stage.addEventListener(FYGE.Event.INIT_STAGE, this.onAddToStage, this);
var self = this;
loop();
function loop() {
if (!self._pause) {
FYGE.Tween.flush();
stage.flush();
}
self.requestID = FYGE.getRequestAnimationFrame()(loop);
}
}
Main.prototype.onAddToStage = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
layers_1.layers.init(this.stage);
console.log("初始化层级完成");
return [4, RES_1.RES.loadSparkAssets(resCanvasList_1.default)];
case 1:
_a.sent();
console.log("通用资源加载完成");
ctrls_1.changeScene(StartScene_1.StartScene);
return [2];
}
});
});
};
Main.prototype.run = function () {
this._pause = false;
exports.GDispatcher.dispatchEvent(G_EVENT_1.G_EVENT.ON_SHOW);
};
Main.prototype.pause = function () {
exports.GDispatcher.dispatchEvent(G_EVENT_1.G_EVENT.ON_HIDE);
};
Main.prototype.addGlobalEvent = function (name, fun, thisObj, once) {
if (once === void 0) { once = false; }
if (once) {
exports.GDispatcher.once(name, fun, thisObj);
}
else {
exports.GDispatcher.addEventListener(name, fun, thisObj);
}
};
Main.prototype.dispatchGlobalEvent = function (name, data) {
exports.GDispatcher.dispatchEvent(name, data);
};
Main.prototype.removeGlobalEvent = function (name, fun, thisObj) {
exports.GDispatcher.removeEventListener(name, fun, thisObj);
};
Main.prototype.destroy = function () {
FYGE.Tween.removeAllTweens();
FYGE.getCancelAnimationFrame()(this.requestID);
layers_1.destroyLayers();
ctrls_1.destroyAllCtrls();
this.stage.destroy();
exports.GDispatcher.removeAllEventListener();
TaoBaoNet_1.destroyNetData();
};
return Main;
}());
exports.Main = Main;
/***/ }),
/***/ "./src/TaoBaoNet.ts":
/*!**************************!*\
!*** ./src/TaoBaoNet.ts ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"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.destroyNetData = exports.getTbData = exports.sendTbNet = exports.TbNetName = void 0;
var ctrls_1 = __webpack_require__(/*! ../module/ctrls */ "./module/ctrls/index.ts");
var Main_1 = __webpack_require__(/*! ./Main */ "./src/Main.ts");
var TbNetName;
(function (TbNetName) {
TbNetName["trackingReport"] = "squirrelsAdoptRest2c.trackingReport";
TbNetName["getIndex"] = "babycare.getIndex";
TbNetName["getActivityBaseInfoById"] = "babycare.getActivityBaseInfoById";
TbNetName["getGameInfo"] = "babycare.getGameInfo";
TbNetName["consumerTools"] = "babycare.consumerTools";
TbNetName["gameOver"] = "babycare.gameOver";
TbNetName["receiveTaskRewards"] = "babycare.receiveTaskRewards";
TbNetName["exchange"] = "babycare.exchange";
TbNetName["getPrizesByLevel"] = "babycare.getPrizesByLevel";
TbNetName["queryCredits"] = "babycare.queryCredits";
TbNetName["dojoin"] = "babycare.dojoin";
TbNetName["completeTask"] = "babycare.completeTask";
TbNetName["getTaskList"] = "babycare.getTaskList";
TbNetName["authorize"] = "mine.authorize";
TbNetName["favorShop"] = "mine.favorShop";
TbNetName["getUserAddress"] = "mine.getUserAddress";
TbNetName["getAdoptName"] = "mine.getAdoptName";
TbNetName["getAppData"] = "mine.getAppData";
TbNetName["navigateToOutside"] = "mine.navigateToOutside";
TbNetName["navigateTo"] = "mine.navigateTo";
TbNetName["navigateBack"] = "mine.navigateBack";
TbNetName["showSharePanel"] = "mine.showSharePanel";
TbNetName["openDetail"] = "mine.openDetail";
TbNetName["reportAnalytics"] = "mine.reportAnalytics";
})(TbNetName = exports.TbNetName || (exports.TbNetName = {}));
var dataRecord = {};
var fc;
function sendTbNet(netName, parameter, callback, hideMsg) {
if (hideMsg === void 0) { hideMsg = false; }
return new Promise(function (resolve, reject) {
var waitObj;
if (!my) {
var url = "../../mock/miniTb/" + netName + ".json";
fetchAsync(url)
.then(function (data) {
dataRecord[netName] = data;
if (!hideMsg && !data.success)
ctrls_1.showToast(data.message || "网络异常");
callback && callback(data.success, data);
resolve(data);
console.log("\n%c[ mock ]\n"
+ ("NAME : " + netName + " \n")
+ "STATE : %o \n"
+ "PARAM : %o \n"
+ "%cDATA : %o \n", "" + (data.success ? 'color:green' : 'color:red'), data.success, parameter, "" + (data.success ? 'color:green' : 'color:red'), data);
}, function () {
});
return;
}
var fun = function (e) {
ctrls_1.clearWait(waitObj);
Main_1.GDispatcher.removeEventListener(netName, fun);
var d = e.data;
dataRecord[netName] = d;
if (!hideMsg && !d.success)
ctrls_1.showToast(d.message || "网络超时");
callback && callback(d.success, d);
resolve(d);
console.log("\n%c[ request ]\n"
+ ("NAME : " + netName + " \n")
+ "STATE : %o \n"
+ "PARAM : %o \n"
+ "%cDATA : %o \n", "" + (d.success ? 'color:green' : 'color:red'), d.success, parameter, "" + (d.success ? 'color:green' : 'color:red'), d);
};
Main_1.GDispatcher.addEventListener(netName, fun);
waitObj = ctrls_1.wait(function () {
if (netName != TbNetName.favorShop &&
netName != TbNetName.getUserAddress &&
netName != TbNetName.authorize &&
netName != TbNetName.getAdoptName &&
netName != TbNetName.trackingReport &&
netName != TbNetName.reportAnalytics) {
fun({ type: netName, data: { success: false } });
}
}, 10000);
Main_1.GDispatcher.dispatchEvent({ type: "onMessage" }, { netName: netName, parameter: parameter });
});
}
exports.sendTbNet = sendTbNet;
function getTbData(netName) {
return dataRecord[netName] || null;
}
exports.getTbData = getTbData;
function destroyNetData() {
dataRecord = {};
}
exports.destroyNetData = destroyNetData;
function fetchAsync(url) {
return __awaiter(this, void 0, void 0, function () {
var response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, fetch(url)];
case 1:
response = _a.sent();
return [4, response.json()];
case 2:
data = _a.sent();
return [2, data];
}
});
});
}
var codeMsg = {
"210001": "服务器异常",
"210002": "用户不存在",
"210003": "邀请已达上限",
"210004": "无法邀请自己",
"210006": "该活动ID无效",
"210009": "该活动暂未开始",
"210010": "该分享ID不存在",
"210012": "该用户暂未获奖",
"210013": "领取失败",
"210015": "该活动已删除",
"210016": "该活动已经结束",
"210017": "该奖品已达领取上线",
"210018": "请先分享好友",
"210019": "暂有奖品未领取",
"210020": "暂有奖品未完成",
"210021": "请先玩一局游戏",
"210022": "请先选择奖品",
"210023": "领取失败,库存不足",
"210024": "请先成为会员",
"210025": "奖品已经过期",
"210026": "不能重复助力",
"210028": "请至我的奖品页重新领取",
};
/***/ }),
/***/ "./src/common/G_EVENT.ts":
/*!*******************************!*\
!*** ./src/common/G_EVENT.ts ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.G_EVENT = void 0;
var G_EVENT;
(function (G_EVENT) {
G_EVENT["ON_SHOW"] = "onShow";
G_EVENT["ON_HIDE"] = "onHide";
G_EVENT["UPDATE_TASK"] = "UpdateTask";
})(G_EVENT = exports.G_EVENT || (exports.G_EVENT = {}));
/***/ }),
/***/ "./src/scenes/DropItem.ts":
/*!********************************!*\
!*** ./src/scenes/DropItem.ts ***!
\********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var RES_1 = __webpack_require__(/*! ../../module/RES */ "./module/RES.ts");
var resCanvasList_1 = __webpack_require__(/*! ../../resCanvasList */ "./resCanvasList.js");
var DropItem = (function (_super) {
__extends(DropItem, _super);
function DropItem() {
var _this = _super.call(this) || this;
_this.texture = RES_1.RES.getRes(resCanvasList_1.default["593e9d74-4944-496a-b6c1-8316756f8bf7"].url);
_this.y = 0;
return _this;
}
DropItem.prototype.updatePosition = function () {
this.y += 10;
};
return DropItem;
}(FYGE.Sprite));
exports.default = DropItem;
/***/ }),
/***/ "./src/scenes/DropsCtrl.ts":
/*!*********************************!*\
!*** ./src/scenes/DropsCtrl.ts ***!
\*********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var stage_1 = __webpack_require__(/*! ./stage */ "./src/scenes/stage.ts");
var DropItem_1 = __webpack_require__(/*! ./DropItem */ "./src/scenes/DropItem.ts");
var DropsCtrl = (function () {
function DropsCtrl(root) {
this._root = root;
}
DropsCtrl.prototype.start = function () {
var _this = this;
stage_1.getStage().addEventListener(FYGE.Event.ENTER_FRAME, this.onEnterFrame, this);
for (var index = 0; index < 10; index++) {
setTimeout(function () {
_this.addDropItem();
}, 1000 * index);
}
};
DropsCtrl.prototype.addDropItem = function () {
this._drops = this._drops || [];
var drop = new DropItem_1.default();
this._root.addChild(drop);
drop.x = Math.random() * 400 + (750 - 400) / 2;
this._drops.push(drop);
};
DropsCtrl.prototype.onEnterFrame = function () {
if (this._drops)
this._drops.forEach(function (drop) { return drop.updatePosition(); });
};
DropsCtrl.prototype.destroy = function () {
stage_1.getStage().removeEventListener(FYGE.Event.ENTER_FRAME, this.onEnterFrame, this);
};
return DropsCtrl;
}());
exports.default = DropsCtrl;
/***/ }),
/***/ "./src/scenes/Root.ts":
/*!****************************!*\
!*** ./src/scenes/Root.ts ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var RES_1 = __webpack_require__(/*! ../../module/RES */ "./module/RES.ts");
var resCanvasList_1 = __webpack_require__(/*! ../../resCanvasList */ "./resCanvasList.js");
var DropsCtrl_1 = __webpack_require__(/*! ./DropsCtrl */ "./src/scenes/DropsCtrl.ts");
var Root = (function (_super) {
__extends(Root, _super);
function Root() {
var _this = _super.call(this) || this;
_this.once(FYGE.Event.ADDED_TO_STAGE, _this.onAddToStage, _this);
var bg = new FYGE.Sprite();
bg.x = 0;
bg.y = 0;
bg.texture = RES_1.RES.getRes(resCanvasList_1.default["cb54f3b5-0469-46d1-99ea-734153b92078"].url);
_this.addChild(bg);
console.log('fuck');
var ctrl = new DropsCtrl_1.default(_this);
ctrl.start();
return _this;
}
Root.prototype.onAddToStage = function () {
this.y = this.stage.viewRect.height / 2 - 1624 / 2;
};
return Root;
}(FYGE.Container));
exports.default = Root;
/***/ }),
/***/ "./src/scenes/StartScene.ts":
/*!**********************************!*\
!*** ./src/scenes/StartScene.ts ***!
\**********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.StartScene = void 0;
var Scene_1 = __webpack_require__(/*! ../../module/views/Scene */ "./module/views/Scene.ts");
var Root_1 = __webpack_require__(/*! ./Root */ "./src/scenes/Root.ts");
var StartScene = (function (_super) {
__extends(StartScene, _super);
function StartScene() {
return _super !== null && _super.apply(this, arguments) || this;
}
StartScene.prototype.initUi = function () {
_super.prototype.initUi.call(this);
var canvas = new FYGE.Container();
canvas.position.set(0, 0);
this.addChild(canvas);
};
StartScene.prototype.start = function () {
this.addChild(new Root_1.default());
};
return StartScene;
}(Scene_1.Scene));
exports.StartScene = StartScene;
/***/ }),
/***/ "./src/scenes/stage.ts":
/*!*****************************!*\
!*** ./src/scenes/stage.ts ***!
\*****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setStage = exports.getStage = void 0;
var _stage;
exports.getStage = function () { return _stage; };
exports.setStage = function (stage) {
_stage = stage;
};
/***/ })
/******/ });
});
//# sourceMappingURL=output.js.map
\ No newline at end of file
<view disable-scroll="true" class="page-game">
<canvas disable-scroll="true" id="canvas" type="2d" class="canvas" onTouchStart="onMouseEvent" onTouchMove="onMouseEvent" onTouchEnd="onMouseEvent" onReady="onCanvasReady">
</canvas>
</view>
\ No newline at end of file
'use strict';
import { Main } from './output';
//import API from '../../api';
Page({
data: {},
onLoad(props) {
this.setData(this.data || {});
},
onReady() {
console.log('on ready')
// let main = this.spark_startEngine(); //main.addEventListener....
},
spark_startEngine() {
console.log('spark_startEngine')
var self = this;
my.createCanvas({
id: 'canvas',
success: ccc => {
const dpr = my.getSystemInfoSync().pixelRatio;
const windowWidth = my.getSystemInfoSync().windowWidth;
const windowHeight = my.getSystemInfoSync().windowHeight;
ccc.width = windowWidth * dpr + dpr; //重新修改会有误差
ccc.height = windowHeight * dpr + dpr;
if (!this.main) {
this.main = new Main(ccc); //添加事件,为了和main里的通信
this.main.addGlobalEvent("onMessage", self.onMessage, self);
}
}
});
},
onCanvasReady() {
console.log('onCanvasReady')
this.spark_startEngine();
},
postMessage(netName, data) {
this.main.dispatchGlobalEvent({
type: netName
}, data); //以防复用事件event串了,就用这种方式
},
//和main通信的方法,接收main的信息
onMessage(e) {
//接口名字
let netName = e.data.netName; //接口参数
let parameter = e.data.parameter; //暂时发现3个需要用户操作的接口
//定制的授权
if (netName.indexOf("mine") == 0) {
var data = {
success: true
};
switch (netName) {
case "mine.getAppData":
//获取信息
let tmpApp = getApp();
console.log('app信息', tmpApp);
data = {
success: true,
data: {
activityId: tmpApp.activityId,
//|| "5e7c40e98564b57d7fb95812",
nickName: tmpApp.nickName,
avatar: tmpApp.avatar,
openId: tmpApp.openId,
isFocusShop: tmpApp.isFollow || false
}
};
break;
case 'test':
console.log('测试一下', parameter.hint);
break;
}
this.postMessage(netName, data);
} else {
var app = getApp(); //获取后端接口
const {
function: fc
} = app.cloud;
const [myCloudName, handler] = netName.split("."); //待写,
fc.invoke(myCloudName, parameter, handler).then(res => {
this.postMessage(netName, res);
});
}
},
//鼠标事件
onMouseEvent(e) {
if (this.main) this.main.stage.onMouseEvent(e);
},
onShow() {
// 页面显示
if (this.main) {
this.main.run();
this.main.dispatchGlobalEvent("onShow");
}
},
onHide() {
// 页面隐藏
if (this.main) {
this.main.pause();
this.main.dispatchGlobalEvent("onHide");
}
}
});
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
.mycanvaspage {
top: 0rpx;
left: 0rpx;
width: 750rpx;
height: 1624rpx;
display: block;
position: absolute;
}
.mycanvaspage .canvas {
width: 300rpx;
height: 300rpx;
opacity: 1;
display: block;
left: 0rpx;
top: 0rpx;
position: absolute;
}
<view class="mycanvaspage">
<view>
<canvas id="canvas" type="2d" class="canvas" disable-scroll="true" onTouchStart="onMouseEvent" onTouchMove="onMouseEvent" onTouchEnd="onMouseEvent" onReady="onCanvasReady"></canvas>
</view>
</view>
\ No newline at end of file
'use strict';
import resList from '../../resconfig/resList'; //import API from '../../api';
Page({
data: {},
onLoad(props) {
this.setData(this.data || {
resList: resList
});
}
});
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
/**
* 目前没有用到
* @param {*} resList
* @param {*} uuid
*/
const getSrcByUuid = (resList, uuid) => {
resList = resList || [];
for (let i = 0; i < resList.length; i++) {
if (resList[i].uuid == uuid) {
return resList[i].url
}
}
}
module.exports = {
getSrcByUuid
}
\ No newline at end of file
const resList = {
'4ee17a9c-5deb-43be-b205-16fb7593d172': {
name: 'spark',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/spark.810e94665ad6f7d7684f9b25b764e040a0cce7bf.png',
uuid: '4ee17a9c-5deb-43be-b205-16fb7593d172'
}
};
export default resList;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tb = require("./lib/tb");
const tbMock = require("./lib/tbMock");
const utils = require("./lib/utils");
const constants = require("./lib/constants");
const capi_1 = require("./lib/capi");
const request_1 = require("./lib/request");
const isH5 = 'undefined' !== typeof window;
// 如果为h5环境走mock数据
let _tb = {};
Object.entries(tb).forEach(([key, value]) => {
_tb[key] = isH5 ? tbMock[key] : value;
});
exports.default = {
capi: capi_1.default,
tb: _tb,
utils,
request: request_1.default,
constants
};
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/index.js"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,uCAAuC;AACvC,qCAAqC;AACrC,6CAA6C;AAC7C,qCAA8B;AAC9B,2CAAoC;AAEpC,MAAM,IAAI,GAAG,WAAW,KAAK,OAAO,MAAM,CAAC;AAE3C,iBAAiB;AACjB,IAAI,GAAG,GAAG,EAAE,CAAC;AACb,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;IAC1C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACxC,CAAC,CAAC,CAAC;AAEH,kBAAe;IACb,IAAI,EAAJ,cAAI;IACJ,EAAE,EAAE,GAAG;IACP,KAAK;IACL,OAAO,EAAP,iBAAO;IACP,SAAS;CACV,CAAC"}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const capi = {
getMyPrizeList: {
handle: 'getMyPrizeList',
isShowLoading: true
},
receiveObjectPrize: 'receiveObjectPrize',
receiveEnamePrize: 'receiveEnamePrize'
};
exports.default = capi;
//# sourceMappingURL=capi.js.map
\ No newline at end of file
{"version":3,"file":"capi.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/capi.js"],"names":[],"mappings":";;AAAA,MAAM,IAAI,GAAG;IACX,cAAc,EAAE;QACd,MAAM,EAAE,gBAAgB;QACxB,aAAa,EAAE,IAAI;KACpB;IACD,kBAAkB,EAAE,oBAAoB;IACxC,iBAAiB,EAAE,mBAAmB;CACvC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
\ No newline at end of file
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const tb_1 = require("./tb");
const utils_1 = require("./utils");
// 通用API封装方法
const capiFn = (apiList, request) => {
return {
receiveObjectPrize(params) {
return __awaiter(this, void 0, void 0, function* () {
const { handle, method, ext } = utils_1.getRequestParams(apiList['receiveObjectPrize']);
const userAddress = yield tb_1.getUserAddress().catch(err => {
tb_1.commonToast(err.errorMessage);
});
if (userAddress) {
const { name, phone, address } = userAddress.duibaAddress;
commonConfirm('提示', '确认使用该收货地址:' + name + phone + address, () => __awaiter(this, void 0, void 0, function* () {
params = Object.assign({ name,
phone,
address }, params);
const result = yield request(handle, method, params, ext).catch(res => {
tb_1.commonToast(res && res.message);
});
if (result && result.success) {
return true;
}
}));
}
return false;
});
},
receiveEnamePrize(params) {
return __awaiter(this, void 0, void 0, function* () {
const { handle, method, ext } = utils_1.getRequestParams(apiList['receiveEnamePrize']);
const result = yield request(handle, method, params, ext).catch(res => {
tb_1.commonToast(res && res.message);
});
if (result && result.success) {
return true;
}
return false;
});
}
};
};
exports.default = capiFn;
//# sourceMappingURL=capiFn.js.map
\ No newline at end of file
{"version":3,"file":"capiFn.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/capiFn.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAAmD;AACnD,mCAA2C;AAE3C,YAAY;AACZ,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IAClC,OAAO;QACC,kBAAkB,CAAC,MAAM;;gBAC7B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,wBAAgB,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;gBAChF,MAAM,WAAW,GAAG,MAAM,mBAAc,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;oBACrD,gBAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;gBAChC,CAAC,CAAC,CAAC;gBACH,IAAI,WAAW,EAAE;oBACf,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC,YAAY,CAAC;oBAC1D,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,GAAG,KAAK,GAAG,OAAO,EAAE,GAAS,EAAE;wBACpE,MAAM,mBACJ,IAAI;4BACJ,KAAK;4BACL,OAAO,IACJ,MAAM,CACV,CAAA;wBACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;4BACpE,gBAAW,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;wBAClC,CAAC,CAAC,CAAC;wBACH,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;4BAC5B,OAAO,IAAI,CAAC;yBACb;oBACH,CAAC,CAAA,CAAC,CAAC;iBACJ;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SAAA;QACK,iBAAiB,CAAC,MAAM;;gBAC5B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,wBAAgB,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC;gBAC/E,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;oBACpE,gBAAW,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;gBAClC,CAAC,CAAC,CAAC;gBACH,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;oBAC5B,OAAO,IAAI,CAAC;iBACb;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SAAA;KACF,CAAA;AACH,CAAC,CAAC;AAGF,kBAAe,MAAM,CAAC"}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PRIZE_TYPE = exports.DRAW_STATUS = void 0;
// 领取奖品状态
exports.DRAW_STATUS = {
// 待领取
WAITAWARD: 1,
// 处理中
PROCESSING: 2,
// 领取成功
SUCCESS: 3,
// 领取失败
FAIL: 4,
// 已过期
EXPIRED: 5,
// 重新领取
RETRY: 6
};
// 奖品类型
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/packages/jsx2taobao/template/api/tbcc-sdk/lib/constants.js"],"names":[],"mappings":";;;AAAA,SAAS;AACI,QAAA,WAAW,GAAG;IACzB,MAAM;IACN,SAAS,EAAE,CAAC;IACZ,MAAM;IACN,UAAU,EAAE,CAAC;IACb,OAAO;IACP,OAAO,EAAE,CAAC;IACV,OAAO;IACP,IAAI,EAAE,CAAC;IACP,MAAM;IACN,OAAO,EAAE,CAAC;IACV,OAAO;IACP,KAAK,EAAE,CAAC;CACT,CAAA;AAED,OAAO;AACM,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;CACV,CAAC"}
\ No newline at end of file
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const AMS_URL = 'https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=';
const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
if (!cloud) {
console.error('请传入cloud');
return false;
}
if (!cloudName) {
console.error('请传入云函数名称');
return false;
}
return (handle, method, params, ext = {}) => __awaiter(void 0, void 0, void 0, function* () {
const { activityId } = getApp();
// 默认注入activityId
params = Object.assign({ activityId }, params);
if (!params.activityId) {
console.error(`${handle}:请传入activityId`);
return false;
}
const _cloudName = ext.cloudName || cloudName;
const { isShowLoading } = ext;
const hideMyLoading = () => {
if (isShowLoading) {
my.hideLoading();
}
};
if (isShowLoading) {
my.showLoading();
}
const requestAms = () => {
return new Promise((resolve, reject) => {
my.request({
url: AMS_URL + _cloudName + '.' + handle,
method,
data: params,
dataType: 'json'
}).then(({ data: res }) => {
hideMyLoading();
if (res && res.success) {
resolve(res);
}
else {
reject(res);
}
}).catch(() => {
hideMyLoading();
reject();
});
});
};
const requestCloud = () => {
return new Promise((resolve, reject) => {
cloud.function.invoke(_cloudName, params, handle).then(res => {
console.log(handle, params, res);
hideMyLoading();
if (res && res.success) {
resolve(res);
}
else {
reject(res);
}
return res;
}).catch(() => {
hideMyLoading();
reject();
});
});
};
return requestType === 'ams' ? requestAms() : requestCloud();
});
};
exports.default = request;
//# sourceMappingURL=request.js.map
\ No newline at end of file
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/request.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,MAAM,OAAO,GAAG,iFAAiF,CAAC;AAElG,MAAM,OAAO,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,GAAG,OAAO,EAAE,EAAE,EAAE;IAC9D,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;KACd;IACD,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;KACd;IACD,OAAO,CAAO,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE;QAChD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,EAAE,CAAC;QAChC,iBAAiB;QACjB,MAAM,mBAAK,UAAU,IAAK,MAAM,CAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YACtB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,gBAAgB,CAAC,CAAC;YACzC,OA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,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;oBACjC,aAAa,EAAE,CAAC;oBAChB,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE;wBACtB,OAAO,CAAC,GAAG,CAAC,CAAC;qBACd;yBAAM;wBACL,MAAM,CAAC,GAAG,CAAC,CAAC;qBACb;oBACD,OAAO,GAAG,CAAC;gBACb,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;oBACZ,aAAa,EAAE,CAAC;oBAChB,MAAM,EAAE,CAAC;gBACX,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IAC/D,CAAC,CAAA,CAAC;AAEJ,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
\ No newline at end of file
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.textRiskIdentification = exports.chattingSendCard = exports.uploadImage = exports.getImageInfo = exports.chooseImage = exports.getUserAddress = exports.createAudio = exports.openDetail = exports.checkGoodsCollectedStatus = exports.collectGoods = exports.getServerTime = exports.redirectTo = exports.navigateTo = exports.navigateToOutside = exports.checkShopFavoredStatus = exports.favorShop = exports.getSystemInfo = exports.getAuthUserInfo = exports.commonConfirm = exports.simpleAlert = exports.commonToast = void 0;
/**
* 通用toast
* @param {string} content toast内容
* @param {number} duration 显示时长
* @param {function} successCb 成功回调
*/
exports.commonToast = (content, duration = 3000, successCb) => {
my.showToast({
content: content || '换个姿势再试一次~',
duration,
success: successCb
});
};
/**
* 简易alert
* @param {string} content toast内容
*/
exports.simpleAlert = content => {
my.alert({
content
});
};
/**
* 通用确认弹窗
* @param {string} title 标题
* @param {string} content 内容
* @param {function} successCb 成功回调
*/
exports.commonConfirm = (title = '提示', content, successCb) => {
my.confirm({
title,
content,
confirmButtonText: '确定',
cancelButtonText: '取消',
success: result => {
const { confirm } = result;
if (confirm) {
successCb && successCb();
}
}
});
};
/**
* 获取授权用户信息
* @returns {object} 用户登录信息
*/
exports.getAuthUserInfo = () => __awaiter(void 0, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
my.authorize({
scopes: 'scope.userInfo',
success: () => {
my.getAuthUserInfo({
success: userInfo => {
resolve(userInfo);
},
fail: err => {
reject(err);
}
});
},
fail: err => {
reject(err);
}
});
});
});
/**
* 获取系统信息
* @returns {object} 小程序系统信息
*/
exports.getSystemInfo = () => __awaiter(void 0, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
my.getSystemInfo({
success: res => {
resolve(res);
},
fail: err => {
reject(err);
}
});
});
});
/**
* 执行关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
exports.favorShop = (sellerId) => __awaiter(void 0, void 0, void 0, function* () {
if (!sellerId) {
console.error('favorShop: 请传入卖家Id');
return false;
}
return new Promise((resolve, reject) => {
my.tb.favorShop({
id: +sellerId,
success: res => {
resolve(res);
},
fail: err => {
if (err.error === 11) {
// error code 11 为用户取消操作不认作失败场景
resolve(false);
}
reject(err);
}
});
});
});
/**
* 判断是否关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
exports.checkShopFavoredStatus = (sellerId) => __awaiter(void 0, void 0, void 0, function* () {
if (!sellerId) {
console.error('checkShopFavoredStatus: 请传入卖家Id');
return false;
}
return new Promise((resolve, reject) => {
my.tb.checkShopFavoredStatus({
id: +sellerId,
success: res => {
resolve(res.isFavor);
},
fail: err => {
reject(err);
}
});
});
});
/**
* 跳转到外部链接
* @param {string} url 跳转链接
*/
exports.navigateToOutside = url => {
if (!url) {
console.error('navigateToOutside: 请传入url');
return false;
}
my.call('navigateToOutside', { url });
};
/**
* 跳转到内部链接(新开窗口)
* @param {string} url 跳转链接
*/
exports.navigateTo = url => {
if (!url) {
console.error('navigateTo: 请传入url');
return false;
}
my.navigateTo({ url });
};
/**
* 跳转到内部链接(不新开窗口)
* @param {string} url 跳转链接
*/
exports.redirectTo = url => {
if (!url) {
console.error('redirectTo: 请传入url');
return false;
}
my.redirectTo({ url });
};
/**
* 获取服务器时间
* @returns {number} 服务器时间戳
*/
exports.getServerTime = () => __awaiter(void 0, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
my.getServerTime({
success: res => {
resolve(res.time);
},
fail: err => {
reject(err);
}
});
});
});
/**
* 收藏商品
* @param {number} 商品id
* @returns {object} 收藏结果
*/
exports.collectGoods = (id) => __awaiter(void 0, void 0, void 0, function* () {
if (!id) {
console.error('collectGoods: 请传入商品id');
return false;
}
return new Promise((resolve, reject) => {
my.tb.collectGoods({
id: +id,
success: res => {
resolve(res);
},
fail: err => {
if (err.error === 11) {
// error code 11 为用户取消操作不认作失败场景
resolve(false);
}
reject(err);
}
});
});
});
/**
* 查询商品收藏状态
* @param {number} 商品id
* @returns {boolean} 商品收场状态
*/
exports.checkGoodsCollectedStatus = (id) => __awaiter(void 0, void 0, void 0, function* () {
if (!id) {
console.error('checkGoodsCollectedStatus: 请传入商品id');
return false;
}
return new Promise(resolve => {
my.tb.checkGoodsCollectedStatus({
id: +id,
success: res => {
resolve(res.isCollect);
}
});
});
});
/**
* 跳转到淘宝商品页
* @param {string} itemId 商品ID
*/
exports.openDetail = (itemId) => __awaiter(void 0, void 0, void 0, function* () {
if (!itemId) {
console.error('openDetail: 请传入商品id');
return false;
}
return new Promise((resolve, reject) => {
my.tb.openDetail({
itemId: itemId + '',
success: res => {
resolve(res);
},
fail: res => {
reject(res);
}
});
});
});
/**
* 创建音频类
*/
class AudioModel {
constructor(opts = {}) {
const { src } = opts;
if (!src) {
console.error('请输入音频链接');
return false;
}
try {
const innerAudioContext = my.createInnerAudioContext();
Object.keys(opts).forEach(item => {
innerAudioContext[item] = opts[item];
});
return innerAudioContext;
}
catch (e) {
console.error('当前版本不支持音频');
}
}
}
/**
* 创建音频实例
* @param {object} opts 配置对象 例 { src: '音频链接', autoplay: false }
*/
exports.createAudio = opts => {
const audioInstance = new AudioModel(opts);
return audioInstance;
};
/**
* 获取淘宝用户收货地址
*/
exports.getUserAddress = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
let defaults = {
addAddress: 'show',
searchAddress: 'hide',
locateAddress: 'hide',
joinTag: '' // 分割收货地址符号(淘宝商家有特定发货需求)
};
let _opts = Object.assign({}, defaults, opts);
return new Promise((resolve, reject) => {
my.authorize({
scopes: 'scope.addressList',
success: () => {
const { addAddress, searchAddress, locateAddress, joinTag } = _opts;
if (!my.tb.chooseAddress) {
reject({
noSupport: true,
errorMessage: '当前版本不支持选择收货地址,请升级到最新版本'
});
return false;
}
my.tb.chooseAddress({
addAddress,
searchAddress,
locateAddress
}, res => {
const { error, provinceName, countyName, cityName, streetName, detailInfo, name, telNumber } = res;
// 如果有error为用户取消操作不做操作
if (error) {
resolve(false);
}
else {
resolve(Object.assign(Object.assign({}, res), { duibaAddress: {
name,
phone: telNumber,
address: [provinceName, cityName, countyName, streetName, detailInfo].join(joinTag)
} }));
}
}, res => {
reject(res);
});
}
});
});
});
/**
* 选择图片
*/
exports.chooseImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
let defaults = {
count: 1,
sourceType: ['camera', 'album'],
compressLevel: 1
};
let _opts = Object.assign({}, defaults, opts);
const { count, sourceType, compressLevel } = _opts;
return new Promise((resolve, reject) => {
if (!my.chooseImage) {
reject({
noSupport: true,
errorMessage: '当前版本不支持选择收货地址,请升级到最新版本'
});
return false;
}
my.chooseImage({
count,
sourceType,
success: res => {
my.compressImage({
apFilePaths: res.apFilePaths,
level: compressLevel,
success: data => {
resolve(data);
},
fail: err => {
resolve(err);
}
});
},
fail: err => {
// error code 2001 为摄像头授权取消、ios 11为用户取消操作不认作失败场景 、安卓 为1
if (err.error !== 2001 && err.error !== 11 && err.error !== 1) {
reject(err);
}
else {
resolve(false);
}
}
});
});
});
/**
* 获取图片信息
* @param {string} src 图片地址
*/
exports.getImageInfo = (src) => __awaiter(void 0, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
my.getImageInfo({
src,
success: res => {
resolve(res);
},
fail: err => {
reject(err);
}
});
});
});
/**
* 获取图片信息
* @param {*} opts chooseImage配置参数
*/
exports.uploadImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
const { cloud } = getApp();
if (!cloud) {
console.error('chattingSendCard: 请传入app.cloud');
return false;
}
const chooseImageResult = yield exports.chooseImage(opts).catch(err => {
exports.commonToast(err && (err.errorMessage || '选择图片失败'));
});
if (chooseImageResult) {
const { apFilePaths } = chooseImageResult;
const filePath = apFilePaths[0];
const imageInfo = yield exports.getImageInfo(filePath).catch(err => {
exports.commonToast(err && err.errorMessage);
});
// 找不到图片信息
if (!imageInfo) {
return false;
}
const { path: imagePath } = imageInfo;
const { url } = yield cloud.file.uploadFile({
filePath,
fileType: 'image',
fileName: imagePath.split('/').pop()
});
return url;
}
return false;
});
/**
* 分享到群聊卡片
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
exports.chattingSendCard = (requestInfo) => __awaiter(void 0, void 0, void 0, function* () {
const { cloud } = getApp();
if (!cloud) {
console.error('chattingSendCard: 请传入app.cloud');
return false;
}
if (!requestInfo) {
console.error('chattingSendCard: 请传入卡片请求参数');
return false;
}
return new Promise((resolve, reject) => {
my.authorize({
scopes: 'scope.groupChat',
success: () => __awaiter(void 0, void 0, void 0, function* () {
const result = yield cloud.topApi
.invoke({
api: 'taobao.chatting.platform.message.sendcard',
data: { request_info: JSON.stringify(requestInfo) }
})
.catch(err => {
reject(err);
});
if (result) {
const { error } = result;
if (error) {
resolve(false);
}
else {
resolve(result);
}
}
}),
fail: err => {
if (err.error === 11) {
// error code 11 为用户取消操作不认作失败场景
resolve(false);
}
reject(err);
}
});
});
});
/**
* 分享到群聊卡片
* @param {*} cloud 小程序云
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
exports.textRiskIdentification = (text) => __awaiter(void 0, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
if (!my.tb.textRiskIdentification) {
reject({
noSupport: true,
errorMessage: '不支持文本校验'
});
}
my.tb.textRiskIdentification({
data: {
text
},
success: res => {
if (res.data && res.data.result) {
const { suggestion } = res.data.result;
if (suggestion === 'pass') {
resolve(true);
}
}
resolve(false);
},
fail: err => {
reject(err);
},
});
});
});
//# sourceMappingURL=tb.js.map
\ No newline at end of file
{"version":3,"file":"tb.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/tb.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;GAKG;AACU,QAAA,WAAW,GAAG,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,EAAE,SAAS,EAAE,EAAE;IACjE,EAAE,CAAC,SAAS,CAAC;QACX,OAAO,EAAE,OAAO,IAAI,WAAW;QAC/B,QAAQ;QACR,OAAO,EAAE,SAAS;KACnB,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,WAAW,GAAG,OAAO,CAAC,EAAE;IACnC,EAAE,CAAC,KAAK,CAAC;QACP,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACU,QAAA,aAAa,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;IAChE,EAAE,CAAC,OAAO,CAAC;QACT,KAAK;QACL,OAAO;QACP,iBAAiB,EAAE,IAAI;QACvB,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,MAAM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M,CAAC,CAAC;qBACjB;iBACF;YACH,CAAC,CAAA;YACD,IAAI,EAAE,GAAG,CAAC,EAAE;gBACV,IAAI,GAAG,CAAC,KAAK,KAAK,EAAE,EAAE;oBACpB,+BAA+B;oBAC/B,OAAO,CAAC,KAAK,CAAC,CAAC;iBAChB;gBACD,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,CAAO,IAAI,EAAE,EAAE;IACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,sBAAsB,EAAE;YACjC,MAAM,CAAC;gBACL,SAAS,EAAE,IAAI;gBACf,YAAY,EAAE,SAAS;aACxB,CAAC,CAAC;SACJ;QACD,EAAE,CAAC,EAAE,CAAC,sBAAsB,CAAC;YAC3B,IAAI,EAAC;gBACH,IAAI;aACL;YACD,OAAO,EAAE,GAAG,CAAC,EAAE;gBACb,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE;oBAC/B,MAAM,EAAE,UAAU,EAAE,GAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;oBACtC,IAAI,UAAU,KAAK,MAAM,EAAE;wBACzB,OAAO,CAAC,IAAI,CAAC,CAAC;qBACf;iBACF;gBACD,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YACD,IAAI,EAAE,GAAG,CAAC,EAAE;gBACV,MAAM,CAAC,GAAG,CAAC,CAAA;YACb,CAAC;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA,CAAA"}
\ No newline at end of file
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.textRiskIdentification = exports.chattingSendCard = exports.uploadImage = exports.getImageInfo = exports.chooseImage = exports.getUserAddress = exports.openDetail = exports.checkGoodsCollectedStatus = exports.collectGoods = exports.getServerTime = exports.redirectTo = exports.navigateTo = exports.navigateToOutside = exports.checkShopFavoredStatus = exports.favorShop = exports.getSystemInfo = exports.getAuthUserInfo = exports.commonConfirm = exports.simpleAlert = exports.commonToast = void 0;
/**
* 通用toast
* @param {string} content toast内容
* @param {number} duration 显示时长
* @param {function} successCb 成功回调
*/
exports.commonToast = (content, duration = 3000, successCb) => {
return '暂不支持toast';
};
/**
* 简易alert
* @param {string} content toast内容
*/
exports.simpleAlert = content => {
alert(content);
};
/**
* 通用确认弹窗
* @param {string} title 标题
* @param {string} content 内容
* @param {function} successCb 成功回调
*/
exports.commonConfirm = (title = '提示', content, successCb) => {
my.confirm({
title,
content,
confirmButtonText: '确定',
cancelButtonText: '取消',
success: result => {
const { confirm } = result;
if (confirm) {
successCb && successCb();
}
}
});
};
/**
* 获取授权用户信息
* @returns {object} 用户登录信息
*/
exports.getAuthUserInfo = () => __awaiter(void 0, void 0, void 0, function* () {
return {
nickName: 'nickName',
avatar: '123',
mixNick: '1234'
};
});
/**
* 获取系统信息
* @returns {object} 小程序系统信息
*/
exports.getSystemInfo = () => __awaiter(void 0, void 0, void 0, function* () {
return {
version: '9.5.0'
};
});
/**
* 执行关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
exports.favorShop = (sellerId) => __awaiter(void 0, void 0, void 0, function* () {
if (!sellerId) {
console.error('favorShop: 请传入卖家Id');
return false;
}
return {};
});
/**
* 判断是否关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
exports.checkShopFavoredStatus = (sellerId) => __awaiter(void 0, void 0, void 0, function* () {
if (!sellerId) {
console.error('checkShopFavoredStatus: 请传入卖家Id');
return false;
}
return true;
});
/**
* 跳转到外部链接
* @param {string} url 跳转链接
*/
exports.navigateToOutside = url => {
if (!url) {
console.error('navigateToOutside: 请传入url');
return false;
}
window.location = url;
};
/**
* 跳转到内部链接(新开窗口)
* @param {string} url 跳转链接
*/
exports.navigateTo = url => {
if (!url) {
console.error('navigateTo: 请传入url');
return false;
}
window.location = url;
};
/**
* 跳转到内部链接(不新开窗口)
* @param {string} url 跳转链接
*/
exports.redirectTo = url => {
if (!url) {
console.error('redirectTo: 请传入url');
return false;
}
window.replace(url);
};
/**
* 获取服务器时间
* @returns {number} 服务器时间戳
*/
exports.getServerTime = () => __awaiter(void 0, void 0, void 0, function* () {
return +new Date();
});
/**
* 收藏商品
* @param {number} 商品id
* @returns {object} 收藏结果
*/
exports.collectGoods = (id) => __awaiter(void 0, void 0, void 0, function* () {
if (!id) {
console.error('collectGoods: 请传入商品id');
return false;
}
return {};
});
/**
* 查询商品收藏状态
* @param {number} 商品id
* @returns {boolean} 商品收场状态
*/
exports.checkGoodsCollectedStatus = (id) => __awaiter(void 0, void 0, void 0, function* () {
if (!id) {
console.error('checkGoodsCollectedStatus: 请传入商品id');
return false;
}
return true;
});
/**
* 跳转到淘宝商品页
* @param {string} itemId 商品ID
*/
exports.openDetail = (itemId) => __awaiter(void 0, void 0, void 0, function* () {
if (!itemId) {
console.error('openDetail: 请传入商品id');
return false;
}
window.location = 'https://item.taobao.com/item.htm?id=' + itemId;
});
/**
* 获取淘宝用户收货地址
*/
exports.getUserAddress = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
return {
name: 1,
phone: 1,
address: 123
};
});
/**
* 选择图片
*/
exports.chooseImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
let defaults = {
count: 1,
sourceType: ['camera', 'album'],
compressLevel: 1
};
let _opts = Object.assign({}, defaults, opts);
const { count, sourceType, compressLevel } = _opts;
return new Promise((resolve, reject) => {
if (!my.chooseImage) {
reject({
noSupport: true,
errorMessage: '当前版本不支持选择收货地址,请升级到最新版本'
});
return false;
}
my.chooseImage({
count,
sourceType,
success: res => {
my.compressImage({
apFilePaths: res.apFilePaths,
level: compressLevel,
success: data => {
resolve(data);
},
fail: err => {
resolve(err);
}
});
},
fail: err => {
// error code 2001 为摄像头授权取消、ios 11为用户取消操作不认作失败场景 、安卓 为1
if (err.error !== 2001 && err.error !== 11 && err.error !== 1) {
reject(err);
}
else {
resolve(false);
}
}
});
});
});
/**
* 获取图片信息
* @param {string} src 图片地址
*/
exports.getImageInfo = (src) => __awaiter(void 0, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
my.getImageInfo({
src,
success: res => {
resolve(res);
},
fail: err => {
reject(err);
}
});
});
});
/**
* 获取图片信息
* @param {*} opts chooseImage配置参数
*/
exports.uploadImage = (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
const { cloud } = getApp();
if (!cloud) {
console.error('chattingSendCard: 请传入app.cloud');
return false;
}
const chooseImageResult = yield exports.chooseImage(opts).catch(err => {
exports.commonToast(err && (err.errorMessage || '选择图片失败'));
});
if (chooseImageResult) {
const { apFilePaths } = chooseImageResult;
const filePath = apFilePaths[0];
const imageInfo = yield exports.getImageInfo(filePath).catch(err => {
exports.commonToast(err && err.errorMessage);
});
// 找不到图片信息
if (!imageInfo) {
return false;
}
const { path: imagePath } = imageInfo;
const { url } = yield cloud.file.uploadFile({
filePath,
fileType: 'image',
fileName: imagePath.split('/').pop()
});
return url;
}
return false;
});
/**
* 分享到群聊卡片
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
exports.chattingSendCard = (requestInfo) => __awaiter(void 0, void 0, void 0, function* () {
alert('无法模拟');
return false;
});
/**
* 分享到群聊卡片
* @param {*} cloud 小程序云
* @param {object} requestInfo 分享到群聊卡片所需请求参数
*/
exports.textRiskIdentification = (text) => __awaiter(void 0, void 0, void 0, function* () {
return true;
});
//# sourceMappingURL=tbMock.js.map
\ No newline at end of file
{"version":3,"file":"tbMock.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/tbMock.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;GAKG;AACU,QAAA,WAAW,GAAG,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,EAAE,SAAS,EAAE,EAAE;IACjE,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,WAAW,GAAG,OAAO,CAAC,EAAE;IACnC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;GAKG;AACU,QAAA,aAAa,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;IAChE,EAAE,CAAC,OAAO,CAAC;QACT,KAAK;QACL,OAAO;QACP,iBAAiB,EAAE,IAAI;QACvB,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,MAAM,CAAC,EAAE;YAChB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;YAC3B,IAAI,OAAO,EAAE;gBACX,SAAS,IAAI,SAAS,EAAE,CAAC;aAC1B;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,eAAe,GAAG,GAAS,EAAE;IACxC,OAAO;QACL,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,MAAM;KAChB,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF;;;GAGG;AACU,QAAA,aAAa,GAAG,GAAS,EAAE;IACtC,OAAO;QACL,OAAO,EAAE,OAAO;KACjB,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF;;;;GAIG;AACU,QAAA,SAAS,GAAG,CAAM,QAA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AA;AAED;;;GAGG;AACU,QAAA,gBAAgB,GAAG,CAAO,WAAW,EAAE,EAAE;IACpD,KAAK,CAAC,MAAM,CAAC,CAAC;IACd,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAC;AAEF;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,CAAO,IAAI,EAAE,EAAE;IACnD,OAAO,IAAI,CAAC;AACd,CAAC,CAAA,CAAA"}
\ No newline at end of file
"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateAPI = exports.getRequestParams = exports.versionCompare = exports.dateFormatter = void 0;
const capiFn_1 = require("./capiFn");
/**
* 时间格式化
* @param date 接收可以被new Date()方法转换的内容
* @param format 字符串,需要的格式例如:'yyyy/MM/dd hh:mm:ss'
* @returns {String}
*/
exports.dateFormatter = (date, format = 'yyyy/MM/dd') => {
if (!date)
return '-';
date = new Date(typeof date === 'string' && isNaN(date) ? date.replace(/-/g, '/') : date);
let o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds(),
'q+': Math.floor((date.getMonth() + 3) / 3),
S: date.getMilliseconds()
};
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
}
for (let k in o) {
if (new RegExp('(' + k + ')').test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
}
}
return format;
};
/**
* 版本比较
* @param {string} cur 当前版本
* @param {string} compare 比较版本
*/
exports.versionCompare = (cur, compare) => {
const _cur = cur.split('.');
const _compare = compare.split('.');
if (+_cur[0] < +_compare[0]) {
return false;
}
else if (+_cur[0] === +_compare[0] && +_cur[1] < +_compare[1]) {
return false;
}
else if (+_cur[0] === +_compare[0] && +_cur[1] === +_compare[1] && +_cur[2] < +_compare[2]) {
return false;
}
return true;
};
/**
* 获取request请求所需参数
* @param {object/string} value API项配置
*/
exports.getRequestParams = value => {
if (typeof value === 'string') {
return {
handle: value,
method: 'POST',
ext: {}
};
}
else if (typeof value === 'object') {
const { handle, method = 'POST' } = value, ext = __rest(value, ["handle", "method"]);
return {
handle,
method,
ext: Object.assign({}, ext)
};
}
else {
console.error('getRequestParams: 传参有误');
}
};
/**
* 生成API
* @param {array} apiList API数据数组
* @param {function} request 请求
*/
exports.generateAPI = (apiList, request) => {
const api = {};
Object.entries(apiList).forEach(([key, value]) => {
const { handle, method, ext } = exports.getRequestParams(value);
api[key] = params => request(handle, method, params, ext);
});
api.fn = capiFn_1.default(apiList, request);
return api;
};
//# sourceMappingURL=utils.js.map
\ No newline at end of file
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/utils.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qCAA8B;AAC9B;;;;;GAKG;AACU,QAAA,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,EAAE;IAC3D,IAAI,CAAC,IAAI;QAAE,OAAO,GAAG,CAAC;IAEtB,IAAI,GAAG,IAAI,IAAI,CACb,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CACzE,CAAC;IACF,IAAI,CAAC,GAAG;QACN,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;QACzB,IAAI,EAAE,IAAI,CA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AE;IAC9C,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC/C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,wBAAgB,CAAC,KAAK,CAAC,CAAC;QACxD,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,GAAG,gBAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
\ No newline at end of file
const { cloud, requestType, cloudName } = getApp();
const request = (url, method, params, ext = {}) => {
const _cloudName = ext.cloudName || cloudName;
const { isShowLoading } = ext;
const hideMyLoading = () => {
if (isShowLoading) {
my.hideLoading();
}
};
if (isShowLoading) {
my.showLoading();
}
const requestAms = () => {
return new Promise((resolve, reject) => {
my.request({
url: `https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=${_cloudName + '.' + url}`,
method,
data: params,
dataType: 'json'
}).then(({ data: res }) => {
hideMyLoading();
if (res && res.success) {
resolve(res);
} else {
reject(res);
}
}).catch(() => {
hideMyLoading();
reject();
});
})
};
const requestCloud = () => {
return new Promise((resolve, reject) => {
cloud.function.invoke(_cloudName, params, url).then(res => {
console.log(url, params, res);
hideMyLoading();
if (res && res.success) {
resolve(res);
} else {
reject(res);
}
return res;
}).catch(() => {
hideMyLoading();
reject();
});
});
};
return requestType === 'ams' ? requestAms() : requestCloud();
};
export default request;
/**
* 通用toast
* @param {string} content toast内容
* @param {number} duration 显示时长
*/
export const commonToast = (content, duration = 3000) => {
my.showToast({
content: content || '换个姿势再试一次~',
duration
});
};
/**
* 获取授权用户信息
* @returns {object} 用户登录信息
*/
export const getAuthUserInfo = () => {
return new Promise((resolve, reject) => {
my.authorize({
scopes: 'scope.userInfo',
success: res => {
my.getAuthUserInfo({
success: userInfo => { resolve(userInfo); }
});
},
fail: err => {
reject(err);
}
});
});
};
/**
* 获取系统信息
* @returns {object} 小程序系统信息
*/
export const getSystemInfo = () => {
return new Promise((resolve, reject) => {
my.getSystemInfo({
success: res => { resolve(res); },
fail: err => { reject(err); }
});
});
};
/**
* 执行关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
export const favorShop = sellerId => {
return new Promise((resolve, reject) => {
my.tb.favorShop({
id: sellerId,
success: res => {
resolve(res);
},
fail: err => {
// error code 11 为用户取消操作不认作失败场景
// if (err.error !== 11) {
reject(err);
// }
}
});
})
};
/**
* 判断是否关注店铺
* @param {number} sellerId 店铺归属的卖家Id
* @returns {boolean} 关注状态
*/
export const checkShopFavoredStatus = sellerId => {
return new Promise((resolve, reject) => {
my.tb.checkShopFavoredStatus({
id: sellerId,
success: res => {
resolve(res.isFavor);
},
fail: err => {
reject(err);
}
});
});
};
/**
* 跳转到外部链接
* @param {string} url 跳转链接
*/
export const navigateToOutside = url => my.call("navigateToOutside", { url });
/**
* 跳转到内部链接(新开窗口)
* @param {string} url 跳转链接
*/
export const navigateTo = url => my.navigateTo({ url });
/**
* 跳转到内部链接(不新开窗口)
* @param {string} url 跳转链接
*/
export const redirectTo = url => my.redirectTo({ url });
/**
* 获取服务器时间
* @returns {number} 服务器时间戳
*/
export const getServerTime = () => {
return new Promise((resolve, reject) => {
my.getServerTime({
success: (res) => {
resolve(res.time);
},
fail: err => {
reject(err);
}
});
});
};
/**
* 收藏商品
* @param {number} 商品id
* @returns {object} 收藏结果
*/
export const collectGoods = id => {
return new Promise((resolve, reject) => {
my.tb.collectGoods({
id,
success: res => {
resolve(res);
},
fail: err => {
if (err.errorMessage === '该商品已收藏') {
// 已收藏没有给到errorCode,只能通过message判断
// 返回收藏成功,并且给到标记代表是已收藏的
resolve({ success: true, hasCollected: true, errorMessage: err.errorMessage });
} else if (err.error !== 11) {
// error code 11 为用户取消操作不认作失败场景
reject(err);
}
}
});
});
};
/**
* 查询商品收藏状态
* @param {number} 商品id
* @returns {boolean} 商品收场状态
*/
export const checkGoodsCollectedStatus = id => {
return new Promise((resolve, reject) => {
my.tb.checkGoodsCollectedStatus({
id,
success: res => {
resolve(res.isCollect);
},
fail: err => {
reject(err);
}
});
});
};
/**
* 时间格式化
* @param date 接收可以被new Date()方法转换的内容
* @param format 字符串,需要的格式例如:'yyyy-MM-dd hh:mm:ss'
* @returns {String}
*/
export const dateFormatter = (date, format = 'yyyy-MM-dd') => {
if (!date) return '-';
date = new Date(typeof date === 'string' && isNaN(date) ? date.replace(/-/g, '/') : date);
let o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds(),
'q+': Math.floor((date.getMonth() + 3) / 3),
'S': date.getMilliseconds()
};
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
}
for (let k in o) {
if (new RegExp('(' + k + ')').test(format)) {
format = format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
}
}
return format;
};
/**
* 创建音频类
*/
class AudioModel {
// isOn = false;
constructor(opts = {}) {
const { src } = opts;
if (!src) {
console.error('请输入音频链接');
return false;
}
try {
const innerAudioContext = my.createInnerAudioContext();
Object.keys(opts).forEach(item => {
innerAudioContext[item] = opts[item];
});
// this.isOn = opts.autoplay;
// innerAudioContext.isOn = opts.autoplay;
return innerAudioContext;
} catch (e) {
console.error('当前版本不支持音频');
}
}
};
/**
* 创建音频实例
* @param {object} opts 配置对象 例 { src: '音频链接', autoplay: false }
*/
export const createAudio = opts => {
const audioInstance = new AudioModel(opts)
return audioInstance;
};
/**
* 获取淘宝用户收货地址
*/
export const getUserAddress = (opts = {}) => {
let defaults = {
addAddress: 'show',
searchAddress: 'hide',
locateAddress: 'hide',
joinTag: '' // 分割收货地址符号(淘宝商家有特定发货需求)
};
let _opts = Object.assign({}, defaults, opts);
return new Promise((resolve, reject) => {
my.authorize({
scopes: 'scope.addressList',
success: () => {
const { addAddress, searchAddress, locateAddress, joinTag } = _opts;
if (!my.tb.chooseAddress) {
reject({ support: false, errorMessage: '当前版本不支持选择收货地址,请升级到最新版本' });
return false;
}
my.tb.chooseAddress({
addAddress,
searchAddress,
locateAddress
}, res => {
const { error, provinceName, countyName, cityName, streetName, detailInfo, name, telNumber } = res;
// 如果有error为用户取消操作不做操作
if (error) {
resolve(false);
} else {
resolve({
...res,
duibaAddress: {
name,
phone: telNumber,
address: [provinceName, cityName, countyName, streetName, detailInfo].join(joinTag)
}
});
}
}, res => {
reject(res);
})
},
});
});
};
/**
* 版本比较
* @param {string} cur 当前版本
* @param {string} compare 比较版本
*/
export const versionCompare = (cur, compare) => {
const _cur = cur.split('.');
const _compare = compare.split('.');
if (+_cur[0] < +_compare[0]) {
return false;
} else if (+_cur[0] === +_compare[0] && +_cur[1] < +_compare[1]) {
return false;
} else if (+_cur[0] === +_compare[0] && +_cur[1] === +_compare[1] && +_cur[2] < +_compare[2]) {
return false;
}
return true;
}
/**
* 打开详情页
* @param {string} itemId
*/
export const openDetail = (itemId) => {
return new Promise((resolve, reject) => {
my.tb.openDetail({
itemId,
success: (res) => {
resolve(res)
},
fail: (res) => {
reject(res)
},
});
})
}
export const reportAnalytics = (logkey) => {
my.reportAnalytics('click', {
// 标志某一类事件,方便数据分析进行分组
'logkey': logkey
})
}
//暂时只有一个音乐,临时处理
// let bgMusic;
// let gameMusic;
let bgs = {
}
export const playBgMusic = (isOn, src) => {//待测试
for (let k in bgs) {
if (bgs[k].isOn) {
bgs[k].stop();
}
// bgs[k].isOn = false; /// TODO 自己记一个开关,因为淘宝的玩意stop之后虽然听不到,但还是在播放,会触发loop播放和onEnded事件
}
const key = src;
if (isOn) {
if (!bgs[key]) {
bgs[key] = createAudio({
src: src,
autoplay: true,
loop: false /// TODO 暂时无效?2020.08.12 目前有效,但stop后还会跑数据,导致到音频结束到时间又自动播放
});
bgs[key].onPlay(() => {
bgs[key].isOn = true;
});
bgs[key].onStop(() => {
bgs[key].isOn = false;
});
/// TODO监听结束,因为loop无效 2020.08.12 loop有效,这个操作是为了解决stop之后还会跑音频数据的问题
bgs[key].onEnded(() => {
if (bgs[key].isOn) { // 判断自己记录的开关
bgs[key].play();
// bgs[key].isOn = true;
}
});
bgs[key].play(); // 安卓有时候autoplay好像莫得用
// console.log(src)
// bgs[key].isOn = true; /// TODO 自己记一个开关,因为淘宝的玩意stop之后虽然听不到,但还是在播放,会触发loop播放和onEnded事件
} else {
bgs[key].play();
// bgs[key].isOn = true; /// TODO 自己记一个开关,因为淘宝的玩意stop之后虽然听不到,但还是在播放,会触发loop播放和onEnded事件
}
} else {
if (bgs[key]) {
// bgs[key].pause(); /// pause 垃圾,不能用
bgs[key].stop();
// bgs[key].isOn = false; /// TODO 自己记一个开关,因为淘宝的玩意stop之后虽然听不到,但还是在播放,会触发loop播放和onEnded事件
}
}
}
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