Skip to content

Commit 4defd69

Browse files
committed
增加我的页面
1 parent 2fdd145 commit 4defd69

13 files changed

+236
-52
lines changed

main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"fmt"
45
"os"
56
"strconv"
67
_ "github.com/jinzhu/gorm/dialects/mysql"
@@ -16,7 +17,8 @@ import (
1617
func init() {
1718
db, err := gorm.Open(config.DBConfig.Dialect, config.DBConfig.URL)
1819
if err != nil {
19-
os.Exit(1)
20+
fmt.Println(err.Error())
21+
os.Exit(-1)
2022
}
2123

2224
if config.DBConfig.SQLLog {
@@ -66,5 +68,3 @@ func main() {
6668

6769
app.Listen(":" + strconv.Itoa(config.ServerConfig.Port))
6870
}
69-
70-

wexin/app.js

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
1+
var userInfoCallbacks = [];
2+
13
App({
24
onLaunch: function() {
3-
5+
var self = this;
6+
wx.login({
7+
success: function(res) {
8+
console.log(res);
9+
wx.getUserInfo({
10+
success: function(res) {
11+
for (var i = 0; i < userInfoCallbacks.length; i++) {
12+
userInfoCallbacks[i](res.userInfo);
13+
}
14+
userInfoCallbacks = [];
15+
self.globalData.userInfo = res.userInfo;
16+
},
17+
fail: function(data) {
18+
console.log(data);
19+
}
20+
})
21+
}
22+
});
23+
},
24+
addUserInfoCallback: function(callback) {
25+
userInfoCallbacks.push(callback);
426
},
527
globalData: {
6-
28+
userInfo: null
729
}
830
})

wexin/icons/order_done.png

470 Bytes
Loading

wexin/icons/wait_deliver.png

528 Bytes
Loading

wexin/icons/wait_pay.png

1.36 KB
Loading

wexin/icons/wait_receive.png

836 Bytes
Loading

wexin/images/1.jpg

-104 KB
Binary file not shown.

wexin/pages/index/index.js

+1-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var config = require('../../config/config.js');
2-
var testinAB = require('../../sdk/sdk.js');
32

43
Page({
54
data: {
@@ -12,12 +11,7 @@ Page({
1211
niaoBuShiColor: '',
1312
},
1413
onCategoryTap: function() {
15-
testinAB.track('nbsbtnclick', 1, function() {
16-
wx.showModal({
17-
title: '提示',
18-
content: 'nbsbtnclick 指标上报成功'
19-
})
20-
});
14+
2115
},
2216
onProductTap: function(event) {
2317
var id = event.currentTarget.dataset.id;
@@ -60,23 +54,5 @@ Page({
6054
}
6155
}
6256
});
63-
64-
var self = this;
65-
testinAB.init('TESTIN_h793c3619-8bac-4ddb-b541-df2c3d7aa1b7');
66-
testinAB.setDefVars({
67-
selectedColor: '#e4393c'
68-
});
69-
70-
testinAB.getVars(function getVars(vars) {
71-
var color = vars.get('color');
72-
if (color == 'yellow') {
73-
color = '#ff0';
74-
} else if (color == 'red') {
75-
color = '#f00';
76-
}
77-
self.setData({
78-
niaoBuShiColor: color
79-
});
80-
});
8157
}
8258
})

wexin/pages/mine/mine.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
Page({
22
data: {
3-
name: 'test'
3+
userInfo: null
44
},
5-
onLoad: function () {
5+
onUserInfoCallback(userInfo) {
66
this.setData({
7-
name: 'xxx'
7+
userInfo: userInfo
88
})
9+
},
10+
onLoad: function() {
11+
var app = getApp();
12+
var userInfo = app.globalData.userInfo;
13+
if (!userInfo) {
14+
app.addUserInfoCallback(this.onUserInfoCallback.bind(this));
15+
} else {
16+
this.setData({
17+
userInfo: userInfo
18+
})
19+
}
920
}
1021
})

wexin/pages/mine/mine.wxml

+50-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,51 @@
1-
<!--我的-->
2-
<view class="container log-list">
3-
<text class="log-item">我的</text>
1+
<view class="mine-box">
2+
<scroll-view>
3+
<view class="mine-user">
4+
<image class="mine-user-avatar" mode="aspectFill" src="{{userInfo.avatarUrl}}" />
5+
<view class="mine-user-name">{{userInfo.nickName}}</view>
6+
</view>
7+
<view class="mine-order">
8+
<view class="mine-order-head">
9+
<view class="mine-order-title">我的订单</view>
10+
<view class="mine-all-order">查看全部订单</view>
11+
<image class="mine-right-arrow" src="../../icons/right_arrow.png"></image>
12+
</view>
13+
<view class="mine-order-status-list">
14+
<view class="mine-order-status-item">
15+
<view class="mine-order-img-box">
16+
<image class="mine-order-status-img" sytle="width:64rpx;height:64rpx;" model="aspectFit" src="../../icons/wait_pay.png"></image>
17+
</view>
18+
<view class="mine-order-status-label">待付款</view>
19+
</view>
20+
<view class="mine-order-status-item">
21+
<view class="mine-order-img-box">
22+
<image class="mine-order-status-img" sytle="width:62rpx;height:62rpx;" model="aspectFit" src="../../icons/wait_deliver.png"></image>
23+
</view>
24+
<view class="mine-order-status-label">待发货</view>
25+
</view>
26+
<view class="mine-order-status-item">
27+
<view class="mine-order-img-box">
28+
<image class="mine-order-status-img" sytle="width:58rpx;height:58rpx;" model="aspectFit" src="../../icons/wait_receive.png"></image>
29+
</view>
30+
<view class="mine-order-status-label">待收货</view>
31+
</view>
32+
<view class="mine-order-status-item">
33+
<view class="mine-order-img-box">
34+
<image class="mine-order-status-img" model="aspectFit" src="../../icons/order_done.png"></image>
35+
</view>
36+
<view class="mine-order-status-label">已完成</view>
37+
</view>
38+
</view>
39+
</view>
40+
<view class="mine-cart">
41+
<view class="mine-cart-title">购物车</view>
42+
<view class="mine-spacing"></view>
43+
<image class="mine-right-arrow" src="../../icons/right_arrow.png"></image>
44+
</view>
45+
<view class="mine-customer-service">
46+
<view class="mine-customer-service-title">联系客服</view>
47+
<view class="mine-spacing"></view>
48+
<image class="mine-right-arrow" src="../../icons/right_arrow.png"></image>
49+
</view>
50+
</scroll-view>
451
</view>

wexin/pages/mine/mine.wxss

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
page {
2+
width: 100%;
3+
height: 100%;
4+
background-color: #f9f9f9;
5+
}
6+
7+
.mine-box {
8+
width: 100%;
9+
height: 100%;
10+
}
11+
12+
.mine-user {
13+
width: 100%;
14+
height: 400rpx;
15+
background: #fff;
16+
text-align: center;
17+
border-bottom: 1px #f0f0f0 solid;
18+
}
19+
20+
.mine-user-avatar {
21+
width: 150rpx;
22+
height: 150rpx;
23+
border-radius: 75rpx;
24+
margin-top: 100rpx;
25+
margin-bottom: 18rpx;
26+
border: 1px #fff solid;
27+
-moz-box-shadow: 0px 0px 13px #ccc;
28+
-webkit-box-shadow: 0px 0px 13px #ccc;
29+
box-shadow:0px 0px 13px #ccc;
30+
}
31+
32+
.mine-user-name {
33+
font-size: 36rpx;
34+
color: #333;
35+
}
36+
37+
.mine-order {
38+
border-top: 1px #f0f0f0 solid;
39+
border-bottom: 1px #f0f0f0 solid;
40+
margin-top: 30rpx;
41+
background: #fff;
42+
}
43+
44+
.mine-order-head {
45+
display: flex;
46+
flex-direction: row;
47+
margin-left: 30rpx;
48+
line-height: 100rpx;
49+
border-bottom: 1px #f0f0f0 solid;
50+
}
51+
52+
.mine-order-title {
53+
font-size: 36rpx;
54+
color: #222;
55+
}
56+
57+
.mine-all-order {
58+
font-size: 28rpx;
59+
color: #999;
60+
flex: 1;
61+
text-align: right;
62+
}
63+
64+
.mine-right-arrow {
65+
width: 32rpx;
66+
height: 32rpx;
67+
margin-top: 34rpx;
68+
margin-left: 10rpx;
69+
margin-right: 30rpx;
70+
}
71+
72+
.mine-order-status-list {
73+
display: flex;
74+
flex-direction: row;
75+
padding-left: 30rpx;
76+
padding-right: 30rpx;
77+
margin-top: 60rpx;
78+
margin-bottom: 60rpx;
79+
}
80+
81+
.mine-order-status-item {
82+
flex: 1;
83+
text-align: center;
84+
}
85+
86+
.mine-order-img-box {
87+
height: 70rpx;
88+
}
89+
90+
.mine-order-status-img {
91+
width: 60rpx;
92+
height: 60rpx;
93+
}
94+
95+
.mine-order-status-label {
96+
font-size: 30rpx;
97+
}
98+
99+
.mine-cart {
100+
margin-top: 30rpx;
101+
display: flex;
102+
flex-direction: row;
103+
padding-left: 30rpx;
104+
line-height: 100rpx;
105+
border-bottom: 1px #f0f0f0 solid;
106+
background: #fff;
107+
}
108+
109+
.mine-cart-title {
110+
font-size: 36rpx;
111+
color: #222;
112+
}
113+
114+
.mine-spacing {
115+
flex: 1;
116+
}
117+
118+
.mine-customer-service {
119+
margin-top: 30rpx;
120+
display: flex;
121+
flex-direction: row;
122+
padding-left: 30rpx;
123+
line-height: 100rpx;
124+
border-bottom: 1px #f0f0f0 solid;
125+
background: #fff;
126+
}
127+
128+
.mine-customer-service-title {
129+
font-size: 36rpx;
130+
color: #222;
131+
}

wexin/pages/product/product.js

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var config = require('../../config/config.js');
2-
var testinAB = require('../../sdk/sdk.js');
32

43
Page({
54
data: {
@@ -8,12 +7,17 @@ Page({
87
swiperHeight : '',
98
},
109
onPriceTap: function() {
11-
testinAB.track('pricebtnclick', 1, function() {
12-
wx.showModal({
13-
title: '提示',
14-
content: 'pricebtnclick 指标上报成功'
15-
})
16-
});
10+
11+
},
12+
onHomeTap() {
13+
wx.switchTab({
14+
url: '/pages/index/index'
15+
});
16+
},
17+
onCartTap() {
18+
wx.switchTab({
19+
url: '/pages/cart/cart'
20+
});
1721
},
1822
onLoad: function(options) {
1923
var self = this;
@@ -51,12 +55,5 @@ Page({
5155
});
5256
}
5357
});
54-
55-
var self = this;
56-
testinAB.getVars(function(vars) {
57-
self.setData({
58-
price: vars.get('price')
59-
});
60-
});
6158
}
6259
})

wexin/pages/product/product.wxml

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
</view>
4343
</scroll-view>
4444
<view class="tabbar">
45-
<view class="tabbar-item tabbar-home">
45+
<view bindtap="onHomeTap" class="tabbar-item tabbar-home">
4646
<view>
4747
<image class="home-icon" mode="aspectFit" src="../../icons/home.png"></image>
4848
</view>
4949
<text class="home-text">首页</text>
5050
</view>
51-
<view class="tabbar-item tabbar-cart">
51+
<view bindtap="onCartTap" class="tabbar-item tabbar-cart">
5252
<view>
5353
<image class="cart-icon" mode="aspectFit" src="../../icons/cart.png"></image>
5454
</view>

0 commit comments

Comments
 (0)