|
@@ -12,7 +12,8 @@
|
|
|
import Auth from '@/libs/wechat.js';
|
|
|
import Routine from './libs/routine.js';
|
|
|
import {
|
|
|
- colorChange
|
|
|
+ colorChange,
|
|
|
+ get_openid
|
|
|
} from '@/api/api.js';
|
|
|
import {
|
|
|
mapGetters
|
|
@@ -31,10 +32,12 @@
|
|
|
let orange =
|
|
|
'--view-theme: #FE5C2D;--view-priceColor:#FE5C2D;--view-minorColor:rgba(254, 92, 45, 0.5);--view-minorColorT:rgba(254, 92, 45, 0.1);--view-bntColor:#FDB000;--view-assistColor:#FDB000;'
|
|
|
let gold =
|
|
|
- '--view-theme: #E0A558;--view-priceColor:#DA8C18;--view-minorColor:rgba(224, 165, 88, 0.5);--view-minorColorT:rgba(224, 165, 88, 0.1);--view-bntColor:#1A1A1A;'
|
|
|
- // #ifdef APP
|
|
|
- import { getUpApp } from './utils/upApp.js';
|
|
|
- // #endif
|
|
|
+ '--view-theme: #E0A558;--view-priceColor:#DA8C18;--view-minorColor:rgba(224, 165, 88, 0.5);--view-minorColorT:rgba(224, 165, 88, 0.1);--view-bntColor:#1A1A1A;'
|
|
|
+ // #ifdef APP
|
|
|
+ import {
|
|
|
+ getUpApp
|
|
|
+ } from './utils/upApp.js';
|
|
|
+ // #endif
|
|
|
|
|
|
export default {
|
|
|
globalData: {
|
|
@@ -65,7 +68,7 @@
|
|
|
if (newCart > 0) {
|
|
|
uni.setTabBarBadge({
|
|
|
index: 3,
|
|
|
- text: newCart>99?'99+':newCart+''
|
|
|
+ text: newCart > 99 ? '99+' : newCart + ''
|
|
|
})
|
|
|
} else {
|
|
|
uni.hideTabBarRedDot({
|
|
@@ -75,10 +78,36 @@
|
|
|
}
|
|
|
},
|
|
|
onLaunch: async function(option) {
|
|
|
+ let that = this;
|
|
|
+ // #ifdef H5
|
|
|
+ let openid = uni.getStorageSync('openid')||false;
|
|
|
+ if (this.$wechat.isWeixin()&&!openid) {
|
|
|
+ if (!option.query.code) {
|
|
|
+ that.openUrlWeixin();
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ let code = '';
|
|
|
+ if (option.query.code instanceof Array) {
|
|
|
+ code = option.query.code[option.query.code.length - 1]
|
|
|
+ } else {
|
|
|
+ code = option.query.code
|
|
|
+ }
|
|
|
+ let res = await get_openid({
|
|
|
+ code: code,
|
|
|
+ }).then((re) => {
|
|
|
+ // 保存openid
|
|
|
+ uni.setStorageSync('openid', re.data.openid);
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error,'error');
|
|
|
+ // that.openUrlWeixin()
|
|
|
+ uni.hideLoading();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
//#ifdef APP
|
|
|
plus.screen.lockOrientation("portrait-primary");
|
|
|
//#endif
|
|
|
- let that = this;
|
|
|
colorChange('color_change').then(res => {
|
|
|
let navigation = res.data.navigation; //判断悬浮导航是否显示
|
|
|
let statusColor = res.data.status; //判断显示啥颜色
|
|
@@ -145,7 +174,6 @@
|
|
|
return false;
|
|
|
}
|
|
|
if (option.query.hasOwnProperty('scene')) {
|
|
|
-
|
|
|
switch (option.scene) {
|
|
|
//扫描小程序码
|
|
|
case 1047:
|
|
@@ -208,14 +236,16 @@
|
|
|
} else {
|
|
|
this.globalData.isIframe = false;
|
|
|
}
|
|
|
-
|
|
|
+ console.log(window.location.pathname, this.isWork(), '66666');
|
|
|
if (window.location.pathname !== '/' && !this.isWork()) {
|
|
|
+ console.log('静茹');
|
|
|
let snsapiBase = 'snsapi_base';
|
|
|
let urlData = location.pathname + location.search;
|
|
|
if (!that.$store.getters.isLogin && uni.getStorageSync('authIng')) {
|
|
|
uni.setStorageSync('authIng', false)
|
|
|
}
|
|
|
if (!that.$store.getters.isLogin && Auth.isWeixin()) {
|
|
|
+ console.log('code');
|
|
|
let code,
|
|
|
state,
|
|
|
scope = ''
|
|
@@ -236,6 +266,8 @@
|
|
|
code: code,
|
|
|
snsapi: 'snsapi_base',
|
|
|
spread_spid: that.$Cache.get('spid')
|
|
|
+ }).then((re) => {
|
|
|
+ console.log(re, 're');
|
|
|
}).catch(error => {
|
|
|
uni.hideLoading()
|
|
|
return this.$util.Tips({
|
|
@@ -256,8 +288,7 @@
|
|
|
this.$store.commit('SETUID', res.data.userInfo.uid);
|
|
|
this.$store.commit('UPDATE_USERINFO', res.data.userInfo);
|
|
|
if (option.query.back_url) {
|
|
|
- location.replace(decodeURIComponent(decodeURIComponent(option.query
|
|
|
- .back_url)));
|
|
|
+ location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
|
|
|
}
|
|
|
}
|
|
|
} catch (e) {
|
|
@@ -330,6 +361,23 @@
|
|
|
// }, 100)
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 打开微信链接
|
|
|
+ openUrlWeixin() {
|
|
|
+ const appid = 'wxceb554336d5e17f3'
|
|
|
+ // 判断是否真实路由模式
|
|
|
+ let ul = encodeURIComponent(window.location.protocol + '//' + window.location.host + window.location
|
|
|
+ .pathname);
|
|
|
+ // 打开微信授权页面
|
|
|
+ let url =
|
|
|
+ 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
|
|
|
+ appid +
|
|
|
+ '&redirect_uri=' +
|
|
|
+ ul +
|
|
|
+ '&response_type=code&scope=snsapi_base&state=' +
|
|
|
+ new Date().getTime() +
|
|
|
+ '#wechat_redirect';
|
|
|
+ window.location.href = url;
|
|
|
+ },
|
|
|
// 小程序静默授权
|
|
|
silenceAuth(code) {
|
|
|
let that = this;
|
|
@@ -353,7 +401,7 @@
|
|
|
})
|
|
|
.catch(err => {
|
|
|
return that.$util.Tips({
|
|
|
- title:err
|
|
|
+ title: err
|
|
|
})
|
|
|
});
|
|
|
},
|
|
@@ -367,7 +415,7 @@
|
|
|
*/
|
|
|
checkUpdateVersion() {
|
|
|
//判断微信版本是否 兼容小程序更新机制API的使用
|
|
|
- if (wx.canIUse('getUpdateManager')) {
|
|
|
+ if (wx.canIUse('getUpdateManager')) {
|
|
|
const updateManager = wx.getUpdateManager();
|
|
|
//检测版本更新
|
|
|
updateManager.onCheckForUpdate(function(res) {
|
|
@@ -424,19 +472,19 @@
|
|
|
page {
|
|
|
font-family: PingFang SC;
|
|
|
}
|
|
|
-
|
|
|
- .activityFrame{
|
|
|
- background-size: 100% 100%;
|
|
|
- background-repeat: no-repeat;
|
|
|
- position: absolute;
|
|
|
- top:0;
|
|
|
- left:0;
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
- z-index: 1;
|
|
|
+
|
|
|
+ .activityFrame {
|
|
|
+ background-size: 100% 100%;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ z-index: 1;
|
|
|
}
|
|
|
-
|
|
|
- .placeholder{
|
|
|
+
|
|
|
+ .placeholder {
|
|
|
color: #ccc;
|
|
|
}
|
|
|
|
|
@@ -468,5 +516,6 @@
|
|
|
top: 0;
|
|
|
bottom: 0;
|
|
|
}
|
|
|
+
|
|
|
/* #endif */
|
|
|
-</style>
|
|
|
+</style>
|