Skip to content

Commit

Permalink
1.添加组件支持
Browse files Browse the repository at this point in the history
2.添加demo
  • Loading branch information
duwen committed Mar 9, 2018
1 parent 3d1f84b commit afe3f7f
Show file tree
Hide file tree
Showing 33 changed files with 1,828 additions and 266 deletions.
253 changes: 223 additions & 30 deletions .idea/workspace.xml

Large diffs are not rendered by default.

120 changes: 0 additions & 120 deletions bind.js

This file was deleted.

73 changes: 0 additions & 73 deletions index.js

This file was deleted.

39 changes: 39 additions & 0 deletions quickstart-grace-demo/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)

// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo

// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null
}
})
12 changes: 12 additions & 0 deletions quickstart-grace-demo/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"pages":[
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
}
}
10 changes: 10 additions & 0 deletions quickstart-grace-demo/app.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
22 changes: 22 additions & 0 deletions quickstart-grace-demo/grace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import grace from "../grace/index.js"
grace.http.config.baseURL = 'http://www.dtworkroom.com/doris/1/2.0.0/'
grace.http.config.timeout = 5000;
grace.http.interceptors.request.use((config, promise) => {
console.log(config.body);
});
var page = grace.page;
grace.page = function (ob) {
grace.mixin(ob, {
onLoad() {
//页面调用onShow时打印出当前页面id
console.log("onLoad, pageID:" + this.$id)
},
onShow() {
//页面调用onShow时打印出当前页面id
console.log("onShow, pageID:" + this.$id)
}
})
//创建页面
page.call(grace, ob)
}
export default grace;
1 change: 0 additions & 1 deletion bind-es6.js → quickstart-grace-demo/grace/bind-es6.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//由于微信小程序目前不支持ES6 Proxy, 故此文件目前没有使用,只做研究学习之用
export default function (context) {
var cache = false;
function proxy(ob) {
Expand Down
Loading

0 comments on commit afe3f7f

Please sign in to comment.