-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsocialarea.js
171 lines (147 loc) · 3.53 KB
/
socialarea.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
clientWidth: 0,
clientHeight: 0,
// tab切换
currentTab: 0,
// 好友下拉切换
content: [],
px: [],
pxopen: false,
pxshow: false,
active: true,
imgUrl: "../../images/+.png"
},
//事件处理函数
bindViewTap: function () {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
var that = this;
// 好友下拉切换
this.setData({
px: ['>默认排序', '>离我最近']
});
wx.getSystemInfo({
success: function (res) {
that.setData({
clientHeight: res.windowHeight
});
}
});
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
})
}
})
}
},
// 好友下拉切换
listpx: function (e) {
console.log(e)
if (this.data.pxopen) {
this.setData({
pxopen: false,
pxshow: false,
active: true,
imgUrl: "../../images/+.png"
})
} else {
this.setData({
content: this.data.px,
pxopen: true,
pxshow: false,
active: false,
imgUrl: "../../images/+2.png"
})
}
console.log(e.target)
},
getUserInfo: function (e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
},
bindChange: function (e) {
var that = this;
that.setData({ currentTab: e.detail.current });
},
swichNav: function (e) {
var that = this;
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currentTab: e.target.dataset.current
})
}
},
/*pinglun*/
formSubmit: function (e) {
console.log(0);
wx.showToast({
title: '评论成功',
icon: 'success',
duration: 3000
})
var that = this;
var liuyantext = e.detail.value.liuyantext; //获取表单所有name=liuyantext的值
console.log('视频id' + that.data.id);
console.log('留言number:' + that.data.number);
wx.request({
url: 'https://xxxx/comment',
data: {
content: liuyantext,
number: that.data.number,
id: that.data.id
},
header: {
'Content-Type': 'application/json'
},
success: function (res) {
// console.log(res.data)
that.setData({
showOrHidden: true,
re: res.data,
keyValue: '',
photo2: res.data.result.comment.photo,
nickname2: res.data.result.comment.nickname,
date2: res.data.result.comment.date,
comment2: res.data.result.comment.comment
})
wx.hideToast();
console.log(res);
}
})
},
})