WebviewCtrl.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. reqSuccess(ret){
  28. if(ret.status !== 1){
  29. this.visitURL('http://sports.meme100.com/m/#/')
  30. }else{
  31. this.visitURL(ret.data.url)
  32. }
  33. },
  34. visitURL: function (url) {
  35. this.webview.url = url;
  36. }
  37. });