index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import Toast from '@vant/weapp/toast/toast';
  2. const _Http = getApp().globalData.http;
  3. const loginMsg = require("./modules/login");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. isAgree: true
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad(options) {
  15. },
  16. toPhoneLodin() {
  17. if (!this.data.isAgree) return Toast({
  18. message: '请阅读并勾选用户协议',
  19. position: 'bottom'
  20. });
  21. wx.navigateTo({
  22. url: './phone'
  23. })
  24. },
  25. agreementChange({
  26. detail
  27. }) {
  28. this.setData({
  29. isAgree: detail
  30. })
  31. },
  32. wechatLogin() {
  33. if (!this.data.isAgree) return Toast({
  34. message: '请阅读并勾选用户协议',
  35. position: 'bottom'
  36. });
  37. wx.login({
  38. success(res) {
  39. if (res.code) {
  40. _Http.loginbywechat({
  41. wechat_code: res.code,
  42. "systemclient": "wechatsaletool"
  43. }).then(res => {
  44. console.log(res)
  45. if (res.code == 0) return wx.showToast({
  46. title: res.msg,
  47. icon: "none"
  48. })
  49. loginMsg.loginMsg(res);
  50. })
  51. } else {
  52. console.log('登录失败!' + res.errMsg)
  53. }
  54. }
  55. })
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady() {
  61. },
  62. /**
  63. * 生命周期函数--监听页面显示
  64. */
  65. onShow() {
  66. },
  67. /**
  68. * 生命周期函数--监听页面隐藏
  69. */
  70. onHide() {
  71. },
  72. /**
  73. * 生命周期函数--监听页面卸载
  74. */
  75. onUnload() {
  76. },
  77. /**
  78. * 页面相关事件处理函数--监听用户下拉动作
  79. */
  80. onPullDownRefresh() {
  81. },
  82. /**
  83. * 页面上拉触底事件的处理函数
  84. */
  85. onReachBottom() {
  86. },
  87. /**
  88. * 用户点击右上角分享
  89. */
  90. onShareAppMessage() {
  91. }
  92. })