me.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import http from '../../base/httputil'
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. isShowAccoutDialog : false,
  9. isBindSuccess : false,
  10. userName :'未登录',
  11. password: null,
  12. openid: null
  13. },
  14. onLoad(e){
  15. this.setData({
  16. isBindSuccess : app.isLoginSuccess,
  17. // userName:
  18. })
  19. if(app.isLoginSuccess){
  20. this.data.userName=wx.getStorageSync('userName')
  21. this.setData({
  22. userName:this.data.userName
  23. })
  24. }
  25. },
  26. onShow() {
  27. },
  28. inputUserName(e){
  29. this.userName = e.detail.value
  30. },
  31. inputPassword(e){
  32. this.password = e.detail.value
  33. },
  34. isLogin(){
  35. if(!app.isLoginSuccess){
  36. wx.reLaunch({
  37. url: '../denglu/denglu',
  38. })
  39. }else{
  40. wx.showModal({
  41. title: '提示',
  42. content: '确认退出?',
  43. complete: (res) => {
  44. if (res.cancel) {
  45. }
  46. if (res.confirm) {
  47. this.clear()
  48. }
  49. }
  50. })
  51. }
  52. },
  53. // init_userInfo() {
  54. // let that = this
  55. // if (app.globalToken == null) {
  56. // wx.getUserProfile({
  57. // desc: 'desc',
  58. // success: (res) => {
  59. // this.getSysUserInfo(res.userInfo)
  60. // that.setData({
  61. // userInfo : res.userInfo
  62. // })
  63. // },
  64. // fail: res => {
  65. // console.log(res)
  66. // },
  67. // })
  68. // }
  69. // },
  70. // getSysUserInfo(info) {
  71. // let that = this
  72. // wx.login({
  73. // success(res) {
  74. // var code = res.code
  75. // var data = {
  76. // wxCode: code,
  77. // wxNickName: info.nickName,
  78. // wxAvatarUrl: info.avatarUrl
  79. // }
  80. // http.send_post("/auth/applogin", data, that.loginSuccess)
  81. // },
  82. // fail(res) {
  83. // console.log("ffff", res)
  84. // }
  85. // })
  86. // },
  87. bindViewClear(){
  88. wx.showModal({
  89. title: '提示',
  90. content: '确认清除缓存?',
  91. complete: (res) => {
  92. if (res.cancel) {
  93. }
  94. if (res.confirm) {
  95. this.clear()
  96. }
  97. }
  98. })
  99. },
  100. clear(){
  101. wx.clearStorage({
  102. success: (res) => {
  103. wx.showToast({
  104. title: '清理成功',
  105. })
  106. wx.removeStorageSync('userName');
  107. wx.removeStorageSync('password');
  108. wx.removeStorageSync('openid');
  109. app.globalToken=null;
  110. app.isLoginSuccess=false;
  111. this.setData({
  112. isShowAccoutDialog : false,
  113. isBindSuccess : false,
  114. userName :"未登录",
  115. password: null,
  116. openid: null
  117. })
  118. wx.reLaunch({
  119. url: '../denglu/denglu'
  120. })
  121. },
  122. })
  123. },
  124. // modalCancel(){
  125. // this.setData({
  126. // isShowAccoutDialog : false
  127. // })
  128. // },
  129. // modalSubmit(){
  130. // let obj = new Object()
  131. // obj.openid = this.openid
  132. // obj.userName = this.userName
  133. // obj.password = this.password
  134. // http.send_post("/system/minapp/AppLoginController/bindWxUser",obj,this.modalSubmitSuccess)
  135. // },
  136. // modalSubmitSuccess(res){
  137. // wx.showToast({
  138. // title: res.msg,
  139. // icon: "none"
  140. // })
  141. // if (res.code == 200) {
  142. // this.setData({
  143. // isShowAccoutDialog : false,
  144. // isBindSuccess : true
  145. // })
  146. // }
  147. // },
  148. /**
  149. * 生命周期函数--监听页面初次渲染完成
  150. */
  151. onReady() {
  152. },
  153. /**
  154. * 生命周期函数--监听页面隐藏
  155. */
  156. onHide() {
  157. },
  158. /**
  159. * 生命周期函数--监听页面卸载
  160. */
  161. onUnload() {
  162. },
  163. /**
  164. * 页面相关事件处理函数--监听用户下拉动作
  165. */
  166. onPullDownRefresh() {
  167. },
  168. /**
  169. * 页面上拉触底事件的处理函数
  170. */
  171. onReachBottom() {
  172. },
  173. /**
  174. * 用户点击右上角分享
  175. */
  176. onShareAppMessage() {
  177. }
  178. })