增加定时获取邀请用户信息的功能

This commit is contained in:
zhl 2019-02-28 10:51:36 +08:00
parent 4ce67cb6d2
commit 372b7a5c9e
3 changed files with 37 additions and 10 deletions

View File

@ -68,12 +68,15 @@ cc.Class({
mobile: '',
images: [],
uid: '',
allshow: false
allshow: false,
infoSchedule: null,
shareUser: ''
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.shareUser = '5c7655c484dde4098f2196fa';
let self = this;
webapi.preLogin({})
.then(rep => {
@ -128,6 +131,10 @@ cc.Class({
// console.log('getScrollOffset: ' + offsetY);
});
this.longPressListener = onfire.on('longPressed', this.longPressed.bind(this));
if (this.logined && !this.allshow) {
this.scheduleUpdateInfo();
}
},
start () {
@ -209,7 +216,7 @@ cc.Class({
},
userLogin(mobile, code) {
let self = this;
webapi.login(mobile, code)
webapi.login(mobile, code, self.shareUser)
.then(rep => {
if (rep.errcode === 0 || rep.errcode === 102 || rep.errcode === 103) {
self.logined = true;
@ -227,7 +234,9 @@ cc.Class({
if (rep.errcode === 0) {
self.showResultView();
}
if (this.logined && !this.allshow) {
this.scheduleUpdateInfo();
}
}
})
.catch (err => {
@ -259,5 +268,23 @@ cc.Class({
if (this.allshow) {
this.mainScrollContent.getComponent('scrollContent').updateTipTxt('隐藏角色已开启');
}
},
scheduleUpdateInfo() {
let self = this;
if (this.infoSchedule) {
this.unschedule(this.infoSchedule);
}
this.infoSchedule = this.schedule(function () {
webapi.updateInviteInfo()
.then(rep => {
if (rep.errcode === 0) {
let text = `${stringUtil.parseMobile(rep.mobile)}接受了你的邀请`;
self.mainScrollContent.getComponent('scrollContent').updateTipTxt(text);
}
})
.catch(err => {
})
}, 60); //每5分钟更新一次
}
});

View File

@ -109,11 +109,6 @@ cc.Class({
.catch(err => {
cc.log('error get activity info');
});
// this.scheduleOnce(function () {
// processBar.getComponent('progressBar').updateShow(35000);
// self.puzzle.getComponent('puzzle').updateValues([])
// }, 5);
},
start() {

View File

@ -1,6 +1,6 @@
var http = require('./http');
const baseUrl = 'http://192.168.100.228:3000';
const baseUrl = 'http://192.168.100.229:3000';
export default {
sendSms: (mobile, captcha) => {
let data = {mobile: mobile};
@ -22,11 +22,12 @@ export default {
let url = baseUrl + '/activity/api/user_info';
return http.get(url);
},
login: (mobile, code) => {
login: (mobile, code, shareUser) => {
let data = {
mobile: mobile,
captcha: code
};
(!!shareUser) && (data['shareUser'] = shareUser);
let url = baseUrl + '/activity/api/join';
return http.post(url, data);
},
@ -41,5 +42,9 @@ export default {
getActivityInfo: () => {
let url = baseUrl + '/activity/api/activity_info';
return http.get(url);
},
updateInviteInfo: () => {
let url = baseUrl + '/activity/api/invite_info';
return http.get(url);
}
}