Browse Source

微信登录

sunChengjie 11 months ago
parent
commit
d997befec4
6 changed files with 492 additions and 527 deletions
  1. 44 54
      src/App.vue
  2. 20 0
      src/api/login.js
  3. 1 15
      src/main.js
  4. 95 141
      src/pages/index.vue
  5. 188 166
      src/pages_bak/index.vue
  6. 144 151
      src/script/common.js

+ 44 - 54
src/App.vue

@@ -1,71 +1,61 @@
 <template>
-  <div id="app">
-    <router-view></router-view>
-  </div>
+    <div id="app">
+        <router-view></router-view>
+    </div>
 </template>
 
 <script>
 import { getWxConfig } from './api/index'
 import wx from "weixin-jsapi";
 export default {
-  name: 'App',
-  provide() { //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。                                             
-    return {
-      reload: this.reload
-    }
-  },
-  data() {
-    return {
-      isRouterAlive: true //控制视图是否显示的变量
-    }
-  },
-
-  async created() {
-    window.localStorage.setItem('scanUrl', location.href.split('#')[0])
-    // this.$http.post(this.$store.state.host + "/weixin/getWxConfig", {
-    // 	url: window.location.href.split('#')[0]
-    // }, {
-    // 	emulateJSON: true
-    // })
+    name: 'App',
+    provide() { //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。                                             
+        return {
+            reload: this.reload
+        }
+    },
+    data() {
+        return {
+            isRouterAlive: true //控制视图是否显示的变量
+        }
+    },
 
-    const res = await getWxConfig({ url: window.location.href.split('#')[0] })
+    async created() {
+        window.localStorage.setItem('scanUrl', location.href.split('#')[0])
+        const res = await getWxConfig({})
+        //发送成功
+        var timestamp = res.wxConfig.timestamp;
+        var noncestr = res.wxConfig.nonceStr;
+        var signature = res.wxConfig.signature;
+        var appId = res.wxConfig.appId;
+        wx.config({
+            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+            // debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+            appId: appId, // 必填,公众号的唯一标识
+            timestamp: timestamp, // 必填,生成签名的时间戳
+            nonceStr: noncestr, // 必填,生成签名的随机串
+            signature: signature, // 必填,签名,见附录1
+            jsApiList: [
+                "scanQRCode",
+            ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+        });
 
-    //发送成功
-    var timestamp = res.wxConfig.timestamp;
-    var noncestr = res.wxConfig.nonceStr;
-    var signature = res.wxConfig.signature;
-    var appId = res.wxConfig.appId;
-    wx.config({
-      debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-      // debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-      appId: appId, // 必填,公众号的唯一标识
-      timestamp: timestamp, // 必填,生成签名的时间戳
-      nonceStr: noncestr, // 必填,生成签名的随机串
-      signature: signature, // 必填,签名,见附录1
-      jsApiList: [
-        "scanQRCode",
-      ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
-    });
-    //  res => {
-    // 	//发送失败
-    // 	Toast("网络错误!")
-    // }
-  },
-  methods: {
-    reload() {
-      this.isRouterAlive = false; //先关闭,
-      this.$nextTick(function () {
-        this.isRouterAlive = true; //再打开
-      })
+    },
+    methods: {
+        reload() {
+            this.isRouterAlive = false; //先关闭,
+            this.$nextTick(function () {
+                this.isRouterAlive = true; //再打开
+            })
+        }
     }
-  }
 }
 </script>
 
 <style scoped>
 #app {
-  width: 100%;
-  max-width: 7.5rem;
-  margin: 0 auto;
+    width: 100%;
+    max-width: 7.5rem;
+    margin: 0 auto;
 }
 </style>

+ 20 - 0
src/api/login.js

@@ -0,0 +1,20 @@
+import request from '../utils/request';
+
+export function getWxUserInfo(data, config) {
+    return request({
+        url: '/tianzong/weixin/getWxUserInfo',
+        method: 'post',
+        data: data,
+        ...config
+    })
+}
+
+// 获取appid
+export function getWxConfig(data, config) {
+    return request({
+        url: '/tianzong/weixin/getWxConfig',
+        method: 'post',
+        data: data,
+        ...config
+    })
+}

+ 1 - 15
src/main.js

@@ -53,21 +53,7 @@ Vue.filter('dateFormat', (dataStr) => {
   return y + '-' + timeAdd0(m) + '-' + timeAdd0(d) + ' ' + timeAdd0(h) + ':' + timeAdd0(mm) + ':' + timeAdd0(s)
 })
 
-// 微信登录校验
-// wx.login({
-//   success(res) {
-//     if (res.code) {
-//       wx.request({
-//         url: '',
-//         data: {
-//           code: res.code
-//         }
-//       })
-//     } else {
-//       console.log('登录失败' + res.errMsg)
-//     }
-//   }
-// })
+
 
 //Vue.prototype.common=common
 // Vue.http.options.emulateJSON = true;

+ 95 - 141
src/pages/index.vue

@@ -1,148 +1,83 @@
 <template>
-  <div class="content">
-    <!-- banner图 -->
-    <banner></banner>
-	<!-- 寄件按钮 -->
-	<div class="btn-two">
-		<router-link to="/Express">
-			<img src="../assets/images/icon4.png" alt="">
-			<span>
-				<p>寄快递</p>
-				<!-- <p>放心寄 丢必赔</p> -->
-			</span>
-		</router-link>
-		<router-link to="Inexpress">
-			<img src="../assets/images/icon5.png" alt="">
-			<span>
-				<p>内部件</p>
-				<!-- <p>让工作 更便捷</p> -->
-			</span>
-		</router-link>
-		<router-link to="Logisticslist">
-			<img src="../assets/images/icon22.png" alt="">
-			<span>
-				<p>我的寄件</p>
-				<!-- <p>让工作 更便捷</p> -->
-			</span>
-		</router-link>
-			<router-link to="Search">
-			<img src="../assets/images/a-124.png" alt="">
-			<span>
-				<p>我的收件</p>
-				<!-- <p>让工作 更便捷</p> -->
-			</span>
-		</router-link>
-	</div>
-	<!-- 同城急送 -->
-	<!-- <div class="btn-four">
-		<div>
-			<router-link to="/Cityexpress">
-				<img src="../assets/images/icon6.png" alt="">
+	<div class="content">
+		<!-- banner图 -->
+		<banner></banner>
+		<!-- 寄件按钮 -->
+		<div class="btn-two">
+			<router-link to="/Express">
+				<img src="../assets/images/icon4.png" alt="">
 				<span>
-					<p>同城急送</p>
-					<p>闪送更快更安全</p>
+					<p>寄快递</p>
+					<!-- <p>放心寄 丢必赔</p> -->
 				</span>
 			</router-link>
-		</div>
-		<div>
-			<router-link to="/Multipleexpress">
-				<img src="../assets/images/icon7.png" alt="">
+			<router-link to="Inexpress">
+				<img src="../assets/images/icon5.png" alt="">
 				<span>
-					<p>批量寄</p>
-					<p>便捷寄多个快递</p>
+					<p>内部件</p>
+					<!-- <p>让工作 更便捷</p> -->
 				</span>
 			</router-link>
-		</div>
-		<div>
-			<router-link to="/Foreignexpress">
-				<img src="../assets/images/icon8.png" alt="">
+			<router-link to="Logisticslist">
+				<img src="../assets/images/icon22.png" alt="">
 				<span>
-					<p>国际件</p>
-					<p>放心寄 丢必赔</p>
+					<p>我的寄件</p>
+					<!-- <p>让工作 更便捷</p> -->
 				</span>
 			</router-link>
-		</div>
-		<div>
-			<router-link to="/Hkexpress">
-				<img src="../assets/images/icon9.png" alt="">
+			<router-link to="Search">
+				<img src="../assets/images/a-124.png" alt="">
 				<span>
-					<p>港澳台</p>
-					<p>让工作 更快捷</p>
+					<p>我的收件</p>
+					<!-- <p>让工作 更便捷</p> -->
 				</span>
 			</router-link>
 		</div>
-	</div> -->
-    <!--  -->
-	<!-- <div class="ad-two">
-		<router-link :to="{ path: 'Myaddressbook', query: { active: 1 }}">
-			<img src="../assets/images/ad_icon1.png" alt="">
-			<span>地址簿</span>
-		</router-link>
-		<router-link to="" @click.native="link()">
-			<img src="../assets/images/ad_icon2.png" alt="">
-			<span>寄包柜</span>
-		</router-link>
-
-		<router-link to="/Xz">
-			<img src="../assets/images/ad_icon4.png" alt="">
-			<span>禁寄品</span>
-		</router-link>
-	</div> -->
-	<!-- 底部icon -->
-	<!-- <div class="foot_icon">
-		<div>
-			<img src="../assets/images/foot_icon1.png" >
-			<p>放心寄 丢必赔</p>
-		</div>
-		<div>
-			<img src="../assets/images/foot_icon2.png" >
-			<p>闪电送件</p>
-		</div>
-		<div>
-			<img src="../assets/images/foot_icon3.png" >
-			<p>专属客服</p>
-		</div>
-	</div> -->
-	<!-- 底部 -->
-    <tabbar></tabbar>
+		<tabbar></tabbar>
 
-  </div>
+	</div>
 </template>
 <script>
-  import {Toast,Dialog} from 'vant'
-  // import tabber from "./components/tabbar"
-  export default {
-    data() {
-      return {
+import { Toast, Dialog } from 'vant'
+import { getWxUserInfo } from '../api/login'
+export default {
+	data() {
+		return {
+
+
+		};
+	},
+	created: async function () {
+		this.getOpenid("index.html");
+		const code = getUrlParam('code');
+		if (code) {
+			const res = await getWxUserInfo({ code: code, userId: localStorage.getItem("userId") })
+			console.log(res, '==========res')
+		}
 
 
-      };
-    },
-    created:function(){
-      //本地(服务器下面这个要去了)
-      //localStorage.setItem("openid", "123");
-      //this.getOpenid("");
-	  this.isLogin();
-    },
-    methods:{
-      link(){
-        Toast("正在开发中,敬请期待!")
-      }
-    }
-  };
+	},
+	methods: {
+		link() {
+			Toast("正在开发中,敬请期待!")
+		}
+	}
+};
 </script>
 
 <style lang="less" scoped>
-.content{
+.content {
 	padding: .33rem .34rem 1rem;
-	.btn-two{
+
+	.btn-two {
 		font-size: .24rem;
 		color: #999999;
 		display: flex;
 		flex-wrap: wrap;
-		margin:.2rem auto;
+		margin: .2rem auto;
 		height: 300px;
-		a{
+
+		a {
 			display: flex;
 			flex-direction: column;
 			align-items: center;
@@ -150,56 +85,64 @@
 			color: #999999;
 			padding: .25rem 0rem;
 			background: white;
-			width:50%;
+			width: 50%;
 			border-radius: .05rem;
 			justify-content: center;
-			img{
+
+			img {
 				width: 1.2rem;
 				height: 1.2rem;
 				position: relative;
 				top: .1rem;
 				margin-bottom: 10px;
 			}
-			span{
-				p:nth-of-type(1){
+
+			span {
+				p:nth-of-type(1) {
 					font-size: .3rem;
-					color:#333;
+					color: #333;
 					font-weight: bold;
 					margin-bottom: .1rem;
 				}
 			}
 		}
 	}
-	.btn-four{
+
+	.btn-four {
 		font-size: .24rem;
 		color: #999999;
 		display: flex;
 		flex-wrap: wrap;
 		justify-content: space-between;
-		margin:.2rem auto;
+		margin: .2rem auto;
 		background: white;
 		padding: .25rem .2rem;
 		border-radius: .05rem;
-		div{
+
+		div {
 			flex: 1;
 			min-width: 48%;
 			padding: .2rem 0rem;
-			a{
+
+			a {
 				display: flex;
 				color: #999999;
 				justify-content: center;
 				padding: .1rem 0rem;
-				img{
+
+				img {
 					width: .52rem;
 					height: .5rem;
 					position: relative;
 					top: .2rem;
 				}
-				span{
+
+				span {
 					margin-left: .25rem;
-					p:nth-of-type(1){
+
+					p:nth-of-type(1) {
 						font-size: .3rem;
-						color:#333;
+						color: #333;
 						font-weight: bold;
 						margin-bottom: .1rem;
 					}
@@ -207,49 +150,60 @@
 			}
 
 		}
-		div:nth-of-type(1) a,div:nth-of-type(3) a{
+
+		div:nth-of-type(1) a,
+		div:nth-of-type(3) a {
 			border-right: .01rem solid #f7f7f7;
 		}
-		div:nth-of-type(1),div:nth-of-type(2){
+
+		div:nth-of-type(1),
+		div:nth-of-type(2) {
 			border-bottom: .01rem solid #f7f7f7;
 		}
 
 	}
-	.ad-two{
+
+	.ad-two {
 		font-size: .24rem;
 		color: #999999;
 		display: flex;
 		justify-content: center;
-		margin:.2rem auto;
-		a{
+		margin: .2rem auto;
+
+		a {
 			flex: 1;
 			color: #999999;
 			padding: .35rem 0rem;
 			background: white;
-			width:48%;
+			width: 48%;
 			border-radius: .05rem;
 			text-align: center;
-			img{
+
+			img {
 				width: .55rem;
 				height: .55rem;
 				margin-bottom: .1rem;
 			}
-			span{
+
+			span {
 				display: block;
 
 			}
 		}
 	}
-	.foot_icon{
+
+	.foot_icon {
 		display: flex;
 		justify-content: center;
 		margin: .55rem auto;
-		div{
+
+		div {
 			flex: 1;
 			text-align: center;
 			font-size: .2rem;
 			color: #999999;
-			img{
+
+			img {
 				width: .64rem;
 				height: .64rem;
 			}

+ 188 - 166
src/pages_bak/index.vue

@@ -1,270 +1,292 @@
 <template>
-  <div class="content">
-    <!-- banner图 -->
-    <banner></banner>
-	<!-- 寄件按钮 -->
-	<div class="btn-two">
-		<router-link to="/Express">
-			<img src="../assets/images/icon4.png" alt="">
-			<span>
-				<p>寄快递</p>
-				<p>放心寄 丢必赔</p>
-			</span>
-		</router-link>
-		<router-link to="Inexpress">
-			<img src="../assets/images/icon5.png" alt="">
-			<span>
-				<p>内部件</p>
-				<p>让工作 更便捷</p>
-			</span>
-		</router-link>
-	</div>
-	<!-- 同城急送 -->
-	<div class="btn-four">
-		<div>
-			<router-link to="/Cityexpress">
-				<img src="../assets/images/icon6.png" alt="">
+	<div class="content">
+		<!-- banner图 -->
+		<banner></banner>
+		<!-- 寄件按钮 -->
+		<div class="btn-two">
+			<router-link to="/Express">
+				<img src="../assets/images/icon4.png" alt="">
 				<span>
-					<p>同城急送</p>
-					<p>闪送更快更安全</p>
+					<p>寄快递</p>
+					<p>放心寄 丢必赔</p>
 				</span>
 			</router-link>
-		</div>
-		<div>
-			<router-link to="/Multipleexpress">
-				<img src="../assets/images/icon7.png" alt="">
+			<router-link to="Inexpress">
+				<img src="../assets/images/icon5.png" alt="">
 				<span>
-					<p>批量寄</p>
-					<p>便捷寄多个快递</p>
+					<p>内部件</p>
+					<p>让工作 更便捷</p>
 				</span>
 			</router-link>
 		</div>
-		<div>
+		<!-- 同城急送 -->
+		<div class="btn-four">
+			<div>
+				<router-link to="/Cityexpress">
+					<img src="../assets/images/icon6.png" alt="">
+					<span>
+						<p>同城急送</p>
+						<p>闪送更快更安全</p>
+					</span>
+				</router-link>
+			</div>
+			<div>
+				<router-link to="/Multipleexpress">
+					<img src="../assets/images/icon7.png" alt="">
+					<span>
+						<p>批量寄</p>
+						<p>便捷寄多个快递</p>
+					</span>
+				</router-link>
+			</div>
+			<div>
+				<router-link to="">
+					<img src="../assets/images/icon8.png" alt="">
+					<span>
+						<p>国际件</p>
+						<p>放心寄 丢必赔</p>
+					</span>
+				</router-link>
+			</div>
+			<div>
+				<router-link to="">
+					<img src="../assets/images/icon9.png" alt="">
+					<span>
+						<p>港澳台</p>
+						<p>让工作 更快捷</p>
+					</span>
+				</router-link>
+			</div>
+
+
+
+		</div>
+		<!--  -->
+		<div class="ad-two">
 			<router-link to="">
-				<img src="../assets/images/icon8.png" alt="">
-				<span>
-					<p>国际件</p>
-					<p>放心寄 丢必赔</p>
-				</span>
+				<img src="../assets/images/ad_icon1.png" alt="">
+				<span>地址簿</span>
 			</router-link>
-		</div>
-		<div>
 			<router-link to="">
-				<img src="../assets/images/icon9.png" alt="">
-				<span>
-					<p>港澳台</p>
-					<p>让工作 更快捷</p>
-				</span>
+				<img src="../assets/images/ad_icon2.png" alt="">
+				<span>寄包柜</span>
+			</router-link>
+			<router-link to="">
+				<img src="../assets/images/ad_icon3.png" alt="">
+				<span>运费时效</span>
+			</router-link>
+			<router-link to="">
+				<img src="../assets/images/ad_icon4.png" alt="">
+				<span>寄禁品</span>
 			</router-link>
 		</div>
-		
-		
-		
-	</div>
-    <!--  -->
-	<div class="ad-two">
-		<router-link to="">
-			<img src="../assets/images/ad_icon1.png" alt="">
-			<span>地址簿</span>
-		</router-link>
-		<router-link to="">
-			<img src="../assets/images/ad_icon2.png" alt="">
-			<span>寄包柜</span>
-		</router-link>
-		<router-link to="">
-			<img src="../assets/images/ad_icon3.png" alt="">
-			<span>运费时效</span>
-		</router-link>
-		<router-link to="">
-			<img src="../assets/images/ad_icon4.png" alt="">
-			<span>寄禁品</span>
-		</router-link>
-	</div>
-	<!-- 底部icon -->
-	<div class="foot_icon">
-		<div>
-			<img src="../assets/images/foot_icon1.png" >
-			<p>放心寄 丢必赔</p>
-		</div>
-		<div>
-			<img src="../assets/images/foot_icon2.png" >
-			<p>闪电送件</p>
-		</div>
-		<div>
-			<img src="../assets/images/foot_icon3.png" >
-			<p>专属客服</p>
+		<!-- 底部icon -->
+		<div class="foot_icon">
+			<div>
+				<img src="../assets/images/foot_icon1.png">
+				<p>放心寄 丢必赔</p>
+			</div>
+			<div>
+				<img src="../assets/images/foot_icon2.png">
+				<p>闪电送件</p>
+			</div>
+			<div>
+				<img src="../assets/images/foot_icon3.png">
+				<p>专属客服</p>
+			</div>
 		</div>
-	</div>
-	<!-- 底部 -->
-    <tabbar></tabbar>
+		<!-- 底部 -->
+		<tabbar></tabbar>
 
-  </div>
+	</div>
 </template>
 <script>
-  import {Toast,Dialog} from 'vant'
-  // import tabber from "./components/tabbar"
-  export default {
-    data() {
-      return {
-        
-        
-      };
-    },
-    created:function(){
-      localStorage.setItem("openid","123456")
-      this.$store.state.openId=localStorage.getItem("openid")
-      //this.common.getOpenid("index.html")
-      //this.getOpenid("index.html")
-    },
-    methods:{
-      // 获取业务
-      getywlist(){
-        this.$http.post(this.$store.state.host+"/interface/yewuList",{},{emulateJSON:true})
-        .then(res=>{
-          //发送成功
-          console.log(res)
-          if(res.body.code==0){
-            this.ywlist=res.body.list
-          }
-
-          //if()
-        },res=>{
-           //发送失败
-        })
-      },
-      // 业务跳转
-      link(obj,type,title){
-        if(this.SMstatus!=1){
-          Dialog.alert({
-            message: '您尚未实名认证,暂不能使用本功能,请前往个人中心进行实名认证',
-          }).then(() => {
-            this.$router.push("/Realinfo")
-          });
-        }
-        else{
-            this.$router.push({path:'/Ywlist',query:{ywId:obj,type:type,title:title}})
-        }
-
-      },
-     
-		}
-  };
+import { Toast, Dialog } from 'vant'
+// import tabber from "./components/tabbar"
+export default {
+	data() {
+		return {
+
+
+		};
+	},
+	created: function () {
+		//   localStorage.setItem("openid","123456")
+		this.$store.state.openId = localStorage.getItem("openid")
+		//this.common.getOpenid("index.html")
+		//this.getOpenid("index.html")
+	},
+	methods: {
+		// 获取业务
+		getywlist() {
+			this.$http.post(this.$store.state.host + "/interface/yewuList", {}, { emulateJSON: true })
+				.then(res => {
+					//发送成功
+					console.log(res)
+					if (res.body.code == 0) {
+						this.ywlist = res.body.list
+					}
+
+					//if()
+				}, res => {
+					//发送失败
+				})
+		},
+		// 业务跳转
+		link(obj, type, title) {
+			if (this.SMstatus != 1) {
+				Dialog.alert({
+					message: '您尚未实名认证,暂不能使用本功能,请前往个人中心进行实名认证',
+				}).then(() => {
+					this.$router.push("/Realinfo")
+				});
+			}
+			else {
+				this.$router.push({ path: '/Ywlist', query: { ywId: obj, type: type, title: title } })
+			}
+
+		},
+
+	}
+};
 </script>
 
 <style lang="less" scoped>
-.content{
+.content {
 	padding: 0rem .34rem;
-	.btn-two{
+
+	.btn-two {
 		font-size: .24rem;
 		color: #999999;
 		display: flex;
 		justify-content: space-between;
-		margin:.2rem auto;
-		a{
+		margin: .2rem auto;
+
+		a {
 			display: flex;
 			color: #999999;
 			padding: .25rem 0rem;
 			background: white;
-			width:48%;
+			width: 48%;
 			border-radius: .05rem;
 			justify-content: center;
-			img{
+
+			img {
 				width: .67rem;
 				height: .68rem;
 				position: relative;
 				top: .1rem;
 			}
-			span{
+
+			span {
 				margin-left: .25rem;
-				p:nth-of-type(1){
+
+				p:nth-of-type(1) {
 					font-size: .3rem;
-					color:#333;
+					color: #333;
 					font-weight: bold;
 					margin-bottom: .1rem;
 				}
 			}
 		}
 	}
-	.btn-four{
+
+	.btn-four {
 		font-size: .24rem;
 		color: #999999;
 		display: flex;
 		flex-wrap: wrap;
 		justify-content: space-between;
-		margin:.2rem auto;
+		margin: .2rem auto;
 		background: white;
 		padding: .25rem .2rem;
 		border-radius: .05rem;
-		div{
+
+		div {
 			flex: 1;
 			min-width: 48%;
 			padding: .2rem 0rem;
-			a{
-				display: flex;				
+
+			a {
+				display: flex;
 				color: #999999;
 				justify-content: center;
 				padding: .1rem 0rem;
-				img{
+
+				img {
 					width: .52rem;
 					height: .5rem;
 					position: relative;
 					top: .2rem;
 				}
-				span{
+
+				span {
 					margin-left: .25rem;
-					p:nth-of-type(1){
+
+					p:nth-of-type(1) {
 						font-size: .3rem;
-						color:#333;
+						color: #333;
 						font-weight: bold;
 						margin-bottom: .1rem;
 					}
 				}
 			}
-			
+
 		}
-		div:nth-of-type(1) a,div:nth-of-type(3) a{
+
+		div:nth-of-type(1) a,
+		div:nth-of-type(3) a {
 			border-right: .01rem solid #f7f7f7;
 		}
-		div:nth-of-type(1),div:nth-of-type(2){
+
+		div:nth-of-type(1),
+		div:nth-of-type(2) {
 			border-bottom: .01rem solid #f7f7f7;
 		}
-		
+
 	}
-	.ad-two{
+
+	.ad-two {
 		font-size: .24rem;
 		color: #999999;
 		display: flex;
 		justify-content: center;
-		margin:.2rem auto;
-		a{
+		margin: .2rem auto;
+
+		a {
 			flex: 1;
 			color: #999999;
 			padding: .35rem 0rem;
 			background: white;
-			width:48%;
+			width: 48%;
 			border-radius: .05rem;
 			text-align: center;
-			img{
+
+			img {
 				width: .55rem;
 				height: .55rem;
 				margin-bottom: .1rem;
 			}
-			span{
+
+			span {
 				display: block;
-				
+
 			}
 		}
 	}
-	.foot_icon{
+
+	.foot_icon {
 		display: flex;
 		justify-content: center;
 		margin: .55rem auto;
-		div{
+
+		div {
 			flex: 1;
 			text-align: center;
 			font-size: .2rem;
 			color: #999999;
-			img{
+
+			img {
 				width: .64rem;
 				height: .64rem;
 			}

+ 144 - 151
src/script/common.js

@@ -1,167 +1,160 @@
+import { getWxUserInfo, getWxConfig } from '../api/login'
+
 export default {
-  install(Vue){
-    Vue.prototype.getOpenid = function(page) {
-        //var host='http://www.kzmos.com/tianzong';
-        var host='http://47.101.145.23/tianzong';
-        if (localStorage.getItem("openid") != 'undefined' && localStorage.getItem("openid") != null)
-          return;
-        var code = this.getUrlParam("code");
-        if (code == 'undefined' || code == null || code == "") {
-          //alert("参数异常,请返回首页重试");
-          this.urlredirect(page);
-          return;
-        }
-        this.$http.post(host + "/weixin/getWxUserInfo", {
-            code: code,
-			userId:localStorage.getItem("userId")
-          }, {
-            emulateJSON: true
-          })
-          .then(res => {
-            //发送成功
-			console.log(res);
+	install(Vue) {
+		Vue.prototype.getOpenid = async function (page) {
+			if (localStorage.getItem("openid") != 'undefined' && localStorage.getItem("openid") != null) {
+				return;
+			}
+			var code = this.getUrlParam("code");
+			console.log(code, 'code====++++')
+			if (code == 'undefined' || code == null || code == "") {
+				// alert("参数异常,请返回首页重试");
+				this.urlredirect(page);
+				return;
+			}
 
-            if (res.body.code == '0') {
-              localStorage.setItem("openid", res.body.openId);
-              localStorage.setItem("headimgurl", res.body.headimgurl);
-              //this.$store.commit("getId",res.body.data)
-            } else {
-              //console.log(res);
-              this.urlredirect(page);
-            }
+			const res = await getWxUserInfo({ code: code, userId: localStorage.getItem("userId") })
+			console.log(res, '================================')
+			if (res.body.code == '0') {
+				console.log('直接走+======', res)
+				localStorage.setItem("openid", res.body.openId);
+				localStorage.setItem("headimgurl", res.body.headimgurl);
+			} else {
+				this.urlredirect(page);
+			}
+		}
 
-            //if()
-          }, res => {
-            //发送失败
-          })
 
-      }
+		Vue.prototype.urlredirect = async function (page) {
+			const res = await getWxConfig({})
+			const href = window.location.href
+			window.location.href =
+				`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res.wxConfig.appId}&redirect_uri=${encodeURIComponent(href)}` + `&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect`;
+		}
 
-      Vue.prototype.urlredirect=function(page) {
-        var host='http://47.101.145.23/wuliu';
-        window.location.href =
-          "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx3d3b98cc26425f40&redirect_uri=" + host + page + "&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect";
-      }
-      Vue.prototype.getUrlParam=function(name) {
-        var vars = [],
-          hash;
-        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
-        for (var i = 0; i < hashes.length; i++) {
-          hash = hashes[i].split('=');
-          vars.push(hash[0]);
-          vars[hash[0]] = hash[1];
-        }
-        return decodeURIComponent(vars[name]);
-      }
-			Vue.prototype.getUser=function(){
-				this.$http.post(this.$store.state.host+"/personal/getPersonalInfoByUserId.do",{userId:this.userId},{emulateJSON:true})
-					.then(res=>{
-							//发送成功
-							if(res.body.msg=='success'){
-								this.user=res.body.personalInfo;
-							}
-				},res=>{
-							 //发送失败
-				})
+		Vue.prototype.getUrlParam = function (name) {
+			var vars = [],
+				hash;
+			var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
+			for (var i = 0; i < hashes.length; i++) {
+				hash = hashes[i].split('=');
+				vars.push(hash[0]);
+				vars[hash[0]] = hash[1];
 			}
-			//代收人列表
-			Vue.prototype.findCollectAgentList=function(){
-				this.$http.post(this.$store.state.host+"/sendMail/findCollectAgentList.do",{},{emulateJSON:true})
-					.then(res=>{
-						//发送成功
-						if(res.body.msg=='success'){
-							this.dsList = res.body.list
-								for(var i=0;i<this.dsList.length;i++){
-									this.dsList[i].text = this.dsList[i].name+' '+this.dsList[i].phone + ' '+this.dsList[i].department
-								}
-						}
-				},res=>{
-						 //发送失败
+			return decodeURIComponent(vars[name]);
+		}
+
+
+		Vue.prototype.getUser = function () {
+			this.$http.post(this.$store.state.host + "/personal/getPersonalInfoByUserId.do", { userId: this.userId }, { emulateJSON: true })
+				.then(res => {
+					//发送成功
+					if (res.body.msg == 'success') {
+						this.user = res.body.personalInfo;
+					}
+				}, res => {
+					//发送失败
 				})
-			}
-			//获取对应人的地址
-			Vue.prototype.getPersonalAddressById=function(id){
-				this.$http.post(this.$store.state.host+"/personal/getPersonalAddress.do",{userId:id},{emulateJSON:true})
-					.then(res=>{
-						//发送成功
-						if(res.body.msg=='success'){
-							this.address = res.body.address
+		}
+		//代收人列表
+		Vue.prototype.findCollectAgentList = function () {
+			this.$http.post(this.$store.state.host + "/sendMail/findCollectAgentList.do", {}, { emulateJSON: true })
+				.then(res => {
+					//发送成功
+					if (res.body.msg == 'success') {
+						this.dsList = res.body.list
+						for (var i = 0; i < this.dsList.length; i++) {
+							this.dsList[i].text = this.dsList[i].name + ' ' + this.dsList[i].phone + ' ' + this.dsList[i].department
 						}
-				},res=>{
-						 //发送失败
+					}
+				}, res => {
+					//发送失败
 				})
-			}
-			//代收人列表
-			Vue.prototype.getLogisticsList=function(){
-				this.$http.post(this.$store.state.host+"/sendMail/getLogisticsList.do",{},{emulateJSON:true})
-					.then(res=>{
-						//发送成功
-						if(res.body.msg=='success'){
-							this.columns = res.body.list
+		}
+		//获取对应人的地址
+		Vue.prototype.getPersonalAddressById = function (id) {
+			this.$http.post(this.$store.state.host + "/personal/getPersonalAddress.do", { userId: id }, { emulateJSON: true })
+				.then(res => {
+					//发送成功
+					if (res.body.msg == 'success') {
+						this.address = res.body.address
+					}
+				}, res => {
+					//发送失败
+				})
+		}
+		//代收人列表
+		Vue.prototype.getLogisticsList = function () {
+			this.$http.post(this.$store.state.host + "/sendMail/getLogisticsList.do", {}, { emulateJSON: true })
+				.then(res => {
+					//发送成功
+					if (res.body.msg == 'success') {
+						this.columns = res.body.list
 
-								for(var i=0;i<this.columns.length;i++){
-									if(this.columns[i].companyFlag == '' ||this.columns[i].companyFlag == undefined){
-										this.columns[i].text = this.columns[i].expressCompany
-									}else{
-										this.columns[i].text = this.columns[i].expressCompany+'('+this.columns[i].companyFlag+')'
-									}
-								}
-								//默认顺丰快递
-								this.expressInfoShow=this.columns[0].text
-								this.expressInfo=this.columns[0].id
-								this.expressPhone=this.columns[0].phone
+						for (var i = 0; i < this.columns.length; i++) {
+							if (this.columns[i].companyFlag == '' || this.columns[i].companyFlag == undefined) {
+								this.columns[i].text = this.columns[i].expressCompany
+							} else {
+								this.columns[i].text = this.columns[i].expressCompany + '(' + this.columns[i].companyFlag + ')'
+							}
 						}
-				},res=>{
-						 //发送失败
+						//默认顺丰快递
+						this.expressInfoShow = this.columns[0].text
+						this.expressInfo = this.columns[0].id
+						this.expressPhone = this.columns[0].phone
+					}
+				}, res => {
+					//发送失败
 				})
-			}
-
-      //成本中心列表
-      Vue.prototype.getCostCenterList=function(){
-      	this.$http.post(this.$store.state.host+"/sendMail/getCostCenterList.do",{mailRoomId:this.mailRoomId},{emulateJSON:true})
-      		.then(res=>{
-      			//发送成功
-      			if(res.body.msg=='success'){
-      				this.costCenterList = res.body.list
-              for(var i=0;i<this.costCenterList.length;i++){
-                this.costCenterList[i].text = this.costCenterList[i].costCenterName
-              }
-              this.costCenterInfoShow=this.costCenterList[0].text
-              this.costCenterName=this.costCenterList[0].costCenterName
-              this.costCenterId=this.costCenterList[0].id
-      			}
-      	},res=>{
-      			 //发送失败
-      	})
-      }
+		}
 
-			//代收人列表
-			Vue.prototype.getDefaultAddress=function(){
-				this.$http.post(this.$store.state.host+"/solic/getDefaultAddress.do",{
-					userId:localStorage.getItem("userId"),
-					mailRoomId:localStorage.getItem("roomId")
-				},{emulateJSON:true})
-					.then(res=>{
-						//发送成功
-						if(res.body.msg=='success'){
-							this.jjname=res.body.personalInfo.name+' '+res.body.personalInfo.phone
-							this.jjadd=res.body.mailRoomInfo.province+" "+res.body.mailRoomInfo.city+" "+res.body.mailRoomInfo.area+' '+res.body.mailRoomInfo.address
-							this.jjInfo.jjname = this.jjname
-							this.jjInfo.jjadd = this.jjadd
-							this.jjInfo.senderMobile = res.body.personalInfo.telephone
-							this.jjInfo.sender = res.body.personalInfo.name
-							this.jjInfo.senderPhone = res.body.personalInfo.phone
-							this.jjInfo.sendAddr = res.body.mailRoomInfo.province+" "+res.body.mailRoomInfo.city+" "+res.body.mailRoomInfo.area
-							this.jjInfo.sendAddress = res.body.mailRoomInfo.address
-							this.$store.commit("getJjInfo",this.jjInfo)
+		//成本中心列表
+		Vue.prototype.getCostCenterList = function () {
+			this.$http.post(this.$store.state.host + "/sendMail/getCostCenterList.do", { mailRoomId: this.mailRoomId }, { emulateJSON: true })
+				.then(res => {
+					//发送成功
+					if (res.body.msg == 'success') {
+						this.costCenterList = res.body.list
+						for (var i = 0; i < this.costCenterList.length; i++) {
+							this.costCenterList[i].text = this.costCenterList[i].costCenterName
 						}
-				},res=>{
-						 //发送失败
+						this.costCenterInfoShow = this.costCenterList[0].text
+						this.costCenterName = this.costCenterList[0].costCenterName
+						this.costCenterId = this.costCenterList[0].id
+					}
+				}, res => {
+					//发送失败
 				})
-			}
+		}
+
+		//代收人列表
+		Vue.prototype.getDefaultAddress = function () {
+			this.$http.post(this.$store.state.host + "/solic/getDefaultAddress.do", {
+				userId: localStorage.getItem("userId"),
+				mailRoomId: localStorage.getItem("roomId")
+			}, { emulateJSON: true })
+				.then(res => {
+					//发送成功
+					if (res.body.msg == 'success') {
+						this.jjname = res.body.personalInfo.name + ' ' + res.body.personalInfo.phone
+						this.jjadd = res.body.mailRoomInfo.province + " " + res.body.mailRoomInfo.city + " " + res.body.mailRoomInfo.area + ' ' + res.body.mailRoomInfo.address
+						this.jjInfo.jjname = this.jjname
+						this.jjInfo.jjadd = this.jjadd
+						this.jjInfo.senderMobile = res.body.personalInfo.telephone
+						this.jjInfo.sender = res.body.personalInfo.name
+						this.jjInfo.senderPhone = res.body.personalInfo.phone
+						this.jjInfo.sendAddr = res.body.mailRoomInfo.province + " " + res.body.mailRoomInfo.city + " " + res.body.mailRoomInfo.area
+						this.jjInfo.sendAddress = res.body.mailRoomInfo.address
+						this.$store.commit("getJjInfo", this.jjInfo)
+					}
+				}, res => {
+					//发送失败
+				})
+		}
 
-			//登录判断
-			Vue.prototype.isLogin=function(){
+		//登录判断
+		Vue.prototype.isLogin = function () {
 			// 	this.$http.post(this.$store.state.host+"/appSysUser/isLogin.do",{
 			// 	},{emulateJSON:true})
 			// 		.then(res=>{
@@ -170,14 +163,14 @@ export default {
 			// 			if(res.body.msg=='success'){
 
 			// 			}else{
-            //   //本地(服务器下面这个要放开)
+			//   //本地(服务器下面这个要放开)
 			// 				localStorage.clear();
 			// 			}
 			// 	},res=>{
 			// 			 //发送失败
 			// 	})
-			}
-  }
+		}
+	}
 
 
 }