phone.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. Page({
  2. data: {
  3. isAgree: false,
  4. disabled: true, //是否禁用
  5. loading: false, //登陆中
  6. register: null,
  7. languages: [],
  8. language: {},
  9. showDialog: false,
  10. pageShow: false,
  11. showLogo: false
  12. },
  13. async onLoad() {
  14. if (wx.getStorageSync('isAgree')) this.setData({
  15. isAgree: wx.getStorageSync('isAgree')
  16. })
  17. this.setData({
  18. devCount: 0,
  19. })
  20. getApp().globalData.http.base({
  21. id: "10026401",
  22. content: {}
  23. }).then(res => {
  24. console.log("语言包列表", res)
  25. if (res.code == '1') {
  26. let item = res.data.find(v => v.languagecode == (wx.getStorageSync('languagecode') || 'ZH'))
  27. try {
  28. this.setData({
  29. languages: res.data,
  30. languagename: item.languagename || '简体中文',
  31. rowIndex: item.rowindex - 1
  32. })
  33. } catch (error) {
  34. this.setData({
  35. languages: res.data,
  36. languagename: '简体中文',
  37. rowIndex: 0
  38. })
  39. }
  40. }
  41. })
  42. getApp().globalData.Language.getLanguagePackage(this, '账户登录');
  43. const deviceInfo = wx.getDeviceInfo();
  44. this.setData({
  45. showLogo: !deviceInfo.system.includes("iOS 26")
  46. })
  47. if (!this.data.showLogo) setTimeout(() => {
  48. this.setData({
  49. showLogo: true
  50. })
  51. }, 1000);
  52. },
  53. changeLanguages(e) {
  54. let item = this.data.languages[e.detail.value];
  55. getApp().globalData.Language.getLanguages(item.languagecode).then(res => {
  56. this.setData({
  57. languagename: item.languagename || '简体中文',
  58. rowIndex: item.rowindex - 1
  59. })
  60. getApp().globalData.Language.getLanguagePackage(this, '账户登录');
  61. })
  62. },
  63. /* 修改授权 */
  64. isAgreeChange() {
  65. let isAgree = !this.data.isAgree
  66. this.setData({
  67. isAgree
  68. })
  69. wx.setStorageSync(isAgree)
  70. },
  71. /* 查看隐私协议 */
  72. checkTheAgreement() {
  73. wx.showLoading({
  74. title: getApp().globalData.Language.getMapText('加载中...'),
  75. })
  76. wx.downloadFile({
  77. 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',
  78. success: (res) => {
  79. wx.openDocument({
  80. filePath: res.tempFilePath,
  81. success: (s) => {
  82. wx.hideLoading();
  83. },
  84. fail: (err) => {
  85. wx.hideLoading();
  86. getApp().globalData.Language.showToast('读取失败,请稍后再试')
  87. }
  88. })
  89. },
  90. fail: (err) => {
  91. wx.hideLoading();
  92. getApp().globalData.Language.showToast('读取失败,请稍后再试')
  93. }
  94. })
  95. },
  96. /* 微信登录 */
  97. wechatLogin() {
  98. if (this.data.loading) return
  99. if (!this.data.isAgree) {
  100. this.data.register = this.wechatLogin
  101. this.setData({
  102. showDialog: true
  103. })
  104. return
  105. }
  106. wx.login({
  107. success(res) {
  108. if (res.code) {
  109. getApp().globalData.http.loginbywechat({
  110. wechat_code: res.code,
  111. "systemclient": "wechatsaletool"
  112. }).then(res => {
  113. console.log("微信快捷登录", res)
  114. if (res.code == 0) return wx.showToast({
  115. title: getApp().globalData.Language.getMapText(res.msg == '' ? '未查询到绑定账号' : res.msg),
  116. icon: "none"
  117. })
  118. require("./modules/login").loginMsg(res);
  119. getApp().globalData.remindchangepassword = res.remindchangepassword == 1;
  120. })
  121. } else {
  122. console.log('登录失败!' + res.errMsg)
  123. }
  124. }
  125. })
  126. },
  127. /* 用户登录 */
  128. userLogin() {
  129. if (this.data.loading || this.data.disabled) return;
  130. if (!this.data.isAgree) {
  131. this.data.register = this.userLogin
  132. this.setData({
  133. showDialog: true
  134. })
  135. return
  136. }
  137. this.setData({
  138. loading: true
  139. })
  140. this.selectComponent('#login').handleLogin();
  141. },
  142. onConfirm() {
  143. this.setData({
  144. showDialog: false,
  145. isAgree: true
  146. })
  147. this.data.register()
  148. },
  149. todev() {
  150. if (this.data.devCount == 5) {
  151. wx.navigateTo({
  152. url: '/pages/login/developerTools',
  153. })
  154. this.data.devCount = 0;
  155. } else {
  156. this.data.devCount += 1;
  157. }
  158. },
  159. onShareAppMessage() {}
  160. })