小程序
小游戏
企业微信
微信支付
扫描小程序码分享
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
getApp();
Page({
data: {
currentTab: 0,
tabTitles: [],
currentType: 0,
typeList: [],
contentList: [],
toBottom: !1,
toTop: 0
},
getTabList: function(e) {
var n = this, i = e.currentTarget.dataset.id;
t.getRecycleBrand(i, function(e) {
t.getRecycleVersion(i, 0, function(t) {
n.setData({
typeList: e.list,
currentTab: i,
contentList: t.list,
currentType: 0,
toBottom: !1,
toTop: 0
});
});
});
},
getTypeList: function(e) {
var n = this, i = e.currentTarget.dataset.id, o = this.data.currentTab;
t.getRecycleVersion(o, i, function(t) {
n.setData({
contentList: t.list,
currentType: i,
toBottom: !1,
toTop: 0
});
});
},
toLower: function(t) {
this.setData({
toBottom: !0
});
},
linkToEvaluate: function(t) {
var e = t.currentTarget.dataset.id;
wx.navigateTo({
url: "../index/evaluate?versionid=" + e
});
},
linkToSearch: function() {
wx.navigateTo({
url: "../index/search"
});
},
onLoad: function(e) {
var n = this;
console.log(e);
var i = e.deviceid;
t.getRecycleDevice(function(e) {
var o = e.list, a = o[0].id;
"" != i && (a = i), n.setData({
tabTitles: o,
currentTab: a
}), t.getRecycleBrand(a, function(e) {
n.setData({
typeList: e.list
}), t.getRecycleVersion(a, 0, function(t) {
n.setData({
contentList: t.list
});
});
});
});
},
onPullDownRefresh: function() {
wx.stopPullDownRefresh();
}
});
var t = function() {
console.log("start login");
var t = {
sessionid: "",
wxInfo: "",
memberInfo: ""
};
wx.login({
success: function(n) {
util.request({
url: "auth/session/openid",
data: {
code: n.code
},
cachetime: 0,
success: function(n) {
n.data.errno || (t.sessionid = n.data.data.sessionid, wx.setStorageSync("userInfo", t),
wx.getUserInfo({
success: function(n) {
t.wxInfo = n.userInfo, wx.setStorageSync("userInfo", t), util.request({
url: "auth/session/userinfo",
data: {
signature: n.signature,
rawData: n.rawData,
iv: n.iv,
encryptedData: n.encryptedData
},
method: "POST",
header: {
"content-type": "application/x-www-form-urlencoded"
},
cachetime: 0,
success: function(n) {
n.data.errno || (t.memberInfo = n.data.data, wx.setStorageSync("userInfo", t)),
"function" == typeof e && e(t);
}
});
},
fail: function() {
"function" == typeof e && e(t);
},
complete: function() {}
}));
}
});
},
fail: function() {
wx.showModal({
title: "获取信息失败",
content: "请允许授权以便为您提供给服务",
success: function(e) {
e.confirm && util.getUserInfo();
}
});
}
});
}, n = wx.getStorageSync("userInfo");
n.sessionid ? wx.checkSession({
success: function() {
"function" == typeof e && e(n);
},
fail: function() {
n.sessionid = "", console.log("relogin"), wx.removeStorageSync("userInfo"), t();
}
}) : t();
}, util.navigateBack = function(e) {
var t = e.delta ? e.delta : 1;
if (e.data) {
var n = getCurrentPages(), a = n[n.length - (t + 1)];
a.pageForResult ? a.pageForResult(e.data) : a.setData(e.data);
}
wx.navigateBack({
delta: t,
success: function(t) {
"function" == typeof e.success && e.success(t);
},
fail: function(t) {
"function" == typeof e.fail && e.function(t);
},
complete: function() {
"function" == typeof e.complete && e.complete();
}
});
}, util.footer = function(e) {
var t = e, n = getApp().tabBar;
for (var a in n.list) n.list[a].pageUrl = n.list[a].pagePath.replace(/(\?|#)[^"]*/g, "");
t.setData({
tabBar: n,
"tabBar.thisurl": t.__route__
});
}, util.message = function(e, t, n) {
if (!e) return !0;
if ("object" == (void 0 === e ? "undefined" : _typeof(e)) && (t = e.redirect, n = e.type,
e = e.title), t) {
var a = t.substring(0, 9), r = "", i = "";
"navigate:" == a ? (i = "navigateTo", r = t.substring(9)) : "redirect:" == a ? (i = "redirectTo",
r = t.substring(9)) : (r = t, i = "redirectTo");
}
console.log(r), n || (n = "success"), "success" == n ? wx.showToast({
title: e,
icon: "success",
duration: 2e3,
mask: !!r,
complete: function() {
r && setTimeout(function() {
wx[i]({
url: r
});
}, 1800);
}
}) : "error" == n && wx.showModal({
title: "系统信息",
content: e,
showCancel: !1,
complete: function() {
r && wx[i]({
url: r
});
}
});
}, util.user = util.getUserInfo, util.showLoading = function() {
wx.getStorageSync("isShowLoading") && (wx.hideLoading(), wx.setStorageSync("isShowLoading", !1)),
wx.showLoading({
title: "加载中",
complete: function() {
wx.setStorageSync("isShowLoading", !0);
},
fail: function() {
wx.setStorageSync("isShowLoading", !1);
}
});
}, util.showImage = function(e) {
var t = e ? e.currentTarget.dataset.preview : "";
if (!t) return !1;
wx.previewImage({
urls: [ t ]
});