作者 朱振飞

测试

//app.js
import md5 from 'utils/md5.js';
App({
post: function(url, data) {
wx.showNavigationBarLoading()
wx.showLoading({
title: '加载中',
})
var promise = new Promise((resolve, reject) => {
let that = this;
let postData = data;
let baseUrl = 'https://insurance.w.broteam.cn/';
wx.request({
url: baseUrl + url,
data: postData,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: function(res) {
resolve(res)
wx.hideLoading()
wx.hideNavigationBarLoading()
},
fail: function(e) {
reject('');
wx.hideLoading()
wx.hideNavigationBarLoading()
wx.showModal({
title: '',
content: res.data.msg,
showCancel: false
})
}
})
});
return promise;
console.log(promise)
},
formCollect(id) {
let url = 'sign/formid'
let params = {
formid: id,
openid: wx.getStorageSync('openId')
}
this.post(url, params).then((res) => {
console.log(res)
}).catch((errMsg) => {
})
},
nowDate() {
let date = new Date();
let month = date.getMonth() + 1;
let day = date.getDate();
return date.getFullYear() + '-' + (month > 9 ? month : ('0' + month)) + '-' + (day > 9 ? day : ('0' + day));
},
initDate(a) {
let date1 = new Date();
let time1 = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate();
let date2 = new Date(date1);
date2.setDate(date1.getDate() + a);
let time2 = date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate();
return time2;
},
// 数组移除指定元素
arryRemove(arr, item) {
return arr.filter(function(ele) {
return ele != item;
})
},
strTime(strtime) {
let str = 'bronet' + strtime + 'beijing'
return md5(md5(str))
},
globalData: {
userInfo: null,
OpenId: '', //用户openid
UserId: '', //用户userid
UserType: '', //用户类型(2为普通会员,3为顾问,4为推广)
checkstatus: '', //分享参数(0为无分享参数,1为保单分享,2为注册分享,3为文章分享)
UserStatus: '', //用户状态(1初次登录需要授权操作,2多次登录不需要授权)
PublishId: '', //如果是保单分享返回保单id
NewsId: '', //如果是文章分享返回文章id
temp_UserType:'',
user_index:''
}
})
\ No newline at end of file
{
"pages": [
"pages/start/start",
"pages/index/verigyCode/verigyCode",
"pages/index/summaryList2/summaryList2",
"pages/index/register/register",
"pages/about/about",
"pages/index/personalPolicyList/personalPolicyList",
"pages/index/agreement/agreement",
"pages/index/browseRecordDetail/browseRecordDetail",
"pages/index/consultantList/consultantList",
"pages/index/periodicReviews/periodicReviews",
"pages/index/CustomerManagement/CustomerManagement",
"pages/index/ArticleDetails/ArticleDetails",
"pages/index/reportList/reportList",
"pages/index/reportList2/reportList2",
"pages/index/editProfile/editProfile",
"pages/index/editProfile2/editProfile2",
"pages/index/policyList/policyList",
"pages/index/policyListDetail/policyListDetail",
"pages/index/policyManage/policyManage",
"pages/index/addListDetail/addListDetail",
"pages/index/personInfo/personInfo",
"pages/index/addNewFamily/addNewFamily",
"pages/index/smartRemind/smartRemind",
"pages/index/VipRecharge/VipRecharge",
"pages/index/twoCode/twoCode",
"pages/index/share/share",
"pages/index/inviteList/inviteList",
"pages/index/payWay/payWay",
"pages/index/addLog/addLog",
"pages/index/remind/remind",
"pages/index/summaryList/summaryList",
"pages/index/learnShare/learnShare",
"pages/index/EntryInformation2/EntryInformation2",
"pages/index/EntryInformation/EntryInformation",
"pages/index/Program/Program",
"pages/index/Suggest/Suggest",
"pages/index/articleBrowseRecord/articleBrowseRecord",
"pages/index/browseRecord/browseRecord",
"pages/index/TB/TB",
"pages/index/index",
"pages/personalCenter/personalCenter"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#0286FF",
"navigationBarTitleText": "保单体检专家",
"navigationBarTextStyle": "white"
},
"tabBar": {
"color": "#666666",
"selectedColor": "#487AFF",
"borderStyle": "black",
"backgroundColor": "#fff",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "/images/nav01@2x.png",
"selectedIconPath": "/images/nav02@2x.png"
},
{
"pagePath": "pages/about/about",
"text": "关于",
"iconPath": "/images/nav03@2x.png",
"selectedIconPath": "/images/nav04@2x.png"
},
{
"pagePath": "pages/personalCenter/personalCenter",
"text": "我的",
"iconPath": "/images/nav05@2x.png",
"selectedIconPath": "/images/nav06@2x.png"
}
]
}
}
\ No newline at end of file
.no_data {
color: #999;
font-size: 36rpx;
text-align: center;
width: 100%;
height: 100%;
position: fixed;
left: 0;
top: 0;
display: flex;
align-items: center;
justify-content: center;
}
button {
border-radius: 0;
}
button::after {
border: 0;
border-radius: 0;
}
/* iconfont */
@font-face {
font-family: 'iconfont'; /* project id 926819 */
src: url('//at.alicdn.com/t/font_926819_0pzhvmpbjahd.eot');
src: url('//at.alicdn.com/t/font_926819_0pzhvmpbjahd.eot?#iefix') format('embedded-opentype'),
url('//at.alicdn.com/t/font_926819_0pzhvmpbjahd.woff2') format('woff2'),
url('//at.alicdn.com/t/font_926819_0pzhvmpbjahd.woff') format('woff'),
url('//at.alicdn.com/t/font_926819_0pzhvmpbjahd.ttf') format('truetype'),
url('//at.alicdn.com/t/font_926819_0pzhvmpbjahd.svg#iconfont') format('svg');
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-chongzhi:before {
content: "\e606";
}
.icon-bi:before {
content: "\e60a";
}
.icon-renzheng:before {
content: "\e646";
}
.icon-anquan:before {
content: "\e63c";
}
.icon-listpress:before {
content: "\e627";
}
.icon-xiala1:before {
content: "\e61c";
}
.icon-baodanyuhetong:before {
content: "\e642";
}
.icon-shu:before {
content: "\e645";
}
.icon-fenxiang2:before {
content: "\e620";
}
.icon-fangxingxuanzhongfill:before {
content: "\e721";
}
.icon-bianji:before {
content: "\e6b4";
}
.icon-zhaoxiangji1:before {
content: "\e663";
}
.icon-xuanzhong2:before {
content: "\e62b";
}
.icon-guanyuwomen:before {
content: "\e61e";
}
.icon-ren-copy:before {
content: "\e600";
}
.icon-xuanzhong:before {
content: "\e61a";
}
.icon-artboard61:before {
content: "\e788";
}
.icon-jinru:before {
content: "\e618";
}
.icon-kehu:before {
content: "\e613";
}
.icon-jiating1:before {
content: "\e81d";
}
.icon-wuuiconxiangjifangda:before {
content: "\e623";
}
.icon-guwen:before {
content: "\e61d";
}
.icon-tianjia:before {
content: "\e648";
}
.icon-xiala:before {
content: "\e619";
}
.icon-icon-test:before {
content: "\e72e";
}
.icon-fangkuang:before {
content: "\e629";
}
.icon-jiating:before {
content: "\e73d";
}
.icon-jiaoyijilu:before {
content: "\e638";
}
.icon-jinbi:before {
content: "\e672";
}
.icon-bianji1:before {
content: "\e68a";
}
.icon-mingdanguanli:before {
content: "\e658";
}
.icon-renzheng1:before {
content: "\e62a";
}
.icon-dkw_wode-:before {
content: "\e60e";
}
.icon-guanbi2:before {
content: "\e60f";
}
.icon-wenjian:before {
content: "\e67d";
}
.icon-xuanzhongyuandian:before {
content: "\e624";
}
.icon-sousuo:before {
content: "\e617";
}
.icon-xuanze:before {
content: "\e6c3";
}
.icon-sousuo1:before {
content: "\e632";
}
.icon-yuan:before {
content: "\e622";
}
.icon-YDUI-naozhong:before {
content: "\e65d";
}
.icon-ren:before {
content: "\e6d9";
}
.icon-ziliao:before {
content: "\e603";
}
.icon-kehuguanli-copy-copy:before {
content: "\e63a";
}
.icon-add:before {
content: "\e604";
}
.icon-baodanxinxi:before {
content: "\e602";
}
.icon-hengxian1:before {
content: "\e626";
}
.icon-riqi:before {
content: "\ea1a";
}
.icon-tijian:before {
content: "\e605";
}
.icon-hengxian:before {
content: "\e657";
}
.icon-gouwuche:before {
content: "\e609";
}
.icon-yaoqing:before {
content: "\e60b";
}
.icon-guanbi:before {
content: "\e621";
}
.icon-xiazai:before {
content: "\e625";
}
.icon-fenxiang:before {
content: "\e62e";
}
.icon-xuexi:before {
content: "\e61b";
}
.icon-baogao:before {
content: "\e639";
}
.icon-weixinzhifu:before {
content: "\e647";
}
.icon-dianhua:before {
content: "\e67c";
}
.icon-xiugai:before {
content: "\e607";
}
.icon-xuanzhong1:before {
content: "\e61f";
}
.icon-guanli:before {
content: "\e6e3";
}
.icon-tixian:before {
content: "\e62d";
}
.icon-shang:before {
content: "\e611";
}
.icon-rizhi:before {
content: "\e614";
}
.icon-baogao1:before {
content: "\e62f";
}
.icon-jisuanqi:before {
content: "\e608";
}
.icon-jiatingzhanghu:before {
content: "\e615";
}
.icon-shuoming:before {
content: "\e633";
}
.icon-nav:before {
content: "\e601";
}
.icon-xuanzhongkuang:before {
content: "\e628";
}
.icon-ling:before {
content: "\e8bf";
}
.icon-dianhua2:before {
content: "\e649";
}
.icon-fangan:before {
content: "\e60c";
}
.icon-fenxiang1:before {
content: "\e634";
}
.icon-gray-crown:before {
content: "\e60d";
}
.icon-shanchu1:before {
content: "\e616";
}
.icon-kakou:before {
content: "\e660";
}
.icon-shezhi:before {
content: "\e610";
}
.icon-jianyi:before {
content: "\e696";
}
.icon-zhuanfa:before {
content: "\e783";
}
.icon-shanchu:before {
content: "\e67b";
}
.icon-danjiantou:before {
content: "\e612";
}
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true,
"autoAudits": false
},
"compileType": "miniprogram",
"libVersion": "2.4.0",
"appid": "wxac365079a43a66bb",
"projectname": "%E5%AE%B6%E5%BA%AD%E4%BF%9D%E9%99%A91",
"debugOptions": {
"hidedInDevtools": []
},
"isGameTourist": false,
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": [
{
"id": 0,
"name": "保单添加",
"pathName": "pages/index/addListDetail/addListDetail",
"query": "",
"scene": null
},
{
"id": -1,
"name": "保单体检",
"pathName": "pages/index/periodicReviews/periodicReviews",
"query": ""
},
{
"id": 2,
"name": "保单体检",
"pathName": "pages/index/periodicReviews/periodicReviews",
"query": "allinfo={\"family_id\":128,\"warn_time\":0,\"warn_status\":0,\"infor\":2,\"users\":[{\"family_id\":128,\"id\":241,\"name\":\"测试\",\"family_role\":\"家住\",\"user_family\":1,\"cid\":413,\"key_status\":0},{\"family_id\":128,\"id\":242,\"name\":\"ceshi\",\"family_role\":\"haiz\",\"user_family\":0,\"cid\":413,\"key_status\":0}]}"
},
{
"id": -1,
"name": "个人信息录入",
"pathName": "pages/index/EntryInformation/EntryInformation",
"query": ""
},
{
"id": 4,
"name": "编辑保单",
"pathName": "pages/index/addListDetail/addListDetail",
"query": "def_id=105&inforid=68&FamilyId=53",
"scene": null
},
{
"id": -1,
"name": "方案预设",
"pathName": "pages/index/Program/Program",
"query": ""
},
{
"id": -1,
"name": "center",
"pathName": "pages/personalCenter/personalCenter",
"query": ""
},
{
"id": -1,
"name": "保单汇总表",
"pathName": "pages/index/summaryList/summaryList",
"query": "allinfo={\"family_id\":130,\"warn_time\":0,\"warn_status\":0,\"infor\":1,\"users\":[{\"family_id\":130,\"id\":245,\"name\":\"ceshi\",\"family_role\":\"dsfs\",\"user_family\":1,\"cid\":413,\"key_status\":0}]}"
},
{
"id": -1,
"name": "提醒和跟踪",
"pathName": "pages/index/remind/remind",
"query": "cid=5&mainid=127",
"scene": null
}
]
}
}
}
\ No newline at end of file
function withData(param) {
return param < 10 ? '0' + param : '' + param;
}
function getLoopArray(start, end) {
var start = start || 0;
var end = end || 1;
var array = [];
for (var i = start; i <= end; i++) {
array.push(withData(i));
}
return array;
}
function getMonthDay(year, month) {
var flag = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0), array = null;
switch (month) {
case '01':
case '03':
case '05':
case '07':
case '08':
case '10':
case '12':
array = getLoopArray(1, 31)
break;
case '04':
case '06':
case '09':
case '11':
array = getLoopArray(1, 30)
break;
case '02':
array = flag ? getLoopArray(1, 29) : getLoopArray(1, 28)
break;
default:
array = '月份格式不正确,请重新输入!'
}
return array;
}
function getNewDateArry() {
// 当前时间的处理
var newDate = new Date();
var year = withData(newDate.getFullYear()),
mont = withData(newDate.getMonth() + 1),
date = withData(newDate.getDate()),
hour = withData(newDate.getHours()),
minu = withData(newDate.getMinutes()),
seco = withData(newDate.getSeconds());
return [year, mont, date, hour, minu, seco];
}
function dateTimePicker(startYear, endYear, date) {
// 返回默认显示的数组和联动数组的声明
var dateTime = [], dateTimeArray = [[], [], [], [], [], []];
var start = startYear || 1978;
var end = endYear || 2100;
// 默认开始显示数据
var defaultDate = date ? [...date.split(' ')[0].split('-'), ...date.split(' ')[1].split(':')] : getNewDateArry();
// 处理联动列表数据
/*年月日 时分秒*/
dateTimeArray[0] = getLoopArray(start, end);
dateTimeArray[1] = getLoopArray(1, 12);
dateTimeArray[2] = getMonthDay(defaultDate[0], defaultDate[1]);
dateTimeArray[3] = getLoopArray(0, 23);
dateTimeArray[4] = getLoopArray(0, 59);
dateTimeArray[5] = getLoopArray(0, 59);
dateTimeArray.forEach((current, index) => {
dateTime.push(current.indexOf(defaultDate[index]));
});
return {
dateTimeArray: dateTimeArray,
dateTime: dateTime
}
}
module.exports = {
dateTimePicker: dateTimePicker,
getMonthDay: getMonthDay
}
\ No newline at end of file
/*
* 小程序MD5加密算法封装
* +-----------------------------------------------------
* Author: 武当山道士
* Created: 2018-01-06
* Md5 Lib Source: http://cdn.bootcss.com/blueimp-md5/1.1.0/js/md5.js
* Tips: js库文件改装,加密算法没动,我只是封装了一下,便于小程序调用
* Thanks: 感谢js库文件作者 Sebastian Tschan 的辛勤付出
* +-----------------------------------------------------
* Usage:
*
* 引入(比如index.js页面引入md5.js):
* //pages/index.js
* import md5 from 'utils/md5.js';
*
* 调用base64MD5加密:
* var encryptedStr = md5('需要加密的字符串');
*/
function safe_add(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF),
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}
function md5_ff(a, b, c, d, x, s, t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binl_md5(x, len) {
/* append padding */
x[len >> 5] |= 0x80 << (len % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var i, olda, oldb, oldc, oldd,
a = 1732584193,
b = -271733879,
c = -1732584194,
d = 271733878;
for (i = 0; i < x.length; i += 16) {
olda = a;
oldb = b;
oldc = c;
oldd = d;
a = md5_ff(a, b, c, d, x[i], 7, -680876936);
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i], 20, -373897302);
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
d = md5_hh(d, a, b, c, x[i], 11, -358537222);
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i], 6, -198630844);
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return [a, b, c, d];
}
/*
* Convert an array of little-endian words to a string
*/
function binl2rstr(input) {
var i,
output = '';
for (i = 0; i < input.length * 32; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
}
return output;
}
/*
* Convert a raw string to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binl(input) {
var i,
output = [];
output[(input.length >> 2) - 1] = undefined;
for (i = 0; i < output.length; i += 1) {
output[i] = 0;
}
for (i = 0; i < input.length * 8; i += 8) {
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
}
return output;
}
/*
* Calculate the MD5 of a raw string
*/
function rstr_md5(s) {
return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
}
/*
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
function rstr_hmac_md5(key, data) {
var i,
bkey = rstr2binl(key),
ipad = [],
opad = [],
hash;
ipad[15] = opad[15] = undefined;
if (bkey.length > 16) {
bkey = binl_md5(bkey, key.length * 8);
}
for (i = 0; i < 16; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
}
/*
* Convert a raw string to a hex string
*/
function rstr2hex(input) {
var hex_tab = '0123456789abcdef',
output = '',
x,
i;
for (i = 0; i < input.length; i += 1) {
x = input.charCodeAt(i);
output += hex_tab.charAt((x >>> 4) & 0x0F) +
hex_tab.charAt(x & 0x0F);
}
return output;
}
/*
* Encode a string as utf-8
*/
function str2rstr_utf8(input) {
return unescape(encodeURIComponent(input));
}
/*
* Take string arguments and return either raw or hex encoded strings
*/
function raw_md5(s) {
return rstr_md5(str2rstr_utf8(s));
}
function hex_md5(s) {
return rstr2hex(raw_md5(s));
}
function raw_hmac_md5(k, d) {
return rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d));
}
function hex_hmac_md5(k, d) {
return rstr2hex(raw_hmac_md5(k, d));
}
/**
* 暴露接口给小程序 因为export default,所以引入的时候可以自定义方法名称
* +--------------------
* @param {String} string 需要加密的字符串
* @param {String} key 加密key
* @param {Boolean} raw 规则 false: 返回hex_md5, true: 返回raw_md5
*/
export default function md5(string, key, raw) {
if (!key) {
if (!raw) {
return hex_md5(string);
}
return raw_md5(string);
}
if (!raw) {
return hex_hmac_md5(key, string);
}
return raw_hmac_md5(key, string);
}
\ No newline at end of file
function formatTime(date) {
var year = date.getFullYear()
var month = date.getMonth() + 1
var day = date.getDate()
var hour = date.getHours()
var minute = date.getMinutes()
var second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
function formatNumber(n) {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime
}
function chooseTimeFormat(callback) {
//格式化日期时间
Date.prototype.pattern = function (fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
var week = {
"0": "/u65e5",
"1": "/u4e00",
"2": "/u4e8c",
"3": "/u4e09",
"4": "/u56db",
"5": "/u4e94",
"6": "/u516d"
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
if (/(E+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : "") + week[this.getDay() + ""]);
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
}
return fmt;
}
var date = new Date();
console.log("格式化前:" + date);
var fmtDate = date.pattern("yyyy-MM-dd hh:mm:ss");
console.log("格式化后:" + fmtDate);
callback(fmtDate, date);
}
module.exports.chooseTimeFormat = chooseTimeFormat;
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime
}