Commit a6976e79 authored by zhangjinzhou's avatar zhangjinzhou

代码暂存

parent f760c225
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,33 +11,33 @@
<image class="gamemroleimg1" src={{resList['70ad9e81-ebe3-43ab-ad49-38f3c4d675bd'].url}} />
<view class="gamemplayer1" a:if="{{myidx==1}}">
<image class="gamempimg1" src={{resList['c68097a5-eb32-422f-8583-600e3d636c93'].url}} />
<label class="gamemptxt1">{{"我的队伍\n"+"当前温度值:"+roomdata[myidx-1].wd+"c"}}</label>
<label class="gamemptxt1">{{"我的队伍\n"+"当前温度值:"+roomdata[myidx-1].wd+""}}</label>
</view>
<label class="gamemaitor1" a:if="{{myidx!=1}}">当前温度值:{{roomdata[0].wd}}</label>
<label class="gamemaitor1" a:if="{{myidx!=1}}">当前温度值:{{roomdata[0].wd}}</label>
</view>
<view class="gamemrole2" a:if="{{roomdata.length>1}}">
<image class="gamemroleimg2" src={{resList['70ad9e81-ebe3-43ab-ad49-38f3c4d675bd'].url}} />
<view class="gamemplayer2" a:if="{{myidx==2}}">
<image class="gamempimg2" src={{resList['c68097a5-eb32-422f-8583-600e3d636c93'].url}} />
<label class="gamemptxt2">{{"我的队伍\n"+"当前温度值:"+roomdata[myidx-1].wd+"c"}}</label>
<label class="gamemptxt2">{{"我的队伍\n"+"当前温度值:"+roomdata[myidx-1].wd+""}}</label>
</view>
<label class="gamemaitor2" a:if="{{myidx!=2}}">当前温度值:{{roomdata[1].wd}}</label>
<label class="gamemaitor2" a:if="{{myidx!=2}}">当前温度值:{{roomdata[1].wd}}</label>
</view>
<view class="gamemrole3" a:if="{{roomdata.length>2}}">
<image class="gamemroleimg3" src={{resList['70ad9e81-ebe3-43ab-ad49-38f3c4d675bd'].url}} />
<view class="gamemplayer3" a:if="{{myidx==3}}">
<image class="gamempimg3" src={{resList['c68097a5-eb32-422f-8583-600e3d636c93'].url}} />
<label class="gamemptxt3">{{"我的队伍\n"+"当前温度值:"+roomdata[myidx-1].wd+"c"}}</label>
<label class="gamemptxt3">{{"我的队伍\n"+"当前温度值:"+roomdata[myidx-1].wd+""}}</label>
</view>
<label class="gamemaitor3" a:if="{{myidx!=3}}">当前温度值:{{roomdata[2].wd}}</label>
<label class="gamemaitor3" a:if="{{myidx!=3}}">当前温度值:{{roomdata[2].wd}}</label>
</view>
<view class="gamemrole4" a:if="{{roomdata.length>3}}">
<image class="gamemroleimg4" src={{resList['70ad9e81-ebe3-43ab-ad49-38f3c4d675bd'].url}} />
<view class="gamemplayer4" a:if="{{myidx==4}}">
<image class="gamempimg4" src={{resList['c68097a5-eb32-422f-8583-600e3d636c93'].url}} />
<label class="gamemptxt4">{{"我的队伍\n"+"当前温度值:"+roomdata[myidx-1].wd+"c"}}</label>
<label class="gamemptxt4">{{"我的队伍\n"+"当前温度值:"+roomdata[myidx-1].wd+""}}</label>
</view>
<label class="gamemaitor4" a:if="{{myidx!=4}}">当前温度值:{{roomdata[3].wd}}</label>
<label class="gamemaitor4" a:if="{{myidx!=4}}">当前温度值:{{roomdata[3].wd}}</label>
</view>
</view>
</view>
......
'use strict';
import resList from '../../resconfig/resList'; //import API from '../../api';
import API from '../../api';
import {
modalType, SHARE_CONFIG
} from '../../tbcc-sdk/lib/constants';
const app = getApp();
const {
tbcc
} = app;
const {
commonToast,
navigateToOutside,
getSystemInfo
} = tbcc.tb;
let updateact = 1;//请求
Page({
data: {
show_v: 1,//1匹配,2活动
......@@ -19,12 +32,36 @@ Page({
tooltime: 5,//升温工具倒计时
showtooltime: "04:59",
attionlist: [
{ txt: "1游戏开始啦,共有四名玩家加入游戏,快来升温队伍拿奖励吧。" },
{ txt: "2游戏开始啦,共有四名玩家加入游戏,快来升温队伍拿奖励吧。" },
{ txt: "3游戏开始啦,共有四名玩家加入游戏,快来升温队伍拿奖励吧。" },
{ txt: "4游戏开始啦,共有四名玩家加入游戏,快来升温队伍拿奖励吧。" }
{ txt: "游戏开始啦,共有四名玩家加入游戏,快来升温队伍拿奖励吧。" }
],
attiontxt: "游戏开始啦,共有四名玩家加入游戏,快来升温队伍拿奖励吧。",
iswin: false,//
step: 1,//阶段
//我的消息通知
linvite: {
count: 0,
warms: 0
},//上次邀请
ltool: {
count: 0,
warms: 0
},//上次使用道具
lfollow: {
count: 0,
warms: 0
},//
lsign: {
count: 0,
warms: 0
},
lcollect: {
count: 0,
warms: 0
},
lbrowseGoods: {
count: 0,
warms: 0
},
},
onLoad(props) {
this.setData({
......@@ -33,6 +70,35 @@ Page({
this.changePashow();
this.updateAct();
// this.updateActInfo();
},
onShow() {
this.updateActInfo();
},
//更新活动信息
//30s刷新一次邀请人列表,新增温度,结束前5s再请求一次,onshow请求一次
async updateActInfo() {
console.log("updateActInfo=======>");
clearTimeout(updateact);
await this.updateAttionList();
await this.getInviteListByCurGame();
let lesstime = this.data.gametime * 1000;
let chatime = 30000;
if (lesstime > chatime) {
} else {
if (lesstime > 5000) {
chatime = lesstime - 5000;
} else {
chatime = 0;
}
}
if (chatime > 0) {
console.log("下次请求间隔", chatime);
updateact = setTimeout(() => {
this.updateActInfo();
}, chatime);
}
},
//全局的update
updateAct() {
......@@ -69,8 +135,21 @@ Page({
let gameupdate = setInterval(update.bind(this), 50);
},
//游戏结束
gameover() {
async gameover() {
console.log("游戏结束");
let iswin = this.data.iswin;
let step = this.data.step;
const overdata = await API.gameOver({
isWin: iswin,
step: step
}).catch(res => {
commonToast(res && res.message);
})
const { success, data } = overdata;
if (success) {
const { warms, isWin, prize, unLockStep } = overdata;
console.log("结束数据", overdata);
}
},
//匹配3s,切换活动
changePashow() {
......@@ -91,14 +170,21 @@ Page({
});
},
//使用道具
usetool() {
async usetool() {
let tooltime = this.data.tooltime;
if (tooltime <= 0) {//可使用
console.log("使用道具");
let ridx = this.data.myidx;
let addwd = 3;
let rwd = addwd;
this.updateRolewd(ridx, rwd);
let addwarm = 10;
let tooldata = await API.sendWarmsByCurGame({
type: "tool",
warms: addwarm,
}).catch(res => {
commonToast(res && res.message);
});
const { success, data } = tooldata;
if (success) {
this.updateActInfo();
}
} else {//倒计时中
}
......@@ -117,16 +203,30 @@ Page({
if (dataset) {
let sidx = Number(dataset.sidx);
if (this.data.invitedata[sidx]) {
} else {
this.shareact();
}
}
},
onShareAppMessage(){
let {
path,
...rest
} = SHARE_CONFIG;
if(app.openId){
let step = this.data.step;
path = "pages/pagepageindex/pagepageindex?openId="+app.openId+"&inviteStep="+step;
}
return {
...rest,
path
};
},
//分享活动
shareact() {
console.log("分享本次活动");
this.updateAttionList();
my.showSharePanel();
},
//s时间转时间显示
changeshowtime(ntime) {
......@@ -138,14 +238,146 @@ Page({
let shows = shows1 < 10 ? "0" + shows1 : shows1;
return showm + ":" + shows;
},
//更新attionlist
updateAttionList(){
//更新attionlist,玩家相关
async updateAttionList() {
console.log("更新玩家++温度值");
let startime = this.data.startime;
let endtime = this.data.endtime;
let step = this.data.step;
let attiondata = await API.getWarmDetailListByCurGame({
joinGameStartTime: startime,
joinGameEndTime: endtime,
step: step
}).catch(res => {
commonToast(res && res.message);
})
const { success, data } = attiondata;
if (success) {
const { total, invite, tool, follow, sign, collect, browseGoods } = data;
let ridx = this.data.myidx;
this.updateRolewd(ridx, total);
// let addattion = [];
if (invite) {
let txt1 = this.solveAttionTxt(invite,this.data.linvite,"invite");
if(txt1.length>0){
this.addAttionTxt(txt1);
this.setData({
linvite:invite
});
}
}
if (tool) {
let txt2 = this.solveAttionTxt(tool,this.data.ltool,"tool");
if(txt2.length>0){
this.addAttionTxt(txt2);
this.setData({
ltool:tool
});
}
}
if (follow) {
let txt3 = this.solveAttionTxt(follow,this.data.lfollow,"follow");
if(txt3.length>0){
this.addAttionTxt(txt3);
this.setData({
lfollow:follow
});
}
}
if (sign) {
let txt4 = this.solveAttionTxt(sign,this.data.lsign,"sign");
if(txt4.length>0){
this.addAttionTxt(txt4);
this.setData({
lsign:sign
});
}
}
if (collect) {
let txt5 = this.solveAttionTxt(collect,this.data.lcollect,"collect");
if(txt5.length>0){
this.addAttionTxt(txt5);
this.setData({
lcollect:collect
});
}
}
if (browseGoods) {
let txt6 = this.solveAttionTxt(browseGoods,this.data.lbrowseGoods,"browseGoods");
if(txt6.length>0){
this.addAttionTxt(txt6);
this.setData({
lbrowseGoods:browseGoods
});
}
}
}
},
//提示信息整理
solveAttionTxt(ndata,ldata,type){
let ncount = ndata.count;
if(!ncount){
return "";
}
let lcount = ldata.count;
let chacount = ncount-lcount;
if(chacount>0){
let chawarm = ndata.warms - ldata.warms;
let iattiontxt = "";
if(type=="invite"){
iattiontxt = "邀请" + chacount + "人" + "获得了" + chawarm + "温度值";
}else if(type=="tool"){
iattiontxt = "使用道具" + chacount + "次" + "获得了" + chawarm + "温度值";
}else if(type=="follow"){
iattiontxt = "完成任务follow" + chacount + "次" + "获得了" + chawarm + "温度值";
}else if(type=="sign"){
iattiontxt = "完成任务sign" + chacount + "次" + "获得了" + chawarm + "温度值";
}else if(type=="collect"){
iattiontxt = "完成任务collect" + chacount + "次" + "获得了" + chawarm + "温度值";
}else if(type=="browseGoods"){
iattiontxt = "完成任务browseGoods" + chacount + "次" + "获得了" + chawarm + "温度值";
}
if(iattiontxt.length>0){
return iattiontxt;
}
}else{
return "";
}
if(ncount>lcount){
let cha
}
},
//新增一条消息
addAttionTxt(txt){
let attionlist = this.data.attionlist;
attionlist.push({
txt:"新增attion"
txt:txt
});
this.setData({
attionlist:attionlist
});
}
},
//获取邀请人
async getInviteListByCurGame() {
console.log("更新邀请人列表");
let startime = this.data.startime;
let endtime = this.data.endtime;
let step = this.data.step;
let invitedata = await API.getInviteListByCurGame({
joinGameStartTime: startime,
joinGameEndTime: endtime,
step: step
}).catch(res => {
commonToast(res && res.message);
});
const { success, data } = invitedata;
if (success) {
if (data && data.length > this.data.invitedata.length) {
this.setData({
invitedata: data
});
}
}
},
});
\ No newline at end of file
......@@ -2,33 +2,27 @@
"code": 84479393.0040682,
"success": true,
"data": {
"total": 23797510.558772445,
"list": [
{
"type": "follow",
"count": 71736628.84235147,
"warms": 31448271.838879377
},
{
"type": "follow",
"count": 74402080.91422823,
"warms": -66725690.75145462
},
{
"type": "follow",
"count": -59343034.60167052,
"warms": -18845556.91745086
},
{
"type": "tool",
"count": 71868834.65446723,
"warms": -30559758.690655768
},
{
"type": "invite",
"count": -50531894.123465456,
"warms": -14260662.376641572
}
]
"total": 999,
"invite": {
"count": 3,
"warms": 10
},
"tool": {
"count": 3,
"warms": 10
},
"follow": {
"count": 3,
"warms": 10
},
"sign": {
"count": 3,
"warms": 10
},
"collect": {
"count": 3,
"warms": 10
},
"browseGoods": {}
}
}
\ 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