phone.js 3.7 KB

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