增加公共状态管理
This commit is contained in:
parent
f410719b46
commit
3919dc507c
|
|
@ -20,3 +20,9 @@ export const commonType = (num) => {
|
||||||
url: `/common/type/${num}`,
|
url: `/common/type/${num}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCommonConfig(){
|
||||||
|
return http.request({
|
||||||
|
url:'common/getAppUseKv'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -119,7 +119,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-10">
|
<view class="u-m-t-10">
|
||||||
<text class="font-bold u-font-26 color-333">温馨提示</text>
|
<text class="font-bold u-font-26 color-333">温馨提示</text>
|
||||||
<text class="u-m-t-10 u-font-24 color-999">一经购买不予退款,未满18岁需在监护人的指导、同意下进行付费操作</text>
|
<text class="u-m-t-10 u-font-24 color-999">{{$common.payTips}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-flex u-flex-row u-m-t-30 u-flex-y-center u-font-28">
|
<view class="u-flex u-flex-row u-m-t-30 u-flex-y-center u-font-28">
|
||||||
<view class="u-flex-y-center">
|
<view class="u-flex-y-center">
|
||||||
|
|
@ -154,6 +154,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import {
|
||||||
|
useCommonStore
|
||||||
|
} from '@/store/common.js'
|
||||||
|
const $common=useCommonStore()
|
||||||
// #ifdef APP
|
// #ifdef APP
|
||||||
const domModule = uni.requireNativePlugin('dom')
|
const domModule = uni.requireNativePlugin('dom')
|
||||||
// #endif
|
// #endif
|
||||||
|
|
|
||||||
17
main.js
17
main.js
|
|
@ -1,6 +1,12 @@
|
||||||
import App from './App'
|
import App from './App'
|
||||||
import uviewPlus from 'uview-plus'
|
import uviewPlus from 'uview-plus'
|
||||||
|
import * as Pinia from "pinia";
|
||||||
|
import {
|
||||||
|
createUnistorage
|
||||||
|
} from "pinia-plugin-unistorage";
|
||||||
|
import {
|
||||||
|
useCommonStore
|
||||||
|
} from '@/store/common.js'
|
||||||
// #ifndef VUE3
|
// #ifndef VUE3
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import './uni.promisify.adaptor'
|
import './uni.promisify.adaptor'
|
||||||
|
|
@ -18,9 +24,16 @@ import {
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
|
const store = Pinia.createPinia();
|
||||||
|
store.use(createUnistorage());
|
||||||
app.use(uviewPlus)
|
app.use(uviewPlus)
|
||||||
|
app.use(store)
|
||||||
|
|
||||||
|
const $common = useCommonStore()
|
||||||
|
$common.init()
|
||||||
return {
|
return {
|
||||||
app
|
app,
|
||||||
|
Pinia
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|
@ -8,5 +8,8 @@
|
||||||
"pre-commit": "^1.2.2",
|
"pre-commit": "^1.2.2",
|
||||||
"to-arraybuffer": "^1.0.1",
|
"to-arraybuffer": "^1.0.1",
|
||||||
"uview-plus": "^3.3.61"
|
"uview-plus": "^3.3.61"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"pinia-plugin-unistorage": "^0.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="min-page">
|
<view class="min-page">
|
||||||
<my-video-list ref="refVideoList" v-if="state.list.length" @swiperChange="swiperChange" :list="state.list"
|
<my-video-list ref="refVideoList" v-if="state.list.length" @swiperChange="swiperChange" :list="state.list"
|
||||||
|
|
||||||
@update="update" :info="state"></my-video-list>
|
@update="update" :info="state"></my-video-list>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -77,7 +78,8 @@
|
||||||
const nobuyCourseId = uni.getStorageSync('nobuyCourseId')
|
const nobuyCourseId = uni.getStorageSync('nobuyCourseId')
|
||||||
const item = state.list.find(v => v.courseId == nobuyCourseId)
|
const item = state.list.find(v => v.courseId == nobuyCourseId)
|
||||||
uni.clearStorageSync('nobuyCourseId')
|
uni.clearStorageSync('nobuyCourseId')
|
||||||
if(drawRes.count*1>0&&nobuyCourseId!==null&&nobuyCourseId!==undefined&&item.videoUrl){
|
if (drawRes.count * 1 > 0 && nobuyCourseId !== null && nobuyCourseId !== undefined && item
|
||||||
|
.videoUrl) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/me/prizeDraw'
|
url: '/pages/me/prizeDraw'
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
import {
|
||||||
|
defineStore
|
||||||
|
} from "pinia";
|
||||||
|
import {getCommonConfig} from '@/api/init.js'
|
||||||
|
const $map = {
|
||||||
|
882: 'isWxIosPay',
|
||||||
|
833: 'checkIosLogin',
|
||||||
|
834: 'checkIosPay',
|
||||||
|
835: 'checkWxLogin',
|
||||||
|
836: 'checkPhoneLogin',
|
||||||
|
108: 'isOpenWxWebAutoLogin',
|
||||||
|
817: 'zhengbu',
|
||||||
|
818: 'danbu',
|
||||||
|
252: 'adUnitId',
|
||||||
|
821: 'playType',
|
||||||
|
251: 'isGuanggao',
|
||||||
|
254: 'isGuanggaody',
|
||||||
|
202: 'kefu',
|
||||||
|
206: 'kefuPhone',
|
||||||
|
204: 'kefuUrl',
|
||||||
|
203: 'kefuAppId',
|
||||||
|
248: 'isVips',
|
||||||
|
249: 'moreSearch',
|
||||||
|
49: 'AppUrl',
|
||||||
|
823: 'OfferID',
|
||||||
|
824: 'payEnv',
|
||||||
|
825: 'moneyTips',
|
||||||
|
855: 'kmPaySel',
|
||||||
|
849: 'homeTypeSel',
|
||||||
|
856: 'syPaySel',
|
||||||
|
857: 'imId',
|
||||||
|
858: 'isAccountPay',
|
||||||
|
860: 'dyadUnitId',
|
||||||
|
881: '',
|
||||||
|
109: '',
|
||||||
|
922: 'withdrawNum',
|
||||||
|
500:'payTips'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useCommonStore = defineStore("common", {
|
||||||
|
state() {
|
||||||
|
return {
|
||||||
|
payTips:'付款完成后不要忘记抽红包哦'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
actions:{
|
||||||
|
async init(){
|
||||||
|
const res=await getCommonConfig()
|
||||||
|
if(res){
|
||||||
|
for (let i in $map) {
|
||||||
|
const key = $map[i]
|
||||||
|
if (key) {
|
||||||
|
this[key]=res[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(res);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unistorage: true, // 开启后对 state 的数据读写都将持久化
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue