mall-app-t/peach/store/app.js

182 lines
6.1 KiB
JavaScript
Raw Normal View History

2024-06-03 18:35:53 +08:00
import { ref } from 'vue'
import { defineStore } from 'pinia'
import $platform from '@/peach/platform'
import $router from '@/peach/router'
import useSysStore from './sys'
2024-05-22 15:42:13 +08:00
const useAppStore = defineStore(
2024-06-03 18:35:53 +08:00
'app',
() => {
/**
* @description 应用信息
* @param string name 应用名称
* @param string logo 应用logo
* @param string version 应用版本
* @param string copyright 版权信息
* @param string copyrightTime 版权时间
* @param string cdnurl 静态资源域名
* @param string filesystem 文件系统
*/
const info = ref({
name: '',
logo: '',
version: '',
copyright: '',
copytime: '',
cdnurl: '',
filesystem: '',
})
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
/**
* @description 平台信息
* @param Array share.methods 分享方式
* @param Object share.forwardInfo 转发信息
* @param Object share.posterInfo 海报信息
* @param string share.linkAddress 分享链接地址
* @param number bindMobile 绑定手机号提醒 0: 提醒 1: 不提醒
*/
const platform = ref({
share: {
methods: [],
forwardInfo: {},
posterInfo: {},
linkAddress: '',
},
bindMobile: 0,
})
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
const chat = ref({})
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
/**
* @description 模板信息
* @param Object basic 基础模板
* @param Object tabbar 底部导航模板
*/
const template = ref({
basic: {
tabbar: {
items: [
{
activeIconUrl: '/static/a-index.png',
iconUrl: '/static/index.png',
text: '首页',
url: '/pages/index/index',
},
{
activeIconUrl: '/static/a-product.png',
iconUrl: '/static/product.png',
text: '产品',
url: '/pages/index/product',
},
{
activeIconUrl: '/static/a-order.png',
iconUrl: '/static/order.png',
text: '订单',
url: '/pages/index/order',
},
{
activeIconUrl: '/static/a-my.png',
iconUrl: '/static/my.png',
text: '我的',
url: '/pages/index/my',
},
{
activeIconUrl: 'http://mall.yudao.iocoder.cn/static/images/4-002.png',
iconUrl: 'http://mall.yudao.iocoder.cn/static/images/4-001.png',
text: 'icons',
url: '/pages/index/icons',
},
],
style: {
activeColor: '#fc4141',
bgColor: '#fff',
bgType: 'color',
color: '#282828',
},
theme: 'red',
},
2024-05-22 15:42:13 +08:00
},
2024-06-03 18:35:53 +08:00
})
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
// 全局分享信息
const shareInfo = ref({})
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
// 小程序发货信息管理 0: 没有 1
const hasWechatTradeManaged = ref(0)
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
/**
* @author Ankkaya
* @description 小程序初始化
* @param {Type} -
* @returns {Type}
*/
async function init() {
// 检查网络
const networkStatus = await $platform.checkNetwork()
if (!networkStatus) {
$router.error('NetworkError')
}
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
if (true) {
this.info = {
name: '🍑商城',
logo: 'https://static.iocoder.cn/ruoyi-vue-pro-logo.png',
version: '1.0.0',
copyright: '全部开源,个人与企业可 100% 免费使用',
copytime: 'Copyright© 2018-2024',
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
cdnurl: 'https://file.sheepjs.com', // 云存储域名
filesystem: 'qcloud', // 云存储平台
}
this.platform = {
share: {
methods: ['poster', 'link'],
linkAddress: 'https://shopro.sheepjs.com/#/',
posterInfo: {
user_bg: '/static/img/shop/config/user-poster-bg.png',
goods_bg: '/static/img/shop/config/goods-poster-bg.png',
groupon_bg: '/static/img/shop/config/groupon-poster-bg.png',
},
},
bind_mobile: 0,
}
this.chat = {
chat_domain: 'https://api.shopro.sheepjs.com/chat',
room_id: 'admin',
}
this.has_wechat_trade_managed = 0
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
// 加载主题
const sysStore = useSysStore()
sysStore.setTheme()
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
return Promise.resolve(true)
} else {
$router.error('InitError', res.msg || '加载失败')
}
}
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
return {
info,
platform,
chat,
template,
shareInfo,
hasWechatTradeManaged,
init,
}
2024-05-31 01:06:20 +08:00
},
2024-06-03 18:35:53 +08:00
{
persist: {
enabled: true,
strategies: [
{
key: 'app-store',
},
],
},
}
)
2024-05-22 15:42:13 +08:00
2024-06-03 18:35:53 +08:00
export default useAppStore