Commit fc76171047ba661b7699fe89c90158e5785d7771

Authored by 郭伟龙
1 parent 1558aa37
Exists in develop and in 1 other branch charge

feat:修改问题、增加登录验证码,记住密码功能

api/address.js
... ... @@ -1,15 +0,0 @@
1   -//请求工具参考https://ext.dcloud.net.cn/plugin?id=392
2   -const { http } = uni.$u
3   -
4   -//获得用户收件地址列表
5   -export const getAddressList = params => http.get('/member/address/list', params)
6   -//创建用户收件地址
7   -export const createAddress = data => http.post('/member/address/create', data)
8   -//通过ID获得用户收件地址
9   -export const getAddressById = params => http.get('/member/address/get', { params })
10   -//获得默认的用户收件地址
11   -export const getDefaultUserAddress = params => http.get('/member/address/get-default', { params })
12   -//更新用户收件地址
13   -export const updateAddress = params => http.put('/member/address/update', params)
14   -//删除用户收件地址
15   -export const deleteAddress = params => http.delete('/member/address/delete', {}, { params })
api/auth.js
1   -import code from "../uni_modules/uview-ui/libs/config/props/code"
2   -
  1 +import { encrypt } from "@/utils/encrypt.js";
  2 +import request from '@/utils/request'
3 3 //请求工具参考https://ext.dcloud.net.cn/plugin?id=392
4   -const { http } = uni.$u
  4 +const {
  5 + http
  6 +} = uni.$u
5 7  
6 8 //使用手机 + 密码登录
7   -export const passwordLogin = data => http.post('/auth/login', data)
  9 +export const passwordLogin = data => {
  10 + data.password = encrypt(data.password);
  11 + return http.post('/auth/login', data)
  12 +}
  13 +
  14 +// export function passwordLogin(username, password, code, uuid) {
  15 +// const data = {
  16 +// username,
  17 +// password: encrypt(password),
  18 +// code,
  19 +// uuid
  20 +// }
  21 +// return request({
  22 +// 'url': '/auth/login',
  23 +// headers: {
  24 +// isToken: false
  25 +// },
  26 +// 'method': 'post',
  27 +// 'data': data
  28 +// })
  29 +// }
  30 +
8 31 //钉钉登录
9   -export const dingLogin = code => http.post('/auth/dingding/login?code='+code)
  32 +export const dingLogin = code => http.post('/auth/dingding/login?code=' + code)
10 33 //发送手机验证码
11 34 export const sendSmsCode = data => http.post('/member/auth/send-sms-code', data)
12 35 //使用手机 + 验证码登录
13 36 export const smsLogin = data => http.post('/member/auth/sms-login', data)
14 37 //微信小程序的一键登录
15 38 export const weixinMiniAppLogin = data => http.post('/member/auth/weixin-mini-app-login', data)
  39 +// 获取验证码
  40 +export const getCodeImg = params => http.get('/captchaImage')
16 41 //刷新令牌
17   -export const refreshToken = data => http.post('/member/auth/refresh-token', {data})
  42 +export const refreshToken = data => http.post('/member/auth/refresh-token', {
  43 + data
  44 +})
18 45 //退出登录
19 46 export const logout = data => http.delete('/auth/logout', data)
... ...
api/cart.js
... ... @@ -1,5 +0,0 @@
1   -const { http } = uni.$u
2   -
3   -//获取购物车数据
4   -export const getCartProductDetail = () => http.get('/trade/cart/get-detail')
5   -
api/category.js
... ... @@ -1,5 +0,0 @@
1   -//请求工具参考https://ext.dcloud.net.cn/plugin?id=392
2   -const { http } = uni.$u
3   -
4   -// 查询分类列表
5   -export const categoryListData = params => http.get('product/category/list', { params })
api/order.js
... ... @@ -1,6 +0,0 @@
1   -const { http } = uni.$u
2   -
3   -// 获得订单交易分页
4   -export const getOrderPage = params => http.get('/trade/order/page', { params })
5   -// 获得交易订单详情
6   -export const getOrderDetail = params => http.get('/trade/order/get-detail', { params })
api/product.js
... ... @@ -1,8 +0,0 @@
1   -//请求工具参考https://ext.dcloud.net.cn/plugin?id=392
2   -const { http } = uni.$u
3   -
4   -// 查询商品spu列表
5   -export const productSpuPage = params => http.get('product/spu/page', { params })
6   -
7   -// 查询商品
8   -export const getSpuDetail = id => http.get('product/spu/get-detail?id=' + id, { })
api/total.js
... ... @@ -4,10 +4,10 @@ const { http } = uni.$u
4 4 export const getStatisticsReport = id => http.get('/insight/statistics/report/'+id)
5 5  
6 6 // 待开发用户池数据分析
7   -export const getStatisticsPool = params => http.get('/insight/statistics/pool',params)
  7 +export const getStatisticsPool = params => http.get('/insight/statistics/pool',{params})
8 8 // /statistics/pool
9 9  
10   -export const getStatisticsLogin = params => http.get('/insight/statistics/login',params)
  10 +export const getStatisticsLogin = params => http.get('/insight/statistics/login',{params})
11 11 // 访问量和浏览量
12 12 // /statistics/login
13 13  
... ...
common/config.js
1 1 module.exports = {
2 2 //后端接口地址
3 3 // baseUrl: 'http://10.11.38.240:9001', //内网开发环境
4   - // baseUrl: 'http://172.17.56.37:18082/api', //测试环境
  4 + baseUrl: 'http://172.17.56.37:18082/api', //测试环境
5 5 // baseUrl: 'http://172.17.56.16:18082/api', //ip正式环境
6   - baseUrl: 'https://scdcapp.chinagasholdings.com/api', //域名正式环境
  6 + // baseUrl: 'https://scdcapp.chinagasholdings.com/api', //域名正式环境
7 7 // 超时
8 8 timeout: 30000,
9 9 // 禁用 Cookie 等信息
... ...
package-lock.json
... ... @@ -10,6 +10,11 @@
10 10 "promise-polyfill": "^7.1.0"
11 11 }
12 12 },
  13 + "jsencrypt": {
  14 + "version": "3.3.2",
  15 + "resolved": "https://registry.npmmirror.com/jsencrypt/-/jsencrypt-3.3.2.tgz",
  16 + "integrity": "sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A=="
  17 + },
13 18 "promise-polyfill": {
14 19 "version": "7.1.2",
15 20 "resolved": "https://registry.npmmirror.com/promise-polyfill/-/promise-polyfill-7.1.2.tgz",
... ...
package.json
... ... @@ -6,6 +6,7 @@
6 6 ]
7 7 },
8 8 "dependencies": {
9   - "dingtalk-jsapi": "^3.0.29"
  9 + "dingtalk-jsapi": "^3.0.29",
  10 + "jsencrypt": "^3.3.2"
10 11 }
11 12 }
... ...
pages.json
... ... @@ -7,6 +7,7 @@
7 7 "path": "pages/market/index",
8 8 "style": {
9 9 "navigationBarTitleText": "市场资讯",
  10 + "navigationStyle": "custom",
10 11 "enablePullDownRefresh": true
11 12 }
12 13 }, {
... ... @@ -18,35 +19,41 @@
18 19 }, {
19 20 "path": "pages/market/total",
20 21 "style": {
21   - "navigationBarTitleText": "数据统计"
  22 + "navigationBarTitleText": "数据统计",
  23 + "navigationStyle": "custom"
22 24 }
23 25 }, {
24 26 "path": "pages/market/insight",
25 27 "style": {
26 28 "enablePullDownRefresh": true,
27   - "navigationBarTitleText": "市场洞察"
  29 + "navigationBarTitleText": "市场洞察",
  30 + "navigationStyle": "custom"
28 31 }
29 32 }, {
30 33 "path": "pages/market/researchReport",
31 34 "style": {
32   - "navigationBarTitleText": "研究报告"
  35 + "navigationBarTitleText": "研究报告",
  36 + "navigationStyle": "custom"
33 37 }
34 38 }, {
35 39 "path": "pages/market/knowledgeBase",
36 40 "style": {
37   - "navigationBarTitleText": "知识库"
  41 + "navigationBarTitleText": "知识库",
  42 + "navigationStyle": "custom"
38 43 }
39 44 },
40 45 {
41 46 "path": "pages/market/userDetails",
42 47 "style": {
43   - "navigationBarTitleText": "居民用户详情"
  48 + "navigationBarTitleText": "居民用户详情",
  49 + "navigationStyle": "custom"
44 50 }
45 51 },
46 52 {
47 53 "path": "pages/market/reportDetails",
48 54 "style": {
49   - "navigationBarTitleText": "报告详情"
  55 + "navigationBarTitleText": "报告详情",
  56 + "navigationStyle": "custom"
50 57 }
51 58 }
52 59 ],
... ...
pages/login/mobile.vue
... ... @@ -14,20 +14,15 @@
14 14 </view>
15 15  
16 16 <view class="auth-box">
17   - <!-- 登录方式选择 -->
18   -
19   -
20   - <!-- 登录表单 -->
21 17 <u--form labelPosition="left" :model="formData" :rules="rules" ref="form">
22 18 <u-form-item prop="username" ref="item-mobile">
23 19 <u-input type="text" maxlength="11" border="surround" shape="circle" v-model="formData.username" clearable
24 20 placeholder="请输入您的用户名" style="width: 610rpx;">
25 21 <u-icon slot="prefix" size="20" style="margin-right: 48rpx;" name="/static/images/icon/user.png"></u-icon>
26   - <!-- <u--text text="http://" slot="prefix" margin="0 3px 0 0" type="tips"></u--text> -->
27 22 </u-input>
28 23 </u-form-item>
29 24  
30   - <u-gap height="20"></u-gap>
  25 + <u-gap height="10"></u-gap>
31 26  
32 27 <u-form-item prop="password" ref="item-password">
33 28 <u-input :type="inputType" prefixIcon="lock" maxlength="16" border="surround" shape="circle"
... ... @@ -42,20 +37,34 @@
42 37 </u-input>
43 38 </u-form-item>
44 39  
  40 + <u-gap height="10"></u-gap>
  41 +
  42 + <u-form-item prop="code" ref="item-code">
  43 + <u--input v-model="formData.code" placeholder="请输入验证码" shape="circle" type="text" class="input">
  44 + <template slot="prefix">
  45 + <img class="prefix-icon" src='/static/images/login/code.png' />
  46 + </template>
  47 + </u--input>
  48 + <image :src="codeUrl" @click="getCode" class="login-code-img"></image>
  49 + </u-form-item>
  50 + <view class="remember-box" @click="rememberMe = !rememberMe">
  51 + <img class="suffix-icon"
  52 + :src="rememberMe ? '/static/images/login/remember.png' : '/static/images/login/not-remember.svg'" />
  53 + <view class="text" :class="rememberMe ? 'remember-text' : ''">记住密码</view>
  54 + </view>
45 55 <view class="btn-group">
46 56 <u-button class="auth-btn" customStyle="margin-top: 50px" @click="handleSubmit">登录</u-button>
47 57 </view>
48 58 </u--form>
49 59 </view>
50   - <u-loading-page v-if="isDing" :loading="isDing" iconSize="50" loadingMode="spinner" image="/static/images/empty/loding-logo.gif"
51   - loadingText="检测为钉钉环境\n自动登录中..." bg-color="#e8e8e8"></u-loading-page>
  60 + <u-loading-page v-if="isDing" :loading="isDing" iconSize="50" loadingMode="spinner"
  61 + image="/static/images/empty/loding-logo.gif" loadingText="检测为钉钉环境\n自动登录中..." bg-color="#e8e8e8"></u-loading-page>
52 62 </view>
53 63 </template>
54 64  
55 65 <script>
56   - import {
57   - passwordLogin
58   - } from '@/api/auth'
  66 + import {passwordLogin,getCodeImg,} from '@/api/auth'
  67 + import { encrypt, decrypt } from "@/utils/jsencrypt";
59 68 import * as dd from 'dingtalk-jsapi'
60 69 export default {
61 70 data() {
... ... @@ -65,9 +74,15 @@
65 74 codeDisabled: false,
66 75 codeTips: '',
67 76 formData: {
  77 + // username: 'xucfa',
  78 + // password: 'qkOzF!liEfd',
68 79 username: '',
69 80 password: '',
  81 + code: '',
  82 + uuid: ''
70 83 },
  84 + rememberMe: false,
  85 + codeUrl: "",
71 86 rules: {
72 87 username: {
73 88 type: 'string',
... ... @@ -81,13 +96,21 @@
81 96 message: '请填写登录密码',
82 97 trigger: ['blur', 'change']
83 98 },
  99 + code: {
  100 + type: 'string',
  101 + required: true,
  102 + message: '请填写验证码',
  103 + trigger: ['blur', 'change']
  104 + },
84 105 },
85 106 isDing: false
86 107 }
87 108 },
88 109 onLoad() {},
89 110 onShow() {
90   - this.detectionEnvironment()
  111 + this.getCode();
  112 + this.detectionEnvironment();
  113 + this.getLocalCache()
91 114 // console.log(this.$isDing);
92 115 // this.isDing = true;
93 116 },
... ... @@ -121,9 +144,9 @@
121 144 // alert(JSON.stringify(err))
122 145 console.log(err);
123 146 // uni.$u.toast('非钉钉内部账号');
124   - setTimeout(()=>{
  147 + setTimeout(() => {
125 148 that.isDing = false;
126   - },500)
  149 + }, 500)
127 150 })
128 151 },
129 152 onFail: (err) => {
... ... @@ -134,6 +157,31 @@
134 157 })
135 158 }
136 159 },
  160 + //记住账号密码
  161 + getLocalCache() {
  162 + // uni.setStorageSync('roleId', roleIdString)
  163 + const rememberMe = uni.getStorageSync('rememberMe');
  164 + console.log("是否记住密码", Boolean(rememberMe));
  165 + if (!rememberMe) return;
  166 + const username = uni.getStorageSync('username')
  167 + const password = uni.getStorageSync('password')
  168 + console.log("密码缓存",password);
  169 + this.formData = {
  170 + username: username === undefined ? this.formData.username : username,
  171 + password: password === undefined ? this.formData.password : decrypt(password),
  172 + };
  173 + console.log(this.formData);
  174 + this.rememberMe = rememberMe === undefined ? false : true;
  175 + },
  176 + getCode() {
  177 + getCodeImg().then(res => {
  178 + this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
  179 + if (this.captchaEnabled) {
  180 + this.codeUrl = 'data:image/gif;base64,' + res.img
  181 + this.formData.uuid = res.uuid
  182 + }
  183 + })
  184 + },
137 185  
138 186 handleSubmit() {
139 187 this.$refs.form.validate().then(res => {
... ... @@ -155,7 +203,20 @@
155 203 // })
156 204 })
157 205 },
  206 + rememberPassword() {
  207 + if (this.rememberMe) {
  208 + uni.setStorageSync('username', this.formData.username);
  209 + uni.setStorageSync('password', encrypt(this.formData.password));
  210 + uni.setStorageSync('rememberMe', this.rememberMe);
  211 + } else {
  212 + uni.removeStorageSync('username');
  213 + uni.removeStorageSync('password');
  214 + uni.removeStorageSync('rememberMe');
  215 + }
  216 + },
158 217 mobileLogin(data) {
  218 + // return
  219 + this.rememberPassword()
159 220 this.$store.dispatch('Login', {
160 221 type: 0,
161 222 data: data
... ... @@ -247,6 +308,38 @@
247 308 }
248 309 }
249 310  
  311 + .remember-box {
  312 + height: 37rpx;
  313 + margin: 33rpx 0 42rpx 0;
  314 + display: flex;
  315 + align-items: center;
  316 +
  317 + img {
  318 + width: 30rpx;
  319 + height: 30rpx;
  320 + margin-right: 12rpx;
  321 + }
  322 +
  323 + .text {
  324 + font-size: 26rpx;
  325 + font-family: '苹方 中等', '苹方', sans-serif;
  326 + color: #666666;
  327 + text-align: left;
  328 + line-height: normal;
  329 + }
  330 +
  331 + .remember-text {
  332 + color: #333;
  333 + }
  334 + }
  335 +
  336 + .login-code-img {
  337 + width: 33%;
  338 + height: 98rpx;
  339 + cursor: pointer;
  340 + vertical-align: middle;
  341 + }
  342 +
250 343 .u-input {
251 344 height: 60rpx;
252 345 background: #f5f7f7;
... ...
pages/market/components/reportModule1.vue
... ... @@ -49,11 +49,11 @@
49 49 <!-- </u-collapse> -->
50 50 </view>
51 51  
52   - <view class="cardCss" v-if="isShowUrl">
  52 + <view class="cardCss">
53 53 <!-- <u-collapse :border="false" :value="['3']"> -->
54 54 <!-- <u-collapse-item name="3"> -->
55 55 <text class="slot-title">预算主体附件</text>
56   - <view class="attachmentCss">
  56 + <view class="attachmentCss" v-if="this.isShowUrl">
57 57 <view class="flexCss" v-for="(item,index) in reportData.attachmentsUrl" :key="index">
58 58 <view class="leftCss overflow-one-lines">
59 59 <u-icon size="18" :name="calcIcon(item.extension)"></u-icon>
... ... @@ -106,7 +106,7 @@
106 106 this.isShowUrl = true
107 107 }else{
108 108 this.reportData.attachmentsUrl = JSON.parse(this.reportData.attachmentsUrl);
109   - if(this.reportData.attachmentsUrl.length){
  109 + if(this.reportData.attachmentsUrl.length && this.reportData.attachmentsUrl != '[]'){
110 110 this.isShowUrl = true
111 111 }else{
112 112 this.isShowUrl = false
... ...
pages/market/total.vue
1 1 <template>
2 2 <view class="ComCss">
3   - <u-navbar v-if="!$isDing" class="navBarCss" title="数据统计" leftIconSize="0"
4   - :titleStyle="{'fontSize':'36rpx','color':'#333333','fontWeight':'700'}" safeAreaInsetTop placeholder />
  3 + <!-- <u-navbar v-if="!$isDing" class="navBarCss" title="数据统计" leftIconSize="0"
  4 + :titleStyle="{'fontSize':'36rpx','color':'#333333','fontWeight':'700'}" safeAreaInsetTop placeholder /> -->
5 5 <view class="bigCardCss">
6 6 <view class="titleCss">
7 7 本财年报告已上报数
... ... @@ -134,7 +134,11 @@
134 134 console.log("报告", this.data1);
135 135 }
136 136 })
137   - await getStatisticsPool().then(res => {
  137 + let query = {
  138 + roleIds: uni.getStorageSync('roleId') || null,
  139 + entity: uni.getStorageSync("entity") || null,
  140 + }
  141 + await getStatisticsPool(query).then(res => {
138 142 if (res.code === 200) {
139 143 let data = res.data;
140 144 this.statistics.resident = data.resident;
... ... @@ -227,7 +231,7 @@
227 231 align: 'left',
228 232 data: this.data2.map(item => item.name)
229 233 },
230   - color: ['#15C2C3', '#5875EB', '#E74C3C' ],
  234 + color: ['#15C2C3', '#5875EB', '#E74C3C'],
231 235 series: [{
232 236 name: '待开发用户池数据分析',
233 237 type: 'pie',
... ...
static/font/iconfont.css 0 → 100644
... ... @@ -0,0 +1,90 @@
  1 +@font-face {
  2 + font-family: "iconfont";
  3 + src: url('@/static/font/iconfont.ttf') format('truetype');
  4 +}
  5 +
  6 +.iconfont {
  7 + font-family: "iconfont" !important;
  8 + font-size: 16px;
  9 + display: inline-block;
  10 + font-style: normal;
  11 + -webkit-font-smoothing: antialiased;
  12 + -moz-osx-font-smoothing: grayscale;
  13 +}
  14 +
  15 +.icon-user:before {
  16 + content: "\e7ae";
  17 +}
  18 +
  19 +.icon-password:before {
  20 + content: "\e8b2";
  21 +}
  22 +
  23 +.icon-code:before {
  24 + content: "\e699";
  25 +}
  26 +
  27 +.icon-setting:before {
  28 + content: "\e6cc";
  29 +}
  30 +
  31 +.icon-share:before {
  32 + content: "\e739";
  33 +}
  34 +
  35 +.icon-edit:before {
  36 + content: "\e60c";
  37 +}
  38 +
  39 +.icon-version:before {
  40 + content: "\e63f";
  41 +}
  42 +
  43 +.icon-service:before {
  44 + content: "\e6ff";
  45 +}
  46 +
  47 +.icon-friendfill:before {
  48 + content: "\e726";
  49 +}
  50 +
  51 +.icon-community:before {
  52 + content: "\e741";
  53 +}
  54 +
  55 +.icon-people:before {
  56 + content: "\e736";
  57 +}
  58 +
  59 +.icon-dianzan:before {
  60 + content: "\ec7f";
  61 +}
  62 +
  63 +.icon-right:before {
  64 + content: "\e7eb";
  65 +}
  66 +
  67 +.icon-logout:before {
  68 + content: "\e61d";
  69 +}
  70 +
  71 +.icon-help:before {
  72 + content: "\e616";
  73 +}
  74 +
  75 +.icon-github:before {
  76 + content: "\e628";
  77 +}
  78 +
  79 +.icon-aixin:before {
  80 + content: "\e601";
  81 +}
  82 +
  83 +.icon-clean:before {
  84 + content: "\e607";
  85 +}
  86 +
  87 +.icon-refresh:before {
  88 + content: "\e604";
  89 +}
  90 +
... ...
static/font/iconfont.ttf 0 → 100644
No preview for this file type
static/images/login/account.png 0 → 100644

1.42 KB

static/images/login/close-eye.png 0 → 100644

1.44 KB

static/images/login/code.png 0 → 100644

1.25 KB

static/images/login/not-remember.svg 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<svg version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="30px" height="30px" xmlns="http://www.w3.org/2000/svg">
  3 + <g transform="matrix(1 0 0 1 0 -4 )">
  4 + <path d="M 15 4 C 23.400000000000002 4 30 10.6 30 19 C 30 27.400000000000002 23.400000000000002 34 15 34 C 6.6 34 0 27.400000000000002 0 19 C 0 10.6 6.6 4 15 4 Z " fill-rule="nonzero" fill="#ffffff" stroke="none" />
  5 + <path d="M 15 4.5 C 23.12 4.5 29.5 10.879999999999999 29.5 19 C 29.5 27.12 23.12 33.5 15 33.5 C 6.879999999999999 33.5 0.5 27.12 0.5 19 C 0.5 10.879999999999999 6.879999999999999 4.5 15 4.5 Z " stroke-width="1" stroke="#c8c8c8" fill="none" />
  6 + </g>
  7 +</svg>
0 8 \ No newline at end of file
... ...
static/images/login/open-eye.png 0 → 100644

907 Bytes

static/images/login/password.png 0 → 100644

1.05 KB

static/images/login/remember.png 0 → 100644

2 KB

store/index.js
... ... @@ -2,7 +2,6 @@ import Vue from &#39;vue&#39;
2 2 import Vuex from 'vuex'
3 3 import user from './mudules/user'
4 4 import dict from './mudules/dict'
5   -import cart from './mudules/cart'
6 5 import getters from './getters'
7 6  
8 7 Vue.use(Vuex) // vue的插件机制
... ... @@ -11,7 +10,6 @@ Vue.use(Vuex) // vue的插件机制
11 10 const store = new Vuex.Store({
12 11 modules: {
13 12 user,
14   - cart,
15 13 dict
16 14 },
17 15 getters
... ...
store/mudules/user.js
... ... @@ -151,4 +151,4 @@ const user = {
151 151 }
152 152 }
153 153 }
154 154 -export default user
  155 +export default user
155 156 \ No newline at end of file
... ...
utils/encrypt.js 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +import { JSEncrypt } from 'jsencrypt'
  2 +
  3 +// 密钥对生成 http://web.chacuo.net/netrsakeypair
  4 +
  5 +const publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2ctpEL5c4wlQskegcl2M\n" +
  6 + "OJzPbdt+CZ+Enn/8IpH1Kz1H4nFbaqwyLQl1pjyfbqJqjxyUwVzuC2EfgPLkdDl1\n" +
  7 + "PDiidaVmKoZgKhuilWSOr6loXrwOLHGFTRH9Pbw/CZE8oS1kOz2eR5qz8fjcA4VN\n" +
  8 + "+2z61hPkkSnLalUfWca+UqkDJJhEn8de9iZC4+c7RO5uwNlWqb3ZVBU9zyh+IXny\n" +
  9 + "J3asSUYpqs4WdNROUiliWOw18SdbksPlcDbMVjMXaFLS6U2JxbVVkXo1ojPVRpnK\n" +
  10 + "P4GKT63NiLltid8meimtJ7wxfdf5T+v29gufTrMHgJE9WzZr0ASwonWaGtxDM+oh\n" +
  11 + "SQIDAQAB";
  12 +
  13 +// 加密
  14 +export function encrypt(txt) {
  15 + const encryptor = new JSEncrypt()
  16 + encryptor.setPublicKey(publicKey) // 设置公钥
  17 + return encryptor.encrypt(txt) // 对数据进行加密
  18 +}
  19 +
  20 +
  21 +
  22 +
... ...
utils/jsencrypt.js 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
  2 +
  3 +
  4 +const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
  5 + 'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
  6 +
  7 +const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
  8 + '7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
  9 + 'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
  10 + 'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
  11 + 'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
  12 + 'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
  13 + 'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
  14 + 'UP8iWi1Qw0Y='
  15 +
  16 +// 加密
  17 +export function encrypt(txt) {
  18 + const encryptor = new JSEncrypt()
  19 + encryptor.setPublicKey(publicKey) // 设置公钥
  20 + return encryptor.encrypt(txt) // 对数据进行加密
  21 +}
  22 +
  23 +// 解密
  24 +export function decrypt(txt) {
  25 + const encryptor = new JSEncrypt()
  26 + encryptor.setPrivateKey(privateKey) // 设置私钥
  27 + return encryptor.decrypt(txt) // 对数据进行解密
  28 +}
  29 +
... ...