phone.js 1.7 KB

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