cmy 5 years ago
parent
commit
6df1e7f240

+ 35 - 29
libs/login.js

@@ -1,13 +1,20 @@
 import store from "../store";
 import Cache from '../utils/cache';
 // #ifdef H5 || APP-PLUS
-import { isWeixin } from "../utils";
+import {
+	isWeixin
+} from "../utils";
 import auth from './wechat';
 // #endif
 
-import { LOGIN_STATUS, USER_INFO, EXPIRES_TIME, STATE_R_KEY} from './../config/cache';
+import {
+	LOGIN_STATUS,
+	USER_INFO,
+	EXPIRES_TIME,
+	STATE_R_KEY
+} from './../config/cache';
 
-function prePage(){
+function prePage() {
 	let pages = getCurrentPages();
 	let prePage = pages[pages.length - 2];
 	// #ifdef H5
@@ -19,58 +26,57 @@ function prePage(){
 export function toLogin(push, pathLogin) {
 	// store.commit("LOGOUT");
 	let path = prePage();
-	if(path){
+	if (path) {
 		path = path.router;
-		if(path == undefined){
+		if (path == undefined) {
 			path = location.pathname;
 		}
-	}  
-		// #ifdef H5
-	else{
+	}
+	// #ifdef H5
+	else {
 		path = location.pathname;
-	} 
-		// #endif
-		
-	if(!pathLogin)
+	}
+	// #endif
+
+	if (!pathLogin)
 		pathLogin = '/page/users/login/index'
-	Cache.set('login_back_url',path);
+	Cache.set('login_back_url', path);
 	// #ifdef H5 || APP-PLUS
 	if (isWeixin()) {
 		auth.oAuth();
 	} else {
 		if (path !== pathLogin) {
-		 push ? uni.navigateTo({
-		 	url:'/pages/users/login/index'
-		 }) : uni.reLaunch({
-		 	url: '/pages/users/login/index'
-		 });
+			push ? uni.navigateTo({
+				url: '/pages/users/login/index'
+			}) : uni.reLaunch({
+				url: '/pages/users/login/index'
+			});
 		}
 	}
 	// #endif
-	
+
 	// #ifdef MP 
-	
-	
+
+
 	// #endif
 }
 
 
-export function checkLogin()
-{
+export function checkLogin() {
 	let token = Cache.get(LOGIN_STATUS);
 	let expiresTime = Cache.get(EXPIRES_TIME);
 	let newTime = Math.round(new Date() / 1000);
-	if (expiresTime < newTime || !token){
+	if (expiresTime < newTime || !token) {
 		Cache.clear(LOGIN_STATUS);
 		Cache.clear(EXPIRES_TIME);
 		Cache.clear(USER_INFO);
 		Cache.clear(STATE_R_KEY);
 		return false;
-	}else{
-		store.commit('UPDATE_LOGIN',token);
-		let userInfo = Cache.get(USER_INFO,true);
-		if(userInfo){
-			store.commit('UPDATE_USERINFO',userInfo);
+	} else {
+		store.commit('UPDATE_LOGIN', token);
+		let userInfo = Cache.get(USER_INFO, true);
+		if (userInfo) {
+			store.commit('UPDATE_USERINFO', userInfo);
 		}
 		return true;
 	}

+ 83 - 75
manifest.json

@@ -1,77 +1,85 @@
 {
-    "name" : "基础项目",
-    "appid" : "__UNI__F0EBD91",
-    "description" : "",
-    "versionName" : "1.0.0",
-    "versionCode" : "100",
-    "transformPx" : false,
-    "app-plus" : {
-        /* 5+App特有相关 */
-        "usingComponents" : true,
-        "splashscreen" : {
-            "alwaysShowBeforeRender" : true,
-            "waiting" : true,
-            "autoclose" : true,
-            "delay" : 0
-        },
-        "modules" : {},
-        /* 模块配置 */
-        "distribute" : {
-            /* 应用发布信息 */
-            "android" : {
-                /* android打包配置 */
-                "permissions" : [
-                    "<uses-feature android:name=\"android.hardware.camera\"/>",
-                    "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
-                    "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
-                    "<uses-permission android:name=\"android.permission.CAMERA\"/>",
-                    "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
-                    "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
-                    "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
-                    "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
-                    "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
-                    "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
-                    "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>"
-                ],
-                "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ]
-            },
-            "ios" : {
-                "idfa" : false
-            },
-            /* ios打包配置 */
-            "sdkConfigs" : {
-                "maps" : {},
-                "oauth" : {
-                    "weixin" : {
-                        "appid" : "",
-                        "appsecret" : "",
-                        "UniversalLinks" : ""
-                    }
-                }
-            }
-        }
-    },
-    /* SDK配置 */
-    "quickapp" : {},
-    /* 快应用特有相关 */
-    "mp-weixin" : {
-        /* 小程序特有相关 */
-        "usingComponents" : true,
-        "appid" : "",
-        "setting" : {
-            "urlCheck" : true
-        }
-    },
-    "h5" : {
-        "title" : "商城",
-        "domain" : "",
-        "router" : {
-            "base" : "/index/",
-            "mode" : "history"
-        },
-        "devServer" : {
-            "port" : ""
-        }
-    }
+	"name": "基础项目",
+	"appid": "__UNI__F0EBD91",
+	"description": "",
+	"versionName": "1.0.0",
+	"versionCode": "100",
+	"transformPx": false,
+	"app-plus": {
+		/* 5+App特有相关 */
+		"usingComponents": true,
+		"splashscreen": {
+			"alwaysShowBeforeRender": true,
+			"waiting": true,
+			"autoclose": true,
+			"delay": 0
+		},
+		"modules": {},
+		/* 模块配置 */
+		"distribute": {
+			/* 应用发布信息 */
+			"android": {
+				/* android打包配置 */
+				"permissions": [
+					"<uses-feature android:name=\"android.hardware.camera\"/>",
+					"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
+					"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
+					"<uses-permission android:name=\"android.permission.CAMERA\"/>",
+					"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
+					"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
+					"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
+					"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
+					"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
+					"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
+					"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
+					"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>"
+				],
+				"abiFilters": ["armeabi-v7a", "arm64-v8a", "x86"]
+			},
+			"ios": {
+				"idfa": false
+			},
+			/* ios打包配置 */
+			"sdkConfigs": {
+				"maps": {},
+				"oauth": {
+					"weixin": {
+						"appid": "",
+						"appsecret": "",
+						"UniversalLinks": ""
+					}
+				}
+			}
+		}
+	},
+	/* SDK配置 */
+	"quickapp": {},
+	/* 快应用特有相关 */
+	"mp-weixin": {
+		/* 小程序特有相关 */
+		"usingComponents": true,
+		"appid": "",
+		"setting": {
+			"urlCheck": true
+		}
+	},
+	"h5": {
+		"title": "商城",
+		"domain": "",
+		"router": {
+			"base": "/index/",
+			"mode": "history"
+		},
+		"devServer": {
+			"proxy": {
+				"/api": {
+					"target": "http://192.168.0.101/api",
+					// "changeOrigin": true,
+					"pathRewrite": {
+						"/api": "" // rewrite path
+					}
+				}
+			}
+		}
+	}
 }

+ 0 - 30
node_modules/jweixin-module/README.md

@@ -1,30 +0,0 @@
-# jweixin-module
-
-微信JS-SDK
-
-## 安装
-
-### NPM
-
-```shell
-npm install jweixin-module --save
-```
-
-### UMD
-
-```http
-https://unpkg.com/jweixin-module/out/index.js
-```
-
-## 使用
-
-```js
-var wx = require('jweixin-module')
-wx.ready(function(){
-    // TODO
-});
-```
-
-## 完整API
-
->[微信JS-SDK说明文档](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115)

File diff suppressed because it is too large
+ 0 - 0
node_modules/jweixin-module/out/index.js


+ 0 - 60
node_modules/jweixin-module/package.json

@@ -1,60 +0,0 @@
-{
-  "_from": "jweixin-module",
-  "_id": "jweixin-module@1.4.1",
-  "_inBundle": false,
-  "_integrity": "sha512-2R2oa1lYhAsclfjKSf3DP4ZiP1dcrQUbM7aklbeJA+UAg/LS7MqoA6UbTy1cs4sbB34z62K4bKW0Z9iazD8ejg==",
-  "_location": "/jweixin-module",
-  "_phantomChildren": {},
-  "_requested": {
-    "type": "tag",
-    "registry": true,
-    "raw": "jweixin-module",
-    "name": "jweixin-module",
-    "escapedName": "jweixin-module",
-    "rawSpec": "",
-    "saveSpec": null,
-    "fetchSpec": "latest"
-  },
-  "_requiredBy": [
-    "#USER",
-    "/"
-  ],
-  "_resolved": "https://registry.npmjs.org/jweixin-module/-/jweixin-module-1.4.1.tgz",
-  "_shasum": "1fc8fa42622243f6c35651d272cd587debf56cd1",
-  "_spec": "jweixin-module",
-  "_where": "D:\\工作\\项目\\appBase",
-  "author": {
-    "name": "Shengqiang Guo"
-  },
-  "bugs": {
-    "url": "https://github.com/zhetengbiji/jweixin-module/issues"
-  },
-  "bundleDependencies": false,
-  "deprecated": false,
-  "description": "微信JS-SDK",
-  "devDependencies": {
-    "textfile": "^1.2.0",
-    "uglify-js": "^3.4.9"
-  },
-  "homepage": "https://github.com/zhetengbiji/jweixin-module#readme",
-  "keywords": [
-    "wxjssdk",
-    "weixin",
-    "jweixin",
-    "wechat",
-    "jssdk",
-    "wx"
-  ],
-  "license": "ISC",
-  "main": "out/index.js",
-  "name": "jweixin-module",
-  "repository": {
-    "type": "git",
-    "url": "git+https://github.com/zhetengbiji/jweixin-module.git"
-  },
-  "scripts": {
-    "build": "node build",
-    "prepublish": "npm run build"
-  },
-  "version": "1.4.1"
-}

+ 0 - 11
package-lock.json

@@ -1,11 +0,0 @@
-{
-  "requires": true,
-  "lockfileVersion": 1,
-  "dependencies": {
-    "jweixin-module": {
-      "version": "1.4.1",
-      "resolved": "https://registry.npmjs.org/jweixin-module/-/jweixin-module-1.4.1.tgz",
-      "integrity": "sha512-2R2oa1lYhAsclfjKSf3DP4ZiP1dcrQUbM7aklbeJA+UAg/LS7MqoA6UbTy1cs4sbB34z62K4bKW0Z9iazD8ejg=="
-    }
-  }
-}

+ 30 - 10
utils/newRequest.js

@@ -43,18 +43,26 @@ let service = {
 	open: async function(data) {
 		return await new Promise(function(resolve, reject) {
 			let requestData = ''; //保存处理完成后请求数据
+			let url =''//保存链接地址
+			//console.log(data);
 			// 请求前数据处理
 			requestData = service.request.success(data);
-			// 数据复制用于请求
-			let url = '';
-			if (requestData.url.indexOf('http') > -1) {
-				url = requestData.url
-			} else {
-				url = service.baseURL + requestData.url
+			// #ifdef H5
+			
+			if(process.env.NODE_ENV === 'development'){
+				url= requestData.url;
+			    console.log('开发环境')
+			}else{
+				url=service.baseURL + requestData.url;
+			    console.log('生产环境')
 			}
+			// #endif
+			// #ifndef H5
+			url=service.baseURL + requestData.url;
+			// #endif
 			// 数据复制用于请求
 			uni.request({
-				url,
+				url:url,
 				method: requestData.method || 'GET',
 				data: requestData.data,
 				header: data.header || service.header,
@@ -79,6 +87,7 @@ let service = {
 	upFilse: async function(data) {
 		return await new Promise(function(resolve, reject) {
 			let requestData = ''; //保存处理完成后请求数据
+			let url = '' //保存请求地址
 			try {
 				// 请求前数据处理
 				requestData = service.request.success(data);
@@ -86,9 +95,21 @@ let service = {
 				// 请求报错拦截
 				service.request.error(e);
 			}
+			// #ifdef H5
+			if(process.env.NODE_ENV === 'development'){
+				url= requestData.url;
+			    console.log('开发环境')
+			}else{
+				url=service.baseURL + requestData.url;
+			    console.log('生产环境')
+			}
+			// #endif
+			// #ifndef H5
+			url=service.baseURL + requestData.url;
+			// #endif
 			let config = {
 				// 上传图片的API
-				upload_img_url: service.baseURL + requestData.url
+				upload_img_url:url
 			}
 
 			let Uploader = {
@@ -97,8 +118,6 @@ let service = {
 					return new Promise((resolve, reject) => {
 						uni.chooseImage({
 							count: num,
-							sourceType:['album'],
-							sizeType:'compressed',
 							success(res) {
 								// console.log(res);
 								// 缓存文件路径
@@ -110,6 +129,7 @@ let service = {
 							}
 						})
 					})
+
 				},
 				// 上传图片
 				upload_one(path) {

+ 1 - 1
utils/wxAuthorized.js

@@ -7,7 +7,7 @@ import {
 } from './platform.js'
 import store from '../store';
 // 保存wx对象
-let weixinObj = require('jweixin-module');
+import weixinObj from "@/plugin/jweixin-module/index.js";
 // 保存分享数据
 let shareData = '';
 // 保存注册返回appId数据

Some files were not shown because too many files changed in this diff