forked from shen100/wemall
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"pages":[ | ||
"pages/index/index", | ||
"pages/logs/logs", | ||
"pages/product/product", | ||
"pages/cart/cart", | ||
"pages/mine/mine" | ||
], | ||
"window":{ | ||
"backgroundTextStyle": "light", | ||
"backgroundColor": "#ff0", | ||
"navigationBarBackgroundColor": "#000", | ||
"navigationBarTitleText": "爱宝宝母婴微商城", | ||
"navigationBarTextStyle": "white" | ||
}, | ||
"tabBar": { | ||
"color": "#5f616c", | ||
"selectedColor": "#f13030", | ||
"backgroundColor": "#fff", | ||
"borderStyle": "white", | ||
"position": "bottom", | ||
"list": [ | ||
{ | ||
"pagePath": "pages/index/index", | ||
"text": "首页", | ||
"iconPath": "./icons/home.png", | ||
"selectedIconPath": "./icons/homeSelected.png" | ||
}, | ||
{ | ||
"pagePath": "pages/cart/cart", | ||
"text": "购物车", | ||
"iconPath": "./icons/cart.png", | ||
"selectedIconPath": "./icons/cartSelected.png" | ||
}, | ||
{ | ||
"pagePath": "pages/mine/mine", | ||
"text": "购物车", | ||
"iconPath": "./icons/mine.png", | ||
"selectedIconPath": "./icons/mineSelected.png" | ||
} | ||
] | ||
}, | ||
"networkTimeout": { | ||
"request": 10000, | ||
"downloadFile": 10000 | ||
}, | ||
"debug": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/**app.wxss**/ | ||
.container { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 200rpx 0; | ||
box-sizing: border-box; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Page({ | ||
data: { | ||
name: 'test' | ||
}, | ||
onLoad: function () { | ||
this.setData({ | ||
name: 'xxx' | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!--购物车--> | ||
<view class="container log-list"> | ||
<text class="log-item">我的购物车</text> | ||
</view> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//index.js | ||
//获取应用实例 | ||
var app = getApp() | ||
Page({ | ||
data: { | ||
motto: 'Hello World', | ||
userInfo: {} | ||
}, | ||
//事件处理函数 | ||
bindViewTap: function() { | ||
wx.navigateTo({ | ||
url: '../logs/logs' | ||
}) | ||
}, | ||
onLoad: function () { | ||
console.log('onLoad') | ||
var that = this | ||
//调用应用实例的方法获取全局数据 | ||
app.getUserInfo(function(userInfo){ | ||
//更新数据 | ||
that.setData({ | ||
userInfo:userInfo | ||
}) | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!--index.wxml--> | ||
<view class="container"> | ||
<view bindtap="bindViewTap" class="userinfo"> | ||
<image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image> | ||
<text class="userinfo-nickname">{{userInfo.nickName}}</text> | ||
</view> | ||
<view class="usermotto"> | ||
<text class="user-motto">{{motto}}</text> | ||
</view> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/**index.wxss**/ | ||
.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: 200px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//logs.js | ||
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)) | ||
}) | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"navigationBarTitleText": "查看启动日志" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!--logs.wxml--> | ||
<view class="container log-list"> | ||
<block wx:for="{{logs}}" wx:for-item="log" wx:key="*this"> | ||
<text class="log-item">{{index + 1}}. {{log}}</text> | ||
</block> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.log-list { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 40rpx; | ||
} | ||
.log-item { | ||
margin: 10rpx; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Page({ | ||
data: { | ||
name: 'test' | ||
}, | ||
onLoad: function () { | ||
this.setData({ | ||
name: 'xxx' | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!--我的--> | ||
<view class="container log-list"> | ||
<text class="log-item">我的</text> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Page({ | ||
data: { | ||
name: 'test' | ||
}, | ||
onLoad: function () { | ||
this.setData({ | ||
name: 'shen100' | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!--产品详情页--> | ||
<view class="container log-list"> | ||
<text class="log-item">我的商品</text> | ||
</view> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |