代码拉取完成,页面将自动刷新
同步操作将从 Mamba/答题小程序 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// app.js
var Apis = require('utils/apis.js');
App({
onLaunch() {
this.initAPI();
wx.Apis = Apis;
//请求公告
wx.Apis.api.getConfigValue('notice',(code, data) => {
wx.setStorageSync('notice', data.value)
});
//请求配置
wx.Apis.api.getConfigValue('isWrite',(code, data) => {
wx.setStorageSync('isWrite', data.value)
});
wx.Apis.api.getConfigValue('checkUser',(code, data) => {
wx.setStorageSync('checkUser', data.value)
});
wx.Apis.api.getConfigValue('useLearn',(code, data) => {
wx.setStorageSync('useLearn', data.value)
});
var that = this;
var openid = wx.getStorageSync('openid')
if (openid == '' || openid == undefined) {
wx.showLoading({
title: '',
})
wx.login({
success(res) {
if (res.code) {
console.log(res.code)
wx.Apis.login.login(res.code, (code, data) => {
console.log(data);
wx.Apis.setUid(data.openid); //openid
wx.Apis.set('openid', data.openid);
wx.setStorageSync('userInfo', data);
wx.hideLoading({
success: (res) => {},
})
});
}
},fail(){
wx.hideLoading({
success: (res) => {},
})
}
});
}else {
Apis.login.index((code, data) => {
console.log(data);
Apis.setUid(data.openid); //openid
wx.setStorageSync('userInfo', data)
});
}
},
globalData: {
userInfo: null,
mainActiveIndex:0,
bgmUrl: 'https://mamba-blog-images.oss-cn-shanghai.aliyuncs.com/5c8a08dc4956424741.mp3'
},
initAPI() {
var cloudCaller = function (url,oper,params, callback) {
// console.log(url)
var header = {
'Content-Type': 'application/json'
};
wx.request({
url,
method: oper,
data: params,
header,
success: function (res) {
try {
wx.stopPullDownRefresh();
} catch (e) {}
callback(res.statusCode == 200 ? null : res, res.data);
},
fail: function (err) {
try {
wx.stopPullDownRefresh();
} catch (e) {}
callback(err);
}
});
};
Apis.init(cloudCaller);
},
saveInfo: function(e,t,n){
wx.getStorage({
key: e + "" + t,
success: function(e){
var t = e.data;
getApp().info = !1;
for (var i = 0; i < t.length; i++) if (t[i][Object.keys(t[i]).toString()].indexOf(n) > -1) return console.log(t[i][Object.keys(t[i]).toString()].indexOf(n) > -1),
void (getApp().info = !0);
}
});
},
setIdsStroage: function (e, t, n, i) {
wx.getStorage({
key: e + "" + t,
success: function (o) {
for (var s = o.data, r = [], c = 0; c < s.length; c++) r.push(Object.keys(s[c]).toString());
console.log(r)
if (r.indexOf(n.toString()) > -1)
for (c = 0; c < s.length; c++) Object.keys(s[c]).indexOf(n) > -1 && -1 == s[c][n].indexOf(i) && s[c][n].push(i);
else {
var a = {};
a[n] = [], a[n].push(i), s.push(a);
}
wx.setStorage({
key: e + "" + t,
data: s
});
}, fail: function () {
var o = [], s = {};
s[n] = [], s[n].push(i), o.push(s), wx.setStorage({
key: e + "" + t,
data: o
});
}
})
},
removeids: function(e,c,n) {
wx.getStorage({
key: e + "" + c,
success: function (t) {
for (var i = t.data, o = 0; o < i.length; o++) if (i[o][Object.keys(i[o]).toString()].indexOf(n) > -1) {
var s = i[o][Object.keys(i[o]).toString()].indexOf(n);
i[o][Object.keys(i[o]).toString()].splice(s, 1), 0 == i[o][Object.keys(i[o]).toString()].length && i.splice(o, 1);
}
wx.setStorage({
key: e + "" + c,
data: i
});
}
});
},
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。