You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
481 lines
20 KiB
481 lines
20 KiB
2 years ago
|
"use strict";
|
||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
};
|
||
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
||
|
function step(op) {
|
||
|
if (f) throw new TypeError("Generator is already executing.");
|
||
|
while (_) try {
|
||
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
||
|
switch (op[0]) {
|
||
|
case 0: case 1: t = op; break;
|
||
|
case 4: _.label++; return { value: op[1], done: false };
|
||
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||
|
default:
|
||
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||
|
if (t[2]) _.ops.pop();
|
||
|
_.trys.pop(); continue;
|
||
|
}
|
||
|
op = body.call(thisArg, _);
|
||
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||
|
}
|
||
|
};
|
||
|
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
||
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
||
|
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
||
|
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
||
|
r[k] = a[j];
|
||
|
return r;
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
var rerquest_1 = require("../../config/rerquest");
|
||
|
var tools_1 = require("../../utils/tools");
|
||
|
var promise_wx_api_1 = require("../../utils/promise-wx-api");
|
||
|
var app = getApp();
|
||
|
Component({
|
||
|
properties: {},
|
||
|
data: {
|
||
|
iniLoaded: false,
|
||
|
isRefresh: false,
|
||
|
associationType: "my-group",
|
||
|
pageSize: 20,
|
||
|
mygroupPageNo: 1,
|
||
|
recommandgroupPageNo: 1,
|
||
|
allPageNo: 1,
|
||
|
myGroupList: [],
|
||
|
myGroupMore: false,
|
||
|
recommandGroupMore: false,
|
||
|
allGroupMore: false,
|
||
|
recommandGroupList: [],
|
||
|
allGroupList: [],
|
||
|
achieveList: [],
|
||
|
nomoreVisible: false,
|
||
|
noDataVisible: true,
|
||
|
loadMoreType: "loading",
|
||
|
loadMoreVisible: false,
|
||
|
showDialog: false,
|
||
|
visible: false,
|
||
|
completeInfoDialogVisible: false,
|
||
|
tabsList: [
|
||
|
{
|
||
|
type: "my-group",
|
||
|
name: "我的小组",
|
||
|
img: "../../assets/images/group/mine.png",
|
||
|
},
|
||
|
{
|
||
|
type: "all-group",
|
||
|
name: "所有小组",
|
||
|
img: "../../assets/images/group/suoyou.png",
|
||
|
},
|
||
|
{
|
||
|
type: "top-group",
|
||
|
name: "小组排名",
|
||
|
img: "../../assets/images/group/grail.png",
|
||
|
},
|
||
|
],
|
||
|
achieveTipsList: [],
|
||
|
},
|
||
|
lifetimes: {
|
||
|
ready: function () {
|
||
|
return __awaiter(this, void 0, void 0, function () {
|
||
|
return __generator(this, function (_a) {
|
||
|
switch (_a.label) {
|
||
|
case 0:
|
||
|
console.log("ready");
|
||
|
return [4, tools_1.doAfterLogin()];
|
||
|
case 1:
|
||
|
_a.sent();
|
||
|
app.globalData.previewImage = false;
|
||
|
return [2];
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
detached: function () {
|
||
|
},
|
||
|
},
|
||
|
methods: {
|
||
|
refreshData: function () {
|
||
|
console.log("刷新组首页数据", this.data.isRefresh);
|
||
|
this.selectComponent("#titleList").getInfo();
|
||
|
if (this.data.isRefresh)
|
||
|
return;
|
||
|
this.setData({
|
||
|
allPageNo: 1,
|
||
|
mygroupPageNo: 1,
|
||
|
recommandgroupPageNo: 1,
|
||
|
allGroupMore: false,
|
||
|
myGroupMore: false,
|
||
|
recommandGroupMore: false,
|
||
|
isRefresh: true,
|
||
|
});
|
||
|
this.getAchieveTips();
|
||
|
this.getMyAssociation();
|
||
|
this.getCommandAssociation();
|
||
|
this.getAllGroup();
|
||
|
console.log("刷新组数据", this.data.noDataVisible);
|
||
|
},
|
||
|
refreshRecommand: function () {
|
||
|
this.setData({
|
||
|
recommandgroupPageNo: 1,
|
||
|
recommandGroupMore: false,
|
||
|
isRefresh: true,
|
||
|
});
|
||
|
this.getCommandAssociation();
|
||
|
},
|
||
|
refreshAll: function () {
|
||
|
this.setData({
|
||
|
allPageNo: 1,
|
||
|
allGroupMore: false,
|
||
|
isRefresh: true,
|
||
|
});
|
||
|
this.getAllGroup();
|
||
|
},
|
||
|
closeDialog: function () {
|
||
|
this.setData({
|
||
|
visible: false,
|
||
|
});
|
||
|
},
|
||
|
onReachBottom: function () {
|
||
|
return __awaiter(this, void 0, void 0, function () {
|
||
|
var _a, myGroupMore, recommandGroupMore, allGroupMore, $ele;
|
||
|
return __generator(this, function (_b) {
|
||
|
this.setData({
|
||
|
loadMoreVisible: true,
|
||
|
loadMoreType: "loading",
|
||
|
});
|
||
|
_a = this.data, myGroupMore = _a.myGroupMore, recommandGroupMore = _a.recommandGroupMore, allGroupMore = _a.allGroupMore;
|
||
|
console.log("allpageno", this.data.allPageNo);
|
||
|
if (this.data.associationType === "my-group") {
|
||
|
console.log("onReachBottom my-group", myGroupMore, this.data.myGroupList);
|
||
|
if (myGroupMore) {
|
||
|
this.setData({
|
||
|
loadMoreType: "none",
|
||
|
});
|
||
|
return [2, false];
|
||
|
}
|
||
|
this.data.mygroupPageNo += 1;
|
||
|
this.getMyAssociation();
|
||
|
}
|
||
|
else if (this.data.associationType === "all-group") {
|
||
|
if (allGroupMore) {
|
||
|
this.setData({
|
||
|
loadMoreType: "none",
|
||
|
});
|
||
|
return [2, false];
|
||
|
}
|
||
|
this.setData({
|
||
|
allPageNo: this.data.allPageNo + 1,
|
||
|
});
|
||
|
this.getAllGroup();
|
||
|
}
|
||
|
else if (this.data.associationType === "top-group") {
|
||
|
$ele = this.selectComponent("#groupTop");
|
||
|
$ele.handleReachBottom();
|
||
|
}
|
||
|
return [2];
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
associationChange: function (e) {
|
||
|
var type = e.currentTarget.dataset.type;
|
||
|
this.setData({
|
||
|
associationType: type,
|
||
|
});
|
||
|
},
|
||
|
getCommandAssociationData: function (params) {
|
||
|
return rerquest_1.default({
|
||
|
method: "POST",
|
||
|
url: "resi/group/group/getrecommendgroup",
|
||
|
options: params,
|
||
|
ifToken: true,
|
||
|
});
|
||
|
},
|
||
|
getCommandAssociation: function () {
|
||
|
var _this = this;
|
||
|
var params = {
|
||
|
pageNo: this.data.recommandgroupPageNo,
|
||
|
pageSize: this.data.pageSize,
|
||
|
customerId: app.globalData.customerId,
|
||
|
gridId: app.globalData.gridId,
|
||
|
};
|
||
|
var _a = this.data, recommandGroupMore = _a.recommandGroupMore, isRefresh = _a.isRefresh;
|
||
|
var list = [];
|
||
|
this.getCommandAssociationData(params)
|
||
|
.then(function (res) {
|
||
|
console.log("推荐群列表", res);
|
||
|
if (res.code === 0) {
|
||
|
if (res.data.length === 20)
|
||
|
recommandGroupMore = false;
|
||
|
else
|
||
|
recommandGroupMore = true;
|
||
|
if (isRefresh)
|
||
|
list = __spreadArrays(res.data);
|
||
|
else
|
||
|
list = __spreadArrays(_this.data.recommandGroupList, res.data);
|
||
|
_this.setData({
|
||
|
recommandGroupMore: recommandGroupMore,
|
||
|
noDataVisible: false,
|
||
|
recommandGroupList: list,
|
||
|
isRefresh: false,
|
||
|
loadMoreVisible: true,
|
||
|
loadMoreType: "none",
|
||
|
});
|
||
|
}
|
||
|
})
|
||
|
.catch(function (err) {
|
||
|
_this.setData({
|
||
|
noDataVisible: false,
|
||
|
loadMoreType: "none",
|
||
|
});
|
||
|
console.log(err);
|
||
|
});
|
||
|
},
|
||
|
getMyAssociationData: function (params) {
|
||
|
return rerquest_1.default({
|
||
|
method: "POST",
|
||
|
url: "resi/group/group/getmygroupV2",
|
||
|
options: params,
|
||
|
ifToken: true,
|
||
|
});
|
||
|
},
|
||
|
updateWxuserInfoData: function (params) {
|
||
|
return rerquest_1.default({
|
||
|
method: "POST",
|
||
|
url: "epmetuser/user/updatewxuserinfo",
|
||
|
options: params,
|
||
|
ifToken: true,
|
||
|
});
|
||
|
},
|
||
|
getAllGroup: function () {
|
||
|
return __awaiter(this, void 0, void 0, function () {
|
||
|
var _a, allGroupMore, isRefresh, list, _b, _c, code, data, msg;
|
||
|
return __generator(this, function (_d) {
|
||
|
switch (_d.label) {
|
||
|
case 0:
|
||
|
this.setData({});
|
||
|
_a = this.data, allGroupMore = _a.allGroupMore, isRefresh = _a.isRefresh;
|
||
|
list = [];
|
||
|
return [4, promise_wx_api_1.wxRequestPost("resi/group/group/allgrouplist", {
|
||
|
gridId: app.globalData.gridId,
|
||
|
pageNo: this.data.allPageNo,
|
||
|
pageSize: this.data.pageSize,
|
||
|
}, {})];
|
||
|
case 1:
|
||
|
_b = _d.sent(), _c = _b.data.data, code = _c.code, data = _c.data, msg = _b.msg;
|
||
|
if (msg === "success") {
|
||
|
if (code === 0) {
|
||
|
if (data.length === 20)
|
||
|
allGroupMore = false;
|
||
|
else
|
||
|
allGroupMore = true;
|
||
|
if (isRefresh)
|
||
|
list = data;
|
||
|
else
|
||
|
list = __spreadArrays(this.data.allGroupList, data);
|
||
|
this.setData({
|
||
|
allGroupMore: allGroupMore,
|
||
|
allGroupList: list,
|
||
|
noDataVisible: false,
|
||
|
loadMoreVisible: true,
|
||
|
isRefresh: false,
|
||
|
loadMoreType: "none",
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
return [2];
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
getAchieveTips: function () {
|
||
|
return __awaiter(this, void 0, void 0, function () {
|
||
|
var _a, _b, code, data, msg;
|
||
|
return __generator(this, function (_c) {
|
||
|
switch (_c.label) {
|
||
|
case 0: return [4, promise_wx_api_1.wxRequestPost("resi/group/group/achievement", {
|
||
|
gridId: app.globalData.gridId,
|
||
|
}, {})];
|
||
|
case 1:
|
||
|
_a = _c.sent(), _b = _a.data.data, code = _b.code, data = _b.data, msg = _a.msg;
|
||
|
if (msg === "success") {
|
||
|
if (code === 0) {
|
||
|
this.setData({
|
||
|
achieveTipsList: data,
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
return [2];
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
handleToGroup: function (e) {
|
||
|
console.log("reeee", e);
|
||
|
var gid = e.currentTarget.dataset.gid;
|
||
|
wx.navigateTo({
|
||
|
url: "/subpages/group/pages/group/integral/integral?gid=" + gid,
|
||
|
});
|
||
|
},
|
||
|
createGroup: function () {
|
||
|
return __awaiter(this, void 0, void 0, function () {
|
||
|
var userRoleList;
|
||
|
return __generator(this, function (_a) {
|
||
|
switch (_a.label) {
|
||
|
case 0: return [4, tools_1.loginGrid()];
|
||
|
case 1:
|
||
|
_a.sent();
|
||
|
console.log(app.globalData.userRoleList);
|
||
|
userRoleList = app.globalData.userRoleList;
|
||
|
if (userRoleList.indexOf("warmhearted") >= 0 ||
|
||
|
userRoleList.indexOf("partymember") >= 0) {
|
||
|
wx.navigateTo({
|
||
|
url: "/pages/group/group/newGroup/newGroup",
|
||
|
});
|
||
|
}
|
||
|
else {
|
||
|
this.setData({
|
||
|
visible: true,
|
||
|
});
|
||
|
}
|
||
|
return [2];
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
confirm: function () {
|
||
|
return __awaiter(this, void 0, void 0, function () {
|
||
|
var _a, msg, data, that_1, params;
|
||
|
return __generator(this, function (_b) {
|
||
|
switch (_b.label) {
|
||
|
case 0: return [4, promise_wx_api_1.wxGetUserProfile({
|
||
|
desc: "用于完善居民信息",
|
||
|
})];
|
||
|
case 1:
|
||
|
_a = _b.sent(), msg = _a.msg, data = _a.data;
|
||
|
if (msg == "success") {
|
||
|
console.log(data.avatarUrl);
|
||
|
that_1 = this;
|
||
|
params = {
|
||
|
nickName: data.userInfo.nickName,
|
||
|
gender: data.userInfo.gender,
|
||
|
avatarUrl: data.userInfo.avatarUrl,
|
||
|
province: data.userInfo.province,
|
||
|
country: data.userInfo.country,
|
||
|
city: data.userInfo.city,
|
||
|
};
|
||
|
this.updateWxuserInfoData(params).then(function (res) {
|
||
|
that_1.setData({
|
||
|
visible: false,
|
||
|
});
|
||
|
wx.navigateTo({
|
||
|
url: "/subpages/mine/pages/register/communist/index?from=group_createGroup&success=/pages/group/group/newGroup/newGroup",
|
||
|
});
|
||
|
});
|
||
|
console.log("111");
|
||
|
}
|
||
|
else {
|
||
|
}
|
||
|
return [2];
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
confirm2: function () {
|
||
|
return __awaiter(this, void 0, void 0, function () {
|
||
|
var _a, msg, data, that_2, params;
|
||
|
return __generator(this, function (_b) {
|
||
|
switch (_b.label) {
|
||
|
case 0: return [4, promise_wx_api_1.wxGetUserProfile({
|
||
|
desc: "用于完善居民信息",
|
||
|
})];
|
||
|
case 1:
|
||
|
_a = _b.sent(), msg = _a.msg, data = _a.data;
|
||
|
if (data.userInfo) {
|
||
|
console.log(data);
|
||
|
that_2 = this;
|
||
|
params = {
|
||
|
nickName: data.userInfo.nickName,
|
||
|
gender: data.userInfo.gender,
|
||
|
avatarUrl: data.userInfo.avatarUrl,
|
||
|
province: data.userInfo.province,
|
||
|
country: data.userInfo.country,
|
||
|
city: data.userInfo.city,
|
||
|
};
|
||
|
this.updateWxuserInfoData(params).then(function (res) {
|
||
|
that_2.setData({
|
||
|
visible: false,
|
||
|
});
|
||
|
wx.navigateTo({
|
||
|
url: "/subpages/mine/pages/register/activist/index?from=group_createGroup&success=/pages/group/group/newGroup/newGroup",
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
else {
|
||
|
}
|
||
|
return [2];
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
getMyAssociation: function () {
|
||
|
var _this = this;
|
||
|
this.setData({
|
||
|
loadMoreVisible: false,
|
||
|
});
|
||
|
var params = {
|
||
|
pageNo: this.data.mygroupPageNo,
|
||
|
pageSize: this.data.pageSize,
|
||
|
customerId: app.globalData.customerId,
|
||
|
gridId: app.globalData.gridId,
|
||
|
};
|
||
|
var _a = this.data, myGroupMore = _a.myGroupMore, isRefresh = _a.isRefresh;
|
||
|
var list = [];
|
||
|
this.getMyAssociationData(params)
|
||
|
.then(function (res) {
|
||
|
console.log("我的群列表", res);
|
||
|
if (res.code === 0) {
|
||
|
if (res.data.length.length === 20)
|
||
|
myGroupMore = false;
|
||
|
else
|
||
|
myGroupMore = true;
|
||
|
if (isRefresh)
|
||
|
list = res.data;
|
||
|
else
|
||
|
list = __spreadArrays(_this.data.myGroupList, res.data);
|
||
|
_this.setData({
|
||
|
noDataVisible: false,
|
||
|
myGroupMore: myGroupMore,
|
||
|
myGroupList: list,
|
||
|
isRefresh: false,
|
||
|
loadMoreVisible: true,
|
||
|
loadMoreType: "none",
|
||
|
});
|
||
|
}
|
||
|
})
|
||
|
.catch(function (err) {
|
||
|
_this.setData({
|
||
|
noDataVisible: false,
|
||
|
loadMoreType: "none",
|
||
|
});
|
||
|
console.log(err);
|
||
|
});
|
||
|
},
|
||
|
},
|
||
|
});
|