Commit ec8bddf8 authored by limingzhe's avatar limingzhe

feat: d登陆

parent 5b8390ac
No preview for this file type
...@@ -35541,7 +35541,7 @@ ...@@ -35541,7 +35541,7 @@
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "297c6c6f-c675-4606-bb8a-11e4fea0eba0" "__uuid__": "297c6c6f-c675-4606-bb8a-11e4fea0eba0"
}, },
"_type": 0, "_type": 1,
"_sizeMode": 0, "_sizeMode": 0,
"_fillType": 0, "_fillType": 0,
"_fillCenter": { "_fillCenter": {
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { asyncCallNetworkApiPost } from "./util";
const {ccclass, property} = cc._decorator; const {ccclass, property} = cc._decorator;
@ccclass @ccclass
...@@ -66,13 +68,42 @@ export default class NewClass extends cc.Component { ...@@ -66,13 +68,42 @@ export default class NewClass extends cc.Component {
} }
enterBtnClick() { async enterBtnClick() {
if (Math.random() < 0.5) { const phone = this.phoneNum;
this.showEnterSuccess(); if (!this.checkPhone(phone)) {
} else { global.middleLayer.showTips('请输入正确的手机号码');
return;
}
const res = await asyncCallNetworkApiPost('/api/kyxq/v1/login', {
phone: phone,
});
if (res.code != '200') {
global.middleLayer.showTips(res.msg);
this.showEnterFail(); this.showEnterFail();
return;
}
global.middleLayer.isLogin = true;
cc.sys.localStorage.setItem('token', res.token);
cc.sys.localStorage.setItem('phone', phone);
this.showEnterSuccess();
// if (Math.random() < 0.5) {
// this.showEnterSuccess();
// } else {
// this.showEnterFail();
// }
}
checkPhone(phone) {
const test = /^[1]([3-9])[0-9]{9}$/;
if (!test.test(phone)) {
return false;
} }
return true;
} }
showEnterSuccess() { showEnterSuccess() {
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
"height": 172, "height": 172,
"rawWidth": 398, "rawWidth": 398,
"rawHeight": 172, "rawHeight": 172,
"borderTop": 0, "borderTop": 74,
"borderBottom": 0, "borderBottom": 79,
"borderLeft": 0, "borderLeft": 190,
"borderRight": 0, "borderRight": 190,
"subMetas": {} "subMetas": {}
} }
} }
......
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