Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第3次作业 #91

Merged
merged 7 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions 1517060328/comp/scroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// pages/comp/scroll.js
var base64 = require("../example/images/base64");

Page({

/**
* 页面的初始数据
*/
data: {
isEnd: false,
messages: [{
name: "张三",
last: "您好!"
}, {
name: "李四",
last: "您好!"
}, {
name: "李四",
last: "您好!"
}, {
name: "李四",
last: "您好!"
}, {
name: "李四",
last: "您好!"
}, {
name: "李四",
last: "您好!"
}, {
name: "李四",
last: "您好!"
}]
},

/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
icon20: base64.icon20,
icon60: base64.icon60
});
},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
* 生命周期函数--监听页面显示
*/
onShow: function () {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

},

onEnd: function () {
console.log("onEnd")
var that = this;
var data = that.data;
that.setData({
isEnd: true /*,
messages: data.messages.concat([{
name: "Tom",
last: "Hello!"
}, {
name: "john",
last: "yes."
}]) */
});

}
})
1 change: 1 addition & 0 deletions 1517060328/comp/scroll.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
27 changes: 27 additions & 0 deletions 1517060328/comp/scroll.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--pages/comp/scroll.wxml-->
<scroll-view class="page" bindtouchend='onEnd'>
<view class="page__hd">
<view class="page__title">Panel</view>
<view class="page__desc">面板</view>
</view>
<view class="page__bd">
<view class="weui-panel weui-panel_access">
<view class="weui-panel__hd"></view>
<view class="weui-panel__bd">
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active" wx:for="{{messages}}">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="{{icon60}}" />
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">{{index}} {{item.name}}</view>
<view class="weui-media-box__desc">{{item.last}}</view>
</view>
</navigator>
</view>
</view>
<view class='weui-loadmore' wx:if="{{isEnd}}">
<view class='weui-loading'></view>
<view class='weui-loadmore__tips'>正在加载……</view>
</view>
</view>
</scroll-view>
1 change: 1 addition & 0 deletions 1517060328/comp/scroll.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* pages/comp/scroll.wxss */
113 changes: 113 additions & 0 deletions 1517060328/form/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// pages/form/form.js
Page({

/**
* 页面的初始数据
*/
data: {
text: "Hello"
},

/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
/*
wx.getStorage({
key: 'formData',
success: function (res) {
console.log(res.data)
that.setData({
text: res.data.text,
paragh: res.data.paragh
});
}
})
*/
wx.request({
url: 'https://api.infoaas.com/data/hzc.json', //仅为示例,并非真实的接口地址
data: {},
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
console.log(res.data)
that.setData({
text: res.data.name,
paragh: "任课老师是:" + res.data.teacher + " 2017"
});
}
})
},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
* 生命周期函数--监听页面显示
*/
onShow: function () {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

},

doSubmit: function (e) {
console.dir(e)
var that = this;
var text = e.detail.value.text;
var paragh = e.detail.value.paragh;

wx.setStorage({
key: "formData",
data: {
text: text,
paragh: paragh
}
})

wx.showToast({
title: '成功',
icon: 'success',
duration: 2000
})
}
})
1 change: 1 addition & 0 deletions 1517060328/form/form.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
35 changes: 35 additions & 0 deletions 1517060328/form/form.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--pages/form/form.wxml-->
<view class="page" xmlns:wx="http://www.w3.org/1999/xhtml">
<view class="page__hd">
<view class="page__title">表单示例</view>
<view class="page__desc">输入文字并提交</view>
</view>
<form bindsubmit="doSubmit">
<view class="page__bd">
<view class="weui-toptips weui-toptips_warn" wx:if="{{paragh}}">{{text + ", " + paragh}}</view>

<view class="weui-cells__title">文本框</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_input">
<view class="weui-cell__bd">
<input class="weui-input" placeholder="请输入文本" name="text" value="{{text}}"/>
</view>
</view>
</view>

<view class="weui-cells__title">文本域</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell">
<view class="weui-cell__bd">
<textarea name="paragh" class="weui-textarea" placeholder="请输入文本" style="height: 3.3em" value="{{paragh}}"/>
<view class="weui-textarea-counter">0/200</view>
</view>
</view>
</view>

<view class="weui-btn-area">
<button class="weui-btn" type="primary" formType="submit">确定</button>
</view>
</view>
</form>
</view>
1 change: 1 addition & 0 deletions 1517060328/form/form.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* pages/form/form.wxss */
30 changes: 30 additions & 0 deletions 1517060328/wen/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//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)
}
})
}
})
}
},
globalData:{
userInfo:null
}
})
44 changes: 44 additions & 0 deletions 1517060328/wen/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"pages": [
"pages/index/index",
"pages/comp/scroll",
"pages/logs/logs",
"pages/comp/view",
"pages/example/navbar/navbar",
"pages/example/grid/grid",
"pages/example/list/list",
"pages/example/article/article",
"pages/form/form"

],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#EEEE00",
"navigationBarTitleText": "第一个小程序",
"navigationBarTextStyle": "white"
},
"tabBar": {
"color":"#ffffff",
"backgroundColor":"yellow",
"list": [
{
"pagePath": "pages/index/index",
"iconPath": "pages/example/images/67.png",
"selectedIconPath": "pages/example/images/17.png",
"text": "首页"
},
{
"pagePath": "pages/comp/scroll",
"iconPath": "pages/example/images/80.png",
"selectedIconPath": "pages/example/images/432.png",
"text": "发现"
},
{
"pagePath": "pages/form/form",
"iconPath": "pages/example/images/10.png",
"selectedIconPath": "pages/example/images/101.png",
"text": "关于"
}
]
}
}
11 changes: 11 additions & 0 deletions 1517060328/wen/app.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**app.wxss**/
@import 'style/weui.wxss';
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
Loading