七天开发进度(七)(微信小程序版(二)记账本)
终于把小程序版弄完了,不过这并不能称之为是我的作品,因为我还没有彻底学会小程序,对JavaScript语言还有很多不会的地方,没有掌握,
这次的程序是通过学习网上的多个教程,多个案例结合拼凑模仿者人家的弄出来的,所以接下来希望自己能学好JavaScript语言,真正写出自己的
微信小程序!
ps:但是前面的轮播图和整体布局可是自己设计的哦^_^啦啦啦
这就是我的随心记账本(美中不足的是过于简单,没有加上日期等模块,嘿嘿,随心嘛~)


这是意趣那一夜,这一页很骄傲啊都是自己设计的,不过,就是,有点low

这是记一笔时:



<!--index.wxml-->
<swiper indicator-dots="{{indicatorDots}}"
autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-dots="true">
<block wx:for="{{imgUrls}}">
<swiper-item>
<image src="{{item}}" class="slide-image" width="355" height="150"/>
</swiper-item>
</block>
</swiper>
<view class="container"><!--轮播图--> <form catchsubmit="formSubmit" >
<view class="account-detail">
<input placeholder="账目详情" name="inputdetail" type="text" /><!--placeholder 属性提供可描述输入字段预期值的提示信息(hint)。 该提示会在输入字段为空时显示,并会在字段获得焦点时消失。 注释:placeholder 属性适用于以下的 <input> 类型:text, search, url, telephone, email 以及 password。-->
</view> <view class="account-amount">
<input placeholder="账目数额" name="inputamount" type="number" />
</view> <view class="add-one">
<button formType="submit" type="primary" loading="{{buttonLoading}}"> 记一笔 </button>
</view>
</form> <view class="account-list-text">
<text>账单列表:</text>
</view> <view class="account-list-all-amount">
<text>合计:{{accountTotal}}</text>
</view> <block wx:for="{{accountData}}" >
<view class="account-list">
<view class="account-list-detail">
{{item.detail}}
</view> <view class="account-list-amount">
{{item.amount}}
</view> <view class="account-list-del">
<button size="mini" type="warn" data-index-key="{{index}}" bindtap="deleteRow" >删除</button>
</view> </view>
</block> </view>
swiper{
width: 100%;
height: 400rpx;
}
swiper image{
display: block;
width: 100%;
height: 100%;
}/*轮播图。。。*/
.account-detail{
height: 100rpx;
padding: 0 30rpx;
margin:35rpx 0 0 0rpx;
}
.account-amount{
padding: 0 30rpx;
margin:15rpx 0 0 0rpx;
}
.add-one{
margin-top: 20rpx;
}
.account-list-text{
color:gray;
margin:30rpx 0 0 30rpx;
}
.account-list-all-amount{
color:gray;
align-self: flex-end;
padding-right: 25rpx;
}
.account-list{
color:gray;
margin:30rpx 0 0 30rpx;
display: flex;
flex-direction: row;
background-color:wheat;
line-height: 70rpx;
}
.account-list-detail{
flex:1;
}
.account-list-amount{
width: 100rpx;
}
//index.js
var util = require("../../utils/util.js");
//获取应用实例
var app = getApp();
Page({
data: {
imgUrls: [
'/images/01.jpg',
'/images/03.jpg',
'/images/05.jpg',
],
indicatorDots: false,
autoplay: true,
interval: 3000,
duration: 1000,
proList: null,
userInfo: {},
buttonLoading: false,
accountData:[],
accountTotal:0
},
onLoad: function () {
console.log('onLoad')
var that = this; // 获取记录
var tempAccountData = wx.getStorageSync("accountData") || [];
this.caculateTotal(tempAccountData);
this.setData({
accountData: tempAccountData
}); },
// 计算总额
caculateTotal:function(data){
var tempTotal = 0;
for(var x in data){
tempTotal += parseFloat(data[x].amount);
}
this.setData({
accountTotal: tempTotal
});
},
//表单提交
formSubmit:function(e){
this.setData({
buttonLoading: true
}); var that = this;
setTimeout(function(){
var inDetail = e.detail.value.inputdetail;
var inAmount = e.detail.value.inputamount;
if(inDetail.toString().length <= 0 || inAmount.toString().length <= 0){
console.log("can not empty");
that.setData({
buttonLoading: false
});
return false;
} //新增记录
var tempAccountData = wx.getStorageSync("accountData") || [];
tempAccountData.unshift({detail:inDetail,amount:inAmount});
wx.setStorageSync("accountData",tempAccountData);
that.caculateTotal(tempAccountData);
that.setData({
accountData: tempAccountData,
buttonLoading: false
}); },1000);
},
//删除行
deleteRow: function(e){
var that = this;
var index = e.target.dataset.indexKey;
var tempAccountData = wx.getStorageSync("accountData") || [];
tempAccountData.splice(index,1);
wx.setStorageSync("accountData",tempAccountData);
that.caculateTotal(tempAccountData);
that.setData({
accountData: tempAccountData,
});
}
})
// pages/joy/joy.js
Page({ /**
* 页面的初始数据
*/
data: { "value": "", // 文本的内容
"placeholder": "随心而输:",
"maxlength": -1, // 最大输入长度,设置为 -1 的时候不限制最大长度
"focus": true,
"auto-height": true, // 是否自动增高,设置auto-height时,style.height不生效
"adjust-position": true, // 键盘弹起时,是否自动上推页面 }, /**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) { }, /**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () { }, /**
* 生命周期函数--监听页面显示
*/
onShow: function () { }, /**
* 生命周期函数--监听页面隐藏
*/
onHide: function () { }, /**
* 生命周期函数--监听页面卸载
*/
onUnload: function () { }, /**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () { }, /**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () { }, /**
* 用户点击右上角分享
*/
onShareAppMessage: function () { }
})
<!--pages/joy/joy.wxml-->
<view class="cls1">
<text>欢迎您谈一谈使用随心账本的感受</text>
</view> <textarea class="textarea" value="{{value}}" placeholder="{{placeholder}}" placeholder-class="placeholder" maxlength="{{maxlength}}" focus="{{focus}}" auto-height="{{auto-height}}" show-confirm-bar="{{show-confirm-bar}}"></textarea> <view class="cls2">
<text>想记就记,只为随心</text>
</view>
/* pages/joy/joy.wxss */
.cls1{
color:#CD6600;
margin:30rpx 0 0 30rpx;
position: absolute;
left: 30px;
} .cls2{
color:black;
align-self: flex-end;
margin:30rpx 0 0 30rpx;
text-shadow: 5px 5px 5px #FF0000;
position: absolute;
left: 50px;
top: 260px;
}
.textarea {
font-size: 36rpx;
margin:180rpx 0 0 0rpx;
background-color:#ADD8E6;
width: 100%;
height: 200px;
position: absolute;
left: 0px;
top: 10px;
} .placeholder {
font-size: 28rpx;
color: gray;
}
这里只插入了主要代码。这部分没有插入,太多有点乱,我会上传到自己的代码仓库里的

七天开发进度(七)(微信小程序版(二)记账本)的更多相关文章
- 移动开发之【微信小程序】的原理与权限问题以及相关的简易教程
这几天圈子里到处都在传播着这样一个东西,微信公众平台提供了一种新的开放能力,开发者可以快速开发一个小程序,取名曰:微信公众平台-小程序 据说取代移动开发安卓和苹果,那这个东东究竟是干吗用的?但很多人觉 ...
- 零基础开发一款微信小程序商城
零基础开发一款微信小程序商城 一个朋友问我能不能帮忙做个商城?我一个完整网页都写不出的 菜鸟程序员,我该怎么拒绝呢?好吧,看在小程序这么火的形势下,我还是答应了!找了个开源项目,差不多花了三天时间搞定 ...
- 微信小程序的开发:通过微信小程序看前端
前言 2016年9月22日凌晨,微信官方通过"微信公开课"公众号发布了关于微信小程序(微信应用号)的内测通知.整个朋友圈瞬间便像炸开了锅似的,各种揣测.介绍性文章在一夜里诞生.而真 ...
- 微信小程序版博客——开发汇总总结(附源码)
花了点时间陆陆续续,拼拼凑凑将我的小程序版博客搭建完了,这里做个简单的分享和总结. 整体效果 对于博客来说功能页面不是很多,且有些限制于后端服务(基于ghost博客提供的服务),相关样式可以参考截图或 ...
- 微信小程序版2048
最近流行微信"跳一跳"小游戏,我也心血来潮写了一个微信小程序版2048,本篇文章主要分享实现2048的算法以及注意的点,一起来学习吧!(源码地址见文章末尾) 算法 1.生成4* ...
- 微信小程序配置二
tabBar 客户端窗口底部的tab页面切换,只能配置最好两个.最多5个tab 属性说明: 属性 类型 必填 默认值 描述 color HexColor 是 tab上的文字默认颜色 selectedC ...
- 七天开发进度(六)(微信小程序版(一))
1. 今天主要根据网上教程学习了微信小程序的代码结构,和代码编写-Tabbar配置, 学习了app.js的App和Page方法, 认识了view组件,button组件,input组件,但是还没怎么应用 ...
- 微信小程序之简单记账本开发记录(七)
记账本已经可以实现添加和删除的功能 现在只需要将上述步骤重复一遍便可将另一个界面做出来. 大体上已制作完成,如果在细节上有变动会在这一篇更新 总体来说,这个作业让我对微信小程序的开发有了更多地认识,大 ...
- 支付宝小程序开发之与微信小程序不同的地方
前言: 本文仅汇总微信小程序移植支付宝小程序过程中遇到的一些不同的地方,详细请参考官方开发文档. 网络请求: 对于网络请求,基本上改动不大,也就支付宝小程序没有responseType属性及响应码字段 ...
随机推荐
- OpenStack-Glance(3)
一. Glance功能 传统 IT 环境下,安装一个系统是要么从CD安装,要么用 Ghost 等克隆工具恢复.有如下几个问题: 如果要安装的系统多了效率就很低 时间长,工作量大 安装完还要进行手工配置 ...
- docker下载镜像received unexpected Http status:500 Internal Server Error
解决办法 1.就是网上说的 关闭selLinue ,但是对我就没用 2.就是不使用镜像加速 ,但是出现连接超时 3.就是加上具体版本号 结果就成功了 [root@localhost ~]# docke ...
- java对象池commons-pool-1.6详解(一)
自己的项目中用到了 对象池 commons-pool: package com.sankuai.qcs.regulation.protocol.client; import com.dianping. ...
- Lodop、c-lodop注册与角色简短问答
注册与角色:参考http://www.c-lodop.com/demolist/t1.html参考链接里的三种场景,是哪种角色.客户端访问网站后用自己的打印机打印.是客户端本地打印角色.IP和域名注册 ...
- [BZOJ 2285] [SDOI 2011] 保密
Description 传送门 Solution 这道题的最大难点在于读懂题意(雾 分数规划求出 \(n\) 到 \(1\cdots n_1\) 每个点的最小 \(\sum\frac{t_i}{s_i ...
- 欧拉筛法模板and 洛谷 P3383 【模板】线性筛素数(包括清北的一些方法)
题目描述 如题,给定一个范围N,你需要处理M个某数字是否为质数的询问(每个数字均在范围1-N内) 输入格式 第一行包含两个正整数N.M,分别表示查询的范围和查询的个数. 接下来M行每行包含一个不小于1 ...
- TypeError: 'NoneType' object is not subscriptable
运行,显示TypeError: 'NoneType' object is not subscriptable错误信息,原因是变量使用了系统内置的关键字list 重新定义下这个变量就好了
- Springboot 1.简介 及第一个demo
按照官网上的新建一个maven项目,然后将类引入pom.xml文件中 <?xml version="1.0" encoding="UTF-8"?> ...
- 金融量化分析【day111】:Matplotib-图标标注
一.图像标注 1.股票 df = pd.read_csv('601318.csv') df.plot() plt.plot([1,3,4,5]) plt.plot([5,8,7,9]) plt.tit ...
- 流程控制if、while、for
if判断 if判断想执行第一个条件,if后的判断必须是True 1 什么是if判断 判断一个条件如果成立则做...不成立则做....2 为何要有if判断 让计算机能够像人一样具有判断的能力3 如何 ...