Commit 2f17270b authored by 汪欢's avatar 汪欢
parents d15e4825 9d985411
No preview for this file type
......@@ -16,11 +16,31 @@ const apiList = {
handle: 'index',
isShowLoading: true
},
receiveObjectPrize: {
handle: 'receiveObjectPrize',
method:'get',
isShowLoading: true
},
receiveEnamePrize: {
handle: 'receiveEnamePrize',
method:'get',
isShowLoading: true
},
getMyPrizeList: {
handle: 'getMyPrizeList',
method:'get',
isShowLoading: true
},
getActivityBaseInfoById: {
handle: 'getActivityBaseInfoById',
method:'get',
isShowLoading: true
},
getVipInfo: {
handle: 'getVipInfo',
method:'get',
isShowLoading: true
},
login: {
handle: 'login',
method:'get',
......
......@@ -2,11 +2,12 @@ import cloud from '@tbmp/mp-cloud-sdk';
import tbcc from './tbcc-sdk';
cloud.init({
env: 'online' // 云函数环境 test 测试环境 online 线上环境
env: 'test' // 云函数环境 test 测试环境 online 线上环境
});
App({
requestType: 'yapi', // ams:ams接口,cloud: 云函数
requestType: 'yapi', // yapi,cloud: 云函数
// requestType: 'cloud', // yapi,cloud: 云函数
cloudName: 'floor', // 主云函数项目名 base clientTemplate2C
cloud,
tbcc,
......@@ -23,6 +24,6 @@ App({
*/
handleQuery(query) {
const { activityId } = query;
this.activityId = activityId || '5f34e1c4964f9706aa7d803c';
this.activityId = activityId || '5f505873738989c8b356e284';
}
});
{
"pages": [
"pages/index/index",
"pages/myprize/myprize",
"pages/pageshou_ye/pageshou_ye",
"pages/pagehuo_dong_ye/pagehuo_dong_ye",
"pages/index/index",
"pages/pagejie_shu_ye/pagejie_shu_ye",
"pages/pagewo_de_jiang_pin_ye_mian1/pagewo_de_jiang_pin_ye_mian1"
],
......
@keyframes modalAnimation {
to {
opacity: 1;
}
}
.logistics-modal-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.7);
z-index: 20;
opacity: 0;
animation: modalAnimation .3s forwards;
}
@keyframes containerAnimation {
to {
transform: scale(1)
}
}
.logistics-modal-container__content {
width: 646rpx;
height: 244rpx;
padding: 0 46rpx;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: auto;
display: flex;
align-items: center;
transform: scale(0);
animation: containerAnimation .3s forwards;
}
.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 {
border-radius: 10rpx;
display: flex;
}
.logistics-modal-container__content-left {
width: 144rpx;
height: 144rpx;
background: rgba(244, 244, 244, 1);
}
.logistics-modal-container__content-left image {
width: 100%;
height: 100%;
}
.logistics-modal-container__content-right {
height: 144rpx;
margin-left: 24rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
font-size: 20rpx;
color: #959595;
flex: 1;
overflow: hidden;
white-space: nowrap;
}
.logistics-modal-container__content-name {
font-size: 28rpx;
color: rgba(51, 51, 51, 1);
}
.logistics-modal-container__content-desc {
font-size: 20rpx;
}
.logistics-modal-container__content-ids {
margin-bottom: 20rpx;
}
.logistics-modal-container__content-copy {
display: flex;
align-items: center;
height: 30rpx;
}
.logistics-modal-container__content-copy__code {
font-size: 20rpx;
}
.logistics-modal-container__content-copy__img {
width: 20rpx;
height: 20rpx;
background-size: 100% 100%;
margin-left: 20rpx;
}
\ No newline at end of file
<view class="logistics-modal-container">
<view class="logistics-modal-container__content"
style="{{prizeItem.shipStatus == 3 ?`background: url(${task.shipped}) no-repeat;background-size: 100% 100%;`
:`background: url(${task.notShipped}) no-repeat;background-size: 100% 100%;`}}">
<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-copy">
<view class="logistics-modal-container__content-copy__code">奖品编码:{{prizeItem._id}}</view>
<view class="logistics-modal-container__content-copy__img" onTap="copyPrizeId"></view>
</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-copy" a:else>
<view class="logistics-modal-container__content-copy__code">{{'物流单号:'+prizeItem.shipNum}}</view>
<view class="logistics-modal-container__content-copy__img" style="{{`background: url(${task.copyIcon}) no-repeat;background-size: 100% 100%;`}}" onTap="copyCode"></view>
</view>
</view>
</view>
</view>
</view>
\ No newline at end of file
const app = getApp();
const { tbcc } = app;
const { commonToast } = tbcc.tb;
Component({
mixins: [],
data: {},
props: {
prizeItem: {},
onCloseModal: () => { },
task: {
shipped: '',
notShipped: '',
}
},
didMount() { },
didUpdate() { },
didUnmount() { },
methods: {
closeModal() {
this.props.onCloseModal()
},
//复制运单号
copyCode() {
let { shipNum } = this.props.prizeItem
my.setClipboard({
text: shipNum + '',
success: () => {
commonToast('复制成功')
}
});
},
copyPrizeId() {
let { _id } = this.props.prizeItem
my.setClipboard({
text: _id + '',
success: () => {
commonToast('复制成功')
}
});
}
},
});
{
"component": true
}
\ No newline at end of file
.my-prize-page {
width: 100vw;
height: 100vh;
opacity: 1;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
/* background: url('') no-repeat center top/cover; */
}
.my-prize-page .my-prize-wrap {
width: 100%;
height: 100%;
overflow: auto;
}
.my-prize-page .my-prize-label {
width: 286rpx;
height: 49rpx;
margin: 140rpx auto 40rpx;
background: url('//yun.duiba.com.cn/aurora/assets/a15fe07a819f3f6deb271725b37468030523dc05.png') no-repeat;
background-size: 100% 100%;
}
.my-prize-page .my-prize-list {
width: 100%;
height: auto;
}
.my-prize-page .my-prize-empty {
text-align: center;
color: #fff;
margin-top: 30rpx;
}
.my-prize-page .my-prize-item {
display: flex;
justify-content: center;
align-items: center;
padding: 0 28rpx 0 26rpx;
margin: 0 auto 24rpx;
position: relative;
box-sizing: border-box;
width: 700rpx;
height: 161rpx;
background-color: #ffffff;
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;
box-sizing: border-box;
}
.my-prize-page .my-prize-item .my-prize-avatar {
width: 120rpx;
height: 120rpx;
}
.my-prize-page .my-prize-item .my-prize-content {
flex: 1;
min-width: 0;
padding: 10rpx 20rpx 0;
display: flex;
flex-direction: column;
height: 130rpx;
}
.my-prize-page .my-prize-item .my-prize-subtitle {
display: flex;
justify-content: center;
align-items: center;
}
.my-prize-page .my-prize-item .my-prize-copy {
width: 20rpx;
height: 20rpx;
margin-left: 18rpx;
}
.my-prize-page .my-prize-item .prize-status {
width: 150rpx;
height: 41rpx;
}
.prize-status>image {
width: 100%;
height: 100%;
}
.my-prize-page .my-prize-item .my-prize-name {
width: 100%;
font-size: 28rpx;
color: #2d2d2d;
letter-spacing: -1rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.my-prize-page .my-prize-item .my-prize-tip {
margin-top: 16rpx;
font-size: 20rpx;
line-height: 20rpx;
letter-spacing: 0;
color: #8a8a8a;
}
.my-prize-page .my-prize-item .my-prize-code {
width: 290rpx;
font-family: PingFangSC-Regular;
font-size: 20rpx;
color: #8a8a8a;
letter-spacing: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
\ No newline at end of file
<view class="my-prize-page" style="{{{'background':`url(${task.image.bg}) no-repeat center top/cover`}}}">
<view class="my-prize-wrap">
<view class="my-prize-label"></view>
<view class="my-prize-list" a:if="{{myPrizeList && myPrizeList.length > 0}}">
<view class="my-prize-item" a:for="{{myPrizeList}}">
<image class="my-prize-avatar" src="{{item.image}}"/>
<view class="my-prize-content">
<label class="my-prize-name">{{item.name}}</label>
<!-- <view class="my-prize-subtitle"> -->
<!-- <label class="my-prize-code">奖品编码:{{item._id}}</label> -->
<!-- 复制按钮 -->
<!-- <image class="my-prize-copy" data-text="{{item._id}}" onTap="handleCopyId" src="{{task.image.copyIcon}}" /> -->
<!-- </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.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>
<view class="prize-status" style="{{task.btnStyle}}">
<!-- 未领取 -->
<block a:if="{{item.drawStatus===PRIZE_DRAW_STATUS_MAP.RECEIVE}}">
<!-- 实物填写地址 -->
<image a:if="{{item.type === PRIZE_TYPE_MAP.ENTITY}}" onTap="handleClick" data-item="{{item}}" src="{{task.image.addressBth}}" />
<!-- 优惠券立即领取 -->
<image a:else onTap="handleClick" data-item="{{item}}" src="{{task.image.getBth}}" />
</block>
<!-- 已领取 -->
<block a:if="{{item.drawStatus===PRIZE_DRAW_STATUS_MAP.SUCCESS}}">
<!-- 实物查看物流 -->
<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}}" />
</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.FINISHED}}" src="{{task.image.invalidBtn}}" />
<!-- 领取失败 -->
<image a:if="{{item.drawStatus===PRIZE_DRAW_STATUS_MAP.FAILURE}}" src="{{task.image.failBth}}" />
</view>
</view>
</view>
<view a:if="{{myPrizeList && myPrizeList.length === 0}}" class="my-prize-empty">暂无奖品</view>
</view>
<logistics-modal a:if="{{isLogistic}}" prizeItem="{{currentPrize}}" onCloseModal="closeLogisticModal" task="{{task.logisticsImage}}"/>
</view>
\ No newline at end of file
const app = getApp();
const { tbcc } = app;
const { commonToast, navigateToOutside, getUserAddress, setClipboard } = tbcc.tb;
const { PRIZE_TYPE_MAP, PRIZE_DRAW_STATUS_MAP } = tbcc.constants;
Component({
mixins: [],
data: {
PRIZE_TYPE_MAP,
PRIZE_DRAW_STATUS_MAP,
currentPrize: {},
isLogistic: false,
},
props: {
myPrizeList: null, //我的奖品
endTime: null,//到期时间
task: {
image: {},
logisticsImage: {},
btnStyle: {}
}
},
didMount() { },
didUpdate() { },
didUnmount() { },
methods: {
//领取奖品
handleClick(e) {
this.props.onHandleClick(e)
},
// 复制编码
handleCopyId(e) {
const { text } = e.target.dataset || {}
setClipboard({ text })
console.log(text)
commonToast('复制成功')
},
// 去使用
handleTouse(e) {
const { item } = e.target.dataset;
navigateToOutside(item.useUrl)
},
//查看物流
handleView(e) {
let { item } = e.target.dataset
this.setData({ currentPrize: item, isLogistic: true })
},
/**
* 关闭物流弹窗
*/
closeLogisticModal() {
this.setData({ isLogistic: false })
},
},
});
{
"component": true,
"usingComponents": {
"logistics-modal": "/components/logisticsModal/logisticsModal"
}
}
\ No newline at end of file
<view class="index-page">
<view>正在加载...</view>
<view></view>
</view>
\ No newline at end of file
......@@ -22,19 +22,17 @@ Page({
this.getAuth();
console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
},
init() {
this.getActivityBaseInfoById();
},
async getActivityBaseInfoById() {
const { success, data } = await API.getActivityBaseInfoById().catch(res => {
commonToast(res && res.message);
}) || {};
if (success) {
console.log('getActivityBaseInfoById 成功')
// my.redirectTo({url:'/pages/pageshou_ye/pageshou_ye'});
// my.redirectTo({url:'/pages/pagehuo_dong_ye/pagehuo_dong_ye'});
}
async init() {
const [activity, vipInfo] = await Promise.all([
API.getActivityBaseInfoById(),
API.getVipInfo(),
]);
// if (vipInfo.isVip && activity.data.isUserJoin) {
// my.redirectTo({ url: '/pages/pagehuo_dong_ye/pagehuo_dong_ye' });
// } else {
// my.redirectTo({ url: '/pages/pageshou_ye/pageshou_ye' });
// }
my.redirectTo({ url: '/pages/myprize/myprize' });
},
onReady() {
// 页面加载完成
......
<view class="my-prize">
<prize-modal
myPrizeList="{{myPrizeList}}"
task="{{task}}"
endTime="{{endTime}}"
onHandleClick="handleClick"/>
</view>
\ No newline at end of file
'use strict';
import API from "/api";
const app = getApp();
const { tbcc } = app;
const { commonToast, navigateToOutside, getUserAddress, setClipboard } = tbcc.tb;
const { PRIZE_TYPE_MAP, PRIZE_DRAW_STATUS_MAP } = tbcc.constants;
let flag = false;
Page({
data: {
PRIZE_TYPE_MAP,
PRIZE_DRAW_STATUS_MAP,
myPrizeList: null, //我的奖品
endTime: null,//到期时间
task: {
image: {
bg: '//yun.duiba.com.cn/aurora/assets/7283d715cc5c7d13a5f498d15f5f5b9f4d9c29e5.jpg', //背景图
copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制
addressBth: '//yun.dui88.com/duiba-components-c-myprizeto_address.png', //填写地址(实物奖品)
getBth: '//yun.dui88.com/duiba-components-c-myprizeget_now.png', //立即领取(除实物奖品外)
logisticsBth: '//yun.dui88.com/duiba-components-c-myprizelogistics.png', //查看物流
useBth: '//yun.dui88.com/duiba-components-c-myprizeto_use.png', //去使用(除实物奖品外)
getAgainBtn: '//yun.dui88.com/duiba-components-c-myprizeget_again.png', //重新领取
invalidBtn: '//yun.duiba.com.cn/spark/assets/914ba8643c8abb8d710a3126ec312aecf6c4daf0.png', //已失效
failBth: '//yun.duiba.com.cn/spark/assets/8267375232058a6d0140270b1594427fb08d6ae3.png', //领取失败
},
logisticsImage: {
shipped: '//yun.dui88.com/duiba-components-c-myprizeprize_shipped.png', // 已发货物理弹窗
notShipped: '//yun.dui88.com/duiba-components-c-myprizenotshipped.png', // 待发货物流弹窗
copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制
},
btnStyle: { // 按钮自定义样式
width: '150rpx',
height: '41rpx',
}
}
},
onShow() {
flag = false
this.getMyPrize();
},
// 到期时间
getEndTime(prizeList = []) {
if (!prizeList || !prizeList.length) return null
const endTime = prizeList[0].expiredTime
if (!endTime) return null
const t1 = new Date(endTime).toLocaleDateString() + '';//获取年月日
const t2 = new Date(endTime).getHours() + '';//获取时
const t3 = new Date(endTime).getMinutes() + '';//获取分
const t4 = new Date(endTime).getMilliseconds() + '';//获取秒
console.log(endTime, new Date(endTime + 48 * 60 * 60 * 1000).toLocaleString(), 'endTime');
this.setData({
endTime: t1 + " " + t2.padStart(2, '0') + ":" + t3.padStart(2, '0') + ":" + t4.padStart(2, '0')
})
},
/**
* 获取奖品列表
* @param {string} type 是否展示loading
*/
async getMyPrize(type) {
const { activityId } = app;
if (type != 'noLoading') {
my.showLoading();
}
const { success, data, message } = await API.getMyPrizeList({ activityId }).catch(res => {
this.setData({
myPrizeList: []
})
}) || {};
if (success && data) {
this.setData({
myPrizeList: data
})
this.getEndTime(data)
}
if (type != 'noLoading') {
my.hideLoading();
}
},
//领取奖品
async handleClick(e) {
const { item } = e.target.dataset;
// 领取权益
if (item.type === PRIZE_TYPE_MAP.EQUITY) return this.handleGetEquity(e)
// 领取实物
if (item.type === PRIZE_TYPE_MAP.ENTITY) return this.handleGetEntity(e)
// 领取积分
if (item.type === PRIZE_TYPE_MAP.INTEGRATION) return this.handleGetIntergation(e)
},
// 优惠券
async handleGetEquity(e) {
if (flag) {
return
}
flag = true;
const { activityId } = app;
const { item } = e.target.dataset;
console.log(item, '领取权益')
const { success, data, message } = await API.receiveEnamePrize({ activityId, _id: item._id }).catch(res => {
this.getMyPrize('noLoading')
commonToast(res && res.message)
}) || {};
if (success && data) {
commonToast('领取成功')
this.getMyPrize()
}
setTimeout(() => {
flag = false
}, 500)
},
// 领取实物前询问
async handleGetEntity(e) {
if (flag) {
return
}
my.showLoading();
flag = true;
const { activityId } = app;
const { item } = e.target.dataset;
const userAddress = await getUserAddress({ joinTag: " " })
my.hideLoading();
if (!userAddress) return
const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {};
const params = {
activityId,
name,
phone: telNumber,
detailInfo,
cityCode,
cityName,
provinceName,
countyName,
streetName,
_id: item._id
}
my.confirm({
title: '提示',
content: '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address,
confirmButtonText: '确定',
cancelButtonText: '取消',
success: (result) => {
console.log(result)
const { confirm } = result;
if (confirm) {
this.receiveObjectPrize(params);
}
},
});
flag = false
},
// 领取实物
async receiveObjectPrize(params) {
const { success, data, message } = await API.receiveObjectPrize(params) || {}
if (success && data) {
commonToast('领取成功')
} else {
commonToast(message)
}
this.getMyPrize()
},
// 积分
async handleGetIntergation(e) {
if (flag) {
return
}
flag = true;
// 判断是否为会员
await this.getUserInfo()
const { isVip, vipLink } = app;
if (!isVip) {
commonToast('立即加入会员,即可领取奖品', 2000);
setTimeout(() => {
navigateToOutside(vipLink)
}, 1000)
flag = false
return
}
const { activityId } = app;
const { item } = e.target.dataset;
console.log(item, '领取积分')
const { success, data, message } = await API.receiveEnamePrize({ activityId, _id: item._id }) || {};
if (success && data) {
commonToast('领取成功')
} else {
commonToast(message)
}
flag = false
this.getMyPrize()
},
//获取用户vip信息
async getUserInfo() {
const { activityId } = app;
const { success, data, message } = await API.getVipInfo({ activityId }) || {};
console.log(data, '用户vip信息');
if (success && data) {
app.isVip = (data && data.isVip) || false;
app.vipLink = (data && data.url) || '';
} else {
commonToast(message)
}
},
});
\ No newline at end of file
{
"usingComponents": {
"prize-modal": "/components/prizeModal/prizeModal"
}
}
\ No newline at end of file
'use strict';
import resList from '../../resconfig/resList'; //import API from '../../api';
import API from '../../api';
const app = getApp();
const { tbcc } = app;
const { commonToast, getAuthUserInfo, navigateToOutside } = tbcc.tb;
Page({
data: {
ruleModalVisible:false
ruleModalVisible: false
},
onLoad(props) {
......@@ -12,21 +15,30 @@ Page({
resList: resList
});
},
handleStart(){
gotoVipPage() {
API.getVipInfo().then(res => {
if (!res.vip)
navigateToOutside(res.url)
else
my.redirectTo({ url: '/pages/pagehuo_dong_ye/pagehuo_dong_ye' });
})
},
handleStart() {
console.log('change')
my.redirectTo({
url: '/pages/pagehuo_dong_ye/pagehuo_dong_ye'
});
},
showRuleModal(){
showRuleModal() {
this.setData({
ruleModalVisible:true
ruleModalVisible: true
})
},
ruleModalClose(){
ruleModalClose() {
this.setData({
ruleModalVisible:false
ruleModalVisible: false
})
}
......
......@@ -59,8 +59,8 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
const requestPrefix = mockUrl || mockUrlPrefix[requestType];
return new Promise((resolve, reject) => {
// const url = requestPrefix + _cloudName + '.';
const url =requestPrefix + _cloudName + '.' + handle;
console.log(`requestMock url,method=>${method}=>`, url)
const url = requestPrefix + _cloudName + '.' + handle;
console.log(`requestMock url=>${url}`, `,method=>${method}`);
my.request({
url: url,
method,
......@@ -68,7 +68,7 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
dataType: 'json'
}).then(({ data: res }) => {
hideMyLoading();
console.log('mock res=>',JSON.stringify(res))
console.log('mock res=>', JSON.stringify(res))
if (res && res.success) {
resolve(res);
} else {
......@@ -84,7 +84,8 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
const requestCloud = () => {
return new Promise((resolve, reject) => {
cloud.function.invoke(_cloudName, params, handle).then(res => {
console.log('requestCloud', handle, params, res);
console.log('request Cloud callback=>', handle, res);
// console.log('requestCloud', handle, params, res);
hideMyLoading();
if (res && res.success) {
resolve(res);
......@@ -99,9 +100,7 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
});
};
console.log('requestCloud', _cloudName, handle, params);
// console.log('requestCloud', _cloudName, handle, params);
// return requestType === 'ams' ? requestAms() : requestCloud();
return (requestType === 'ams' || requestType === 'yapi') ? requestMock() : requestCloud();
......
'use strict';
import resList from '../../resconfig/resList'; //import API from '../../api';
import API from '../../api';
const app = getApp();
const { tbcc } = app;
const { commonToast, getAuthUserInfo, navigateToOutside } = tbcc.tb;
Page({
data: {
ruleModalVisible: false
},
onLoad(props) {
this.setData({
resList: resList
});
},
gotoVipPage() {
API.getVipInfo().then(res => {
if (!res.vip)
navigateToOutside(res.url)
else
my.redirectTo({ url: '/pages/pagehuo_dong_ye/pagehuo_dong_ye' });
})
},
handleStart() {
console.log('change')
my.redirectTo({
url: '/pages/pagehuo_dong_ye/pagehuo_dong_ye'
});
},
showRuleModal() {
this.setData({
ruleModalVisible: true
})
},
ruleModalClose() {
this.setData({
ruleModalVisible: false
})
}
});
\ No newline at end of file
This diff is collapsed.
{
"_args": [
[
"@tbmp/mp-cloud-sdk@1.3.4",
"d:\\develop\\nodejs\\sparkProject\\filaFloor\\project\\hello_taobao\\taobao1"
]
],
"_from": "@tbmp/mp-cloud-sdk@1.3.4",
"_id": "@tbmp/mp-cloud-sdk@1.3.4",
"_inBundle": false,
"_integrity": "sha1-+1HCYryYfVc0kze0SOWv1oL6xgk=",
"_location": "/@tbmp/mp-cloud-sdk",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@tbmp/mp-cloud-sdk@1.3.4",
"name": "@tbmp/mp-cloud-sdk",
"escapedName": "@tbmp%2fmp-cloud-sdk",
"scope": "@tbmp",
"rawSpec": "1.3.4",
"saveSpec": null,
"fetchSpec": "1.3.4"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npm.taobao.org/@tbmp/mp-cloud-sdk/download/@tbmp/mp-cloud-sdk-1.3.4.tgz",
"_spec": "1.3.4",
"_where": "d:\\develop\\nodejs\\sparkProject\\filaFloor\\project\\hello_taobao\\taobao1",
"author": "",
"description": "",
"gitHead": "1dff694baa0d0714e10794820a1df4806c19eebb",
"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.3.4"
}
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 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 { IRequestOptions } from "../../../shared/request";
export default class Top {
client: any;
context: IRequestOptions;
constructor(context: IRequestOptions);
invoke(apiName: string, data?: any, httpHeaders?: any): Promise<any>;
}
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';
export declare class Cloud {
function: CloudFunction;
file: CloudStorage;
db: Db;
topApi: Top;
qimenApi: Qimen;
processApi: Process;
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;
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