/*!
* Bmob WeChat applet SDK
* http://www.bmob.cn
* Copyright Bmob, Inc.
* The Bmob WeChat applet SDK is freely distributable under the MIT license.
* (c) 2016-2050 Magic
*/
(function(root) {
var _ = require('underscore.js');
var Bmob = {};
Bmob.VERSION = "js0.0.1";
Bmob._ = _;
var EmptyConstructor = function() {};
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = Bmob;
}
exports.Bmob = Bmob;
} else {
root.Bmob = Bmob;
}
// Helper function to correctly set up the prototype chain, for subclasses.
// Similar to `goog.inherits`, but uses a hash of prototype properties and
// class properties to be extended.
var inherits = function(parent, protoProps, staticProps) {
var child;
// The constructor function for the new subclass is either defined by you
// (the "constructor" property in your `extend` definition), or defaulted
// by us to simply call the parent's constructor.
if (protoProps && protoProps.hasOwnProperty('constructor')) {
child = protoProps.constructor;
} else {
/** @ignore */
child = function() {
parent.apply(this, arguments);
};
}
// Inherit class (static) properties from parent.
Bmob._.extend(child, parent);
// Set the prototype chain to inherit from `parent`, without calling
// `parent`'s constructor function.
EmptyConstructor.prototype = parent.prototype;
child.prototype = new EmptyConstructor();
// Add prototype properties (instance properties) to the subclass,
// if supplied.
if (protoProps) {
Bmob._.extend(child.prototype, protoProps);
}
// Add static properties to the constructor function, if supplied.
if (staticProps) {
Bmob._.extend(child, staticProps);
}
// Correctly set child's `prototype.constructor`.
child.prototype.constructor = child;
// Set a convenience property in case the parent's prototype is
// needed later.
child.__super__ = parent.prototype;
return child;
};
// Set the server for Bmob to talk to.
Bmob.serverURL = "https://api.bmob.cn";
Bmob.fileURL = "http://file.bmob.cn";
// Check whether we are running in Node.js.
if (typeof(process) !== "undefined" && process.versions && process.versions.node) {
Bmob._isNode = true;
}
/**
* 初始化时需要调用这个函数。可以从bmob中获取所需的key
*
* @param {String} applicationId 你的 Application ID.
* @param {String} applicationKey 你的 restful api Key.
* @param {String} masterKey (optional) 你的 bmob Master Key.
*/
Bmob.initialize = function(applicationId, applicationKey, masterKey) {
Bmob._initialize(applicationId, applicationKey, masterKey);
};
/**
* Call this method first to set up authentication tokens for Bmob.
* This method is for Bmob's own private use.
* @param {String} applicationId Your Bmob Application ID.
* @param {String} applicationKey Your Bmob Application Key
*/
Bmob._initialize = function(applicationId, applicationKey, masterKey) {
Bmob.applicationId = applicationId;
Bmob.applicationKey = applicationKey;
Bmob.masterKey = masterKey;
Bmob._useMasterKey = true;
};
if (Bmob._isNode) {
Bmob.initialize = Bmob._initialize;
}
/**
* Returns prefix for localStorage keys used by this instance of Bmob.
* @param {String} path The relative suffix to append to it.
* null or undefined is treated as the empty string.
* @return {String} The full key name.
*/
Bmob._getBmobPath = function(path) {
if (!Bmob.applicationId) {
throw "You need to call Bmob.initialize before using Bmob.";
}
if (!path) {
path = "";
}
if (!Bmob._.isString(path)) {
throw "Tried to get a localStorage path that wasn't a String.";
}
if (path[0] === "/") {
path = path.substring(1);
}
return "Bmob/" + Bmob.applicationId + "/" + path;
};
/**
* Returns prefix for localStorage keys used by this instance of Bmob.
* @param {String} path The relative suffix to append to it.
* null or undefined is treated as the empty string.
* @return {String} The full key name.
*/
Bmob._getBmobPath = function(path) {
if (!Bmob.applicationId) {
throw "You need to call Bmob.initialize before using Bmob.";
}
if (!path) {
path = "";
}
if (!Bmob._.isString(path)) {
throw "Tried to get a localStorage path that wasn't a String.";
}
if (path[0] === "/") {
path = path.substring(1);
}
return "Bmob/" + Bmob.applicationId + "/" + path;
};
/**
* Returns the unique string for this app on this machine.
* Gets reset when localStorage is cleared.
*/
Bmob._installationId = null;
Bmob._getInstallationId = function() {
// See if it's cached in RAM.
if (Bmob._installationId) {
return Bmob._installationId;
}
// Try to get it from localStorage.
var path = Bmob._getBmobPath("installationId");
// Bmob._installationId = Bmob.localStorage.getItem(path);
wx.getStorage({
key: 'key',
success: function(res) {
Bmob._installationId = res.data;
console.log(res.data)
}
})
if (!Bmob._installationId || Bmob._installationId === "") {
// It wasn't in localStorage, so create a new one.
var hexOctet = function() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
};
Bmob._installationId = (hexOctet() + hexOctet() + "-" + hexOctet() + "-" + hexOctet() + "-" + hexOctet() + "-" + hexOctet() + hexOctet() + hexOctet());
wx.setStorage({
key: path,
data: Bmob._installationId
})
}
return Bmob._installationId;
};
Bmob._parseDate = function(iso8601) {
var regexp = new RegExp("^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})" + "T" + "([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})" + "(.([0-9]+))?" + "Z$");
var match = regexp.exec(iso8601);
if (!match) {
return null;
}
var year = match[1] || 0;
var month = (match[2] || 1) - 1;
var day = match[3] || 0;
var hour = match[4] || 0;
var minute = match[5] || 0;
var second = match[6] || 0;
var milli = match[8] || 0;
return new Date(Date.UTC(year, month, day, hour, minute, second, milli));
};
Bmob._ajax = function(method, url, data, success, error) {
var options = {
success: success,
error: error
};
var promise = new Bmob.Promise();
var dataObject = JSON.parse(data);
var error;
if (dataObject.category == "wechatApp") {
wx.uploadFile({
url: url,
filePath: dataObject.base64,
name: 'file',
header: {
"X-Bmob-SDK-Type": "wechatApp"
},
formData: dataObject,
success: function(res) {
console.log(res);
var data = JSON.parse(res.data);
promise.resolve(data, res.stat
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序实现的简单教务管理系统 (179个子文件)
20141023144127.gif 10KB
headshot.jpg 131KB
new.jpg 33KB
travel.jpg 31KB
share.jpg 27KB
review.jpg 26KB
delete.jpg 6KB
bgimg.jpg 6KB
bmob.js 244KB
underscore.js 59KB
storelist.js 8KB
tprogramme.js 8KB
bookorder.js 6KB
bishe.js 6KB
kechenhistory.js 6KB
moc.js 6KB
tclassschedule.js 5KB
newtittle.js 5KB
kechengsheji.js 5KB
personal-info.js 5KB
lists.js 4KB
login.js 3KB
details.js 3KB
signin.js 3KB
config.js 2KB
bookorderdetail.js 2KB
personal.js 2KB
newsdetail.js 2KB
kechengshejidetail.js 2KB
bishedetail.js 2KB
seach.js 2KB
备忘.js 2KB
findpsw.js 2KB
changePwd.js 2KB
storeprogram.js 2KB
news.js 1KB
util.js 971B
newsreview.js 941B
app.js 933B
callphone.js 908B
works.js 790B
store.js 698B
urls.js 407B
keshe1.js 335B
keshe.js 333B
makenew.js 242B
app.json 1KB
kechengsheji.json 56B
personal-info.json 54B
personal.json 51B
storelist.json 50B
news.json 50B
store.json 50B
changePwd.json 49B
bookorder.json 48B
bookorderdetail.json 48B
bishe.json 48B
kechenhistory.json 47B
tclassschedule.json 47B
keshe1.json 42B
storeprogram.json 42B
bishedetail.json 42B
keshe.json 42B
tprogramme.json 41B
lists.json 15B
kechengshejidetail.json 10B
newsdetail.json 10B
makenew.json 7B
works.json 2B
findpsw.json 2B
newsreview.json 2B
callphone.json 2B
login.json 2B
seach.json 2B
details.json 2B
signin.json 2B
artisan.png 34KB
nav3.png 32KB
nav2.png 32KB
nav4.png 32KB
nav1.png 32KB
baike.png 24KB
4.png 19KB
2.png 17KB
5.png 16KB
3.png 16KB
1.png 15KB
fail.png 15KB
bg_blue.png 14KB
headline.png 13KB
zc_app_default_photo.png 9KB
email.png 7KB
用户.png 5KB
首页 (1).png 4KB
首页.png 4KB
users.png 3KB
company.png 3KB
modify.png 3KB
hotdoor.png 3KB
feedback.png 3KB
共 179 条
- 1
- 2
资源评论
- 讯达网络2020-04-10有参考价值
- weixin_381719922019-06-04希望有用,谢谢分享
m0_37857151
- 粉丝: 58
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功