|
|
@@ -1,107 +1,146 @@
|
|
|
-import Toast from '@vant/weapp/toast/toast';
|
|
|
-
|
|
|
Page({
|
|
|
- data: {
|
|
|
- isAgree: false,
|
|
|
- disabled: true, //是否禁用
|
|
|
- loading: false, //登陆中
|
|
|
- languages: [],
|
|
|
- },
|
|
|
- async onLoad() {
|
|
|
- if (wx.getStorageSync('isAgree')) this.setData({
|
|
|
- isAgree: wx.getStorageSync('isAgree')
|
|
|
- })
|
|
|
- this.setData({
|
|
|
- devCount: 0,
|
|
|
- })
|
|
|
- getApp().globalData.http.base({
|
|
|
- id: "10026401",
|
|
|
- content: {}
|
|
|
- }).then(res => {
|
|
|
- console.log("语言包列表", res)
|
|
|
- if (res.code == '1') {
|
|
|
- let item = res.data.find(v => v.languagecode == (wx.getStorageSync('languagecode')))
|
|
|
- console.log("item", item)
|
|
|
- this.setData({
|
|
|
- languages: res.data,
|
|
|
- languagename: item.languagename || '简体中文',
|
|
|
- rowIndex: item.rowindex - 1
|
|
|
- })
|
|
|
- this.changeTitle();
|
|
|
- }
|
|
|
- })
|
|
|
- this.changeTitle()
|
|
|
- },
|
|
|
- changeLanguages(e) {
|
|
|
- let item = this.data.languages[e.detail.value];
|
|
|
- getApp().globalData.Language.getLanguages(item.languagecode).then(res => {
|
|
|
- this.setData({
|
|
|
- language: res,
|
|
|
- languagename: item.languagename || '简体中文',
|
|
|
- rowIndex: item.rowindex - 1
|
|
|
- })
|
|
|
- this.changeTitle();
|
|
|
- })
|
|
|
- },
|
|
|
- changeTitle() {
|
|
|
- getApp().globalData.Language.getLanguagePackage(this, '账户登录');
|
|
|
- },
|
|
|
- /* 微信登录 */
|
|
|
- wechatLogin() {
|
|
|
- if (!this.data.isAgree) return Toast({
|
|
|
- message: getApp().globalData.Language.getMapText("确认用户协议") || '请阅读并勾选用户协议',
|
|
|
- position: 'bottom'
|
|
|
- });
|
|
|
- wx.login({
|
|
|
- success(res) {
|
|
|
- if (res.code) {
|
|
|
- getApp().globalData.http.loginbywechat({
|
|
|
- wechat_code: res.code,
|
|
|
- "systemclient": "wechatsaletool"
|
|
|
- }).then(res => {
|
|
|
- console.log("微信快捷登录", res)
|
|
|
- if (res.code == 0) return wx.showToast({
|
|
|
- title: res.msg,
|
|
|
- icon: "none"
|
|
|
- })
|
|
|
- require("./modules/login").loginMsg(res);
|
|
|
- getApp().globalData.remindchangepassword = res.remindchangepassword == 1;
|
|
|
- })
|
|
|
- } else {
|
|
|
- console.log('登录失败!' + res.errMsg)
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- /* 用户登录 */
|
|
|
- userLogin() {
|
|
|
- if (this.data.loading || this.data.disabled) return;
|
|
|
- if (!this.data.isAgree) return Toast({
|
|
|
- message: getApp().globalData.Language.getMapText("确认用户协议") || '请阅读并勾选用户协议',
|
|
|
- position: 'bottom'
|
|
|
- });
|
|
|
- this.setData({
|
|
|
- loading: true
|
|
|
- })
|
|
|
- this.selectComponent('#login').handleLogin();
|
|
|
- },
|
|
|
- /* 授权 */
|
|
|
- agreementChange({
|
|
|
- detail
|
|
|
- }) {
|
|
|
- this.setData({
|
|
|
- isAgree: detail
|
|
|
- })
|
|
|
- },
|
|
|
- todev() {
|
|
|
- if (this.data.devCount == 5) {
|
|
|
- wx.navigateTo({
|
|
|
- url: '/pages/login/developerTools',
|
|
|
- })
|
|
|
- this.data.devCount = 0;
|
|
|
- } else {
|
|
|
- this.data.devCount += 1;
|
|
|
- }
|
|
|
- },
|
|
|
- onShareAppMessage() {}
|
|
|
+ data: {
|
|
|
+ isAgree: false,
|
|
|
+ disabled: true, //是否禁用
|
|
|
+ loading: false, //登陆中
|
|
|
+ register: null,
|
|
|
+ languages: [],
|
|
|
+ showDialog: false
|
|
|
+ },
|
|
|
+ async onLoad() {
|
|
|
+ if (wx.getStorageSync('isAgree')) this.setData({
|
|
|
+ isAgree: wx.getStorageSync('isAgree')
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ devCount: 0,
|
|
|
+ })
|
|
|
+ getApp().globalData.http.base({
|
|
|
+ id: "10026401",
|
|
|
+ content: {}
|
|
|
+ }).then(res => {
|
|
|
+ console.log("语言包列表", res)
|
|
|
+ if (res.code == '1') {
|
|
|
+ let item = res.data.find(v => v.languagecode == (wx.getStorageSync('languagecode')))
|
|
|
+ console.log("item", item)
|
|
|
+ this.setData({
|
|
|
+ languages: res.data,
|
|
|
+ languagename: item.languagename || '简体中文',
|
|
|
+ rowIndex: item.rowindex - 1
|
|
|
+ })
|
|
|
+ this.changeTitle();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ getApp().globalData.Language.getLanguagePackage(this, '账户登录');
|
|
|
+ },
|
|
|
+ changeLanguages(e) {
|
|
|
+ let item = this.data.languages[e.detail.value];
|
|
|
+ getApp().globalData.Language.getLanguages(item.languagecode).then(res => {
|
|
|
+ this.setData({
|
|
|
+ language: res,
|
|
|
+ languagename: item.languagename || '简体中文',
|
|
|
+ rowIndex: item.rowindex - 1
|
|
|
+ })
|
|
|
+ this.changeTitle();
|
|
|
+ })
|
|
|
+ },
|
|
|
+ changeTitle() {
|
|
|
+ getApp().globalData.Language.setNavBarTitle('账户登录')
|
|
|
+ },
|
|
|
+ /* 修改授权 */
|
|
|
+ isAgreeChange() {
|
|
|
+ let isAgree = !this.data.isAgree
|
|
|
+ this.setData({
|
|
|
+ isAgree
|
|
|
+ })
|
|
|
+ wx.setStorageSync(isAgree)
|
|
|
+ },
|
|
|
+ /* 查看隐私协议 */
|
|
|
+ checkTheAgreement() {
|
|
|
+ wx.showLoading({
|
|
|
+ title: getApp().globalData.Language.getMapText('加载中...'),
|
|
|
+ })
|
|
|
+ wx.downloadFile({
|
|
|
+ url: 'https://yossys80658.obs.cn-east-2.myhuaweicloud.com/system/E%E8%AE%A2%E5%8D%95%E9%9A%90%E7%A7%81%E4%BF%9D%E6%8A%A4.docx',
|
|
|
+ success: (res) => {
|
|
|
+ wx.openDocument({
|
|
|
+ filePath: res.tempFilePath,
|
|
|
+ success: (s) => {
|
|
|
+ wx.hideLoading();
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ wx.hideLoading();
|
|
|
+ getApp().globalData.Language.showToast('读取失败,请稍后再试')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ wx.hideLoading();
|
|
|
+ getApp().globalData.Language.showToast('读取失败,请稍后再试')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 微信登录 */
|
|
|
+ wechatLogin() {
|
|
|
+ if (this.data.loading) return
|
|
|
+ if (!this.data.isAgree) {
|
|
|
+ this.data.register = this.wechatLogin
|
|
|
+ this.setData({
|
|
|
+ showDialog: true
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ wx.login({
|
|
|
+ success(res) {
|
|
|
+ if (res.code) {
|
|
|
+ getApp().globalData.http.loginbywechat({
|
|
|
+ wechat_code: res.code,
|
|
|
+ "systemclient": "wechatsaletool"
|
|
|
+ }).then(res => {
|
|
|
+ console.log("微信快捷登录", res)
|
|
|
+ if (res.code == 0) return wx.showToast({
|
|
|
+ title: getApp().globalData.Language.getMapText('res.msg'),
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ require("./modules/login").loginMsg(res);
|
|
|
+ getApp().globalData.remindchangepassword = res.remindchangepassword == 1;
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('登录失败!' + res.errMsg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 用户登录 */
|
|
|
+ userLogin() {
|
|
|
+ if (this.data.loading || this.data.disabled) return;
|
|
|
+ if (!this.data.isAgree) {
|
|
|
+ this.data.register = this.userLogin
|
|
|
+ this.setData({
|
|
|
+ showDialog: true
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ loading: true
|
|
|
+ })
|
|
|
+ this.selectComponent('#login').handleLogin();
|
|
|
+ },
|
|
|
+ onConfirm() {
|
|
|
+ this.setData({
|
|
|
+ showDialog: false,
|
|
|
+ isAgree: true
|
|
|
+ })
|
|
|
+ this.data.register()
|
|
|
+ },
|
|
|
+ todev() {
|
|
|
+ if (this.data.devCount == 5) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/login/developerTools',
|
|
|
+ })
|
|
|
+ this.data.devCount = 0;
|
|
|
+ } else {
|
|
|
+ this.data.devCount += 1;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onShareAppMessage() {}
|
|
|
})
|