phone.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. },
  18. /* 微信登录 */
  19. wechatLogin() {
  20. if (!this.data.isAgree) return Toast({
  21. message: '请阅读并勾选用户协议',
  22. position: 'bottom'
  23. });
  24. wx.login({
  25. success(res) {
  26. if (res.code) {
  27. _Http.loginbywechat({
  28. wechat_code: res.code,
  29. "systemclient": "wechatsaletool"
  30. }).then(res => {
  31. console.log("微信快捷登录", res)
  32. if (res.code == 0) return wx.showToast({
  33. title: res.msg,
  34. icon: "none"
  35. })
  36. loginMsg.loginMsg(res);
  37. console.log('是否为初始密码', res.remindchangepassword == 1)
  38. getApp().globalData.remindchangepassword = res.remindchangepassword == 1;
  39. })
  40. } else {
  41. console.log('登录失败!' + res.errMsg)
  42. }
  43. }
  44. })
  45. },
  46. /* 用户登录 */
  47. userLogin() {
  48. if (this.data.loading || this.data.disabled) return;
  49. if (!this.data.isAgree) return Toast({
  50. message: '请阅读并勾选用户协议',
  51. position: 'bottom'
  52. });
  53. this.setData({
  54. loading: true
  55. })
  56. this.selectComponent('#login').handleLogin();
  57. },
  58. /* 授权 */
  59. agreementChange({
  60. detail
  61. }) {
  62. this.setData({
  63. isAgree: detail
  64. })
  65. },
  66. onShareAppMessage() {}
  67. })