index.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. var url = app.globalData.url
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. src: '/image/fen.jpg',
  11. src3: '/image/huang.png',
  12. src4: '/image/zan.png',
  13. showMore: false,
  14. frameStyle: { useTop: true, name: '我的', leftArrow: false, useBar: true },
  15. // 主体高度
  16. infoHeight: '',
  17. total: '4',
  18. item: {
  19. id: '1', head2: '/image/head2.png', head1: '/image/head1.png', fraction2: '0', groupname2: '马尼拉组', fraction1: '0', site: '第一场', groupname1: '哈拉海组', week: '星期五', time: '13:00',
  20. state: '已结束', date: '01.15', start: '未开始'
  21. },
  22. item1: {},
  23. list3: [],
  24. //头像
  25. icon: '',
  26. //团队logo
  27. showModal: false,
  28. },
  29. tabPath(e) {
  30. let query = e.detail.detail;
  31. if (query) wx.redirectTo({ url: `/pages/${query}/index` })
  32. },
  33. //展开
  34. listToggle: function () {
  35. this.setData({
  36. showMore: !this.data.showMore
  37. })
  38. },
  39. //修改个人信息
  40. modify: function () {
  41. wx.navigateTo({
  42. url: `/pages/information/index`,
  43. })
  44. },
  45. //上传比分
  46. upload: function () {
  47. wx.navigateTo({
  48. url: `/pages/score/index`,
  49. })
  50. },
  51. //创建团队
  52. create: function () {
  53. wx.navigateTo({
  54. url: `/pages/createTeam/index`,
  55. })
  56. },
  57. ToDetails: function () {
  58. wx.navigateTo({
  59. url: `/pages/teamDetails/detail`,
  60. })
  61. },
  62. //已上传图片
  63. Uploaded: function () {
  64. wx.navigateTo({
  65. url: `/pages/photo/index`,
  66. })
  67. },
  68. //修改密码
  69. change: function () {
  70. wx.navigateTo({
  71. url: `/pages/password/index`,
  72. })
  73. },
  74. //审核队员
  75. examine: function () {
  76. wx.navigateTo({
  77. url: `/pages/auditTeam/index`,
  78. })
  79. },
  80. //解散申请
  81. apply: function (e) {
  82. let id= e.currentTarget.dataset.id;
  83. wx.navigateTo({
  84. url: `/pages/dissolution/index?id=`+id,
  85. })
  86. },
  87. //解散团队弹窗
  88. clickme: function () {
  89. this.setData({
  90. showModal: true
  91. })
  92. },
  93. preventTouchMove: function () {
  94. },
  95. //关闭弹窗
  96. go: function () {
  97. this.setData({
  98. showModal: false
  99. })
  100. },
  101. /**
  102. * 生命周期函数--监听页面加载
  103. */
  104. onLoad: function (options) {
  105. // 计算高度
  106. this.searchHeight()
  107. // 监听用户是否登录
  108. this.watchLogin();
  109. const that = this;
  110. wx.getStorage({
  111. key: 'token',
  112. success: res => {
  113. //数据请求
  114. wx.request({
  115. url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
  116. method: "get",//请求方法
  117. data: {},//请求参数
  118. header: {},
  119. success: res => {
  120. // console.log(res);
  121. that.setData({ list3: res.data.data })
  122. console.log(res.data.data);
  123. },
  124. error: err => {
  125. console.log(err);
  126. }
  127. })
  128. },
  129. fail: res => {
  130. wx.redirectTo({ url: '/pages/login/index', })
  131. }
  132. })
  133. },
  134. // 监听用户是否登录
  135. watchLogin: function () {
  136. const that = this;
  137. wx.getStorage({
  138. key: 'token',
  139. success: res => {
  140. //数据请求
  141. wx.request({
  142. url: `${app.globalData.publicUrl}/courtAdmin/api/user/${res.data.id}`, //接口地址
  143. method: "get",//请求方法
  144. data: {},//请求参数
  145. header: {},
  146. success: res => {
  147. // console.log(res);
  148. that.setData({ item1: res.data.data })
  149. let icon = res.data.data.icon[0];
  150. if (icon) this.setData({ icon: icon.url })
  151. else this.setData({ icon: '/image/tou.png' })
  152. console.log(res.data.data);
  153. },
  154. error: err => {
  155. console.log(err);
  156. }
  157. })
  158. },
  159. fail: res => {
  160. wx.redirectTo({ url: '/pages/login/index', })
  161. }
  162. })
  163. },
  164. tui() {
  165. wx.showModal({
  166. title: '',
  167. content: '是否确认退出登录',
  168. success(res) {
  169. if (res.confirm) {
  170. wx.removeStorage({
  171. key: 'token',
  172. success (res) {
  173. return wx.redirectTo({ url: '/pages/index/index', })
  174. }
  175. })
  176. } else if (res.cancel) {
  177. console.log('用户点击取消')
  178. }
  179. }
  180. })
  181. },
  182. // 计算高度
  183. searchHeight: function () {
  184. let frameStyle = this.data.frameStyle;
  185. let client = app.globalData.client;
  186. // 减去状态栏
  187. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  188. // 是否减去底部菜单
  189. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  190. if (infoHeight) this.setData({ infoHeight: infoHeight })
  191. },
  192. /**
  193. * 生命周期函数--监听页面初次渲染完成
  194. */
  195. onReady: function () {
  196. },
  197. /**
  198. * 生命周期函数--监听页面显示
  199. */
  200. onShow: function () {
  201. },
  202. /**
  203. * 生命周期函数--监听页面隐藏
  204. */
  205. onHide: function () {
  206. },
  207. /**
  208. * 生命周期函数--监听页面卸载
  209. */
  210. onUnload: function () {
  211. },
  212. /**
  213. * 页面相关事件处理函数--监听用户下拉动作
  214. */
  215. onPullDownRefresh: function () {
  216. },
  217. /**
  218. * 页面上拉触底事件的处理函数
  219. */
  220. onReachBottom: function () {
  221. },
  222. /**
  223. * 用户点击右上角分享
  224. */
  225. onShareAppMessage: function () {
  226. }
  227. })