Commit 6417f421 authored by 黄媛媛's avatar 黄媛媛

update

parent 2fd53c56
......@@ -47,8 +47,8 @@ import PAGE_CONFIG from './config/pageConfig.js'
const { Provider } = WeAppRedux;
const store = createStore(reducer) // redux store
let md5 = require('utils/md5.js')
// let netUrl = 'http://testapi.oytour.com/api/common/post';
let netUrl = 'https://reborn.oytour.com/api/common/post';
let netUrl = 'http://testapi.oytour.com/api/common/post';
// let netUrl = 'https://reborn.oytour.com/api/common/post';
App(
Provider(store)(
......
images/index/default1.png

1.86 KB | W: | H:

images/index/default1.png

607 Bytes | W: | H:

images/index/default1.png
images/index/default1.png
images/index/default1.png
images/index/default1.png
  • 2-up
  • Swipe
  • Onion skin
images/index/dperson.png

6.12 KB | W: | H:

images/index/dperson.png

2.46 KB | W: | H:

images/index/dperson.png
images/index/dperson.png
images/index/dperson.png
images/index/dperson.png
  • 2-up
  • Swipe
  • Onion skin
images/index/trip.png

528 KB | W: | H:

images/index/trip.png

92 KB | W: | H:

images/index/trip.png
images/index/trip.png
images/index/trip.png
images/index/trip.png
  • 2-up
  • Swipe
  • Onion skin
// pages/Clockin/Clockin.js
var util = require('../../utils/util.js')
var utilsNew = require('../../utils/utilsNew.js')
const app = getApp()
Page({
......@@ -7,72 +8,181 @@ Page({
* 页面的初始数据
*/
data: {
uploadimgList:[],
msg:{
Name:'22222wwww',
Type:1,
SourceId:'2',
Score:0,
Description:'',
CreateBy:'37284',
ImgList:[],
uploadimgList: [],
msg: {
Name: '22222wwww',
Type: 1,
SourceId: '2',
Score: 0,
Description: '',
CreateBy: '37284',
ImgList: [],
VideoAddress: '',
Cover: '',
},
grey:5,
index:false,
grey: 5,
index: false,
videoUrl: '',
videoContext:'',
playVideoSrc:'',
videoState: false,
},
videoContext: null,
onReady: function (res) {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
console.log("options", options)
if (options.CreateBy){
let msg=this.data.msg;
if (options.CreateBy) {
let msg = this.data.msg;
msg.CreateBy = options.CreateBy;
msg.Name = options.Name;
msg.SourceId = options.SourceId;
msg.Type = options.Type;
this.setData({
msg:msg
msg: msg
})
}
if (options.index){
if (options.index) {
this.setData({
index:true
index: true
})
}
},
tiJiao(){
closeVideo(){
this.setData({
videoState: false,
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.pause();
},
deleteVideo(){
let msg=this.data.msg;
if (msg.Description==''){
util.showToast('text', '说些什么吧!', { duration: 2000 })
msg.VideoAddress='';
this.setData({
msg:msg
})
},
bindPreviewVideo(e) {
let playVideoSrc =this.data.msg.VideoAddress;
this.setData({
videoState: true,
playVideoSrc: playVideoSrc
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.play();
},
bindVideoScreenChange: function ( e) {
var status = e.detail.fullScreen;
console.log(status)
var play = {
playVideo: false
}
if (status) {
play.playVideo = true;
} else {
this.videoContext.pause();
}
this.setData(play);
},
upvideo() {
var aliOssParams = utilsNew.utilNew.aliOssParams();
//上传视频到阿里云
var that = this;
wx.chooseVideo({
maxDuration: 10,
success: function(res) {
var tempFilePath = res.tempFilePath;
var stringFilePath = String(tempFilePath);
var indexType = stringFilePath.lastIndexOf('.');
var type = stringFilePath.substring(indexType);
var alikey = 'video/' + new Date().getTime() +
Math.floor(Math.random() * 1000) + type; //随机1000内的数加上时间戳作为你存放在阿里云video目录下名字和类型。
util.showToast('loading', '上传中', {
duration: 1000 * 100
})
wx.uploadFile({
url: aliOssParams.host,
filePath: tempFilePath,
name: 'file',
formData: {
name: tempFilePath,
key: alikey, //这个是关键它是定义存放在阿里云那个目录下
policy: aliOssParams.policy, //上传阿里云的加密策略
OSSAccessKeyId: aliOssParams.aid, //自己阿里云的aid
success_action_status: "200",
signature: aliOssParams.signature, //上传阿里云的签名
},
success: function(res) {
var videoUrl = aliOssParams.host + '/' + alikey; //这就是刚上传阿里云后的存放的地址链接,通过它打开你刚上传视频。
that.videoUrl = videoUrl;
let msg = that.data.msg;
msg.VideoAddress = that.videoUrl;
let lastUrl = "?x-oss-process=video/snapshot,t_9,f_jpg,w_210,h_0,m_fast";
msg.Cover = that.videoUrl + lastUrl;
msg.ImgList = [];
that.setData({
msg: msg,
uploadimgList:[]
})
util.showToast('text', '上传成功!', {
duration: 2000
})
},
fail: function({
errMsg
}) {
util.showToast('text', '上传失败!', {
duration: 2000
})
},
})
}
})
},
tiJiao() {
let msg = this.data.msg;
if (msg.Description == '') {
util.showToast('text', '说些什么吧!', {
duration: 2000
})
return;
}
app.$api('b2b_post_SetMXYToDayTourPunchCard', msg).then(res => {
console.log("res",res)
console.log("res", res)
let pathUrl = (wx.getStorageSync('pathUrl'))
if (this.data.index){
wx.switchTab({ url: '/pages/index/index' })
}else{
if (this.data.index) {
wx.switchTab({
url: '/pages/index/index'
})
} else {
wx.navigateTo({
url: pathUrl
})
}
}).catch(err => { })
}).catch(err => {})
},
bindinputText(e){
bindinputText(e) {
let val = e.detail.value;
let msg = this.data.msg;
msg.Description=val;
msg.Description = val;
this.setData({
msg:msg
msg: msg
})
},
scoreColor(e){
scoreColor(e) {
let index = e.currentTarget.dataset.index;
let msg = this.data.msg;
msg.Score = index;
......@@ -82,9 +192,9 @@ Page({
grey: grey
})
},
scoreGrey(e){
scoreGrey(e) {
let index = e.currentTarget.dataset.index;
let msg=this.data.msg;
let msg = this.data.msg;
msg.Score = index + msg.Score;
let grey = 5 - msg.Score;
this.setData({
......@@ -93,7 +203,7 @@ Page({
})
},
deleteImg(e) {
let imgIndex= e.currentTarget.dataset.index;
let imgIndex = e.currentTarget.dataset.index;
let that = this;
let uploadimgList = that.data.uploadimgList;
uploadimgList.splice(imgIndex, 1)
......@@ -109,13 +219,13 @@ Page({
let uploadimgList = that.data.uploadimgList;
wx.chooseImage({
sourceType: ['album', 'camera'],
success: function (res) {
success: function(res) {
setTimeout(() => {
wx.showLoading({
title: '上传中,请稍后',
mask: true,
})
var tempFilePaths = res.tempFilePaths;
wx.uploadFile({
url: "https://upload.oytour.com/Upload?filePath=/Upload/Temporary/",
......@@ -125,16 +235,18 @@ Page({
'myfile': tempFilePaths[0],
},
// contentType:'multipart/form-data',
success: function (res) {
success: function(res) {
wx.hideLoading()
if (res.statusCode == 200) {
let url = "http://imgfile.oytour.com";
// let uploadInfo = that.data.uploadInfo;
let path = url + JSON.parse(res.data).FilePath;
uploadimgList.push(path)
let msg=that.data.msg;
let msg = that.data.msg;
msg.ImgList = uploadimgList;
msg.VideoAddress = '';
msg.Cover='';
that.setData({
uploadimgList: uploadimgList,
msg: msg
......@@ -142,9 +254,11 @@ Page({
}
},
fail: function (res) {
fail: function(res) {
wx.hideLoading();
util.showToast('text', '上传失败!', { duration: 2000 })
util.showToast('text', '上传失败!', {
duration: 2000
})
}
})
......@@ -157,49 +271,49 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})
\ No newline at end of file
......@@ -22,14 +22,32 @@
<image bindtap="deleteImg" data-index="{{index}}" class="closeImg" src="../../images/index/close.png"></image>
<image src="{{item}}"></image>
</view>
<view wx:if="{{msg.VideoAddress && msg.VideoAddress!=''}}" class="picItem">
<view style="position:relative">
<image style="width:210rpx;height:210rpx;margin-right:24rpx;border-radius:20rpx;" src="{{msg.Cover}}"></image>
<image bindtap="bindPreviewVideo" class="bfimg" src="../../images/index/bf.png"></image>
<image bindtap="deleteVideo" class="closeImg" src="../../images/index/close.png"></image>
</view>
</view>
<view bindtap="upload" class="picItem upload">
<image src="../../images/index/pic.png"></image>
<view style="margin-top:15rpx" class="c99 f24">添加图片</view>
</view>
<view bindtap="upvideo" class="picItem upload">
<image src="../../images/index/pic.png"></image>
<view style="margin-top:15rpx" class="c99 f24">上传视频</view>
</view>
</view>
</view>
<view class="hr"></view>
<view bindtap="tiJiao" class="sumbitBtn">提交</view>
</view>
\ No newline at end of file
</view>
<view hidden="{{!videoState}}" class="video_box">
<video id="prew_video"
show-fullscreen-btn="fasle"
src="{{playVideoSrc}}"></video>
<image bindtap="closeVideo" class="closeImg" src="../../images/index/close.png"></image>
</view>
\ No newline at end of file
/* pages/Clockin/Clockin.wxss */
.bfimg{
position: absolute;
top:70rpx;
left: 70rpx;
width: 80rpx!important;
height: 80rpx;
}
.video_box{
position: fixed;
width: 100%;
height: 100%;
top: 0;
background: #000;
}
.video_box #prew_video{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin:auto;
width:100%;
}
.video_box .closeImg{
position: absolute;
right: 20rpx;
top: 20rpx;
width: 60rpx!important;
height: 60rpx;
}
.title{
width: 100%;
padding-left: 85rpx;
......@@ -31,6 +62,10 @@
float: left;
margin-bottom: 20rpx;
}
#myVideo{
width: 100%;
height: 100%;
}
.upload{
background:rgba(255,255,255,1);
box-shadow:0px 4rpx 10rpx 0px rgba(207,207,207,0.2);
......@@ -56,7 +91,7 @@
margin:0 auto;
margin-top: 150rpx;
}
.closeImg{
.picItem .closeImg{
position: absolute;
width: 40rpx!important;
height: 40rpx;
......
......@@ -7,10 +7,12 @@ Page({
*/
data: {
msg: {
Id: '847',
Type: 2,
GuestId: '37284'
Id: '11',
Type: 1,
GuestId: '38736'
},
videoState: false,
playVideoSrc:"",
},
/**
......@@ -29,6 +31,24 @@ Page({
}
this.getPinglunList();
},
closeVideo() {
this.setData({
videoState: false,
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.pause();
},
bindPreviewVideo(e) {
console.log("eee",e);
let playVideoSrc = e.currentTarget.dataset.item.VideoAddress;
this.setData({
videoState: true,
playVideoSrc: playVideoSrc
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.play();
},
modeImg(e) {
let img = e.currentTarget.dataset.item.ImgList;
......
......@@ -15,8 +15,19 @@
<view style="margin-top:20rpx">
<image bindtap="modeImg" data-item="{{item}}" wx:for="{{item.ImgList}}" wx:for-item="img" wx:key="index" style="width:250rpx;height:250rpx;margin-right:24rpx;border-radius:20rpx;" src="{{img}}"></image>
</view>
<view wx:if="{{item.Cover && item.Cover!=''}}" style="position:relative">
<image style="width:250rpx;height:250rpx;margin-right:24rpx;border-radius:20rpx;" src="{{item.Cover}}"></image>
<image data-item="{{item}}" bindtap="bindPreviewVideo" class="bfimg" src="../../images/index/bf.png"></image>
</view>
</view>
</view>
<view wx:else style="padding-top:280rpx;text-align:center">
<image style="width:438rpx;height:215rpx" src="../../images/index/nodata.png"></image>
</view>
\ No newline at end of file
<image style="width:438rpx;height:215rpx" src="../../images/index/nodata.png"></image>
</view>
<view hidden="{{!videoState}}" class="video_box">
<video id="prew_video"
show-fullscreen-btn="fasle"
src="{{playVideoSrc}}"></video>
<image bindtap="closeVideo" class="closeImg" src="../../images/index/close.png"></image>
</view>
\ No newline at end of file
/* pages/comments/comments.wxss */
.video_box{
position: fixed;
width: 100%;
height: 100%;
top: 0;
background: #000;
}
.video_box #prew_video{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin:auto;
width:100%;
}
.video_box .closeImg{
position: absolute;
right: 20rpx;
top: 20rpx;
width: 60rpx!important;
height: 60rpx;
}
.bfimg{
position: absolute;
top:80rpx;
left: 80rpx;
width: 80rpx;
height: 80rpx;
}
.comments{
width: 100%;
padding:0 30rpx;
......
......@@ -7,13 +7,15 @@ Page({
*/
data: {
msg:{
Id:'2499',
Id:'2500',
Type:4,
GuestId:'37284'
},
dataInfo:{},
pathUrl:'',
plList:[],
videoState: false,
playVideoSrc: "",
},
/**
......@@ -36,6 +38,23 @@ Page({
pathUrl: pathUrl
})
},
closeVideo() {
this.setData({
videoState: false,
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.pause();
},
bindPreviewVideo(e) {
let playVideoSrc = e.currentTarget.dataset.item.VideoAddress;
this.setData({
videoState: true,
playVideoSrc: playVideoSrc
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.play();
},
modeImg1(e) {
let img = e.currentTarget.dataset.item.ImgList;
wx.previewImage({
......
......@@ -42,5 +42,15 @@
<view style="margin-top:20rpx">
<image bindtap="modeImg1" data-item="{{item}}" wx:for="{{item.ImgList}}" wx:for-item="img" wx:key="index" style="width:250rpx;height:250rpx;margin-right:24rpx" src="{{img}}"></image>
</view>
<view wx:if="{{item.Cover && item.Cover}}" style="position:relative">
<image style="width:250rpx;height:250rpx;margin-right:24rpx;border-radius:20rpx;" src="{{item.Cover}}"></image>
<image data-item="{{item}}" bindtap="bindPreviewVideo" class="bfimg" src="../../../images/index/bf.png"></image>
</view>
</view>
</view>
\ No newline at end of file
</view>
<view hidden="{{!videoState}}" class="video_box">
<video id="prew_video"
show-fullscreen-btn="fasle"
src="{{playVideoSrc}}"></video>
<image bindtap="closeVideo" class="closeImg" src="../../../images/index/close.png"></image>
</view>
\ No newline at end of file
/* pages/comments/comments.wxss */
.video_box{
position: fixed;
width: 100%;
height: 100%;
top: 0;
background: #000;
}
.video_box #prew_video{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin:auto;
width:100%;
}
.video_box .closeImg{
position: absolute;
right: 20rpx;
top: 20rpx;
width: 60rpx!important;
height: 60rpx;
}
.bfimg{
position: absolute;
top:80rpx;
left: 80rpx;
width: 80rpx;
height: 80rpx;
}
.sceneDetail{
width: 100%;
background: #FAFAFA;
......
......@@ -30,8 +30,8 @@ Page({
configId: '',
tcid: '',
pathUrl: '/pages/index/index',
optionTCID: '8705',
// 7003
optionTCID: '7003' ,
// 8705
getimg: true,
guidegrey: 5,
guidemsg: {
......
......@@ -14,6 +14,8 @@ Page({
dataInfo: {},
pathUrl:'',
plList:[],
videoState: false,
playVideoSrc: "",
},
/**
......@@ -36,6 +38,23 @@ Page({
pathUrl: pathUrl
})
},
closeVideo() {
this.setData({
videoState: false,
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.pause();
},
bindPreviewVideo(e) {
let playVideoSrc = e.currentTarget.dataset.item.VideoAddress;
this.setData({
videoState: true,
playVideoSrc: playVideoSrc
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.play();
},
modeImg1(e) {
let img = e.currentTarget.dataset.item.ImgList;
wx.previewImage({
......
......@@ -45,5 +45,15 @@
<view style="margin-top:20rpx">
<image bindtap="modeImg1" data-item="{{item}}" wx:for="{{item.ImgList}}" wx:for-item="img" wx:key="index" style="width:250rpx;height:250rpx;margin-right:24rpx" src="{{img}}"></image>
</view>
<view wx:if="{{item.Cover && item.Cover}}" style="position:relative">
<image style="width:250rpx;height:250rpx;margin-right:24rpx;border-radius:20rpx;" src="{{item.Cover}}"></image>
<image data-item="{{item}}" bindtap="bindPreviewVideo" class="bfimg" src="../../../images/index/bf.png"></image>
</view>
</view>
</view>
\ No newline at end of file
</view>
<view hidden="{{!videoState}}" class="video_box">
<video id="prew_video"
show-fullscreen-btn="fasle"
src="{{playVideoSrc}}"></video>
<image bindtap="closeVideo" class="closeImg" src="../../../images/index/close.png"></image>
</view>
\ No newline at end of file
/* pages/comments/comments.wxss */
.video_box{
position: fixed;
width: 100%;
height: 100%;
top: 0;
background: #000;
}
.video_box #prew_video{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin:auto;
width:100%;
}
.video_box .closeImg{
position: absolute;
right: 20rpx;
top: 20rpx;
width: 60rpx!important;
height: 60rpx;
}
.bfimg{
position: absolute;
top:80rpx;
left: 80rpx;
width: 80rpx;
height: 80rpx;
}
.sceneDetail{
width: 100%;
background: #FAFAFA;
......
......@@ -7,13 +7,15 @@ Page({
*/
data: {
msg: {
Id: '2162',
Id: '847',
Type: 2,
GuestId: '37284'
},
dataInfo: {},
pathUrl:'',
plList:[],
videoState: false,
playVideoSrc: "",
},
/**
......@@ -37,6 +39,24 @@ Page({
this.getPinglunList();
},
closeVideo() {
this.setData({
videoState: false,
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.pause();
},
bindPreviewVideo(e) {
let playVideoSrc = e.currentTarget.dataset.item.VideoAddress;
this.setData({
videoState: true,
playVideoSrc: playVideoSrc
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.play();
},
modeImg1(e) {
let img = e.currentTarget.dataset.item.ImgList;
wx.previewImage({
......
......@@ -43,5 +43,16 @@
<view style="margin-top:20rpx">
<image bindtap="modeImg1" data-item="{{item}}" wx:for="{{item.ImgList}}" wx:for-item="img" wx:key="index" style="width:250rpx;height:250rpx;margin-right:24rpx" src="{{img}}"></image>
</view>
<view wx:if="{{item.Cover && item.Cover}}" style="position:relative">
<image style="width:250rpx;height:250rpx;margin-right:24rpx;border-radius:20rpx;" src="{{item.Cover}}"></image>
<image data-item="{{item}}" bindtap="bindPreviewVideo" class="bfimg" src="../../../images/index/bf.png"></image>
</view>
</view>
</view>
\ No newline at end of file
</view>
<view hidden="{{!videoState}}" class="video_box">
<video id="prew_video"
show-fullscreen-btn="fasle"
src="{{playVideoSrc}}"></video>
<image bindtap="closeVideo" class="closeImg" src="../../../images/index/close.png"></image>
</view>
\ No newline at end of file
/* pages/comments/comments.wxss */
.video_box{
position: fixed;
width: 100%;
height: 100%;
top: 0;
background: #000;
}
.video_box #prew_video{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin:auto;
width:100%;
}
.video_box .closeImg{
position: absolute;
right: 20rpx;
top: 20rpx;
width: 60rpx!important;
height: 60rpx;
}
.bfimg{
position: absolute;
top:80rpx;
left: 80rpx;
width: 80rpx;
height: 80rpx;
}
.sceneDetail{
width: 100%;
background: #FAFAFA;
......
......@@ -14,6 +14,8 @@ Page({
dataInfo: {},
pathUrl:'',
plList: [],
videoState: false,
playVideoSrc: "",
},
/**
......@@ -36,6 +38,23 @@ Page({
pathUrl: pathUrl
})
},
closeVideo() {
this.setData({
videoState: false,
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.pause();
},
bindPreviewVideo(e) {
let playVideoSrc = e.currentTarget.dataset.item.VideoAddress;
this.setData({
videoState: true,
playVideoSrc: playVideoSrc
})
this.videoContext = wx.createVideoContext('prew_video');
this.videoContext.play();
},
modeImg1(e) {
let img = e.currentTarget.dataset.item.ImgList;
wx.previewImage({
......
......@@ -43,5 +43,16 @@
<view style="margin-top:20rpx">
<image bindtap="modeImg1" data-item="{{item}}" wx:for="{{item.ImgList}}" wx:for-item="img" wx:key="index" style="width:250rpx;height:250rpx;margin-right:24rpx" src="{{img}}"></image>
</view>
<view wx:if="{{item.Cover && item.Cover}}" style="position:relative">
<image style="width:250rpx;height:250rpx;margin-right:24rpx;border-radius:20rpx;" src="{{item.Cover}}"></image>
<image data-item="{{item}}" bindtap="bindPreviewVideo" class="bfimg" src="../../../images/index/bf.png"></image>
</view>
</view>
</view>
\ No newline at end of file
</view>
<view hidden="{{!videoState}}" class="video_box">
<video id="prew_video"
show-fullscreen-btn="fasle"
src="{{playVideoSrc}}"></video>
<image bindtap="closeVideo" class="closeImg" src="../../../images/index/close.png"></image>
</view>
\ No newline at end of file
.video_box #prew_video{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin:auto;
width:100%;
}
.video_box .closeImg{
position: absolute;
right: 20rpx;
top: 20rpx;
width: 60rpx!important;
height: 60rpx;
}
.bfimg{
position: absolute;
top:80rpx;
left: 80rpx;
width: 80rpx;
height: 80rpx;
}
.sceneDetail{
width: 100%;
background: #FAFAFA;
......
var Base64 = {
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode(str) { // 加密
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
str = this._utf16to8(str);
while (i < str.length) {
chr1 = str.charCodeAt(i++);
chr2 = str.charCodeAt(i++);
chr3 = str.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
} return output;
},
decode(input) { // 解密
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
} return this._utf8to16(output);
},
_utf16to8: function (str) {
var out, i, len, c;
out = "";
len = str.length;
for (i = 0; i < len; i++) {
c = str.charCodeAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
out += str.charAt(i);
} else if (c > 0x07FF) {
out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
} else {
out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
}
}
return out;
},
_utf8to16(str) {
var out, i, len, c;
var char2, char3;
out = "";
len = str.length;
i = 0;
while (i < len) {
c = str.charCodeAt(i++);
switch (c >> 4) {
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case7:
out += str.charAt(i - 1);
break;
case 12: case 13:
char2 = str.charCodeAt(i++);
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
char2 = str.charCodeAt(i++);
char3 = str.charCodeAt(i++);
out += String.fromCharCode(((c & 0x0F) << 12) |
((char2 & 0x3F) << 6) |
((char3 & 0x3F) << 0));
break;
}
} return out;
}
}
/* 暴露函数 */
// module.exports = base64
export { Base64 }
\ No newline at end of file
var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
// Global Crypto object
const Crypto = {};
// Crypto utilities
Crypto.utilNew = {
// Bit-wise rotate left
rotl: function (n, b) {
return (n << b) | (n >>> (32 - b));
},
// Bit-wise rotate right
rotr: function (n, b) {
return (n << (32 - b)) | (n >>> b);
},
// Swap big-endian to little-endian and vice versa
endian: function (n) {
// If number given, swap endian
if (n.constructor == Number) {
return utilNew.rotl(n, 8) & 0x00FF00FF |
utilNew.rotl(n, 24) & 0xFF00FF00;
}
// Else, assume array and swap all items
for (var i = 0; i < n.length; i++)
n[i] = utilNew.endian(n[i]);
return n;
},
// Generate an array of any length of random bytes
randomBytes: function (n) {
for (var bytes = []; n > 0; n--)
bytes.push(Math.floor(Math.random() * 256));
return bytes;
},
// Convert a string to a byte array
stringToBytes: function (str) {
var bytes = [];
for (var i = 0; i < str.length; i++)
bytes.push(str.charCodeAt(i));
return bytes;
},
// Convert a byte array to a string
bytesToString: function (bytes) {
var str = [];
for (var i = 0; i < bytes.length; i++)
str.push(String.fromCharCode(bytes[i]));
return str.join("");
},
// Convert a string to big-endian 32-bit words
stringToWords: function (str) {
var words = [];
for (var c = 0, b = 0; c < str.length; c++ , b += 8)
words[b >>> 5] |= str.charCodeAt(c) << (24 - b % 32);
return words;
},
// Convert a byte array to big-endian 32-bits words
bytesToWords: function (bytes) {
var words = [];
for (var i = 0, b = 0; i < bytes.length; i++ , b += 8)
words[b >>> 5] |= bytes[i] << (24 - b % 32);
return words;
},
// Convert big-endian 32-bit words to a byte array
wordsToBytes: function (words) {
var bytes = [];
for (var b = 0; b < words.length * 32; b += 8)
bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
return bytes;
},
// Convert a byte array to a hex string
bytesToHex: function (bytes) {
var hex = [];
for (var i = 0; i < bytes.length; i++) {
hex.push((bytes[i] >>> 4).toString(16));
hex.push((bytes[i] & 0xF).toString(16));
}
return hex.join("");
},
// Convert a hex string to a byte array
hexToBytes: function (hex) {
var bytes = [];
for (var c = 0; c < hex.length; c += 2)
bytes.push(parseInt(hex.substr(c, 2), 16));
return bytes;
},
// Convert a byte array to a base-64 string
bytesToBase64: function (bytes) {
// Use browser-native function if it exists
if (typeof btoa == "function") return btoa(utilNew.bytesToString(bytes));
var base64 = [],
overflow;
for (var i = 0; i < bytes.length; i++) {
switch (i % 3) {
case 0:
base64.push(base64map.charAt(bytes[i] >>> 2));
overflow = (bytes[i] & 0x3) << 4;
break;
case 1:
base64.push(base64map.charAt(overflow | (bytes[i] >>> 4)));
overflow = (bytes[i] & 0xF) << 2;
break;
case 2:
base64.push(base64map.charAt(overflow | (bytes[i] >>> 6)));
base64.push(base64map.charAt(bytes[i] & 0x3F));
overflow = -1;
}
}
// Encode overflow bits, if there are any
if (overflow != undefined && overflow != -1)
base64.push(base64map.charAt(overflow));
// Add padding
while (base64.length % 4 != 0) base64.push("=");
return base64.join("");
},
// Convert a base-64 string to a byte array
base64ToBytes: function (base64) {
// Use browser-native function if it exists
if (typeof atob == "function") return utilNew.stringToBytes(atob(base64));
// Remove non-base-64 characters
base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
var bytes = [];
for (var i = 0; i < base64.length; i++) {
switch (i % 4) {
case 1:
bytes.push((base64map.indexOf(base64.charAt(i - 1)) << 2) |
(base64map.indexOf(base64.charAt(i)) >>> 4));
break;
case 2:
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & 0xF) << 4) |
(base64map.indexOf(base64.charAt(i)) >>> 2));
break;
case 3:
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & 0x3) << 6) |
(base64map.indexOf(base64.charAt(i))));
break;
}
}
return bytes;
},
HMAC: function (hasher, message, key, options) {
// Allow arbitrary length keys
key = key.length > 16 * 4 ?
hasher(key, { asBytes: true }) :
Crypto.utilNew.stringToBytes(key);
// XOR keys with pad constants
var okey = key,
ikey = key.slice(0);
for (var i = 0; i < 16 * 4; i++) {
okey[i] ^= 0x5C;
ikey[i] ^= 0x36;
}
var hmacbytes = hasher(Crypto.utilNew.bytesToString(okey) +
hasher(Crypto.utilNew.bytesToString(ikey) + message, { asString: true }),
{ asBytes: true });
return options && options.asBytes ? hmacbytes :
options && options.asString ? Crypto.utilNew.bytesToString(hmacbytes) :
Crypto.utilNew.bytesToHex(hmacbytes);
},
sha11: function (k) {
var u = Crypto.utilNew.stringToWords(k),
v = k.length * 8,
o = [],
q = 1732584193,
p = -271733879,
h = -1732584194,
g = 271733878,
f = -1009589776;
u[v >> 5] |= 128 << (24 - v % 32);
u[((v + 64 >>> 9) << 4) + 15] = v;
for (var y = 0; y < u.length; y += 16) {
var D = q,
C = p,
B = h,
A = g,
z = f;
for (var x = 0; x < 80; x++) {
if (x < 16) {
o[x] = u[y + x]
} else {
var s = o[x - 3] ^ o[x - 8] ^ o[x - 14] ^ o[x - 16];
o[x] = (s << 1) | (s >>> 31)
}
var r = ((q << 5) | (q >>> 27)) + f + (o[x] >>> 0) + (x < 20 ? (p & h | ~p & g) + 1518500249 : x < 40 ? (p ^ h ^ g) + 1859775393 : x < 60 ? (p & h | p & g | h & g) - 1894007588 : (p ^ h ^ g) - 899497514);
f = g;
g = h;
h = (p << 30) | (p >>> 2);
p = q;
q = r
}
q += D;
p += C;
h += B;
g += A;
f += z
}
return [q, p, h, g, f]
},
SHA1: function (e, c) {
var d = Crypto.utilNew.wordsToBytes(Crypto.utilNew.sha11(e));
return c && c.asBytes ? d : c && c.asString ? Crypto.utilNew.bytesToString(d) : Crypto.utilNew.bytesToHex(d)
}
};
// Crypto mode namespace
Crypto.mode = {};
export { Crypto }
\ No newline at end of file
// import base64 from "../base-64"
var base64 = require('./base64')
import { Crypto } from "./crypto.js"
const utilNew = {
aliOssParams() {
var aid = "LTAIwE7l9dImZSa3";//你自己的阿里云的accessid
var aky = "j47Ajn0d0WzUCIX8Biyj3P2r8QDltI";//你自己的阿里云的accesskey
var host = "http://vt-im-bucket.oss-cn-chengdu.aliyuncs.com";//你自己的阿里云域名
var policyText = {
"expiration": "2022-01-01T12:00:00.000Z",//上传的文件失效日期自己定义
"conditions": [
["content-length-range", 0, 10485760000]//上传的内容大小,自己定义
]
};
var policy = base64.Base64.encode(JSON.stringify(policyText));//生成的加密策略
var bytes = Crypto.utilNew.HMAC(Crypto.utilNew.SHA1, policy, aky, { asBytes: true });
var signature = Crypto.utilNew.bytesToBase64(bytes);//生成的签名
return {
policy: policy,
signature: signature,
aid: aid,
host: host
}
}
}
export { utilNew }
\ 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