|
@@ -24,7 +24,12 @@
|
|
|
</template>
|
|
|
<script>
|
|
|
import loginMinix from '@/mixins/login';
|
|
|
-import { getIsMin, getIsWxh5, getUrlParams, initEnv, requestInit, wssInit, theCommunicationBetweenWechatAndH5IsNormal, isReloadBefore, getsTheCurrentTopic } from '@/utils/index.js';
|
|
|
+import {
|
|
|
+ getIsMin, getIsWxh5, getUrlParams, initEnv, requestInit,
|
|
|
+ wssInit, theCommunicationBetweenWechatAndH5IsNormal,
|
|
|
+ isReloadBefore, getsTheCurrentTopic, alipayClientInit,
|
|
|
+ localStorageInit, setToken, windowSendInit
|
|
|
+} from '@/utils/index.js';
|
|
|
import uni from '@/utils/uniHooks';
|
|
|
import { getAppIdByGroupIdAndMallId } from '@/utils/index.js';
|
|
|
import sensorsFn from '@/plugins/sensors';
|
|
@@ -32,6 +37,7 @@ import sensorsFn from '@/plugins/sensors';
|
|
|
export default {
|
|
|
mixins: [loginMinix],
|
|
|
async created() {
|
|
|
+
|
|
|
await initEnv();
|
|
|
await requestInit();
|
|
|
await this.init();
|
|
@@ -72,6 +78,27 @@ export default {
|
|
|
methods: {
|
|
|
async init() {
|
|
|
uni.setStorageSync('env', window.env);
|
|
|
+ // 如果是支付宝小程序:初始化
|
|
|
+ if (isAlipayClient) {
|
|
|
+ setToken()
|
|
|
+ localStorageInit();
|
|
|
+ windowSendInit()
|
|
|
+ try {
|
|
|
+ this.$store.commit('SET_IS_INIT', false);
|
|
|
+ const options = await alipayClientInit();
|
|
|
+ await this.$store.dispatch('baseInit', {
|
|
|
+ options,
|
|
|
+ callback: () => {
|
|
|
+ this.$store.commit('SET_IS_INIT', true);
|
|
|
+ // 无感积分逻辑
|
|
|
+ // this.wxEasyPointsCommitStatusInit();
|
|
|
+ },
|
|
|
+ });
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
// 如果是微信小程序。初始化wss
|
|
|
if (getIsMin()) {
|
|
|
// 如果刷新之后没有与微信小程序建立链接则提示用户,关闭小程序重新进入
|
|
@@ -100,20 +127,21 @@ export default {
|
|
|
if (window.location.href.indexOf('cryptojs') > -1) {
|
|
|
return;
|
|
|
}
|
|
|
- // 保留 carList
|
|
|
- const carList = uni.getStorageSync('carList');
|
|
|
- // 保留 buildingId
|
|
|
- const buildingId = window.localStorage.getItem('buildingId')
|
|
|
- // 每次进入页面清空 缓存数据
|
|
|
- window.localStorage.clear();
|
|
|
- if (carList) {
|
|
|
- uni.setStorageSync('carList', JSON.parse(carList));
|
|
|
- }
|
|
|
- if (buildingId) {
|
|
|
- window.localStorage.setItem('buildingId', buildingId)
|
|
|
- }
|
|
|
+ // // 保留 carList
|
|
|
+ // const carList = uni.getStorageSync('carList');
|
|
|
+ // // 保留 buildingId
|
|
|
+ // const buildingId = window.localStorage.getItem('buildingId')
|
|
|
+ // // 每次进入页面清空 缓存数据
|
|
|
+ // window.localStorage.clear();
|
|
|
+ // if (carList) {
|
|
|
+ // uni.setStorageSync('carList', JSON.parse(carList));
|
|
|
+ // }
|
|
|
+ // if (buildingId) {
|
|
|
+ // window.localStorage.setItem('buildingId', buildingId)
|
|
|
+ // }
|
|
|
+ setToken();
|
|
|
+ localStorageInit();
|
|
|
this.$store.commit('SET_IS_INIT', false);
|
|
|
- window.token = `${window.location.href}`.replace(/.*wx\/(.*)\/.*/g, '$1');
|
|
|
try {
|
|
|
const options = await wssInit();
|
|
|
this.$store.dispatch('baseInit', {
|