zhengkaixin 3 år sedan
förälder
incheckning
a3f8556642
16 ändrade filer med 127 tillägg och 101 borttagningar
  1. 1 1
      .env.dev.js
  2. 1 1
      .env.prod.js
  3. 1 1
      .env.test.js
  4. 1 2
      .env.uat.js
  5. 1 1
      App.vue
  6. 1 1
      README.md
  7. 7 69
      bobo-router/index.js
  8. 29 1
      components/Common.vue
  9. 11 5
      main.js
  10. 1 1
      manifest.json
  11. 3 3
      pages.json
  12. 1 1
      pages/index/index.js
  13. 6 11
      pages/index/index.vue
  14. 60 0
      utils/init.js
  15. 2 2
      utils/mixin.js
  16. 1 1
      vue.config.js

+ 1 - 1
.env.dev.js

@@ -1,6 +1,6 @@
 const UNI_APP = {  
 	
-    BASE_URL: 'https://ykt-test.xiaoxinda.com/smart-bus-server/' ,
+    BASE_URL: 'https://xpgjapi.xiaoxinda.com/' ,
 	NODE_ENV :"dev",
 	SIMPLE_RUN:true,// 无视权限控制跳转页面   , 用于样式人员快速访问各种功能 ,快速测试等
 	//小鹏管家appid

+ 1 - 1
.env.prod.js

@@ -1,6 +1,6 @@
 const UNI_APP = {  
 	
-	BASE_URL: 'http://121.37.187.149/smart-bus-server/' ,
+	BASE_URL: 'https://xpgjapi.xiaoxinda.com/' ,
 	NODE_ENV :"prod",
 	SIMPLE_RUN:false,
 	//小鹏管家appid

+ 1 - 1
.env.test.js

@@ -1,6 +1,6 @@
 const UNI_APP = {  
 	//BASE_URL: 'http://192.168.33.120:8087/smart-bus-server/' ,
-	BASE_URL: 'http://121.37.187.149/smart-bus-server/' ,
+	BASE_URL: 'https://xpgjapi.xiaoxinda.com/' ,
 	NODE_ENV :"test",
 	SIMPLE_RUN:false,
 	//小鹏管家appid

+ 1 - 2
.env.uat.js

@@ -1,7 +1,6 @@
 const UNI_APP = {  
 	
-	BASE_URL: 'https://ykt-test.xiaoxinda.com/smart-bus-server/' ,
-	//BASE_URL: 'http://121.37.187.149/smart-bus-server/' ,
+	BASE_URL: 'https://xpgjapi.xiaoxinda.com/' ,
 	NODE_ENV :"uat",
 	SIMPLE_RUN:false,
 	//小鹏管家appid

+ 1 - 1
App.vue

@@ -11,7 +11,7 @@
 		
 		},
 		onReady: function() {
-			
+			console.log("aaa")
 		},
 		onHide: function() {
 			

+ 1 - 1
README.md

@@ -1,4 +1,4 @@
-# jp-car-phone 车信达手机端
+#  jp_employment_kfq  荆开求职在线
 
 ## 运行与安装
 建议使用uniapp的官方推荐开发工具HBuilder最新版本

+ 7 - 69
bobo-router/index.js

@@ -1,10 +1,5 @@
-import {
-	getUrlParam,
-	getWeixinRedirectURI,
-	isWeiXin
-} from '@/utils'
-import * as API_WeiXin from '@/apis/weixin.js'
-import  carhelp from '@/utils/mixin.js'
+ 
+// import  carhelp from '@/utils/mixin.js'
 
 import Vue from 'vue'
 import uniCrazyRouter from "uni-crazy-router";
@@ -15,25 +10,9 @@ Vue.use(uniCrazyRouter)
 
 uniCrazyRouter.beforeEach(async (to, from, next) => {
 
-	// 逻辑代码
-	console.log("beforeEach")
-	if(to.url==from.url){
-		
-		var url="pages/index/index";
-		if(to.url.indexOf("pages/my")==0){
-			url="pages/my/index";
-		}
-		if(to.url.indexOf("pages/news")==0){
-			url="pages/news/index";
-		}
-		if(to.url.indexOf("pages/remind")==0){
-			url="pages/remind/index";
-		}
-		
-		window.location.href=window.location.href.split('#')[0]+"#/"+url
-	}else{
-		routerBeforeEach(to, from, next);
-	}
+
+	routerBeforeEach(to, from, next);
+	
 })
 
 uniCrazyRouter.afterEach((to, from) => {
@@ -63,52 +42,11 @@ const router = new Router()
 // 路由全局拦截器 在这里处理登录、授权等相关操作
 router.beforeEach(function(to, from, next) {
 	
-	console.log('前置守卫')
-	if (process.car.SIMPLE_RUN) {
-		if (!carhelp.getOpenId()) {
-			carhelp.setOpenId("test")
-		}
-		routerBeforeEach(to, from, next);
-	} else {
-		
-		if (!carhelp.getOpenId()) {
-			if (isWeiXin()) {
-				getOpenId();
-			}
-		} else {
-			
-			routerBeforeEach(to, from, next);
-		}
-
-	}
-
-
+	console.log('前置守卫')
+	routerBeforeEach(to, from, next);
 
 })
-
-function getOpenId() {
-	const code = getUrlParam('code');
-	
-	if (!code) {
-		var url = document.URL;
-		
-		window.location.href = getWeixinRedirectURI(process.car.VUE_APP_WXAPPID, url);
-	} else {
  
-		 
-		API_WeiXin.getDataByCode(code).then(response => {
-			
-			carhelp.setOpenId(response.data.openid)
-			//var linkUrl = document.URL.replace(/\?code=(.*?)&state=STATE/g, '');
-			//window.location = linkUrl; //隐藏参数
-			//return Promise.resolve(response.openid);
-		}).catch(error => {
-			console.log(error);
-		});
-
-	}
-
-}
 
 function routerBeforeEach(to, from, next) {
 	next();

+ 29 - 1
components/Common.vue

@@ -15,6 +15,7 @@
 
 <script>
 	import * as API from '@/apis/common.js'
+	import * as API_WeiXin from '@/apis/weixin.js'
 	
  	export default {
 		name:"Common",
@@ -49,7 +50,33 @@
 			
 		},methods:{
 			
+			getDataByOpenId() {
+				var openId=this.carhelp.getOpenId()
+				if (process.car.SIMPLE_RUN) {
+					//测试账号
+					openId="oHjCawigqi8SEAwutwkQ-VEgdp3k"
+				}
+				if(!openId){
+					return
+				}
+				var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
+				var _this=this
+				var token=this.carhelp.get("token_tdate");//每10分钟存储一次token
+				if(token&&token[0]==tdate){
+					return
+				}
+				
+				API_WeiXin.getDataByOpenId(openId).then(response => {
 			
+					var token = response ? response.data.token : '';
+					this.carhelp.setToken(token);
+					 
+					this.carhelp.set("token_tdate",[tdate]);
+					this.$emit("getToken")
+				}).catch(error => {
+					_this.alert(error)
+				})
+			},
 			islogin(){
 				if(this.login){
 					if (!this.carhelp.getPersonInfo()) {
@@ -127,7 +154,8 @@
 				})
 			}
 		},mounted(){
-				
+				console.log("common-mounted")
+				this.getDataByOpenId();
 		},destroyed(){
 			
 		}

+ 11 - 5
main.js

@@ -2,14 +2,17 @@ import Vue from 'vue'
 import App from './App'
 import MyCommon from '@/components/Common.vue'
 //import CarLoading from '@/components/Loading.vue'
+import  getOpenId from './utils/init.js'
+getOpenId.init()
 
 import  mixin from './utils/mixin.js'
+
 Vue.config.ignoredElements.push("wx-open-subscribe") ;
 Vue.prototype.carhelp=mixin
 
 import Vconsole from 'vconsole'
  //import './router' // 引入路由
- import router from './bobo-router'
+import router from './bobo-router'
 
 
 // main.js
@@ -25,17 +28,20 @@ const app = new Vue({
 })
 Vue.component('my-common',MyCommon)
 //Vue.component('car-loading',CarLoading)
-
-
-Vue.use(mixin)
+//Vue.use(mixin)
 Vue.mixin({ 
     onLoad( option){  
         if (option.test == 'test') {
         	let vConsole = new Vconsole()
         }
 		
-    } ,onReady(){
+    } ,methods:{
 	
+		gotoUrl(url){
+			uni.navigateTo({
+				url:url
+			})
+		}
 	}
 })
 

+ 1 - 1
manifest.json

@@ -70,7 +70,7 @@
     },
     "h5" : {
         "devServer" : {
-            "port" : 80,
+            "port" : 8080,
             "https" : false,
             "disableHostCheck" : true
         },

+ 3 - 3
pages.json

@@ -9,7 +9,7 @@
 			"path": "pages/index/index",
 			"style": {
 	
-				"navigationStyle": "custom" // 隐藏系统导航栏
+				//"navigationStyle": "custom" // 隐藏系统导航栏
 			}
 		}
 
@@ -470,6 +470,6 @@
 			"navigationBarTitleText": "荆开就业在线",
 			"enablePullDownRefresh": false
 			
-	}
-	 
+	}
+  
 }

+ 1 - 1
pages/index/index.js

@@ -14,7 +14,7 @@ export default {
 			//this.id=op.id;
 		},
 		methods: {
-			 
+			
 			
 		},onReady(){ 
 			

+ 6 - 11
pages/index/index.vue

@@ -1,20 +1,15 @@
 <template>
 	<view>
- 		
+		<my-common      mytitle="公共标题"  ref="common"></my-common>
+		
+ 		<u-button type="primary"  @click="gotoUrl('/pages/job/index/index')" >我要求职</u-button>
+ 		<u-button type="success" @click="gotoUrl('/pages/hr/index/index')" >企业招聘</u-button>
 	</view>
 </template>
 
 <script>
-	export default {
-		data() {
-			return {
-				
-			}
-		},
-		methods: {
-			
-		}
-	}
+	import api from './index.js'
+	export default api;
 </script>
 
 <style>

+ 60 - 0
utils/init.js

@@ -0,0 +1,60 @@
+import carhelp from '@/utils/mixin.js'
+import * as API_WeiXin from '@/apis/weixin.js'
+
+import {
+	getUrlParam,
+	getWeixinRedirectURI,
+	isWeiXin
+} from '@/utils'
+var checkOpenId = true; //是否需要获取openId
+var openId = carhelp.getOpenId();
+
+var app = {
+	init: function() {
+
+		if (isWeiXin()) {
+			if (checkOpenId) {
+				if (!openId) {
+					this.getOpenId();
+				} else {
+					//this.getDataByOpenId();
+				}
+			}
+		} else {
+			if (checkOpenId) {
+				/* mui.alert('请使用微信浏览打开!', '提示', function() {
+					//info.innerText = '你刚关闭了警告框';
+				}); */
+			}
+		}
+	},
+	getDataByOpenId() {
+
+		API_WeiXin.getDataByOpenId(openId).then(response => {
+			var token = response ? response.token : '';
+			carhelp.setToken(token);
+		}).catch(error => {
+			mui.toast(error);
+		})
+	},
+	getOpenId() {
+		const code = getUrlParam('code');
+		var openId = carhelp.getOpenId()
+		if (!openId) {
+			if (!code) {
+				var url = document.URL;
+				window.location.href = getWeixinRedirectURI(process.car.VUE_APP_WXAPPID, url);
+			} else {
+
+				API_WeiXin.getDataByCode(code).then(response => {
+					carhelp.setOpenId(response.data.openid)
+					openId = response.data.openid;
+					//this.getDataByOpenId()
+				}).catch(error => {
+					console.log(error);
+				});
+			}
+		}
+	}
+}
+module.exports = app

+ 2 - 2
utils/mixin.js

@@ -1,8 +1,8 @@
-var prefix = 'jp_car_' + process.car.NODE_ENV + '_';
+var prefix = 'jp_employment_' + process.car.NODE_ENV + '_';
 
 var app = {
 	
-	 getPrefix:()=> prefix,
+	getPrefix:()=> prefix,
 	get : key =>  uni.getStorageSync(prefix + key),
 
 	set : (key, value) => uni.setStorageSync(prefix + key, value),

+ 1 - 1
vue.config.js

@@ -24,7 +24,7 @@ module.exports = {
 	lintOnSave: false,
 	devServer: {
 		host: 'localhost',
-		port: 80,
+		port: 8080,
 		//解析缓存
 		disableHostCheck: true,
 		//支持gzip