phone.js 2.2 KB

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