Merge branch 'test' of https://e.coding.net/g-cphe0354/duanju/new_app into gaohao
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/node_modules/
|
||||
/unpackage/
|
||||
/unpackage/dist/
|
||||
/unpackage/dist/cache/
|
||||
|
||||
9
.hbuilderx/launch.json
Normal file
9
.hbuilderx/launch.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"version" : "1.0",
|
||||
"configurations" : [
|
||||
{
|
||||
"playground" : "custom",
|
||||
"type" : "uni-app:app-android"
|
||||
}
|
||||
]
|
||||
}
|
||||
8
App.vue
8
App.vue
@@ -1,4 +1,5 @@
|
||||
<script>
|
||||
import { init } from '@/api/init.js'
|
||||
import http from '@/http/http.js'
|
||||
export default {
|
||||
onLaunch: function () {
|
||||
@@ -13,9 +14,10 @@
|
||||
|
||||
},
|
||||
onShow: function () {
|
||||
init()
|
||||
// ios是否在审核
|
||||
http.request({
|
||||
url: 'common/type/919',
|
||||
url: '/common/type/919',
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
uni.setStorageSync('isExamine', res.data.value)
|
||||
@@ -86,7 +88,6 @@
|
||||
margin: 0;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
|
||||
}
|
||||
|
||||
.initStyle {
|
||||
@@ -118,7 +119,4 @@
|
||||
top: 800rpx;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
35
api/index/index.js
Normal file
35
api/index/index.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import http from '@/http/http.js'
|
||||
|
||||
// 获取弹窗信息
|
||||
export const announcement = (data) => {
|
||||
return http.request({
|
||||
url: '/announcement',
|
||||
data
|
||||
})
|
||||
}
|
||||
// 获取公告
|
||||
export const messageselectMessage = (data) => {
|
||||
return http.request({
|
||||
url: '/message/selectMessage',
|
||||
data: {
|
||||
page: 1,
|
||||
limit: 5,
|
||||
state: 1
|
||||
}
|
||||
})
|
||||
}
|
||||
// 获取推荐视频
|
||||
export const courseselectCourse = (data) => {
|
||||
return http.request({
|
||||
url: '/course/selectCourse',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 搜索
|
||||
export const selectCourseTitles = (data) => {
|
||||
return http.request({
|
||||
url: '/course/selectCourseTitles',
|
||||
data
|
||||
})
|
||||
}
|
||||
13
api/init.js
Normal file
13
api/init.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import http from '@/http/http.js'
|
||||
|
||||
export async function init() {
|
||||
|
||||
//热搜词
|
||||
http.request({
|
||||
url: 'common/type/249',
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
uni.setStorageSync('moreSearch', res.data.value)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import http from '@/http/http.js'
|
||||
export const selectByUserId = (data) => {
|
||||
return http.request({
|
||||
url: '/courseCollect/selectByUserId',
|
||||
data: data
|
||||
data: data,
|
||||
method: 'GET'
|
||||
})
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export const h5Config = {
|
||||
|
||||
export const AppConfig = {
|
||||
production: 'https://dj-api.hnsiyao.cn',
|
||||
test: 'https://video-h5.hnsiyao.cn',
|
||||
test: 'https://web-api.hnsiyao.cn',
|
||||
local: 'http://192.168.1.41:8100'
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,11 @@ import {
|
||||
} from 'lodash';
|
||||
import config from '@/commons/config.js'
|
||||
// 测试服
|
||||
let baseUrl = config.baseApiUrl
|
||||
let baseUrl = config.baseApiUrl + 'app'
|
||||
const loadingShowTime = 200
|
||||
|
||||
function getHeader() {
|
||||
const headerObject = {}
|
||||
// headerObject["token"] = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNjkyNSIsImlhdCI6MTczNTg4OTk5NCwiZXhwIjoxNzM2NDk0Nzk0fQ.j-KFEE1FHckmFCO8UA884RBWvpMv8MfEGj7GPGf3kVo6sHeORl043Yle_w7HdTZKPpQqSr2LQLCq_rUxG4qqwA'
|
||||
headerObject["token"] = uni.getStorageSync('token')
|
||||
return headerObject
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@
|
||||
"NSPhotoLibraryUsageDescription" : "获取您的相册读取权限,目的是为了在我的资料页面使用相册读取功能,修改上传头像",
|
||||
"NSCameraUsageDescription" : "获取您的摄像头权限,目的是为了在我的资料页面使用摄像头功能,修改上传头像"
|
||||
},
|
||||
"urltypes" : "com.hnsiyao.duanju"
|
||||
"urltypes" : "com.hnsiyao.duanju",
|
||||
"dSYMs" : false
|
||||
},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs" : {
|
||||
|
||||
11
pages.json
11
pages.json
@@ -31,8 +31,11 @@
|
||||
"path": "pages/chasingDrama/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "",
|
||||
"navigationStyle": "custom"
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
}, {
|
||||
"path": "pages/watching_history/watching_history"
|
||||
}, {
|
||||
"path": "pages/me/index",
|
||||
"style": {
|
||||
@@ -71,8 +74,7 @@
|
||||
},
|
||||
{
|
||||
"path": "pages/index/search/index",
|
||||
"style" :
|
||||
{
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索"
|
||||
}
|
||||
}
|
||||
@@ -88,8 +90,7 @@
|
||||
"selectedColor": "#FF7581",
|
||||
"backgroundColor": "#FFFFFF",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"list": [{
|
||||
"pagePath": "pages/index/index",
|
||||
"iconPath": "static/tabbar/index.png",
|
||||
"selectedIconPath": "static/tabbar/index_2.png",
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
<view class="list-wrap">
|
||||
<view class="title-wrap">
|
||||
<view class="title">最近观看</view>
|
||||
<view class="more">更多</view>
|
||||
<navigator class="more" url="/pages/watching_history/watching_history?type=3">更多</navigator>
|
||||
</view>
|
||||
<view class="list">
|
||||
<view class="item">
|
||||
<div class="item-content">
|
||||
<view class="cover">
|
||||
<image class="img" src="https://img0.baidu.com/it/u=966333451,3199467079&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=714" mode="aspectFill"></image>
|
||||
<view class="num">第三集</view>
|
||||
@@ -17,10 +16,8 @@
|
||||
<view class="name">我在八十年代当后妈</view>
|
||||
<view class="t">言情</view>
|
||||
</view>
|
||||
</div>
|
||||
</view>
|
||||
<view class="item">
|
||||
<div class="item-content">
|
||||
<view class="cover">
|
||||
<image class="img" src="https://img0.baidu.com/it/u=966333451,3199467079&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=714" mode="aspectFill"></image>
|
||||
<view class="num">第三集</view>
|
||||
@@ -29,10 +26,8 @@
|
||||
<view class="name">我在八十年代当后妈</view>
|
||||
<view class="t">言情</view>
|
||||
</view>
|
||||
</div>
|
||||
</view>
|
||||
<view class="item">
|
||||
<div class="item-content">
|
||||
<view class="cover">
|
||||
<image class="img" src="https://img0.baidu.com/it/u=966333451,3199467079&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=714" mode="aspectFill"></image>
|
||||
<view class="num">第三集</view>
|
||||
@@ -41,10 +36,8 @@
|
||||
<view class="name">我在八十年代当后妈</view>
|
||||
<view class="t">言情</view>
|
||||
</view>
|
||||
</div>
|
||||
</view>
|
||||
<view class="item">
|
||||
<div class="item-content">
|
||||
<view class="cover">
|
||||
<image class="img" src="https://img0.baidu.com/it/u=966333451,3199467079&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=714" mode="aspectFill"></image>
|
||||
<view class="num">第三集</view>
|
||||
@@ -53,10 +46,8 @@
|
||||
<view class="name">我在八十年代当后妈</view>
|
||||
<view class="t">言情</view>
|
||||
</view>
|
||||
</div>
|
||||
</view>
|
||||
<view class="item">
|
||||
<div class="item-content">
|
||||
<view class="cover">
|
||||
<image class="img" src="https://img0.baidu.com/it/u=966333451,3199467079&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=714" mode="aspectFill"></image>
|
||||
<view class="num">第三集</view>
|
||||
@@ -65,26 +56,13 @@
|
||||
<view class="name">我在八十年代当后妈</view>
|
||||
<view class="t">言情</view>
|
||||
</view>
|
||||
</div>
|
||||
</view>
|
||||
<view class="item">
|
||||
<div class="item-content">
|
||||
<view class="cover">
|
||||
<image class="img" src="https://img0.baidu.com/it/u=966333451,3199467079&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=714" mode="aspectFill"></image>
|
||||
<view class="num">第三集</view>
|
||||
</view>
|
||||
<view class="intro-wrap">
|
||||
<view class="name">我在八十年代当后妈</view>
|
||||
<view class="t">言情</view>
|
||||
</view>
|
||||
</div>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-wrap">
|
||||
<view class="title-wrap">
|
||||
<view class="title">我的追剧</view>
|
||||
<view class="more">更多</view>
|
||||
<navigator class="more" url="/pages/watching_history/watching_history?type=1">更多</navigator>
|
||||
</view>
|
||||
<view class="list">
|
||||
<view class="item">
|
||||
@@ -105,20 +83,37 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive } from 'vue';
|
||||
import { selectByUserId } from '@/api/me/me.js';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app';
|
||||
|
||||
async function selectByUserIdAjax() {
|
||||
try {
|
||||
const res = await selectByUserId();
|
||||
console.log(res);
|
||||
const res1 = await selectByUserId({ page: 1, limit: 6, classify: 3 });
|
||||
const res2 = await selectByUserId({ page: 1, limit: 6, classify: 6 });
|
||||
console.log(res1);
|
||||
console.log(res2);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
const data = reactive({
|
||||
list1: [], // 最近观看
|
||||
list2: [] // 我的追剧
|
||||
});
|
||||
|
||||
// 滚动到底部
|
||||
onReachBottom(() => {});
|
||||
|
||||
// 监听下拉结束
|
||||
onPullDownRefresh(() => {
|
||||
selectByUserIdAjax();
|
||||
});
|
||||
|
||||
// 页面初始化
|
||||
onLoad(() => {
|
||||
selectByUserId();
|
||||
selectByUserIdAjax();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -155,10 +150,10 @@ page {
|
||||
grid-row-gap: 28upx;
|
||||
padding: 0 28upx;
|
||||
.item {
|
||||
.item-content {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
background-color: #fff;
|
||||
border-radius: 30upx;
|
||||
border-radius: 20upx;
|
||||
.cover {
|
||||
height: 200upx;
|
||||
position: relative;
|
||||
@@ -197,5 +192,4 @@ page {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
import {
|
||||
reactive
|
||||
} from 'vue';
|
||||
import { announcement, messageselectMessage,courseselectCourse } from '@/api/index/index.js'
|
||||
import {
|
||||
onLoad,
|
||||
onReachBottom
|
||||
@@ -91,10 +92,8 @@
|
||||
})
|
||||
|
||||
// 获取弹窗信息
|
||||
function getPop() {
|
||||
http.request({
|
||||
url: 'app/announcement',
|
||||
}).then(res => {
|
||||
async function getPop() {
|
||||
let res = await announcement()
|
||||
if (res.code == 0) {
|
||||
if (res.data && res.data.state == 1) {
|
||||
datas.ruleShow = true
|
||||
@@ -108,7 +107,6 @@
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
// 搜索跳转
|
||||
function moreVideo() {
|
||||
@@ -117,15 +115,8 @@
|
||||
});
|
||||
}
|
||||
// 公告
|
||||
function getMsg() {
|
||||
http.request({
|
||||
url: 'app/message/selectMessage',
|
||||
data: {
|
||||
page: 1,
|
||||
limit: 5,
|
||||
state: 1
|
||||
}
|
||||
}).then(res => {
|
||||
async function getMsg() {
|
||||
let res = await messageselectMessage()
|
||||
if (res.code == 0) {
|
||||
datas.noticeList = res.data.list
|
||||
} else {
|
||||
@@ -135,23 +126,20 @@
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取推荐视频
|
||||
function getrecomVideo(sort, active = 1) {
|
||||
async function getrecomVideo(sort, active = 1) {
|
||||
datas.active = active
|
||||
if (sort) {
|
||||
datas.page = 1
|
||||
}
|
||||
http.request({
|
||||
url: 'app/course/selectCourse',
|
||||
data: {
|
||||
let res = await courseselectCourse({
|
||||
page: datas.page,
|
||||
limit: 12,
|
||||
sort: sort,
|
||||
classifyId: ''
|
||||
}
|
||||
}).then(res => {
|
||||
})
|
||||
|
||||
if (res.code == 0) {
|
||||
if (datas.page == 1) {
|
||||
datas.list = res.data.list
|
||||
@@ -165,7 +153,6 @@
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
<u-sticky :enable="true">
|
||||
<view class="search-box">
|
||||
<u-search bg-color="#f2f2f2" style="width: 100%;" placeholder="搜索更多资源" :focus="true" :show-action="true"
|
||||
:animation="true" action-text="取消" @custom="goBack()" @search="doSearch(false)"></u-search>
|
||||
:animation="true" action-text="取消" v-model="datas.keyword" @custom="goBack()"
|
||||
@search="doSearch(false)"></u-search>
|
||||
</view>
|
||||
</u-sticky>
|
||||
</view>
|
||||
@@ -26,6 +27,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { selectCourseTitles } from '@/api/index/index.js'
|
||||
import {
|
||||
reactive
|
||||
} from 'vue';
|
||||
@@ -34,6 +36,8 @@
|
||||
} from '@dcloudio/uni-app'
|
||||
let datas = reactive({
|
||||
hotKeywordList: [], //热搜
|
||||
keywordList: [],// 搜索列表
|
||||
keyword: "",// 搜索关键字
|
||||
})
|
||||
onShow(() => {
|
||||
getList()
|
||||
@@ -46,6 +50,20 @@
|
||||
datas.hotKeywordList = []
|
||||
}
|
||||
}
|
||||
// 搜索
|
||||
async function doSearch() {
|
||||
let res = await selectCourseTitles({
|
||||
title: datas.keyword,
|
||||
limit: 20,
|
||||
page: 1,
|
||||
})
|
||||
datas.keywordList = res.data.list
|
||||
}
|
||||
|
||||
// 取消返回首页
|
||||
function goBack() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
<view class="content">
|
||||
<view class="user-info">
|
||||
<view class="logo-wrap">
|
||||
<view class="logo"></view>
|
||||
<view class="logo">
|
||||
<image class="img" src="/static/logo.png" mode="widthFix"></image>
|
||||
</view>
|
||||
<view class="quick-menu">
|
||||
<image class="icon" src="/static/me/logo_btn1.png" mode="aspectFit"></image>
|
||||
<image class="icon" src="/static/me/logo_btn2.png" mode="aspectFit"></image>
|
||||
@@ -137,7 +139,15 @@ page {
|
||||
.user-info {
|
||||
.logo-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
.logo {
|
||||
width: 160upx;
|
||||
.img {
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
.quick-menu {
|
||||
display: flex;
|
||||
gap: 20upx;
|
||||
@@ -151,6 +161,7 @@ page {
|
||||
.top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-top: 40upx;
|
||||
.avatar {
|
||||
$size: 94upx;
|
||||
width: $size;
|
||||
|
||||
126
pages/watching_history/watching_history.vue
Normal file
126
pages/watching_history/watching_history.vue
Normal file
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="list">
|
||||
<view class="item" v-for="item in listData.list" :key="item.id">
|
||||
<view class="cover">
|
||||
<image class="img" :src="item.titleImg" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="info">
|
||||
<view class="title">
|
||||
{{ item.title }}
|
||||
</view>
|
||||
<view class="record">看到{{ item.courseDetailsName }}</view>
|
||||
<view class="btm">
|
||||
<view class="num">
|
||||
<view v-if="item.courseDetailsCount">更新{{ item.courseDetailsCount }}</view>
|
||||
</view>
|
||||
<view class="btn">继续观看</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
|
||||
|
||||
import { selectByUserId } from '@/api/me/me.js';
|
||||
|
||||
const type = ref(1);
|
||||
const typeList = ref([
|
||||
{
|
||||
type: 1,
|
||||
label: '我的追剧'
|
||||
},
|
||||
{
|
||||
type: 3,
|
||||
label: '最近观看'
|
||||
}
|
||||
]);
|
||||
|
||||
const listData = reactive({
|
||||
list: [],
|
||||
page: 1,
|
||||
size: 10
|
||||
});
|
||||
|
||||
// 获取数据
|
||||
async function selectByUserIdAjax() {
|
||||
try {
|
||||
const res = await selectByUserId({
|
||||
page: listData.page,
|
||||
limit: listData.size,
|
||||
classify: type.value
|
||||
});
|
||||
console.log(res);
|
||||
if (res.code === 0) {
|
||||
listData.list = res.data.records;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
onReachBottom(() => {
|
||||
listData.page++;
|
||||
selectByUserIdAjax();
|
||||
});
|
||||
|
||||
onLoad((e) => {
|
||||
if (e.type) {
|
||||
type.value = e.type;
|
||||
uni.setNavigationBarTitle({
|
||||
title: typeList.value.find((item) => item.type == type.value).label
|
||||
});
|
||||
}
|
||||
selectByUserIdAjax();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.container {
|
||||
padding: 28upx;
|
||||
color: #333;
|
||||
font-size: 29upx;
|
||||
}
|
||||
.list {
|
||||
.item {
|
||||
padding: 28upx 0;
|
||||
display: flex;
|
||||
.cover {
|
||||
width: 150upx;
|
||||
height: 200upx;
|
||||
margin-right: 28upx;
|
||||
.img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
border-radius: 20upx;
|
||||
}
|
||||
}
|
||||
.info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
.title {
|
||||
font-size: 32upx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.record {
|
||||
color: $uni-zj-color-primary;
|
||||
}
|
||||
.btm {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
.btn {
|
||||
padding: 4upx 12upx;
|
||||
color: #fff;
|
||||
background: $uni-zj-color-primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
6
uni.scss
6
uni.scss
@@ -13,6 +13,8 @@
|
||||
*/
|
||||
|
||||
/* 颜色变量 */
|
||||
$uni-zj-color-primary: #ff7581;
|
||||
$uni-zj-color-primary-active: #cb5d68;
|
||||
|
||||
/* 行为相关颜色 */
|
||||
$uni-color-primary: #007aff;
|
||||
@@ -68,10 +70,10 @@ $uni-spacing-col-lg: 12px;
|
||||
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
|
||||
|
||||
/* 文章场景相关 */
|
||||
$uni-color-title: #2C405A; // 文章标题颜色
|
||||
$uni-color-title: #2c405a; // 文章标题颜色
|
||||
$uni-font-size-title: 20px;
|
||||
$uni-color-subtitle: #555555; // 二级标题颜色
|
||||
$uni-font-size-subtitle: 26px;
|
||||
$uni-color-paragraph: #3F536E; // 文章段落颜色
|
||||
$uni-color-paragraph: #3f536e; // 文章段落颜色
|
||||
$uni-font-size-paragraph: 15px;
|
||||
@import 'uview-plus/theme.scss';
|
||||
@@ -1,64 +1,3 @@
|
||||
import { SM4 } from 'gm-crypto'
|
||||
import {encryptKey} from '@/commons/config.js'
|
||||
|
||||
let HEX_KEY = null
|
||||
|
||||
// 字符串转16进制
|
||||
function str2hex(str) {
|
||||
var val = ''
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
if (val == '')
|
||||
val = str.charCodeAt(i).toString(16)
|
||||
else
|
||||
val += str.charCodeAt(i).toString(16)
|
||||
}
|
||||
val += ''
|
||||
return val
|
||||
}
|
||||
|
||||
// 获取hex秘钥
|
||||
function getHexKey(){
|
||||
|
||||
if(!HEX_KEY){
|
||||
|
||||
HEX_KEY = str2hex(encryptKey)
|
||||
|
||||
}
|
||||
return HEX_KEY
|
||||
}
|
||||
|
||||
|
||||
// 解密 (http响应数据, 做通用处理)
|
||||
export function sm4DecryptByResData(data){
|
||||
|
||||
if(!data){
|
||||
return data
|
||||
}
|
||||
|
||||
let res = SM4.decrypt(data, getHexKey(), {
|
||||
inputEncoding: 'base64',
|
||||
outputEncoding: 'utf8'
|
||||
})
|
||||
|
||||
if(!res){
|
||||
return res
|
||||
}
|
||||
|
||||
return JSON.parse(res)['originData']
|
||||
}
|
||||
|
||||
// 加密 (http响应数据, 做通用处理)
|
||||
export function sm4EncryptByReqData(data){
|
||||
if(!data){
|
||||
return data
|
||||
}
|
||||
|
||||
// 加密处理
|
||||
let encryptData = SM4.encrypt(JSON.stringify(data), getHexKey(), {
|
||||
inputEncoding: 'utf8',
|
||||
outputEncoding: 'base64'
|
||||
})
|
||||
|
||||
return {encryptData : encryptData}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user