第一次提交

This commit is contained in:
gxwebsoft
2023-08-04 13:14:48 +08:00
commit 1b923e5cff
1030 changed files with 128016 additions and 0 deletions

3
common/constant/index.js Executable file
View File

@@ -0,0 +1,3 @@
import paginate from './paginate'
export { paginate }

7
common/constant/paginate.js Executable file
View File

@@ -0,0 +1,7 @@
export default {
data: [], // 列表数据
current_page: 1, // 当前页码
last_page: 1, // 最大页码
per_page: 15, // 每页记录数
total: 0, // 总记录数
}

12
common/enum/Client.js Executable file
View File

@@ -0,0 +1,12 @@
import Enum from './enum'
/**
* 枚举类:客户端类型
* ClientEnum
*/
export default new Enum([
{ key: 'APP', name: 'APP端', value: 'APP' },
{ key: 'H5', name: 'H5端', value: 'H5' },
{ key: 'H5_WEIXIN', name: '微信公众号端', value: 'H5-WEIXIN' },
{ key: 'MP_WEIXIN', name: '微信小程序端', value: 'MP-WEIXIN' },
])

View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:优惠券适用范围
* ApplyRangeEnum
*/
export default new Enum([
{ key: 'ALL', name: '全部商品', value: 10 },
{ key: 'SOME_GOODS', name: '指定商品', value: 20 }
])

View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:优惠券类型
* CouponTypeEnum
*/
export default new Enum([
{ key: 'FULL_DISCOUNT', name: '满减券', value: 10 },
{ key: 'DISCOUNT', name: '折扣券', value: 20 }
])

View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:优惠券到期类型
* ExpireTypeEnum
*/
export default new Enum([
{ key: 'RECEIVE', name: '领取后', value: 10 },
{ key: 'FIXED_TIME', name: '固定时间', value: 20 }
])

5
common/enum/coupon/index.js Executable file
View File

@@ -0,0 +1,5 @@
import ApplyRangeEnum from './ApplyRange'
import ExpireTypeEnum from './ExpireType'
import CouponTypeEnum from './CouponType'
export { ApplyRangeEnum, CouponTypeEnum, ExpireTypeEnum }

View File

@@ -0,0 +1,11 @@
import Enum from '../../enum'
/**
* 枚举类:分销商审核状态
* ApplyStatusEnum
*/
export default new Enum([
{ key: 'WAIT', name: '待审核', value: 10 },
{ key: 'PASSED', name: '审核通过', value: 20 },
{ key: 'REJECT', name: '驳回', value: 30 }
])

View File

@@ -0,0 +1,10 @@
import Enum from '../../enum'
/**
* 枚举类:分销商申请方式
* ApplyTypeEnum
*/
export default new Enum([
{ key: 'AUDIT', name: '需后台审核', value: 10 },
{ key: 'PASS', name: '无需审核', value: 20 }
])

View File

@@ -0,0 +1,4 @@
import ApplyStatusEnum from './ApplyStatus'
import ApplyTypeEnum from './ApplyType'
export { ApplyStatusEnum, ApplyTypeEnum }

View File

@@ -0,0 +1,12 @@
import Enum from '../../enum'
/**
* 枚举类:分销商提现申请状态
* ApplyStatusEnum
*/
export default new Enum([
{ key: 'WAIT', name: '待审核', value: 10 },
{ key: 'PASSED', name: '审核通过', value: 20 },
{ key: 'REJECT', name: '驳回', value: 30 },
{ key: 'PAYMENT', name: '已打款', value: 40 }
])

View File

@@ -0,0 +1,11 @@
import Enum from '../../enum'
/**
* 枚举类:分销商体现打款方式
* PayTypeEnum
*/
export default new Enum([
{ key: 'WECHAT', name: '微信零钱', value: 10 },
{ key: 'ALIPAY', name: '支付宝', value: 20 },
{ key: 'BANK_CARD', name: '银行卡', value: 30 }
])

View File

@@ -0,0 +1,4 @@
import PayTypeEnum from './PayType'
import ApplyStatusEnum from './ApplyStatus'
export { PayTypeEnum, ApplyStatusEnum }

85
common/enum/enum.js Executable file
View File

@@ -0,0 +1,85 @@
/**
* 枚举类
* Enum.IMAGE.name => "图片"
* Enum.getNameByKey('IMAGE') => "图片"
* Enum.getValueByKey('IMAGE') => 10
* Enum.getNameByValue(10) => "图片"
* Enum.getData() => [{key: "IMAGE", name: "图片", value: 10}]
*/
class Enum {
constructor (param) {
const keyArr = []
const valueArr = []
if (!Array.isArray(param)) {
throw new Error('param is not an array!')
}
param.map(element => {
if (!element.key || !element.name) {
return
}
// 保存key值组成的数组方便A.getName(name)类型的调用
keyArr.push(element.key)
valueArr.push(element.value)
// 根据key生成不同属性值以便A.B.name类型的调用
this[element.key] = element
if (element.key !== element.value) {
this[element.value] = element
}
})
// 保存源数组
this.data = param
this.keyArr = keyArr
this.valueArr = valueArr
// 防止被修改
// Object.freeze(this)
}
// 根据key得到对象
keyOf (key) {
return this.data[this.keyArr.indexOf(key)]
}
// 根据key得到对象
valueOf (key) {
return this.data[this.valueArr.indexOf(key)]
}
// 根据key获取name值
getNameByKey (key) {
const prop = this.keyOf(key)
if (!prop) {
throw new Error('No enum constant' + key)
}
return prop.name
}
// 根据value获取name值
getNameByValue (value) {
const prop = this.valueOf(value)
if (!prop) {
throw new Error('No enum constant' + value)
}
return prop.name
}
// 根据key获取value值
getValueByKey (key) {
const prop = this.keyOf(key)
if (!prop) {
throw new Error('No enum constant' + key)
}
return prop.key
}
// 返回源数组
getData () {
return this.data
}
}
export default Enum

10
common/enum/goods/GoodsType.js Executable file
View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:商品类型
* GoodsTypeEnum
*/
export default new Enum([
{ key: 'PHYSICAL', name: '实物商品', value: 10 },
{ key: 'VIRTUAL', name: '虚拟商品', value: 20 }
])

10
common/enum/goods/SpecType.js Executable file
View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:商品规格类型
* SpecTypeEnum
*/
export default new Enum([
{ key: 'SINGLE', name: '单规格', value: 10 },
{ key: 'MULTI', name: '多规格', value: 20 }
])

4
common/enum/goods/index.js Executable file
View File

@@ -0,0 +1,4 @@
import GoodsTypeEnum from './GoodsType'
import SpecTypeEnum from './SpecType'
export { GoodsTypeEnum, SpecTypeEnum }

View File

@@ -0,0 +1,11 @@
import Enum from '../enum'
/**
* 枚举类:拼团活动状态
* GoodsStatusEnum
*/
export default new Enum([
{ key: 'STATE_BEGIN', name: '已开始', value: 10 },
{ key: 'STATE_SOON', name: '未开始', value: 20 },
{ key: 'STATE_END', name: '已结束', value: 30 }
])

View File

@@ -0,0 +1,11 @@
import Enum from '../enum'
/**
* 枚举类:拼团类型
* ActiveTypeEnum
*/
export default new Enum([
{ key: 'NORMAL', name: '普通拼团', value: 10, name2: '多人拼团' },
{ key: 'PULL_NEW', name: '老带新拼团', value: 20, name2: '新人团' },
{ key: 'STEPS', name: '阶梯拼团', value: 30, name2: '阶梯团' }
])

View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:拼团商品状态
* GoodsStatusEnum
*/
export default new Enum([
{ key: 'NORMAL', name: '进行中', value: 10 },
{ key: 'FINISH', name: '已结束', value: 20 }
])

View File

@@ -0,0 +1,11 @@
import Enum from '../enum'
/**
* 枚举类:拼单状态
* TaskStatusEnum
*/
export default new Enum([
{ key: 'NORMAL', name: '进行中', value: 10 },
{ key: 'SUCCESS', name: '拼单成功', value: 20 },
{ key: 'FAIL', name: '拼单失败', value: 30 }
])

6
common/enum/groupon/index.js Executable file
View File

@@ -0,0 +1,6 @@
import GoodsStatusEnum from './GoodsStatus'
import TaskStatusEnum from './TaskStatus'
import ActiveTypeEnum from './ActiveType'
import ActiveStatusEnum from './ActiveStatus'
export { GoodsStatusEnum, TaskStatusEnum, ActiveTypeEnum, ActiveStatusEnum }

15
common/enum/live/LiveStatus.js Executable file
View File

@@ -0,0 +1,15 @@
import Enum from '../enum'
/**
* 枚举类:微信小程序直播间状态
* LiveStatusEnum
*/
export default new Enum([
{ key: 101, name: '直播中', value: 101 },
{ key: 102, name: '未开始', value: 102 },
{ key: 103, name: '已结束', value: 103 },
{ key: 104, name: '禁播', value: 104 },
{ key: 105, name: '暂停中', value: 105 },
{ key: 106, name: '异常', value: 106 },
{ key: 107, name: '已过期', value: 107 }
])

3
common/enum/live/index.js Executable file
View File

@@ -0,0 +1,3 @@
import LiveStatusEnum from './LiveStatus'
export { LiveStatusEnum }

View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:订单发货状态
* DeliveryStatusEnum
*/
export default new Enum([
{ key: 'NOT_DELIVERED', name: '未发货', value: 10 },
{ key: 'DELIVERED', name: '已发货', value: 20 }
])

View File

@@ -0,0 +1,11 @@
import Enum from '../enum'
/**
* 枚举类:配送方式
* DeliveryTypeEnum
*/
export default new Enum([
{ key: 'EXPRESS', name: '快递配送', value: 10 },
{ key: 'EXTRACT', name: '上门自提', value: 20 },
{ key: 'NOTHING', name: '无需配送', value: 30 }
])

View File

@@ -0,0 +1,11 @@
import Enum from '../enum'
/**
* 枚举类:订单来源
* OrderSourceEnum
*/
export default new Enum([
{ key: 'MASTER', name: '普通订单', value: 10 },
{ key: 'BARGAIN', name: '砍价订单', value: 20 },
{ key: 'SHARP', name: '秒杀订单', value: 30 }
])

View File

@@ -0,0 +1,12 @@
import Enum from '../enum'
/**
* 枚举类:订单状态
* OrderStatusEnum
*/
export default new Enum([
{ key: 'NORMAL', name: '进行中', value: 10 },
{ key: 'CANCELLED', name: '已取消', value: 20 },
{ key: 'APPLY_CANCEL', name: '待取消', value: 21 },
{ key: 'COMPLETED', name: '已完成', value: 30 }
])

10
common/enum/order/OrderType.js Executable file
View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:订单类型
* OrderTypeEnum
*/
export default new Enum([
{ key: 'PHYSICAL', name: '实物订单', value: 10 },
{ key: 'VIRTUAL', name: '虚拟订单', value: 20 }
])

10
common/enum/order/PayStatus.js Executable file
View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:订单支付状态
* PayStatusEnum
*/
export default new Enum([
{ key: 'PENDING', name: '待支付', value: 10 },
{ key: 'SUCCESS', name: '已支付', value: 20 }
])

10
common/enum/order/PayType.js Executable file
View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:订单支付方式
* PayTypeEnum
*/
export default new Enum([
{ key: 'BALANCE', name: '余额支付', value: 10 },
{ key: 'WECHAT', name: '微信支付', value: 20 }
])

View File

@@ -0,0 +1,10 @@
import Enum from '../enum'
/**
* 枚举类:订单收货状态
* ReceiptStatusEnum
*/
export default new Enum([
{ key: 'NOT_RECEIVED', name: '未收货', value: 10 },
{ key: 'RECEIVED', name: '已收货', value: 20 }
])

View File

@@ -0,0 +1,11 @@
import Enum from '../../enum'
/**
* 枚举类:发货方式
* DeliveryMethodEnum
*/
export default new Enum([
{ key: 'MANUAL', name: '手动发货', value: 10 },
{ key: 'UNWANTED', name: '无需物流', value: 20 },
{ key: 'EORDER', name: '电子面单', value: 30 }
])

View File

@@ -0,0 +1,3 @@
import DeliveryMethodEnum from './DeliveryMethod'
export { DeliveryMethodEnum }

17
common/enum/order/index.js Executable file
View File

@@ -0,0 +1,17 @@
import DeliveryStatusEnum from './DeliveryStatus'
import DeliveryTypeEnum from './DeliveryType'
import OrderSourceEnum from './OrderSource'
import OrderStatusEnum from './OrderStatus'
import PayStatusEnum from './PayStatus'
import ReceiptStatusEnum from './ReceiptStatus'
import OrderTypeEnum from './OrderType'
export {
DeliveryStatusEnum,
DeliveryTypeEnum,
OrderSourceEnum,
OrderStatusEnum,
PayStatusEnum,
ReceiptStatusEnum,
OrderTypeEnum
}

View File

@@ -0,0 +1,11 @@
import Enum from '../../enum'
/**
* 枚举类:商家审核状态
* AuditStatusEnum
*/
export default new Enum([
{ key: 'WAIT', name: '待审核', value: 0 },
{ key: 'REVIEWED', name: '已同意', value: 10 },
{ key: 'REJECTED', name: '已拒绝', value: 20 }
])

View File

@@ -0,0 +1,12 @@
import Enum from '../../enum'
/**
* 枚举类:售后单状态
* RefundStatusEnum
*/
export default new Enum([
{ key: 'NORMAL', name: '进行中', value: 0 },
{ key: 'REJECTED', name: '已拒绝', value: 10 },
{ key: 'COMPLETED', name: '已完成', value: 20 },
{ key: 'CANCELLED', name: '已取消', value: 30 }
])

View File

@@ -0,0 +1,10 @@
import Enum from '../../enum'
/**
* 枚举类:售后类型
* RefundTypeEnum
*/
export default new Enum([
{ key: 'RETURN', name: '退货退款', value: 10 },
{ key: 'EXCHANGE', name: '换货', value: 20 }
])

View File

@@ -0,0 +1,9 @@
import AuditStatusEnum from './AuditStatus'
import RefundStatusEnum from './RefundStatus'
import RefundTypeEnum from './RefundType'
export {
AuditStatusEnum,
RefundStatusEnum,
RefundTypeEnum
}

11
common/enum/payment/Method.js Executable file
View File

@@ -0,0 +1,11 @@
import Enum from '../enum'
/**
* 枚举类:支付方式类型
* PayMethodEnum
*/
export default new Enum([
{ key: 'WECHAT', name: '微信支付', value: 'wechat' },
{ key: 'ALIPAY', name: '支付宝支付', value: 'alipay' },
{ key: 'BALANCE', name: '余额支付', value: 'balance' }
])

3
common/enum/payment/index.js Executable file
View File

@@ -0,0 +1,3 @@
import PayMethodEnum from './Method'
export { PayMethodEnum }

42
common/enum/setting/Key.js Executable file
View File

@@ -0,0 +1,42 @@
import Enum from '../enum'
/**
* 枚举类:设置项索引
* SettingKeyEnum
*/
export default new Enum([{
key: 'REGISTER',
name: '账户注册设置',
value: 'register'
},
{
key: 'APP_THEME',
name: '店铺页面风格',
value: 'app_theme'
},
{
key: 'PAGE_CATEGORY_TEMPLATE',
name: '分类页模板',
value: 'page_category_template'
},
{
key: 'POINTS',
name: '积分设置',
value: 'points'
},
{
key: 'RECHARGE',
name: '充值设置',
value: 'recharge'
},
{
key: 'RECOMMENDED',
name: '商品推荐设置',
value: 'recommended'
},
{
key: 'CUSTOMER',
name: '商城客服设置',
value: 'customer'
}
])

View File

@@ -0,0 +1,11 @@
import Enum from '../enum'
/**
* 枚举类:整点秒杀-活动会场状态
* ActiveStatusEnum
*/
export default new Enum([
{ key: 'STATE_BEGIN', name: '已开始', value: 10 },
{ key: 'STATE_SOON', name: '即将开始', value: 20 },
{ key: 'STATE_NOTICE', name: '预告', value: 30 }
])

View File

@@ -0,0 +1,11 @@
import Enum from '../enum'
/**
* 枚举类:整点秒杀-活动商品状态
* GoodsStatusEnum
*/
export default new Enum([
{ key: 'STATE_BEGIN', name: '已开始', value: 10 },
{ key: 'STATE_SOON', name: '未开始', value: 20 },
{ key: 'STATE_END', name: '已结束', value: 30 }
])

4
common/enum/sharp/index.js Executable file
View File

@@ -0,0 +1,4 @@
import ActiveStatusEnum from './ActiveStatus'
import GoodsStatusEnum from './GoodsStatus'
export { ActiveStatusEnum, GoodsStatusEnum }

View File

@@ -0,0 +1,12 @@
import Enum from '../../../enum'
/**
* 枚举类:地址类型
* PageCategoryStyleEnum
*/
export default new Enum([
{ key: 'ONE_LEVEL_BIG', name: '一级分类[大图]', value: 10 },
{ key: 'ONE_LEVEL_SMALL', name: '一级分类[小图]', value: 11 },
{ key: 'TWO_LEVEL', name: '二级分类', value: 20 },
{ key: 'COMMODITY', name: '一级分类+商品', value: 30 }
])

View File

@@ -0,0 +1,3 @@
import PageCategoryStyleEnum from './Style'
export { PageCategoryStyleEnum }

57
common/model/Region.js Executable file
View File

@@ -0,0 +1,57 @@
import * as Api from '@/api/region'
import storage from '@/utils/storage'
const REGION_TREE = 'region_tree'
/**
* 商品分类 model类
* RegionModel
*/
export default {
// 从服务端获取全部地区数据(树状)
getTreeDataFromApi () {
return new Promise((resolve, reject) => {
Api.tree().then(result => resolve(result.data.list))
})
},
// 获取所有地区(树状)
getTreeData () {
return new Promise((resolve, reject) => {
// 判断缓存中是否存在
const data = storage.get(REGION_TREE)
// 从服务端获取全部地区数据
if (data) {
resolve(data)
} else {
this.getTreeDataFromApi().then(list => {
// 缓存24小时
storage.set(REGION_TREE, list, 24 * 60 * 60)
resolve(list)
})
}
})
},
// 获取所有地区的总数
getCitysCount () {
return new Promise((resolve, reject) => {
// 获取所有地区(树状)
this.getTreeData().then(data => {
const cityIds = []
// 遍历省份
for (const pidx in data) {
const province = data[pidx]
// 遍历城市
for (const cidx in province.city) {
const cityItem = province.city[cidx]
cityIds.push(cityItem.id)
}
}
resolve(cityIds.length)
})
})
}
}

99
common/model/Setting.js Executable file
View File

@@ -0,0 +1,99 @@
import store from '@/store'
import Config from '@/core/config'
import storage from '@/utils/storage'
import * as SettingApi from '@/api/setting'
import SettingKeyEnum from '@/common/enum/setting/Key'
import platform from '@/core/platform'
const CACHE_KEY = 'Setting'
const OTHER = '_other'
// 写入缓存, 到期时间10分钟
const setStorage = (data) => {
const expireTime = 10 * 60
storage.set(CACHE_KEY, data, expireTime)
}
// 获取缓存中的数据
const getStorage = () => {
return storage.get(CACHE_KEY)
}
// 获取后端接口商城设置 (最新)
const getApiData = () => {
return new Promise((resolve, reject) => {
SettingApi.data()
.then(result => {
resolve(result.data.setting)
})
})
}
/**
* 获取商城设置
* 有缓存的情况下返回缓存, 没有缓存从后端api获取
* @param {bool} isCache 是否从缓存中获取 [优点不用每次请求后端api 缺点后台更新设置后需等待时效性]
*/
const data = isCache => {
if (isCache == undefined) {
isCache = Config.get('enabledSettingCache')
}
return new Promise((resolve, reject) => {
const cacheData = getStorage()
if (isCache && cacheData) {
resolve(cacheData)
} else {
getApiData()
.then(data => {
setStorage(data)
resolve(data)
})
}
})
}
// 获取商城设置(指定项)
const item = (key, isCache) => {
return new Promise((resolve, reject) => {
data(isCache).then(setting => resolve(setting[key]))
})
}
// 获取H5端访问地址
const h5Url = (isCache = false) => {
return new Promise((resolve, reject) => {
data(isCache)
.then(setting => {
const h5Url = setting[OTHER]['h5Url']
resolve(h5Url)
})
})
}
// 设置全局自定义主题
const setAppTheme = () => {
return new Promise((resolve, reject) => {
item(SettingKeyEnum.APP_THEME.value, false)
.then(appTheme => {
store.dispatch('SetAppTheme', appTheme)
resolve()
})
})
}
// 是否显示客服按钮 (微信小程序客服只有在微信小程序端显示)
const isShowCustomerBtn = async () => {
const setting = await item(SettingKeyEnum.CUSTOMER.value, true)
if (!setting.enabled) {
return false
}
return setting.provider === 'wxqykf' || (setting.provider === 'mpwxkf' && platform === 'MP-WEIXIN')
}
export default {
data,
item,
h5Url,
setAppTheme,
isShowCustomerBtn
}

58
common/model/dealer/Setting.js Executable file
View File

@@ -0,0 +1,58 @@
import * as SettingApi from '@/api/dealer/setting'
import storage from '@/utils/storage'
const CACHE_KEY = 'Dealer-Setting'
// 写入缓存, 到期时间30分钟
const setStorage = (data) => {
const expireTime = 30 * 60
storage.set(CACHE_KEY, data, expireTime)
}
// 获取缓存中的数据
const getStorage = () => {
return storage.get(CACHE_KEY)
}
// 获取后端接口商城设置 (最新)
const getApiData = () => {
return new Promise((resolve, reject) => {
SettingApi.data()
.then(result => {
resolve(result.data.setting)
})
})
}
/**
* 获取商城设置
* 有缓存的情况下返回缓存, 没有缓存从后端api获取
* @param {bool} isCache 是否从缓存中获取
*/
const data = (isCache = false) => {
return new Promise((resolve, reject) => {
const cacheData = getStorage()
if (isCache && cacheData) {
resolve(cacheData)
} else {
getApiData().then(data => {
setStorage(data)
resolve(data)
})
}
})
}
// 获取商城设置(指定项)
const item = (key, isCache = false) => {
return new Promise((resolve, reject) => {
data(isCache).then(setting => {
resolve(setting[key])
})
})
}
export default {
data,
item
}

52
common/model/groupon/Setting.js Executable file
View File

@@ -0,0 +1,52 @@
import Config from '@/core/config'
import * as SettingApi from '@/api/groupon/setting'
import storage from '@/utils/storage'
const CACHE_KEY = 'Groupon-Setting'
// 写入缓存, 到期时间30分钟
const setStorage = (data) => {
const expireTime = 30 * 60
storage.set(CACHE_KEY, data, expireTime)
}
// 获取缓存中的数据
const getStorage = () => {
return storage.get(CACHE_KEY)
}
// 获取后端接口商城设置 (最新)
const getApiData = () => {
return new Promise((resolve, reject) => {
SettingApi.data()
.then(result => {
resolve(result.data.setting)
})
})
}
/**
* 获取商城设置
* 有缓存的情况下返回缓存, 没有缓存从后端api获取
* @param {bool} isCache 是否从缓存中获取
*/
const data = (isCache = false) => {
if (isCache == undefined) {
isCache = Config.get('enabledSettingCache')
}
return new Promise((resolve, reject) => {
const cacheData = getStorage()
if (isCache && cacheData) {
resolve(cacheData)
} else {
getApiData().then(data => {
setStorage(data)
resolve(data)
})
}
})
}
export default {
data
}