WebviewCtrl.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import SubHallManger from '../view/SubHallManger'
  2. cc.Class({
  3. extends: SubHallManger,
  4. properties: {
  5. gamesNode:cc.Node,
  6. webview: cc.WebView,
  7. },
  8. onLoad(){
  9. // cc.vv.userMgr.agentLogin(this.gameid,function (ret) {
  10. // this.reqSuccess(ret)
  11. // }.bind(this))
  12. },
  13. onWebFinishLoad: function (sender, event) {
  14. var loadStatus = "";
  15. if (event === cc.WebView.EventType.LOADED) {
  16. loadStatus = " is loaded!";
  17. } else if (event === cc.WebView.EventType.LOADING) {
  18. loadStatus = " is loading!";
  19. } else if (event === cc.WebView.EventType.ERROR) {
  20. loadStatus = ' load error!';
  21. }
  22. console.log(loadStatus)
  23. },
  24. // setView(gameid){
  25. // this.gameid = gameid
  26. // },
  27. initScene()
  28. {
  29. cc.vv.userMgr.agentLogin(this.gameid,function (ret) {
  30. this.reqSuccess(ret)
  31. }.bind(this))
  32. },
  33. reqSuccess(ret){
  34. if(ret.status !== 1){
  35. this.visitURL('http://sports.meme100.com/m/#/')
  36. }else{
  37. this.visitURL(ret.data.url)
  38. }
  39. },
  40. visitURL: function (url) {
  41. this.webview.url = url;
  42. }
  43. });