From 640720165e21a16fd81859bcbd1d7be0958c5f44 Mon Sep 17 00:00:00 2001
From: chz <1064711610@qq.com>
Date: Wed, 1 Nov 2017 09:31:51 +0800
Subject: [PATCH] =?UTF-8?q?#84=20#123=20=E6=9C=9F=E6=9C=AB=E4=BD=9C?=
=?UTF-8?q?=E4=B8=9A=EF=BC=9A=E7=82=B9=E9=A4=90=E5=B0=8F=E7=A8=8B=E5=BA=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
1517010101/final/app.js | 36 +++++
1517010101/final/app.json | 13 ++
1517010101/final/app.wxss | 19 +++
.../final/pages/components/dishes/dishes.js | 133 ++++++++++++++++++
.../final/pages/components/dishes/dishes.json | 3 +
.../final/pages/components/dishes/dishes.wxml | 30 ++++
.../final/pages/components/dishes/dishes.wxss | 49 +++++++
1517010101/final/pages/index/index.js | 48 +++++++
1517010101/final/pages/index/index.wxml | 23 +++
1517010101/final/pages/index/index.wxss | 23 +++
1517010101/final/pages/logs/logs.js | 13 ++
1517010101/final/pages/logs/logs.json | 3 +
1517010101/final/pages/logs/logs.wxml | 6 +
1517010101/final/pages/logs/logs.wxss | 8 ++
1517010101/final/project.config.json | 27 ++++
1517010101/final/utils/util.js | 21 +++
16 files changed, 455 insertions(+)
create mode 100644 1517010101/final/app.js
create mode 100644 1517010101/final/app.json
create mode 100644 1517010101/final/app.wxss
create mode 100644 1517010101/final/pages/components/dishes/dishes.js
create mode 100644 1517010101/final/pages/components/dishes/dishes.json
create mode 100644 1517010101/final/pages/components/dishes/dishes.wxml
create mode 100644 1517010101/final/pages/components/dishes/dishes.wxss
create mode 100644 1517010101/final/pages/index/index.js
create mode 100644 1517010101/final/pages/index/index.wxml
create mode 100644 1517010101/final/pages/index/index.wxss
create mode 100644 1517010101/final/pages/logs/logs.js
create mode 100644 1517010101/final/pages/logs/logs.json
create mode 100644 1517010101/final/pages/logs/logs.wxml
create mode 100644 1517010101/final/pages/logs/logs.wxss
create mode 100644 1517010101/final/project.config.json
create mode 100644 1517010101/final/utils/util.js
diff --git a/1517010101/final/app.js b/1517010101/final/app.js
new file mode 100644
index 0000000..0b8a304
--- /dev/null
+++ b/1517010101/final/app.js
@@ -0,0 +1,36 @@
+//app.js
+App({
+ onLaunch: function () {
+ //调用API从本地缓存中获取数据
+ var logs = wx.getStorageSync('logs') || []
+ logs.unshift(Date.now())
+ wx.setStorageSync('logs', logs)
+ },
+ onShow: function(){
+ console.log('onShow');
+ },
+ onHide: function(){
+ console.log('onHide');
+ },
+ 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
+ }
+})
diff --git a/1517010101/final/app.json b/1517010101/final/app.json
new file mode 100644
index 0000000..23c49ae
--- /dev/null
+++ b/1517010101/final/app.json
@@ -0,0 +1,13 @@
+{
+ "pages":[
+ "pages/index/index",
+ "pages/components/dishes/dishes"
+ ],
+ "window":{
+ "backgroundColor":"#f4f4f4",
+ "backgroundTextStyle":"light",
+ "navigationBarBackgroundColor": "orange",
+ "navigationBarTitleText": "美食汇微菜单",
+ "navigationBarTextStyle":"white"
+ }
+}
diff --git a/1517010101/final/app.wxss b/1517010101/final/app.wxss
new file mode 100644
index 0000000..dc06c32
--- /dev/null
+++ b/1517010101/final/app.wxss
@@ -0,0 +1,19 @@
+/**app.wxss**/
+.container {
+ height: 100%;
+ box-sizing: border-box;
+ background-color: #f4f4f4;
+}
+
+.flex-wrap{
+ display: flex;
+}
+.flex-item{
+ flex: 1;
+}
+.flex-wrap.flex-direction-col{
+ flex-direction: column;
+}
+.flex-wrap.flex-direction-row{
+ flex-direction: row;
+}
diff --git a/1517010101/final/pages/components/dishes/dishes.js b/1517010101/final/pages/components/dishes/dishes.js
new file mode 100644
index 0000000..295df7e
--- /dev/null
+++ b/1517010101/final/pages/components/dishes/dishes.js
@@ -0,0 +1,133 @@
+var app = getApp()
+Page({
+ data: {
+ hidden:false,
+ curNav:1,
+ curIndex:0,
+ cart:[],
+ cartTotal:0,
+ navList:[
+ {
+ id:1,
+ name:'热销菜品'
+ },
+ {
+ id:2,
+ name:'热菜'
+ },
+ {
+ id:3,
+ name:'凉菜'
+ },
+ {
+ id:4,
+ name:'套餐'
+ }
+ ],
+ dishesList:[
+ [
+ {
+ name:"红烧肉",
+ price:38,
+ num:1,
+ id:1
+ },
+ {
+ name:"宫保鸡丁",
+ price:58,
+ num:1,
+ id:29
+ },
+ {
+ name:"水煮鱼",
+ price:88,
+ num:1,
+ id:2
+ }
+ ],
+ [
+ {
+ name:"小炒日本豆腐",
+ price:18,
+ num:1,
+ id:3
+ },
+ {
+ name:"烤鱼",
+ price:58,
+ num:1,
+ id:4
+ }
+ ],
+ [
+ {
+ name:"大拌菜",
+ price:18,
+ num:1,
+ id:5
+ },
+ {
+ name:"川北凉粉",
+ price:8,
+ num:1,
+ id:6
+ }
+ ],
+ []
+ ],
+ dishes:[]
+ },
+ loadingChange () {
+ setTimeout(() => {
+ this.setData({
+ hidden:true
+ })
+ },2000)
+ },
+ selectNav (event) {
+ let id = event.target.dataset.id,
+ index = parseInt(event.target.dataset.index);
+ self = this;
+ this.setData({
+ curNav:id,
+ curIndex:index
+ })
+ },
+ // 选择菜品
+ selectDish (event) {
+ let dish = event.currentTarget.dataset.dish;
+ let flag = true;
+ let cart = this.data.cart;
+
+ if(cart.length > 0){
+ cart.forEach(function(item,index){
+ if(item == dish){
+ cart.splice(index,1);
+ flag = false;
+ }
+ })
+ }
+ if(flag) cart.push(dish);
+ this.setData({
+ cartTotal:cart.length
+ })
+ this.setStatus(dish)
+ },
+ setStatus (dishId) {
+ let dishes = this.data.dishesList;
+ for (let dish of dishes){
+ dish.forEach((item) => {
+ if(item.id == dishId){
+ item.status = !item.status || false
+ }
+ })
+ }
+
+ this.setData({
+ dishesList:this.data.dishesList
+ })
+ },
+ onLoad () {
+ this.loadingChange()
+ }
+})
\ No newline at end of file
diff --git a/1517010101/final/pages/components/dishes/dishes.json b/1517010101/final/pages/components/dishes/dishes.json
new file mode 100644
index 0000000..4aa6981
--- /dev/null
+++ b/1517010101/final/pages/components/dishes/dishes.json
@@ -0,0 +1,3 @@
+{
+ "navigationBarTitleText": "堂食-点菜"
+}
\ No newline at end of file
diff --git a/1517010101/final/pages/components/dishes/dishes.wxml b/1517010101/final/pages/components/dishes/dishes.wxml
new file mode 100644
index 0000000..294856e
--- /dev/null
+++ b/1517010101/final/pages/components/dishes/dishes.wxml
@@ -0,0 +1,30 @@
+
+
+
+
+ {{item.name}}
+
+
+
+
+
+
+
+
+ {{item.name}}
+ ¥{{item.price}}
+
+
+
+
+
+
+
+
+
+
+
+ 购物车:{{cartTotal}}
+
+
+玩命加载中…
diff --git a/1517010101/final/pages/components/dishes/dishes.wxss b/1517010101/final/pages/components/dishes/dishes.wxss
new file mode 100644
index 0000000..4cdfbf7
--- /dev/null
+++ b/1517010101/final/pages/components/dishes/dishes.wxss
@@ -0,0 +1,49 @@
+.aside{
+ width:4rem;
+ border-right: 1px solid #ddd;
+ font-size: .85rem;
+}
+.type-nav{
+ position: relative;
+ padding:.7rem .3rem;
+ text-align: center;
+ border-bottom: 1px solid #ddd;
+ z-index: 10;
+}
+.type-nav.selected{
+ margin-right: -1px;
+ padding-left::-1px;
+ color: #333;
+ background-color: #fff;
+}
+.content{
+ background-color: #fff;
+}
+
+.dish{
+ margin-left: 1rem;
+ padding: 1rem;
+ border-bottom: 1px solid #ddd;
+}
+.dish .title{
+ display: block;
+ font-size: 1rem;
+}
+.dish p{
+ color: orange;
+ font-size: .75rem;
+}
+.dish .add-btn{
+ width: 3rem;
+ text-align: right;
+}
+
+.cart{
+ display: block;
+ position: fixed;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ padding: 1rem;
+ background: #ddd;
+}
\ No newline at end of file
diff --git a/1517010101/final/pages/index/index.js b/1517010101/final/pages/index/index.js
new file mode 100644
index 0000000..a65c74a
--- /dev/null
+++ b/1517010101/final/pages/index/index.js
@@ -0,0 +1,48 @@
+//index.js
+//获取应用实例
+var app = getApp()
+Page({
+ data: {
+ imgUrls: [
+ 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
+ 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
+ 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
+ ],
+ indicatorDots: true,
+ autoplay: true,
+ interval: 3000,
+ duration: 1000,
+ navItems:[
+ {
+ name:'堂食',
+ url:'dishes'
+ },
+ {
+ name:'外卖',
+ url:'take',
+ isSplot:true
+ },
+ {
+ name:'外带',
+ url:'out'
+ },
+ {
+ name:'订单',
+ url:'bill'
+ },
+ {
+ name:'帐单',
+ url:'bill',
+ isSplot:true
+ },
+ {
+ name:'报表',
+ url:'bill'
+ }
+ ]
+ },
+ onLoad: function () {
+ console.log('onLoad')
+ }
+
+})
diff --git a/1517010101/final/pages/index/index.wxml b/1517010101/final/pages/index/index.wxml
new file mode 100644
index 0000000..dc5609b
--- /dev/null
+++ b/1517010101/final/pages/index/index.wxml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.name}}
+
+
+
+
+
\ No newline at end of file
diff --git a/1517010101/final/pages/index/index.wxss b/1517010101/final/pages/index/index.wxss
new file mode 100644
index 0000000..298388d
--- /dev/null
+++ b/1517010101/final/pages/index/index.wxss
@@ -0,0 +1,23 @@
+/**index.wxss**/
+.my-swiper image{
+ width: 100%;
+}
+
+.wrap{
+ display: inline-block;
+ margin-top: .8rem;
+}
+.wrap-item{
+ display: inline-block;
+ width: 33%;
+ height: 6rem;
+ line-height: 6rem;
+ border-bottom: 1px solid #ddd;
+ background-color: #fff;
+ text-align: center;
+}
+ /*不支持 :nth-child(2);*/
+.wrap-item.exp{
+ border: 1px solid #ddd;
+ border-top: 0;
+}
\ No newline at end of file
diff --git a/1517010101/final/pages/logs/logs.js b/1517010101/final/pages/logs/logs.js
new file mode 100644
index 0000000..38db3c8
--- /dev/null
+++ b/1517010101/final/pages/logs/logs.js
@@ -0,0 +1,13 @@
+var util = require('../../utils/util.js')
+Page({
+ data: {
+ logs: []
+ },
+ onLoad: function () {
+ this.setData({
+ logs: (wx.getStorageSync('logs') || []).map(function (log) {
+ return util.formatTime(new Date(log))
+ })
+ })
+ }
+})
diff --git a/1517010101/final/pages/logs/logs.json b/1517010101/final/pages/logs/logs.json
new file mode 100644
index 0000000..66dcbc7
--- /dev/null
+++ b/1517010101/final/pages/logs/logs.json
@@ -0,0 +1,3 @@
+{
+ "navigationBarTitleText": "查看启动日志"
+}
\ No newline at end of file
diff --git a/1517010101/final/pages/logs/logs.wxml b/1517010101/final/pages/logs/logs.wxml
new file mode 100644
index 0000000..fdf5f5f
--- /dev/null
+++ b/1517010101/final/pages/logs/logs.wxml
@@ -0,0 +1,6 @@
+
+
+
+ {{index + 1}}. {{log}}
+
+
diff --git a/1517010101/final/pages/logs/logs.wxss b/1517010101/final/pages/logs/logs.wxss
new file mode 100644
index 0000000..94d4b88
--- /dev/null
+++ b/1517010101/final/pages/logs/logs.wxss
@@ -0,0 +1,8 @@
+.log-list {
+ display: flex;
+ flex-direction: column;
+ padding: 40rpx;
+}
+.log-item {
+ margin: 10rpx;
+}
diff --git a/1517010101/final/project.config.json b/1517010101/final/project.config.json
new file mode 100644
index 0000000..c60edce
--- /dev/null
+++ b/1517010101/final/project.config.json
@@ -0,0 +1,27 @@
+{
+ "description": "项目配置文件。",
+ "setting": {
+ "urlCheck": true,
+ "es6": true,
+ "postcss": true,
+ "minified": true
+ },
+ "compileType": "weapp",
+ "libVersion": "1.6.0",
+ "appid": "wx3f32ec5a72700b17",
+ "projectname": "buy",
+ "condition": {
+ "weapp": {
+ "current": -1,
+ "list": []
+ },
+ "search": {
+ "current": -1,
+ "list": []
+ },
+ "conversation": {
+ "current": -1,
+ "list": []
+ }
+ }
+}
\ No newline at end of file
diff --git a/1517010101/final/utils/util.js b/1517010101/final/utils/util.js
new file mode 100644
index 0000000..54ea2f6
--- /dev/null
+++ b/1517010101/final/utils/util.js
@@ -0,0 +1,21 @@
+function formatTime(date) {
+ var year = date.getFullYear()
+ var month = date.getMonth() + 1
+ var day = date.getDate()
+
+ var hour = date.getHours()
+ var minute = date.getMinutes()
+ var second = date.getSeconds();
+
+
+ return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
+}
+
+function formatNumber(n) {
+ n = n.toString()
+ return n[1] ? n : '0' + n
+}
+
+module.exports = {
+ formatTime: formatTime
+}