phone.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import Toast from '@vant/weapp/toast/toast';
  2. const _Http = getApp().globalData.http;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. site: getApp().globalData.site,
  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. if (res.code == 0) return wx.showToast({
  28. title: res.msg,
  29. icon: "none"
  30. })
  31. loginMsg.loginMsg(res);
  32. })
  33. } else {
  34. console.log('登录失败!' + res.errMsg)
  35. }
  36. }
  37. })
  38. },
  39. /* 用户登录 */
  40. userLogin() {
  41. if (this.data.loading || this.data.disabled) return;
  42. if (!this.data.isAgree) return Toast({
  43. message: '请阅读并勾选用户协议',
  44. position: 'bottom'
  45. });
  46. this.setData({
  47. loading: true
  48. })
  49. this.selectComponent('#login').handleLogin();
  50. },
  51. /* 授权 */
  52. agreementChange({
  53. detail
  54. }) {
  55. this.setData({
  56. isAgree: detail
  57. })
  58. },
  59. onShareAppMessage() {}
  60. })