forked from harveyqing/BearDiary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wangjin
committed
Oct 4, 2016
0 parents
commit 9340895
Showing
45 changed files
with
1,091 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// app.js | ||
|
||
App({ | ||
|
||
onLaunch: function () { | ||
//调用API从本地缓存中获取数据 | ||
var logs = wx.getStorageSync('logs') || [] | ||
logs.unshift(Date.now()) | ||
wx.setStorageSync('logs', logs) | ||
}, | ||
|
||
getUserInfo:function(cb){ | ||
var that = this; | ||
if(this.globalData.userInfo){ | ||
typeof cb == "function" && cb(this.globalData.userInfo) | ||
}else{ | ||
//调用登录接口 | ||
wx.login({ | ||
success: function () { | ||
wx.getUserInfo({ | ||
success: function (res) { | ||
that.globalData.userInfo = res.userInfo; | ||
typeof cb == "function" && cb(that.globalData.userInfo) | ||
} | ||
}) | ||
} | ||
}); | ||
} | ||
}, | ||
|
||
getDeviceInfo: function(callback) { | ||
var that = this; | ||
|
||
if (this.globalData.deviceInfo) { | ||
typeof callback == "function" && callback(this.globalData.deviceInfo) | ||
} else { | ||
wx.getSystemInfo({ | ||
success: function(res) { | ||
that.globalData.deviceInfo = res; | ||
typeof callback == "function" && callback(that.globalData.deviceInfo) | ||
} | ||
}) | ||
} | ||
}, | ||
|
||
globalData: { | ||
userInfo: null, | ||
deviceInfo: null, | ||
} | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"pages":[ | ||
"pages/index/index", | ||
"pages/mine/mine", | ||
"pages/compose/compose", | ||
"pages/diary/diary", | ||
"pages/new/new" | ||
], | ||
"window":{ | ||
"backgroundTextStyle": "light", | ||
"navigationBarBackgroundColor": "#39b5de", | ||
"navigationBarTitleText": "小熊の日记", | ||
"navigationBarTextStyle": "white", | ||
"backgroundColor": "#eceff4" | ||
}, | ||
"tabBar": { | ||
"color": "#858585", | ||
"selectedColor": "#39b5de", | ||
"backgroundColor": "#ffffff", | ||
"borderStyle": "black", | ||
"list":[ | ||
{ | ||
"pagePath": "pages/index/index", | ||
"iconPath": "images/icons/mark.png", | ||
"selectedIconPath": "images/icons/markHL.png", | ||
"text": "印记" | ||
}, | ||
{ | ||
"pagePath": "pages/compose/compose", | ||
"iconPath": "images/icons/strategy.png", | ||
"selectedIconPath": "images/icons/strategyHL.png", | ||
"text": "攻略" | ||
}, | ||
{ | ||
"pagePath": "pages/mine/mine", | ||
"iconPath": "images/icons/mine.png", | ||
"selectedIconPath": "images/icons/mineHL.png", | ||
"text": "我的" | ||
} | ||
] | ||
}, | ||
"debug": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
app.wxss | ||
全局样式 | ||
**/ | ||
|
||
page { | ||
width: 100%; | ||
padding: 0; | ||
background-color: #eceff4; | ||
font-size: 30rpx; | ||
font-family: -apple-system-font, 'Helvetica Neue', Helvetica, 'Microsoft YaHei', sans-serif; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
var diaries = [ | ||
{ | ||
meta: { // 内容元数据 | ||
cover: "http://m.chanyouji.cn/index-cover/45546-1628868.jpg", | ||
avatar: "http://a.chanyouji.cn/352674/1475220354.jpg", | ||
title: "穿越风花与雪月,觐见梅里", | ||
meta: "2016.09.11/ 12天/ 106图", | ||
}, | ||
lists: [ | ||
{ | ||
type: "TEXT", | ||
content: ' 9月11日,15年的911事件使这天蒙上了特殊的意义。2016年的这一天,怀着激动的心情,开启了高原寻秘之旅,向着那圣洁之地出发。全程自驾近2000公里,雨崩徒步80公里,完成觐见之旅。', | ||
poi: { | ||
longitude: 117.2, | ||
latitude: 37.5, | ||
name: "深圳宝安国际机场", | ||
}, | ||
description: "", | ||
id: 1, | ||
commentNum: 0, | ||
likeNum: 0, | ||
}, | ||
{ | ||
type: "IMAGE", | ||
content: 'http://p.chanyouji.cn/1473699595/1740E45C-D5AF-497E-A351-06E5BA22B1A3.jpg', | ||
poi: { | ||
longitude: 117.2, | ||
latitude: 37.5, | ||
name: "深圳宝安国际机场", | ||
}, | ||
description: "深圳宝安国际机场", | ||
id: 2, | ||
commentNum: 1, | ||
likeNum: 5, | ||
}, | ||
{ | ||
type: "IMAGE", | ||
content: 'http://p.chanyouji.cn/1473699603/7C3B253F-0A31-4754-B042-E04115F2C931.jpg', | ||
poi: { | ||
longitude: 117.2, | ||
latitude: 37.5, | ||
name: "丽江三义机场", | ||
}, | ||
description: "丽江三义机场", | ||
id: 2, | ||
commentNum: 1, | ||
likeNum: 5, | ||
}, | ||
{ | ||
type: "TEXT", | ||
content: ' 玉水寨在白沙溪镇,是纳西族中部地区的东巴圣地,是丽江古城的溯源。\n\nTips:门票50元/人,游玩时间2小时。', | ||
poi: { | ||
longitude: 117.2, | ||
latitude: 37.5, | ||
name: "玉水寨", | ||
}, | ||
description: "", | ||
id: 1, | ||
commentNum: 0, | ||
likeNum: 0, | ||
}, | ||
{ | ||
type: "IMAGE", | ||
content: 'http://p.chanyouji.cn/1473685830/2A48B40F-1F11-498D-ABD2-B0EDCD09F776.jpg', | ||
poi: { | ||
longitude: 117.2, | ||
latitude: 37.5, | ||
name: "玉水寨", | ||
}, | ||
description: "阳光下的玉水寨", | ||
id: 2, | ||
commentNum: 1, | ||
likeNum: 5, | ||
}, | ||
{ | ||
type: "VIDEO", | ||
content: 'http://flv.bn.netease.com/videolib3/1605/22/auDfZ8781/HD/auDfZ8781-mobile.mp4', | ||
poi: { | ||
longitude: 117.2, | ||
latitude: 37.5, | ||
name: "深圳宝安国际机场", | ||
}, | ||
description: "", | ||
id: 2, | ||
commentNum: 10, | ||
likeNum: 200, | ||
}, | ||
] | ||
} | ||
] | ||
|
||
module.exports = { | ||
diaries: diaries, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var data = { | ||
"diaries": [ | ||
{ | ||
"image": "http://m.chanyouji.cn/articles/625/ca9e50f74e273041e3a399bf5528f7b5.jpg?imageView2/1/w/620/h/330/format/jpg", | ||
"avatar": "http://tva3.sinaimg.cn/crop.0.0.540.540.50/6cbb1ee0jw8ej0zou5e71j20f00f0q3b.jpg", | ||
"title": "濑户内海北半圈-历史、艺术与兔子", | ||
"meta": "2016年9月1日 / 6天 / 476图" | ||
}, | ||
{ | ||
"image": "http://m.chanyouji.cn/articles/625/ca9e50f74e273041e3a399bf5528f7b5.jpg?imageView2/1/w/620/h/330/format/jpg", | ||
"avatar": "http://tva3.sinaimg.cn/crop.0.0.540.540.50/6cbb1ee0jw8ej0zou5e71j20f00f0q3b.jpg", | ||
"title": "濑户内海北半圈-历史、艺术与兔子", | ||
"meta": "2016年9月1日 / 6天 / 476图" | ||
}, | ||
{ | ||
"image": "http://m.chanyouji.cn/articles/625/ca9e50f74e273041e3a399bf5528f7b5.jpg?imageView2/1/w/620/h/330/format/jpg", | ||
"avatar": "http://tva3.sinaimg.cn/crop.0.0.540.540.50/6cbb1ee0jw8ej0zou5e71j20f00f0q3b.jpg", | ||
"title": "濑户内海北半圈-历史、艺术与兔子", | ||
"meta": "2016年9月1日 / 6天 / 476图" | ||
}, | ||
{ | ||
"image": "http://m.chanyouji.cn/articles/625/ca9e50f74e273041e3a399bf5528f7b5.jpg?imageView2/1/w/620/h/330/format/jpg", | ||
"avatar": "http://tva3.sinaimg.cn/crop.0.0.540.540.50/6cbb1ee0jw8ej0zou5e71j20f00f0q3b.jpg", | ||
"title": "濑户内海北半圈-历史、艺术与兔子", | ||
"meta": "2016年9月1日 / 6天 / 476图" | ||
}, | ||
{ | ||
"image": "http://m.chanyouji.cn/articles/625/ca9e50f74e273041e3a399bf5528f7b5.jpg?imageView2/1/w/620/h/330/format/jpg", | ||
"avatar": "http://tva3.sinaimg.cn/crop.0.0.540.540.50/6cbb1ee0jw8ej0zou5e71j20f00f0q3b.jpg", | ||
"title": "濑户内海北半圈-历史、艺术与兔子", | ||
"meta": "2016年9月1日 / 6天 / 476图" | ||
}, | ||
{ | ||
"image": "http://m.chanyouji.cn/articles/625/ca9e50f74e273041e3a399bf5528f7b5.jpg?imageView2/1/w/620/h/330/format/jpg", | ||
"avatar": "http://tva3.sinaimg.cn/crop.0.0.540.540.50/6cbb1ee0jw8ej0zou5e71j20f00f0q3b.jpg", | ||
"title": "濑户内海北半圈-历史、艺术与兔子", | ||
"meta": "2016年9月1日 / 6天 / 476图" | ||
} | ||
], | ||
|
||
dairys: [ | ||
{ | ||
"cover": "http://m.chanyouji.cn/articles/625/ca9e50f74e273041e3a399bf5528f7b5.jpg?imageView2/1/w/620/h/330/format/jpg", | ||
} | ||
] | ||
} | ||
|
||
module.exports = { | ||
"data": data | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// compose.js | ||
// TODO 并不是所有非中文字符宽度都为中文字符宽度一半,需特殊处理 | ||
|
||
const CHAR_WIDTH = 14; // in rpx, 一个字符的宽度 | ||
const RESOLUTION = 750; // 微信规定屏幕宽度为750rpx | ||
const MARGIN = 10; // 写字面板左右margin | ||
const ROW_CHARS = Math.floor((RESOLUTION - 2 * MARGIN) / CHAR_WIDTH); | ||
|
||
// 计算字符串长度(英文占一个字符,中文汉字占2个字符) | ||
function strlen(str) { | ||
var len = 0; | ||
for (var i = 0; i < str.length; i++) { | ||
var c = str.charCodeAt(i); | ||
if ((c >= 0x0001 && c <= 0x007e) || (c >= 0xff60 && c <= 0xff9f)) { | ||
len++; | ||
} else { | ||
len += 2; | ||
} | ||
} | ||
return len; | ||
} | ||
|
||
Page({ | ||
|
||
// 数据 | ||
data: { | ||
row: 0, | ||
column: 0, | ||
text: '', // 全部文本 | ||
curText: '', // 当前行文本 | ||
curLen: 0, // 当前行文本字符长度 | ||
lines: [''], // 所有行 | ||
isNew: false, // 是否需要添加新行 | ||
}, | ||
|
||
// 初始化当前输入框 | ||
initInput: function() { | ||
}, | ||
|
||
// 事件 | ||
userInput: function(e) { | ||
var context = e.detail; | ||
var lines = this.data.lines; | ||
var row = this.data.row; | ||
|
||
if (context.value.length != context.cursor) { | ||
console.log('用户正在输入中!'); | ||
} else { | ||
var len = strlen(context.value); | ||
console.log('长度' + len.toString()) | ||
if (len == ROW_CHARS) { // 需换行 | ||
console.log('当前行已满,需换行!' + row.toString()); | ||
lines[lines.length - 1] = context.value; | ||
lines.push(''); | ||
|
||
row += 1; | ||
console.log('*****' + row.toString()); | ||
|
||
this.setData({ | ||
lines: lines, | ||
row: row, | ||
}); | ||
} | ||
} | ||
console.log(e); | ||
}, | ||
userInputChange: function(e) { | ||
console.log(e); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!--compose.wxml--> | ||
|
||
<view class="container"> | ||
<input type="text" wx:for="{{lines}}" wx:for-index="idx" id="input-{{idx}}" class="compose-input" placeholder="" bindinput="userInput" bindchange="userInputChange" value="{{item}}" auto-focus="{{idx == row ? true : false}}" /> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*compose.wxss*/ | ||
|
||
.container { | ||
background-color: #eceff4; | ||
background-image: linear-gradient(#E1E6EA .1em, transparent .1em); | ||
background-size: 100% 48rpx; | ||
min-height:100%; | ||
padding: 0; | ||
box-sizing: border-box; | ||
margin: 0 10rpx; | ||
} | ||
|
||
.compose-input { | ||
height: 48rpx; | ||
min-height: 48rpx; | ||
font-size: 28rpx; | ||
line-height: 28rpx; | ||
font-family: "sans-serif"; | ||
background: none; | ||
margin: 0px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// dairy.js | ||
|
||
var app = getApp(); | ||
|
||
var diaries = require("../../demo/diaries.js"); | ||
|
||
Page({ | ||
data: { | ||
dairy: diaries.diaries[0], | ||
}, | ||
|
||
onLoad: function(params) { | ||
console.log(params); | ||
} | ||
}) |
Oops, something went wrong.