合伙人运营小程序
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // pages/login/index.js
  2. const api = require('../../api/index.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. // 状态栏高度
  9. statusBarHeight: wx.getStorageSync('statusBarHeight'),
  10. // 导航栏高度
  11. navBarHeight: wx.getStorageSync('navBarHeight'),
  12. // 导航栏和状态栏高度
  13. navStatusBarHeight: wx.getStorageSync('navStatusBarHeight'),
  14. // 胶囊
  15. menu:wx.getStorageSync('menu'),
  16. account:'',
  17. password:'',
  18. passwordtype:true,
  19. checked:false,
  20. isChecked: false, // 单选框是否被勾选
  21. shakeClass: '', // 控制晃动动画的类名
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad(options) {
  27. },
  28. onpassword(){
  29. console.log(111);
  30. this.setData({
  31. passwordtype:!this.data.passwordtype
  32. })
  33. },
  34. checkboxChange(e) {
  35. console.log('checkbox发生change事件,携带value值为:', e.currentTarget.dataset.value)
  36. this.setData({
  37. checked:!e.currentTarget.dataset.value
  38. })
  39. },
  40. // 处理单选框状态变化
  41. onRadioChange(e) {
  42. this.setData({
  43. isChecked: e.detail.value === 'agree',
  44. });
  45. },
  46. bindKeyInput1: function (e) {
  47. this.setData({
  48. account: e.detail.value
  49. })
  50. },
  51. bindKeyInput2: function (e) {
  52. this.setData({
  53. password: e.detail.value
  54. })
  55. },
  56. // 处理登录按钮点击
  57. onLogin() {
  58. if (!this.data.checked) {
  59. return wx.showToast({
  60. title: '请勾选同意',
  61. icon: 'none',
  62. });
  63. }
  64. let data ={
  65. username:this.data.account,
  66. password:this.data.password,
  67. rememberMe: 1
  68. }
  69. console.log(data);
  70. api.request('/auth/login', 'POST',data).then((res) => {
  71. console.log(res);
  72. if (res.code==200&&res.status=='ok') {
  73. // 设置数据到本地存储
  74. wx.setStorage({
  75. key: 'cookies', // 存储的key值
  76. data:res.msg,
  77. success: function(ress) {
  78. console.log(ress);
  79. // 获取本地存储的数据
  80. wx.reLaunch({
  81. url: '/pages/index/index'
  82. });
  83. wx.showToast({
  84. title: '登录成功',
  85. icon: 'success',
  86. });
  87. }
  88. });
  89. }else{
  90. wx.showToast({
  91. title: res.msg,
  92. icon: 'none',
  93. });
  94. }
  95. // 在这里处理返回的数据
  96. })
  97. .catch((err) => {
  98. wx.showToast({
  99. title: "账户或密码输入不正确",
  100. icon: 'none',
  101. });
  102. // 在这里处理请求失败的情况
  103. });
  104. },
  105. onprivacy(e){
  106. console.log(e.target.dataset.name);
  107. wx.navigateTo({
  108. url: `/pages/privacy/index?name=${e.target.dataset.name}`,
  109. })
  110. },
  111. /**
  112. * 生命周期函数--监听页面初次渲染完成
  113. */
  114. onReady() {
  115. },
  116. /**
  117. * 生命周期函数--监听页面显示
  118. */
  119. onShow() {
  120. },
  121. /**
  122. * 生命周期函数--监听页面隐藏
  123. */
  124. onHide() {
  125. },
  126. /**
  127. * 生命周期函数--监听页面卸载
  128. */
  129. onUnload() {
  130. },
  131. /**
  132. * 页面相关事件处理函数--监听用户下拉动作
  133. */
  134. onPullDownRefresh() {
  135. },
  136. /**
  137. * 页面上拉触底事件的处理函数
  138. */
  139. onReachBottom() {
  140. },
  141. /**
  142. * 用户点击右上角分享
  143. */
  144. onShareAppMessage() {
  145. }
  146. })