lhl 4 年之前
父节点
当前提交
b1e54be2e5
共有 2 个文件被更改,包括 12 次插入11 次删除
  1. 2 10
      pages/applic/contribution.vue
  2. 10 1
      utils/newRequest.js

+ 2 - 10
pages/applic/contribution.vue

@@ -258,16 +258,8 @@
 			// console.log(333,options)
 		},
 		onShow() {
-			// saveUrl()
-			// let token = uni.getStorageSync('token');
-			console.log(1, this);
-			// uni.showModal({
-			// 	title: '判断hasLogin',
-			// 	content: JSON.stringify(this.hasLogin),
-			// })
 			if (!this.hasLogin) {
 				// 登录拦截
-				// interceptor();
 				uni.showModal({
 					title: '登录',
 					content: '您未登录,是否马上登陆?',
@@ -280,7 +272,7 @@
 					fail: e => {
 						console.log(e);
 						uni.showModal({
-							title: 'cuowu',
+							title: '错误',
 							content: JSON.stringify(e),
 						})
 					}
@@ -445,7 +437,7 @@
 							let date = new Date()
 							let year = date.getFullYear()
 							let month = date.getMonth() >= 9 ? date.getMonth() + 1 : '0'+(date.getMonth() +1 )
-							let day = date.getDay() >= 10 ? date.getDay() : '0' + date.getDay()
+							let day = date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()
 							uni.navigateTo({
 								url: '/pages/form/donaSuccess?money=' + obj.money + '&name=' + obj.donate_er + '&time=' + year + '年' + month + '月' + day +'日'
 							})

+ 10 - 1
utils/newRequest.js

@@ -1,4 +1,6 @@
 import store from '../store'
+import md5 from './md5.js'
+import sha1 from './sha1.js'
 let service = {
 	// baseURL: store.state.baseURL, // 请求头
 	baseURL: '', // 请求头
@@ -119,12 +121,19 @@ let service = {
 						uni.showLoading({
 							title: '上传中'
 						})
+						let timestamp = new Date().getTime();
+						let appSecret = '55dc12c813b6131578780dcd9cfd9d90';
+						let Appid = 'wx9e9cda4611521ed4';
+						let Sign = md5(sha1(Appid + timestamp + appSecret + timestamp + Appid + appSecret))
 						uni.uploadFile({
 							url: config.upload_img_url, //仅为示例,非真实的接口地址
 							filePath: path,
 							name: 'file',
 							header: {
-								"Authori-zation": 'Bearer ' + uni.getStorageSync('token')
+								"Authori-zation": 'Bearer ' + uni.getStorageSync('token'),
+								"App-id": Appid,
+								"Sign": Sign,
+								"Sign-time": timestamp
 							},
 							success: (uploadFileRes) => {
 								if ("string" === typeof uploadFileRes.data) {