phone.js 3.4 KB

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