phone.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. getApp().globalData.remindchangepassword_str = res.remindchangepassword_str;
  38. })
  39. } else {
  40. console.log('登录失败!' + res.errMsg)
  41. }
  42. }
  43. })
  44. },
  45. /* 用户登录 */
  46. userLogin() {
  47. if (this.data.loading || this.data.disabled) return;
  48. if (!this.data.isAgree) return Toast({
  49. message: '请阅读并勾选用户协议',
  50. position: 'bottom'
  51. });
  52. this.setData({
  53. loading: true
  54. })
  55. this.selectComponent('#login').handleLogin();
  56. },
  57. /* 授权 */
  58. agreementChange({
  59. detail
  60. }) {
  61. this.setData({
  62. isAgree: detail
  63. })
  64. },
  65. onShareAppMessage() {}
  66. })