瀏覽代碼

接口返回数据加密,添加解密流程

xiaoxin 2 年之前
父節點
當前提交
a13923e01f

+ 4 - 4
App.vue

@@ -1,14 +1,14 @@
 <script>
 export default {
 	onLaunch: function () {
-		console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
-		console.log('App Launch')
+		// console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
+		// console.log('App Launch')
 	},
 	onShow: function () {
-		console.log('App Show')
+		// console.log('App Show')
 	},
 	onHide: function () {
-		console.log('App Hide')
+		// console.log('App Hide')
 	}
 }
 </script>

+ 9 - 7
main.js

@@ -1,4 +1,3 @@
-
 // #ifndef VUE3
 import Vue from 'vue'
 import App from './App'
@@ -8,18 +7,21 @@ Vue.config.productionTip = false
 App.mpType = 'app'
 
 const app = new Vue({
-    ...App
+	...App
 })
 app.$mount()
 // #endif
 
 // #ifdef VUE3
-import { createSSRApp } from 'vue'
+import {
+	createSSRApp
+} from 'vue'
 import App from './App.vue'
+
 export function createApp() {
-  const app = createSSRApp(App)
-  return {
-    app
-  }
+	const app = createSSRApp(App)
+	return {
+		app
+	}
 }
 // #endif

+ 9 - 3
node_modules/.package-lock.json

@@ -1,6 +1,12 @@
 {
-  "name": "smartCampus-wanzai",
-  "lockfileVersion": 2,
+  "name": "WanZai_School_app",
+  "lockfileVersion": 3,
   "requires": true,
-  "packages": {}
+  "packages": {
+    "node_modules/crypto-js": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
+      "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+    }
+  }
 }

+ 20 - 2
package-lock.json

@@ -1,6 +1,24 @@
 {
-  "name": "smartCampus-wanzai",
+  "name": "WanZai_School_app",
   "lockfileVersion": 2,
   "requires": true,
-  "packages": {}
+  "packages": {
+    "": {
+      "dependencies": {
+        "crypto-js": "^4.2.0"
+      }
+    },
+    "node_modules/crypto-js": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
+      "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+    }
+  },
+  "dependencies": {
+    "crypto-js": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
+      "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+    }
+  }
 }

+ 5 - 1
package.json

@@ -1 +1,5 @@
-{}
+{
+  "dependencies": {
+    "crypto-js": "^4.2.0"
+  }
+}

+ 4 - 3
pages/grade/grade.vue

@@ -18,6 +18,7 @@ import { onLoad } from '@dcloudio/uni-app'
 import headerInput from '@/components/headerInput.vue'
 import listView from '@/components/listView.vue'
 import { myRequest } from '@/utils/api.js'
+import { decryptDes } from '@/utils/des.js'
 
 // 学生列表数组
 const list = ref([])
@@ -55,9 +56,9 @@ const getData = async () => {
 			id: uni.getStorageSync('userInfo').id
 		}
 	})
-	// console.log(res.data)
-
-	res.data.forEach((ele) => {
+	// console.log(res)
+	const result = JSON.parse(decryptDes(res.data))
+	result.forEach((ele) => {
 		let temlist
 		ele.classBookList.forEach((item, index, arr) => {
 			if (item.bookUserList.length) {

+ 34 - 3
pages/home/home.vue

@@ -44,6 +44,8 @@
 					切换 >
 				</view>
 
+				<view v-if="!childMsgList.length" class="info_no">暂无孩子绑定</view>
+
 				<!-- 关联区域 -->
 				<view class="info_bind">
 					<img @click="goPage('/pages/bind/bind')" class="bind_img" src="../../static/images/bind.png" />
@@ -72,6 +74,7 @@ import { ref } from 'vue'
 import { onLoad, onPageScroll, onPullDownRefresh, onShow } from '@dcloudio/uni-app'
 import { myRequest } from '@/utils/api.js'
 import NoData from '@/components/noData.vue'
+import { decryptDes } from '@/utils/des.js'
 
 onLoad(() => {
 	// 获取系统信息
@@ -195,7 +198,8 @@ const getQrcode = async () => {
 		}
 	})
 	// console.log(res)
-	QRCodeUrl.value = res.data.qrcode
+	const result = JSON.parse(decryptDes(res.data))
+	QRCodeUrl.value = result.qrcode
 }
 
 // 获取绑定小孩的信息
@@ -207,7 +211,8 @@ const getChildMsg = async () => {
 		}
 	})
 	// console.log(res)
-	childMsgList.value = res.data
+	const result = JSON.parse(decryptDes(res.data))
+	childMsgList.value = result
 
 	if (childMsgList.value.length) {
 		currentChild.value = childMsgList.value[0]
@@ -223,7 +228,8 @@ const getUseAppList = async () => {
 		}
 	})
 	// console.log(res)
-	useAppList.value = res.data
+	const result = JSON.parse(decryptDes(res.data))
+	useAppList.value = result
 }
 
 // 跳转页面函数
@@ -243,6 +249,14 @@ const goPage = (url, item) => {
 	}
 	if (url === '/pages/track/track') {
 		if (userInfo.value.identityId == 1) {
+			if (!currentChild.value.id) {
+				uni.showToast({
+					title: '请关联孩子后再查看轨迹',
+					icon: 'none',
+					mask: true
+				})
+				return
+			}
 			uni.navigateTo({
 				url: `/pages/track/track?id=${currentChild.value.id}`
 			})
@@ -255,6 +269,14 @@ const goPage = (url, item) => {
 		}
 	}
 	if (url === '/pagesReservation/reservation/reservation') {
+		if (userInfo.value.identityId == 1 && !currentChild.value.id) {
+			uni.showToast({
+				title: '请关联孩子后再开始预约',
+				icon: 'none',
+				mask: true
+			})
+			return
+		}
 		uni.setStorageSync('Tab-activeIndex', 0)
 	}
 	uni.navigateTo({
@@ -428,6 +450,15 @@ const updateObj = (data) => {
 				color: #a6a6a6;
 			}
 
+			.info_no {
+				position: absolute;
+				top: 38rpx;
+				left: 163rpx;
+				z-index: 1;
+				font-size: 30rpx;
+				color: #a6a6a6;
+			}
+
 			.info_bind {
 				position: absolute;
 				top: 20rpx;

+ 5 - 2
pages/msgWarn/msgWarn.vue

@@ -36,6 +36,7 @@ import { onLoad, onReachBottom } from '@dcloudio/uni-app'
 import NoData from '@/components/noData.vue'
 import { myRequest } from '@/utils/api.js'
 import { previewImage } from '@/utils/previewImage.js'
+import { decryptDes } from '@/utils/des.js'
 
 onLoad(() => {
 	let token = uni.getStorageSync('token')
@@ -90,9 +91,11 @@ const getData = async () => {
 		}
 	})
 	// console.log(res)
+
 	if (res.code == 200) {
-		list.value = [...list.value, ...res.data.list]
-		total.value = res.data.totalCount
+		const result = JSON.parse(decryptDes(res.data))
+		list.value = [...list.value, ...result.list]
+		total.value = result.totalCount
 	}
 }
 

+ 3 - 1
pages/track/track.vue

@@ -47,6 +47,7 @@ import MapContainer from '@/components/MapContainer.vue'
 import NoData from '@/components/noData.vue'
 import { myRequest } from '@/utils/api.js'
 import { previewImage } from '@/utils/previewImage.js'
+import { decryptDes } from '@/utils/des.js'
 
 onLoad((options) => {
 	currentId.value = options.id
@@ -92,7 +93,8 @@ const getData = async () => {
 	})
 	// console.log(res)
 	if (res.code == 200) {
-		list.value = res.data
+		const result = JSON.parse(decryptDes(res.data))
+		list.value = result
 	}
 }
 

+ 4 - 2
pagesReservation/backlog/backlog.vue

@@ -125,6 +125,7 @@ import { onLoad, onReachBottom } from '@dcloudio/uni-app'
 import Tabber from '@/components/tabber.vue'
 import NoData from '@/components/noData.vue'
 import { myRequest } from '@/utils/api.js'
+import { decryptDes } from '@/utils/des.js'
 
 // 分段器当前索引
 const activeCurrent = ref(0)
@@ -176,8 +177,9 @@ const getData = async () => {
 		}
 	})
 	// console.log(res)
-	total.value = res.data.totalCount
-	list.value = [...list.value, ...res.data.list]
+	const result = JSON.parse(decryptDes(res.data))
+	total.value = result.totalCount
+	list.value = [...list.value, ...result.list]
 }
 
 // 切换分段器时的回调

+ 4 - 2
pagesReservation/record/record.vue

@@ -104,6 +104,7 @@ import { onLoad, onReachBottom } from '@dcloudio/uni-app'
 import Tabber from '@/components/tabber.vue'
 import NoData from '@/components/noData.vue'
 import { myRequest } from '@/utils/api.js'
+import { decryptDes } from '@/utils/des.js'
 
 // 分段器当前索引
 const activeCurrent = ref(0)
@@ -154,8 +155,9 @@ const getData = async () => {
 		}
 	})
 	// console.log(res)
-	total.value = res.data.totalCount
-	list.value = [...list.value, ...res.data.list]
+	const result = JSON.parse(decryptDes(res.data))
+	total.value = result.totalCount
+	list.value = [...list.value, ...result.list]
 }
 
 // 点击每一条预约记录时的回调

+ 3 - 1
pagesReservation/register/register.vue

@@ -144,6 +144,7 @@ import { onLoad } from '@dcloudio/uni-app'
 import { myRequest } from '@/utils/api.js'
 import { time_format } from '@/utils/formatTime.js'
 import { isVehicleNumber } from '@/utils/plate.js'
+import { decryptDes } from '@/utils/des.js'
 
 // 判断是哪种身份 1为学生家长 2为其他访客
 const type = ref('')
@@ -226,7 +227,8 @@ const getList = async () => {
 		}
 	})
 	// console.log(res)
-	list.value = res.data
+	const result = JSON.parse(decryptDes(res.data))
+	list.value = result
 }
 
 // 访客预约按钮回调

+ 6 - 3
pagesWarning/home/home.vue

@@ -69,6 +69,7 @@ import { time_format, getNowDate } from '@/utils/formatTime.js'
 import { myRequest } from '@/utils/api.js'
 import NoData from '@/components/noData.vue'
 import { previewImage } from '@/utils/previewImage.js'
+import { decryptDes } from '@/utils/des.js'
 
 // 状态筛选框数组当前索引
 const typeIndex = ref(0)
@@ -128,7 +129,8 @@ const getTypeList = async () => {
 		url: '/wanzai/api/smartWarning/warningType'
 	})
 	// console.log(res)
-	typeList.value = res.data.reverse()
+	const result = JSON.parse(decryptDes(res.data))
+	typeList.value = result.reverse()
 }
 
 // 获取预警列表数据
@@ -144,8 +146,9 @@ const getData = async () => {
 	})
 	// console.log(res)
 	if (res.code == 200) {
-		listData.value = [...listData.value, ...res.data.list]
-		total.value = res.data.totalCount
+		const result = JSON.parse(decryptDes(res.data))
+		listData.value = [...listData.value, ...result.list]
+		total.value = result.totalCount
 	}
 }
 

+ 0 - 4
unpackage/dist/dev/mp-weixin/app.js

@@ -25,14 +25,10 @@ if (!Math) {
 }
 const _sfc_main = {
   onLaunch: function() {
-    console.warn("当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!");
-    console.log("App Launch");
   },
   onShow: function() {
-    console.log("App Show");
   },
   onHide: function() {
-    console.log("App Hide");
   }
 };
 const App = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "E:/workSpace/WanZai_School_app/App.vue"]]);

File diff suppressed because it is too large
+ 6900 - 8
unpackage/dist/dev/mp-weixin/common/vendor.js


+ 3 - 1
unpackage/dist/dev/mp-weixin/pages/grade/grade.js

@@ -1,6 +1,7 @@
 "use strict";
 const common_vendor = require("../../common/vendor.js");
 const utils_api = require("../../utils/api.js");
+const utils_des = require("../../utils/des.js");
 if (!Math) {
   (headerInput + listView)();
 }
@@ -37,7 +38,8 @@ const _sfc_main = {
           id: common_vendor.index.getStorageSync("userInfo").id
         }
       });
-      res.data.forEach((ele) => {
+      const result = JSON.parse(utils_des.decryptDes(res.data));
+      result.forEach((ele) => {
         let temlist;
         ele.classBookList.forEach((item, index, arr) => {
           if (item.bookUserList.length) {

+ 31 - 9
unpackage/dist/dev/mp-weixin/pages/home/home.js

@@ -1,6 +1,7 @@
 "use strict";
 const common_vendor = require("../../common/vendor.js");
 const utils_api = require("../../utils/api.js");
+const utils_des = require("../../utils/des.js");
 if (!Array) {
   const _easycom_uv_qrcode2 = common_vendor.resolveComponent("uv-qrcode");
   _easycom_uv_qrcode2();
@@ -100,7 +101,8 @@ const _sfc_main = {
           userId: common_vendor.index.getStorageSync("userInfo").id
         }
       });
-      QRCodeUrl.value = res.data.qrcode;
+      const result = JSON.parse(utils_des.decryptDes(res.data));
+      QRCodeUrl.value = result.qrcode;
     };
     const getChildMsg = async () => {
       const res = await utils_api.myRequest({
@@ -109,7 +111,8 @@ const _sfc_main = {
           id: common_vendor.index.getStorageSync("userInfo").id
         }
       });
-      childMsgList.value = res.data;
+      const result = JSON.parse(utils_des.decryptDes(res.data));
+      childMsgList.value = result;
       if (childMsgList.value.length) {
         currentChild.value = childMsgList.value[0];
       }
@@ -121,7 +124,8 @@ const _sfc_main = {
           id: common_vendor.index.getStorageSync("userInfo").identityId
         }
       });
-      useAppList.value = res.data;
+      const result = JSON.parse(utils_des.decryptDes(res.data));
+      useAppList.value = result;
     };
     const goPage = (url, item) => {
       if (item && item.category == "其他小程序") {
@@ -139,6 +143,14 @@ const _sfc_main = {
       }
       if (url === "/pages/track/track") {
         if (userInfo.value.identityId == 1) {
+          if (!currentChild.value.id) {
+            common_vendor.index.showToast({
+              title: "请关联孩子后再查看轨迹",
+              icon: "none",
+              mask: true
+            });
+            return;
+          }
           common_vendor.index.navigateTo({
             url: `/pages/track/track?id=${currentChild.value.id}`
           });
@@ -151,6 +163,14 @@ const _sfc_main = {
         }
       }
       if (url === "/pagesReservation/reservation/reservation") {
+        if (userInfo.value.identityId == 1 && !currentChild.value.id) {
+          common_vendor.index.showToast({
+            title: "请关联孩子后再开始预约",
+            icon: "none",
+            mask: true
+          });
+          return;
+        }
         common_vendor.index.setStorageSync("Tab-activeIndex", 0);
       }
       common_vendor.index.navigateTo({
@@ -208,12 +228,14 @@ const _sfc_main = {
       }, childMsgList.value.length > 1 ? {
         x: common_vendor.o(($event) => goPage(`/pages/change/change?list=${JSON.stringify(childMsgList.value)}&id=${currentChild.value.id}`))
       } : {}, {
-        y: common_vendor.o(($event) => goPage("/pages/bind/bind")),
-        z: common_vendor.o(($event) => goPage("/pages/bind/bind"))
+        y: !childMsgList.value.length
+      }, !childMsgList.value.length ? {} : {}, {
+        z: common_vendor.o(($event) => goPage("/pages/bind/bind")),
+        A: common_vendor.o(($event) => goPage("/pages/bind/bind"))
       }) : {}, {
-        A: useAppList.value.length
+        B: useAppList.value.length
       }, useAppList.value.length ? {
-        B: common_vendor.f(useAppList.value, (item, k0, i0) => {
+        C: common_vendor.f(useAppList.value, (item, k0, i0) => {
           return {
             a: item.url,
             b: common_vendor.t(item.title),
@@ -222,9 +244,9 @@ const _sfc_main = {
           };
         })
       } : {}, {
-        C: !useAppList.value.length
+        D: !useAppList.value.length
       }, !useAppList.value.length ? {} : {}, {
-        D: common_vendor.s(_ctx.__cssVars())
+        E: common_vendor.s(_ctx.__cssVars())
       });
     };
   }

File diff suppressed because it is too large
+ 1 - 1
unpackage/dist/dev/mp-weixin/pages/home/home.wxml


+ 8 - 0
unpackage/dist/dev/mp-weixin/pages/home/home.wxss

@@ -135,6 +135,14 @@
   font-size: 24rpx;
   color: #a6a6a6;
 }
+.container .body .body_header .info_no.data-v-07e72d3c {
+  position: absolute;
+  top: 38rpx;
+  left: 163rpx;
+  z-index: 1;
+  font-size: 30rpx;
+  color: #a6a6a6;
+}
 .container .body .body_header .info_bind.data-v-07e72d3c {
   position: absolute;
   top: 20rpx;

+ 4 - 2
unpackage/dist/dev/mp-weixin/pages/msgWarn/msgWarn.js

@@ -2,6 +2,7 @@
 const common_vendor = require("../../common/vendor.js");
 const utils_api = require("../../utils/api.js");
 const utils_previewImage = require("../../utils/previewImage.js");
+const utils_des = require("../../utils/des.js");
 if (!Math) {
   NoData();
 }
@@ -47,8 +48,9 @@ const _sfc_main = {
         }
       });
       if (res.code == 200) {
-        list.value = [...list.value, ...res.data.list];
-        total.value = res.data.totalCount;
+        const result = JSON.parse(utils_des.decryptDes(res.data));
+        list.value = [...list.value, ...result.list];
+        total.value = result.totalCount;
       }
     };
     const bindPickerChange = (e) => {

+ 3 - 1
unpackage/dist/dev/mp-weixin/pages/track/track.js

@@ -2,6 +2,7 @@
 const common_vendor = require("../../common/vendor.js");
 const utils_api = require("../../utils/api.js");
 const utils_previewImage = require("../../utils/previewImage.js");
+const utils_des = require("../../utils/des.js");
 if (!Array) {
   const _easycom_uv_steps_item2 = common_vendor.resolveComponent("uv-steps-item");
   const _easycom_uv_steps2 = common_vendor.resolveComponent("uv-steps");
@@ -50,7 +51,8 @@ const _sfc_main = {
         }
       });
       if (res.code == 200) {
-        list.value = res.data;
+        const result = JSON.parse(utils_des.decryptDes(res.data));
+        list.value = result;
       }
     };
     const changeIndex = (v) => {

+ 4 - 2
unpackage/dist/dev/mp-weixin/pagesReservation/backlog/backlog.js

@@ -1,6 +1,7 @@
 "use strict";
 const common_vendor = require("../../common/vendor.js");
 const utils_api = require("../../utils/api.js");
+const utils_des = require("../../utils/des.js");
 if (!Array) {
   const _easycom_uni_segmented_control2 = common_vendor.resolveComponent("uni-segmented-control");
   const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
@@ -47,8 +48,9 @@ const _sfc_main = {
           type: activeCurrent.value - 0 + 1
         }
       });
-      total.value = res.data.totalCount;
-      list.value = [...list.value, ...res.data.list];
+      const result = JSON.parse(utils_des.decryptDes(res.data));
+      total.value = result.totalCount;
+      list.value = [...list.value, ...result.list];
     };
     const onClickItem = (e) => {
       if (activeCurrent.value != e.currentIndex) {

+ 4 - 2
unpackage/dist/dev/mp-weixin/pagesReservation/record/record.js

@@ -1,6 +1,7 @@
 "use strict";
 const common_vendor = require("../../common/vendor.js");
 const utils_api = require("../../utils/api.js");
+const utils_des = require("../../utils/des.js");
 if (!Array) {
   const _easycom_uni_segmented_control2 = common_vendor.resolveComponent("uni-segmented-control");
   const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
@@ -47,8 +48,9 @@ const _sfc_main = {
           type: activeCurrent.value
         }
       });
-      total.value = res.data.totalCount;
-      list.value = [...list.value, ...res.data.list];
+      const result = JSON.parse(utils_des.decryptDes(res.data));
+      total.value = result.totalCount;
+      list.value = [...list.value, ...result.list];
     };
     const handleClick = (item) => {
       popObj.value = item;

+ 3 - 1
unpackage/dist/dev/mp-weixin/pagesReservation/register/register.js

@@ -3,6 +3,7 @@ const common_vendor = require("../../common/vendor.js");
 const utils_api = require("../../utils/api.js");
 const utils_formatTime = require("../../utils/formatTime.js");
 const utils_plate = require("../../utils/plate.js");
+const utils_des = require("../../utils/des.js");
 if (!Array) {
   const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
   _easycom_uni_datetime_picker2();
@@ -56,7 +57,8 @@ const _sfc_main = {
           id: common_vendor.index.getStorageSync("userInfo").id
         }
       });
-      list.value = res.data;
+      const result = JSON.parse(utils_des.decryptDes(res.data));
+      list.value = result;
     };
     const handleSubmit = () => {
       const flag = verifyValue();

+ 15 - 0
utils/des.js

@@ -0,0 +1,15 @@
+import cryptoJs from 'crypto-js'
+
+// des解密 message为需要解密的信息  key为密钥
+export const decryptDes = (message, key = 'com.template.common.utils') => {
+	let keyHex = cryptoJs.enc.Utf8.parse(key)
+	let decrypted = cryptoJs.DES.decrypt({
+			ciphertext: cryptoJs.enc.Base64.parse(message)
+		},
+		keyHex, {
+			mode: cryptoJs.mode.ECB,
+			padding: cryptoJs.pad.Pkcs7
+		}
+	)
+	return decrypted.toString(cryptoJs.enc.Utf8)
+}