index.js 5.4 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. //团队详情
  58. ToDetails: function (e) {
  59. let id = e.currentTarget.dataset.id;
  60. console.log(e.currentTarget.dataset.id);
  61. wx.navigateTo({
  62. url: `/pages/teamDetails/detail?id=` + id,
  63. })
  64. },
  65. //已上传图片
  66. Uploaded: function () {
  67. wx.navigateTo({
  68. url: `/pages/photo/index`,
  69. })
  70. },
  71. //修改密码
  72. change: function () {
  73. wx.navigateTo({
  74. url: `/pages/password/index`,
  75. })
  76. },
  77. //审核队员
  78. examine: function () {
  79. wx.navigateTo({
  80. url: `/pages/auditTeam/index`,
  81. })
  82. },
  83. //解散申请
  84. apply: function (e) {
  85. let id = e.currentTarget.dataset.id;
  86. wx.navigateTo({
  87. url: `/pages/dissolution/index?id=` + id,
  88. })
  89. },
  90. //解散团队弹窗
  91. clickme: function () {
  92. this.setData({
  93. showModal: true
  94. })
  95. },
  96. preventTouchMove: function () {
  97. },
  98. //关闭弹窗
  99. go: function () {
  100. this.setData({
  101. showModal: false
  102. })
  103. },
  104. /**
  105. * 生命周期函数--监听页面加载
  106. */
  107. onLoad: function (options) {
  108. // 计算高度
  109. this.searchHeight()
  110. // 监听用户是否登录
  111. this.watchLogin();
  112. },
  113. // 监听用户是否登录
  114. watchLogin: function () {
  115. const that = this;
  116. wx.getStorage({
  117. key: 'token',
  118. success: res => {
  119. //数据请求
  120. wx.request({
  121. url: `${app.globalData.publicUrl}/courtAdmin/api/user/${res.data.id}`, //接口地址
  122. method: "get",//请求方法
  123. data: {},//请求参数
  124. header: {},
  125. success: res => {
  126. // console.log(res);
  127. that.setData({ item1: res.data.data })
  128. let icon = res.data.data.icon[0];
  129. if (icon) this.setData({ icon: icon.url })
  130. else this.setData({ icon: '/image/tou.png' })
  131. console.log(res.data.data);
  132. },
  133. error: err => {
  134. console.log(err);
  135. }
  136. })
  137. },
  138. fail: res => {
  139. wx.redirectTo({ url: '/pages/login/index', })
  140. }
  141. })
  142. wx.getStorage({
  143. key: 'token',
  144. success: res => {
  145. //数据请求
  146. wx.request({
  147. url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
  148. method: "get",//请求方法
  149. data: {},//请求参数
  150. header: {},
  151. success: res => {
  152. // console.log(res);
  153. that.setData({ list3: res.data.data })
  154. console.log(res.data.data);
  155. },
  156. error: err => {
  157. console.log(err);
  158. }
  159. })
  160. },
  161. fail: res => {
  162. wx.redirectTo({ url: '/pages/login/index', })
  163. }
  164. })
  165. },
  166. //退出登录
  167. tui() {
  168. wx.showModal({
  169. title: '',
  170. content: '是否确认退出登录',
  171. success(res) {
  172. if (res.confirm) {
  173. wx.removeStorage({
  174. key: 'token',
  175. success(res) {
  176. return wx.redirectTo({ url: '/pages/index/index', })
  177. }
  178. })
  179. } else if (res.cancel) {
  180. console.log('用户点击取消')
  181. }
  182. }
  183. })
  184. },
  185. // 计算高度
  186. searchHeight: function () {
  187. let frameStyle = this.data.frameStyle;
  188. let client = app.globalData.client;
  189. // 减去状态栏
  190. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  191. // 是否减去底部菜单
  192. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  193. if (infoHeight) this.setData({ infoHeight: infoHeight })
  194. },
  195. /**
  196. * 生命周期函数--监听页面初次渲染完成
  197. */
  198. onReady: function () {
  199. },
  200. /**
  201. * 生命周期函数--监听页面显示
  202. */
  203. onShow: function () {
  204. },
  205. /**
  206. * 生命周期函数--监听页面隐藏
  207. */
  208. onHide: function () {
  209. },
  210. /**
  211. * 生命周期函数--监听页面卸载
  212. */
  213. onUnload: function () {
  214. },
  215. /**
  216. * 页面相关事件处理函数--监听用户下拉动作
  217. */
  218. onPullDownRefresh: function () {
  219. },
  220. /**
  221. * 页面上拉触底事件的处理函数
  222. */
  223. onReachBottom: function () {
  224. },
  225. /**
  226. * 用户点击右上角分享
  227. */
  228. onShareAppMessage: function () {
  229. }
  230. })