记账本已经可以实现添加和删除的功能

现在只需要将上述步骤重复一遍便可将另一个界面做出来。

大体上已制作完成,如果在细节上有变动会在这一篇更新

总体来说,这个作业让我对微信小程序的开发有了更多地认识,大致主体程序和页面开发的一些手法也有了一个

较为详细地了解,对以后的学习也有了很大的帮助。

使用教程:千锋教育-微信程序开发

下面是小程序的大体代码

 const app = getApp()

 Page({
data: {
motto: 'Life is fantastic',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function () {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse) {
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo: function (e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
},
onShow() { },
onShareAppMessage() {
return {
title: '管家记账本',
path: '/pages/index/index'
}
},
showTxet(){
this.setData({
motto:"生活充满精彩"
})
} })

index.js

 {
"navigationBarTitleText": "记账本", "usingComponents": {} }

index.json

 <view class="container" bindtap="showTxet">

   <view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view> <view class="btns">
<view class="btn btn-publish">
<navigator url="/pages/publish/publish">收入</navigator>
</view>
<view class="btn">
<navigator url="/pages/pro/pro">支出</navigator>
</view> </view>

index.wxml

 /*.map-container {
position: absolute;
top: 0;
right: 0;
bottom: 40px;
left: 0;
background: greenyellow;
}
.map{
width: 100%;
height: 100%
}*/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
} .userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
} .userinfo-nickname {
color: #aaa;
} .usermotto {
margin-top: 100px;
color: #aaa;
} /*下方按钮*/
.btns {
position: absolute;
display: flex;
left:0;
right: 0;
line-height: 40px;
bottom: 0;
background: #03bbd5;
}
.btn{
flex: 1;
text-align: center;
color: #fff;
}
.btn-publish{
background: #ff9700
} .classname{
width: 100%;
height: 100%;
display: flex;
justify-content: center; }
.classname-publish{
align-items: center;
}

index.wxss

 {
"pages": [
"pages/index/index"
],
"window": {
"backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "记账",
"navigationBarTextStyle": "black",
"backgroundColor": "gray"
},
"debug": true
}

pro.json

 <view class="container">

     <form catchsubmit="formSubmit" >
<view class="account-detail">
<input placeholder="花销详情(内容加时间)" name="inputdetail" type="text" />
</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-amount">
{{item.amount}}
</view> <view class="account-list-detail">
{{item.detail}}
</view> <view class="account-list-del">
<button size="mini" type="warn" data-index-key="{{index}}" bindtap="deleteRow" >删除</button>
</view> </view>
</block> </view>

pro.wxml

 .account-detail{
height: 100rpx;
padding: 0 30rpx;
} .account-amount{
padding: 0 30rpx;
} .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: 80rpx;
} .account-list-detail{
flex:1;
} .account-list-amount{
width: 500rpx;
}

pro.wxss

 {
"pages": [
"pages/index/index"
],
"window": {
"backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "记账",
"navigationBarTextStyle": "black",
"backgroundColor": "gray"
},
"debug": true
}

pro.js

另一个相似页面就不再重复贴了

微信小程序之简单记账本开发记录(七)的更多相关文章

  1. 微信小程序之简单记账本开发记录(一)

    下载并安装微信开发者工具 在选择开发记账本程序的时候犹豫着选择android studio还是微信小程序 最后选择了微信小程序,因其便利和快捷. 话不多说,第一步,下载并安装微信开发者工具.下面是教程 ...

  2. 微信小程序之简单记账本开发记录(二)

    1.打开开发者工具 2.从微信公众平台上获取到appid,或者使用测试号. 项目的大致目录如下: 一个小程序主体部分由三个文件组成,必须放在项目的根目录中 以app为开头的文件名用来布置作用于整个项目 ...

  3. 微信小程序之简单记账本开发记录(三)

    昨天已经编辑了主界面,在wxml文件中设置好跳转链接之后,就可以进行下一步的开发了 在pages中建立一个新的页面文件夹作为之后的支出页面 编辑后台,今天先搭建大致界面

  4. 微信小程序之简单记账本开发记录(六)

    昨天虽然将页面成功的搭建出来 但是其中的增删改查功能没有实现,需要到逻辑页面,即js页面注册一下 效果如下图

  5. 微信小程序之简单记账本开发记录(五)

    样式表和大致布局在昨天已构建好,今天完成页面结构部分 结果如下图所示

  6. 微信小程序之简单记账本开发记录(四)

    昨天搭建了大致界面 今天需要将用到的一系列样式表配置出来并检查错误

  7. 微信小程序仿朋友圈功能开发(发布、点赞、评论等功能)

    微信小程序仿朋友圈功能开发(发布.点赞.评论等功能) 1.项目分析 项目整体分为三个部分 发布 展示 详情页 graph LR 朋友圈发布 --内容发布--> 内容展示 内容展示 --点击展示卡 ...

  8. 转载:第五弹!全球首个微信小程序(应用号)开发教程!通宵吐血赶稿,每日更新!

    博卡君今天继续更新,忙了一天,终于有时间开工写教程.不罗嗦了,今天我们来看看如何实现一些前端的功能和效果. 第八章:微信小程序分组开发与左滑功能实现 先来看看今天的整体思路: 进入分组管理页面--&g ...

  9. 转载:第四弹!全球首个微信小程序(应用号)开发教程!通宵吐血赶稿,每日更新!

    感谢大家支持!博卡君周末休息了两天,今天又回到战斗状态了.上周五晚上微信放出官方工具和教程了,推荐程序猿小伙伴们都去试一试,结合教程和代码,写写自己的 demo 也不错. 闲话不多说,开始更新! 第七 ...

随机推荐

  1. 基础知识---const、readonly、static

    const:静态常量,也称编译时常量(compile-time constants),属于类型级,通过类名直接访问,被所有对象共享! a.叫编译时常量的原因是它编译时会将其替换为所对应的值: b.静态 ...

  2. java -jar 时指定内存大小

    java -jar -Xms1024m -Xmx1536m -XX:PermSize=128M -XX:MaxPermSize=256M car.jar 说明: 1.堆内存:最小1024M,最大153 ...

  3. [转]ASP.NET Core Web API 最佳实践指南

    原文地址: ASP.NET-Core-Web-API-Best-Practices-Guide 转自 介绍# 当我们编写一个项目的时候,我们的主要目标是使它能如期运行,并尽可能地满足所有用户需求. 但 ...

  4. mvc5中webapi的路由

    1.Global.asax中路由的注册 public class WebApiApplication : System.Web.HttpApplication { protected void App ...

  5. python 双层for循环,在第二层的for循环中的else中的continue,会退出到第一层for循环继续执行

    for a in [1,2,3,4,5]: for b in [1,2,3]: if a == b: print("a = b = %s" % a) break # 退出本次for ...

  6. springMVC对RESTful的支持

    1:后台controller方法编写 @RequestMapping("/itemsLook/{id}") public ItemsCustom itemsLook(@PathVa ...

  7. File "tesserocr.pyx", line 2443, in tesserocr._tesserocr.image_to_text RuntimeError: Failed to in...

    将Tesseract-OCR安装目录下的tessdata文件夹复制到Python解释器目录下就可以了

  8. flink PageRank详解(批量迭代的页面排名算法的基本实现)

    1.PageRank算法原理   2.基本数据准备 /** * numPages缺省15个测试页面 * * EDGES表示从一个pageId指向相连的另外一个pageId */ public clas ...

  9. logger(二)logback简介及其实现原理

    一.logback简介 logback是log4j创始人写的,性能比log4j要好,目前主要分为3个模块 logback-core:核心代码模块 logback-classic:log4j的一个改良版 ...

  10. ASP.NET Core 2.2 和之前版本区别: 可以在IIS上进行ASP.NET核心进程托管 (翻译)

    原文链接: https://weblog.west-wind.com/posts/2019/Mar/16/ASPNET-Core-Hosting-on-IIS-with-ASPNET-Core-22 ...