-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1117 from linkzw/master
#7 实验7 之前pull request的文件有误
- Loading branch information
Showing
54 changed files
with
1,777 additions
and
268 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,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 | ||
} | ||
}) |
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,32 @@ | ||
{ | ||
"pages": [ | ||
"pages/index/index", | ||
"pages/edit/edit", | ||
"pages/logs/logs", | ||
"pages/main/main", | ||
"pages/list", | ||
"pages/list/list" | ||
], | ||
"window": { | ||
"backgroundTextStyle": "light", | ||
"navigationBarBackgroundColor": "#fff", | ||
"navigationBarTitleText": "记事本", | ||
"navigationBarTextStyle": "black" | ||
}, | ||
"tabBar": { | ||
"list": [ | ||
{ | ||
"pagePath": "pages/index/index", | ||
"selectedIconPath": "pages/img/main2.png", | ||
"iconPath": "pages/img/main1.png", | ||
"text": "主页" | ||
}, | ||
{ | ||
"selectedIconPath": "pages/img/per2.png", | ||
"iconPath": "pages/img/per1.png", | ||
"pagePath": "pages/logs/logs", | ||
"text": "个人" | ||
} | ||
] | ||
} | ||
} |
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,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; | ||
} |
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
File renamed without changes.
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,18 @@ | ||
<!--pages/edit/edit.wxml--> | ||
<view class="page"> | ||
<view style='margin-bottom: 3px;'> | ||
<view class="top"> | ||
<button style='border: 0' size="mini" ></button> | ||
<text style='align-items: center;'>编辑备忘录</text> | ||
<button style='border: 0' size="mini" type="primary" plain="true" class="submit" bindtap="submit">保存</button> | ||
</view> | ||
</view> | ||
<view class="page-t"> | ||
<textarea class="content" placeholder="请输入文字,不能为空" bindinput="change" value="{{content}}" maxlength="-1"></textarea> | ||
</view> | ||
<modal hidden="{{hiddenmodalput}}" title="请输入记录名称" confirm-text="确定" cancel-text="取消" bindcancel="cancel" bindconfirm="confirm"> | ||
<input type='text' placeholder="请输入内容" value='{{annal_name}}' bindinput ="annal_NameInput" auto-focus/> | ||
</modal> | ||
|
||
|
||
</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
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,88 @@ | ||
//index.js | ||
//获取应用实例 | ||
var util = require('../../utils/util'); | ||
Page({ | ||
data: { | ||
lists:[] | ||
}, | ||
/** | ||
* 生命周期函数--监听页面加载 | ||
*/ | ||
onLoad: function (options) { | ||
initData(this); | ||
}, | ||
|
||
/** | ||
* 生命周期函数--监听页面显示 | ||
*/ | ||
onShow: function () { | ||
initData(this); | ||
}, | ||
|
||
bindTouchStart: function (e) { | ||
this.startTime = e.timeStamp; | ||
}, | ||
bindTouchEnd: function (e) { | ||
this.endTime = e.timeStamp; | ||
}, | ||
|
||
edit(e) { | ||
if (this.endTime - this.startTime < 350) { | ||
var id = e.currentTarget.dataset.id; | ||
// 跳转 navigateTo | ||
wx.navigateTo({ | ||
url: '../edit/edit?id=' + id | ||
}) | ||
} | ||
}, | ||
add:function() { | ||
wx.navigateTo({ | ||
url: '../edit/edit' | ||
}); | ||
}, | ||
delete:function(e){ | ||
var id = e.currentTarget.dataset.id; | ||
var arr = wx.getStorageSync('txt'); | ||
var arrs; | ||
var that = this; | ||
var f = 1; | ||
wx.showModal({ | ||
content: '确认删除该记录?', | ||
success: function (res) { | ||
console.log(id) | ||
arr.forEach((item, i) => { | ||
if ((item.id) == id && f == 1) { | ||
console.log(i); | ||
arr.splice(i, 1); | ||
wx.setStorageSync('txt', arr); | ||
f = 0; | ||
} | ||
}) | ||
arrs = wx.getStorageSync('txt'); | ||
arrs.forEach((item, i) => { | ||
var t = new Date(Number(item.time)); | ||
item.time = util.dateFormate(t); | ||
}) | ||
that.setData({ | ||
lists: arrs | ||
}) | ||
} | ||
}); | ||
} | ||
|
||
|
||
}) | ||
|
||
function initData(page) { | ||
var arr = wx.getStorageSync('txt'); | ||
if (arr.length) { | ||
arr.forEach((item, i) => { | ||
var t = new Date(Number(item.time)); | ||
item.time = util.dateFormate(t); | ||
}) | ||
page.setData({ | ||
lists: arr | ||
}) | ||
} | ||
} | ||
|
File renamed without changes.
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,19 @@ | ||
<!--index.wxml--> | ||
<view class='index-container'> | ||
<view class="weui-search-bar"> | ||
<view class="weui-search-bar__form"> | ||
|
||
<label class="weui-search-bar__label" hidden="{{inputShowed}}" bindtap="toSearch"> | ||
<icon class="weui-icon-search" type="search" size="14"></icon> | ||
<view class="weui-search-bar__text">搜索</view> | ||
</label> | ||
</view> | ||
<view class="weui-search-bar__cancel-btn" bindtap="add">新建记录</view> | ||
</view> | ||
<block wx:for="{{lists}}" wx:key="*this.id"> | ||
<view class="list_recording" bindtouchstart="bindTouchStart" bindtouchend="bindTouchEnd" bindlongtap="delete" bindtap="edit" data-id="{{item.id}}"> | ||
<view class="content">{{item.annal_name}}</view> | ||
<view class="time">创建时间:{{item.time}}</view> | ||
</view> | ||
</block> | ||
</view> |
Oops, something went wrong.