1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <!DOCTYPE html>
- <html lang="en-US">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <title>Hi 运动(教练端)小程序 | 偶游前端</title>
- <meta name="generator" content="VuePress 1.5.0">
-
- <meta name="description" content="">
- <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/9.39b37f48.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/3.34e7d28d.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="stylesheet" href="/docs/assets/css/0.styles.fa04140f.css">
- </head>
- <body>
- <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" aria-current="page" class="active sidebar-link">hi运动教练小程序</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/docs/currentProgram/hiydMini.html#项目地址" class="sidebar-link">项目地址</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/hiydMini.html#技术选型" class="sidebar-link">技术选型</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/hiydMini.html#最终的技术栈" class="sidebar-link">最终的技术栈</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/hiydMini.html#项目架构" class="sidebar-link">项目架构</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/hiydMini.html#开发时发现的问题" class="sidebar-link">开发时发现的问题</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/docs/currentProgram/hiydMini.html#_2020-5-6" class="sidebar-link">2020/5/6</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/hiydMini.html#_20205-14" class="sidebar-link">20205/14</a></li><li class="sidebar-sub-header"><a href="/docs/currentProgram/hiydMini.html#_2020-5-22" class="sidebar-link">2020/5/22</a></li></ul></li></ul></li><li><a href="/docs/currentProgram/hiydShop.html" class="sidebar-link">hi运动商城</a></li><li><a href="/docs/currentProgram/webGame.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/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="hi-运动-教练端-小程序"><a href="#hi-运动-教练端-小程序" class="header-anchor">#</a> Hi 运动(教练端)小程序</h1> <blockquote><p>请编辑过的人员留下你的姓名</p></blockquote> <ul><li>文档编辑人员 杜文华(2020/4/27)</li></ul> <h2 id="项目地址"><a href="#项目地址" class="header-anchor">#</a> 项目地址</h2> <ul><li>svn://svn.webdev.ouj.com/biz/hiyd_miniprogram/wx</li></ul> <h2 id="技术选型"><a href="#技术选型" class="header-anchor">#</a> 技术选型</h2> <blockquote><p>目标:单纯的微信小程序,没有任何跨端的需求</p></blockquote> <ol><li>针对当时有挺多可选择的方案,(1)原生,(2)框架</li> <li>框架来说,就是更多的用于跨端的,所以感觉没多大必要。但是原生也会有原生的问题</li></ol> <p>原生的问题:</p> <ol><li>比如 npm 的管理就比较棘手,官方的 npm 引入需要构建然后需要外部相对路径的引入,这样的灵活性不太高</li> <li>对于 sass,TypeScript 等预编译的操作无法实现</li> <li>不支持 ES7 以上的高级语法,如 async await 等特性</li> <li>不管是体验版还是开发版只能存在一种环境,一旦发布预览测试环境切换繁琐</li> <li>缺少集中式的 API 地址和 ENV 环境变量管理</li></ol> <p>最终由于技术人员大家的技术都倾向于原生比较容易上手,框架需要再熟悉可能有碍于开发效率等,选择了原生</p> <h2 id="最终的技术栈"><a href="#最终的技术栈" class="header-anchor">#</a> 最终的技术栈</h2> <blockquote><p>Gulp4.x + TypeScript(后来觉得 wx 的类型可能有点坑就放弃了) + Babel + Scss + 原生小程序内置 Api + jest(单元测试,node 版本要尽量高不然会报错) + Mobx</p></blockquote> <p>5/22注后来发现TypeScript也是可以做的,wx的类型直接引入微信的库就可以了,我们要做的只是用TypeScript转换成JS就可以了</p> <h2 id="项目架构"><a href="#项目架构" class="header-anchor">#</a> 项目架构</h2> <div class="language-Bash extra-class"><pre class="language-bash"><code>- dist
- - node_modules
- - src
- <span class="token operator">|</span>- <span class="token punctuation">..</span>.
- <span class="token operator">|</span>- __test__ --- jest单元测试
- <span class="token operator">|</span>- assets --- 静态资源文件<span class="token punctuation">(</span>*png,*jpg<span class="token punctuation">)</span>
- <span class="token operator">|</span>- components --- 公共组件<span class="token punctuation">(</span>自定义<span class="token punctuation">)</span>
- <span class="token operator">|</span>- custom-tab-bar --- 自定义tabbar<span class="token punctuation">(</span>一定要放在最外层<span class="token punctuation">)</span>
- <span class="token operator">|</span>- libs --- 用上了ES7的async的地方都得用这个库 <span class="token punctuation">(</span>在头部得引入不然会报错<span class="token punctuation">)</span>
- <span class="token operator">|</span>- miniprogram_npm --- 小程序的npm
- <span class="token operator">|</span>- pages --- 页面
- <span class="token operator">|</span>- <span class="token punctuation">..</span>.
- <span class="token operator">|</span>- <span class="token punctuation">..</span>.
- <span class="token operator">|</span>- router --- 封装的路由
- <span class="token operator">|</span>- services --- 业务层
- <span class="token operator">|</span>- lib --- 封装的ajax
- <span class="token operator">|</span>- styles --- 定义的全局scss
- <span class="token operator">|</span>- utils --- 工具类
- <span class="token operator">|</span>- index.d.ts --- 用来提示类型的<span class="token punctuation">(</span>不是用TypeScript但是可以透过工具达到类型提示的效果<span class="token punctuation">)</span>
- <span class="token operator">|</span>- <span class="token punctuation">..</span>.
- - gulpfile.js --- 构建打包的配置文件
- </code></pre></div><h2 id="开发时发现的问题"><a href="#开发时发现的问题" class="header-anchor">#</a> 开发时发现的问题</h2> <h3 id="_2020-5-6"><a href="#_2020-5-6" class="header-anchor">#</a> 2020/5/6</h3> <p>小程序的背景图片不能直接引入本地的,可能是因为线上的缘故吧。要转成 base64 或者是引入线上服务器的地址才可以引入。</p> <p>数据流最后是通过 mobx 进行传递。写了一些例子可能都不太好,没有那种修改了马上更新的操作,放在 globalData 就更加不行</p> <p>使用 async 的地方都得引入 libs 里面的 runtime 库不然会报错(本地可能不报错,但是线上会报错)</p> <h3 id="_20205-14"><a href="#_20205-14" class="header-anchor">#</a> 20205/14</h3> <p>商品管理的拖动还是存在bug,比如无法实时看到拖动的效果,只能在拖动完最后才能看到效果。(最主要还是安卓存在的性能问题,因为每次都会load图片,安卓load图片就会出现性能的问题,IOS不会有这个问题,实现的原理得自己看下里面的)</p> <p>保存海报是通过canvas画出来的,所以要看一下对应的微信提供的Api</p> <p>小程序自带的mobx在App.js无法使用,因为没有办法代理App.js里面的数据。page里面如果在onload,等生命周期使用。得下一轮循环才行(不知道是不是推到微任务里面去了)</p> <h3 id="_2020-5-22"><a href="#_2020-5-22" class="header-anchor">#</a> 2020/5/22</h3> <p>tabPage是自定义,并且是重写了onShow方法,是在Page实例化前调用的,所以在tabPage的onShow里面没有找到当前tabPage的this。</p></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
- ←
- <a href="/docs/currentProgram/tank.html" class="prev">
- 坦克专题
- </a></span> <span class="next"><a href="/docs/currentProgram/hiydShop.html">
- hi运动商城
- </a>
- →
- </span></p></div> </main></div><div class="global-ui"></div></div>
- <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/9.39b37f48.js" defer></script>
- </body>
- </html>
|