|
@@ -0,0 +1,130 @@
|
|
|
+import APIClient from '../../../util/API/APIClient';
|
|
|
+import Consts from '../../../util/Consts';
|
|
|
+
|
|
|
+class GeoCheckScene extends scene {
|
|
|
+ constructor(scope) {
|
|
|
+ super(scope);
|
|
|
+ this.timer = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 轮询二维码状态 - 失效、验证失败、验证成功、等待验证
|
|
|
+ */
|
|
|
+ queryQRCodeState() {
|
|
|
+ APIClient.getGeoQRState((isTrue, res) => {
|
|
|
+ if (!isTrue || !res.success) {
|
|
|
+ console.log('轮询过程中失败一次如何处置?');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const { status } = res.data || {};
|
|
|
+ switch(status) {
|
|
|
+ case Consts.GEO_QR_WAITING:
|
|
|
+ break;
|
|
|
+ case Consts.GEO_QR_FAILED:
|
|
|
+ document.querySelector('.qr-invalid').style.display = "block";
|
|
|
+ document.querySelector('.click-alert').style.display = "block";
|
|
|
+ if (this.timer) {
|
|
|
+ window.clearInterval(this.timer);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Consts.GEO_QR_SUCCEED:
|
|
|
+ if (this.timer) {
|
|
|
+ window.clearInterval(this.timer);
|
|
|
+ }
|
|
|
+ if (this.moye.focusList.indexOf('WaterfallIndexScene') !== -1) {
|
|
|
+ this.hideScene({success: true}, 'WaterfallIndexScene');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.showScene(require('./WaterfallIndexScene.js'), {});
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 渲染一张新二维码
|
|
|
+ */
|
|
|
+ renderGeoQRImage() {
|
|
|
+ APIClient.getGeoQRImage((isTrue, res) => {
|
|
|
+ //二维码请求失败提醒
|
|
|
+ if (!isTrue || !res.success) {
|
|
|
+ TVUtil.Toast.show('二维码加载失败,请重新打开应用!', 5000);
|
|
|
+ return;
|
|
|
+ };
|
|
|
+ const { qrcode, simple } = res.data || {};
|
|
|
+ //二维码图片展现
|
|
|
+ const qrDom = document.querySelector('.qr-wrapper');
|
|
|
+ if (qrDom) {
|
|
|
+ const imgHTML = `<img src="${qrcode}" />`;
|
|
|
+ qrDom.innerHTML = imgHTML;
|
|
|
+ }
|
|
|
+ //扫码平台描述文字
|
|
|
+ let pltDesc = simple === '365tggj' ? '365托管管家' : '贝尔安亲家校平台';
|
|
|
+ const descDom = document.querySelector('.first-line');
|
|
|
+ if (descDom) {
|
|
|
+ const descHTML = `请使用<span>${pltDesc}</span>`;
|
|
|
+ descDom.innerHTML = descHTML;
|
|
|
+ }
|
|
|
+ //隐藏失效提示蒙层
|
|
|
+ document.querySelector('.qr-invalid').style.display = "none";
|
|
|
+ document.querySelector('.click-alert').style.display = "none";
|
|
|
+ //定时轮询扫码结果
|
|
|
+ this.timer = window.setInterval(this.queryQRCodeState.bind(this), 1500);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ onCreate() {
|
|
|
+ this.setContentView(
|
|
|
+ require('../../../res/tpl/GeoCheckScene.tpl'), {}, 'GeoCheckScene', {'isParentShow': true}, () => {
|
|
|
+ this.renderGeoQRImage();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ onPause() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onDestroy() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onDestroy() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onActive() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onInactive() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onResume() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onBack() {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ onOK(e) {
|
|
|
+ if (e.target.id === 'refresh-btn') {
|
|
|
+ this.renderGeoQRImage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ oKeydown() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onKeyup() {
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+module.exports = GeoCheckScene;
|