/*!
* 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 = "js3.6.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";
Bmob.socketURL = "https://api.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;
Bmob.serverURL = "https://api.bmobcloud.com";
};
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") {
const uploadTask = wx.uploadFile({
url: url,
filePath: dataObject.base64,
name: 'file',
header: {
"X-Bmob-SDK-Type": "wechatApp"
},
formData: dataObject,
success: function (res) {
没有合适的资源?快使用搜索试试~ 我知道了~
微信小程序demo-留言板(第八章作业)
共59个文件
js:10个
json:7个
wxss:4个
需积分: 0 0 下载量 191 浏览量
2024-05-14
15:25:27
上传
评论
收藏 190KB ZIP 举报
温馨提示
该demo只有部分功能完成!!
资源推荐
资源详情
资源评论
收起资源包目录
demo.zip (59个子文件)
demo
sitemap.json 191B
project.private.config.json 388B
pages
detail
detail.json 29B
detail.js 646B
detail.wxml 578B
detail.wxss 130B
index1
index1.json 29B
index1.wxss 863B
index1.wxml 3KB
index1.js 6KB
logs
logs.json 30B
logs.js 305B
logs.wxml 224B
logs.wxss 247B
.eslintrc.js 587B
app.json 411B
project.config.json 588B
app.js 137B
image
add.png 9KB
utils
bmobSocketIo.js 7KB
common.js 458B
underscore.js 59KB
bmob.js 261KB
util.js 481B
.git
index 2KB
HEAD 23B
refs
heads
master 41B
tags
objects
1e
bed4b432138b341bb0f60fa28acc80c590652c 396B
ca
02add20b581be471b8d17f887b8e8337070546 194B
0b
5dae680213a4cdc2fb0f5848396561250dbbe9 116B
e6
9de29bb2d1d6434b8b29ae775ad8c2e48c5391 15B
ae
b70ff793f3b42203d7921c822328f835d8f096 341B
76
4bc2ce26ab9b55a21cbb069dcf084a8418dffd 261B
10
fa70bec8e58648499843a426118aaa5a7f04bd 158B
9f
9938b73100be15f67dd4ba025ed9c2a37ab19a 135B
a4
6e321b7af0e354dafee56d6263381f616102fd 129B
11
5cc02b049fd21c82bc61a7200f51fcec66e528 334B
99
94ff7d24f54a4e0d34931317971ed0822bfc20 76B
33
f9d9e1dca09f6aeb68b3e39c243876ce5d240f 184B
85
cf1bfe79c718c4222c94fc090af60dcf29575d 168B
f6aac5ab16db728fa27cdf75c4ab2126b1105b 212B
a5
630abdeb6bead221718ccd19500e613580cdd2 66KB
b5
5b5a25411975f285b21a489b8ef5b6f6c325a6 44B
e2
a5a9eec924fd3bc6ddd0fc3c9130abf9c80a9a 134B
04
2e0295ae426d3ef7b0b3a37520b6206687dfe9 224B
4c
37342370d8f7e900d54f2f009805f829cfa31b 296B
6b
18cf146c4ea76883bee85f2a498599e17c40d6 138B
pack
e5
aae81626d3da679e75d0b21102b4bb40c850a1 63B
info
12
a208822c49a3bc210184b8277da80fa681bc3e 18KB
2b
1e7b32dbcd8f5c6d2036d1ef1097b3b11eb0d9 304B
06
c6fc9ce35b7d02e031b1e8f4636147321dedc1 161B
description 73B
info
exclude 113B
logs
HEAD 162B
refs
heads
master 162B
hooks
README.sample 177B
config 130B
app.wxss 194B
.gitignore 159B
共 59 条
- 1
资源评论
夏太热小小夏
- 粉丝: 234
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功