diff --git a/README.md b/README.md
index 68ac43e..22f7047 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,13 @@
#### 引言:
最近微信小程序爆火,顺势写了一个小demo,用了半天编码。结论是开发门槛降低,小程序更注重让开发者关注前端UI和交互。欢迎交流与提交~
+### 贡献者名单
+---
+| 时间 | 贡献者 | 贡献内容 |
+|--------|------------|---------------|
+| 2016.09.25 | JohnWang | 优化wx:for的使用,创建复用模板 |
+| 2016.09.24 | JohnWang | 优化结构目录 |
+
### 目录结构:
---
为了方便其他开发者学习和使用,拓展目录结构:
@@ -21,4 +28,4 @@
### 项目地址:
---
-https://github.com/aidenzou/SmallApp
\ No newline at end of file
+https://github.com/aidenzou/SmallApp
diff --git a/app.js b/app.js
index d177875..af01e9c 100755
--- a/app.js
+++ b/app.js
@@ -2,16 +2,16 @@
App({
onLaunch: function () {
console.log('App Launch')
- //调用API从本地缓存中获取数据
+ //调用API从本地缓存中获取数据
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
},
- getUserInfo:function(cb){
+ getUserInfo: function (cb) {
var that = this
- if(this.globalData.userInfo){
+ if (this.globalData.userInfo) {
typeof cb == "function" && cb(this.globalData.userInfo)
- }else{
+ } else {
//调用登录接口
wx.login({
success: function () {
@@ -31,7 +31,7 @@ App({
onHide: function () {
console.log('App Hide')
},
- globalData:{
- userInfo:null
+ globalData: {
+ userInfo: null
}
})
\ No newline at end of file
diff --git a/app.json b/app.json
index f26b49f..e418b0f 100755
--- a/app.json
+++ b/app.json
@@ -41,5 +41,11 @@
"text": "我的"
}]
},
+ "networkTimeout": {
+ "request": 10000,
+ "connectSocket": 10000,
+ "uploadFile": 10000,
+ "downloadFile": 10000
+ },
"debug": true
}
diff --git a/pages/i/index.js b/pages/i/index.js
index 742395f..de94ff7 100755
--- a/pages/i/index.js
+++ b/pages/i/index.js
@@ -22,4 +22,4 @@ Page( {
})
})
}
-})
+})
\ No newline at end of file
diff --git a/pages/i/index.wxml b/pages/i/index.wxml
index 89f7e7c..796b50d 100755
--- a/pages/i/index.wxml
+++ b/pages/i/index.wxml
@@ -7,4 +7,4 @@
{{source}}
-
+
\ No newline at end of file
diff --git a/pages/index/index.js b/pages/index/index.js
index c4ce5b4..670ed2f 100755
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -3,48 +3,57 @@
var app = getApp()
Page( {
data: {
+ //向模板传入数据
// 轮播
- images: [
- 'https://hamlet.b0.upaiyun.com/1609/19171/2788065f96c04ad38c8db50ad723bc37.jpg!/fwfh/640x352/quality/80',
- 'https://hamlet.b0.upaiyun.com/1609/23150/4cc74e62833e4cdaaec79f3a2ef256e5.jpg!/fwfh/640x352/quality/80',
- 'https://hamlet.b0.upaiyun.com/1609/23150/4cc74e62833e4cdaaec79f3a2ef256e5.jpg!/fwfh/640x352/quality/80',
- 'https://hamlet.b0.upaiyun.com/1609/20180/934270f1be264c63bfaf85b37e545928.jpg!/fwfh/640x352/quality/80',
- 'https://hamlet.b0.upaiyun.com/1609/20171/77f7a3c93fd641bf95150501ef9a7cad.jpg!/fwfh/640x352/quality/80',
- 'https://hamlet.b0.upaiyun.com/1609/19171/2788065f96c04ad38c8db50ad723bc37.jpg!/fwfh/640x352/quality/80',
- 'https://hamlet.b0.upaiyun.com/1609/23171/70065cf9e45d46729ca51dec55d5f650.jpg!/fwfh/640x352/quality/80'
- ],
- indicatorDots: true,
- vertical: false,
- autoplay: true,
- interval: 3000,
- duration: 1200,
+ index_index_scroll_tmpl: {
+ images: [
+ 'https://hamlet.b0.upaiyun.com/1609/19171/2788065f96c04ad38c8db50ad723bc37.jpg!/fwfh/640x352/quality/80',
+ 'https://hamlet.b0.upaiyun.com/1609/23150/4cc74e62833e4cdaaec79f3a2ef256e5.jpg!/fwfh/640x352/quality/80',
+ 'https://hamlet.b0.upaiyun.com/1609/23150/4cc74e62833e4cdaaec79f3a2ef256e5.jpg!/fwfh/640x352/quality/80',
+ 'https://hamlet.b0.upaiyun.com/1609/20180/934270f1be264c63bfaf85b37e545928.jpg!/fwfh/640x352/quality/80',
+ 'https://hamlet.b0.upaiyun.com/1609/20171/77f7a3c93fd641bf95150501ef9a7cad.jpg!/fwfh/640x352/quality/80',
+ 'https://hamlet.b0.upaiyun.com/1609/19171/2788065f96c04ad38c8db50ad723bc37.jpg!/fwfh/640x352/quality/80',
+ 'https://hamlet.b0.upaiyun.com/1609/23171/70065cf9e45d46729ca51dec55d5f650.jpg!/fwfh/640x352/quality/80'
+ ],
+ indicatorDots: true,
+ vertical: false,
+ autoplay: true,
+ interval: 3000,
+ duration: 1200
+ },
// nav
- navs: [
- {
- image: 'https://m.youcai.xin/static/img/gravida.png',
- text: '孕妇'
- }, {
- image: 'https://m.youcai.xin/static/img/confinement.png',
- text: '月子'
- }, {
- image: 'https://m.youcai.xin/static/img/baby.png',
- text: '幼儿'
- }, {
- image: 'https://m.youcai.xin/static/img/old.png',
- text: '老人'
- }
- ],
+ index_index_navs_tmpl: {
+ navs: [
+ {
+ image: 'https://m.youcai.xin/static/img/gravida.png',
+ text: '孕妇'
+ }, {
+ image: 'https://m.youcai.xin/static/img/confinement.png',
+ text: '月子'
+ }, {
+ image: 'https://m.youcai.xin/static/img/baby.png',
+ text: '幼儿'
+ }, {
+ image: 'https://m.youcai.xin/static/img/old.png',
+ text: '老人'
+ }
+ ]
+ },
+
// item
- items: [
- {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
- {image: 'https://hamlet.b0.upaiyun.com/1609/22111/84439174cad04497beda3a076663beb4.jpg'},
- {image: 'https://hamlet.b0.upaiyun.com/1609/22111/1987d8eb8b1748368b7f2382332c9718.jpg'},
- {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
- {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
- {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
- {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
- {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'}
- ]
+ index_index_items_tmpl: {
+ items: [
+ {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
+ {image: 'https://hamlet.b0.upaiyun.com/1609/22111/84439174cad04497beda3a076663beb4.jpg'},
+ {image: 'https://hamlet.b0.upaiyun.com/1609/22111/1987d8eb8b1748368b7f2382332c9718.jpg'},
+ {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
+ {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
+ {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
+ {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
+ {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'}
+ ]
+ }
+
},
//事件处理函数
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
index 4ace76a..36bbf76 100755
--- a/pages/index/index.wxml
+++ b/pages/index/index.wxml
@@ -1,33 +1,20 @@
+
+
-
-
-
-
-
-
-
+
-
+
-
-
-
- {{item.text}}
-
-
+
精品特价
-
-
-
-
-
-
+
+
+
diff --git a/pages/list/index.js b/pages/list/index.js
index e68d387..34df860 100755
--- a/pages/list/index.js
+++ b/pages/list/index.js
@@ -1,7 +1,10 @@
Page({
data: {
title: '',
- items: [{"mprice":0,"maxpacks":100,"price":12800,"subcate":210,"remains":998,"type":1,"freight":0,"title":"北京油鸡(小公鸡)","imgs":["https://hamlet.b0.upaiyun.com/1609/22170/362ba7ea685440e5891d6f6c661d0552.jpg"],"unit":"只","id":302,"quantity":"1"},{"mprice":0,"maxpacks":14,"price":1600,"subcate":410,"remains":14,"type":4,"freight":1000,"title":"红糖粉","imgs":["https://hamlet.b0.upaiyun.com/1604/06200/34088f0a883f4b85ae573a822ff68381.jpg"],"unit":"g","id":93,"quantity":"400"},{"mprice":0,"maxpacks":100,"price":4800,"subcate":202,"remains":5,"type":1,"freight":1000,"title":"极致Q弹肉丸子","imgs":["https://hamlet.b0.upaiyun.com/1601/27161/2e8c13bc2d0847718c223bcd0f5f6fe3.png"],"unit":"g","id":69,"quantity":"300"},{"mprice":2200,"maxpacks":100,"price":1980,"subcate":410,"remains":42,"type":1,"freight":1000,"title":"女生红糖","imgs":["https://hamlet.b0.upaiyun.com/1604/06150/c500467218ea4ce8ace753a05e31a49e.jpg"],"unit":"g","id":91,"quantity":"220"},{"mprice":2280,"maxpacks":100,"price":1880,"subcate":410,"remains":29,"type":1,"freight":1000,"title":"姜母红糖","imgs":["https://hamlet.b0.upaiyun.com/1604/06150/bef4cca020764e91a194bba87c627a8a.jpg"],"unit":"g","id":90,"quantity":"215"},{"mprice":0,"maxpacks":100,"price":1800,"subcate":301,"remains":999936,"type":1,"freight":1000,"title":"“沁州黄”小米","imgs":["https://hamlet.b0.upaiyun.com/1511/12100/e31c7dc53a874d368fa4af8e54fbffb5.jpg"],"unit":"g","id":20,"quantity":"1000"},{"mprice":0,"maxpacks":1000,"price":12800,"subcate":301,"remains":9994,"type":4,"freight":0,"title":"富硒米家庭装","imgs":["https://hamlet.b0.upaiyun.com/1606/12101/e6bbd6b6cd474a97a1786b43a063f510.jpg"],"unit":"kg","id":171,"quantity":"5"},{"mprice":0,"maxpacks":10,"price":3000,"subcate":201,"remains":99885,"type":1,"freight":1000,"title":"优选香草贵妃鸡蛋","imgs":["https://hamlet.b0.upaiyun.com/1606/24001/5cdfc1d626a7407c86d82a3c99daeaa3.jpg"],"unit":"g","id":22,"quantity":"500"},{"mprice":0,"maxpacks":100,"price":16800,"subcate":210,"remains":49956,"type":4,"freight":1000,"title":"有菜推荐香草贵妃鸡","imgs":["https://hamlet.b0.upaiyun.com/1606/24001/c40521bd9f054e2988fde39527d8e6f0.jpg"],"unit":"g","id":19,"quantity":"1250"},{"mprice":0,"maxpacks":100,"price":3800,"subcate":202,"remains":999980,"type":1,"freight":1000,"title":"深山散养黑猪后臀尖","imgs":["https://hamlet.b0.upaiyun.com/1512/15160/620395fd67164f41aba7bdfdcabe5379.jpg"],"unit":"g","id":44,"quantity":"400"},{"mprice":2480,"maxpacks":100,"price":2280,"subcate":410,"remains":0,"type":1,"freight":1000,"title":"玫瑰红糖","imgs":["https://hamlet.b0.upaiyun.com/1604/06141/92c264a3dc5d4c49ae33c9a1fbdf54e5.jpg"],"unit":"g","id":89,"quantity":"175"}]
+ //向模板传入数据
+ list_index_items_tmpl: {
+ items: [{"mprice":0,"maxpacks":100,"price":12800,"subcate":210,"remains":998,"type":1,"freight":0,"title":"北京油鸡(小公鸡)","imgs":["https://hamlet.b0.upaiyun.com/1609/22170/362ba7ea685440e5891d6f6c661d0552.jpg"],"unit":"只","id":302,"quantity":"1"},{"mprice":0,"maxpacks":14,"price":1600,"subcate":410,"remains":14,"type":4,"freight":1000,"title":"红糖粉","imgs":["https://hamlet.b0.upaiyun.com/1604/06200/34088f0a883f4b85ae573a822ff68381.jpg"],"unit":"g","id":93,"quantity":"400"},{"mprice":0,"maxpacks":100,"price":4800,"subcate":202,"remains":5,"type":1,"freight":1000,"title":"极致Q弹肉丸子","imgs":["https://hamlet.b0.upaiyun.com/1601/27161/2e8c13bc2d0847718c223bcd0f5f6fe3.png"],"unit":"g","id":69,"quantity":"300"},{"mprice":2200,"maxpacks":100,"price":1980,"subcate":410,"remains":42,"type":1,"freight":1000,"title":"女生红糖","imgs":["https://hamlet.b0.upaiyun.com/1604/06150/c500467218ea4ce8ace753a05e31a49e.jpg"],"unit":"g","id":91,"quantity":"220"},{"mprice":2280,"maxpacks":100,"price":1880,"subcate":410,"remains":29,"type":1,"freight":1000,"title":"姜母红糖","imgs":["https://hamlet.b0.upaiyun.com/1604/06150/bef4cca020764e91a194bba87c627a8a.jpg"],"unit":"g","id":90,"quantity":"215"},{"mprice":0,"maxpacks":100,"price":1800,"subcate":301,"remains":999936,"type":1,"freight":1000,"title":"“沁州黄”小米","imgs":["https://hamlet.b0.upaiyun.com/1511/12100/e31c7dc53a874d368fa4af8e54fbffb5.jpg"],"unit":"g","id":20,"quantity":"1000"},{"mprice":0,"maxpacks":1000,"price":12800,"subcate":301,"remains":9994,"type":4,"freight":0,"title":"富硒米家庭装","imgs":["https://hamlet.b0.upaiyun.com/1606/12101/e6bbd6b6cd474a97a1786b43a063f510.jpg"],"unit":"kg","id":171,"quantity":"5"},{"mprice":0,"maxpacks":10,"price":3000,"subcate":201,"remains":99885,"type":1,"freight":1000,"title":"优选香草贵妃鸡蛋","imgs":["https://hamlet.b0.upaiyun.com/1606/24001/5cdfc1d626a7407c86d82a3c99daeaa3.jpg"],"unit":"g","id":22,"quantity":"500"},{"mprice":0,"maxpacks":100,"price":16800,"subcate":210,"remains":49956,"type":4,"freight":1000,"title":"有菜推荐香草贵妃鸡","imgs":["https://hamlet.b0.upaiyun.com/1606/24001/c40521bd9f054e2988fde39527d8e6f0.jpg"],"unit":"g","id":19,"quantity":"1250"},{"mprice":0,"maxpacks":100,"price":3800,"subcate":202,"remains":999980,"type":1,"freight":1000,"title":"深山散养黑猪后臀尖","imgs":["https://hamlet.b0.upaiyun.com/1512/15160/620395fd67164f41aba7bdfdcabe5379.jpg"],"unit":"g","id":44,"quantity":"400"},{"mprice":2480,"maxpacks":100,"price":2280,"subcate":410,"remains":0,"type":1,"freight":1000,"title":"玫瑰红糖","imgs":["https://hamlet.b0.upaiyun.com/1604/06141/92c264a3dc5d4c49ae33c9a1fbdf54e5.jpg"],"unit":"g","id":89,"quantity":"175"}]
+ }
},
//事件处理函数
onLoad: function (options) {
diff --git a/pages/list/index.wxml b/pages/list/index.wxml
index 67870ad..4734c91 100755
--- a/pages/list/index.wxml
+++ b/pages/list/index.wxml
@@ -1,15 +1,6 @@
+
+
-
-
-
-
-
-
- {{item.title}}
- {{item.quantity}}{{item.unit}}/份
- ¥{{item.price/100}}
-
-
-
-
+
+
\ No newline at end of file
diff --git a/pages/logs/logs.json b/pages/logs/logs.json
index 66dcbc7..5f10171 100755
--- a/pages/logs/logs.json
+++ b/pages/logs/logs.json
@@ -1,3 +1,3 @@
{
"navigationBarTitleText": "查看启动日志"
-}
\ No newline at end of file
+}
diff --git a/template/item-template.wxml b/template/item-template.wxml
new file mode 100644
index 0000000..3244ba4
--- /dev/null
+++ b/template/item-template.wxml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.text}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.title}}
+ {{item.quantity}}{{item.unit}}/份
+ ¥{{item.price/100}}
+
+
+
+