phone.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import Toast from '@vant/weapp/toast/toast';
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. isAgree: false,
  8. disabled: true, //是否禁用
  9. loading: false, //登陆中
  10. },
  11. onLoad(options) {
  12. if (wx.getStorageSync('isAgree')) this.setData({
  13. isAgree: wx.getStorageSync('isAgree')
  14. })
  15. this.setData({
  16. devCount: 0
  17. })
  18. },
  19. /* 微信登录 */
  20. wechatLogin() {
  21. if (!this.data.isAgree) return Toast({
  22. message: '请阅读并勾选用户协议',
  23. position: 'bottom'
  24. });
  25. wx.login({
  26. success(res) {
  27. if (res.code) {
  28. getApp().globalData.http.loginbywechat({
  29. wechat_code: res.code,
  30. "systemclient": "wechatsaletool"
  31. }).then(res => {
  32. console.log("微信快捷登录", res)
  33. if (res.code == 0) return wx.showToast({
  34. title: res.msg,
  35. icon: "none"
  36. })
  37. require("./modules/login").loginMsg(res);
  38. console.log('是否为初始密码', res.remindchangepassword == 1)
  39. getApp().globalData.remindchangepassword = res.remindchangepassword == 1;
  40. })
  41. } else {
  42. console.log('登录失败!' + res.errMsg)
  43. }
  44. }
  45. })
  46. },
  47. /* 用户登录 */
  48. userLogin() {
  49. if (this.data.loading || this.data.disabled) return;
  50. if (!this.data.isAgree) return Toast({
  51. message: '请阅读并勾选用户协议',
  52. position: 'bottom'
  53. });
  54. this.setData({
  55. loading: true
  56. })
  57. this.selectComponent('#login').handleLogin();
  58. },
  59. /* 授权 */
  60. agreementChange({
  61. detail
  62. }) {
  63. this.setData({
  64. isAgree: detail
  65. })
  66. },
  67. todev() {
  68. if (this.data.devCount == 5) {
  69. wx.navigateTo({
  70. url: '/pages/login/developerTools',
  71. })
  72. this.data.devCount = 0;
  73. } else {
  74. this.data.devCount += 1;
  75. }
  76. },
  77. onShareAppMessage() {}
  78. })