|
@@ -1,9 +1,52 @@
|
|
-<script>
|
|
|
|
- import Vue from 'vue';
|
|
|
|
|
|
+<script>
|
|
|
|
+ import Vue from 'vue';
|
|
|
|
+// 判断微信环境
|
|
|
|
+function isWeixin() {
|
|
|
|
+ var ua = navigator.userAgent.toLowerCase();
|
|
|
|
+ if (ua.indexOf('micromessenger') != -1) {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
|
|
+// 解析地址栏参数
|
|
|
|
+function getQueryVariable(variable) {
|
|
|
|
+ // 从?开始获取后面的所有数据
|
|
|
|
+ var query = window.location.search.substring(1);
|
|
|
|
+ // 从字符串&开始分隔成数组split
|
|
|
|
+ var vars = query.split('&');
|
|
|
|
+ // 遍历该数组
|
|
|
|
+ for (var i = 0; i < vars.length; i++) {
|
|
|
|
+ // 从等号部分分割成字符
|
|
|
|
+ var pair = vars[i].split('=');
|
|
|
|
+ // 如果第一个元素等于 传进来的参的话 就输出第二个元素
|
|
|
|
+ if (pair[0] == variable) {
|
|
|
|
+ return pair[1];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return undefined;
|
|
|
|
+}
|
|
export default {
|
|
export default {
|
|
onLaunch: function() {
|
|
onLaunch: function() {
|
|
- // console.log('App Launch')
|
|
|
|
|
|
+ if(isWeixin()){
|
|
|
|
+ // 微信鉴权登入
|
|
|
|
+ var isAuthorization = getQueryVariable('isAuthorization');
|
|
|
|
+ if (isAuthorization) {
|
|
|
|
+ var url = 'https://jiasm.zfire.top/recycleh5';
|
|
|
|
+ const href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd935838591c00e16&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo#wechat_redirect`;
|
|
|
|
+ window.location.href = href;
|
|
|
|
+ } else {
|
|
|
|
+ var code = getQueryVariable('code');
|
|
|
|
+ if (code) {
|
|
|
|
+ uni.setStorageSync('code', code);
|
|
|
|
+ } else if (!uni.getStorageSync('code')) {
|
|
|
|
+ const url = location.href;
|
|
|
|
+ const href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd935838591c00e16&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo#wechat_redirect`;
|
|
|
|
+ window.location.href = href;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
onShow: function() {
|
|
onShow: function() {
|
|
// console.log('App Show')
|
|
// console.log('App Show')
|
|
@@ -16,7 +59,7 @@
|
|
|
|
|
|
<style lang="scss">
|
|
<style lang="scss">
|
|
/*每个页面公共css */
|
|
/*每个页面公共css */
|
|
- @import "uview-ui/index.scss";
|
|
|
|
-
|
|
|
|
|
|
+ @import "uview-ui/index.scss";
|
|
|
|
+
|
|
@import "styles/iconfont.css";
|
|
@import "styles/iconfont.css";
|
|
-</style>
|
|
|
|
|
|
+</style>
|