index.js 6.0 KB

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