fighting_sort.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. let qcloud = require('../../vendor/wafer2-client-sdk/index')
  2. let config = require('../../config')
  3. let util = require('../../utils/util.js')
  4. let app = getApp()
  5. Page({
  6. data: {
  7. question_sort: [],
  8. },
  9. onLoad (options) {
  10. this.getFightingSort()
  11. },
  12. onShow(){
  13. this.closeTunnel()//当信道连接或者重连了时,关闭已连接的信道
  14. },
  15. getFightingSort() {
  16. //util.showBusy('正在请求');
  17. qcloud.request({
  18. login: false,
  19. url: `${app.appData.baseUrl}question_sort`,
  20. success: (res) => {
  21. // util.showSuccess('请求成功完成');
  22. let data0 = res.data.data;
  23. this.setData({
  24. question_sort: data0
  25. })
  26. },
  27. fail(error) {
  28. util.showModel('请求失败', error);
  29. console.log('request fail', error);
  30. },
  31. });
  32. },
  33. gotoFightingMatch(e) {
  34. console.log(e);
  35. wx.redirectTo({
  36. url: `../fighting_match/fighting_match?sortId=${e.target.dataset.sortid} `
  37. })
  38. },
  39. closeTunnel(){
  40. //当信道连接或者重连了时,关闭已连接的信道
  41. if (app.appData.tunnelStatus === 'connect' || app.appData.tunnelStatus === 'reconnect' ){
  42. app.tunnel.close();
  43. }
  44. }
  45. })