webGame.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <!DOCTYPE html>
  2. <html lang="en-US">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <title>多玩游戏大厅(珠海页游) | 偶游前端</title>
  7. <meta name="generator" content="VuePress 1.5.0">
  8. <meta name="description" content="">
  9. <link rel="preload" href="/docs/assets/css/0.styles.fa04140f.css" as="style"><link rel="preload" href="/docs/assets/js/app.6eb096df.js" as="script"><link rel="preload" href="/docs/assets/js/2.eb3dc6dc.js" as="script"><link rel="preload" href="/docs/assets/js/3.34e7d28d.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.121c4396.js"><link rel="prefetch" href="/docs/assets/js/11.4152d57d.js"><link rel="prefetch" href="/docs/assets/js/12.6f3f98e4.js"><link rel="prefetch" href="/docs/assets/js/13.121cf2d2.js"><link rel="prefetch" href="/docs/assets/js/14.15bdf673.js"><link rel="prefetch" href="/docs/assets/js/15.5a659b8b.js"><link rel="prefetch" href="/docs/assets/js/16.6c83c4bd.js"><link rel="prefetch" href="/docs/assets/js/17.a200da04.js"><link rel="prefetch" href="/docs/assets/js/18.bac57b7c.js"><link rel="prefetch" href="/docs/assets/js/19.6246c10b.js"><link rel="prefetch" href="/docs/assets/js/4.c124f7a5.js"><link rel="prefetch" href="/docs/assets/js/5.36672b5d.js"><link rel="prefetch" href="/docs/assets/js/6.2072c2b2.js"><link rel="prefetch" href="/docs/assets/js/7.c034f81f.js"><link rel="prefetch" href="/docs/assets/js/8.8ed5f3ae.js"><link rel="prefetch" href="/docs/assets/js/9.39b37f48.js">
  10. <link rel="stylesheet" href="/docs/assets/css/0.styles.fa04140f.css">
  11. </head>
  12. <body>
  13. <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">偶游前端</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <!----></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><!----> <ul class="sidebar-links"><li><a href="/docs/" aria-current="page" class="sidebar-link">偶游前端(原多玩前端)</a></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>项目</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/currentProgram/tank.html" class="sidebar-link">坦克专题</a></li><li><a href="/docs/currentProgram/hiydMini.html" class="sidebar-link">hi运动教练小程序</a></li><li><a href="/docs/currentProgram/hiydShop.html" class="sidebar-link">hi运动商城</a></li><li><a href="/docs/currentProgram/webGame.html" aria-current="page" class="active sidebar-link">多玩游戏大厅</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#开发人员" class="sidebar-link">开发人员</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#项目地址" class="sidebar-link">项目地址</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#技术栈" class="sidebar-link">技术栈</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#项目域名" class="sidebar-link">项目域名</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#项目结构" class="sidebar-link">项目结构</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#sdk" class="sidebar-link">sdk</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#混入方法" class="sidebar-link">混入方法</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#上报方式" class="sidebar-link">上报方式</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#充值" class="sidebar-link">充值</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#游戏页" class="sidebar-link">游戏页</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#广告" class="sidebar-link">广告</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#备注" class="sidebar-link">备注</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#项目启动" class="sidebar-link">项目启动</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#fis-的语法" class="sidebar-link">fis 的语法</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/webGame.html#暂时遇到的坑-或者你有更好的解决方法,欢迎提-issue" class="sidebar-link">暂时遇到的坑(或者你有更好的解决方法,欢迎提 issue)</a></li></ul></li></ul></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>开发规范</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/standard/html-guide.html" class="sidebar-link">HTML规范</a></li><li><a href="/docs/standard/css-guide.html" class="sidebar-link">css规范</a></li><li><a href="/docs/standard/javascript-guide.html" class="sidebar-link">JavaScript规范</a></li><li><a href="/docs/standard/directory-guide.html" class="sidebar-link">目录规范</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>工具类</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/utils/fetch.html" class="sidebar-link">Fetch</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>博客</span> <!----></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="多玩游戏大厅(珠海页游)"><a href="#多玩游戏大厅(珠海页游)" class="header-anchor">#</a> 多玩游戏大厅(珠海页游)</h1> <blockquote><p>多玩游戏大厅是 fis3 构建和打包(Webpack 不支持 IE8),通过 avalon 配合 JQuery 实现视图的逻辑(Vue 和 React 都不支持)。页面跳转是通过多页面实现的(不是一个单页面应用)。</p></blockquote> <h2 id="开发人员"><a href="#开发人员" class="header-anchor">#</a> 开发人员</h2> <ul><li>康志鸿 百醇 唐喜君 杜文华</li></ul> <h2 id="项目地址"><a href="#项目地址" class="header-anchor">#</a> 项目地址</h2> <ul><li>svn://svn.webdev.ouj.com/biz/page_game/trunk/web</li></ul> <h2 id="技术栈"><a href="#技术栈" class="header-anchor">#</a> 技术栈</h2> <ul><li>环境依赖 : node6+ , fis3 ,mod.js</li> <li>开发技术 : JQuery , avalon, sass</li></ul> <h2 id="项目域名"><a href="#项目域名" class="header-anchor">#</a> 项目域名</h2> <table><thead><tr><th>环境</th> <th>域名</th></tr></thead> <tbody><tr><td>正式环境</td> <td><a href="http://wan.ouj.com" target="_blank" rel="noopener noreferrer">http://wan.ouj.com<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></td></tr> <tr><td>测试环境</td> <td><a href="http://test-wan.ouj.com" target="_blank" rel="noopener noreferrer">http://test-wan.ouj.com<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></td></tr> <tr><td>预发环境</td> <td><a href="http://new-wan.ouj.com" target="_blank" rel="noopener noreferrer">http://new-wan.ouj.com<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></td></tr></tbody></table> <h2 id="项目结构"><a href="#项目结构" class="header-anchor">#</a> 项目结构</h2> <div class="language-Text extra-class"><pre class="language-text"><code>|- src
  14. |- api --- 通用的http请求api(封装http请求)
  15. |- modules --- 按模块分类的api
  16. |- assets --- 静态资源文件(图片)
  17. |- components --- 不同模块对应的小组件
  18. |- lib --- 项目引入的第三方库
  19. |- mixins --- 全局混合(按需引入)
  20. |- modules --- 封装的插件(lazhload,md5,qrcode...)
  21. |- page --- 页面代码
  22. |- bt --- bt页游
  23. |- fcm --- 防沉迷
  24. |- hezi --- 目前dnf旧版&amp;新版盒子,lol盒子,坦克世界盒子左侧游戏tab入口(2个尺寸)
  25. |- lolbox --- lol盒子和旧版dnf
  26. |- box --- 坦克世界盒子和新版dnf
  27. |- index --- 首页
  28. |- popup --- 多玩游戏大厅盒子-内嵌webview弹窗页面
  29. |- propCenter --- 道具中心-主要入口为运营推广广告
  30. |- self --- 多玩游戏大厅盒子-左侧个人中心
  31. |- agreement.html --- 多玩游戏充值协议
  32. |- asset.html --- 各页面通用配置-若js没有&lt;!--ignore--&gt;标志会自动编译到下面的
  33. |- index.html --- 首页
  34. |- list.html --- 游戏列表-精品游戏
  35. |- sdk --- 全局对象DW_APP_SDK 用于调用SDK的API
  36. |- style --- 样式表(components,modules,page)
  37. |- tpl --- 模板
  38. |- typeing --- 类型检查
  39. |- eslintrc.js --- eslint配置文件
  40. |- fis-conf.js --- fis配置文件
  41. </code></pre></div><h2 id="sdk"><a href="#sdk" class="header-anchor">#</a> sdk</h2> <p><code>sdk/index</code>文件保存全局方法,分别给游戏大厅,游戏盒子交互的。</p> <h2 id="混入方法"><a href="#混入方法" class="header-anchor">#</a> 混入方法</h2> <p><code>mixins/index</code>文件是全局混入的方法,在 avalon 定义 VM 的时候要通过 underscore 的 extend 方法扩展。</p> <div class="language-JS extra-class"><pre class="language-js"><code><span class="token keyword">import</span> _ <span class="token keyword">from</span> <span class="token string">&quot;underscore&quot;</span>
  42. <span class="token keyword">var</span> vm <span class="token operator">=</span> avalon<span class="token punctuation">.</span><span class="token function">define</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">extend</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  43. <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">mixins(这里加mixins的内容)</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span>
  44. </code></pre></div><p>提供公共方法</p> <div class="language-js extra-class"><pre class="language-js"><code>checkLogin <span class="token operator">--</span><span class="token operator">-</span> 检测页面登录态
  45. onEnterGame <span class="token operator">--</span><span class="token operator">-</span>进入游戏(要登录态)
  46. onEnterGameWithoutLogin <span class="token operator">--</span><span class="token operator">-</span>进入游戏(不检测登录)
  47. onChoiceServer <span class="token operator">--</span><span class="token operator">-</span>选服
  48. </code></pre></div><h2 id="上报方式"><a href="#上报方式" class="header-anchor">#</a> 上报方式</h2> <p>1.多玩通用统计-目前用于自定义页游广告点击</p> <p>2.大厅统计 pv/uv 地方加上 date-gid,data-poskey,data-dwgameclick 标志,对应的方法</p> <p><a href="../image/webgame.png"><img src="/docs/assets/img/webgame.1d6ec041.png" alt="avatar"></a></p> <p>3.loginGame 接口里面第三个参数(userSource)标志用户的来源,做到上报的</p> <div class="language-JS extra-class"><pre class="language-js"><code> <span class="token function">getLoginGame</span> <span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> gid<span class="token punctuation">,</span> sid<span class="token punctuation">,</span> userSource <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  49. <span class="token keyword">return</span> ax<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">'/loginGame.do'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
  50. params<span class="token operator">:</span> <span class="token punctuation">{</span> gid<span class="token punctuation">,</span> sid<span class="token punctuation">,</span> userSource <span class="token punctuation">}</span>
  51. <span class="token punctuation">}</span><span class="token punctuation">)</span>
  52. <span class="token punctuation">}</span>
  53. </code></pre></div><p>4.游戏页</p> <ul><li><strong>任务上报</strong> 判断是否有 channel 参数(道具中心来源),然后获取道具中心的对应任务,匹配则在结束时上报</li> <li><strong>时长上报</strong> 关闭浏览器 tab 页时上报游戏时长,暴露上报方法给大厅盒子检测用户关闭时调用上报</li></ul> <p>5....</p> <h2 id="充值"><a href="#充值" class="header-anchor">#</a> 充值</h2> <p>1.充值页,大厅盒子充值弹框,游戏页充值弹框都为同一个组件</p> <p>2.默认帮用户选择游戏和区服(通过链接的&amp;game_code=DZ&amp;server_code=s4 主动选择)</p> <p>3.初始化方法暴露了一个 initPayPopup 方法,主要用于引入的页面主动调起初始化,避免多余请求</p> <p>4.微信支付是后端返回一个支付链接前端生成二维码,支付宝支付则是后端返回支付宝的页面,前端通过 iframe 引入再用 css 调整显示二维码位置</p> <h2 id="游戏页"><a href="#游戏页" class="header-anchor">#</a> 游戏页</h2> <p>1.iframe 引入游戏页面,游戏链接都是有时效性&amp;登录态的,故从接口拿</p> <p>2.里面含上报,任务上报和时长上报(看上面上报那点)</p> <h2 id="广告"><a href="#广告" class="header-anchor">#</a> 广告</h2> <p>广告部分暂时有两个自定义的广告位置,一个是右上角的,有个是右边侧边栏,对应接口是一个静态的 JSON 文件。修改图片链接或者是其他都在 JSON 文件中直接修改</p> <p>模板位置:</p> <p><img src="/docs/assets/img/cms61.6d86a7fd.png" alt="avatar"></p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">// 多玩游戏大厅/模板管理/广告数据</span>
  54. <span class="token function">jsonp_dwDa</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  55. <span class="token comment">//web顶部导航-图文广告300*76</span>
  56. headerRight<span class="token operator">:</span> <span class="token punctuation">{</span>
  57. title<span class="token operator">:</span> <span class="token string">&quot;xx&quot;</span><span class="token punctuation">,</span>
  58. clientLink<span class="token operator">:</span> <span class="token string">&quot;http://www.duowan.com/&quot;</span><span class="token punctuation">,</span> <span class="token comment">// 客户端打开的链接</span>
  59. webLink<span class="token operator">:</span> <span class="token string">&quot;http://pgame.duowan.com/dwgame.html&quot;</span><span class="token punctuation">,</span> <span class="token comment">// web downLoad的链接</span>
  60. img<span class="token operator">:</span> <span class="token string">&quot;http://img.dwstatic.com/yxdt/adPic/1907topright.png&quot;</span><span class="token punctuation">,</span>
  61. report<span class="token operator">:</span> <span class="token string">&quot;dwgame_nav_youshangjiao&quot;</span> <span class="token comment">//上报id</span>
  62. <span class="token punctuation">}</span><span class="token punctuation">,</span>
  63. <span class="token comment">//主页-右侧广告-宽250</span>
  64. mainRight<span class="token operator">:</span> <span class="token punctuation">{</span>
  65. title<span class="token operator">:</span> <span class="token string">&quot;xx&quot;</span><span class="token punctuation">,</span>
  66. clientLink<span class="token operator">:</span> <span class="token string">&quot;dwgame://yygame&quot;</span><span class="token punctuation">,</span> <span class="token comment">// 客户端打开的链接</span>
  67. webLink<span class="token operator">:</span> <span class="token string">&quot;http://wan.yy.com/&quot;</span><span class="token punctuation">,</span> <span class="token comment">// web 打开的链接</span>
  68. img<span class="token operator">:</span> <span class="token string">&quot;http://img.dwstatic.com/yxdt/adPic/1906right.jpg&quot;</span><span class="token punctuation">,</span>
  69. report<span class="token operator">:</span> <span class="token string">&quot;dwgame_main_youce&quot;</span> <span class="token comment">//上报id</span>
  70. <span class="token punctuation">}</span>
  71. <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  72. </code></pre></div><ul><li>在发布器中,对应项目中的模板中会可以看到对应的广告。增加广告或者是删除广告等。</li></ul> <p><a href="../image/webgame1.png"><img src="/docs/assets/img/webgame1.6820a5c3.png" alt="avatar"></a></p> <h2 id="备注"><a href="#备注" class="header-anchor">#</a> 备注</h2> <h3 id="项目启动"><a href="#项目启动" class="header-anchor">#</a> 项目启动</h3> <ul><li>安装选择的时候直接选 fis-parser-node-sass</li> <li>配置 host,需要多玩域记录登录状态</li></ul> <div class="language-Text extra-class"><pre class="language-text"><code>// hosts文件在C:\Windows\System32\drivers\etc
  73. 127.0.0.1 yournickname.duowan.com
  74. </code></pre></div><h3 id="fis-的语法"><a href="#fis-的语法" class="header-anchor">#</a> fis 的语法</h3> <ul><li><p><code>?__inline</code>可以实现对整个外部文件的引入,eg:html</p></li> <li><p><code>background(url?__sprite)</code>实现对图片进行整合成雪碧图</p></li></ul> <h3 id="暂时遇到的坑-或者你有更好的解决方法,欢迎提-issue"><a href="#暂时遇到的坑-或者你有更好的解决方法,欢迎提-issue" class="header-anchor">#</a> 暂时遇到的坑(或者你有更好的解决方法,欢迎提 issue)</h3> <p>1.游戏是通过 iframe 承载的,元素分为窗口元素和无窗口元素,在 ie 下窗口元素在最高层级的,设置 z-index 都是无效的,假如需要在游戏上面添加覆盖元素,要将覆盖的元素最下方添加一个空的 iframe</p> <p><strong><em>参考</em></strong> web 端游戏页游戏助手</p> <p>2.上报的时候,在点击关闭的时候触发 onbeforeunload 的方法。这个方法在 JQuery 引入的情况下,Chrome,Firefox 浏览器都不能直接使用要套在 JQuery 方法里面才能使用</p> <div class="language-JS extra-class"><pre class="language-js"><code><span class="token function">$</span><span class="token punctuation">(</span>window<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  75. window<span class="token punctuation">.</span><span class="token function-variable function">onunload</span> <span class="token operator">=</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  76. _this<span class="token punctuation">.</span><span class="token function">gameReport</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
  77. <span class="token keyword">return</span> <span class="token string">&quot;Are you sure&quot;</span>
  78. <span class="token punctuation">}</span>
  79. <span class="token punctuation">}</span><span class="token punctuation">)</span>
  80. </code></pre></div><p>3.window.open 打开异步获取的链接或被浏览器 adblock 拦截</p> <ul><li><strong>失败尝试 1</strong> - 异步前先打开一个空窗口,然后在 window 赋值,在普通浏览器可以解决被 adblock 拦截的情况 <strong><em>但是</em></strong> 在盒子赋值打开的链接不是同一个浏览器了,window 的对象已经发生改变,导致用户访问了一个空白页面</li> <li><strong>失败尝试 2</strong> - 加个 a 标签动态赋值,然后 js 模拟点击,尝试打开 <strong><em>结果</em></strong> 依旧被 adblock 拦截</li></ul></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
  81. <a href="/docs/currentProgram/hiydShop.html" class="prev">
  82. hi运动商城
  83. </a></span> <span class="next"><a href="/docs/standard/html-guide.html">
  84. HTML规范
  85. </a>
  86. </span></p></div> </main></div><div class="global-ui"></div></div>
  87. <script src="/docs/assets/js/app.6eb096df.js" defer></script><script src="/docs/assets/js/2.eb3dc6dc.js" defer></script><script src="/docs/assets/js/3.34e7d28d.js" defer></script>
  88. </body>
  89. </html>