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
// pages/searchCircle/searchCircle.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
keyword: '',
circleList:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let keyword = options.keyword;
this.setData({
keyword: keyword
})
this.searchCircle()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
//获取输入内容
changeInput(e){
this.setData({
keyword: e.detail.value
})
},
//调取接口检索圈子
searchCircle(){
var that = this;
var config = wx.getStorageSync('config');
wx: wx.request({
url: app.url + 'ajax_get_search_circle_list.php',
data: {
unionId: config.unionId,
keyword: that.data.keyword
},
header: { 'content-type': 'application/json' },
method: 'GET',
dataType: 'json',
success: function (res) {
console.log(res)
if (res.statusCode == 200) {
that.setData({
circleList: res.data.result.circleList
})
}
},
fail: function (res) { },
complete: function (res) { },
})
},
//进圈
circleJoin(e) {
//获取圈子的id
let circleId = e.currentTarget.dataset['index']
//调用接口申请加入
var that = this;
var config = wx.getStorageSync('config');
wx: wx.request({
url: app.url + 'ajax_user_join_circle.php',
data: {
unionId: config.unionId,
circleId: circleId
},
header: { 'content-type': 'application/json' },
method: 'GET',
dataType: 'json',
success: function (res) {
console.log(res)
if (res.statusCode == 200) {
//参数错误
if (res.data.status == "NG") {
wx.showToast({
title: res.data.result.message,
icon: 'success',
duration: 1500
});
return;
}
//已经是会员 或者 加入成功
if (res.data.status == "MEMBER") {
//跳转到对应圈子首页
wx.navigateTo({
url: '../circleDetails/circleDetails?circleId=' + circleId
})
return;
}
//申请成功
if (res.data.status == "OK") {
//弹出消息,等待审核
wx.showToast({
title: res.data.result.message,
icon: 'success',
duration: 1500
});
return;
}
}
},
fail: function (res) { },
complete: function (res) { },
})
},
})