261 lines
7.4 KiB
JavaScript
261 lines
7.4 KiB
JavaScript
var t = getApp();
|
|
|
|
Page({
|
|
data: {
|
|
token: t.globalData.token,
|
|
page: {
|
|
page: 1,
|
|
rows: 5,
|
|
newsTypeId: "52baf515-304c-46f2-911a-355d889346f2",
|
|
showArea: "6dcbb862-4b48-4dca-aee1-d78fd76adc05",
|
|
areaCode: ""
|
|
},
|
|
noticeList: [],
|
|
serviceUrl: t.baseUrls.serviceUrl,
|
|
baseImgUrl: t.baseUrls.baseImgUrl,
|
|
cardInfo: {},
|
|
curCommunity: wx.getStorageSync("curCommunityName"),
|
|
sourceUrl: t.baseUrls.sourceUrl,
|
|
isBindPhone: !1,
|
|
cardTemplateDispatchId: ""
|
|
},
|
|
changeCommunity: function () {
|
|
wx.navigateTo({
|
|
url: "../community/changeCommunity"
|
|
});
|
|
},
|
|
joinCommunity: function () {
|
|
wx.navigateTo({
|
|
url: "../community/joinCommunity"
|
|
});
|
|
},
|
|
doCheckIn: function () {
|
|
wx.getStorageSync("curCommunityId") ? wx.getStorageSync("areaLevel") < 4 ? wx.showToast({
|
|
title: "请选择至社区级",
|
|
icon: "error"
|
|
}) : wx.navigateTo({
|
|
url: "../checkIn/checkIn"
|
|
}) : wx.showToast({
|
|
title: "请先选择社区",
|
|
icon: "none"
|
|
});
|
|
},
|
|
goTalk: function () {
|
|
wx.getStorageSync("curCommunityId") ? wx.getStorageSync("areaLevel") < 4 ? wx.showToast({
|
|
title: "请选择至社区级",
|
|
icon: "error"
|
|
}) : wx.navigateTo({
|
|
url: "../talk/talk"
|
|
}) : wx.showToast({
|
|
title: "请先选择社区",
|
|
icon: "none"
|
|
});
|
|
},
|
|
goReport: function () {
|
|
wx.getStorageSync("curCommunityId") ? wx.getStorageSync("areaLevel") < 4 ? wx.showToast({
|
|
title: "请选择至社区级",
|
|
icon: "error"
|
|
}) : wx.navigateTo({
|
|
url: "../report/report"
|
|
}) : wx.showToast({
|
|
title: "请先加入并选择社区",
|
|
icon: "none"
|
|
});
|
|
},
|
|
goServe: function () {
|
|
wx.getStorageSync("curCommunityId") ? wx.getStorageSync("areaLevel") < 4 ? wx.showToast({
|
|
title: "请选择至社区级",
|
|
icon: "error"
|
|
}) : wx.navigateTo({
|
|
url: "../serve/serve"
|
|
}) : wx.showToast({
|
|
title: "请先加入并选择社区",
|
|
icon: "none"
|
|
});
|
|
},
|
|
checkMoreNews: function () {
|
|
wx.navigateTo({
|
|
url: "../news/newsList"
|
|
});
|
|
},
|
|
getNotice: function () {
|
|
var e = this;
|
|
t.restAjax.get(t.restAjax.path(t.apis.getNewsList, [t.baseUrls.requestUrl]), {
|
|
page: 1,
|
|
rows: 5,
|
|
newsTypeId: "52baf515-304c-46f2-911a-355d889346f2",
|
|
showArea: "6dcbb862-4b48-4dca-aee1-d78fd76adc05",
|
|
areaCode: wx.getStorageSync("areaCode")
|
|
}, {
|
|
headers: {
|
|
token: t.globalData.token
|
|
}
|
|
}, function (t, a) {
|
|
e.setData({
|
|
noticeList: a.rows
|
|
});
|
|
}, function (e, t) {
|
|
console.log(t);
|
|
});
|
|
},
|
|
checkNewsDetail: function (e) {
|
|
var t = e.currentTarget.dataset.id;
|
|
wx.navigateTo({
|
|
url: "../news/newsDetail?newsId=" + t
|
|
});
|
|
},
|
|
doLogin: function () {
|
|
var _self = this;
|
|
wx.login({
|
|
success: function (a) {
|
|
t.restAjax.post(t.restAjax.path(t.apis.doLogin, [t.baseUrls.serviceUrl]), {
|
|
jsCode: a.code
|
|
}, {}, function (a, o) {
|
|
var n = o.data.split("_")[0];
|
|
var r = o.data.split("_")[1];
|
|
if (wx.setStorageSync("bindPhone", r), t.globalData.token = n, _self.setData({
|
|
token: t.globalData.token,
|
|
isBindPhone: 0 == r
|
|
}), "" != _self.data.cardId && null != _self.data.cardId ? (console.log(_self.data.cardId),
|
|
_self.getCard()) : _self.getDefaultCard(), _self.getNotice(), "" != _self.data.cardTemplateDispatchId && null != _self.data.cardTemplateDispatchId) {
|
|
var s = "/pages/mine/otherCard/othercarddetail?cardTemplateUseId=" + _self.data.cardTemplateDispatchId;
|
|
wx.navigateTo({
|
|
url: s
|
|
});
|
|
}
|
|
}, function (e, t) {
|
|
console.log(t);
|
|
});
|
|
}
|
|
});
|
|
},
|
|
getDictionary: function () {
|
|
t.restAjax.get(t.restAjax.path(t.apis.getDictionary, [t.baseUrls.serviceUrl, "5879c4fc-d357-44a1-9126-394af36ffe63"]), {}, {
|
|
headers: {
|
|
token: this.data.token
|
|
}
|
|
}, function (e, t) {
|
|
console.log(t);
|
|
}, function (e, t) {
|
|
console.log(t);
|
|
});
|
|
},
|
|
getCard: function () {
|
|
var e = this;
|
|
t.restAjax.get(t.restAjax.path(t.apis.getCardSyzlDetail, [t.baseUrls.requestUrl, e.data.cardId]), {}, {
|
|
headers: {
|
|
token: e.data.token
|
|
}
|
|
}, function (t, a) {
|
|
e.setData({
|
|
cardInfo: a
|
|
}), wx.setStorage({
|
|
data: a.areaCode,
|
|
key: "areaCode"
|
|
});
|
|
}, function (e, t) {
|
|
console.log(t);
|
|
});
|
|
},
|
|
getDefaultCard: function () {
|
|
var e = this;
|
|
t.restAjax.get(t.restAjax.path(t.apis.getDefaultSyzlCard, [t.baseUrls.requestUrl]), {}, {
|
|
headers: {
|
|
token: e.data.token
|
|
}
|
|
}, function (t, a) {
|
|
e.setData({
|
|
cardInfo: a
|
|
});
|
|
}, function (e, t) {
|
|
console.log(t);
|
|
});
|
|
},
|
|
getPhoneNumber: function (e) {
|
|
var a = this, o = e.detail.iv, n = e.detail.encryptedData;
|
|
console.log(n), n && (wx.showLoading({
|
|
title: "绑定中..."
|
|
}), t.http.put(t.urls.doUpdatePhone, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
iv: o,
|
|
encryptedData: n
|
|
}
|
|
}).then(function (e) {
|
|
wx.hideLoading({}), wx.setStorageSync("token", e.data.data), wx.setStorageSync("bindPhone", 0),
|
|
a.setData({
|
|
isBindPhone: !0
|
|
}), t.globalData.token = e.data.data, wx.showToast({
|
|
title: "绑定成功",
|
|
success: function (e) { }
|
|
});
|
|
}).catch(function (e) { }));
|
|
},
|
|
checkPermission: function () {
|
|
var e = this;
|
|
try {
|
|
var t = wx.getStorageSync("name"), a = wx.getStorageSync("userIcon");
|
|
t ? this.setData({
|
|
name: t,
|
|
userIcon: a
|
|
}) : wx.showModal({
|
|
title: "提示",
|
|
content: "小程序需要您微信头像以及昵称用于展示,请授权.",
|
|
showCancel: !1,
|
|
success: function (t) {
|
|
t.confirm && e.getUserProfile(3);
|
|
}
|
|
});
|
|
} catch (e) {
|
|
e = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(e);
|
|
console.log(e), wx.showToast({
|
|
title: "获取信息失败",
|
|
icon: "error"
|
|
});
|
|
}
|
|
},
|
|
getUserProfile: function (e) {
|
|
var a = this;
|
|
wx.getUserProfile({
|
|
desc: "获取微信头像以及昵称用于展示",
|
|
success: function (e) {
|
|
wx.setStorage({
|
|
data: e.userInfo.nickName,
|
|
key: "name"
|
|
}), wx.setStorage({
|
|
data: e.userInfo.avatarUrl,
|
|
key: "userIcon"
|
|
}), a.setData({
|
|
name: e.userInfo.nickName,
|
|
userIcon: e.userInfo.avatarUrl
|
|
}), t.globalData.userIcon = e.userInfo.avatarUrl, t.globalData.userInfo = e.userInfo;
|
|
},
|
|
fail: function (e) {
|
|
wx.showToast({
|
|
title: "获取个人信息失败",
|
|
icon: "error"
|
|
});
|
|
}
|
|
});
|
|
},
|
|
onLoad: function (e) {
|
|
e.cardTemplateDispatchId && this.setData({
|
|
cardTemplateDispatchId: e.cardTemplateDispatchId
|
|
});
|
|
this.doLogin();
|
|
this.checkPermission();
|
|
wx.setStorage({
|
|
data: "1",
|
|
key: "gridMiniId"
|
|
});
|
|
},
|
|
onShow: function () {
|
|
this.setData({
|
|
curCommunityName: wx.getStorageSync("curCommunityName") ? wx.getStorageSync("curCommunityName") : "切换社区",
|
|
curCommunityId: wx.getStorageSync("curCommunityId") ? wx.getStorageSync("curCommunityId") : "",
|
|
curCommunity: wx.getStorageSync("curCommunityName")
|
|
}, "page.areaCode", wx.getStorageSync("areaCode") ? wx.getStorageSync("areaCode") : "");
|
|
}
|
|
}); |