phone.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. Page({
  2. data: {
  3. isAgree: false,
  4. disabled: true, //是否禁用
  5. loading: false, //登陆中
  6. register: null,
  7. showDialog: false
  8. },
  9. async onLoad() {
  10. if (wx.getStorageSync('isAgree')) this.setData({
  11. isAgree: wx.getStorageSync('isAgree')
  12. })
  13. this.setData({
  14. devCount: 0,
  15. })
  16. },
  17. /* 修改授权 */
  18. isAgreeChange() {
  19. let isAgree = !this.data.isAgree
  20. this.setData({
  21. isAgree
  22. })
  23. wx.setStorageSync(isAgree)
  24. },
  25. /* 查看隐私协议 */
  26. checkTheAgreement() {
  27. wx.showLoading({
  28. title: getApp().globalData.Language.getMapText('加载中...'),
  29. })
  30. wx.downloadFile({
  31. 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',
  32. success: (res) => {
  33. wx.openDocument({
  34. filePath: res.tempFilePath,
  35. success: (s) => {
  36. wx.hideLoading();
  37. },
  38. fail: (err) => {
  39. wx.hideLoading();
  40. getApp().globalData.Language.showToast('读取失败,请稍后再试')
  41. }
  42. })
  43. },
  44. fail: (err) => {
  45. wx.hideLoading();
  46. getApp().globalData.Language.showToast('读取失败,请稍后再试')
  47. }
  48. })
  49. },
  50. /* 微信登录 */
  51. wechatLogin() {
  52. if (this.data.loading) return
  53. if (!this.data.isAgree) {
  54. this.data.register = this.wechatLogin
  55. this.setData({
  56. showDialog: true
  57. })
  58. return
  59. }
  60. wx.login({
  61. success(res) {
  62. if (res.code) {
  63. getApp().globalData.http.loginbywechat({
  64. wechat_code: res.code,
  65. "systemclient": "wechatsaletool"
  66. }).then(res => {
  67. console.log("微信快捷登录", res)
  68. if (res.code == 0) return wx.showToast({
  69. title: getApp().globalData.Language.getMapText(res.msg || '未查询到绑定账号'),
  70. icon: "none"
  71. })
  72. require("./modules/login").loginMsg(res);
  73. getApp().globalData.remindchangepassword = res.remindchangepassword == 1;
  74. })
  75. } else {
  76. console.log('登录失败!' + res.errMsg)
  77. }
  78. }
  79. })
  80. },
  81. /* 用户登录 */
  82. userLogin() {
  83. if (this.data.loading || this.data.disabled) return;
  84. if (!this.data.isAgree) {
  85. this.data.register = this.userLogin
  86. this.setData({
  87. showDialog: true
  88. })
  89. return
  90. }
  91. this.setData({
  92. loading: true
  93. })
  94. this.selectComponent('#login').handleLogin();
  95. },
  96. onConfirm() {
  97. this.setData({
  98. showDialog: false,
  99. isAgree: true
  100. })
  101. this.data.register()
  102. },
  103. todev() {
  104. if (this.data.devCount == 5) {
  105. wx.navigateTo({
  106. url: '/pages/login/developerTools',
  107. })
  108. this.data.devCount = 0;
  109. } else {
  110. this.data.devCount += 1;
  111. }
  112. },
  113. onShareAppMessage() {}
  114. })