Commit 5d11c903 by Sweet Zhang

Initial commit

parents
//app.js
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs);
var _this = this
wx.getSystemInfo({
success: function (response) {
if (response.model.toUpperCase().indexOf('IPHONE') >= 0 && response.model.toUpperCase().indexOf('X') >= 0) {
_this.globalData.isIpx = true;
}
}
})
wx.request({
url: 'https://m.zuihuibi.cn/api/authorize/obtainToken',
method: 'POST',
data: {
ticket: 'miniPro'
},
success: function (response) {
wx.setStorageSync('X-Authorization', response.data.data.token);
// 登录
wx.login({
success: function (res) {
if (res.code) {
//发起网络请求
wx.request({
url: 'https://m.zuihuibi.cn/api/jscode2session',
method: 'POST',
header: { 'X-Authorization': wx.getStorageSync('X-Authorization') },
data: {
appid: 'wx53a601e27aaf7897',
secret: 'f61707a62e46fee78ef46155330cdf45',
js_code: res.code
},
success: function (res) {
wx.setStorageSync('sessionKey', res.data.data.session_key);
wx.setStorageSync('openid', res.data.data.openid);
}
})
} else {
console.log('登录失败!' + res.errMsg)
}
}
})
}
})
},
globalData: {
userInfo: null,
isIpx: false
}
})
\ No newline at end of file
{
{
"pages": [
"pages/index/index",
"pages/returnPage/returnPage",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "獴哥保险诊所",
"navigationBarTextStyle": "black"
}
}
\ No newline at end of file
/**app.wxss**/
/**app.wxss**/
.container {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
background-color: #f6f7f2;
}
.linerGradient {
background: linear-gradient(270deg, #f10000, #ff4e18);
font-family: -apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
"Helvetica Neue",
Helvetica,
"PingFang SC",
"Hiragino Sans GB",
"Microsoft YaHei",
SimSun,
sans-serif;
}
.inputControl {
width: 595rpx;
height: 84rpx;
border: 2rpx solid rgba(61,70,103,0.5);
border-radius: 44rpx;
color: #000;
font-size: 36rpx;
padding-left: 40rpx;
margin: 0 auto;
}
.inputControl input {
width: 348rpx;
height: 100%;
}
.smallBtn {
display: inline-block;
width: 700rpx;
height: 94rpx;
line-height: 94rpx;
border-radius: 10rpx;
background-color: #fff;
color: #000;
font-size: 36rpx;
text-align: center;
border: 1px solid #dcdcdc;
}
.fix-iphonex-button {
width: 100%;
background-color: #f6f7f2;
}
.none-iphonex-button {
width: 100%;
background-color: #f6f7f2;
}
{}
{}
\ No newline at end of file
<!--index.wxml-->
<!--index.wxml-->
<view class="container" class="{{isIpx?'fix-iphonex-button':'none-iphonex-button'}}">
<image src='../images/bg.png' style='width:750rpx;height:5191rpx'></image>
<view class='footer'>
<view class='priceBox'>
<view style='font-weight:bold;font-size:40rpx'>
<text style='font-size:30rpx'>¥</text>49</view>
<view style='font-weight:300;font-size:26rpx' class='line-through'>原价:
<text style='font-size:20rpx'>¥</text>
<text>199/年</text>
</view>
</view>
<view class='redeemBtn linerGradient' bindtap="buy">立即购买</view>
</view>
</view>
<!-- 立即购买信息 -->
<block wx:if="{{isBuy}}">
<view class="modalBox">
<view class='inputBox'>
<!--获取手机号 -->
<view class="mobileNoSection inputControl">
<input type='number' maxlength="11" placeholder="输入手机号" placeholder-style="color: #b2b2b2;" bindinput="inputMobileNo" value='{{mobileNo}}' />
<view class='autoGet'>
<image class='wechatIcon' style="width: 46rpx; height: 46rpx;margin-top:20rpx;" src='../images/wechatIcon.png'></image>
<button class='getPhoneNumber commonBtn' open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">自动获取</button>
</view>
</view>
<!--获取验证码 -->
<view class="codeSection inputControl" wx:if="{{!autogetPhoneNumber}}">
<input type='number' maxlength="4" placeholder="输入验证码" placeholder-style=" color: #b2b2b2;" bindblur="getVerificationCode" />
<view class='autoGet'>
<button class='getCode commonBtn' bindtap='getCode' disabled='{{disableBtn}}'>{{codeBtnHtml}}</button>
</view>
</view>
<!--姓名 -->
<view class="nameSection inputControl">
<input type='text' maxlength="50" placeholder="姓名" style="width:100%" placeholder-style=" color: #b2b2b2;" bindblur="nameValid" />
</view>
<!--立即支付 -->
<button class='goBuyBtn commonBtn' bindtap='goPay'>立即支付</button>
</view>
<!-- 关闭按钮 -->
<view class='closeModal' bindtap='closeModalBox'>X</view>
</view>
</block>
\ No newline at end of file
/**index.wxss**/
/**index.wxss**/
.redeemBtn {
position: absolute;
right: 0;
width: 400rpx;
height: 130rpx;
line-height: 130rpx;
text-align: center;
color: #fff;
font-size: 40rpx;
}
.priceBox {
width: 300rpx;
color: #fe3400;
text-align: center;
}
.footer {
display: flex;
align-items: center;
height: 130rpx;
background-color: rgb(255, 255, 255);
}
.line-through {
position: relative;
}
.line-through::after {
position: absolute;
top: 50%;
left: 0;
right: 0;
margin: 0 auto;
content: '';
width: 65%;
height: 1px;
background-color: #fe3400;
}
.modalBox {
position: fixed;
left: 0;
top: 0;
width: 750rpx;
height: 6000rpx;
background: rgba(0, 0, 0, 0.9);
z-index: 1;
}
.inputBox {
position: absolute;
top: 300rpx;
left: 30rpx;
width: 85%;
background-color: #f6f7f2;
padding: 60rpx 30rpx;
border-radius: 10rpx;
}
.mobileNoSection, .codeSection {
position: relative;
display: flex;
}
.codeSection, .nameSection {
margin-top: 40rpx;
}
.getPhoneNumber, .getCode {
width: 248rpx;
height: 84rpx;
color: #000;
border-radius: 44rpx;
font-size: 32rpx;
}
.getPhoneNumber {
padding-left: 80rpx;
}
.autoGet {
width: 248rpx;
height: 84rpx;
position: absolute;
right: 0rpx;
top: 0rpx;
}
.wechatIcon {
position: absolute;
left: 30rpx;
top: 0;
z-index: 1;
}
.commonBtn {
background: #16c4bb;
color: #fff;
}
.goBuyBtn {
width: 400rpx;
height: 90rpx;
line-height: 90rpx;
border-radius: 44rpx;
border: none;
margin-top: 100rpx;
}
.closeModal {
position: absolute;
right: 20rpx;
top: 20rpx;
color: #fff;
border: 2px solid #fff;
border-radius: 50%;
width: 60rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
cursor: pointer;
font-size: 44rpx;
}
//logs.js
//logs.js
const util = require('../../utils/util.js')
//获取应用实例
const app = getApp()
Page({
data: {
isIpx:false,
logs: []
},
onLoad: function () {
this.setData({
isIpx: app.globalData.isIpx,
logs: (wx.getStorageSync('logs') || []).map(log => {
return util.formatTime(new Date(log))
})
})
}
})
{
{
"navigationBarTitleText": "查看启动日志"
}
\ No newline at end of file
<!--logs.wxml-->
<!--logs.wxml-->
<view class="container log-list" class="{{isIpx?'fix-iphonex-button':'none-iphonex-button'}}">
<block wx:for="{{logs}}" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log}}</text>
</block>
</view>
.log-list {
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
// pages/returnPage/returnPage.js
// pages/returnPage/returnPage.js
//获取应用实例
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
paymentStatus: '0',
isIpx:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({ 'paymentStatus': options.paymentStatus, isIpx: app.globalData.isIpx })
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function (res) {
if (res.from === 'button') {
// 来自页面内转发按钮
// console.log(res.target)
}
return {
title: '1对1家庭风险管理服务',
imageUrl: '../images/share_img.png',
path: '/pages/index/index'
}
}
})
\ No newline at end of file
<!--pages/returnPage/returnPage.wxml-->
<!--pages/returnPage/returnPage.wxml-->
<view class="container" class="{{isIpx?'fix-iphonex-button':'none-iphonex-button'}}">
<view class="modal">
<block wx:if="{{paymentStatus=='0'}}">
<view class="statusBox">
<view style='text-align:center;margin-bottom:20rpx;'>
<icon type="warn" size="90" />
</view>
<view class='titleContainer' style="display: flex;justify-content: center;">
<view style='font-weight:400;font-size:40rpx;;margin-bottom:10rpx;'>支付失败</view>
</view>
</view>
</block>
<block wx:if="{{paymentStatus=='1'}}">
<view class="statusBox">
<view style='text-align:center;margin-bottom:20rpx;'>
<icon type="success" size="90" />
</view>
<view class='titleContainer' style="text-align:center">
<view style='font-weight:400;font-size:40rpx;margin-bottom:10rpx;'>支付成功</view>
<view class='stausText' style='display:flex;flex-direction:column'>
<text>谢谢购买家庭风险管理服务。</text>
<text>我们的风险分析师会在24小时内和您联系。</text>
</view>
</view>
</view>
</block>
<block wx:if="{{paymentStatus=='2'}}">
<view class="statusBox">
<view style='text-align:center;margin-bottom:20rpx;'>
<icon type="warn" size="90" />
</view>
<view class='titleContainer' style="display: flex;justify-content: center;">
<view style='font-weight:400;font-size:40rpx;;margin-bottom:10rpx;'>支付失败!!!!</view>
</view>
</view>
</block>
<view class="{{isIpx?'btnBlockFixedX':'btnBlock'}}">
<view class="btnBox">
<button open-type="share" class='shareBtn' hover-class="none">
<text class="smallBtn actived">分享好友</text>
</button>
</view>
<view class="btnBox">
<navigator url='/pages/index/index'>
<text class="smallBtn">返回首页</text>
</navigator>
</view>
</view>
</view>
</view>
\ No newline at end of file
/* pages/returnPage/returnPage.wxss */
/* pages/returnPage/returnPage.wxss */
.modal {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: #f6f7f2;
}
.statusBox {
margin-top: 10%;
}
.titleContainer {
padding: 40rpx;
}
.titleContainer .stausText {
font-size: 28rpx;
font-weight: 400;
text-align: center;
margin-bottom: 20rpx;
}
.btnBlock, .btnBlockFixedX {
width: 100%;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
margin-top: 10rpx;
}
.btnBlock .btnBox, .btnBlockFixedX .btnBox {
margin-bottom: 30rpx;
}
.shareBtn {
background: none;
border: none !important;
border-radius: 0;
line-height: 1;
}
.shareBtn::after {
border: none;
}
.actived {
background: rgba(22, 196, 187, 1);
color: #fff;
border: 1px solid rgba(22, 196, 187, 0.5);
}
{
{
"description": "项目配置文件。",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "2.0.9",
"appid": "wx53a601e27aaf7897",
"projectname": "49%E5%85%83%E4%BF%9D%E9%99%A9%E6%B4%BB%E5%8A%A8",
"isGameTourist": false,
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}
\ No newline at end of file
/*
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
/*
* Perform a simple self-test to see if the VM is working
*/
function md5_vm_test()
{
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function core_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 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+ 0], 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+ 0], 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+ 0], 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 Array(a, b, c, d);
}
/*
* 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 HMAC-MD5, of a key and some data
*/
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var 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));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
return str;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of little-endian words to a base-64 string
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
module.exports = {
MD5:hex_md5
}
\ No newline at end of file
const formatTime = date => {
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
}
//app.js
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs);
var _this = this
wx.getSystemInfo({
success: function (response) {
if (response.model.toUpperCase().indexOf('IPHONE') >= 0 && response.model.toUpperCase().indexOf('X') >= 0) {
_this.globalData.isIpx = true;
}
}
})
wx.request({
url: 'https://m.zuihuibi.cn/api/authorize/obtainToken',
method: 'POST',
data: {
ticket: 'miniPro'
},
success: function (response) {
wx.setStorageSync('X-Authorization', response.data.data.token);
// 登录
wx.login({
success: function (res) {
if (res.code) {
//发起网络请求
wx.request({
url: 'https://m.zuihuibi.cn/api/jscode2session',
method: 'POST',
header: { 'X-Authorization': wx.getStorageSync('X-Authorization') },
data: {
appid: 'wx6ae60f33768036aa',
secret: 'd31f03454666a2a0dd261ee90c8aa6ce',
js_code: res.code
},
success: function (res) {
wx.setStorageSync('sessionKey', res.data.data.session_key);
wx.setStorageSync('openid', res.data.data.openid);
}
})
} else {
console.log('登录失败!' + res.errMsg)
}
}
})
// // 获取用户信息
// wx.getSetting({
// success: res => {
// if (res.authSetting['scope.userInfo']) {
// // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
// // wx.getUserInfo({
// // success: res => {
// // // 可以将 res 发送给后台解码出 unionId
// // this.globalData.userInfo = res.userInfo
// // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// // // 所以此处加入 callback 以防止这种情况
// // if (this.userInfoReadyCallback) {
// // this.userInfoReadyCallback(res)
// // }
// // }
// // })
// }
// }
// })
}
})
},
globalData: {
userInfo: null,
isIpx: false
}
})
\ No newline at end of file
{
{
"pages": [
"pages/index/index",
"pages/returnPage/returnPage",
"pages/fillInfo/fillInfo",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
}
}
\ No newline at end of file
/**app.wxss**/
/**app.wxss**/
.container {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
background-color: #000;
}
.linerGradient {
background: linear-gradient(#f7cb8e, #ac8b6e);
font-family: -apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
"Helvetica Neue",
Helvetica,
"PingFang SC",
"Hiragino Sans GB",
"Microsoft YaHei",
SimSun,
sans-serif;
}
.inputControl {
width: 624rpx;
height: 84rpx;
border: 2px solid #e3b870;
border-radius: 44rpx;
color: rgb(201, 181, 144);
font-size: 26rpx;
padding-left: 40rpx;
margin: 0 auto;
}
.inputControl input{
width:58%;
height:100%;
}
.smallBtn{
width: 166rpx;
height:70rpx;
line-height: 70rpx;
border-radius:34rpx;
background-color: #fff;
color: rgb(201,152,61);
font-size: 28rpx;
text-align: center;
}
.fix-iphonex-button {
height: 1448rpx;
width: 100%;
}
.none-iphonex-button {
height: 1206rpx;
width: 100%;
}
\ No newline at end of file
{}
{}
\ No newline at end of file
<!--pages/fillInfo/fillInfo.wxml-->
<!--pages/fillInfo/fillInfo.wxml-->
<view class='container' class="{{isIpx?'fix-iphonex-button':'none-iphonex-button'}}">
<image src='../images/fillInfo_bg.jpg' style='width:750rpx;height:1196rpx'></image>
<view class='inputBox'>
<!--获取手机号 -->
<view class="mobileNoSection inputControl">
<input type='number' maxlength="11" placeholder="输入手机号" placeholder-style="color: rgb(201, 181, 144);" bindblur="inputMobileNo" value='{{mobileNo}}' />
<view class='autoGet'>
<image class='wechatIcon' style="width: 46rpx; height: 46rpx;margin-top:20rpx;" src='../images/wechatIcon.png'></image>
<button class='getPhoneNumber linerGradient' open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">自动获取</button>
</view>
</view>
<!--获取验证码 -->
<view class="codeSection inputControl" wx:if="{{!autogetPhoneNumber}}">
<input type='number' maxlength="4" placeholder="输入验证码" placeholder-style=" color: rgb(201, 181, 144);" bindblur="getVerificationCode" />
<view class='autoGet'>
<button class='getCode linerGradient' bindtap='getCode' disabled='{{disableBtn}}'>{{codeBtnHtml}}</button>
</view>
</view>
<!--姓名 -->
<view class="nameSection inputControl">
<input type='text' maxlength="50" placeholder="姓名" style="width:100%" placeholder-style=" color: rgb(201, 181, 144);" bindblur="nameValid" />
</view>
</view>
<!--立即领取 -->
<button class='redeemBtn' bindtap='goPay'>立即支付</button>
</view>
\ No newline at end of file
/* pages/fillInfo/fillInfo.wxss */
/* pages/fillInfo/fillInfo.wxss */
.redeemBtn {
position: absolute;
bottom: 188rpx;
left: 50%;
width: 400rpx;
height: 90rpx;
line-height: 90rpx;
margin-left: -200rpx;
text-align: center;
color: rgb(55, 28, 1);
font-size: 40rpx;
background: linear-gradient(#f7cb8e, #ac8b6e);
border-radius: 44rpx;
border: 4rpx solid #d3bd8d;
}
.inputBox {
position: absolute;
top: 442rpx;
left: 40rpx;
}
.mobileNoSection,.codeSection{
position: relative;
display: flex;
}
.codeSection, .nameSection {
margin-top: 40rpx;
}
.getPhoneNumber, .getCode {
width: 248rpx;
height: 84rpx;
color: rgb(55, 28, 1);
border-radius: 44rpx;
font-size: 32rpx;
}
.getPhoneNumber {
padding-left: 80rpx;
}
.autoGet {
width: 248rpx;
height: 84rpx;
position: absolute;
right: 0rpx;
top: 0rpx;
}
.wechatIcon {
position: absolute;
left: 30rpx;
top: 0;
z-index: 1;
}
.fix-iphonex-button {
background: url('https://ajb-images.oss-cn-shanghai-finance-1-pub.aliyuncs.com/mini/vip9/fillInfo_bg.jpg');
}
.none-iphonex-button {
background: url('https://ajb-images.oss-cn-shanghai-finance-1-pub.aliyuncs.com/mini/vip9/fillInfo_bg.jpg');
}
\ No newline at end of file
//index.js
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
userInfo: {},
isIpx:false,
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
this.setData({ isIpx: app.globalData.isIpx});
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
return {
title: '专属于你的保险经纪人服务',
imageUrl: '../images/share_mini.jpg',
path: '/pages/index/index'
}
}
})
{}
{}
\ No newline at end of file
<!--index.wxml-->
<!--index.wxml-->
<view class="container" class="{{isIpx?'fix-iphonex-button':'none-iphonex-button'}}">
<!-- <view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view> -->
<image src='../images/index_bg.jpg' style='width:750rpx;height:1196rpx'></image>
<navigator url="/pages/fillInfo/fillInfo" hover-class="navigator-hover" class='redeemBtn linerGradient'>立即加入</navigator>
</view>
/**index.wxss**/
/**index.wxss**/
.redeemBtn {
position: absolute;
bottom: 30rpx;
left: 50%;
width: 400rpx;
height: 90rpx;
line-height: 90rpx;
margin-left: -200rpx;
text-align: center;
color: rgb(55, 28, 1);
font-size: 40rpx;
border-radius: 44rpx;
border: 4rpx solid #d3bd8d;
}
.info{
position: absolute;
bottom: 176rpx;
left: 0;
right:0;
z-index: 1;
color: #c9b590;
font-size: 26rpx;
text-align: center;
}
.fix-iphonex-button {
background: url('https://ajb-images.oss-cn-shanghai-finance-1-pub.aliyuncs.com/mini/vip9/fillInfo_bg.jpg');
}
.none-iphonex-button {
background: url('https://ajb-images.oss-cn-shanghai-finance-1-pub.aliyuncs.com/mini/vip9/fillInfo_bg.jpg');
}
\ No newline at end of file
//logs.js
//logs.js
const util = require('../../utils/util.js')
//获取应用实例
const app = getApp()
Page({
data: {
isIpx:false,
logs: []
},
onLoad: function () {
this.setData({
isIpx: app.globalData.isIpx,
logs: (wx.getStorageSync('logs') || []).map(log => {
return util.formatTime(new Date(log))
})
})
}
})
{
{
"navigationBarTitleText": "查看启动日志"
}
\ No newline at end of file
<!--logs.wxml-->
<!--logs.wxml-->
<view class="container log-list" class="{{isIpx?'fix-iphonex-button':'none-iphonex-button'}}">
<block wx:for="{{logs}}" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log}}</text>
</block>
</view>
.log-list {
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
// pages/returnPage/returnPage.js
// pages/returnPage/returnPage.js
//获取应用实例
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
paymentStatus: '0',
isIpx:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({ 'paymentStatus': options.paymentStatus, isIpx: app.globalData.isIpx })
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function (res) {
if (res.from === 'button') {
// 来自页面内转发按钮
// console.log(res.target)
}
return {
title: '专属于你的保险经纪人服务',
imageUrl:'../images/share_mini.jpg',
path: '/pages/index/index'
}
}
})
\ No newline at end of file
<!--pages/returnPage/returnPage.wxml-->
<!--pages/returnPage/returnPage.wxml-->
<view class="container" class="{{isIpx?'fix-iphonex-button':'none-iphonex-button'}}">
<view class="modal">
<block wx:if="{{paymentStatus=='0'}}">
<view class='modalContainer'>
<image src='../images/fail_ng.png' style='width:458rpx;height:521rpx'></image>
</view>
</block>
<block wx:if="{{paymentStatus=='1'}}">
<image src='../images/success_ng.png' style='width:750rpx;height:1121rpx'></image>
</block>
<block wx:if="{{paymentStatus=='2'}}">
<image src='../images/repeat.png' style='width:750rpx;height:1121rpx'></image>
</block>
<view class="{{isIpx?'btnBlockFixedX':'btnBlock'}}">
<button class="smallBtn" open-type="share">分享好友</button>
<navigator class="smallBtn" url='/pages/index/index'>返回首页</navigator>
</view>
</view>
</view>
\ No newline at end of file
/* pages/returnPage/returnPage.wxss */
/* pages/returnPage/returnPage.wxss */
.container {
position: relative;
width: 750rpx;
height: 1206rpx;
background: url('https://ajb-images.oss-cn-shanghai-finance-1-pub.aliyuncs.com/mini/vip9/fillInfo_bg.jpg') repeat-y center;
background-size: 100% 100%;
}
.modal {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
.btnBlock {
position: absolute;
top: 700rpx;
left: 197rpx;
display: flex;
}
.btnBlockFixedX{
position: absolute;
top: 785rpx;
left: 197rpx;
display: flex;
}
.btnBlock button,.btnBlockFixedX button{
padding:0;
margin-right: 30rpx;
}
.modalContainer{
width:100%;
height:100%;
background: rgba(0,0,0,.4);
display: flex;
justify-content: center;
align-items: center;
}
\ No newline at end of file
{
{
"description": "项目配置文件。",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "2.0.9",
"appid": "wx6ae60f33768036aa",
"projectname": "9%E5%85%83%E4%BC%9A%E5%91%98%E6%B4%BB%E5%8A%A8",
"isGameTourist": false,
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}
\ No newline at end of file
/*
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
/*
* Perform a simple self-test to see if the VM is working
*/
function md5_vm_test()
{
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function core_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 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+ 0], 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+ 0], 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+ 0], 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 Array(a, b, c, d);
}
/*
* 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 HMAC-MD5, of a key and some data
*/
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var 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));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
return str;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of little-endian words to a base-64 string
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
module.exports = {
MD5:hex_md5
}
\ No newline at end of file
const formatTime = date => {
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
}
App({
App({
globalData: {
// userInfo:null,
appId: 'xxx',
key: 'xxx' //AppSecret
},
onLaunch: function () {
wx.request({
url: 'https://m.zuihuibi.cn/api/authorize/obtainToken',
method:'POST',
data:{
ticket:'miniPro'
},
success:function(response){
wx.setStorageSync('X-Authorization', response.data.data.token);
wx.login({
success: function (res) {
if (res.code) {
//发起网络请求
wx.request({
url: 'https://m.zuihuibi.cn/api/jscode2session',
method: 'POST',
header: { 'X-Authorization': response.data.data.token },
data: {
js_code: res.code
},
success: function (res) {
wx.setStorageSync('openId', res.data.data.openid)
}
})
} else {
console.log('登录失败!' + res.errMsg)
}
}
});
// 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scope
wx.getSetting({
success(res) {
if (!res.authSetting['scope.writePhotosAlbum']) {
wx.authorize({
scope: 'scope.writePhotosAlbum',
success() {
wx.writePhotosAlbum()
}
})
}
}
})
}
})
}
})
\ No newline at end of file
{
{
"pages": [
"pages/list/list",
"pages/zhbQrcode/zhbQrcode",
"pages/packinglist/packinglist",
"pages/mine/mine",
"pages/myList/myList"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "旅行打包神器",
"navigationBarTextStyle": "black"
},
"tabBar": {
"selectedColor": "#DE0615",
"list": [
{
"pagePath": "pages/list/list",
"text": "首页",
"iconPath": "images/home.png",
"selectedIconPath": "images/home1.png"
},
{
"pagePath": "pages/mine/mine",
"text": "我的",
"iconPath": "images/my.png",
"selectedIconPath": "images/my1.png"
}
]
}
}
\ No newline at end of file
@import 'lib/weui.wxss';
@import 'lib/weui.wxss';
page {
height: 100%;
background-color: rgba(155, 205, 204, 0.8);
font-family: -apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
"Helvetica Neue",
Helvetica,
"PingFang SC",
"Hiragino Sans GB",
"Microsoft YaHei",
SimSun,
sans-serif;
}
.text-center {
text-align: center;
}
/*右上角*号 */
.sup {
display: inline-block;
padding: 0.15em 0.4em;
min-width: 8px;
color: #de0615;
line-height: 1.2;
text-align: center;
font-size: 32rpx;
vertical-align: middle;
}
.weui-icon-selected {
display: block;
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
width: 100%;
height: 100%;
background: url('https://ajb-images.oss-cn-shanghai-finance-1-pub.aliyuncs.com/mini/packing/pen-circle.svg') no-repeat center center;
background-size: contain;
z-index: 1;
}
.option-checkboxes__checkbox {
border: 2px solid #949897;
width: 22px;
height: 22px;
display: inline-block;
box-sizing: border-box;
margin-right: 10px;
vertical-align: middle;
}
.option-checkboxes__checkbox_checked {
background: url('https://ajb-images.oss-cn-shanghai-finance-1-pub.aliyuncs.com/mini/packing/tick.svg') no-repeat center center;
}
.header {
color: #fff;
text-shadow: 0 2px 0 #79b1ae;
padding: 40rpx 0 20rpx 40rpx;
font-weight: bold;
line-height: 1.5em;
}
.logo {
position: absolute;
right: 0;
top: 0;
width: 280rpx;
height: 80rpx;
line-height: 80rpx;
padding-top: 20rpx;
background: #fff;
box-shadow: 0 3px 0 0 rgba(44, 103, 101, 0.2);
}
.logo_corner {
position: absolute;
left: -80rpx;
top: 0;
width: 80rpx;
height: 80rpx;
}
.logo_corner::before {
position: absolute;
top: 0;
right: 2px;
content: '';
display: block;
border-right: 40rpx solid rgba(44, 103, 101, 0.2);
border-top: 0 solid transparent;
border-left: 0 solid transparent;
border-bottom: 80rpx solid transparent;
box-shadow: 2px 0 0 0 rgba(44, 103, 101, 0.2);
}
.logo_corner::after {
position: absolute;
top: 0;
right: 0;
content: '';
display: block;
border-right: 40rpx solid #fff;
border-top: 0 solid transparent;
border-left: 0 solid transparent;
border-bottom: 100rpx solid transparent;
}
.list-item-new__add, .list-item__disable, .list-item__enable {
cursor: pointer;
float: right;
background: #a7d5d3 url(https://ajb-images.oss-cn-shanghai-finance-1-pub.aliyuncs.com/mini/packing/plus.svg) no-repeat center center;
background-size: 12px;
border-radius: 50%;
color: #fff;
width: 20px;
height: 20px;
line-height: 20px;
text-align: center;
padding: 0;
display: block;
margin: 2px 0 0 5px;
}
.list-item__disable {
background-color: #e5c4bd;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.list-item__quantity {
float: right;
max-width: 80rpx;
min-height: 52rpx;
box-sizing: border-box;
border: 1px solid #ccc;
padding: 0 0 0 4px;
height: 52rpx;
font-size: 16px;
line-height: 52rpx;
box-shadow: none;
border-radius: 0;
background: #fff;
text-align: center;
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" height="17px" viewBox="-63.734 47.167 17.078 17" width="17.078px" version="1.1" y="0px" x="0px" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new -63.734 47.167 17.078 17">
<path d="m-48.873 61.306c0.199-0.224 0.298-0.511 0.28-0.807-0.017-0.298-0.15-0.57-0.373-0.769-0.446-0.395-1.184-0.349-1.578 0.094-1.193 1.341-2.902 2.111-4.689 2.111-3.45-0.006-6.26-2.817-6.267-6.266 0.007-3.452 2.817-6.262 6.266-6.268 1.386 0 2.7 0.443 3.799 1.284l0.685 0.524-2.606 2.598c-0.146 0.147-0.2 0.317-0.142 0.456 0.064 0.152 0.254 0.243 0.507 0.243h6.019c0.251 0 0.318-0.262 0.318-0.415v-6.1c0-0.276-0.275-0.338-0.382-0.338-0.068 0-0.166 0.017-0.244 0.094l-1.91 1.905-0.529-0.451c-1.537-1.312-3.496-2.035-5.513-2.035-4.686 0.001-8.499 3.814-8.5 8.5 0.001 4.686 3.815 8.499 8.5 8.5h0.002c2.431 0.001 4.748-1.042 6.357-2.86" fill="#3C4449"/>
</svg>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1523865510176" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3164" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M911.6 651.6l0 209.2c0 36-30.4 66.2-66.2 66.2l-699.6 1.2c-35.8 0-65-29.2-65-65.2l1.2-699.6c0-35.8 30.4-66.2 66.2-66.2l387 0L535.2 20.2 148.2 20.2c-81.8 0-143 82.8-143 156.8l0 686c0 77.6 63 140.8 140.8 140.8l686 0c82 0 156.6-68.2 156.6-143L988.6 651.6 911.6 651.6 911.6 651.6zM730.2 60.8l288.6 289.2L730.2 639l0-165.2c0 0-286.4-31.8-453.6 206.6 0 0 52.6-454.4 453.6-454.4L730.2 60.8 730.2 60.8z" p-id="3165" fill="#ffffff"></path></svg>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1523865510176" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3164" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M911.6 651.6l0 209.2c0 36-30.4 66.2-66.2 66.2l-699.6 1.2c-35.8 0-65-29.2-65-65.2l1.2-699.6c0-35.8 30.4-66.2 66.2-66.2l387 0L535.2 20.2 148.2 20.2c-81.8 0-143 82.8-143 156.8l0 686c0 77.6 63 140.8 140.8 140.8l686 0c82 0 156.6-68.2 156.6-143L988.6 651.6 911.6 651.6 911.6 651.6zM730.2 60.8l288.6 289.2L730.2 639l0-165.2c0 0-286.4-31.8-453.6 206.6 0 0 52.6-454.4 453.6-454.4L730.2 60.8 730.2 60.8z" p-id="3165" fill="#ffffff"></path></svg>
\ No newline at end of file
// pages/list/list.js
// pages/list/list.js
Page({
/**
* 页面的初始数据
*/
data: {
hasUserInfo:false,
checkboxItems: [
{ name: '滑雪', value: 'skiing' },
{ name: '海滩', value: 'beach' },
{ name: '野营', value: 'camping' },
{ name: '徒步', value: 'hiking' }
],
selectedWhere: null,
selectedDays: null,
selectedWash: null,
selectedTemperature: null,
selectedGender: null,
btnActived: null,
results: [],
packingListEntry: {
gender: null,
temperature: null,
ifWashClothes: null,
region: null,
travelDays: null,
skiing: null,
beach: null,
camping: null,
hiking: null
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function () {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
// 多选点击事件
checkboxChange: function (e) {
var checkboxItems = this.data.checkboxItems, values = e.detail.value, packingListEntry = this.data.packingListEntry;
for (var i = 0, lenI = checkboxItems.length; i < lenI; ++i) {
checkboxItems[i].checked = false;
for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
if (checkboxItems[i].value == values[j]) {
checkboxItems[i].checked = true;
break;
}
}
if (checkboxItems[i].value === 'skiing') {
if (checkboxItems[i].checked === true) {
packingListEntry.skiing = 1
} else {
packingListEntry.skiing = null
}
} else if (checkboxItems[i].value === 'beach') {
if (checkboxItems[i].checked === true) {
packingListEntry.beach = 1
} else {
packingListEntry.beach = null
}
} else if (checkboxItems[i].value === 'camping') {
if (checkboxItems[i].checked === true) {
packingListEntry.camping = 1
} else {
packingListEntry.camping = null
}
} else if (checkboxItems[i].value === 'hiking') {
if (checkboxItems[i].checked === true) {
packingListEntry.hiking = 1
} else {
packingListEntry.hiking = null
}
}
}
this.setData({
checkboxItems: checkboxItems,
packingListEntry: packingListEntry
});
},
// 选择目的地
selectWhere: function (e) {
var results = this.data.results;
var packingListEntry = this.data.packingListEntry;
results['selectedWhere'] = e.target.dataset;
packingListEntry.region = e.target.dataset.value;
this.setData({ selectedWhere: e.target.dataset.value, packingListEntry: packingListEntry });
this.updateOptionResult();
},
// 选择天数
selectDay: function (e) {
var results = this.data.results;
var packingListEntry = this.data.packingListEntry;
results['selectedDays'] = e.target.dataset;
packingListEntry.travelDays = e.target.dataset.value;
this.setData({ selectedDays: e.target.dataset.value, packingListEntry: packingListEntry });
this.updateOptionResult();
},
selectWash: function (e) {
var results = this.data.results;
var packingListEntry = this.data.packingListEntry;
results['selectedWash'] = e.target.dataset;
packingListEntry.ifWashClothes = e.target.dataset.value;
this.setData({ selectedWash: e.target.dataset.value, packingListEntry: packingListEntry });
this.updateOptionResult();
},
selectTemperature: function (e) {
var results = this.data.results;
var packingListEntry = this.data.packingListEntry;
packingListEntry.temperature = e.target.dataset.value;
results['selectedTemperature'] = e.target.dataset;
this.setData({ selectedTemperature: e.target.dataset.value, packingListEntry: packingListEntry });
this.updateOptionResult();
},
selectGender: function (e) {
var results = this.data.results;
var packingListEntry = this.data.packingListEntry;
packingListEntry.gender = e.target.dataset.value;
results['selectedGender'] = e.target.dataset;
this.setData({ selectedGender: e.target.dataset.value, packingListEntry: packingListEntry });
this.updateOptionResult();
},
// 生成列表
makeLists: function (e) {
wx.request({
url: 'https://m.zuihuibi.cn/api/promotion/packingListQry',
data: this.data.packingListEntry,
method: 'POST',
header: { 'X-Authorization': wx.getStorageSync('X-Authorization')},
dataType: 'json',
success: function (res) {
wx.setStorageSync('packingCategoryList', res.data.data.packingCategoryList);
wx.navigateTo({
url: '../packinglist/packinglist',
})
}
})
},
// 更新选项答案
updateOptionResult: function () {
var indexArray = [];
for (var i in this.data.results) {
indexArray.push(i);
}
var btnActived = indexArray.length === 5;
this.setData({ btnActived, btnActived })
}
})
\ No newline at end of file
{}
{}
\ No newline at end of file
<block wx:if="{{!hasUserInfo}}">
<block wx:if="{{!hasUserInfo}}">
<view class='header'>
<view style='font-size:36rpx'>创建你的终极</view>
<view style='font-size:48rpx'>旅行</view>
<view style='font-size:48rpx'>打包清单</view>
</view>
<view class='logo'>
<view class='logo_corner'></view>
<image src='/images/logo.png' style='width:258rpx;height:60rpx;'></image>
</view>
<view class="page">
<view class='text-center wx_title'>关于你的旅行</view>
<!--选项模块 -->
<view class='optionsBox'>
<view class='part'>
<view class="weui-cell__bd">
<view style="display: inline-block; vertical-align: middle">性别</view>
<view class="sup">*</view>
</view>
<view class="weui-flex" bindtap='selectGender'>
<view class="weui-flex__item">
<view class="option" data-value='1'>男
<view class="weui-icon-selected" wx:if="{{selectedGender=='1'}}"></view>
</view>
</view>
<view class="weui-flex__item">
<view class="option" data-value='2'>女
<view class="weui-icon-selected" wx:if="{{selectedGender=='2'}}"></view>
</view>
</view>
</view>
</view>
<view class='part'>
<view class="weui-cell__bd">
<view style="display: inline-block; vertical-align: middle">气候</view>
<view class="sup">*</view>
</view>
<view class="weui-flex" bindtap='selectTemperature'>
<view class="weui-flex__item">
<view class="option" data-value='1'>冷
<view class="weui-icon-selected" wx:if="{{selectedTemperature=='1'}}"></view>
</view>
</view>
<view class="weui-flex__item">
<view class="option" data-value='2'>热
<view class="weui-icon-selected" wx:if="{{selectedTemperature=='2'}}"></view>
</view>
</view>
</view>
</view>
<view class='part'>
<view class="weui-cell__bd">
<view style="display: inline-block; vertical-align: middle">需要洗衣服吗?</view>
<view class="sup">*</view>
</view>
<view class="weui-flex" bindtap='selectWash'>
<view class="weui-flex__item">
<view class="option" data-value='1'>需要
<view class="weui-icon-selected" wx:if="{{selectedWash=='1'}}"></view>
</view>
</view>
<view class="weui-flex__item">
<view class="option" data-value='0'>不需要
<view class="weui-icon-selected" wx:if="{{selectedWash=='0'}}"></view>
</view>
</view>
</view>
</view>
<view class='part'>
<view class="weui-cell__bd">
<view style="display: inline-block; vertical-align: middle">去哪里?</view>
<view class="sup">*</view>
</view>
<view class="weui-flex" bindtap='selectWhere'>
<view class="weui-flex__item">
<view class="option" data-name="where" data-value="1">国内
<view class="weui-icon-selected" wx:if="{{selectedWhere=='1'}}"></view>
</view>
</view>
<view class="weui-flex__item">
<view class="option" data-name="where" data-value="2">国外
<view class="weui-icon-selected" wx:if="{{selectedWhere=='2'}}"></view>
</view>
</view>
</view>
</view>
<view class='part'>
<view class="weui-cell__bd">
<view style="display: inline-block; vertical-align: middle">天数</view>
<view class="sup">*</view>
</view>
<view class="weui-flex" bindtap='selectDay'>
<view class="weui-flex__item">
<view class="option" data-value="3">3
<view class="weui-icon-selected" wx:if="{{selectedDays=='3'}}"></view>
</view>
</view>
<view class="weui-flex__item">
<view class="option" data-value="7">7
<view class="weui-icon-selected" wx:if="{{selectedDays=='7'}}"></view>
</view>
</view>
<view class="weui-flex__item">
<view class="option" data-value="14">14
<view class="weui-icon-selected" wx:if="{{selectedDays=='14'}}"></view>
</view>
</view>
</view>
</view>
<view class='part'>
<text class='title'>你要去做什么?</text>
<view class="weui-cells weui-cells_after-title">
<checkbox-group bindchange="checkboxChange">
<label class="weui-cell weui-check__label" wx:for="{{checkboxItems}}" wx:key="value">
<checkbox class="weui-check" value="{{item.value}}" checked="{{item.checked}}" />
<view class="weui-cell__hd weui-check__hd_in-checkbox">
<view class='option-checkboxes__checkbox' wx:if="{{!item.checked}}"></view>
<view class='option-checkboxes__checkbox option-checkboxes__checkbox_checked' wx:if="{{item.checked}}"></view>
</view>
<view class="weui-cell__bd">{{item.name}}</view>
</label>
</checkbox-group>
</view>
</view>
<view class='part filters__actions' bindtap='makeLists'>
<button class="btn" disabled wx:if="{{!btnActived}}">生成你的打包列表</button>
<button class="btn btn-active" wx:if="{{btnActived}}">生成你的打包列表</button>
</view>
</view>
</view>
</block>
<!-- <block wx:if="{{!hasUserInfo}}">
<view class='warp' hidden='{{eye}}'>
<button open-type="getUserInfo" hover-class='none' bindgetuserinfo="getUserInfoFun">允许授权才能使用打包神器</button>
</view>
</block> -->
\ No newline at end of file
/* pages/list/list.wxss */
/* pages/list/list.wxss */
.page {
position: relative;
width: 90%;
margin: 0 auto;
margin-bottom: 60rpx;
background-color: #fff;
border-top-left-radius: 40rpx;
border-top-right-radius: 40rpx;
border-bottom-left-radius: 40rpx;
border-bottom-right-radius: 40rpx;
font-size: 32rpx;
overflow: hidden;
padding-bottom: 20rpx;
}
.page::after{
display: block;
content: '';
position: absolute;
right: 0;
left: 0;
bottom: 0;
height: 12px;
background: repeating-linear-gradient(-45deg,rgba(255,255,255,0),rgba(255,255,255,0) 6px,#de0615 6px,#de0615 8px);
}
.wx_title {
height: 80rpx;
line-height: 80rpx;
background-color: #de0615;
color: #fff;
border-top-left-radius: 40rpx;
border-top-right-radius: 40rpx;
}
.optionsBox {
padding: 30rpx;
}
.option {
width: 100%;
text-align: center;
border: 2px solid #949897;
border-width: 4rpx 2rpx;
padding: 20rpx 10rpx;
box-sizing: border-box;
cursor: pointer;
color: #3b4449;
position: relative;
font-size: 28rpx;
}
.part {
margin-bottom: 16rpx;
}
.btn {
display: block;
width: 100%;
text-align: center;
background-size: 44rpx;
color: #fff !important;
text-transform: uppercase;
border-radius: 0 20px 0 20px;
padding: 8px 0;
cursor: pointer;
font-size: 16px;
background-color: #949897 !important;
box-shadow: 0 5px 0 #868a89;
font-weight: bold;
}
.btn-active {
background: #de0615 !important;
box-shadow: 0 5px 0 #930205;
font-weight: bold;
}
.filters__actions {
clear: both;
box-sizing: border-box;
margin: 0;
padding: 20px 20px 0;
text-align: center;
}
Page({
Page({
data: {
packingRecordList: [],
packingCategoryList: []
},
onShareAppMessage: function (res) {
},
onLoad: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var openId = wx.getStorageSync('openId');
var that = this;
wx.request({
url: 'https://m.zuihuibi.cn/api/promotion/userPackingListQry',
method: 'POST',
header: { 'X-Authorization': wx.getStorageSync('X-Authorization') },
data: {
openid: openId
},
success: function (res) {
var packingRecordList = res.data.data.packingRecordList;
that.setData({ packingRecordList: packingRecordList });
}
})
},
goMyList: function (e) {
var packingNo = e.currentTarget.dataset.packingno;
var packingRecordList = this.data.packingRecordList;
var packingCategoryList = this.data.packingCategoryList;
for (var i = 0; i < packingRecordList.length; i++) {
if (packingRecordList[i].packingNo == packingNo) {
packingCategoryList = packingRecordList[i].packingCategoryList;
wx.setStorageSync('packingCategoryList', packingRecordList[i].packingCategoryList);
}
}
this.setData({ packingRecordList, packingRecordList, packingCategoryList: packingCategoryList });
wx.navigateTo({
url: '/pages/myList/myList'
})
}
})
\ No newline at end of file
{}
{}
\ No newline at end of file
<!--pages/mine/mine.wxml-->
<!--pages/mine/mine.wxml-->
<block wx:if="{{!packingRecordList}}">
<view class='noLists'>
<view>暂没有打包记录</view>
<view>还在等什么,快去打包吧~~~</view>
<navigator class='goBtn' url="/pages/list/list" open-type="switchTab" hover-class="other-navigator-hover">GO!</navigator>
</view>
</block>
<block wx:if="{{packingRecordList}}">
<view class="weui-cells__title">最近两次的打包清单记录</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_access" wx:if="{{packingRecordList.length>0}}" data-packingNo="{{packingRecordList[0].packingNo}}" hover-class="weui-cell_active" bindtap='goMyList'>
<view class="weui-cell__hd">
<image src="../../images/1-.png" style="margin-right: 5px;vertical-align: middle;width:20px; height: 20px;"></image>
</view>
<view class="weui-cell__bd">
<view>最新</view>
<view style='color:#8a8a8a'>{{packingRecordList[0].packingDate}}</view>
</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</view>
<view class="weui-cell weui-cell_access" wx:if="{{packingRecordList.length>1}}" data-packingNo="{{packingRecordList[1].packingNo}}" hover-class="weui-cell_active" bindtap='goMyList'>
<view class="weui-cell__hd">
<image src="../../images/2-.png" style="margin-right: 5px;vertical-align: middle;width:20px; height: 20px;"></image>
</view>
<view class="weui-cell__bd">
<view>前一个</view>
<view style='color:#8a8a8a'>{{packingRecordList[1].packingDate}}</view>
</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</view>
</view>
</block>
\ No newline at end of file
/* pages/mine/mine.wxss */
/* pages/mine/mine.wxss */
.weui-cells__title {
background-color: #fff;
font-size: 38rpx;
color: #4a4a4a;
font-weight: bold;
margin: 0;
padding: 16rpx 0rpx 16rpx 30rpx;
}
.noLists {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
margin-top: -50rpx;
flex-direction: column;
}
.goBtn {
font-size: 34rpx;
background: #de0615;
color: #fff;
text-align: center;
padding: 12rpx 0;
width: 200rpx;
margin: 80rpx auto 0;
}
// pages/myList/myList.js
// pages/myList/myList.js
Page({
/**
* 页面的初始数据
*/
data: {
packingCategoryList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var packingCategoryList = this.data.packingCategoryList;
packingCategoryList = wx.getStorageSync('packingCategoryList');
this.setData({ packingCategoryList: packingCategoryList });
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{}
{}
\ No newline at end of file
<!--pages/myList/myList.wxml-->
<!--pages/myList/myList.wxml-->
<view class='logo'>
<view class='logo_corner'></view>
<image src='/images/logo.png' style='width:258rpx;height:60rpx;'></image>
</view>
<view class='mineLists'>
<block wx:if="{{ packingCategoryList.length }}">
<view class='clothing' wx:for="{{packingCategoryList}}" wx:key="{{id}}">
<view class="weui-cells__title category__title">{{item.categoryName}}</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell list-item {{ subItem.completed ? '' : 'completed' }}" wx:for="{{item.packingItemList}}" wx:for-index="subIndex" wx:for-item="subItem" wx:key="{{ itemId }}">
<view class="weui-cell__bd name">{{subItem.itemName}}</view>
<view class="weui-cell__ft">
<view class="weui-cell__bd">
x {{subItem.quantity}}
</view>
</view>
</view>
</view>
</view>
</block>
<!--服装End -->
</view>
\ No newline at end of file
/* pages/myList/myList.wxss */
/* pages/myList/myList.wxss */
.mineLists {
margin-top: 90rpx;
background-color: #fff;
padding-bottom: 30rpx;
}
.weui-cells__title {
font-size: 38rpx;
color: #4a4a4a;
font-weight: bold;
}
.list-item {
color: #4a4a4a;
font-size: 30rpx;
padding: 16rpx 0rpx;
margin: 0 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #ccc;
}
.weui-cell:before {
border: none;
}
// pages/packinglist/packinglist.js
// pages/packinglist/packinglist.js
Page({
/**
* 页面的初始数据
*/
data: {
// 弹出确认框
refreshFlag: false,
packingCategoryList: [],
packingCategoryListEntry: []
},
save: function () {
// 将 data 存储在本地缓存中指定的 key 中,会覆盖掉原来该 key 对应的内容,这是一个同步接口。
wx.setStorageSync('packingCategoryList', this.data.packingCategoryList);
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function () {
var packingCategoryList = wx.getStorageSync('packingCategoryList');
if (!packingCategoryList) { var packingCategoryList = this.data.packingCategoryList };
for (var i = 0; i < packingCategoryList.length; i++) {
var length = packingCategoryList[i].packingItemList.length;
packingCategoryList[i].input = '';
packingCategoryList[i].newQuantity = 1;
for (var j = 0; j < length; j++) {
if (packingCategoryList[i].packingItemList[j].completed == null) {
packingCategoryList[i].packingItemList[j].completed = true;
}
}
}
this.setData({ packingCategoryList: packingCategoryList });
this.save();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function (res) {
if (res.from === 'button') {
// 来自页面内转发按钮
console.log(res.target)
}
return {
title: '旅行达人出行必备的打包神器',
path: 'pages/list/list',
imageUrl: '../../images/share.jpg',
success: function (res) {
console.log(res)
// 转发成功
},
fail: function (res) {
// 转发失败
}
}
},
// 增加还是删除
action: function (e) {
var index = e.currentTarget.dataset.index;
var subIndex = e.currentTarget.dataset.subindex;
var packingCategoryList = this.data.packingCategoryList;
packingCategoryList[index].packingItemList[subIndex].completed = !packingCategoryList[index].packingItemList[subIndex].completed;
this.setData({
packingCategoryList: packingCategoryList
});
this.save();
},
// ===== 事项内容事件处理函数 =====
inputChangeHandle: function (e) {
var index = e.currentTarget.dataset.index;
var packingCategoryList = this.data.packingCategoryList;
packingCategoryList[index].input = e.detail.value
this.setData({ packingCategoryList: packingCategoryList });
},
// ====数量处理函数
inputQuantityChangeHandle: function (e) {
var index = e.currentTarget.dataset.index;
var packingCategoryList = this.data.packingCategoryList;
packingCategoryList[index].newQuantity = e.detail.value
this.setData({ packingCategoryList: packingCategoryList });
this.save();
},
// 单条数量修改
quantityChangeHandle: function (e) {
var index = e.currentTarget.dataset.index;
var subIndex = e.currentTarget.dataset.subindex;
var packingCategoryList = this.data.packingCategoryList;
packingCategoryList[index].packingItemList[subIndex].quantity = e.detail.value
this.setData({ packingCategoryList: packingCategoryList });
this.save();
},
// 新增
addTodoHandle: function (e) {
var index = e.currentTarget.dataset.index;
var categoryid = e.currentTarget.dataset.categoryid;
var packingCategoryList = this.data.packingCategoryList
if (!packingCategoryList[index].input || !packingCategoryList[index].input.trim()) return;
packingCategoryList[index].packingItemList.push({ categoryId: categoryid, itemId: '-1', itemName: packingCategoryList[index].input, quantity: packingCategoryList[index].newQuantity, completed: true });
packingCategoryList[index].input = '';
packingCategoryList[index].newQuantity = 1;
this.setData({
packingCategoryList: packingCategoryList,
});
this.save();
},
// 创建新清单
refresh: function (e) {
var refreshFlag = this.data.refreshFlag;
refreshFlag = true;
this.setData({ refreshFlag: refreshFlag })
},
answer: function (e) {
var value = e.target.dataset.value;
var refreshFlag = this.data.refreshFlag;
if (value === '1') {
refreshFlag = true;
wx.removeStorageSync('packingCategoryList')
wx.switchTab({
url: '/pages/list/list',
})
} else if (value === '0') {
refreshFlag = false;
}
this.setData({ refreshFlag: refreshFlag })
},
saveLists: function (e) {
var openId = wx.getStorageSync('openId');
var packingCategoryList = wx.getStorageSync('packingCategoryList');
var packingCategoryListEntry = this.data.packingCategoryListEntry;
var packingItemLists = [];
packingCategoryListEntry = packingCategoryList;
for (let i = 0; i < packingCategoryListEntry.length; i++) {
packingItemLists = packingCategoryListEntry[i].packingItemList;
for (let j = 0; j < packingItemLists.length; j++) {
if (packingItemLists[j].completed === false) {
packingItemLists.splice(packingItemLists.indexOf(packingItemLists[j]), 1);
j--;
}
}
if (packingCategoryListEntry[i].packingItemList.length <= 0) {
packingCategoryListEntry.splice(packingCategoryListEntry.indexOf(packingCategoryListEntry[i]), 1)
}
};
// 用户打包清单保存接口
wx.request({
url: 'https://m.zuihuibi.cn/api/promotion/userPackingListSave',
data: {
openid: openId,
packingCategoryList: packingCategoryListEntry
},
method: 'POST',
header: { 'X-Authorization': wx.getStorageSync('X-Authorization') },
dataType: 'json',
success: function (res) {
wx.showToast({
title: '保存成功',
icon: 'success',
duration: 3000
})
},
fail: function (res) {
wx.showToast({
title: '保存失败',
icon: 'none',
duration: 3000
})
}
})
}
})
\ No newline at end of file
{}
{}
\ No newline at end of file
<!--pages/packinglist/packinglist.wxml-->
<!--pages/packinglist/packinglist.wxml-->
<view class='header'>
<view style='font-size:36rpx'>创建你的终极</view>
<view style='font-size:48rpx'>旅行</view>
<view style='font-size:48rpx'>打包清单</view>
</view>
<view class='logo'>
<view class='logo_corner'></view>
<image src='/images/logo.png' style='width:258rpx;height:60rpx;'></image>
</view>
<!--模块-->
<view class='container_list'>
<view class="weui-flex tabContainer">
<view class="weui-flex__item">
<view class='newList' bindtap='refresh'>
<view class='newListTitle'>
<image src='../../images/refresh.svg' style='width:100%;height:100%;'></image>
</view>
创建新清单
</view>
</view>
<view class="weui-flex__item weui-flex__item_last newList tap-active">
<view class='newListTitle'>
<image src='../../images/share.svg' style='width:100%;height:100%;'></image>
</view>
<view>
<button class="shareBtn weui-btn" type="default" plain="true" open-type="share">分享给好友</button>
</view>
</view>
</view>
<view class='totalBox'>
<!--服装 -->
<block wx:if="{{ packingCategoryList.length }}">
<view class='clothing' wx:for="{{packingCategoryList}}" wx:key="{{category}}">
<view class="weui-cells__title category__title">{{item.categoryName}}</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell list-item {{ subItem.completed ? '' : 'completed' }}" wx:for="{{item.packingItemList}}" wx:for-index="subIndex" wx:for-item="subItem" wx:key="{{ itemName }}">
<view class="weui-cell__bd name">{{subItem.itemName}}</view>
<view class="weui-cell__ft">
<view class="weui-cell__bd">
<input class="weui-input list-item__quantity" type="number" value='{{subItem.quantity}}' data-subindex="{{ subIndex }}" data-index="{{ index }}" bindinput="quantityChangeHandle" maxlength="2" />
</view>
<view class="weui-cell__hd weui-check__hd_in-checkbox">
<view class='{{ subItem.completed ? "list-item__disable" : "list-item__enable" }} ' bindtap='action' data-subindex="{{ subIndex }}" data-index="{{ index }}"></view>
</view>
</view>
</view>
</view>
<view class="header_title">
<view class="weui-cell list-item-new-weui-cell">
<view class="weui-cell__bd name">
<input class="list-item-new__title-input" value="{{ item.input }}" placeholder="添加事项..." bindinput="inputChangeHandle" data-categoryId="{{item.id}}" data-index="{{index}}" data-name="{{item.input}}" data-quantity="{{ item.newQuantity }}" />
</view>
<view class="weui-cell__ft">
<view class="weui-cell__bd">
<input class="weui-input list-item__quantity" type="number" value='{{ item.newQuantity }}' bindinput="inputQuantityChangeHandle" maxlength="2" data-category="{{item.id}}" data-index="{{index}}" data-name="{{item.input}}" data-quantity="{{ item.newQuantity }}"
/>
</view>
<view class="weui-cell__hd weui-check__hd_in-checkbox">
<view class='{{ item.completed ? "list-item__disable" : "list-item__enable" }} ' bindtap='addTodoHandle' data-categoryId="{{item.id}}" data-index="{{index}}" data-name="{{item.input}}" data-quantity="{{ item.newQuantity }}"></view>
</view>
</view>
</view>
</view>
</view>
</block>
<!--服装End -->
</view>
<block wx:if="{{ packingCategoryList.length }}">
<view class='saveBtn' bindtap='saveLists'>保存</view>
</block>
<block wx:if="{{ packingCategoryList.length }}">
<view class='markBlock'></view>
</block>
</view>
<!--旅行保险 -->
<block wx:if="{{ packingCategoryList.length }}">
<view class='quote text-center'>
<!-- <text class='quote_message'></text> -->
<view class='quote_message'>
<view>不要忘了打包一份</view>
<view>旅行保险哦!</view>
</view>
<navigator class='quoteBtn' url="/pages/zhbQrcode/zhbQrcode" hover-class="navigator-hover">获取报价</navigator>
</view>
</block>
<block wx:if="{{refreshFlag}}">
<view class='confirmDialogContainer'>
<view class='content'>
<text class='popup__title'>你确定要创建一个新的清单吗?</text>
<view class="popup__body">您将失去当前列表,包括您所做的任何更改。</view>
<view class='popup__actions' bindtap='answer'>
<view class='popup-actions-button' data-value='1'>确定</view>
<view class='popup-actions-cancel' data-value='0'>取消</view>
</view>
</view>
</view>
</block>
\ No newline at end of file
/* pages/packinglist/packinglist.wxss */
/* pages/packinglist/packinglist.wxss */
.header {
padding-bottom: 100rpx;
}
.container_list {
background: #fff;
border-top: 5px solid #8ebfbc;
margin: 0;
position: relative;
z-index: 3;
}
.newList {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
.tabContainer .newListTitle {
width: 40rpx;
height: 40rpx;
margin-right: 10rpx;
margin-top: -20rpx;
}
.container_list .tap-active {
background: #de0615 !important;
border-color: #ce0613 !important;
}
.container_list .tap-active .shareBtn {
color: #fff !important;
font-size: 32rpx;
}
.totalBox {
margin: 0 auto;
padding: 0 40rpx;
}
.category__title {
color: #3b4449;
font-weight: bold;
font-size: 36rpx;
padding-left: 0;
}
.list-item {
margin: 0;
padding: 5px 0;
opacity: 1;
border-top: 1px solid #ccc;
font-weight: normal;
}
.completed .name {
text-decoration: line-through;
color: #888;
}
.weui-cell__ft {
display: flex;
justify-content: center;
align-items: center;
}
.weui-cell:before {
border: none;
}
.list-item-new-weui-cell {
padding: 20rpx 0px;
}
.list-item-new__title-input {
display: block;
width: 90%;
box-sizing: border-box;
border: 1px solid #ccc;
padding: 0 4px;
height: 50rpx;
font-size: 32rpx;
line-height: 50rpx;
box-shadow: none;
border-radius: 0;
background: #fff;
}
.quote {
padding: 20rpx 0;
}
.markBlock{
padding-bottom: 80rpx;
}
.quote .quote_message {
font-size: 32rpx;
}
.quoteBtn {
font-size: 34rpx;
background: #de0615;
color: #fff;
text-align: center;
padding: 12rpx 0;
border-radius: 120rpx;
width: 300rpx;
margin: 10rpx auto 0;
}
.tabContainer {
font-size: 32rpx;
margin: -78rpx auto 0;
width: 100%;
}
.tabContainer .weui-flex__item {
text-align: center;
box-sizing: border-box;
padding: 0 20rpx;
background: #eee;
color: #3b4449;
border-radius: 20rpx 20rpx 0 0;
margin-right: 10rpx;
font-weight: 400;
font-size: 32rpx;
border-bottom: 5px solid #ddd;
cursor: pointer;
height: 80rpx;
line-height: 80rpx;
}
.tabContainer .weui-flex__item_last {
margin-right: 0;
}
.shareBtn {
padding: 0;
}
button[plain], button[type=default][plain] {
border: none;
}
.confirmDialogContainer {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 10;
}
.confirmDialogContainer .content {
position: absolute;
left: 0;
right: 0;
top: calc(50vh - 500rpx/2);
margin: 0 auto;
width: 560rpx;
height: 420rpx;
background: #fff;
padding: 20px;
z-index: 1002;
}
.popup__title {
font-weight: bold;
color: #3a4348;
padding: 0;
margin: 0;
font-size: 40rpx;
line-height: 1em;
}
.popup__body {
font-size: 32rpx;
margin: 20rpx 0 0;
padding: 0;
}
.popup__actions {
margin: 30rpx 0 0;
padding: 30rpx 0 0;
border-top: 3px dotted #d1d1d1;
overflow: hidden;
text-align: center;
}
.popup__actions .popup-actions-button {
background: #de0615;
border-radius: 40rpx;
color: #fff;
padding: 16rpx 0;
}
.popup__actions .popup-actions-cancel {
text-decoration: underline;
color: #de0615;
line-height: 100rpx;
}
.saveBtn {
width: 150rpx;
height: 65rpx;
line-height: 65rpx;
text-align: center;
border-radius: 5px;
background-color: #9bcdcc;
margin-bottom: 20rpx;
font-size: 30rpx;
margin-right: 57rpx;
color: #fff;
margin-left: 40rpx;
}
// pages/zhbQrcode/zhbQrcode.js
// pages/zhbQrcode/zhbQrcode.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
//保存至相册
saveImageToPhotosAlbum: function () {
wx.saveImageToPhotosAlbum({
filePath: '/images/qrcode.jpg',
success: (res) => {
wx.showToast({
title: '保存成功',
icon: 'success',
duration: 2000
})
},
fail: (err) => {
console.log(err)
}
})
}
})
\ No newline at end of file
{}
{}
\ No newline at end of file
<!--pages/zhbQrcode/zhbQrcode.wxml-->
<!--pages/zhbQrcode/zhbQrcode.wxml-->
<view class='eqrcodeContainer'>
<view class='zhbQrcodeBox'>
<image style='width:220rpx;height:220rpx' mode="scaleToFill" src="/images/qrcode.jpg" bindtap='saveImageToPhotosAlbum'></image>
<view class='saveBtn' bindtap='saveImageToPhotosAlbum'>确认保存二维码</view>
</view>
<view class="icon-box">
<icon type="info" size="20" color='#de0615'></icon>
<view class="icon-box__ctn" style='margin-left:16rpx;'>
<view class="icon-box__desc" style='font-size:32rpx;margin:16rpx 0;'>请按图示内容进行操作哦~</view>
</view>
</view>
<image style='width:688rpx;height:820rpx' mode="scaleToFill" src="/images/eqrcode.jpg"></image>
</view>
\ No newline at end of file
/* pages/zhbQrcode/zhbQrcode.wxss */
/* pages/zhbQrcode/zhbQrcode.wxss */
.eqrcodeContainer{
padding:60rpx 30rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.zhbQrcodeBox{
display: flex;
align-items: flex-end;
justify-content: center;
}
.zhbQrcodeBox .saveBtn{
width: 300rpx;
height: 80rpx;
line-height: 80rpx;
font-size: 32rpx;
background-color: #de0615;
color: #fff;
border-radius: 10rpx;
text-align: center;
margin-left: 30rpx;
}
.icon-box{
display: flex;
align-items: center;
}
\ No newline at end of file
{
{
"description": "项目配置文件。",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "1.9.98",
"appid": "wx11f9698a3aff2540",
"projectname": "wxapp",
"isGameTourist": false,
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}
\ No newline at end of file
/*
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
/*
* Perform a simple self-test to see if the VM is working
*/
function md5_vm_test()
{
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function core_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 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+ 0], 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+ 0], 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+ 0], 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 Array(a, b, c, d);
}
/*
* 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 HMAC-MD5, of a key and some data
*/
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var 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));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
return str;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of little-endian words to a base-64 string
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
module.exports = {
MD5:hex_md5
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment