Commit 238b9b29 authored by Edwise's avatar Edwise 🍷

Merge remote-tracking branch 'refs/remotes/origin/master'

parents a6ff0b94 2e2e9de0
# hello_taobao2 # canvas开发
http://gitlab2.dui88.com/wanghongyuan/hello_canvas
# 注意的点
- 不要一次性预加载整个项目的图片,只预加载canvas game需要的。
- 复杂动效用Lottie
- project/src/canvas/game/resCanvasList.js里URL要https开头
# 打开弹窗
```js
sendTbNet(TbNetName.showModal, {name:'ruleModal'}, (s, res) => { })
```
# 切换场景
```js
sendTbNet(TbNetName.navigateToPage, {name:'pageshop'}, (s, res) => { })
```
\ No newline at end of file
...@@ -7,8 +7,8 @@ cloud.init({ ...@@ -7,8 +7,8 @@ cloud.init({
App({ App({
requestType: 'cloud', // yapi,cloud: 云函数 requestType: 'cloud', // yapi,cloud: 云函数
// requestType: 'yapi', // yapi,cloud: 云函数 requestType: 'yapi', // yapi,cloud: 云函数
cloudName: 'bubbleSurviva', // 主云函数项目名 base clientTemplate2C cloudName: 'floor', // 主云函数项目名 base clientTemplate2C
cloud, cloud,
tbcc, tbcc,
onLaunch(options) { onLaunch(options) {
......
{ {
"pages": [ "pages": [
"pages/index/index",
"pages/pagecanvas/pagecanvas", "pages/pagecanvas/pagecanvas",
"pages/pageshop/pageshop", "pages/pageshop/pageshop",
"pages/myprize/myprize", "pages/myprize/myprize"
"pages/index/index"
], ],
"window": { "window": {
"enableSkia": "true", "enableSkia": "true",
......
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
</view> </view>
<view class="logistics-modal-container__content-right"> <view class="logistics-modal-container__content-right">
<view class="logistics-modal-container__content-name">{{prizeItem.name}}</view> <view class="logistics-modal-container__content-name">{{prizeItem.name}}</view>
<view class="logistics-modal-container__content-copy"> <!-- <view class="logistics-modal-container__content-copy">
<view class="logistics-modal-container__content-copy__code">奖品编码:{{prizeItem._id}}</view> <view class="logistics-modal-container__content-copy__code">奖品编码:{{prizeItem._id}}</view>
<view class="logistics-modal-container__content-copy__img" onTap="copyPrizeId"></view> <view class="logistics-modal-container__content-copy__img" onTap="copyPrizeId" style="{{`background: url(${task.copyIcon}) no-repeat;background-size: 100% 100%;`}}"></view>
</view> </view> -->
<view class="logistics-modal-container__content-desc">{{prizeItem.shipStatus== 3?'发货状态:已发货':'发货状态:发货'}}</view> <view class="logistics-modal-container__content-desc">{{prizeItem.shipStatus== 3?'发货状态:已发货':'发货状态:发货'}}</view>
<view class="logistics-modal-container__content-desc" a:if="{{prizeItem.shipStatus == 2}}">温馨提示:奖品将在活动结束7天内陆续发出</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" a:else>
<view class="logistics-modal-container__content-copy__code">{{'物流单号:'+prizeItem.shipNum}}</view> <view class="logistics-modal-container__content-copy__code">{{'物流单号:'+prizeItem.shipNum}}</view>
......
import { SHARE_CONFIG } from '/tbcc-sdk/lib/constants';
const app = getApp(); const app = getApp();
const { tbcc } = app; const { tbcc } = app;
const { commonToast } = tbcc.tb; const { commonToast } = tbcc.tb;
...@@ -23,6 +25,7 @@ Component({ ...@@ -23,6 +25,7 @@ Component({
//复制运单号 //复制运单号
copyCode() { copyCode() {
console.log('fuck copyCode')
let { shipNum } = this.props.prizeItem let { shipNum } = this.props.prizeItem
my.setClipboard({ my.setClipboard({
text: shipNum + '', text: shipNum + '',
...@@ -41,4 +44,7 @@ Component({ ...@@ -41,4 +44,7 @@ Component({
}); });
} }
}, },
onShareAppMessage() {
return SHARE_CONFIG;
},
}); });
...@@ -12,14 +12,15 @@ ...@@ -12,14 +12,15 @@
.my-prize-page .my-prize-wrap { .my-prize-page .my-prize-wrap {
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: auto; /* overflow: auto; */
overflow-x: auto;
} }
.my-prize-page .my-prize-label { .my-prize-page .my-prize-label {
width: 208rpx; width: 286rpx;
height: 36rpx; height: 49rpx;
margin: 140rpx auto 40rpx; margin: 140rpx auto 40rpx;
background: url('//yun.dui88.com/duiba-components-c-myprizeprize_title.png') no-repeat; background: url('//yun.duiba.com.cn/aurora/assets/a15fe07a819f3f6deb271725b37468030523dc05.png') no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
} }
...@@ -45,7 +46,10 @@ ...@@ -45,7 +46,10 @@
width: 700rpx; width: 700rpx;
height: 161rpx; height: 161rpx;
background-color: #ffffff; background-color: #ffffff;
box-shadow: 2rpx 3rpx 18rpx 0 rgba(230, 146, 255, 0.6); border-color:rgb(255, 63, 38);
border-width: 1rpx;
border-style: solid;
/* box-shadow: 2rpx 3rpx 18rpx 0 rgb(255, 63, 38); */
border-radius: 10rpx; border-radius: 10rpx;
box-sizing: border-box; box-sizing: border-box;
} }
...@@ -58,7 +62,7 @@ ...@@ -58,7 +62,7 @@
.my-prize-page .my-prize-item .my-prize-content { .my-prize-page .my-prize-item .my-prize-content {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
padding: 0 20rpx; padding: 10rpx 20rpx 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 130rpx; height: 130rpx;
...@@ -97,7 +101,7 @@ ...@@ -97,7 +101,7 @@
} }
.my-prize-page .my-prize-item .my-prize-tip { .my-prize-page .my-prize-item .my-prize-tip {
margin-top: 8rpx; margin-top: 16rpx;
font-size: 20rpx; font-size: 20rpx;
line-height: 20rpx; line-height: 20rpx;
letter-spacing: 0; letter-spacing: 0;
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<image class="my-prize-avatar" src="{{item.image}}"/> <image class="my-prize-avatar" src="{{item.image}}"/>
<view class="my-prize-content"> <view class="my-prize-content">
<label class="my-prize-name">{{item.name}}</label> <label class="my-prize-name">{{item.name}}</label>
<view class="my-prize-subtitle"> <!-- <view class="my-prize-subtitle"> -->
<label class="my-prize-code">奖品编码:{{item._id}}</label> <!-- <label class="my-prize-code">奖品编码:{{item._id}}</label> -->
<!-- 复制按钮 --> <!-- 复制按钮 -->
<image class="my-prize-copy" data-text="{{item._id}}" onTap="handleCopyId" src="{{task.image.copyIcon}}" /> <!-- <image class="my-prize-copy" data-text="{{item._id}}" onTap="handleCopyId" src="{{task.image.copyIcon}}" /> -->
</view> <!-- </view> -->
<view class="my-prize-tip" a:if="{{item.drawStatus === PRIZE_DRAW_STATUS_MAPPRIZE_DRAW_STATUS_MAP.FAILURE}}">{{item.remark}}</view> <view class="my-prize-tip" a:if="{{item.drawStatus === PRIZE_DRAW_STATUS_MAP.FAILURE}}">{{item.remark}}</view>
<view class="my-prize-tip" a:if="{{item.drawStatus === PRIZE_DRAW_STATUS_MAP.REPEAT || (item.drawStatus === PRIZE_DRAW_STATUS_MAP.RECEIVE)}}">请于{{endTime}}前领取</view> <view class="my-prize-tip" a:if="{{item.drawStatus === PRIZE_DRAW_STATUS_MAP.REPEAT || (item.drawStatus === PRIZE_DRAW_STATUS_MAP.RECEIVE)}}">请于{{endTime}}前领取</view>
<view class="my-prize-tip" a:if="{{item.drawStatus === PRIZE_DRAW_STATUS_MAP.FINISHED }}">奖品已过期失效</view> <view class="my-prize-tip" a:if="{{item.drawStatus === PRIZE_DRAW_STATUS_MAP.FINISHED }}">奖品已过期失效</view>
</view> </view>
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
<!-- 实物查看物流 --> <!-- 实物查看物流 -->
<image a:if="{{item.type === PRIZE_TYPE_MAP.ENTITY}}" onTap="handleView" data-item="{{item}}" src="{{task.image.logisticsBth}}" /> <image a:if="{{item.type === PRIZE_TYPE_MAP.ENTITY}}" onTap="handleView" data-item="{{item}}" src="{{task.image.logisticsBth}}" />
<!-- 优惠券去使用 --> <!-- 优惠券去使用 -->
<image a:else onTap="handleTouse" data-item="{{item}}" src="{{task.image.useBtn}}" /> <image a:else data-item="{{item}}" src="{{task.image.gotBtn}}" />
<!-- <image a:else onTap="handleTouse" data-item="{{item}}" src="{{task.image.useBtn}}" /> -->
</block> </block>
<!-- 重新领取 --> <!-- 重新领取 -->
<image a:if="{{item.drawStatus===PRIZE_DRAW_STATUS_MAP.REPEAT}}" onTap="handleClick" data-item="{{item}}" src="{{task.image.getAgainBtn}}" /> <image a:if="{{item.drawStatus===PRIZE_DRAW_STATUS_MAP.REPEAT}}" onTap="handleClick" data-item="{{item}}" src="{{task.image.getAgainBtn}}" />
......
import { SHARE_CONFIG } from '/tbcc-sdk/lib/constants';
const app = getApp(); const app = getApp();
const { tbcc } = app; const { tbcc } = app;
const { commonToast, navigateToOutside, getUserAddress, setClipboard } = tbcc.tb; const { commonToast, navigateToOutside, getUserAddress, setClipboard } = tbcc.tb;
...@@ -23,6 +23,9 @@ Component({ ...@@ -23,6 +23,9 @@ Component({
didMount() { }, didMount() { },
didUpdate() { }, didUpdate() { },
didUnmount() { }, didUnmount() { },
onShareAppMessage() {
return SHARE_CONFIG;
},
methods: { methods: {
//领取奖品 //领取奖品
handleClick(e) { handleClick(e) {
......
'use strict'; 'use strict';
import API from "/api"; import API from "/api";
import { SHARE_CONFIG } from '/tbcc-sdk/lib/constants';
const app = getApp(); const app = getApp();
const { tbcc } = app; const { tbcc } = app;
const { commonToast, navigateToOutside, getUserAddress, setClipboard } = tbcc.tb; const { commonToast, navigateToOutside, getUserAddress, setClipboard } = tbcc.tb;
...@@ -15,19 +16,20 @@ Page({ ...@@ -15,19 +16,20 @@ Page({
endTime: null,//到期时间 endTime: null,//到期时间
task: { task: {
image: { image: {
bg: '//yun.duiba.com.cn/aurora/assets/e13fab3165d3a6bb4cbe8827e8f0fd41084b0091.png', //背景图 bg: '//yun.duiba.com.cn/aurora/assets/7283d715cc5c7d13a5f498d15f5f5b9f4d9c29e5.jpg', //背景图
copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制 copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制
addressBth: '//yun.dui88.com/duiba-components-c-myprizeto_address.png', //填写地址(实物奖品) addressBth: '//yun.duiba.com.cn/aurora/assets/82cc3c6d8861334ebaf128c98e3341b687bdc007.png', //填写地址(实物奖品)
getBth: '//yun.dui88.com/duiba-components-c-myprizeget_now.png', //立即领取(除实物奖品外) getBth: '//yun.dui88.com/duiba-components-c-myprizeget_now.png', //立即领取(除实物奖品外)
logisticsBth: '//yun.dui88.com/duiba-components-c-myprizelogistics.png', //查看物流 logisticsBth: '//yun.duiba.com.cn/aurora/assets/661f86ff3392cb3b56922b048acf74bebc07bb23.png', //查看物流
useBth: '//yun.dui88.com/duiba-components-c-myprizeto_use.png', //去使用(除实物奖品外) useBtn: '//yun.duiba.com.cn/aurora/assets/0829f92f771c5e9fdb05a258a46b2d038d3a9997.png', //去使用(除实物奖品外)
getAgainBtn: '//yun.dui88.com/duiba-components-c-myprizeget_again.png', //重新领取 gotBtn: '//yun.duiba.com.cn/aurora/assets/1120dd6b6ce4abe2666e877e3ae33eb99a778009.png', //已领取(优惠券)
getAgainBtn: '//yun.duiba.com.cn/aurora/assets/716f0a388144945b169554a30ff4a16f7bcb95ab.png', //重新领取
invalidBtn: '//yun.duiba.com.cn/spark/assets/914ba8643c8abb8d710a3126ec312aecf6c4daf0.png', //已失效 invalidBtn: '//yun.duiba.com.cn/spark/assets/914ba8643c8abb8d710a3126ec312aecf6c4daf0.png', //已失效
failBth: '//yun.duiba.com.cn/spark/assets/8267375232058a6d0140270b1594427fb08d6ae3.png', //领取失败 failBth: '//yun.duiba.com.cn/spark/assets/8267375232058a6d0140270b1594427fb08d6ae3.png', //领取失败
}, },
logisticsImage: { logisticsImage: {
shipped: '//yun.dui88.com/duiba-components-c-myprizeprize_shipped.png', // 已发货物理弹窗 shipped: '//yun.duiba.com.cn/aurora/assets/3a7b68ec171ee339ce619d19f6ae3f9c1e6d801a.png', // 已发货物理弹窗
notShipped: '//yun.dui88.com/duiba-components-c-myprizenotshipped.png', // 待发货物流弹窗 notShipped: '//yun.duiba.com.cn/aurora/assets/ee0300d7b472c555ecf0b7b8d582fcf9189c2d19.png', // 待发货物流弹窗
copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制 copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制
}, },
btnStyle: { // 按钮自定义样式 btnStyle: { // 按钮自定义样式
...@@ -40,18 +42,26 @@ Page({ ...@@ -40,18 +42,26 @@ Page({
flag = false flag = false
this.getMyPrize(); this.getMyPrize();
}, },
onShareAppMessage() {
return SHARE_CONFIG;
},
// 到期时间 // 到期时间
getEndTime(prizeList = []) { getEndTime(prizeList = []) {
if (!prizeList || !prizeList.length) return null if (!prizeList || !prizeList.length) return null
const endTime = prizeList[0].expiredTime const endTime = prizeList[0].expiredTime
if (!endTime) return null if (!endTime) return null;
const t1 = new Date(endTime).toLocaleDateString() + '';//获取年月日 const yy = new Date(endTime).getFullYear();
const mm = new Date(endTime).getMonth() + 1;
const dd = new Date(endTime).getDate();
const t1 = `${yy}${mm}${dd}日`;
// console.log(new Date(endTime).toLocaleDateString())
// const t1 = new Date(endTime).toLocaleDateString() + '';//获取年月日
const t2 = new Date(endTime).getHours() + '';//获取时 const t2 = new Date(endTime).getHours() + '';//获取时
const t3 = new Date(endTime).getMinutes() + '';//获取分 const t3 = new Date(endTime).getMinutes() + '';//获取分
const t4 = new Date(endTime).getMilliseconds() + '';//获取秒 const t4 = new Date(endTime).getMilliseconds() + '';//获取秒
console.log(endTime, new Date(endTime + 48 * 60 * 60 * 1000).toLocaleString(), 'endTime'); console.log(endTime, new Date(endTime + 48 * 60 * 60 * 1000).toLocaleString(), 'endTime');
this.setData({ this.setData({
endTime: t1 + " " + t2.padStart(2, '0') + ":" + t3.padStart(2, '0') + ":" + t4.padStart(2, '0') endTime: t1 + "" + t2.padStart(2, '0') + ":" + t3.padStart(2, '0') + ":" + t4.padStart(2, '0')
}) })
}, },
...@@ -71,9 +81,9 @@ Page({ ...@@ -71,9 +81,9 @@ Page({
}) || {}; }) || {};
if (success && data) { if (success && data) {
this.setData({ this.setData({
myPrizeList: data.list myPrizeList: data
}) })
this.getEndTime(data.list) this.getEndTime(data)
} }
if (type != 'noLoading') { if (type != 'noLoading') {
my.hideLoading(); my.hideLoading();
...@@ -116,21 +126,29 @@ Page({ ...@@ -116,21 +126,29 @@ Page({
if (flag) { if (flag) {
return return
} }
my.showLoading(); // my.showLoading();
flag = true; flag = true;
const { activityId } = app; const { activityId } = app;
const { item } = e.target.dataset; const { item } = e.target.dataset;
const userAddress = await getUserAddress({ joinTag: " " }) const userAddress = await getUserAddress({ joinTag: " " }).catch((data)=>{
my.hideLoading(); flag = false
console.log('getUserAddress出错了,错误信息是',data);
})
// my.hideLoading();
if (!userAddress) return if (!userAddress) return
// commonToast(' getUserAddress =>'+JSON.stringify( userAddress))
const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {}; const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {};
const params = { const params = {
activityId, activityId,
area:countyName,
addressdetail:detailInfo,
name, name,
phone: telNumber, phone: telNumber,
detailInfo, detailInfo,
cityCode, cityCode,
cityName, cityName,
city:cityName,
province:provinceName,
provinceName, provinceName,
countyName, countyName,
streetName, streetName,
...@@ -155,13 +173,22 @@ Page({ ...@@ -155,13 +173,22 @@ Page({
}, },
// 领取实物 // 领取实物
async receiveObjectPrize(params) { async receiveObjectPrize(params) {
const { success, data, message } = await API.receiveObjectPrize(params) || {} // commonToast('正在调用receiveObjectPrize'+JSON.stringify(params))
if (success && data) { API.receiveObjectPrize(params).then((res) => {
commonToast('领取成功') // setTimeout(() => {
} else { // commonToast(JSON.stringify(res))
commonToast(message) // }, 5000);
}
this.getMyPrize() const { success, data, message } = res;
if (success && data) {
commonToast('领取成功')
} else {
commonToast(message)
}
this.getMyPrize()
},(rej)=>{
commonToast(rej.message)
});
}, },
// 积分 // 积分
async handleGetIntergation(e) { async handleGetIntergation(e) {
......
"use strict"; import * as tb from './lib/tb';
Object.defineProperty(exports, "__esModule", { value: true }); import * as tbMock from './lib/tbMock';
const tb = require("./lib/tb"); import * as utils from './lib/utils';
const tbMock = require("./lib/tbMock"); import * as constants from './lib/constants';
const utils = require("./lib/utils"); import capi from './lib/capi';
const constants = require("./lib/constants"); import request from './lib/request';
const capi_1 = require("./lib/capi");
const request_1 = require("./lib/request");
const isH5 = 'undefined' !== typeof window; const isH5 = 'undefined' !== typeof window;
// 如果为h5环境走mock数据 // 如果为h5环境走mock数据
let _tb = {}; let _tb = {};
Object.entries(tb).forEach(([key, value]) => { Object.entries(tb).forEach(([key, value]) => {
_tb[key] = isH5 ? tbMock[key] : value; _tb[key] = isH5 ? tbMock[key] : value;
}); });
exports.default = {
capi: capi_1.default, export default {
tb: _tb, capi,
utils, tb: _tb,
request: request_1.default, utils,
constants request,
}; constants
//# sourceMappingURL=index.js.map };
\ No newline at end of file \ 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 = { const capi = {
getMyPrizeList: { getMyPrizeList:'getMyPrizeList',
handle: 'getMyPrizeList', receiveObjectPrize: 'receiveObjectPrize',
isShowLoading: true receiveEnamePrize: 'receiveEnamePrize',
}, getItemListByItemIds: 'getItemListByItemIds',
receiveObjectPrize: 'receiveObjectPrize', getCollectItemList: 'getCollectItemList',
receiveEnamePrize: 'receiveEnamePrize' doCollectGoodsTask: 'doCollectGoodsTask',
getVipInfo:'getVipInfo'
}; };
exports.default = capi;
//# sourceMappingURL=capi.js.map export default capi;
\ 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"; import { getUserAddress, commonToast } from './tb';
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { import { getRequestParams } from './utils';
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封装方法 // 通用API封装方法
const capiFn = (apiList, request) => { const capiFn = (apiList, request) => {
return { return {
receiveObjectPrize(params) { async receiveObjectPrize(params) {
return __awaiter(this, void 0, void 0, function* () { const { handle, method, ext } = getRequestParams(apiList['receiveObjectPrize']);
const { handle, method, ext } = utils_1.getRequestParams(apiList['receiveObjectPrize']); const userAddress = await getUserAddress().catch(err => {
const userAddress = yield tb_1.getUserAddress().catch(err => { commonToast(err.errorMessage);
tb_1.commonToast(err.errorMessage); });
}); if (userAddress) {
if (userAddress) { const { name, phone, address } = userAddress.duibaAddress;
const { name, phone, address } = userAddress.duibaAddress; commonConfirm('提示', '确认使用该收货地址:' + name + phone + address, async () => {
commonConfirm('提示', '确认使用该收货地址:' + name + phone + address, () => __awaiter(this, void 0, void 0, function* () { params = {
params = Object.assign({ name, name,
phone, phone,
address }, params); address,
const result = yield request(handle, method, params, ext).catch(res => { ...params
tb_1.commonToast(res && res.message); }
}); const result = await request(handle, method, params, ext).catch(res => {
if (result && result.success) { commonToast(res && res.message);
return true; });
} if (result && result.success) {
})); return true;
} }
return false; });
}); }
}, return false;
receiveEnamePrize(params) { },
return __awaiter(this, void 0, void 0, function* () { async receiveEnamePrize(params) {
const { handle, method, ext } = utils_1.getRequestParams(apiList['receiveEnamePrize']); const { handle, method, ext } = getRequestParams(apiList['receiveEnamePrize']);
const result = yield request(handle, method, params, ext).catch(res => { const result = await request(handle, method, params, ext).catch(res => {
tb_1.commonToast(res && res.message); commonToast(res && res.message);
}); });
if (result && result.success) { if (result && result.success) {
return true; return true;
} }
return false; return false;
}); }
} }
};
}; };
exports.default = capiFn;
//# sourceMappingURL=capiFn.js.map
\ No newline at end of file export default capiFn;
{"version":3,"file":"capiFn.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/capiFn.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAAmD;AACnD,mCAA2C;AAE3C,YAAY;AACZ,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,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,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AAO,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 }); export const SHARE_CONFIG = {
exports.PRIZE_TYPE = exports.DRAW_STATUS = void 0; title: '爱斐楼上请',
// 领取奖品状态 desc: '积分盖楼赢锦鲤 享一年新衣',
exports.DRAW_STATUS = { imageUrl: 'https://isv.alibabausercontent.com/00000000/imgextra/i2/676606897/O1CN01eNrwLl20osHoB4Y7d_!!676606897-2-isvtu-00000000.png', // 分享图片URL
// 待领取 path: '/pages/pageshou_ye/pageshou_ye'
WAITAWARD: 1,
// 处理中
PROCESSING: 2,
// 领取成功
SUCCESS: 3,
// 领取失败
FAIL: 4,
// 已过期
EXPIRED: 5,
// 重新领取
RETRY: 6
}; };
// 奖品类型
exports.PRIZE_TYPE = { // 链接配置
ENAME: 1, export const REDIRECT_URL = {
CREDITS: 2, 'testpage': '/pages/testPage/testPage',
OBJECT: 3, 'tmall': 'https://www.tmall.com'
THANKS: 5
}; };
//# sourceMappingURL=constants.js.map
\ No newline at end of file // 我的奖品状态
export const PRIZE_DRAW_STATUS_MAP = {
RECEIVE: 1, // 待领取
DEALING: 2, // 处理中
SUCCESS: 3, // 领取成功
FAILURE: 4, // 领取失败
FINISHED: 5, // 已过期
REPEAT: 6, // 重新领取
}
// 奖品类型
export const PRIZE_TYPE_MAP = {
EQUITY: 1, // 权益
INTEGRATION: 2, // 积分
ENTITY: 3, // 实物
THANKS: 5 // 谢谢参与
}
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/constants.js"],"names":[],"mappings":";;;AAAA,SAAS;AACI,QAAA,WAAW,GAAG;IACzB,MAAM;IACN,SAAS,EAAE,CAAC;IACZ,MAAM;IACN,UAAU,EAAE,CAAC;IACb,OAAO;IACP,OAAO,EAAE,CAAC;IACV,OAAO;IACP,IAAI,EAAE,CAAC;IACP,MAAM;IACN,OAAO,EAAE,CAAC;IACV,OAAO;IACP,KAAK,EAAE,CAAC;CACT,CAAA;AAED,OAAO;AACM,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;CACV,CAAC"}
\ No newline at end of file
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const AMS_URL = 'https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri='; const AMS_URL = 'https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=';
const request = ({ cloud, cloudName, requestType = 'cloud' }) => { const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
if (!cloud) { if (!cloud) {
console.error('请传入cloud'); console.error('请传入cloud');
return false; return false;
}
if (!cloudName) {
console.error('请传入云函数名称');
return false;
}
return async (handle, method, params, ext = {}) => {
const { activityId } = getApp();
// 默认注入activityId
params = { activityId, ...params };
if (!params.activityId) {
console.error(`${handle}:请传入activityId`);
return false;
} }
if (!cloudName) { const _cloudName = ext.cloudName || cloudName;
console.error('请传入云函数名称'); const { isShowLoading } = ext;
return false; const hideMyLoading = () => {
if (isShowLoading) {
my.hideLoading();
}
};
if (isShowLoading) {
my.showLoading();
} }
return (handle, method, params, ext = {}) => __awaiter(void 0, void 0, void 0, function* () {
const { activityId } = getApp(); const requestAms = () => {
// 默认注入activityId return new Promise((resolve, reject) => {
params = Object.assign({ activityId }, params); my.request({
if (!params.activityId) { url: AMS_URL + _cloudName + '.' + handle,
console.error(`${handle}:请传入activityId`); method,
return false; data: params,
} dataType: 'json'
const _cloudName = ext.cloudName || cloudName; }).then(({ data: res }) => {
const { isShowLoading } = ext; hideMyLoading();
const hideMyLoading = () => { if (res && res.success) {
if (isShowLoading) { resolve(res);
my.hideLoading(); } else {
} reject(res);
}; }
if (isShowLoading) { }).catch(() => {
my.showLoading(); hideMyLoading();
} reject();
const requestAms = () => { });
return new Promise((resolve, reject) => { })
my.request({ };
url: AMS_URL + _cloudName + '.' + handle,
method,
data: params, const requestMock = () => {
dataType: 'json' const mockUrlPrefix = {
}).then(({ data: res }) => { ams: 'https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=',
hideMyLoading(); yapi: 'https://docs.dui88.com/mock/140/'
if (res && res.success) { };
resolve(res); const mockUrl = null;
} const requestPrefix = mockUrl || mockUrlPrefix[requestType];
else { return new Promise((resolve, reject) => {
reject(res); // const url = requestPrefix + _cloudName + '.';
} const url = requestPrefix + _cloudName + '.' + handle;
}).catch(() => { console.log(`requestMock url=>${url}`, `,method=>${method}`);
hideMyLoading(); my.request({
reject(); url: url,
}); method,
}); data: params,
}; dataType: 'json'
const requestCloud = () => { }).then(({ data: res }) => {
return new Promise((resolve, reject) => { hideMyLoading();
cloud.function.invoke(_cloudName, params, handle).then(res => { console.log(`mock res,${url}=>`, res)
console.log(handle, params, res); if (res && res.success) {
hideMyLoading(); resolve(res);
if (res && res.success) { } else {
resolve(res); reject(res);
} }
else { }).catch(() => {
reject(res); hideMyLoading();
} reject();
return res; });
}).catch(() => { })
hideMyLoading(); };
reject();
}); const requestCloud = () => {
}); return new Promise((resolve, reject) => {
}; cloud.function.invoke(_cloudName, params, handle).then(res => {
return requestType === 'ams' ? requestAms() : requestCloud(); console.log('request Cloud callback=>', handle, res,JSON.stringify(res));
}); // console.log('requestCloud', handle, params, res);
hideMyLoading();
if (res && res.success) {
resolve(res);
} else {
reject(res);
}
return res;
}).catch(() => {
hideMyLoading();
reject();
});
});
};
// console.log('requestCloud', _cloudName, handle, params);
// return requestType === 'ams' ? requestAms() : requestCloud();
return (requestType === 'ams' || requestType === 'yapi') ? requestMock() : requestCloud();
};
}; };
exports.default = request;
//# sourceMappingURL=request.js.map export default request;
\ No newline at end of file \ No newline at end of file
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../../../../src/packages/jsx2taobao/template/api/tbcc-sdk/lib/request.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,MAAM,OAAO,GAAG,iFAAiF,CAAC;AAElG,MAAM,OAAO,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,GAAG,OAAO,EAAE,EAAE,EAAE;IAC9D,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;KACd;IACD,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;KACd;IACD,OAAO,CAAO,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE;QAChD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,EAAE,CAAC;QAChC,iBAAiB;QACjB,MAAM,mBAAK,UAAU,IAAK,MAAM,CAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YACtB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,gBAAgB,CAAC,CAAC;YACzC,OAAO,KAAK,CAAC;SACd;QACD,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,IAAI,SAAS,CAAC;QAC9C,MAAM,EAAE,aAAa,EAAE,GAAG,GAAG,CAAC;QAC9B,MAAM,aAAa,GAAG,GAAG,EAAE;YACzB,IAAI,aAAa,EAAE;gBACjB,EAAE,CAAC,WAAW,EAAE,CAA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AG,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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{"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,E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,GAAG,EAAE,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;YAC1C,QAAQ;YACR,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;SACrC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAA;AAED;;;GAGG;AACU,QAAA,gBAAgB,GAAG,CAAO,WAAW,EAAE,EAAE;IACpD,KAAK,CAAC,MAAM,CAAC,CAAC;IACd,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAC;AAEF;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,CAAO,IAAI,EAAE,EAAE;IACnD,OAAO,IAAI,CAAC;AACd,CAAC,CAAA,CAAA"}
\ No newline at end of file
"use strict"; import capiFn from './capiFn';
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 date 接收可以被new Date()方法转换的内容
* @param format 字符串,需要的格式例如:'yyyy/MM/dd hh:mm:ss' * @param format 字符串,需要的格式例如:'yyyy/MM/dd hh:mm:ss'
* @returns {String} * @returns {String}
*/ */
exports.dateFormatter = (date, format = 'yyyy/MM/dd') => { export const dateFormatter = (date, format = 'yyyy/MM/dd') => {
if (!date) if (!date) return '-';
return '-';
date = new Date(typeof date === 'string' && isNaN(date) ? date.replace(/-/g, '/') : date); date = new Date(
let o = { typeof date === 'string' && isNaN(date) ? date.replace(/-/g, '/') : date
'M+': date.getMonth() + 1, );
'd+': date.getDate(), let o = {
'h+': date.getHours(), 'M+': date.getMonth() + 1,
'm+': date.getMinutes(), 'd+': date.getDate(),
's+': date.getSeconds(), 'h+': date.getHours(),
'q+': Math.floor((date.getMonth() + 3) / 3), 'm+': date.getMinutes(),
S: date.getMilliseconds() 's+': date.getSeconds(),
}; 'q+': Math.floor((date.getMonth() + 3) / 3),
if (/(y+)/.test(format)) { S: date.getMilliseconds()
format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); };
} if (/(y+)/.test(format)) {
for (let k in o) { format = format.replace(
if (new RegExp('(' + k + ')').test(format)) { RegExp.$1,
format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)); (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; }
return format;
}; };
/** /**
* 版本比较 * 版本比较
* @param {string} cur 当前版本 * @param {string} cur 当前版本
* @param {string} compare 比较版本 * @param {string} compare 比较版本
*/ */
exports.versionCompare = (cur, compare) => { export const versionCompare = (cur, compare) => {
const _cur = cur.split('.'); const _cur = cur.split('.');
const _compare = compare.split('.'); const _compare = compare.split('.');
if (+_cur[0] < +_compare[0]) { if (+_cur[0] < +_compare[0]) {
return false; return false;
} } else if ( +_cur[0] === +_compare[0] && +_cur[1] < +_compare[1] ) {
else if (+_cur[0] === +_compare[0] && +_cur[1] < +_compare[1]) { return false;
return false; } else if (+_cur[0] === +_compare[0] && +_cur[1] === +_compare[1] && +_cur[2] < +_compare[2]) {
} return false;
else if (+_cur[0] === +_compare[0] && +_cur[1] === +_compare[1] && +_cur[2] < +_compare[2]) { }
return false; return true;
}
return true;
}; };
/** /**
* 获取request请求所需参数 * 获取request请求所需参数
* @param {object/string} value API项配置 * @param {object/string} value API项配置
*/ */
exports.getRequestParams = value => { export const getRequestParams = value => {
if (typeof value === 'string') { if (typeof value === 'string') {
return { return {
handle: value, handle: value,
method: 'POST', method: 'POST',
ext: {} ext: {}
};
}
else if (typeof value === 'object') {
const { handle, method = 'POST' } = value, ext = __rest(value, ["handle", "method"]);
return {
handle,
method,
ext: Object.assign({}, ext)
};
} }
else { } else if (typeof value === 'object') {
console.error('getRequestParams: 传参有误'); const { handle, method = 'POST', ...ext } = value;
return {
handle,
method,
ext: { ...ext }
} }
} else {
console.error('getRequestParams: 传参有误');
}
}; };
/** /**
* 生成API * 生成API
* @param {array} apiList API数据数组 * @param {array} apiList API数据数组
* @param {function} request 请求 * @param {function} request 请求
*/ */
exports.generateAPI = (apiList, request) => { export const generateAPI = (apiList, request) => {
const api = {}; const api = {};
Object.entries(apiList).forEach(([key, value]) => { Object.entries(apiList).forEach(([key, value]) => {
const { handle, method, ext } = exports.getRequestParams(value); const { handle, method, ext } = getRequestParams(value);
api[key] = params => request(handle, method, params, ext); api[key] = params => request(handle, method, params, ext);
}); });
api.fn = capiFn_1.default(apiList, request); api.fn = capiFn(apiList, request);
return api; return api;
}; };
//# sourceMappingURL=utils.js.map \ No newline at end of file
\ 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,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G,oBAAO,GAAG,CAAE;SAChB,CAAA;KACF;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;KACzC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACU,QAAA,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IAC9C,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC/C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,wBAAgB,CAAC,KAAK,CAAC,CAAC;QACxD,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,GAAG,gBAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment