项目作者: hehuier

项目描述 :
小程序原生 + wepy框架的使用
高级语言: JavaScript
项目地址: git://github.com/hehuier/Wechat-applet.git
创建时间: 2019-01-18T03:09:19Z
项目社区:https://github.com/hehuier/Wechat-applet

开源协议:

下载


wechat 原生项目搭建

app.is

  1. /**
  2. * Request 模块 请求数据
  3. * @type {Object}
  4. */
  5. const api = require('./utils/request.js')

app.json

pages

All pages must be here.
First is default to view

  1. { "pages": ["pages/index/index", "pages/logs/logs"] }

window

用于设置小程序的状态栏、导航条、标题、窗口背景色。

  1. {
  2. "window": {
  3. "navigationBarBackgroundColor": "#ffffff",
  4. "navigationBarTextStyle": "black",
  5. "navigationBarTitleText": "微信接口功能演示",
  6. "backgroundColor": "#eeeeee",
  7. "backgroundTextStyle": "light"
  8. }
  9. }

tabBar

如果小程序是一个多 tab 应用(客户端窗口的底部或顶部有 tab 栏可以切换页面),可以通过 tabBar 配置项指定 tab 栏的表现,以及 tab 切换时显示的对应页面。

  1. {
  2. "tabBar": {
  3. "color": "#999999",
  4. "selectedColor": "#35495e",
  5. "borderStyle": "white",
  6. "backgroundColor": "#f5f5f5",
  7. "list": [
  8. {
  9. "text": "榜单",
  10. "pagePath": "pages/board/board",
  11. "iconPath": "images/board.png",
  12. "selectedIconPath": "images/board-actived.png"
  13. },
  14. {
  15. "text": "搜索",
  16. "pagePath": "pages/search/search",
  17. "iconPath": "images/search.png",
  18. "selectedIconPath": "images/search-actived.png"
  19. },
  20. {
  21. "text": "我的",
  22. "pagePath": "pages/profile/profile",
  23. "iconPath": "images/profile.png",
  24. "selectedIconPath": "images/profile-actived.png"
  25. }
  26. ]
  27. }
  28. }

networkTimeout

网络超时时间

  1. "networkTimeout": {
  2. "request": 10000,
  3. "downloadFile": 10000
  4. }

utils 封装的公共模块

wepy

小程序 小结

关于登录

wx.login
wx.checkSession 校验当前用户session_key是否有效
wx.authorize向用户发起授权申请
wx.getUserInfo 获取用户基本信息

生成海报

利用canvas绘制海报 —-> canvasToTempFilePath 导出图片 —> wx.saveImageToPhotosAlbum({})将图片保存在本地相册中
``` javascipt
class CanvasKit {
constructor() {
}
drawImg(option = {}) {

return this
}
drawRect(option = {}) {
return this
}
drawText(option = {}) {

return this
}
static exportImg(option = {}) {

}
}

let drawer = new CanvasKit(‘canvasId’).drawImg(styleObj1).drawText(styleObj2)
drawer.exportImg()

  1. **小程序中无法绘制网络图片到canvas上,需要通过downLoadFile 先下载图片到本地临时文件才可以绘制**
  2. ##[ANIMATE](https://developers.weixin.qq.com/miniprogram/dev/api/wx.createAnimation.html)
  3. ``` javascipt
  4. onShow: function(){
  5. var animaiton = wx.createAnimation({
  6. duration: 1000,
  7. timingFunction: 'ease',
  8. })
  9. this.animation = animation
  10. animation.scale(2, 2).rotate(45).step()
  11. this.setData({
  12. animationData:animation.export()
  13. })
  14. }
  15. //////////////////////////////////////////
  16. onReady: function () {
  17. this.animation = wx.createAnimation()
  18. },
  19. allInQueue: function () {
  20. this.animation.rotate(Math.random() * 720 - 360).step()
  21. .scale(Math.random() * 2).step()
  22. .translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step()
  23. .skew(Math.random() * 90, Math.random() * 90).step()
  24. this.setImmediate(callback, arg1, arg2, arg3);
  25. },
  26. reset: function () {
  27. this.animation.rotate(0, 0)
  28. .scale(1)
  29. .translate(0, 0)
  30. .skew(0, 0)
  31. .step({duration: 0})
  32. this.setData({animation: this.animation.export()})
  33. }

.step(): 一组动画完成。 可以在一组动画中调用任意多个动画方法,一组动画中的所有动画会同时开始,一组动画完成后才会会进行下一组动画
.export(): 导出动画队列。export 方法每次调用后会清掉之前的动画操作