phone.js 1.7 KB

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