Prechádzať zdrojové kódy

修复bug,测试图片上传

Ming 3 rokov pred
rodič
commit
939371f729
5 zmenil súbory, kde vykonal 70 pridanie a 7 odobranie
  1. 9 0
      pages.json
  2. 3 3
      pages/index/index.vue
  3. 54 0
      pages/test/test.vue
  4. 3 3
      util/api.js
  5. 1 1
      util/jssdk.js

+ 9 - 0
pages.json

@@ -422,6 +422,15 @@
             }
             
         }
+        ,{
+            "path" : "pages/test/test",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",

+ 3 - 3
pages/index/index.vue

@@ -220,7 +220,7 @@
 					//使用code请求服务器接口,换取用户用户openID
 
 					uni.request({
-						url: 'http://124.71.174.104:8081/USKYOF/USKYOF.php/Home/Com/getPageAuthorization', //仅为示例,并非真实接口地址。
+						url: 'http://wx.ewoogi.com:8081/USKYOF/USKYOF.php/Home/Com/getPageAuthorization', //仅为示例,并非真实接口地址。
 						// data: {
 						//     text: 'uni.request'
 						// },
@@ -232,7 +232,7 @@
 							// alert(res.data.flag)
 							if (res.data.flag == 3000) {
 								// alert("3000授权失败,请重新登录");
-								window.location.href = 'http://124.71.174.104:8081/index.html#/';
+								window.location.href = 'http://wx.ewoogi.com:8081/index.html#/';
 							}
 
 							if (res.data.flag == 3003) {
@@ -355,7 +355,7 @@
 					if (res.data.flag == 3000) {
 
 						// alert("3000授权失败,");
-						window.location.href = 'http://124.71.174.104:8081/index.html#/';
+						window.location.href = 'http://wx.ewoogi.com:8081/index.html#/';
 					}
 
 					if (res.data.flag == 3003) {

+ 54 - 0
pages/test/test.vue

@@ -0,0 +1,54 @@
+<template>
+ <view>
+  <view ref="input" class="input">
+   附件上传
+  </view>
+ </view>
+</template>
+
+<script>
+ export default {
+  data() {
+   return {
+    
+   }
+  },
+  // uni-app input不支持type=“file”类型所以需要js创建
+  mounted() {
+   // 创建附件上传
+   var _self = this;
+   var input = document.createElement('input');//创建元素
+   input.type = 'file'//添加file类型
+   input.onchange = (event) => {
+    _self.upFile(input, event)
+   }
+   this.$refs.input.$el.appendChild(input)
+  },
+  //上传
+  methods: {
+   upFile(input, event) {
+    var _self = this;
+    uni.uploadFile({
+     url: 'http://124.71.174.104:8081/USKYOF/USKYOF.php/Home/MonitoringReporting/setUpload',
+     files: [
+      {
+       file: input.files[0],
+       uri: event.srcElement.value
+      }
+     ],
+     success: (uploadFileRes) => {
+      console.log(uploadFileRes)
+     },
+     fail: (err) => {
+      console.log(err)
+     }
+    });
+   },
+  }
+  
+ }
+</script>
+
+<style>
+
+</style>

+ 3 - 3
util/api.js

@@ -1,5 +1,5 @@
 // const BASE_URL = 'https://iot.usky.cn/USKYOF/USKYOF.php/Home/' //(测试域名)  
-const BASE_URL = 'http://124.71.174.104:8081/USKYOF/USKYOF.php/Home/' //(测试域名新)  
+const BASE_URL = 'http://wx.ewoogi.com:8081/USKYOF/USKYOF.php/Home/' //(测试域名新)  
 // const BASE_URL='http://https://qhome.usky.cn/USKYOF/USKYOF.php/Home/'
 // 同时发送异步代码的次数,防止一次点击中有多次请求,用于处理
 let ajaxTimes = 0;
@@ -36,7 +36,7 @@ export const myRequest = (options) => {
 						if (notIndexFail2.includes(options.url) && ua.match(
 								/MicroMessenger/i) == "micromessenger") {
 							// alert('数据拉取失败,请重新进入公众号')
-							// window.location.href = 'http://124.71.174.104:8081/index.html#/pages/index/index';
+							// window.location.href = 'http://wx.ewoogi.com:8081/index.html#/pages/index/index';
 						} else {
 
 							return uni.showToast({
@@ -60,7 +60,7 @@ export const myRequest = (options) => {
 				let notIndexFail = ['Index/getDataStatistics', 'Com/getAuthorizationUrl'];
 				if (notIndexFail.includes(options.url)) {
 					window.location.href =
-						'http://124.71.174.104:8081/index.html#/pages/index/index';
+						'http://wx.ewoogi.com:8081/index.html#/pages/index/index';
 				} else {
 					uni.showModal({
 						showCancel: false,

+ 1 - 1
util/jssdk.js

@@ -10,7 +10,7 @@ export function configWeiXin(callback) {
 	console.log(BASE_URL.BASE_URL)
 	// start
 	uni.request({
-		url:"http://124.71.174.104:8081/sign.php",	
+		url:"http://wx.ewoogi.com:8081/sign.php",	
 		// url:"http://s.yxin.tech/sign.php",