phone.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. Page({
  2. data: {
  3. isAgree: false,
  4. disabled: true, //是否禁用
  5. loading: false, //登陆中
  6. register: null,
  7. showDialog: false,
  8. showLogo: 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. const deviceInfo = wx.getDeviceInfo();
  18. this.setData({
  19. showLogo: !deviceInfo.system.includes("iOS 26")
  20. })
  21. if (this.data.showLogo) setTimeout(() => {
  22. this.setData({
  23. showLogo: true
  24. })
  25. }, 1500)
  26. },
  27. /* 修改授权 */
  28. isAgreeChange() {
  29. let isAgree = !this.data.isAgree
  30. this.setData({
  31. isAgree
  32. })
  33. wx.setStorageSync(isAgree)
  34. },
  35. /* 查看隐私协议 */
  36. checkTheAgreement() {
  37. wx.showLoading({
  38. title: getApp().globalData.Language.getMapText('加载中...'),
  39. })
  40. wx.downloadFile({
  41. url: 'https://yossys80658.obs.cn-east-2.myhuaweicloud.com/system/%E7%8F%AD%E5%B0%BC%E6%88%88%E8%90%A5%E9%94%80%E5%B9%B3%E5%8F%B0%E5%B0%8F%E7%A8%8B%E5%BA%8F%E9%9A%90%E7%A7%81%E4%BF%9D%E6%8A%A4%E6%8C%87%E5%BC%95.docx',
  42. success: (res) => {
  43. wx.openDocument({
  44. filePath: res.tempFilePath,
  45. success: (s) => {
  46. wx.hideLoading();
  47. },
  48. fail: (err) => {
  49. wx.hideLoading();
  50. getApp().globalData.Language.showToast('读取失败,请稍后再试')
  51. }
  52. })
  53. },
  54. fail: (err) => {
  55. wx.hideLoading();
  56. getApp().globalData.Language.showToast('读取失败,请稍后再试')
  57. }
  58. })
  59. },
  60. /* 微信登录 */
  61. wechatLogin() {
  62. if (this.data.loading) return
  63. if (!this.data.isAgree) {
  64. this.data.register = this.wechatLogin
  65. this.setData({
  66. showDialog: true
  67. })
  68. return
  69. }
  70. wx.login({
  71. success(res) {
  72. if (res.code) {
  73. getApp().globalData.http.loginbywechat({
  74. wechat_code: res.code,
  75. "systemclient": "wechatsaletool"
  76. }).then(res => {
  77. console.log("微信快捷登录", res)
  78. if (res.code == 0) return wx.showToast({
  79. title: getApp().globalData.Language.getMapText(res.msg || '未查询到绑定账号'),
  80. icon: "none"
  81. })
  82. require("./modules/login").loginMsg(res);
  83. getApp().globalData.remindchangepassword = res.remindchangepassword == 1;
  84. })
  85. } else {
  86. console.log('登录失败!' + res.errMsg)
  87. }
  88. }
  89. })
  90. },
  91. /* 用户登录 */
  92. userLogin() {
  93. if (this.data.loading || this.data.disabled) return;
  94. if (!this.data.isAgree) {
  95. this.data.register = this.userLogin
  96. this.setData({
  97. showDialog: true
  98. })
  99. return
  100. }
  101. this.setData({
  102. loading: true
  103. })
  104. this.selectComponent('#login').handleLogin();
  105. },
  106. onConfirm() {
  107. this.setData({
  108. showDialog: false,
  109. isAgree: true
  110. })
  111. this.data.register()
  112. },
  113. todev() {
  114. if (this.data.devCount == 5) {
  115. wx.navigateTo({
  116. url: '/pages/login/developerTools',
  117. })
  118. this.data.devCount = 0;
  119. } else {
  120. this.data.devCount += 1;
  121. }
  122. },
  123. onShareAppMessage() {}
  124. })