phone.js 2.5 KB

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