diff --git a/app.js b/app.js index 43a104d..6b6810c 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,5 @@ //app.js -const tdsdk = require('./libs/tdweapp.js'); +const tdsdk = require('./libs/tdweapp.js') App({ //----------------------------------------------globalData-------------------------------------- evn: 0,//0:开发环境,1:测试环境,2:生产环境 diff --git a/pages/agent/edit/index.js b/pages/agent/edit/index.js index 6567361..77383cb 100644 --- a/pages/agent/edit/index.js +++ b/pages/agent/edit/index.js @@ -2,11 +2,11 @@ import { getVehicleList, getFactoryPriceDetail, getRelation, postRelation, getProxyOrderInfo, createProxyOrder } from "../../../api/ztb" const util = require('../../../utils/util') const math = require('../../../utils/math') +const tdsdk = require('../../../libs/tdweapp.js') const event = require('../../../utils/event.js') const app = getApp() Page({ - /** * 页面的初始数据 */ @@ -344,10 +344,14 @@ Page({ } }) }, - /** - * 生命周期函数--监听页面卸载 - */ + onShow: function () { + tdsdk.Page.onShow() + }, + onHide: function(){ + tdsdk.Page.onHide() + }, onUnload: function () { + tdsdk.Page.onUnload() event.remove('EventMessage', this) } diff --git a/pages/index/index.js b/pages/index/index.js index 753e99d..f585d97 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -3,6 +3,7 @@ import { zconfig, loginToken, getBaseInfo, getPopupInfo } from "../../api/ztb" import { pconfig } from "../../api/payment" import { mconfig } from "../../api/moment" const util = require('../../utils/util') +const tdsdk = require('../../libs/tdweapp.js') const wxqqmap = require('../../libs/qqmap-wx-jssdk.min') const event = require('../../utils/event') const storage = require('../../utils/storage') @@ -208,6 +209,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { + tdsdk.Page.onShow() if(this.data.inited || app.globalData.Custom){ this.onResume() } @@ -301,7 +303,11 @@ Page({ storage.remove('ztb-history-list') this.setData({ historyList: [] }) }, + onHide: function(){ + tdsdk.Page.onHide() + }, onUnload: function(){ + tdsdk.Page.onUnload() event.remove('EventMessage', this) }, onShareAppMessage: function () { diff --git a/pages/login/index.js b/pages/login/index.js index d7c7fab..d0aeda1 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -5,6 +5,7 @@ import { zconfig, loginToken, getBaseInfo } from "../../api/ztb" import { pconfig } from "../../api/payment" import { mconfig } from "../../api/moment" import { sconfig } from "../../api/saas" +const tdsdk = require('../../libs/tdweapp.js') const storage = require('../../utils/storage') const util = require('../../utils/util') const event = require('../../utils/event') @@ -124,13 +125,9 @@ Page({ }, changePwd: function () { if (this.data.pwdType === 'password') { - this.setData({ - pwdType: 'text' - }) + this.setData({ pwdType: 'text' }) } else { - this.setData({ - pwdType: 'password' - }) + this.setData({ pwdType: 'password' }) } }, bindInput: function (e) { @@ -139,29 +136,19 @@ Page({ var enable = false if ((/^1\d{10}$/.test(e.detail.value)) && e.detail.value.length == 11) { enable = true - this.setData({ - mobileEnable: enable - }) + this.setData({ mobileEnable: enable }) } } if ((/^1\d{10}$/.test(this.data.form.account)) && this.data.form.account.length == 11) { if (this.data.type == 1 && !util.isEmpty(this.data.form.captcha)) { - this.setData({ - loginEnable: false - }) + this.setData({ loginEnable: false }) } else if (this.data.type == 0 && !util.isEmpty(this.data.form.password)) { - this.setData({ - loginEnable: false - }) + this.setData({ loginEnable: false }) } else { - this.setData({ - loginEnable: true - }) + this.setData({ loginEnable: true }) } } else { - this.setData({ - loginEnable: true - }) + this.setData({ loginEnable: true }) } }, loginForm: function () { @@ -177,10 +164,7 @@ Page({ util.showToast('请输入密码') return } - wx.showLoading({ - title: '登录中', - mask: true - }) + wx.showLoading({ title: '登录中', mask: true }) if (this.data.type == 1) { loginCaptcha(this.data.form).then(result => { storage.put('Authorization', result.data.token) @@ -203,17 +187,9 @@ Page({ }, changeType: function () { if (this.data.type == 1) { - this.setData({ - type: 0, - ['form.captcha']: null, - loginEnable: true - }) + this.setData({ type: 0, ['form.captcha']: null, loginEnable: true }) } else { - this.setData({ - type: 1, - ['form.password']: null, - loginEnable: true - }) + this.setData({ type: 1, ['form.password']: null, loginEnable: true }) } }, fetchCode: function (e) { @@ -222,33 +198,19 @@ Page({ return } if (this.second && this.second.interval) return !1 - wx.showLoading({ - title: '正在获取', - mask: true - }) - postCaptcha({ - verifiableAccount: this.data.form.account, - verifiableAccountType: 1, - purpose: 1 - }).then(result => { + wx.showLoading({ title: '正在获取', mask: true }) + postCaptcha({ verifiableAccount: this.data.form.account, verifiableAccountType: 1, purpose: 1 }).then(result => { wx.hideLoading() - this.setData({ - codeEnable: false - }) + this.setData({ codeEnable: false }) util.showToast('验证码已经发送') this.wuxCountDown = new $wuxCountDown({ date: +(new Date) + 60000, onEnd() { - this.setData({ - second: '重新获取验证码', - codeEnable: true - }) + this.setData({ second: '重新获取验证码', codeEnable: true }) }, render(date) { const sec = this.leadingZeros(date.sec, 2) + ' 秒 ' - date.sec !== 0 && this.setData({ - second: sec - }) + date.sec !== 0 && this.setData({ second: sec }) }, }) }).catch(error => { @@ -257,31 +219,20 @@ Page({ }) }, readAgreement: function () { - wx.navigateTo({ - url: '/pages/html/agreement/index' - }) + wx.navigateTo({ url: '/pages/html/agreement/index' }) }, onGotUserInfo: function (e) { - this.setData({ - loging: true - }) - loginWechat({ - encryptedData: e.detail.encryptedData, - iv: e.detail.iv - }).then(result => { + this.setData({ loging: true }) + loginWechat({ encryptedData: e.detail.encryptedData, iv: e.detail.iv }).then(result => { storage.put('Authorization', result.data.token) app.globalData.token = result.data.token this.fetchUserInfo() }).catch(error => { wx.hideLoading() - this.setData({ - loging: false - }) + this.setData({ loging: false }) if (error && error.data) { if (error.code == 200101) { - this.setData({ - wxflag: true - }) + this.setData({ wxflag: true }) } this.data.userInfo = e.detail.userInfo this.data.form.tmpAuthToken = error.data.tmpAuthToken @@ -289,7 +240,14 @@ Page({ } }) }, + onShow: function () { + tdsdk.Page.onShow() + }, + onHide: function(){ + tdsdk.Page.onHide() + }, onUnload: function () { + tdsdk.Page.onUnload() if (this.wuxCountDown) { this.wuxCountDown.stop() this.wuxCountDown = null diff --git a/pages/mall/index/index.js b/pages/mall/index/index.js index 303c5fb..bd18b42 100644 --- a/pages/mall/index/index.js +++ b/pages/mall/index/index.js @@ -1,4 +1,5 @@ // pages/agent/index/index.js +const tdsdk = require('../../../libs/tdweapp.js') const app = getApp() Page({ @@ -31,6 +32,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { + tdsdk.Page.onShow() var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value) if (pageView) { pageView.onRestart() @@ -45,5 +47,11 @@ Page({ } this.setData({ pageIndex: Number(e.currentTarget.dataset.index) }) this.onShow() + }, + onHide: function(){ + tdsdk.Page.onHide() + }, + onUnload: function () { + tdsdk.Page.onUnload() } }) \ No newline at end of file