Commit be6f2eaf authored by 李维's avatar 李维

添加用户IOS审核账号和游客登录

parent 69379332
...@@ -31,12 +31,16 @@ export default class NewClass extends cc.Component { ...@@ -31,12 +31,16 @@ export default class NewClass extends cc.Component {
// 点击用户中心 // 点击用户中心
handleClickUserCenter() { handleClickUserCenter() {
this.userPage.active = true; this.userPage.active = true;
this.refreshUserPage(); this.refreshUserPage();
} }
// 点击左上角登录
handleClickLogin() {
const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LoginPage", "leftIn")
}
userPagePanel; userPagePanel;
userPageName; userPageName;
userPagePhone; userPagePhone;
...@@ -80,7 +84,6 @@ export default class NewClass extends cc.Component { ...@@ -80,7 +84,6 @@ export default class NewClass extends cc.Component {
// 点击课程 // 点击课程
handleClickCourseItem(pid, pData) { handleClickCourseItem(pid, pData) {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.unitPage.attr({syllabus_pid: pid}); vc.unitPage.attr({syllabus_pid: pid});
vc.unitPage.attr({pData: pData}); vc.unitPage.attr({pData: pData});
...@@ -91,7 +94,7 @@ export default class NewClass extends cc.Component { ...@@ -91,7 +94,7 @@ export default class NewClass extends cc.Component {
async getCourseList() { async getCourseList() {
this.SvContent.removeAllChildren(); this.SvContent.removeAllChildren();
this.loading.active = true; this.loading.active = true;
const userInfo = await global.middleLayer.getUserInfo(); const userInfo = this.userInfo;
const {rows} = await asyncCallNetworkApiGet('/api/kyxq/v1/user/jclist', { const {rows} = await asyncCallNetworkApiGet('/api/kyxq/v1/user/jclist', {
jc_arr: userInfo.jc_arr, jc_arr: userInfo.jc_arr,
}); });
...@@ -106,7 +109,6 @@ export default class NewClass extends cc.Component { ...@@ -106,7 +109,6 @@ export default class NewClass extends cc.Component {
let loadEndCount = 0; let loadEndCount = 0;
for(let i=0; i<rows.length; i++) { for(let i=0; i<rows.length; i++) {
const row = rows[i]; const row = rows[i];
const ci = cc.instantiate(this.CourseItem); const ci = cc.instantiate(this.CourseItem);
cc.find(`progressText`, ci).getComponent(cc.Label).string = `学习进度:${row.process}`; cc.find(`progressText`, ci).getComponent(cc.Label).string = `学习进度:${row.process}`;
...@@ -119,8 +121,6 @@ export default class NewClass extends cc.Component { ...@@ -119,8 +121,6 @@ export default class NewClass extends cc.Component {
cc.find(`progress`, ci).getComponent(cc.ProgressBar).progress = Math.floor(a/b*10)/10; cc.find(`progress`, ci).getComponent(cc.ProgressBar).progress = Math.floor(a/b*10)/10;
} }
// console.log("row.cover: ", row.cover);
getSprNodeByUrl(row.cover, async(resSpr) => { getSprNodeByUrl(row.cover, async(resSpr) => {
// getSpriteFrimeByUrl(row.cover, async (spriteFrame) => { // getSpriteFrimeByUrl(row.cover, async (spriteFrame) => {
const coverNode = cc.find(`bg`, ci); const coverNode = cc.find(`bg`, ci);
...@@ -138,7 +138,6 @@ export default class NewClass extends cc.Component { ...@@ -138,7 +138,6 @@ export default class NewClass extends cc.Component {
ci.active = true; ci.active = true;
ci.attr({syllabus_id: row.id}); ci.attr({syllabus_id: row.id});
ci.on("click", ()=>{ ci.on("click", ()=>{
console.log('row: ', row);
this.handleClickCourseItem(ci[`syllabus_id`], row); this.handleClickCourseItem(ci[`syllabus_id`], row);
}) })
...@@ -164,12 +163,11 @@ export default class NewClass extends cc.Component { ...@@ -164,12 +163,11 @@ export default class NewClass extends cc.Component {
ci.height *= scale; ci.height *= scale;
ci.scale = scale; ci.scale = scale;
this.SvContent.addChild(ci); this.SvContent.addChild(ci);
}
console.log("this.canvas.width: ", cc.find("Canvas").width) // 防止在没有数据情况下 加载动画不消失
if(rows.length == 0) {
this.loading.active = false;
} }
// this.loading.active = false; // this.loading.active = false;
} }
...@@ -178,22 +176,19 @@ export default class NewClass extends cc.Component { ...@@ -178,22 +176,19 @@ export default class NewClass extends cc.Component {
userInfo; userInfo;
async getUserInfo() { async getUserInfo() {
this.userInfo = await global.middleLayer.getUserInfo(); this.userInfo = await global.middleLayer.getUserInfo();
console.log("userInfo: ", this.userInfo); global.userInfo = {
this.initTopUserPanel(); phone: this.userInfo.phone,
isIOSReview: this.userInfo.phone == "15500000001",
isAnonymous: this.userInfo.phone == "15500000002",
detail: this.userInfo
}
// 如果是匿名登录 隐藏右上角头像按钮
cc.find("/UserInfo", this.node).active = global.userInfo.isAnonymous ? false : true;
cc.find("/UserLogin", this.node).active = global.userInfo.isAnonymous ? true : false;
// const token = cc.sys.localStorage.getItem('token'); this.initTopUserPanel();
// if (!token) {
// console.log('token not exist!');
// return;
// } else {
// console.log('token: ', token);
// }
// const resData = await asyncCallNetworkApiGet('/api/kyxq/v1/user/info', {token});
// console.log("userInfo: ", resData);
// this.userInfo = resData;
} }
nameLabel; nameLabel;
...@@ -237,26 +232,22 @@ export default class NewClass extends cc.Component { ...@@ -237,26 +232,22 @@ export default class NewClass extends cc.Component {
_canTouch = false; _canTouch = false;
async start () { async start () {
this.initBg(); this.initBg();
await this.getCourseList();
await this.getUserInfo(); await this.getUserInfo();
await this.getCourseList();
this.initTopUserPanel(); this.initTopUserPanel();
this._canTouch = true; this._canTouch = true;
this._inited = true; this._inited = true;
} }
async onEnable() { async onEnable() {
this._canTouch = false; this._canTouch = false;
this.initTopUserPanel();
if(this._inited) { if(this._inited) {
// await this.getCourseList(); // await this.getCourseList();
await this.getUserInfo();
await this.getCourseList();
this.initTopUserPanel();
this._canTouch = true; this._canTouch = true;
} }
} }
......
...@@ -49,15 +49,16 @@ export default class NewClass extends cc.Component { ...@@ -49,15 +49,16 @@ export default class NewClass extends cc.Component {
this.initData(); this.initData();
this.initListener(); this.initListener();
this.initAnonymous();
} }
initData() { initData() {
this.yellowBtn = cc.find("yellow", this.btnNode); this.yellowBtn = cc.find("yellow", this.btnNode);
this.greyBtn = cc.find("grey", this.btnNode); this.greyBtn = cc.find("grey", this.btnNode);
} }
initListener() { initListener() {
this.editBox.on('text-changed', (editBox) => { this.editBox.on('text-changed', (editBox) => {
// console.log('文本改变1:', editBox.string); // console.log('文本改变1:', editBox.string);
this.phoneNum = editBox.string; this.phoneNum = editBox.string;
...@@ -69,6 +70,16 @@ export default class NewClass extends cc.Component { ...@@ -69,6 +70,16 @@ export default class NewClass extends cc.Component {
}); });
} }
initAnonymous() {
const anyBtn = cc.find("/anonymousLoginBtn", this.panelNode);
anyBtn.active = true; // cc.sys.os == cc.sys.OS_IOS;
// 是否开启审查模式,true: 将会判断设备类型和登录账号 false: 关闭审查模式
// const openReview = true;
// IOS设备 并且 手机号是15500000001 或者为空(未登录状态) - 判定为IOS审查状态
// global.iosReviewMode = openReview && cc.sys.os == cc.sys.OS_IOS && (global.userInfo.phone == "15500000001" || global.userInfo.phone == "");
}
clickAgreement() { clickAgreement() {
this.isAgreement = !this.isAgreement; this.isAgreement = !this.isAgreement;
const icon = cc.find("/agreementSection/icon_agree", this.panelNode); const icon = cc.find("/agreementSection/icon_agree", this.panelNode);
...@@ -106,6 +117,27 @@ export default class NewClass extends cc.Component { ...@@ -106,6 +117,27 @@ export default class NewClass extends cc.Component {
cc.find(`${data}_web`, this.webNode).active = true; cc.find(`${data}_web`, this.webNode).active = true;
} }
async clickAnonymousLoginBtn() {
const defaultPhone = "15500000002"
const res = await asyncCallNetworkApiPost('/api/kyxq/v1/login', {
phone: defaultPhone,
});
if (res.code != '200') {
global.middleLayer.showTips(res.msg);
this.showEnterFail();
return;
}
global.userInfo = {
phone: defaultPhone,
isAnonymous: true,
isIOSReview: false,
}
global.middleLayer.isLogin = true;
cc.sys.localStorage.setItem('token', res.data.token);
cc.sys.localStorage.setItem('phone', defaultPhone);
this.showEnterSuccess(false);
}
async enterBtnClick() { async enterBtnClick() {
const phone = this.phoneNum; const phone = this.phoneNum;
if (!this.checkPhone(phone)) { if (!this.checkPhone(phone)) {
...@@ -129,18 +161,30 @@ export default class NewClass extends cc.Component { ...@@ -129,18 +161,30 @@ export default class NewClass extends cc.Component {
return return
} }
const localDelPhone = cc.sys.localStorage.getItem('_del-phone-number');
if(localDelPhone == phone) {
global.middleLayer.showTips("此账号不存在!");
return
}
const res = await asyncCallNetworkApiPost('/api/kyxq/v1/login', { const res = await asyncCallNetworkApiPost('/api/kyxq/v1/login', {
phone: phone, phone: phone,
}); });
if (res.code != '200') { if (res.code != '200') {
global.middleLayer.showTips(res.msg); global.middleLayer.showTips(res.msg);
this.showEnterFail(); this.showEnterFail();
return; return;
} }
global.middleLayer.isLogin = true; global.middleLayer.isLogin = true;
global.userInfo = {
phone: phone,
isAnonymous: false,
isIOSReview: phone,
}
cc.sys.localStorage.setItem('token', res.data.token); cc.sys.localStorage.setItem('token', res.data.token);
cc.sys.localStorage.setItem('phone', phone); cc.sys.localStorage.setItem('phone', phone);
this.showEnterSuccess(); this.showEnterSuccess(true);
...@@ -159,15 +203,25 @@ export default class NewClass extends cc.Component { ...@@ -159,15 +203,25 @@ export default class NewClass extends cc.Component {
return true; return true;
} }
showEnterSuccess() { cleanValueStatus() {
// 清除勾选状态
this.isAgreement = false;
cc.find("/agreementSection/icon_agree", this.panelNode).active = this.isAgreement;
this.editBox.getComponent(cc.EditBox).string = ""
this.phoneNum = ""
this.showGreyBtn();
}
showEnterSuccess(showSuccess = true) {
this.panelNode.active = false; this.panelNode.active = false;
this.successNode.active = true; this.successNode.active = showSuccess;
this.cleanValueStatus();
setTimeout(() => { setTimeout(() => {
if (this.isDestroy) { if (this.isDestroy) {
return; return;
} }
this.showHomePage(); this.showHomePage();
}, 1000); }, showSuccess ? 1000 : 1);
} }
showEnterFail() { showEnterFail() {
...@@ -198,8 +252,6 @@ export default class NewClass extends cc.Component { ...@@ -198,8 +252,6 @@ export default class NewClass extends cc.Component {
this.yellowBtn.active = false; this.yellowBtn.active = false;
} }
showHomePage() { showHomePage() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("HomePage", "rightIn") vc.toView("HomePage", "rightIn")
......
...@@ -24,6 +24,11 @@ export default class NewClass extends cc.Component { ...@@ -24,6 +24,11 @@ export default class NewClass extends cc.Component {
_canTouch = false; _canTouch = false;
async start () { async start () {
this._canTouch = true; this._canTouch = true;
this.initDeleteAccoutBtn();
}
protected onEnable(): void {
this.initDeleteAccoutBtn();
} }
closeBtnClick() { closeBtnClick() {
...@@ -44,10 +49,52 @@ export default class NewClass extends cc.Component { ...@@ -44,10 +49,52 @@ export default class NewClass extends cc.Component {
exitOkClick() { exitOkClick() {
this.exitCancelClick(); this.exitCancelClick();
this.node.active = false; this.node.active = false;
this.logout();
}
initDeleteAccoutBtn() {
const delBtn = cc.find("btn_delAccount", this.node)
delBtn.active = global.userInfo.isIOSReview ? true : false;
}
logout() {
global.middleLayer.isLogin = false;
global.userInfo = {
phone: "",
isAnonymous: false,
isIOSReview: false,
}
// 清空信息
cc.sys.localStorage.setItem('token', "");
cc.sys.localStorage.setItem('phone', "");
// 跳转登录页面
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LoginPage", "leftIn") vc.toView("LoginPage", "leftIn")
} }
clickPopupAccountModal() {
cc.find("/confirmDelAccount", this.node).active = true;
cc.find("/user_info", this.node).active = false;
}
clickDelAccount() {
cc.find("/confirmDelAccount", this.node).active = false;
cc.find("/user_info", this.node).active = true;
// 本地存储删除的手机号 - 在登录的时候进行判断
const phone = cc.sys.localStorage.getItem('phone');
cc.sys.localStorage.setItem('_del-phone-number', phone);
// 登出
this.logout();
this.exitCancelClick();
this.node.active = false;
}
clickCancelDelAccount() {
cc.find("/confirmDelAccount", this.node).active = false;
cc.find("/user_info", this.node).active = true;
}
// update (dt) {} // update (dt) {}
} }
{
"ver": "2.3.5",
"uuid": "0cd87cba-6ef8-48dc-afb1-c1babae27068",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 755,
"height": 377,
"platformSettings": {},
"subMetas": {
"bg_tip_delete": {
"ver": "1.0.4",
"uuid": "6e47f5e9-7e9b-4495-b94b-853de5bf4c21",
"rawTextureUuid": "0cd87cba-6ef8-48dc-afb1-c1babae27068",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 755,
"height": 377,
"rawWidth": 755,
"rawHeight": 377,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "0593980d-982d-4179-9aec-b6893c7b36b4",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 404,
"height": 150,
"platformSettings": {},
"subMetas": {
"btn_cancel": {
"ver": "1.0.4",
"uuid": "964ac0b1-fde8-48df-b7f1-84165f80e41a",
"rawTextureUuid": "0593980d-982d-4179-9aec-b6893c7b36b4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0.5,
"trimX": 3,
"trimY": 3,
"width": 398,
"height": 143,
"rawWidth": 404,
"rawHeight": 150,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "1203bc85-7b67-48c6-a8c3-d5bed28e2578",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 404,
"height": 150,
"platformSettings": {},
"subMetas": {
"btn_delete": {
"ver": "1.0.4",
"uuid": "c3ec3e53-9b63-4179-9239-1745797453d1",
"rawTextureUuid": "1203bc85-7b67-48c6-a8c3-d5bed28e2578",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0.5,
"trimX": 3,
"trimY": 3,
"width": 398,
"height": 143,
"rawWidth": 404,
"rawHeight": 150,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ 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