Commit ab2c0fff authored by zhangjinzhou's avatar zhangjinzhou

代码暂存

parent a6976e79
<view class="tempitemmodal ">
<image class="tempitembg " src={{resList['96de1c81-6629-4226-830b-2a64ec3b54b0'].url}} />
<view class="tempitemtext ">
<span class="tempitemtitle ">蕉内旗下热装备 持久保温</span>
<span class="tempitemname ">产品六字名称</span>
<span class="tempitemprize ">双十一惊喜价:¥299</span>
</view>
<image class="tempitembtn " src={{resList['bb187403-c5fc-4c33-aea1-072bac77f32e'].url}} />
<label class="tempitemtitle ">蕉内旗下热装备 持久保温</label>
<label class="tempitemname ">产品六字名称</label>
<label class="tempitemprize ">双十一惊喜价:¥299</label>
</view>
<image class="tempitembtn " src={{resList['bb187403-c5fc-4c33-aea1-072bac77f32e'].url}} onTap="onClose" />
</view>
\ No newline at end of file
......@@ -3,13 +3,14 @@
import resList from '../../resconfig/resList';
Component({
props: {},
data: {},
methods: {},
onInit(props) {
this.setData({
data: {
resList: resList
});
},
methods: {
onClose(){
const {onClose} = this.props;
onClose&&onClose();
}
},
});
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -91,7 +91,7 @@
opacity: 1;
display: block;
left: 400rpx;
top: 0rpx;
top: 25rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
}
......@@ -103,7 +103,8 @@
left: 0rpx;
top: 0rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
transform-origin: 50% 0%;
transform: scale(0.8);
}
.gamemain .gamemcont .gamemrolesgro .gamemrole1 .gamemplayer1 {
width: 179rpx;
......
<scroll-view class="gamemain" scroll-y={{true}} scroll-top={{86}} disable-scroll={{false}}>
<image class="gamembg" src={{resList['8bcca487-d698-4e01-93e1-8e78ae10107d'].url}} />
<view class="gamemcont">
<image class="gamembg" a:if="{{show_v!=1}}" src={{resList['8bcca487-d698-4e01-93e1-8e78ae10107d'].url}} />
<view class="gamemcont" a:if="{{show_v!=1}}">
<view class="gamemdaojishi">
<image class="gamemdjsbg" src={{resList['6a67309c-0c54-47e3-8955-9756ed4e8c21'].url}} />
<label class="gamemdjslab">游戏倒计时 {{gametimeshow}}</label>
......@@ -41,7 +41,7 @@
</view>
</view>
</view>
<view class="gamembot">
<view class="gamembot" a:if="{{show_v!=1}}">
<image class="gamembotimg" src={{resList['f3909518-193e-49eb-a1cd-357c4f83d796'].url}} />
<view class="gamemtool{{tooltime>0?' blackWhiteFilter':''}}" onTap="usetool">
<image class="gamemtoobg1" src={{resList['6f5cdb3c-0c5b-42a0-9472-982761684dc4'].url}} />
......@@ -68,7 +68,7 @@
</view>
</scroll-view>
</view>
<view class="gamemguide" a:if="{{isnew>0&&isnew<7}}" onTap="tonextguide">
<view class="gamemguide" a:if="{{show_v!=1&&isnew>0&&isnew<7}}" onTap="tonextguide">
<view class="gamemguidecont" a:if="{{isnew==1||isnew==2||isnew==6}}">
<image class="gamemguide1" a:if="{{isnew==1}}" src={{resList['7474511a-a5fb-461c-944b-179fd4326cbc'].url}} />
<image class="gamemguide2" a:if="{{isnew==2}}" src={{resList['5ef54541-b2a1-43d5-8dc1-1ff20b783a52'].url}} />
......@@ -91,3 +91,8 @@
</view>
</view>
</scroll-view>
<pkprize-modal a:if="{{pkshow1_v}}" onClose="closetohome" gameOverData="{{pk1data}}"></pkprize-modal>
<pknoprize-modal a:if="{{pkshow2_v}}" onClose="closetohome" gameOverData="{{pk2data}}"></pknoprize-modal>
<pkfailnoprize-modal a:if="{{pkshow3_v}}" onClose="closetohome" gameOverData="{{pk3data}}"></pkfailnoprize-modal>
<pksuccessnoprize-modal a:if="{{pkshow4_v}}" onClose="closetohome" gameOverData="{{pk4data}}"></pksuccessnoprize-modal>
<tempitem-modal a:if="{{toolshow_v}}" onClose="usetool1"></tempitem-modal>
\ No newline at end of file
......@@ -15,24 +15,26 @@ const {
getSystemInfo
} = tbcc.tb;
let updateact = 1;//请求
const gameatime = 100;//活动倒计时,100,
const toolwarm = 1;//升温道具+温度值
const taskwarm = 1;//任务+温度值
const invitewarm = 1;//邀请+温度值
const toolcd = 5;//
Page({
data: {
resList: resList,
show_v: 1,//1匹配,2活动
isnew: 0,//新手进程,0完成,其他阶段
invitedata: [],//邀请人
gametime: 10,//活动倒计时,s
gametime: 100,//活动倒计时,s
gametimeshow: "05:00",
roomdata: [{
wd: 1
}, {
wd: 3
}],//房间所有人温度信息
roomdata: [],//房间所有人温度信息
roomnums: 3,//房间人数
myidx: 1,//我的位置
tooltime: 5,//升温工具倒计时
showtooltime: "04:59",
attionlist: [
{ txt: "游戏开始啦,共有四名玩家加入游戏,快来升温队伍拿奖励吧。" }
],
iswin: false,//
step: 1,//阶段
......@@ -61,24 +63,127 @@ Page({
count: 0,
warms: 0
},
//弹窗显示
pkshow1_v: false,
pkshow2_v: false,
pkshow3_v: false,
pkshow4_v: false,
toolshow_v: false,
pk1data: {
warms: 0,
isWin: false,
prize: null,
unLockStep: null
},
pk2data: {
},
pk3data: {
},
pk4data: {
},
},
onLoad(props) {
let step = 1;
let roomnums = [2, 3, 4][step - 1];
let roomdata = [];
for (let i = 0; i < roomnums; i++) {
let idata = {
wd: 0
};
roomdata.push(idata);
}
// console.log("onload=========>",roomnums,roomdata);
this.setData({
resList: resList
step: step,
roomnums: roomnums,
roomdata: roomdata,
attionlist: [{
txt: "游戏开始啦,共有" + roomnums + "名玩家加入游戏,快来升温队伍拿奖励吧。"
}]
});
this.changePashow();
this.updateAct();
// this.updateActInfo();
this.doAiControl();
},
//其余机器人升温逻辑
doAiControl() {
/**
* 升温道具+1,
* 任务+1,
* 邀请人+1,
*/
let roomnums = this.data.roomnums - 1;
console.log("aicontrol==============>", roomnums);
for (let i = 0; i < roomnums; i++) {
let chatime = Math.ceil(Math.random()*5)+2;
let itime1 = Number((Math.random() * chatime).toFixed(2)) * 1000;
this.aiuseTool(itime1, i,chatime);
//ai邀请
let inviterange = [0,30];
let invitenums = Math.round(Math.random()*inviterange[1])+inviterange[0];
console.log("邀请的温度值",invitenums);
this.ainvite(invitenums,i);
//ai任务
let taskrange = [1,5];
let tasknums = Math.round(Math.random()*taskrange[1])+taskrange[0];
// this.ai
}
},
//机器使用道具
aiuseTool(time, i,chatime) {
setTimeout(() => {
console.log("ai"+i+"使用道具升温度");
let itxt = "玩家" + (i + 1) + "使用道具获得了" + toolwarm + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i + 1;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += toolwarm;
this.updateRolewd(i + 2, inwd);
let lesstime = this.data.gametime*1000;
let itime1 = Number((Math.random() * chatime).toFixed(2)) * 1000;
let nexttooltime = toolcd*1000+itime1;
if(nexttooltime<lesstime){
return this.aiuseTool(nexttooltime,i,chatime);
}
}, time);
},
//机器邀请人
ainvite(invitenums,i){
let chatime = Math.floor(gameatime/invitenums)*1000;
for(let i1=0;i1<invitenums;i1++){
let i1start = i1*chatime;
let i1end = (i1+1)*chatime-5000;
let rangetime = Math.floor(Math.random()*(i1end-i1start))+i1start;
console.log(rangetime);
setTimeout(() => {
console.log("ai"+i+"邀请好友升温度");
let itxt = "玩家"+(i+1)+"邀请了一位好友,获得了"+invitewarm+"温度值";
this.addAttionTxt(itxt);
let inroomidx = i+1;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += invitewarm;
this.updateRolewd(i+2,inwd);
}, rangetime);
}
},
//机器人完成任务
onShow() {
this.updateActInfo();
},
//更新活动信息
//30s刷新一次邀请人列表,新增温度,结束前5s再请求一次,onshow请求一次
async updateActInfo() {
console.log("updateActInfo=======>");
// console.log("updateActInfo=======>");
clearTimeout(updateact);
await this.updateAttionList();
await this.getInviteListByCurGame();
......@@ -94,7 +199,7 @@ Page({
}
}
if (chatime > 0) {
console.log("下次请求间隔", chatime);
// console.log("下次请求间隔", chatime);
updateact = setTimeout(() => {
this.updateActInfo();
}, chatime);
......@@ -136,7 +241,8 @@ Page({
},
//游戏结束
async gameover() {
console.log("游戏结束");
this.closetool();
// console.log("游戏结束");
let iswin = this.data.iswin;
let step = this.data.step;
const overdata = await API.gameOver({
......@@ -148,8 +254,19 @@ Page({
const { success, data } = overdata;
if (success) {
const { warms, isWin, prize, unLockStep } = overdata;
console.log("结束数据", overdata);
if (isWin) {
if (prize && prize.image && prize.image.length > 0) {
this.setData({
pk1data: data
})
this.openprize1();
} else {
}
}
// console.log("结束数据", overdata);
}
this.openprize1();
},
//匹配3s,切换活动
changePashow() {
......@@ -173,21 +290,46 @@ Page({
async usetool() {
let tooltime = this.data.tooltime;
if (tooltime <= 0) {//可使用
console.log("使用道具");
// console.log("使用道具");
this.opentool();
// return;
// 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 {//倒计时中
}
},
async usetool1() {
let tooltime = this.data.tooltime;
if (tooltime <= 0) {//可使用
let addwarm = 10;
let tooldata = await API.sendWarmsByCurGame({
type: "tool",
warms: addwarm,
step: this.data.step
}).catch(res => {
commonToast(res && res.message);
});
const { success, data } = tooldata;
if (success) {
this.updateActInfo();
this.setData({
tooltime: 5
});
}
} else {//倒计时中
}
this.closetool();
},
//升温
updateRolewd(ridx, rwd) {
......@@ -209,14 +351,14 @@ Page({
}
}
},
onShareAppMessage(){
onShareAppMessage() {
let {
path,
...rest
} = SHARE_CONFIG;
if(app.openId){
if (app.openId) {
let step = this.data.step;
path = "pages/pagepageindex/pagepageindex?openId="+app.openId+"&inviteStep="+step;
path = "pages/pagepageindex/pagepageindex?openId=" + app.openId + "&inviteStep=" + step;
}
return {
...rest,
......@@ -225,7 +367,7 @@ Page({
},
//分享活动
shareact() {
console.log("分享本次活动");
// console.log("分享本次活动");
my.showSharePanel();
},
//s时间转时间显示
......@@ -240,7 +382,7 @@ Page({
},
//更新attionlist,玩家相关
async updateAttionList() {
console.log("更新玩家++温度值");
// console.log("更新玩家++温度值");
let startime = this.data.startime;
let endtime = this.data.endtime;
let step = this.data.step;
......@@ -258,56 +400,56 @@ Page({
this.updateRolewd(ridx, total);
// let addattion = [];
if (invite) {
let txt1 = this.solveAttionTxt(invite,this.data.linvite,"invite");
if(txt1.length>0){
let txt1 = this.solveAttionTxt(invite, this.data.linvite, "invite");
if (txt1.length > 0) {
this.addAttionTxt(txt1);
this.setData({
linvite:invite
linvite: invite
});
}
}
if (tool) {
let txt2 = this.solveAttionTxt(tool,this.data.ltool,"tool");
if(txt2.length>0){
let txt2 = this.solveAttionTxt(tool, this.data.ltool, "tool");
if (txt2.length > 0) {
this.addAttionTxt(txt2);
this.setData({
ltool:tool
ltool: tool
});
}
}
if (follow) {
let txt3 = this.solveAttionTxt(follow,this.data.lfollow,"follow");
if(txt3.length>0){
let txt3 = this.solveAttionTxt(follow, this.data.lfollow, "follow");
if (txt3.length > 0) {
this.addAttionTxt(txt3);
this.setData({
lfollow:follow
lfollow: follow
});
}
}
if (sign) {
let txt4 = this.solveAttionTxt(sign,this.data.lsign,"sign");
if(txt4.length>0){
let txt4 = this.solveAttionTxt(sign, this.data.lsign, "sign");
if (txt4.length > 0) {
this.addAttionTxt(txt4);
this.setData({
lsign:sign
lsign: sign
});
}
}
if (collect) {
let txt5 = this.solveAttionTxt(collect,this.data.lcollect,"collect");
if(txt5.length>0){
let txt5 = this.solveAttionTxt(collect, this.data.lcollect, "collect");
if (txt5.length > 0) {
this.addAttionTxt(txt5);
this.setData({
lcollect:collect
lcollect: collect
});
}
}
if (browseGoods) {
let txt6 = this.solveAttionTxt(browseGoods,this.data.lbrowseGoods,"browseGoods");
if(txt6.length>0){
let txt6 = this.solveAttionTxt(browseGoods, this.data.lbrowseGoods, "browseGoods");
if (txt6.length > 0) {
this.addAttionTxt(txt6);
this.setData({
lbrowseGoods:browseGoods
lbrowseGoods: browseGoods
});
}
......@@ -315,52 +457,52 @@ Page({
}
},
//提示信息整理
solveAttionTxt(ndata,ldata,type){
solveAttionTxt(ndata, ldata, type) {
let ncount = ndata.count;
if(!ncount){
if (!ncount) {
return "";
}
let lcount = ldata.count;
let chacount = ncount-lcount;
if(chacount>0){
let chacount = ncount - lcount;
if (chacount > 0) {
let chawarm = ndata.warms - ldata.warms;
let iattiontxt = "";
if(type=="invite"){
if (type == "invite") {
iattiontxt = "邀请" + chacount + "人" + "获得了" + chawarm + "温度值";
}else if(type=="tool"){
} else if (type == "tool") {
iattiontxt = "使用道具" + chacount + "次" + "获得了" + chawarm + "温度值";
}else if(type=="follow"){
} else if (type == "follow") {
iattiontxt = "完成任务follow" + chacount + "次" + "获得了" + chawarm + "温度值";
}else if(type=="sign"){
} else if (type == "sign") {
iattiontxt = "完成任务sign" + chacount + "次" + "获得了" + chawarm + "温度值";
}else if(type=="collect"){
} else if (type == "collect") {
iattiontxt = "完成任务collect" + chacount + "次" + "获得了" + chawarm + "温度值";
}else if(type=="browseGoods"){
} else if (type == "browseGoods") {
iattiontxt = "完成任务browseGoods" + chacount + "次" + "获得了" + chawarm + "温度值";
}
if(iattiontxt.length>0){
if (iattiontxt.length > 0) {
return iattiontxt;
}
}else{
} else {
return "";
}
if(ncount>lcount){
if (ncount > lcount) {
let cha
}
},
//新增一条消息
addAttionTxt(txt){
addAttionTxt(txt) {
let attionlist = this.data.attionlist;
attionlist.push({
txt:txt
txt: txt
});
this.setData({
attionlist:attionlist
attionlist: attionlist
});
},
//获取邀请人
async getInviteListByCurGame() {
console.log("更新邀请人列表");
// console.log("更新邀请人列表");
let startime = this.data.startime;
let endtime = this.data.endtime;
let step = this.data.step;
......@@ -380,4 +522,69 @@ Page({
}
}
},
//结算返回首页
closetohome() {
this.closeprize1();
this.closeprize2();
this.closeprize3();
this.closeprize4();
my.navigateBack();
},
//打开道具页面
opentool() {
this.setData({
toolshow_v: true
});
},
//关闭道具页
closetool() {
this.setData({
toolshow_v: false
});
},
openprize1() {
this.setData({
pkshow1_v: true
})
},
closeprize1() {
this.setData({
pkshow1_v: false
})
},
openprize2() {
this.setData({
pkshow2_v: true
})
},
closeprize2() {
this.setData({
pkshow2_v: false
})
},
openprize3() {
this.setData({
pkshow3_v: true
})
},
closeprize3() {
this.setData({
pkshow3_v: false
})
},
openprize4() {
this.setData({
pkshow4_v: true
})
},
closeprize4() {
this.setData({
pkshow4_v: false
})
},
});
\ No newline at end of file
......@@ -3,6 +3,7 @@
"pkprize-modal": "/components/compkprizemodal/compkprizemodal",
"pknoprize-modal": "/components/compknoprizemodal/compknoprizemodal",
"pkfailnoprize-modal": "/components/compkfailnoprizemodal/compkfailnoprizemodal",
"pksuccessnoprize-modal": "/components/compksuccessnoprizemodal/compksuccessnoprizemodal"
"pksuccessnoprize-modal": "/components/compksuccessnoprizemodal/compksuccessnoprizemodal",
"tempitem-modal": "/components/comtempitemmodal/comtempitemmodal"
}
}
\ No newline at end of file
......@@ -2,26 +2,26 @@
"code": 84479393.0040682,
"success": true,
"data": {
"total": 999,
"total": 0,
"invite": {
"count": 3,
"warms": 10
"count": 0,
"warms": 0
},
"tool": {
"count": 3,
"warms": 10
"count": 0,
"warms": 0
},
"follow": {
"count": 3,
"warms": 10
"count": 0,
"warms": 0
},
"sign": {
"count": 3,
"warms": 10
"count": 0,
"warms": 0
},
"collect": {
"count": 3,
"warms": 10
"count": 0,
"warms": 0
},
"browseGoods": {}
}
......
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