Browse Source

feat: 修改数据

linwenxin 1 year ago
parent
commit
4ef2cc5aaf
3 changed files with 235 additions and 231 deletions
  1. 93 86
      package-lock.json
  2. 64 68
      src/common/http/index.js
  3. 78 77
      src/common/utils/util.js

+ 93 - 86
package-lock.json

@@ -3054,44 +3054,6 @@
           "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
           "dev": true
         },
-        "ansi-styles": {
-          "version": "4.3.0",
-          "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz",
-          "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "color-convert": "^2.0.1"
-          }
-        },
-        "chalk": {
-          "version": "4.1.2",
-          "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz",
-          "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "ansi-styles": "^4.1.0",
-            "supports-color": "^7.1.0"
-          }
-        },
-        "color-convert": {
-          "version": "2.0.1",
-          "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
-          "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "color-name": "~1.1.4"
-          }
-        },
-        "color-name": {
-          "version": "1.1.4",
-          "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz",
-          "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
-          "dev": true,
-          "optional": true
-        },
         "css-loader": {
           "version": "3.6.0",
           "resolved": "https://registry.npmmirror.com/css-loader/-/css-loader-3.6.0.tgz",
@@ -3149,13 +3111,6 @@
             "pump": "^3.0.0"
           }
         },
-        "has-flag": {
-          "version": "4.0.0",
-          "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz",
-          "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
-          "dev": true,
-          "optional": true
-        },
         "hash-sum": {
           "version": "2.0.0",
           "resolved": "https://registry.npmmirror.com/hash-sum/-/hash-sum-2.0.0.tgz",
@@ -3258,42 +3213,6 @@
           "requires": {
             "minipass": "^3.1.1"
           }
-        },
-        "supports-color": {
-          "version": "7.2.0",
-          "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz",
-          "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "has-flag": "^4.0.0"
-          }
-        },
-        "vue-loader-v16": {
-          "version": "npm:vue-loader@16.8.3",
-          "resolved": "https://registry.npmmirror.com/vue-loader/-/vue-loader-16.8.3.tgz",
-          "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "chalk": "^4.1.0",
-            "hash-sum": "^2.0.0",
-            "loader-utils": "^2.0.0"
-          },
-          "dependencies": {
-            "loader-utils": {
-              "version": "2.0.4",
-              "resolved": "https://registry.npmmirror.com/loader-utils/-/loader-utils-2.0.4.tgz",
-              "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==",
-              "dev": true,
-              "optional": true,
-              "requires": {
-                "big.js": "^5.2.2",
-                "emojis-list": "^3.0.0",
-                "json5": "^2.1.2"
-              }
-            }
-          }
         }
       }
     },
@@ -10516,7 +10435,7 @@
     },
     "js-perform-lock": {
       "version": "1.0.5",
-      "resolved": "https://registry.npmmirror.com/js-perform-lock/-/js-perform-lock-1.0.5.tgz",
+      "resolved": "http://121.41.110.30:4873/js-perform-lock/-/js-perform-lock-1.0.5.tgz",
       "integrity": "sha512-aDp38fxLnur2YMsJhw1Ab23PdwceXMU5Pkcb4R5MSaRfySiDwbDR2L/ysnB4X7/1XERkLC56r32qwtNlitBSGg=="
     },
     "js-tokens": {
@@ -16160,9 +16079,9 @@
       "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
     },
     "uview-ui": {
-      "version": "2.0.31",
-      "resolved": "https://registry.npmmirror.com/uview-ui/-/uview-ui-2.0.31.tgz",
-      "integrity": "sha512-I/0fGuvtiKHH/mBb864SGYk+SJ7WaF32tsBgYgeBOsxlUp+Th+Ac2tgz2cTvsQJl6eZYWsKZ3ixiSXCAcxZ8Sw=="
+      "version": "2.0.34",
+      "resolved": "http://121.41.110.30:4873/uview-ui/-/uview-ui-2.0.34.tgz",
+      "integrity": "sha512-usJHnPCtk45yLTWTXTpLX9Vuqhzjth/+4t/m+S3J5bZuahv49mVQ126rtSnuAWWVkOUtKCX4CU83gFHZj8nP5g=="
     },
     "v8-to-istanbul": {
       "version": "4.1.4",
@@ -16240,6 +16159,94 @@
         "vue-style-loader": "^4.1.0"
       }
     },
+    "vue-loader-v16": {
+      "version": "npm:vue-loader@16.8.3",
+      "resolved": "http://121.41.110.30:4873/vue-loader/-/vue-loader-16.8.3.tgz",
+      "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
+      "dev": true,
+      "optional": true,
+      "requires": {
+        "chalk": "^4.1.0",
+        "hash-sum": "^2.0.0",
+        "loader-utils": "^2.0.0"
+      },
+      "dependencies": {
+        "ansi-styles": {
+          "version": "4.3.0",
+          "resolved": "http://121.41.110.30:4873/ansi-styles/-/ansi-styles-4.3.0.tgz",
+          "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "color-convert": "^2.0.1"
+          }
+        },
+        "chalk": {
+          "version": "4.1.2",
+          "resolved": "http://121.41.110.30:4873/chalk/-/chalk-4.1.2.tgz",
+          "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "ansi-styles": "^4.1.0",
+            "supports-color": "^7.1.0"
+          }
+        },
+        "color-convert": {
+          "version": "2.0.1",
+          "resolved": "http://121.41.110.30:4873/color-convert/-/color-convert-2.0.1.tgz",
+          "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "color-name": "~1.1.4"
+          }
+        },
+        "color-name": {
+          "version": "1.1.4",
+          "resolved": "http://121.41.110.30:4873/color-name/-/color-name-1.1.4.tgz",
+          "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+          "dev": true,
+          "optional": true
+        },
+        "has-flag": {
+          "version": "4.0.0",
+          "resolved": "http://121.41.110.30:4873/has-flag/-/has-flag-4.0.0.tgz",
+          "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+          "dev": true,
+          "optional": true
+        },
+        "hash-sum": {
+          "version": "2.0.0",
+          "resolved": "http://121.41.110.30:4873/hash-sum/-/hash-sum-2.0.0.tgz",
+          "integrity": "sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==",
+          "dev": true,
+          "optional": true
+        },
+        "loader-utils": {
+          "version": "2.0.4",
+          "resolved": "http://121.41.110.30:4873/loader-utils/-/loader-utils-2.0.4.tgz",
+          "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "big.js": "^5.2.2",
+            "emojis-list": "^3.0.0",
+            "json5": "^2.1.2"
+          }
+        },
+        "supports-color": {
+          "version": "7.2.0",
+          "resolved": "http://121.41.110.30:4873/supports-color/-/supports-color-7.2.0.tgz",
+          "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "has-flag": "^4.0.0"
+          }
+        }
+      }
+    },
     "vue-pdf": {
       "version": "4.3.0",
       "resolved": "https://registry.npmmirror.com/vue-pdf/-/vue-pdf-4.3.0.tgz",
@@ -16944,7 +16951,7 @@
     },
     "weixin-js-sdk": {
       "version": "1.6.3",
-      "resolved": "https://registry.npmmirror.com/weixin-js-sdk/-/weixin-js-sdk-1.6.3.tgz",
+      "resolved": "http://121.41.110.30:4873/weixin-js-sdk/-/weixin-js-sdk-1.6.3.tgz",
       "integrity": "sha512-5jYNtVcxWmgHNqCLSPoX6vXab9G4RPDZx0klX8IsVwGjDTwx/UDmgfF7fkRMGguRpuFv0O7tk1jb+Oay2QiV1w=="
     },
     "whatwg-encoding": {

+ 64 - 68
src/common/http/index.js

@@ -125,78 +125,74 @@ function del(url, data, loadingBool) {
 //封装的通用请求方法
 export const axios = function(obj = {}) {
 
-  console.log(666666);
-
-
-	if (typeof obj !== 'object') {
-		throw new Error('arguments must be object');
-	}
-	if (!obj.url) {
-		throw new Error('url not defined');
-	}
-	return new Promise((resolve, reject) => {
-		if (obj.isLoading) {
-			uni.showLoading({
-				title: '加载中',
-				mask: true,
-			})
-		}
-
-    console.log(77777);
-
-	let _url = process.env.VUE_APP_BASE_URL + process.env.VUE_APP_BASE_API + obj.url
-console.log(_url);
-  
-		let isGet = obj.method && obj.method.toLowerCase() == 'get';
-		let isQuery = obj.isQuery;
-		if (isGet || isQuery) {
-			_url += '?' + urlEncode(obj.params)
-		}
-		let _type = 'application/x-www-form-urlencoded';
-		if (obj.type == 'json') {
-			_type = 'application/json'
-		}
-		uni.request({
-			url: _url,
-			data: isGet || isQuery ? '' : (obj.params || ''),
-			header: {
-				'content-type': _type,
-				"x-token": store.getters.token,
-			},
-			method: obj.method ? obj.method : "POST",
-			success: function(ress) {
-        console.log(ress)
-
-				if (obj.isLoading) {
-					uni.hideLoading();
-				}
+  if (typeof obj !== 'object') {
+    throw new Error('arguments must be object');
+  }
+  if (!obj.url) {
+    throw new Error('url not defined');
+  }
+  return new Promise((resolve, reject) => {
+    if (obj.isLoading) {
+      uni.showLoading({
+        title: '加载中',
+        mask: true,
+      })
+    }
 
-        const res = ress.data;
-    if (whiteCodes.indexOf(res.code) < 0) {
-      
+    let _url = process.env.VUE_APP_BASE_URL + process.env.VUE_APP_BASE_API + obj.url
 
-      uni.showToast({
-        title: res.message || 'Error',
-        icon: 'none',
-        duration: 1500
-      })
-      reject(new Error(res.message || 'Error'));
-    } else {
-      resolve(res)
+    let isGet = obj.method && obj.method.toLowerCase() == 'get';
+    let isQuery = obj.isQuery;
+    if (isGet || isQuery) {
+      _url += '?' + Object.entries(obj.params || {}).map(item => item.join("=")).join("&")
+    }
+    let _type = 'application/x-www-form-urlencoded';
+    if (obj.type == 'json') {
+      _type = 'application/json'
     }
 
-			
-			},
-			fail: function(err) {
-				uni.hideLoading();
-				uni.showModal({
-					title: '提示',
-					content: '网络连接失败' + JSON.stringify(err),
-				})
-				reject(err);
-			},
-		})
-	})
+    uni.request({
+      url: _url,
+      data: isGet || isQuery ? '' : (obj.params || ''),
+      header: {
+        'content-type': _type,
+        "x-token": store.getters.token,
+      },
+      method: obj.method ? obj.method : "POST",
+      success: function(ress) {
+
+        console.log(ress, "----------------")
+
+        if (obj.isLoading) {
+          uni.hideLoading();
+        }
+
+        const res = ress.data;
+        if (whiteCodes.indexOf(res.code) < 0) {
+
+
+          uni.showToast({
+            title: res.message || 'Error',
+            icon: 'none',
+            duration: 1500
+          })
+          reject(new Error(res.message || 'Error'));
+        } else {
+          resolve(res)
+        }
+
+
+      },
+      fail: function(err) {
+        uni.hideLoading();
+        uni.showModal({
+          title: '提示',
+          content: '网络连接失败' + JSON.stringify(err),
+        })
+        reject(err);
+      },
+    })
+  })
 }
 
 export default {

+ 78 - 77
src/common/utils/util.js

@@ -1,7 +1,8 @@
 import api from '@/common/http/'
-import { axios } from '@/common/http/'
+import {
+  axios
+} from '@/common/http/'
 import store from '@/store/index.js'
-console.log(axios)
 
 // 获取用户信息
 export const getUserInfo = () => {
@@ -45,7 +46,7 @@ export const uploadImg = async function(file) {
     }).catch(err => {
       uni.hideLoading();
     })
-  const fileKey = par.dir + createName(file.path);
+  const fileKey = par.dir + createName(file.name);
 
   return new Promise((resolve, reject) => {
     const uploadTask = uni.uploadFile({
@@ -94,88 +95,88 @@ export const uploadImg = async function(file) {
 }
 
 export const getArea = function(str) {
-	let area = {}
-	let index11 = 0
-	let index1 = str.indexOf("省")
-	if (index1 == -1) {
-	  index11 = str.indexOf("自治区")
-	  if (index11 != -1) {
-	    area.Province = str.substring(0, index11 + 3)
-	  } else {
-	    area.Province = str.substring(0, 0)
-	  }
-	} else {
-	  area.Province = str.substring(0, index1 + 1)
-	}
+  let area = {}
+  let index11 = 0
+  let index1 = str.indexOf("省")
+  if (index1 == -1) {
+    index11 = str.indexOf("自治区")
+    if (index11 != -1) {
+      area.Province = str.substring(0, index11 + 3)
+    } else {
+      area.Province = str.substring(0, 0)
+    }
+  } else {
+    area.Province = str.substring(0, index1 + 1)
+  }
 
-	let index2 = str.indexOf("市")
-	if (index11 == -1) {
-	  area.City = str.substring(index11 + 1, index2 + 1)
-	} else {
-	  if (index11 == 0) {
-	    area.City = str.substring(index1 + 1, index2 + 1)
-	  } else {
-	    area.City = str.substring(index11 + 3, index2 + 1)
-	  }
-	}
+  let index2 = str.indexOf("市")
+  if (index11 == -1) {
+    area.City = str.substring(index11 + 1, index2 + 1)
+  } else {
+    if (index11 == 0) {
+      area.City = str.substring(index1 + 1, index2 + 1)
+    } else {
+      area.City = str.substring(index11 + 3, index2 + 1)
+    }
+  }
 
-	let index3 = str.lastIndexOf("区")
-	if (index3 == -1) {
-	  index3 = str.indexOf("县")
-	  area.Country = str.substring(index2 + 1, index3 + 1)
-	} else {
-	  area.Country = str.substring(index2 + 1, index3 + 1)
-	}
-	return area;
+  let index3 = str.lastIndexOf("区")
+  if (index3 == -1) {
+    index3 = str.indexOf("县")
+    area.Country = str.substring(index2 + 1, index3 + 1)
+  } else {
+    area.Country = str.substring(index2 + 1, index3 + 1)
+  }
+  return area;
 }
 
 // 图片上传
 export const uploadImgs = async function(file) {
-	uni.showLoading({
-		title: '上传中',
-		mask: true,
-	});
+  uni.showLoading({
+    title: '上传中',
+    mask: true,
+  });
 
-	// 获取oss配置
-	const par = await axios({
-			url: '/common/oss/config',
-			method: 'get',
-		})
-		.then((res) => {
-			return res.data;
-		})
-		.catch((err) => {
-			uni.hideLoading();
-		});
+  // 获取oss配置
+  const par = await axios({
+      url: '/common/oss/config',
+      method: 'get',
+    })
+    .then((res) => {
+      return res.data;
+    })
+    .catch((err) => {
+      uni.hideLoading();
+    });
 
-	const fileKey = par.dir + createName(file.path);
+  const fileKey = par.dir + createName(file.name);
 
-	return new Promise((resolve, reject) => {
-		uni.uploadFile({
-			url: par.host,
-			// header: {
-			// 	"Content-Type": 'multipart/form-data',
-			// },
-			name: 'file',
-			formData: {
-				...par,
-				name: file.name,
-				key: fileKey,
-			},
-			filePath: file.path,
-			success(res) {
-				resolve({
-					url: fileKey,
-				});
-			},
-			fail(err) {
-				reject(err);
-			},
-			complete(res) {
-				uni.hideLoading();
-			},
-		});
-	});
+  return new Promise((resolve, reject) => {
+    uni.uploadFile({
+      url: par.host,
+      // header: {
+      // 	"Content-Type": 'multipart/form-data',
+      // },
+      name: 'file',
+      formData: {
+        ...par,
+        name: file.name,
+        key: fileKey,
+      },
+      filePath: file.path,
+      success(res) {
+        resolve({
+          url: fileKey,
+        });
+      },
+      fail(err) {
+        reject(err);
+      },
+      complete(res) {
+        uni.hideLoading();
+      },
+    });
+  });
 };
 
 export default {
@@ -183,4 +184,4 @@ export default {
   uploadImg,
   getArea,
   uploadImgs
-};
+};