phone.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. loginFunc: "account",
  13. },
  14. onLoad(options) {
  15. if (wx.getStorageSync('isAgree')) this.setData({
  16. isAgree: wx.getStorageSync('isAgree')
  17. })
  18. this.setData({
  19. devCount: 0
  20. })
  21. },
  22. changFun() {
  23. this.setData({
  24. loginFunc: this.data.loginFunc == 'account' ? "phone" : "account"
  25. })
  26. setTimeout(() => {
  27. this.selectComponent('#login').allowOrNot();
  28. }, 800)
  29. },
  30. /* 微信登录 */
  31. wechatLogin() {
  32. if (!this.data.isAgree) return Toast({
  33. message: '请阅读并勾选用户协议',
  34. position: 'bottom'
  35. });
  36. wx.login({
  37. success(res) {
  38. if (res.code) {
  39. _Http.loginbywechat({
  40. wechat_code: res.code,
  41. "systemclient": "wechatsaletool"
  42. }).then(res => {
  43. console.log("微信快捷登录", res)
  44. if (res.code == 0) return wx.showToast({
  45. title: res.msg,
  46. icon: "none"
  47. })
  48. loginMsg.loginMsg(res);
  49. getApp().globalData.remindchangepassword_str = res.remindchangepassword_str;
  50. })
  51. } else {
  52. console.log('登录失败!' + res.errMsg)
  53. }
  54. }
  55. })
  56. },
  57. /* 用户登录 */
  58. userLogin() {
  59. if (this.data.loading || this.data.disabled) return;
  60. if (!this.data.isAgree) return Toast({
  61. message: '请阅读并勾选用户协议',
  62. position: 'bottom'
  63. });
  64. this.setData({
  65. loading: true
  66. })
  67. this.selectComponent('#login').handleLogin();
  68. },
  69. /* 授权 */
  70. agreementChange({
  71. detail
  72. }) {
  73. this.setData({
  74. isAgree: detail
  75. })
  76. },
  77. todev() {
  78. if (_Http.ENV != 'develop' && _Http.ENV != 'trial') return;
  79. if (this.data.devCount == 5) {
  80. wx.navigateTo({
  81. url: '/pages/login/developerTools',
  82. })
  83. this.data.devCount = 0;
  84. } else {
  85. this.data.devCount += 1;
  86. }
  87. },
  88. onShareAppMessage() {}
  89. })