entry.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //index.js
  2. var qcloud = require('../../vendor/wafer2-client-sdk/index')
  3. var config = require('../../config')
  4. var util = require('../../utils/util.js')
  5. const app = getApp();
  6. Page({
  7. data: {
  8. score: 0,
  9. condition:app.globalData.condition
  10. },
  11. onLoad(opt) {
  12. console.log(opt)
  13. app.appData.fromClickId = opt.currentClickId
  14. app.upDateUser_networkFromClickId = require('../../utils/upDateUser_networkFromClickId.js').upDateUser_networkFromClickId
  15. wx.showShareMenu({
  16. withShareTicket: true
  17. })
  18. app.pageGetUserInfo(this, this.getScore)
  19. },
  20. onShow() {
  21. if (this.data.openId) {
  22. this.getScore(this.data.openId)
  23. }
  24. this.closeTunnel()//当信道连接或者重连了时,关闭已连接的信道
  25. },
  26. // 从授权页面跳过来重新赋值userInfo 要不会没有头像信息
  27. fnInit(e){
  28. var userInfo = e.detail.userInfo
  29. this.setData({
  30. userInfo
  31. })
  32. },
  33. onShareAppMessage(res) {
  34. const that = this;
  35. return {
  36. title: '谁才是头脑王者?比比看吧!',
  37. path: `/pages/entry/entry?currentClickId=${app.appData.currentClickId}`,
  38. success: (res) => {
  39. //转发时向用户关系表中更新一条转发记录(个人为person,群为GId)。
  40. require('../../utils/upDateShareInfoToUser_network.js').upDateShareInfoToUser_network(app, that, res)
  41. }
  42. }
  43. },
  44. getScore(openId) {
  45. if (openId) {
  46. qcloud.request({
  47. login: false,
  48. url: `${app.appData.baseUrl}get_score`,
  49. data: {
  50. openId
  51. },
  52. success: (res) => {
  53. let score = res.data.data;
  54. this.setData({
  55. score
  56. })
  57. },
  58. fail(error) {
  59. util.showModel('请求失败', error);
  60. },
  61. });
  62. }
  63. },
  64. gotoFighting() {
  65. wx.navigateTo({
  66. url: '../fighting_sort/fighting_sort'
  67. })
  68. },
  69. gotoFriends() {
  70. wx.navigateTo({
  71. url: '../friends_sort/friends_sort'
  72. })
  73. },
  74. gotoCustomRoom() {
  75. wx.navigateTo({
  76. url: '../custom_room/custom_room'
  77. })
  78. },
  79. gotoRank() {
  80. wx.navigateTo({
  81. url: '../rank/rank'
  82. })
  83. },
  84. get_qr_address() {
  85. qcloud.request({
  86. login: false,
  87. url: `${app.appData.baseUrl}qr_address`,
  88. success: (res) => { },
  89. });
  90. },
  91. closeTunnel() {
  92. //当信道连接或者重连了时,关闭已连接的信道
  93. if (app.appData.tunnelStatus == 'connect' || app.appData.tunnelStatus == 'reconnect') {
  94. app.tunnel.close();
  95. }
  96. }
  97. })