commit 1b923e5cff63c13fe1f78cab964dca9e6b51ff8e Author: gxwebsoft Date: Fri Aug 4 13:14:48 2023 +0800 第一次提交 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a70bc78 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/unpackage +/node_modules diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json new file mode 100644 index 0000000..d190751 --- /dev/null +++ b/.hbuilderx/launch.json @@ -0,0 +1,20 @@ +{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ + // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 + "version": "0.0", + "configurations": [{ + "default" : + { + "launchtype" : "local" + }, + "h5" : + { + "launchtype" : "local" + }, + "mp-weixin" : + { + "launchtype" : "local" + }, + "type" : "uniCloud" + } + ] +} diff --git a/.idea/meihelove-uniapp.iml b/.idea/meihelove-uniapp.iml new file mode 100644 index 0000000..0c8867d --- /dev/null +++ b/.idea/meihelove-uniapp.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9c8bd27 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/App.vue b/App.vue new file mode 100755 index 0000000..9608f69 --- /dev/null +++ b/App.vue @@ -0,0 +1,121 @@ + + + diff --git a/androidPrivacy.json b/androidPrivacy.json new file mode 100755 index 0000000..4896361 --- /dev/null +++ b/androidPrivacy.json @@ -0,0 +1,14 @@ +{ + "version" : "1", + "prompt" : "template", + "title" : "服务协议和隐私政策", + "message" : "  请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。
  你可阅读《服务协议》《隐私政策》了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。", + "buttonAccept" : "同意并接受", + "buttonRefuse" : "暂不同意", + "second" : { + "title" : "确认提示", + "message" : "  进入应用前,你需先同意《服务协议》《隐私政策》,否则将退出应用。", + "buttonAccept" : "同意并继续", + "buttonRefuse" : "退出应用" + } +} diff --git a/api/apps-bc-agent.js b/api/apps-bc-agent.js new file mode 100644 index 0000000..83a0d0e --- /dev/null +++ b/api/apps-bc-agent.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询余额明细 +export const pageAgentUser = (params) => http.get('/open/bc-agent/page', {params}) + +// 分页查询余额明细 +export const listAgentUser = (params) => http.get('/open/bc-agent', {params}) + +// 查询余额明细 +export const getAgentUser = (AgentUserId) => http.get('/open/bc-agent/' + AgentUserId) + +// 添加余额明细 +export const addAgentUser = (data) => http.post('/open/bc-agent', data) + +// 删除余额明细 +export const removeAgentUser = (id) => http.get('/open/user-balance-log/remove/' + id) + +export default { + pageAgentUser, + listAgentUser, + getAgentUser, + addAgentUser, + removeAgentUser +} diff --git a/api/apps-bc-plan.js b/api/apps-bc-plan.js new file mode 100644 index 0000000..48d4b89 --- /dev/null +++ b/api/apps-bc-plan.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询发布菜品 +export const pageBCPlan = (params) => http.get('/apps/bc-plan/page', {params}) + +// 查询全部发布菜品 +export const listBCPlan = (params) => http.get('/apps/bc-plan', {params}) + +// 查询单天发布菜品 +export const getBCPlan = (orderId) => http.get('/apps/bc-plan/' + orderId) + +// 发布菜品 +export const addBCPlan = (data) => http.post('/apps/bc-plan', data) + +// 删除发布菜品 +export const removeBCPlan = (id) => http.get('/apps/bc-plan/remove/' + id) + +export default { + pageBCPlan, + listBCPlan, + getBCPlan, + addBCPlan, + removeBCPlan +} diff --git a/api/apps-bc-temporary.js b/api/apps-bc-temporary.js new file mode 100644 index 0000000..8dd6af8 --- /dev/null +++ b/api/apps-bc-temporary.js @@ -0,0 +1,31 @@ +import http from './index.js'; + +// 分页查询临时报餐 +export const pageTemporary = (params) => http.get('/apps/bc-temporary/page', {params}) + +// 分页查询临时报餐 +export const pageTemporaryUser = (params) => http.get('/open/bc-temporary/page', {params}) + +// 分页查询临时报餐 +export const listTemporaryUser = (params) => http.get('/open/bc-temporary', {params}) + +// 查询临时报餐 +export const getTemporaryUser = (TemporaryUserId) => http.get('/open/bc-temporary/' + TemporaryUserId) + +// 修改 +export const updateTemporary = (data) => http.put('/apps/bc-temporary', data) + +export const removeTemporary = (id) => http.delete('/apps/bc-temporary/' + id) + +// 申请临时报餐 +export const applyTemporary = (data) => http.post('/apps/bc-temporary/apply', data) + +export default { + updateTemporary, + pageTemporary, + pageTemporaryUser, + listTemporaryUser, + getTemporaryUser, + applyTemporary, + removeTemporary +} diff --git a/api/article-comment.js b/api/article-comment.js new file mode 100644 index 0000000..5a912d1 --- /dev/null +++ b/api/article-comment.js @@ -0,0 +1,29 @@ +import http from './index.js'; + +// 分页查询文章评论 +export const pageArticleComment = (params) => http.get('/cms/article-comment/page', {params}) + +// 查询文章评论 +export const getArticleComment = (ArticleCommentId) => http.get('/cms/article-comment/' + ArticleCommentId) + +// 查询全部评论 +export const listArticleComment = (params) => http.get('/cms/article-comment', {params}) + +// 添加文章评论 +export const addArticleComment = (data) => http.post('/cms/article-comment', data) + +// 删除文章评论 +export const removeArticleComment = (id) => http.delete('/cms/article-comment/' + id) + + +// 未读评论数 +export const getArticleCommentUnreadCount = () => http.get('/cms/article-comment/unread') + +export default { + pageArticleComment, + listArticleComment, + getArticleComment, + addArticleComment, + removeArticleComment, + getArticleCommentUnreadCount +} diff --git a/api/article-like.js b/api/article-like.js new file mode 100644 index 0000000..f3d4ba5 --- /dev/null +++ b/api/article-like.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询文章点赞 +export const pageArticleLike = (params) => http.get('/cms/article-like/page', {params}) + +// 查询文章点赞 +export const getArticleLike = (ArticleLikeId) => http.get('/cms/article-like/' + ArticleLikeId) + +// 查询全部文字 +export const listArticleLike = (params) => http.get('/cms/article-like', {params}) + +// 添加文章点赞 +export const addArticleLike = (data) => http.post('/cms/article-like', data) + +// 删除文章点赞 +export const removeArticleLike = (id) => http.delete('/cms/article-like/' + id) + +export default { + pageArticleLike, + listArticleLike, + getArticleLike, + addArticleLike, + removeArticleLike +} diff --git a/api/article.js b/api/article.js new file mode 100644 index 0000000..3c21be8 --- /dev/null +++ b/api/article.js @@ -0,0 +1,25 @@ +import http from './index.js'; + +// 分页查询文章 +export const pageArticle = (params) => http.get('/cms/article/page', {params}) + +// 查询文章 +export const getArticle = (articleId) => http.get('/cms/article/' + articleId) + +// 查询全部文字 +export const listArticle = (params) => http.get('/cms/article', {params}) + +// 添加文章 +export const addArticle = (data) => http.post('/cms/article', data) + +// 删除文章 +export const removeArticle = (id) => http.delete('/cms/article/' + id) + + +export default { + pageArticle, + listArticle, + getArticle, + addArticle, + removeArticle +} diff --git a/api/balance-log.js b/api/balance-log.js new file mode 100644 index 0000000..a64e8eb --- /dev/null +++ b/api/balance-log.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询余额明细 +export const pageBalanceLog = (params) => http.get('/shop/user-balance-log/page', {params}) + +// 分页查询余额明细 +export const listBalanceLog = (params) => http.get('/shop/user-balance-log', {params}) + +// 查询余额明细 +export const getBalanceLog = (balanceLogId) => http.get('/shop/user-balance-log/' + balanceLogId) + +// 添加余额明细 +export const addBalanceLog = (data) => http.post('/shop/user-balance-log', data) + +// 删除余额明细 +export const removeBalanceLog = (id) => http.get('/open/user-balance-log/remove/' + id) + +export default { + pageBalanceLog, + listBalanceLog, + getBalanceLog, + addBalanceLog, + removeBalanceLog +} diff --git a/api/cart.js b/api/cart.js new file mode 100644 index 0000000..395d5f4 --- /dev/null +++ b/api/cart.js @@ -0,0 +1,23 @@ +import http from './index.js'; + +// 查询购物车商品 +export const showCart = (data) => http.post('/apps/bc-cart/showCart',data) + +// 添加购物车 +export const addCart = (data) => http.post('/apps/bc-cart/addCart', data) +export const addCartPro = (data) => http.post('/apps/bc-cart/addCart',data) +// 清空购物车 +export const clearCart = () => http.get('/apps/bc-cart/clearCart') +// 生成订单 +export const createOrder = (data) => http.post('/apps/bc-cart/createOrder', data) + +// 清空购物车 +export const removeCart = () => http.get('/apps/bc-cart/removeCart') + +export default { + showCart, + addCart, + addCartPro, + createOrder, + removeCart +} diff --git a/api/categoty.js b/api/categoty.js new file mode 100644 index 0000000..fa779c1 --- /dev/null +++ b/api/categoty.js @@ -0,0 +1,21 @@ +import http from './index.js'; + +// 分页查询商品分类 +export const pageCategory = (params) => http.get('/open/category/page', {params}) + +// 分页查询全部商品分类 +export const listCategory = (params) => http.get('/open/category', {params}) + +// 查询商品分类 +export const getCategory = (categoryId) => http.get('/open/category/' + categoryId) + +// 添加商品分类 +export const addCategory = (data) => http.post('/open/category', data) + + +export default { + pageCategory, + listCategory, + getCategory, + addCategory +} diff --git a/api/chat.js b/api/chat.js new file mode 100644 index 0000000..bf16313 --- /dev/null +++ b/api/chat.js @@ -0,0 +1,19 @@ +import http from './index.js'; + + +export const getConversationList = () => http.get('/love/chat-conversation/app') + +export const sendMessage = (data) => http.post('/love/chat-message/app/send', data) + +export const getFriemdMessages = (friendId) => http.get('/love/chat-message/app/list/' + friendId) + +export const postMarkRead = (data) => http.post('/love/chat-conversation/app/read', data) + +export const removeConversation = (id) => http.delete('/love/chat-conversation/' + id) +export default { + getConversationList, + sendMessage, + getFriemdMessages, + postMarkRead, + removeConversation +} diff --git a/api/chatgpt.js b/api/chatgpt.js new file mode 100644 index 0000000..40fb423 --- /dev/null +++ b/api/chatgpt.js @@ -0,0 +1,10 @@ +import http from './index.js'; + +// 提交问题 +export const chat = (data) => http.post('https://chatgpt.websoft.top/api/open/chat/chat', data) + +// export const chat = (data) => http.post('/open/chat/chat', data) + +export default { + chat +} diff --git a/api/demo.js b/api/demo.js new file mode 100644 index 0000000..6807a7d --- /dev/null +++ b/api/demo.js @@ -0,0 +1,16 @@ +import http from './index.js'; + +// 添加购物车 +export const ServerTime = () => http.post('http://127.0.0.1:9090/hxz/v1/ServerTime') + +export const QRCodeTransaction = (data) => http.post('http://127.0.0.1:9090/hxz/v1/QRCodeTransaction',data) +export const QRCodeTransaction2 = (data) => http.post('https://server.gxwebsoft.com/hxz/v1/QRCodeTransaction',data) +export const TransactionInquiry = (data) => http.post('http://127.0.0.1:9090/hxz/v1/TransactionInquiry',data) + + +export default { + ServerTime, + QRCodeTransaction, + QRCodeTransaction2, + TransactionInquiry +} diff --git a/api/dict.js b/api/dict.js new file mode 100644 index 0000000..49d7000 --- /dev/null +++ b/api/dict.js @@ -0,0 +1,12 @@ +import http from './index.js'; + +// 读取字典数据 +export const getDictionaryOptions = (params) => http.get('/system/dict-data', {params}) + +export const listDictionary = (params) => http.get('/system/dict/tree', {params}) + + +export default { + getDictionaryOptions, + listDictionary +} diff --git a/api/equipment-goods.js b/api/equipment-goods.js new file mode 100644 index 0000000..e79f9aa --- /dev/null +++ b/api/equipment-goods.js @@ -0,0 +1,20 @@ +import http from './index.js'; + +// 分页查询设备列表 +export const pageEquipmentGoods = (params) => http.get('/apps/equipment-goods/page', {params}) + +// 查询设备 +export const getEquipmentGoods = (goodsId) => http.get('/apps/equipment-goods/' + goodsId) + +// 绑定设备 +export const bindEquipment = (data) => http.post('/open/equipment/bind', data) + +// 绑定设备 +export const changeEquipment = (data) => http.post('/open/equipment/change', data) + +export default { + pageEquipmentGoods, + getEquipmentGoods, + bindEquipment, + changeEquipment +} diff --git a/api/equipment.js b/api/equipment.js new file mode 100644 index 0000000..3952d90 --- /dev/null +++ b/api/equipment.js @@ -0,0 +1,20 @@ +import http from './index.js'; + +// 分页查询设备列表 +export const pageEquipment = (params) => http.get('/apps/equipment/page', {params}) + +// 查询设备 +export const getEquipment = (equipmentId) => http.get('/apps/equipment/' + equipmentId) + +// 绑定设备 +export const bindEquipment = (data) => http.post('/open/equipment/bind', data) + +// 绑定设备 +export const changeEquipment = (data) => http.post('/open/equipment/change', data) + +export default { + pageEquipment, + getEquipment, + bindEquipment, + changeEquipment +} diff --git a/api/goods.js b/api/goods.js new file mode 100644 index 0000000..4d403c1 --- /dev/null +++ b/api/goods.js @@ -0,0 +1,28 @@ +import http from './index.js'; + +// 分页查询商品 +export const pageGoods = (params) => http.get('/open/goods/page', {params}) + +// 分页查询全部商品 +export const listGoods = (params) => http.get('/open/goods', {params}) + +// 查询商品 +export const getGoods = (GoodsId) => http.get('/open/Goods/' + GoodsId) + +// 添加商品 +export const addGoods = (data) => http.post('/shop/Goods', data) + +// 查询菜品列表 +export const getFoodList = (params) => http.get('/apps/bc-food/getFoodList', {params}) + +// 查询一周菜谱 +export const getWeekFood = (params) => http.get('/apps/bc-food/getWeekFood', {params}) + +export default { + pageGoods, + listGoods, + getGoods, + addGoods, + getFoodList, + getWeekFood +} diff --git a/api/house-info.js b/api/house-info.js new file mode 100644 index 0000000..dac6828 --- /dev/null +++ b/api/house-info.js @@ -0,0 +1,28 @@ +import http from './index.js'; + +// 分页查询房源信息 +export const pageHouseInfo = (params) => http.get('/house/info/page', {params}) + +// 查询全部房源信息 +export const listHouseInfo = (params) => http.get('/house/info', {params}) + +// 查询房源信息(当期登录用户) +export const getHouseInfo = (userId) => http.get('/house/info/' + userId) + +// 查询会员资料 +export const getUserDetail = (userId) => http.get('/house/info/detail/' + userId) + +// 新增房源信息 +export const addHouseInfo = (data) => http.post('/house/info', data) + +// 删除房源信息 +export const removeHouseInfo = (id) => http.get('/house/info/remove/' + id) + +export default { + pageHouseInfo, + listHouseInfo, + getHouseInfo, + getUserDetail, + removeHouseInfo, + addHouseInfo +} diff --git a/api/house-reservation.js b/api/house-reservation.js new file mode 100644 index 0000000..5a409d3 --- /dev/null +++ b/api/house-reservation.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询房源信息 +export const pageHouseReservation = (params) => http.get('/house/reservation/page', {params}) + +// 查询全部房源信息 +export const listHouseReservation = (params) => http.get('/house/reservation', {params}) + +// 查询房源信息(当期登录用户) +export const getHouseReservation = (userId) => http.get('/house/reservation/' + userId) + +// 新增房源信息 +export const addHouseReservation = (data) => http.post('/house/reservation', data) + +// 删除房源信息 +export const removeHouseReservation = (id) => http.get('/house/reservation/remove/' + id) + +export default { + pageHouseReservation, + listHouseReservation, + getHouseReservation, + removeHouseReservation, + addHouseReservation +} diff --git a/api/index.js b/api/index.js new file mode 100644 index 0000000..8bedcbc --- /dev/null +++ b/api/index.js @@ -0,0 +1,85 @@ +import Request from 'luch-request' +import storage from '@/utils/storage' +import { + apiUrl, + tenantId, + appId, + appSecret +} from '@/config.js'; +import { + getSign +} from '@/utils/util.js' +import { + ACCESS_TOKEN +} from '@/store/mutation-types' + +const http = new Request(); + + +/** + * @description 修改全局默认配置 + * @param {Function} + */ +http.setConfig((config) => { + /* config 为默认全局配置*/ + config.baseURL = apiUrl; /* 根域名 */ + + return config +}) + +// 拦截器(请求之前拦截) +http.interceptors.request.use((config) => { // 可使用async await 做异步操作 + const token = storage.get(ACCESS_TOKEN) + config.header = { + ...config.header, + tenantId + } + if(token){ + config.header.Authorization = token + config.header.appId = appId + } + if (config.data) { + config.data.tenantId = tenantId + } + if (!token) { + // 如果token不存在,需要加签 + config.params.tenantId = tenantId + config.params.sign = getSign(config.params,appSecret); + }else { + + } + /** + /* 演示 + if (!token) { // 如果token不存在,return Promise.reject(config) 会取消本次请求 + return Promise.reject(config) + } + **/ + return config +}, config => { // 可使用async await 做异步操作 + return Promise.reject(config) +}) + +// 拦截器(请求之后拦截) +http.interceptors.response.use((response) => { + /* 对响应成功做点什么 可使用async await 做异步操作*/ + // if (response.data.code !== 200) { // 服务端返回的状态码不等于200,则reject() + // return Promise.reject(response) // return Promise.reject 可使promise状态进入catch + // if (response.config.custom.verification) { // 演示自定义参数的作用 + // return response.data + // } + + // token过期 + if (response.data.code == 401) { + + } + if (response.data.code == 1) { + return Promise.reject(response.data) + } + return response.data +}, (response) => { + /* 对响应错误做点什么 (statusCode !== 200)*/ + console.log(response) + return Promise.reject(response) +}) + +export default http diff --git a/api/login.js b/api/login.js new file mode 100644 index 0000000..1a6839d --- /dev/null +++ b/api/login.js @@ -0,0 +1,74 @@ +import http from './index.js'; +import { + apiUrl, + fileUrl, + accessKey, + userId +} from '@/config.js'; +import { + ACCESS_TOKEN, + USER_ID, + USER_INFO +} from '@/store/mutation-types' +import store from '@/store' +import storage from '@/utils/storage' + +// 免密登录 +export const getToken = () => http.get(apiUrl + '/token/' + userId + '/' + accessKey + '/').then(result => { + console.log("免密登录: ", result); + const { + access_token, + user + } = result.data + + // 过期时间30天 + const expiryTime = 30 * 86400 + // 保存tokne和userId到缓存 + storage.set(USER_ID, user.userId, expiryTime) + storage.set(USER_INFO, user, expiryTime) + storage.set(ACCESS_TOKEN, access_token, expiryTime) + store.dispatch('setToken', access_token) + store.dispatch('setUserId', user.userId) +}) + +// 获取图形验证码 +export const getCaptcha = (params) => http.get('/captcha', { + params +}) + +// 发送短信验证码 +export const sendSmsCaptcha = (params) => http.post('/open/sendSmsCaptcha', { + params +}) + +// 获取微信openId +export const getWxOpenId = (data) => http.post('/wx-login/getWxOpenId', data) + +// 支付宝授权码换取userId +export const getAuthCode = (data) => http.post('/open/login-alipay/getAuthCode', data) + +// 微信手机号码登录 +export const loginMpWxMobile = (data) => http.post('/wx-login/loginByMpWxPhone', data) + +// 获取支付宝手机号码 +export const getPhoneNumber = (data, config) => http.post('/shop/payment/getPhoneNumber', data, config) + +// 支付宝登录 +export const alipayLogin = (data) => http.post('/login-alipay/login', data) + +// 支付宝用户注册 +export const register = (data) => http.post('/login-alipay/register', data) + +// 游客登录 +export const login = (data) => http.post('/login', data) + +export default { + getToken, + getWxOpenId, + getCaptcha, + sendSmsCaptcha, + getAuthCode, + getPhoneNumber, + alipayLogin, + login +} diff --git a/api/love-certificate.js b/api/love-certificate.js new file mode 100644 index 0000000..e4d98f5 --- /dev/null +++ b/api/love-certificate.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询会员证件 +export const pageCertificate = (params) => http.get('/love/certificate/page', {params}) + +// 查询全部会员证件 +export const listCertificate = (params) => http.get('/love/certificate', {params}) + +// 上传会员证件 +export const addCertificate = (data) => http.post('/love/certificate', data) + +// 修改会员证件 +export const updateCertificate = (data) => http.put('/love/certificate', data) + +// 删除会员证件 +export const removeCertificate = (id) => http.delete('/love/certificate/' + id) + +export default { + pageCertificate, + listCertificate, + addCertificate, + updateCertificate, + removeCertificate +} diff --git a/api/love-profit.js b/api/love-profit.js new file mode 100644 index 0000000..e5cd826 --- /dev/null +++ b/api/love-profit.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询收益明细 +export const pageProfit = (params) => http.get('/love/profit/page', {params}) + +// 分页查询收益明细 +export const listProfit = (params) => http.get('/love/profit', {params}) + +// 查询收益明细 +export const getProfit = (balanceLogId) => http.get('/love/profit/' + balanceLogId) + +// 添加收益明细 +export const addProfit = (data) => http.post('/love/profit', data) + +// 删除收益明细 +export const removeProfit = (id) => http.get('/love/profit/remove/' + id) + +export default { + pageProfit, + listProfit, + getProfit, + addProfit, + removeProfit +} diff --git a/api/love-user-plan-equity.js b/api/love-user-plan-equity.js new file mode 100644 index 0000000..ea5949f --- /dev/null +++ b/api/love-user-plan-equity.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询会员权益 +export const pageUserPlanEquity = (params) => http.get('/love/user-plan-equity/page', {params}) + +// 查询全部会员权益 +export const listUserPlanEquity = (params) => http.get('/love/user-plan-equity', {params}) + +// 修改会员权益 +export const addUserPlanEquity = (data) => http.post('/love/user-plan-equity', data) + +// 删除会员权益 +export const removeUserPlanEquity = (id) => http.delete('/love/user-plan-equity/' + id) + +// 创建会员订单记录 +export const getPlanByPriceId = (priceId) => http.get('/love/user-plan-equity/getPlanByPriceId/' + priceId) + +export default { + pageUserPlanEquity, + listUserPlanEquity, + addUserPlanEquity, + removeUserPlanEquity, + getPlanByPriceId +} diff --git a/api/love-user-plan-log.js b/api/love-user-plan-log.js new file mode 100644 index 0000000..c50a6aa --- /dev/null +++ b/api/love-user-plan-log.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询购买记录 +export const pageUserPlanLog = (params) => http.get('/love/user-plan-log/page', {params}) + +// 查询全部购买记录 +export const listUserPlanLog = (params) => http.get('/love/user-plan-log', {params}) + +// 修改购买记录 +export const addUserPlanLog = (data) => http.post('/love/user-plan-log', data) + +// 删除购买记录 +export const removeUserPlanLog = (id) => http.delete('/love/user-plan-log/' + id) + +// 创建会员订单记录 +export const getPlanByPriceId = (priceId) => http.get('/love/user-plan-log/getPlanByPriceId/' + priceId) + +export default { + pageUserPlanLog, + listUserPlanLog, + addUserPlanLog, + removeUserPlanLog, + getPlanByPriceId +} diff --git a/api/love-user-plan.js b/api/love-user-plan.js new file mode 100644 index 0000000..8374b71 --- /dev/null +++ b/api/love-user-plan.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询会员套餐 +export const pageUserPlan = (params) => http.get('/love/user-plan/page', {params}) + +// 查询全部会员套餐 +export const listUserPlan = (params) => http.get('/love/user-plan', {params}) + +// 查询会员套餐信息 +export const getUserPlan = (id) => http.get('/love/user-plan/' + id) + +// 修改会员套餐 +export const addUserPlan = (data) => http.post('/love/user-plan', data) + +// 删除会员套餐 +export const removeUserPlan = (id) => http.delete('/love/user-plan/' + id) + +export default { + pageUserPlan, + listUserPlan, + getUserPlan, + addUserPlan, + removeUserPlan +} diff --git a/api/love-user-profile.js b/api/love-user-profile.js new file mode 100644 index 0000000..719b711 --- /dev/null +++ b/api/love-user-profile.js @@ -0,0 +1,28 @@ +import http from './index.js'; + +// 分页查询用户资料 +export const pageUserProfile = (params) => http.get('/love/user-profile/page', {params}) + +// 查询全部用户资料 +export const listUserProfile = (params) => http.get('/love/user-profile', {params}) + +// 查询用户资料(当期登录用户) +export const getUserProfile = (userId) => http.get('/love/user-profile/' + userId) + +// 查询会员资料 +export const getUserDetail = (userId) => http.get('/love/user-profile/detail/' + userId) + +// 新增用户资料 +export const updateUserProfile = (data) => http.put('/love/user-profile', data) + +// 删除用户资料 +export const removeUserProfile = (id) => http.get('/love/user-profile/remove/' + id) + +export default { + pageUserProfile, + listUserProfile, + getUserProfile, + getUserDetail, + updateUserProfile, + removeUserProfile +} diff --git a/api/merchant-withdraw.js b/api/merchant-withdraw.js new file mode 100644 index 0000000..511e9c8 --- /dev/null +++ b/api/merchant-withdraw.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询提现明细 +export const pageMerchantWithdraw = (params) => http.get('/shop/merchant-withdraw/page', {params}) + +// 查询全部提现明细 +export const listMerchantWithdraw = (params) => http.get('/shop/merchant-withdraw', {params}) + +// 获取提现明细 +export const getMerchantWithdraw = (id) => http.get('/shop/merchant-withdraw/page', {id}) + +// 添加提现明细 +export const addMerchantWithdraw = (data) => http.post('/shop/merchant-withdraw', data) + +// 修改提现明细 +export const updateMerchantWithdraw = (data) => http.put('/shop/merchant-withdraw/', data) + +export default { + pageMerchantWithdraw, + listMerchantWithdraw, + getMerchantWithdraw, + addMerchantWithdraw, + updateMerchantWithdraw +} diff --git a/api/merchant.js b/api/merchant.js new file mode 100644 index 0000000..beae17e --- /dev/null +++ b/api/merchant.js @@ -0,0 +1,28 @@ +import http from './index.js'; + +// 分页查询商户列表 +export const pageMerchant = (params) => http.get('/shop/merchant/page', {params}) + +// 查询全部商户 +export const listMerchant = (params) => http.get('/shop/merchant', {params}) + +// 获取商户详情 +export const getMerchant = (merchantId) => http.get('/shop/merchant/page', {merchantId}) + +// 添加商户 +export const addMerchant = (data) => http.post('/shop/merchant', data) + +// 修改商户 +export const updateMerchant = (data) => http.put('/shop/merchant/', data) + +// 提现申请 +export const addWithdraw = (data) => http.post('/shop/merchant/addWithdraw', data) + +export default { + pageMerchant, + listMerchant, + getMerchant, + addMerchant, + updateMerchant, + addWithdraw +} diff --git a/api/order-goods.js b/api/order-goods.js new file mode 100644 index 0000000..b682b20 --- /dev/null +++ b/api/order-goods.js @@ -0,0 +1,28 @@ +import http from './index.js'; + +// 分页查询订单 +export const pageOrder = (params) => http.get('/shop/order-goods/page', {params}) + +// 分页查询订单 +export const listOrder = (params) => http.get('/shop/order-goods', {params}) + +// 查询订单 +export const getOrder = (orderId) => http.get('/shop/order-goods/' + orderId) + +// 添加订单 +export const addOrder = (data) => http.post('/shop/order-goods', data) + +// 删除订单 +export const removeOrder = (id) => http.get('/open/order-goods/remove/' + id) + +// 单个取消菜品 +export const cancelfood = (data) => http.post('/open/order-goods/cancel',data) + +export default { + pageOrder, + listOrder, + getOrder, + addOrder, + removeOrder, + cancelfood +} diff --git a/api/order.js b/api/order.js new file mode 100644 index 0000000..85e62c0 --- /dev/null +++ b/api/order.js @@ -0,0 +1,66 @@ +import http from './index.js'; + +// 分页查询订单 +export const pageOrder = (params) => http.get('/shop/order/page', {params}) + +// 查询订单列表 +export const listOrder = (params) => http.get('/shop/order', {params}) + +// 查询订单列表 +export const listByIds = (data) => http.post('/shop/order/listByIds', data) + +// 查询订单 +export const getOrder = (orderId) => http.get('/shop/order/' + orderId) + +// 添加订单 +export const addOrder = (data) => http.post('/shop/order', data) + +// 添加订单 +export const receiptOrder = (data) => http.post('/open/equipment/receipt', data) + +// 删除订单 +export const removeOrder = (id) => http.get('/open/order/remove/' + id) + +export const setPayStatus = (data) => http.post('/shop/order/setPayStatus', data) + +// 查询订单 +export const getMyOrder = (params) => http.get('/open/order/getMyOrder', { params }) + +// 查询核销订单 +export const getReceiptOrder = (params) => http.get('/open/order/getReceiptOrder', { params }) + +// 订单核销 +export const updateOrder = (data) => http.post('/shop/order', data) + +// 生成二维码 +export const generateQrCode = (params) => http.get('/shop/order/generateQrCode', { params }) + +// 核销二维码码 +export const verificationQrCode = (data) => http.put('/open/order/verification',data) + +// 取消报餐 +export const cancelOrder = (data) => http.post('/open/order/cancel', data) + +// 查询代取餐人员的报餐信息 +export const getOthersOrder = (params) => http.get('/apps/bc-food/getOthersFood', {params}) + +// 查询临时报餐订单 +export const getTemporaryOrder = (params) => http.get('/apps/bc-food/getTemporaryOrder',{params}) + +export default { + pageOrder, + listOrder, + listByIds, + getOrder, + addOrder, + receiptOrder, + removeOrder, + setPayStatus, + getMyOrder, + verificationQrCode, + cancelOrder, + updateOrder, + getOthersOrder, + getReceiptOrder, + getTemporaryOrder +} diff --git a/api/payment.js b/api/payment.js new file mode 100644 index 0000000..18d3637 --- /dev/null +++ b/api/payment.js @@ -0,0 +1,35 @@ +import http from './index.js'; + +// 分页查询支付方式 +export const pagePayment = (params) => http.get('/shop/payment/page', {params}) + +// 查询支付方式 +export const getPayment = (paymentId) => http.get('/shop/payment/' + paymentId) + +// 余额支付 +export const balance = (orderId) => http.get('/shop/payment/balance/' + orderId) + +// 余额支付批量 +export const balanceBatch = (data) => http.post('/shop/payment/balanceBatch', data) + +// 支付宝支付 +export const alipay = (orderId) => http.get('/shop/payment/mp-alipay/' + orderId) + +export const alipayReLet = (data) => http.post('/shop/payment/mp-alipay-relet/', data) + +export const test = (data) => http.post('/shop/payment/mp-alipay/test', data) + +export const payQuery = (orderId) => http.get('/shop/payment/mp-alipay/query/' + orderId) + +export const payQueryByRelet = (orderId) => http.get('/shop/payment/mp-alipay/query-relet/' + orderId) + +export default { + pagePayment, + getPayment, + alipay, + alipayReLet, + payQuery, + payQueryByRelet, + balance, + test +} diff --git a/api/redis-util.js b/api/redis-util.js new file mode 100644 index 0000000..ddf6d6a --- /dev/null +++ b/api/redis-util.js @@ -0,0 +1,17 @@ +import http from './index.js'; + +/** + * 缓存工具包 + * @author 科技小王子 + * @since 2023-06-23 11:34:03 + */ + +// 获取配置信息 +export const getConfig = () => http.get('/system/cache/config') +// 添加关注 +export const addFocus = (data) => http.post('/shop/user-follow', data) + +export default { + getConfig, + addFocus +} diff --git a/api/setting.js b/api/setting.js new file mode 100644 index 0000000..1de6d01 --- /dev/null +++ b/api/setting.js @@ -0,0 +1,8 @@ +import http from './index.js'; + +// 获取商户详情 +export const getSetting = (settingKey) => http.get('/open/system/setting/' + settingKey) + +export default { + getSetting +} diff --git a/api/statistics.js b/api/statistics.js new file mode 100644 index 0000000..cd08315 --- /dev/null +++ b/api/statistics.js @@ -0,0 +1,16 @@ +import http from './index.js'; + +// 菜品预定统计 +export const getBaocanUsers = (params) => http.get('/apps/bc-statistics/baoCanUsers', {params}) + +export const baoCanFoodCount = (params) => http.get('/apps/bc-statistics/baoCanFoodCount',{params}) + +export const baoCanUserCount = (params) => http.get('/apps/bc-statistics/baoCanUserCount',{params}) + +export const baoCanUserCount2 = (params) => http.get('/shop/order-goods',{params}) +export default { + getBaocanUsers, + baoCanFoodCount, + baoCanUserCount, + baoCanUserCount2 +} diff --git a/api/test.js b/api/test.js new file mode 100644 index 0000000..50c244f --- /dev/null +++ b/api/test.js @@ -0,0 +1,16 @@ +import http from './index.js'; + +// 分页查询订单 +export const pageTest = (params) => http.get('/shop/order/page', {params}) + +// 查询订单 +export const getTest = (orderId) => http.get('/shop/order/' + orderId) + +// 添加订单 +export const testIndex = (params) => http.get('/shop/test', params) + +export default { + pageTest, + getTest, + testIndex +} diff --git a/api/upload.js b/api/upload.js new file mode 100644 index 0000000..f615cd1 --- /dev/null +++ b/api/upload.js @@ -0,0 +1,56 @@ +import http from './index.js'; +import { + fileUrl +} from '@/config.js'; +import storage from '@/utils/storage' +import dayjs from "dayjs" +import appConfig from '@/config.js' + +// 文件服务器 +// export const uploadFile = (file) => http.upload(fileUrl + '/api/file/upload', file) + +// 阿里云OSS +export const uploadFile = (file) => http.upload('/oss/upload', file) +// export const uploadFile = async ({filePath}) => { + +// // 获取临时凭证 +// let sts = storage.get('sts'); +// if(!sts){ +// const stsRes = await http.get('/oss/getPostForm') +// sts = stsRes.data +// storage.set('sts', sts, 60) +// } +// const {polocyBase64,signature} = sts; +// var suffix = filePath.substring(filePath.lastIndexOf(".")); //.txt +// const fileName = dayjs().format('YYYYMMDD') + '/'+ uni.$u.guid() + suffix; +// return new Promise((reso, rej) => { +// uni.uploadFile({ +// url: appConfig.fileUrl, // 开发者服务器的URL。 +// filePath: filePath, +// name: 'file', // 必须填file。 +// formData: { +// key: fileName, +// 'policy': polocyBase64, +// 'OSSAccessKeyId': 'LTAI5t8UTh8CTXEi2dYxobhj', +// 'success_action_status': '200', //让服务端返回200,不然,默认会返回204 +// 'signature': signature, +// // 'x-oss-security-token': this.stsToken, +// }, +// success: (res) => { +// const webUrl = appConfig.fileUrl + '/' + fileName; +// reso({data: {url: webUrl,thumb: webUrl}}) +// }, +// fail: err => { +// rej(err) +// } +// }); +// }) + + +// } + +export const getTempOssToken = () => http.get('/oss/getTempToken') +export default { + uploadFile, + getTempOssToken +} \ No newline at end of file diff --git a/api/user-comment.js b/api/user-comment.js new file mode 100644 index 0000000..6dfbf69 --- /dev/null +++ b/api/user-comment.js @@ -0,0 +1,20 @@ +import http from './index.js'; + +// 分页查询评论 +export const pageComment = (params) => http.get('/shop/user-comment/page', {params}) + +// 查询全部评论 +export const listComment = (params) => http.get('/shop/user-comment', {params}) + +// 修改评论 +export const addComment = (data) => http.post('/shop/user-comment', data) + +// 删除评论 +export const removeComment = (id) => http.delete('/shop/user-comment/' + id) + +export default { + pageComment, + listComment, + addComment, + removeComment +} diff --git a/api/user-feedback.js b/api/user-feedback.js new file mode 100644 index 0000000..7126ec6 --- /dev/null +++ b/api/user-feedback.js @@ -0,0 +1,20 @@ +import http from './index.js'; + +// 分页查询意见反馈 +export const pageFeedback = (params) => http.get('/shop/user-feedback/page', {params}) + +// 查询全部意见反馈 +export const listFeedback = (params) => http.get('/shop/user-feedback', {params}) + +// 修改意见反馈 +export const addFeedback = (data) => http.post('/shop/user-feedback', data) + +// 删除意见反馈 +export const removeFeedback = (id) => http.delete('/shop/user-feedback/' + id) + +export default { + pageFeedback, + listFeedback, + addFeedback, + removeFeedback +} diff --git a/api/user-follow.js b/api/user-follow.js new file mode 100644 index 0000000..a742f6a --- /dev/null +++ b/api/user-follow.js @@ -0,0 +1,20 @@ +import http from './index.js'; + +// 分页查询关注记录 +export const pageFollow = (params) => http.get('/shop/user-follow/page', {params}) + +// 查询全部关注记录 +export const listFollow = (params) => http.get('/shop/user-follow', {params}) + +// 修改关注记录 +export const addFollow = (data) => http.post('/shop/user-follow', data) + +// 删除关注记录 +export const removeFollow = (id) => http.delete('/shop/user-follow/' + id) + +export default { + pageFollow, + listFollow, + addFollow, + removeFollow +} diff --git a/api/user-grade.js b/api/user-grade.js new file mode 100644 index 0000000..f9422e5 --- /dev/null +++ b/api/user-grade.js @@ -0,0 +1,20 @@ +import http from './index.js'; + +// 分页查询会员等级 +export const pageUsereGrade = (params) => http.get('/shop/user-grade/page', {params}) + +// 查询全部会员等级 +export const listUsereGrade = (params) => http.get('/shop/user-grade', {params}) + +// 修改会员等级 +export const addUsereGrade = (data) => http.post('/shop/user-grade', data) + +// 删除会员等级 +export const removeUsereGrade = (id) => http.delete('/shop/user-grade/' + id) + +export default { + pageUsereGrade, + listUsereGrade, + addUsereGrade, + removeUsereGrade +} diff --git a/api/user-like.js b/api/user-like.js new file mode 100644 index 0000000..9bd3694 --- /dev/null +++ b/api/user-like.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询点赞 +export const pageLike = (params) => http.get('/shop/user-like/page', {params}) + +// 查询全部点赞 +export const listLike = (params) => http.get('/shop/user-like', {params}) + +// 添加点赞 +export const addLike = (data) => http.post('/shop/user-like', data) + +// 修改点赞 +export const updateLike = (data) => http.put('/shop/user-like', data) + +// 删除点赞 +export const removeLike = (id) => http.delete('/shop/user-like/' + id) + +export default { + pageLike, + listLike, + addLike, + removeLike, + updateLike +} diff --git a/api/user-look.js b/api/user-look.js new file mode 100644 index 0000000..d07c88f --- /dev/null +++ b/api/user-look.js @@ -0,0 +1,24 @@ +import http from './index.js'; + +// 分页查询访客记录 +export const pageLook = (params) => http.get('/shop/user-look/page', {params}) + +// 查询全部访客记录 +export const listLook = (params) => http.get('/shop/user-look', {params}) + +// 添加访客记录 +export const addLook = (data) => http.post('/shop/user-look', data) + +// 修改访客记录 +export const updateLook = (data) => http.put('/shop/user-look', data) + +// 删除访客记录 +export const removeLook = (id) => http.delete('/shop/user-look/' + id) + +export default { + pageLook, + listLook, + addLook, + removeLook, + updateLook +} diff --git a/api/user-referee.js b/api/user-referee.js new file mode 100644 index 0000000..81537bb --- /dev/null +++ b/api/user-referee.js @@ -0,0 +1,20 @@ +import http from './index.js'; + +// 分页查询推荐关系 +export const pageUserReferee = (params) => http.get('/shop/user-referee/page', {params}) + +// 查询全部推荐关系 +export const listUserReferee = (params) => http.get('/shop/user-referee', {params}) + +// 修改推荐关系 +export const addUserReferee = (data) => http.post('/shop/user-referee', data) + +// 删除推荐关系 +export const removeUserReferee = (id) => http.delete('/shop/user-referee/' + id) + +export default { + pageUserReferee, + listUserReferee, + addUserReferee, + removeUserReferee +} diff --git a/api/user.js b/api/user.js new file mode 100644 index 0000000..e340f4c --- /dev/null +++ b/api/user.js @@ -0,0 +1,20 @@ +import http from './index.js'; + +// 获取用户资料 +export const getUser = (params) => http.get('/auth/user', {params}) + +// 修改用户资料 +export const updateUser = (data) => http.put('/system/user', data) +export const getMyQrCode = (data) => http.post('/open/user/myQrCode',data) +// 获取用户资料 +export const getAgentUser = (id) => http.get('/open/user/agentUser/' + id) + +export const updatePassword = (data) => http.put('/auth/password',data) + +export default { + getUser, + updateUser, + getMyQrCode, + getAgentUser, + updatePassword +} diff --git a/api/ww-login.js b/api/ww-login.js new file mode 100644 index 0000000..e2c84c7 --- /dev/null +++ b/api/ww-login.js @@ -0,0 +1,8 @@ +import http from './index.js'; + +// 企业微信登录 +export const wwLogin = (data) => http.post('/open/wx-work/accessToken', data) + +export default { + wwLogin +} diff --git a/api/wx-login.js b/api/wx-login.js new file mode 100755 index 0000000..f95cd03 --- /dev/null +++ b/api/wx-login.js @@ -0,0 +1,12 @@ +import http from './index.js'; +import { fileUrl } from '@/config.js'; + +// 获取微信openId +export const getWxQrCode = () => http.get('/wx-login/getQRCode') + +export const getWxQrCodeFile = () => http.get('/file-preview/getQRCode') + +export default { + getWxQrCode, + getWxQrCodeFile +} diff --git a/api/wxofficial.js b/api/wxofficial.js new file mode 100755 index 0000000..5402a0d --- /dev/null +++ b/api/wxofficial.js @@ -0,0 +1,8 @@ +import http from './index.js'; + +// 查询订单列表 +export const oauthUserInfo = (data) => http.post('/wxofficial/oauthUserInfo', data) + +export default { + oauthUserInfo +} diff --git a/app.scss b/app.scss new file mode 100755 index 0000000..d379b1c --- /dev/null +++ b/app.scss @@ -0,0 +1,43 @@ +/* utils.scss */ +@import "/utils/utils.scss"; + +page { + background: #f3f3f3; +} + +@keyframes rotate { + 0% { + transform: rotate(0deg) scale(1); + } + + 100% { + transform: rotate(360deg) scale(1); + } +} + +/* #ifdef H5*/ + +uni-page { + box-shadow: 0 1rpx 44rpx rgba(169, 169, 169, .3); +} + +.uni-app--showlayout+uni-tabbar.uni-tabbar-bottom, +.uni-app--showlayout+uni-tabbar.uni-tabbar-bottom .uni-tabbar, +.uni-app--showlayout+uni-tabbar.uni-tabbar-top, +.uni-app--showlayout+uni-tabbar.uni-tabbar-top .uni-tabbar { + left: var(--window-left); + right: var(--window-right); +} + +.footer-fixed { + left: var(--window-left) !important; + right: var(--window-right) !important; +} + +.u-mask,.u-drawer { + left: var(--window-left) !important; + right: var(--window-right) !important; +} + +/* #endif */ + diff --git a/common/constant/index.js b/common/constant/index.js new file mode 100755 index 0000000..4c1c240 --- /dev/null +++ b/common/constant/index.js @@ -0,0 +1,3 @@ +import paginate from './paginate' + +export { paginate } diff --git a/common/constant/paginate.js b/common/constant/paginate.js new file mode 100755 index 0000000..0617b7e --- /dev/null +++ b/common/constant/paginate.js @@ -0,0 +1,7 @@ +export default { + data: [], // 列表数据 + current_page: 1, // 当前页码 + last_page: 1, // 最大页码 + per_page: 15, // 每页记录数 + total: 0, // 总记录数 +} diff --git a/common/enum/Client.js b/common/enum/Client.js new file mode 100755 index 0000000..c558f90 --- /dev/null +++ b/common/enum/Client.js @@ -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' }, +]) diff --git a/common/enum/coupon/ApplyRange.js b/common/enum/coupon/ApplyRange.js new file mode 100755 index 0000000..7422e62 --- /dev/null +++ b/common/enum/coupon/ApplyRange.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:优惠券适用范围 + * ApplyRangeEnum + */ +export default new Enum([ + { key: 'ALL', name: '全部商品', value: 10 }, + { key: 'SOME_GOODS', name: '指定商品', value: 20 } +]) diff --git a/common/enum/coupon/CouponType.js b/common/enum/coupon/CouponType.js new file mode 100755 index 0000000..5f56fda --- /dev/null +++ b/common/enum/coupon/CouponType.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:优惠券类型 + * CouponTypeEnum + */ +export default new Enum([ + { key: 'FULL_DISCOUNT', name: '满减券', value: 10 }, + { key: 'DISCOUNT', name: '折扣券', value: 20 } +]) diff --git a/common/enum/coupon/ExpireType.js b/common/enum/coupon/ExpireType.js new file mode 100755 index 0000000..269b36c --- /dev/null +++ b/common/enum/coupon/ExpireType.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:优惠券到期类型 + * ExpireTypeEnum + */ +export default new Enum([ + { key: 'RECEIVE', name: '领取后', value: 10 }, + { key: 'FIXED_TIME', name: '固定时间', value: 20 } +]) diff --git a/common/enum/coupon/index.js b/common/enum/coupon/index.js new file mode 100755 index 0000000..be1bdc8 --- /dev/null +++ b/common/enum/coupon/index.js @@ -0,0 +1,5 @@ +import ApplyRangeEnum from './ApplyRange' +import ExpireTypeEnum from './ExpireType' +import CouponTypeEnum from './CouponType' + +export { ApplyRangeEnum, CouponTypeEnum, ExpireTypeEnum } diff --git a/common/enum/dealer/apply/ApplyStatus.js b/common/enum/dealer/apply/ApplyStatus.js new file mode 100755 index 0000000..4808d4c --- /dev/null +++ b/common/enum/dealer/apply/ApplyStatus.js @@ -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 } +]) diff --git a/common/enum/dealer/apply/ApplyType.js b/common/enum/dealer/apply/ApplyType.js new file mode 100755 index 0000000..31b80a1 --- /dev/null +++ b/common/enum/dealer/apply/ApplyType.js @@ -0,0 +1,10 @@ +import Enum from '../../enum' + +/** + * 枚举类:分销商申请方式 + * ApplyTypeEnum + */ +export default new Enum([ + { key: 'AUDIT', name: '需后台审核', value: 10 }, + { key: 'PASS', name: '无需审核', value: 20 } +]) diff --git a/common/enum/dealer/apply/index.js b/common/enum/dealer/apply/index.js new file mode 100755 index 0000000..63844d6 --- /dev/null +++ b/common/enum/dealer/apply/index.js @@ -0,0 +1,4 @@ +import ApplyStatusEnum from './ApplyStatus' +import ApplyTypeEnum from './ApplyType' + +export { ApplyStatusEnum, ApplyTypeEnum } diff --git a/common/enum/dealer/withdraw/ApplyStatus.js b/common/enum/dealer/withdraw/ApplyStatus.js new file mode 100755 index 0000000..2297ebe --- /dev/null +++ b/common/enum/dealer/withdraw/ApplyStatus.js @@ -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 } +]) diff --git a/common/enum/dealer/withdraw/PayType.js b/common/enum/dealer/withdraw/PayType.js new file mode 100755 index 0000000..2b0c23d --- /dev/null +++ b/common/enum/dealer/withdraw/PayType.js @@ -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 } +]) diff --git a/common/enum/dealer/withdraw/index.js b/common/enum/dealer/withdraw/index.js new file mode 100755 index 0000000..9e8210c --- /dev/null +++ b/common/enum/dealer/withdraw/index.js @@ -0,0 +1,4 @@ +import PayTypeEnum from './PayType' +import ApplyStatusEnum from './ApplyStatus' + +export { PayTypeEnum, ApplyStatusEnum } diff --git a/common/enum/enum.js b/common/enum/enum.js new file mode 100755 index 0000000..0894708 --- /dev/null +++ b/common/enum/enum.js @@ -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 diff --git a/common/enum/goods/GoodsType.js b/common/enum/goods/GoodsType.js new file mode 100755 index 0000000..235af2a --- /dev/null +++ b/common/enum/goods/GoodsType.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:商品类型 + * GoodsTypeEnum + */ +export default new Enum([ + { key: 'PHYSICAL', name: '实物商品', value: 10 }, + { key: 'VIRTUAL', name: '虚拟商品', value: 20 } +]) diff --git a/common/enum/goods/SpecType.js b/common/enum/goods/SpecType.js new file mode 100755 index 0000000..ec7832e --- /dev/null +++ b/common/enum/goods/SpecType.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:商品规格类型 + * SpecTypeEnum + */ +export default new Enum([ + { key: 'SINGLE', name: '单规格', value: 10 }, + { key: 'MULTI', name: '多规格', value: 20 } +]) diff --git a/common/enum/goods/index.js b/common/enum/goods/index.js new file mode 100755 index 0000000..b057a95 --- /dev/null +++ b/common/enum/goods/index.js @@ -0,0 +1,4 @@ +import GoodsTypeEnum from './GoodsType' +import SpecTypeEnum from './SpecType' + +export { GoodsTypeEnum, SpecTypeEnum } diff --git a/common/enum/groupon/ActiveStatus.js b/common/enum/groupon/ActiveStatus.js new file mode 100755 index 0000000..77c0350 --- /dev/null +++ b/common/enum/groupon/ActiveStatus.js @@ -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 } +]) diff --git a/common/enum/groupon/ActiveType.js b/common/enum/groupon/ActiveType.js new file mode 100755 index 0000000..0a89d33 --- /dev/null +++ b/common/enum/groupon/ActiveType.js @@ -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: '阶梯团' } +]) diff --git a/common/enum/groupon/GoodsStatus.js b/common/enum/groupon/GoodsStatus.js new file mode 100755 index 0000000..039a02c --- /dev/null +++ b/common/enum/groupon/GoodsStatus.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:拼团商品状态 + * GoodsStatusEnum + */ +export default new Enum([ + { key: 'NORMAL', name: '进行中', value: 10 }, + { key: 'FINISH', name: '已结束', value: 20 } +]) diff --git a/common/enum/groupon/TaskStatus.js b/common/enum/groupon/TaskStatus.js new file mode 100755 index 0000000..6299cfd --- /dev/null +++ b/common/enum/groupon/TaskStatus.js @@ -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 } +]) diff --git a/common/enum/groupon/index.js b/common/enum/groupon/index.js new file mode 100755 index 0000000..316d18e --- /dev/null +++ b/common/enum/groupon/index.js @@ -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 } diff --git a/common/enum/live/LiveStatus.js b/common/enum/live/LiveStatus.js new file mode 100755 index 0000000..cbb683e --- /dev/null +++ b/common/enum/live/LiveStatus.js @@ -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 } +]) diff --git a/common/enum/live/index.js b/common/enum/live/index.js new file mode 100755 index 0000000..d8a53cc --- /dev/null +++ b/common/enum/live/index.js @@ -0,0 +1,3 @@ +import LiveStatusEnum from './LiveStatus' + +export { LiveStatusEnum } diff --git a/common/enum/order/DeliveryStatus.js b/common/enum/order/DeliveryStatus.js new file mode 100755 index 0000000..ed55f95 --- /dev/null +++ b/common/enum/order/DeliveryStatus.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:订单发货状态 + * DeliveryStatusEnum + */ +export default new Enum([ + { key: 'NOT_DELIVERED', name: '未发货', value: 10 }, + { key: 'DELIVERED', name: '已发货', value: 20 } +]) diff --git a/common/enum/order/DeliveryType.js b/common/enum/order/DeliveryType.js new file mode 100755 index 0000000..230eb18 --- /dev/null +++ b/common/enum/order/DeliveryType.js @@ -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 } +]) diff --git a/common/enum/order/OrderSource.js b/common/enum/order/OrderSource.js new file mode 100755 index 0000000..e46062c --- /dev/null +++ b/common/enum/order/OrderSource.js @@ -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 } +]) diff --git a/common/enum/order/OrderStatus.js b/common/enum/order/OrderStatus.js new file mode 100755 index 0000000..f706e43 --- /dev/null +++ b/common/enum/order/OrderStatus.js @@ -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 } +]) diff --git a/common/enum/order/OrderType.js b/common/enum/order/OrderType.js new file mode 100755 index 0000000..de77681 --- /dev/null +++ b/common/enum/order/OrderType.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:订单类型 + * OrderTypeEnum + */ +export default new Enum([ + { key: 'PHYSICAL', name: '实物订单', value: 10 }, + { key: 'VIRTUAL', name: '虚拟订单', value: 20 } +]) diff --git a/common/enum/order/PayStatus.js b/common/enum/order/PayStatus.js new file mode 100755 index 0000000..f0e4b1d --- /dev/null +++ b/common/enum/order/PayStatus.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:订单支付状态 + * PayStatusEnum + */ +export default new Enum([ + { key: 'PENDING', name: '待支付', value: 10 }, + { key: 'SUCCESS', name: '已支付', value: 20 } +]) diff --git a/common/enum/order/PayType.js b/common/enum/order/PayType.js new file mode 100755 index 0000000..96612df --- /dev/null +++ b/common/enum/order/PayType.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:订单支付方式 + * PayTypeEnum + */ +export default new Enum([ + { key: 'BALANCE', name: '余额支付', value: 10 }, + { key: 'WECHAT', name: '微信支付', value: 20 } +]) diff --git a/common/enum/order/ReceiptStatus.js b/common/enum/order/ReceiptStatus.js new file mode 100755 index 0000000..34916a0 --- /dev/null +++ b/common/enum/order/ReceiptStatus.js @@ -0,0 +1,10 @@ +import Enum from '../enum' + +/** + * 枚举类:订单收货状态 + * ReceiptStatusEnum + */ +export default new Enum([ + { key: 'NOT_RECEIVED', name: '未收货', value: 10 }, + { key: 'RECEIVED', name: '已收货', value: 20 } +]) diff --git a/common/enum/order/delivery/DeliveryMethod.js b/common/enum/order/delivery/DeliveryMethod.js new file mode 100755 index 0000000..7d06cb1 --- /dev/null +++ b/common/enum/order/delivery/DeliveryMethod.js @@ -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 } +]) diff --git a/common/enum/order/delivery/index.js b/common/enum/order/delivery/index.js new file mode 100755 index 0000000..171a078 --- /dev/null +++ b/common/enum/order/delivery/index.js @@ -0,0 +1,3 @@ +import DeliveryMethodEnum from './DeliveryMethod' + +export { DeliveryMethodEnum } diff --git a/common/enum/order/index.js b/common/enum/order/index.js new file mode 100755 index 0000000..56f507b --- /dev/null +++ b/common/enum/order/index.js @@ -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 +} diff --git a/common/enum/order/refund/AuditStatus.js b/common/enum/order/refund/AuditStatus.js new file mode 100755 index 0000000..2d9f5f0 --- /dev/null +++ b/common/enum/order/refund/AuditStatus.js @@ -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 } +]) diff --git a/common/enum/order/refund/RefundStatus.js b/common/enum/order/refund/RefundStatus.js new file mode 100755 index 0000000..78331b2 --- /dev/null +++ b/common/enum/order/refund/RefundStatus.js @@ -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 } +]) diff --git a/common/enum/order/refund/RefundType.js b/common/enum/order/refund/RefundType.js new file mode 100755 index 0000000..63999cd --- /dev/null +++ b/common/enum/order/refund/RefundType.js @@ -0,0 +1,10 @@ +import Enum from '../../enum' + +/** + * 枚举类:售后类型 + * RefundTypeEnum + */ +export default new Enum([ + { key: 'RETURN', name: '退货退款', value: 10 }, + { key: 'EXCHANGE', name: '换货', value: 20 } +]) diff --git a/common/enum/order/refund/index.js b/common/enum/order/refund/index.js new file mode 100755 index 0000000..803b268 --- /dev/null +++ b/common/enum/order/refund/index.js @@ -0,0 +1,9 @@ +import AuditStatusEnum from './AuditStatus' +import RefundStatusEnum from './RefundStatus' +import RefundTypeEnum from './RefundType' + +export { + AuditStatusEnum, + RefundStatusEnum, + RefundTypeEnum +} diff --git a/common/enum/payment/Method.js b/common/enum/payment/Method.js new file mode 100755 index 0000000..e9213e4 --- /dev/null +++ b/common/enum/payment/Method.js @@ -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' } +]) diff --git a/common/enum/payment/index.js b/common/enum/payment/index.js new file mode 100755 index 0000000..030b061 --- /dev/null +++ b/common/enum/payment/index.js @@ -0,0 +1,3 @@ +import PayMethodEnum from './Method' + +export { PayMethodEnum } diff --git a/common/enum/setting/Key.js b/common/enum/setting/Key.js new file mode 100755 index 0000000..8bf7582 --- /dev/null +++ b/common/enum/setting/Key.js @@ -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' + } +]) diff --git a/common/enum/sharp/ActiveStatus.js b/common/enum/sharp/ActiveStatus.js new file mode 100755 index 0000000..de89022 --- /dev/null +++ b/common/enum/sharp/ActiveStatus.js @@ -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 } +]) diff --git a/common/enum/sharp/GoodsStatus.js b/common/enum/sharp/GoodsStatus.js new file mode 100755 index 0000000..f5eac32 --- /dev/null +++ b/common/enum/sharp/GoodsStatus.js @@ -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 } +]) diff --git a/common/enum/sharp/index.js b/common/enum/sharp/index.js new file mode 100755 index 0000000..9a98bdb --- /dev/null +++ b/common/enum/sharp/index.js @@ -0,0 +1,4 @@ +import ActiveStatusEnum from './ActiveStatus' +import GoodsStatusEnum from './GoodsStatus' + +export { ActiveStatusEnum, GoodsStatusEnum } diff --git a/common/enum/store/page/category/Style.js b/common/enum/store/page/category/Style.js new file mode 100755 index 0000000..c33c486 --- /dev/null +++ b/common/enum/store/page/category/Style.js @@ -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 } +]) diff --git a/common/enum/store/page/category/index.js b/common/enum/store/page/category/index.js new file mode 100755 index 0000000..bf350e1 --- /dev/null +++ b/common/enum/store/page/category/index.js @@ -0,0 +1,3 @@ +import PageCategoryStyleEnum from './Style' + +export { PageCategoryStyleEnum } diff --git a/common/model/Region.js b/common/model/Region.js new file mode 100755 index 0000000..a495513 --- /dev/null +++ b/common/model/Region.js @@ -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) + }) + }) + } + +} diff --git a/common/model/Setting.js b/common/model/Setting.js new file mode 100755 index 0000000..c32be2a --- /dev/null +++ b/common/model/Setting.js @@ -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 +} diff --git a/common/model/dealer/Setting.js b/common/model/dealer/Setting.js new file mode 100755 index 0000000..0d043e1 --- /dev/null +++ b/common/model/dealer/Setting.js @@ -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 +} diff --git a/common/model/groupon/Setting.js b/common/model/groupon/Setting.js new file mode 100755 index 0000000..db7c284 --- /dev/null +++ b/common/model/groupon/Setting.js @@ -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 +} diff --git a/components/Luke-UniappAddressSelector/components/UniAddressSelector.vue b/components/Luke-UniappAddressSelector/components/UniAddressSelector.vue new file mode 100644 index 0000000..fbf2a33 --- /dev/null +++ b/components/Luke-UniappAddressSelector/components/UniAddressSelector.vue @@ -0,0 +1,425 @@ + + + + + diff --git a/components/Luke-UniappAddressSelector/index.vue b/components/Luke-UniappAddressSelector/index.vue new file mode 100644 index 0000000..aef0816 --- /dev/null +++ b/components/Luke-UniappAddressSelector/index.vue @@ -0,0 +1,61 @@ + + + + + \ No newline at end of file diff --git a/components/Luke-UniappAddressSelector/readme.md b/components/Luke-UniappAddressSelector/readme.md new file mode 100644 index 0000000..5ec1d25 --- /dev/null +++ b/components/Luke-UniappAddressSelector/readme.md @@ -0,0 +1,31 @@ +# UniAddressSelector省市区街道三级四级联动(内附demo) + +### 概述 + +1. 支持uniapp(APP、H5、小程序)省市区街道三级四级联动 +2. 支持默认地区或已选择地区显示 +3. 数据来源可包括高德地图api、公司封装接口返回 + +### 预览 + +![](https://raw.githubusercontent.com/LukeLiou/picLuke/master/images/UniAddressSelector_watermark.gif) + +### API + +#### props + +| 属性 | 必填 | 说明 | 类型 | 默认值 | +| :------- | ------------- | ------------------------------------------------------------ | ------ | ------ | +| areaInfoSelected | 否 | 已选择的地址对象或默认显示地址对象,属性有:provinceObj,cityObjareaObj,streetObj | Object | {} | +| selectAreaLevelLimit | 否 | 指定选择的级别数,如只需要选择省市区,则指定值为3 | Number | 4 | + +#### events + +| 事件名 | 说明| 返回值 | +| :------- |--------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ | +| cancel | 点击取消按钮时触发 | - | +| confirm | 点击确认按钮时触发 | 选中的省市区街道地址对象,包含如下属性:fullAreaText,provinceCode,,cityCode,areaCode,streetCode,provinceObj,cityObj,areaObj,streetObj | + +### 作者想说 + +欢迎大家留言、评论与star \ No newline at end of file diff --git a/components/add-cart-btn/index.vue b/components/add-cart-btn/index.vue new file mode 100755 index 0000000..3b73663 --- /dev/null +++ b/components/add-cart-btn/index.vue @@ -0,0 +1,36 @@ + + + + + diff --git a/components/add-cart-popup/index.vue b/components/add-cart-popup/index.vue new file mode 100755 index 0000000..46ae2a8 --- /dev/null +++ b/components/add-cart-popup/index.vue @@ -0,0 +1,178 @@ + + + + + diff --git a/components/article-video/article-video.vue b/components/article-video/article-video.vue new file mode 100644 index 0000000..66ca101 --- /dev/null +++ b/components/article-video/article-video.vue @@ -0,0 +1,56 @@ + + + + + \ No newline at end of file diff --git a/components/avatar-image/index.vue b/components/avatar-image/index.vue new file mode 100755 index 0000000..f16e91b --- /dev/null +++ b/components/avatar-image/index.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/components/chat-input-bar/chat-input-bar.vue b/components/chat-input-bar/chat-input-bar.vue new file mode 100644 index 0000000..6be5763 --- /dev/null +++ b/components/chat-input-bar/chat-input-bar.vue @@ -0,0 +1,208 @@ + + + + + + + \ No newline at end of file diff --git a/components/chat-input-bar/emoji.js b/components/chat-input-bar/emoji.js new file mode 100644 index 0000000..a69300b --- /dev/null +++ b/components/chat-input-bar/emoji.js @@ -0,0 +1,33 @@ +export default [ + "😀", "😁", "😃", "😄", "😅", "😆", "😉", "😊", "😋", "😎", "😍", + "😘", "😗", "😙", "😚", "☺", "😇", "😐", "😑", "😶", "😏", "😣", "😥", "😮", "😯", "😪", + "😫", "😴", "😌", "😛", "😜", "😝", "😒", "😓", "😔", "😕", "😲", "😷", "😖", "😞", "😟", + "😤", "😢", "😭", "😦", "😧", "😨", "😬", "😰", "😱", "😳", "😵", "😡", "😠", + "👦", "👧", "👨", "👩", "👴", "👵", "👶", "👱", "👮", "👲", "👳", "👷", "👸", "💂", "🎅", "👰", "👼", + "💆", "💇", "🙍", "🙎", "🙅", "🙆", "💁", "🙋", "🙇", "🙌", "🙏", "👤", "👥", "🚶", "🏃", "👯", + "💃", "👫", "👬", "👭", "💏", "💑", "👪", "💪", "👈", "👉", "☝", "👆", "👇", "✌", "✋", "👌", + "👍", "👎", "✊", "👊", "👋", "👏", "👐", "✍", "👣", "👀", "👂", "👃", "👅", "👄", "💋", "👓", + "👔", "👙", "👛", "👜", "👝", "🎒", "💼", "👞", "👟", "👠", "👡", "👢", "👑", + "👒", "🎩", "🎓", "💄", "💅", "💍", "🌂", "📶", "📳", "📴", "♻", "🏧","🚮", "🚰", "♿", "🚹", "🚺", + "🚻", "🚼", "🚾", "⚠", "🚸", "⛔", "🚫", "🚳", "🚭", "🚯", "🚱", "🚷", "🔞", "💈", + "🙈", "🐒", "🐶", "🐕", "🐩", "🐺", "🐱","🐈", "🐯", "🐅", "🐆", "🐴", "🐎", "🐮", "🐂", + "🐃","🐄","🐷","🐖","🐗","🐽","🐏","🐑","🐐","🐪","🐫","🐘","🐭", + "🐁","🐀","🐹","🐰","🐇","🐻","🐨","🐼","🐾","🐔","🐓","🐣","🐤","🐥", + "🐦", "🐧", "🐸", "🐊","🐢", "🐍", "🐲", "🐉", "🐳", "🐋", "🐬", "🐟", "🐠", "🐡", + "🐙", "🐚", "🐌", "🐛", "🐜", "🐝", "🐞", "🦋", "💐", "🌸", "💮", "🌹", "🌺", + "🌻", "🌼", "🌷", "🌱", "🌲", "🌳", "🌴", "🌵", "🌾", "🌿", "🍀", "🍁", "🍂", "🍃", + "🌍","🌎","🌏","🌐","🌑","🌒","🌓","🌔","🌕","🌖","🌗","🌘","🌙","🌚", + "🌛","🌜","☀","🌝","🌞","⭐","🌟","🌠","☁","⛅","☔","⚡","❄","🔥","💧","🌊", + "🏀", "🏈", "🏉", "🎾", "🎱", "🎳", "⛳", "🎣", "🎽", "🎿", + "😈", "👿", "👹", "👺", "💀", "☠", "👻", "👽", "👾", "💣", + "🌋", "🗻", "🏠", "🏡", "🏢", "🏣", "🏤", "🏥", "🏦", "🏨", + "⛲", "🌁", "🌃", "🌆", "🌇", "🎠", "🎡", "🎢", "🚂", + "🚌", "🚍", "🚎", "🚏", "🚐", "🚑", "🚒", "🚓", "🚔", "🚕", "🚖", "🚗", "🚘", + "💌", "💎", "🔪", "💈", "🚪", "🚽", "🚿", "🛁", "⌛", "⏳", "⌚", "⏰", "🎈", "🎉", + "💤", "💢", "💬", "💭", "♨", "🌀", "🔔", "🔕", "✡", "✝", "🔯", "📛", "🔰", "🔱", "⭕", "✅", + "☑", "✔", "✖", "❌", "❎", "➕", "➖", "➗", "➰", "➿", "〽", "✳", "✴", "❇", "‼", "⁉", "❓", "❔", "❕", "❗", + "🕛", "🕧", "🕐", "🕜", "🕑", "🕝", "🕒", "🕞", "🕓", "🕟", "🕔", "🕠", "🕕", "🕡", + "🕖", "🕢", "🕗", "🕣", "🕘", "🕤", "🕙", "🕥", "🕚", "🕦", "⏱", "⏲", "🕰", + "💘", "❤", "💓", "💔", "💕", "💖", "💗", "💙", "💚", "💛", "💜", "💝", "💞", "💟❣", + "🍇", "🍈", "🍉", "🍊", "🍋", "🍌", "🍍", "🍎", "🍏", "🍐", "🍑", "🍒", "🍓", +] \ No newline at end of file diff --git a/components/chat-item-image/chat-item-image.vue b/components/chat-item-image/chat-item-image.vue new file mode 100644 index 0000000..150134d --- /dev/null +++ b/components/chat-item-image/chat-item-image.vue @@ -0,0 +1,63 @@ + + + + + \ No newline at end of file diff --git a/components/chat-item/chat-item.vue b/components/chat-item/chat-item.vue new file mode 100644 index 0000000..74d9054 --- /dev/null +++ b/components/chat-item/chat-item.vue @@ -0,0 +1,217 @@ + + + + + + + \ No newline at end of file diff --git a/components/countdown/index.vue b/components/countdown/index.vue new file mode 100755 index 0000000..ce4208e --- /dev/null +++ b/components/countdown/index.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/components/customer-btn/index.vue b/components/customer-btn/index.vue new file mode 100755 index 0000000..2a4b1e3 --- /dev/null +++ b/components/customer-btn/index.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/components/empty/index.vue b/components/empty/index.vue new file mode 100755 index 0000000..df7fa66 --- /dev/null +++ b/components/empty/index.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/components/goods-poster-popup/index.vue b/components/goods-poster-popup/index.vue new file mode 100755 index 0000000..71f5a6e --- /dev/null +++ b/components/goods-poster-popup/index.vue @@ -0,0 +1,157 @@ + + + + + diff --git a/components/goods-sku-popup/index.vue b/components/goods-sku-popup/index.vue new file mode 100755 index 0000000..4969133 --- /dev/null +++ b/components/goods-sku-popup/index.vue @@ -0,0 +1,1367 @@ + + + + + diff --git a/components/goods-sku-popup/number-box/index.vue b/components/goods-sku-popup/number-box/index.vue new file mode 100755 index 0000000..ab8d9aa --- /dev/null +++ b/components/goods-sku-popup/number-box/index.vue @@ -0,0 +1,450 @@ + + + + + diff --git a/components/jyf-parser/jyf-parser.vue b/components/jyf-parser/jyf-parser.vue new file mode 100755 index 0000000..2af1369 --- /dev/null +++ b/components/jyf-parser/jyf-parser.vue @@ -0,0 +1,645 @@ + + + + + diff --git a/components/jyf-parser/libs/CssHandler.js b/components/jyf-parser/libs/CssHandler.js new file mode 100755 index 0000000..75c6015 --- /dev/null +++ b/components/jyf-parser/libs/CssHandler.js @@ -0,0 +1,100 @@ +const cfg = require('./config.js'), + isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); + +function CssHandler(tagStyle) { + var styles = Object.assign(Object.create(null), cfg.userAgentStyles); + for (var item in tagStyle) + styles[item] = (styles[item] ? styles[item] + ';' : '') + tagStyle[item]; + this.styles = styles; +} +CssHandler.prototype.getStyle = function(data) { + this.styles = new parser(data, this.styles).parse(); +} +CssHandler.prototype.match = function(name, attrs) { + var tmp, matched = (tmp = this.styles[name]) ? tmp + ';' : ''; + if (attrs.class) { + var items = attrs.class.split(' '); + for (var i = 0, item; item = items[i]; i++) + if (tmp = this.styles['.' + item]) + matched += tmp + ';'; + } + if (tmp = this.styles['#' + attrs.id]) + matched += tmp + ';'; + return matched; +} +module.exports = CssHandler; + +function parser(data, init) { + this.data = data; + this.floor = 0; + this.i = 0; + this.list = []; + this.res = init; + this.state = this.Space; +} +parser.prototype.parse = function() { + for (var c; c = this.data[this.i]; this.i++) + this.state(c); + return this.res; +} +parser.prototype.section = function() { + return this.data.substring(this.start, this.i); +} +// 状态机 +parser.prototype.Space = function(c) { + if (c == '.' || c == '#' || isLetter(c)) { + this.start = this.i; + this.state = this.Name; + } else if (c == '/' && this.data[this.i + 1] == '*') + this.Comment(); + else if (!cfg.blankChar[c] && c != ';') + this.state = this.Ignore; +} +parser.prototype.Comment = function() { + this.i = this.data.indexOf('*/', this.i) + 1; + if (!this.i) this.i = this.data.length; + this.state = this.Space; +} +parser.prototype.Ignore = function(c) { + if (c == '{') this.floor++; + else if (c == '}' && !--this.floor) { + this.list = []; + this.state = this.Space; + } +} +parser.prototype.Name = function(c) { + if (cfg.blankChar[c]) { + this.list.push(this.section()); + this.state = this.NameSpace; + } else if (c == '{') { + this.list.push(this.section()); + this.Content(); + } else if (c == ',') { + this.list.push(this.section()); + this.Comma(); + } else if (!isLetter(c) && (c < '0' || c > '9') && c != '-' && c != '_') + this.state = this.Ignore; +} +parser.prototype.NameSpace = function(c) { + if (c == '{') this.Content(); + else if (c == ',') this.Comma(); + else if (!cfg.blankChar[c]) this.state = this.Ignore; +} +parser.prototype.Comma = function() { + while (cfg.blankChar[this.data[++this.i]]); + if (this.data[this.i] == '{') this.Content(); + else { + this.start = this.i--; + this.state = this.Name; + } +} +parser.prototype.Content = function() { + this.start = ++this.i; + if ((this.i = this.data.indexOf('}', this.i)) == -1) this.i = this.data.length; + var content = this.section(); + for (var i = 0, item; item = this.list[i++];) + if (this.res[item]) this.res[item] += ';' + content; + else this.res[item] = content; + this.list = []; + this.state = this.Space; +} diff --git a/components/jyf-parser/libs/MpHtmlParser.js b/components/jyf-parser/libs/MpHtmlParser.js new file mode 100755 index 0000000..aeb0fc3 --- /dev/null +++ b/components/jyf-parser/libs/MpHtmlParser.js @@ -0,0 +1,580 @@ +/** + * html 解析器 + * @tutorial https://github.com/jin-yufeng/Parser + * @version 20201029 + * @author JinYufeng + * @listens MIT + */ +const cfg = require('./config.js'), + blankChar = cfg.blankChar, + CssHandler = require('./CssHandler.js'), + windowWidth = uni.getSystemInfoSync().windowWidth; +var emoji; + +function MpHtmlParser(data, options = {}) { + this.attrs = {}; + this.CssHandler = new CssHandler(options.tagStyle, windowWidth); + this.data = data; + this.domain = options.domain; + this.DOM = []; + this.i = this.start = this.audioNum = this.imgNum = this.videoNum = 0; + options.prot = (this.domain || '').includes('://') ? this.domain.split('://')[0] : 'http'; + this.options = options; + this.state = this.Text; + this.STACK = []; + // 工具函数 + this.bubble = () => { + for (var i = this.STACK.length, item; item = this.STACK[--i];) { + if (cfg.richOnlyTags[item.name]) return false; + item.c = 1; + } + return true; + } + this.decode = (val, amp) => { + var i = -1, + j, en; + while (1) { + if ((i = val.indexOf('&', i + 1)) == -1) break; + if ((j = val.indexOf(';', i + 2)) == -1) break; + if (val[i + 1] == '#') { + en = parseInt((val[i + 2] == 'x' ? '0' : '') + val.substring(i + 2, j)); + if (!isNaN(en)) val = val.substr(0, i) + String.fromCharCode(en) + val.substr(j + 1); + } else { + en = val.substring(i + 1, j); + if (cfg.entities[en] || en == amp) + val = val.substr(0, i) + (cfg.entities[en] || '&') + val.substr(j + 1); + } + } + return val; + } + this.getUrl = url => { + if (url[0] == '/') { + if (url[1] == '/') url = this.options.prot + ':' + url; + else if (this.domain) url = this.domain + url; + } else if (this.domain && url.indexOf('data:') != 0 && !url.includes('://')) + url = this.domain + '/' + url; + return url; + } + this.isClose = () => this.data[this.i] == '>' || (this.data[this.i] == '/' && this.data[this.i + 1] == '>'); + this.section = () => this.data.substring(this.start, this.i); + this.parent = () => this.STACK[this.STACK.length - 1]; + this.siblings = () => this.STACK.length ? this.parent().children : this.DOM; +} +MpHtmlParser.prototype.parse = function() { + if (emoji) this.data = emoji.parseEmoji(this.data); + for (var c; c = this.data[this.i]; this.i++) + this.state(c); + if (this.state == this.Text) this.setText(); + while (this.STACK.length) this.popNode(this.STACK.pop()); + return this.DOM; +} +// 设置属性 +MpHtmlParser.prototype.setAttr = function() { + var name = this.attrName.toLowerCase(), + val = this.attrVal; + if (cfg.boolAttrs[name]) this.attrs[name] = 'T'; + else if (val) { + if (name == 'src' || (name == 'data-src' && !this.attrs.src)) this.attrs.src = this.getUrl(this.decode(val, 'amp')); + else if (name == 'href' || name == 'style') this.attrs[name] = this.decode(val, 'amp'); + else if (name.substr(0, 5) != 'data-') this.attrs[name] = val; + } + this.attrVal = ''; + while (blankChar[this.data[this.i]]) this.i++; + if (this.isClose()) this.setNode(); + else { + this.start = this.i; + this.state = this.AttrName; + } +} +// 设置文本节点 +MpHtmlParser.prototype.setText = function() { + var back, text = this.section(); + if (!text) return; + text = (cfg.onText && cfg.onText(text, () => back = true)) || text; + if (back) { + this.data = this.data.substr(0, this.start) + text + this.data.substr(this.i); + let j = this.start + text.length; + for (this.i = this.start; this.i < j; this.i++) this.state(this.data[this.i]); + return; + } + if (!this.pre) { + // 合并空白符 + var flag, tmp = []; + for (let i = text.length, c; c = text[--i];) + if (!blankChar[c]) { + tmp.unshift(c); + if (!flag) flag = 1; + } else { + if (tmp[0] != ' ') tmp.unshift(' '); + if (c == '\n' && flag == void 0) flag = 0; + } + if (flag == 0) return; + text = tmp.join(''); + } + this.siblings().push({ + type: 'text', + text: this.decode(text) + }); +} +// 设置元素节点 +MpHtmlParser.prototype.setNode = function() { + var node = { + name: this.tagName.toLowerCase(), + attrs: this.attrs + }, + close = cfg.selfClosingTags[node.name]; + if (this.options.nodes.length) node.type = 'node'; + this.attrs = {}; + if (!cfg.ignoreTags[node.name]) { + // 处理属性 + var attrs = node.attrs, + style = this.CssHandler.match(node.name, attrs, node) + (attrs.style || ''), + styleObj = {}; + if (attrs.id) { + if (this.options.compress & 1) attrs.id = void 0; + else if (this.options.useAnchor) this.bubble(); + } + if ((this.options.compress & 2) && attrs.class) attrs.class = void 0; + switch (node.name) { + case 'a': + case 'ad': // #ifdef APP-PLUS + case 'iframe': + // #endif + this.bubble(); + break; + case 'font': + if (attrs.color) { + styleObj['color'] = attrs.color; + attrs.color = void 0; + } + if (attrs.face) { + styleObj['font-family'] = attrs.face; + attrs.face = void 0; + } + if (attrs.size) { + var size = parseInt(attrs.size); + if (size < 1) size = 1; + else if (size > 7) size = 7; + var map = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large']; + styleObj['font-size'] = map[size - 1]; + attrs.size = void 0; + } + break; + case 'embed': + // #ifndef APP-PLUS + var src = node.attrs.src || '', + type = node.attrs.type || ''; + if (type.includes('video') || src.includes('.mp4') || src.includes('.3gp') || src.includes('.m3u8')) + node.name = 'video'; + else if (type.includes('audio') || src.includes('.m4a') || src.includes('.wav') || src.includes('.mp3') || src.includes( + '.aac')) + node.name = 'audio'; + else break; + if (node.attrs.autostart) + node.attrs.autoplay = 'T'; + node.attrs.controls = 'T'; + // #endif + // #ifdef APP-PLUS + this.bubble(); + break; + // #endif + case 'video': + case 'audio': + if (!attrs.id) attrs.id = node.name + (++this[`${node.name}Num`]); + else this[`${node.name}Num`]++; + if (node.name == 'video') { + if (this.videoNum > 3) + node.lazyLoad = 1; + if (attrs.width) { + styleObj.width = parseFloat(attrs.width) + (attrs.width.includes('%') ? '%' : 'px'); + attrs.width = void 0; + } + if (attrs.height) { + styleObj.height = parseFloat(attrs.height) + (attrs.height.includes('%') ? '%' : 'px'); + attrs.height = void 0; + } + } + if (!attrs.controls && !attrs.autoplay) attrs.controls = 'T'; + attrs.source = []; + if (attrs.src) { + attrs.source.push(attrs.src); + attrs.src = void 0; + } + this.bubble(); + break; + case 'td': + case 'th': + if (attrs.colspan || attrs.rowspan) + for (var k = this.STACK.length, item; item = this.STACK[--k];) + if (item.name == 'table') { + item.flag = 1; + break; + } + } + if (attrs.align) { + if (node.name == 'table') { + if (attrs.align == 'center') styleObj['margin-inline-start'] = styleObj['margin-inline-end'] = 'auto'; + else styleObj['float'] = attrs.align; + } else styleObj['text-align'] = attrs.align; + attrs.align = void 0; + } + // 压缩 style + var styles = style.split(';'); + style = ''; + for (var i = 0, len = styles.length; i < len; i++) { + var info = styles[i].split(':'); + if (info.length < 2) continue; + let key = info[0].trim().toLowerCase(), + value = info.slice(1).join(':').trim(); + if (value[0] == '-' || value.includes('safe')) + style += `;${key}:${value}`; + else if (!styleObj[key] || value.includes('import') || !styleObj[key].includes('import')) + styleObj[key] = value; + } + if (node.name == 'img') { + if (attrs.src && !attrs.ignore) { + if (this.bubble()) + attrs.i = (this.imgNum++).toString(); + else attrs.ignore = 'T'; + } + if (attrs.ignore) { + style += ';-webkit-touch-callout:none'; + styleObj['max-width'] = '100%'; + } + var width; + if (styleObj.width) width = styleObj.width; + else if (attrs.width) width = attrs.width.includes('%') ? attrs.width : parseFloat(attrs.width) + 'px'; + if (width) { + styleObj.width = width; + attrs.width = '100%'; + if (parseInt(width) > windowWidth) { + styleObj.height = ''; + if (attrs.height) attrs.height = void 0; + } + } + if (styleObj.height) { + attrs.height = styleObj.height; + styleObj.height = ''; + } else if (attrs.height && !attrs.height.includes('%')) + attrs.height = parseFloat(attrs.height) + 'px'; + } + for (var key in styleObj) { + var value = styleObj[key]; + if (!value) continue; + if (key.includes('flex') || key == 'order' || key == 'self-align') node.c = 1; + // 填充链接 + if (value.includes('url')) { + var j = value.indexOf('('); + if (j++ != -1) { + while (value[j] == '"' || value[j] == "'" || blankChar[value[j]]) j++; + value = value.substr(0, j) + this.getUrl(value.substr(j)); + } + } + // 转换 rpx + else if (value.includes('rpx')) + value = value.replace(/[0-9.]+\s*rpx/g, $ => parseFloat($) * windowWidth / 750 + 'px'); + else if (key == 'white-space' && value.includes('pre') && !close) + this.pre = node.pre = true; + style += `;${key}:${value}`; + } + style = style.substr(1); + if (style) attrs.style = style; + if (!close) { + node.children = []; + if (node.name == 'pre' && cfg.highlight) { + this.remove(node); + this.pre = node.pre = true; + } + this.siblings().push(node); + this.STACK.push(node); + } else if (!cfg.filter || cfg.filter(node, this) != false) + this.siblings().push(node); + } else { + if (!close) this.remove(node); + else if (node.name == 'source') { + var parent = this.parent(); + if (parent && (parent.name == 'video' || parent.name == 'audio') && node.attrs.src) + parent.attrs.source.push(node.attrs.src); + } else if (node.name == 'base' && !this.domain) this.domain = node.attrs.href; + } + if (this.data[this.i] == '/') this.i++; + this.start = this.i + 1; + this.state = this.Text; +} +// 移除标签 +MpHtmlParser.prototype.remove = function(node) { + var name = node.name, + j = this.i; + // 处理 svg + var handleSvg = () => { + var src = this.data.substring(j, this.i + 1); + node.attrs.xmlns = 'http://www.w3.org/2000/svg'; + for (var key in node.attrs) { + if (key == 'viewbox') src = ` viewBox="${node.attrs.viewbox}"` + src; + else if (key != 'style') src = ` ${key}="${node.attrs[key]}"` + src; + } + src = '', this.i)) == -1) this.i = this.data.length; + if (name == 'svg') handleSvg(); + return; + } + } +} +// 节点出栈处理 +MpHtmlParser.prototype.popNode = function(node) { + // 空白符处理 + if (node.pre) { + node.pre = this.pre = void 0; + for (let i = this.STACK.length; i--;) + if (this.STACK[i].pre) + this.pre = true; + } + var siblings = this.siblings(), + len = siblings.length, + childs = node.children; + if (node.name == 'head' || (cfg.filter && cfg.filter(node, this) == false)) + return siblings.pop(); + var attrs = node.attrs; + // 替换一些标签名 + if (cfg.blockTags[node.name]) node.name = 'div'; + else if (!cfg.trustTags[node.name]) node.name = 'span'; + // 处理列表 + if (node.c && (node.name == 'ul' || node.name == 'ol')) { + if ((node.attrs.style || '').includes('list-style:none')) { + for (let i = 0, child; child = childs[i++];) + if (child.name == 'li') + child.name = 'div'; + } else if (node.name == 'ul') { + var floor = 1; + for (let i = this.STACK.length; i--;) + if (this.STACK[i].name == 'ul') floor++; + if (floor != 1) + for (let i = childs.length; i--;) + childs[i].floor = floor; + } else { + for (let i = 0, num = 1, child; child = childs[i++];) + if (child.name == 'li') { + child.type = 'ol'; + child.num = ((num, type) => { + if (type == 'a') return String.fromCharCode(97 + (num - 1) % 26); + if (type == 'A') return String.fromCharCode(65 + (num - 1) % 26); + if (type == 'i' || type == 'I') { + num = (num - 1) % 99 + 1; + var one = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'], + ten = ['X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'], + res = (ten[Math.floor(num / 10) - 1] || '') + (one[num % 10 - 1] || ''); + if (type == 'i') return res.toLowerCase(); + return res; + } + return num; + })(num++, attrs.type) + '.'; + } + } + } + // 处理表格 + if (node.name == 'table') { + var padding = parseFloat(attrs.cellpadding), + spacing = parseFloat(attrs.cellspacing), + border = parseFloat(attrs.border); + if (node.c) { + if (isNaN(padding)) padding = 2; + if (isNaN(spacing)) spacing = 2; + } + if (border) attrs.style = `border:${border}px solid gray;${attrs.style || ''}`; + if (node.flag && node.c) { + // 有 colspan 或 rowspan 且含有链接的表格转为 grid 布局实现 + attrs.style = `${attrs.style || ''};${spacing ? `;grid-gap:${spacing}px` : ';border-left:0;border-top:0'}`; + var row = 1, + col = 1, + colNum, + trs = [], + children = [], + map = {}; + (function f(ns) { + for (var i = 0; i < ns.length; i++) { + if (ns[i].name == 'tr') trs.push(ns[i]); + else f(ns[i].children || []); + } + })(node.children) + for (let i = 0; i < trs.length; i++) { + for (let j = 0, td; td = trs[i].children[j]; j++) { + if (td.name == 'td' || td.name == 'th') { + while (map[row + '.' + col]) col++; + var cell = { + name: 'div', + c: 1, + attrs: { + style: (td.attrs.style || '') + (border ? `;border:${border}px solid gray` + (spacing ? '' : + ';border-right:0;border-bottom:0') : '') + (padding ? `;padding:${padding}px` : '') + }, + children: td.children + } + if (td.attrs.colspan) { + cell.attrs.style += ';grid-column-start:' + col + ';grid-column-end:' + (col + parseInt(td.attrs.colspan)); + if (!td.attrs.rowspan) cell.attrs.style += ';grid-row-start:' + row + ';grid-row-end:' + (row + 1); + col += parseInt(td.attrs.colspan) - 1; + } + if (td.attrs.rowspan) { + cell.attrs.style += ';grid-row-start:' + row + ';grid-row-end:' + (row + parseInt(td.attrs.rowspan)); + if (!td.attrs.colspan) cell.attrs.style += ';grid-column-start:' + col + ';grid-column-end:' + (col + 1); + for (var k = 1; k < td.attrs.rowspan; k++) map[(row + k) + '.' + col] = 1; + } + children.push(cell); + col++; + } + } + if (!colNum) { + colNum = col - 1; + attrs.style += `;grid-template-columns:repeat(${colNum},auto)` + } + col = 1; + row++; + } + node.children = children; + } else { + attrs.style = `border-spacing:${spacing}px;${attrs.style || ''}`; + if (border || padding) + (function f(ns) { + for (var i = 0, n; n = ns[i]; i++) { + if (n.name == 'th' || n.name == 'td') { + if (border) n.attrs.style = `border:${border}px solid gray;${n.attrs.style || ''}`; + if (padding) n.attrs.style = `padding:${padding}px;${n.attrs.style || ''}`; + } else f(n.children || []); + } + })(childs) + } + if (this.options.autoscroll) { + var table = Object.assign({}, node); + node.name = 'div'; + node.attrs = { + style: 'overflow:scroll' + } + node.children = [table]; + } + } + this.CssHandler.pop && this.CssHandler.pop(node); + // 自动压缩 + if (node.name == 'div' && !Object.keys(attrs).length && childs.length == 1 && childs[0].name == 'div') + siblings[len - 1] = childs[0]; +} +// 状态机 +MpHtmlParser.prototype.Text = function(c) { + if (c == '<') { + var next = this.data[this.i + 1], + isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); + if (isLetter(next)) { + this.setText(); + this.start = this.i + 1; + this.state = this.TagName; + } else if (next == '/') { + this.setText(); + if (isLetter(this.data[++this.i + 1])) { + this.start = this.i + 1; + this.state = this.EndTag; + } else this.Comment(); + } else if (next == '!' || next == '?') { + this.setText(); + this.Comment(); + } + } +} +MpHtmlParser.prototype.Comment = function() { + var key; + if (this.data.substring(this.i + 2, this.i + 4) == '--') key = '-->'; + else if (this.data.substring(this.i + 2, this.i + 9) == '[CDATA[') key = ']]>'; + else key = '>'; + if ((this.i = this.data.indexOf(key, this.i + 2)) == -1) this.i = this.data.length; + else this.i += key.length - 1; + this.start = this.i + 1; + this.state = this.Text; +} +MpHtmlParser.prototype.TagName = function(c) { + if (blankChar[c]) { + this.tagName = this.section(); + while (blankChar[this.data[this.i]]) this.i++; + if (this.isClose()) this.setNode(); + else { + this.start = this.i; + this.state = this.AttrName; + } + } else if (this.isClose()) { + this.tagName = this.section(); + this.setNode(); + } +} +MpHtmlParser.prototype.AttrName = function(c) { + if (c == '=' || blankChar[c] || this.isClose()) { + this.attrName = this.section(); + if (blankChar[c]) + while (blankChar[this.data[++this.i]]); + if (this.data[this.i] == '=') { + while (blankChar[this.data[++this.i]]); + this.start = this.i--; + this.state = this.AttrValue; + } else this.setAttr(); + } +} +MpHtmlParser.prototype.AttrValue = function(c) { + if (c == '"' || c == "'") { + this.start++; + if ((this.i = this.data.indexOf(c, this.i + 1)) == -1) return this.i = this.data.length; + this.attrVal = this.section(); + this.i++; + } else { + for (; !blankChar[this.data[this.i]] && !this.isClose(); this.i++); + this.attrVal = this.section(); + } + this.setAttr(); +} +MpHtmlParser.prototype.EndTag = function(c) { + if (blankChar[c] || c == '>' || c == '/') { + var name = this.section().toLowerCase(); + for (var i = this.STACK.length; i--;) + if (this.STACK[i].name == name) break; + if (i != -1) { + var node; + while ((node = this.STACK.pop()).name != name) this.popNode(node); + this.popNode(node); + } else if (name == 'p' || name == 'br') + this.siblings().push({ + name, + attrs: {} + }); + this.i = this.data.indexOf('>', this.i); + this.start = this.i + 1; + if (this.i == -1) this.i = this.data.length; + else this.state = this.Text; + } +} +module.exports = MpHtmlParser; diff --git a/components/jyf-parser/libs/config.js b/components/jyf-parser/libs/config.js new file mode 100755 index 0000000..1f772e9 --- /dev/null +++ b/components/jyf-parser/libs/config.js @@ -0,0 +1,80 @@ +/* 配置文件 */ +var cfg = { + // 出错占位图 + errorImg: null, + // 过滤器函数 + filter: null, + // 代码高亮函数 + highlight: null, + // 文本处理函数 + onText: null, + // 实体编码列表 + entities: { + quot: '"', + apos: "'", + semi: ';', + nbsp: '\xA0', + ensp: '\u2002', + emsp: '\u2003', + ndash: '–', + mdash: '—', + middot: '·', + lsquo: '‘', + rsquo: '’', + ldquo: '“', + rdquo: '”', + bull: '•', + hellip: '…' + }, + blankChar: makeMap(' ,\xA0,\t,\r,\n,\f'), + boolAttrs: makeMap('allowfullscreen,autoplay,autostart,controls,ignore,loop,muted'), + // 块级标签,将被转为 div + blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,pre,section'), + // 将被移除的标签 + ignoreTags: makeMap('area,base,canvas,frame,iframe,input,link,map,meta,param,script,source,style,svg,textarea,title,track,wbr'), + // 只能被 rich-text 显示的标签 + richOnlyTags: makeMap('a,colgroup,fieldset,legend'), + // 自闭合的标签 + selfClosingTags: makeMap('area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr'), + // 信任的标签 + trustTags: makeMap('a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video'), + // 默认的标签样式 + userAgentStyles: { + address: 'font-style:italic', + big: 'display:inline;font-size:1.2em', + blockquote: 'background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px', + caption: 'display:table-caption;text-align:center', + center: 'text-align:center', + cite: 'font-style:italic', + dd: 'margin-left:40px', + mark: 'background-color:yellow', + pre: 'font-family:monospace;white-space:pre;overflow:scroll', + s: 'text-decoration:line-through', + small: 'display:inline;font-size:0.8em', + u: 'text-decoration:underline' + } +} + +function makeMap(str) { + var map = Object.create(null), + list = str.split(','); + for (var i = list.length; i--;) + map[list[i]] = true; + return map; +} + +// #ifdef MP-WEIXIN +if (wx.canIUse('editor')) { + cfg.blockTags.pre = void 0; + cfg.ignoreTags.rp = true; + Object.assign(cfg.richOnlyTags, makeMap('bdi,bdo,caption,rt,ruby')); + Object.assign(cfg.trustTags, makeMap('bdi,bdo,caption,pre,rt,ruby')); +} +// #endif + +// #ifdef APP-PLUS +cfg.ignoreTags.iframe = void 0; +Object.assign(cfg.trustTags, makeMap('embed,iframe')); +// #endif + +module.exports = cfg; diff --git a/components/jyf-parser/libs/handler.wxs b/components/jyf-parser/libs/handler.wxs new file mode 100755 index 0000000..d3b1aaa --- /dev/null +++ b/components/jyf-parser/libs/handler.wxs @@ -0,0 +1,22 @@ +var inline = { + abbr: 1, + b: 1, + big: 1, + code: 1, + del: 1, + em: 1, + i: 1, + ins: 1, + label: 1, + q: 1, + small: 1, + span: 1, + strong: 1, + sub: 1, + sup: 1 +} +module.exports = { + use: function(item) { + return !item.c && !inline[item.name] && (item.attrs.style || '').indexOf('display:inline') == -1 + } +} diff --git a/components/jyf-parser/libs/trees.vue b/components/jyf-parser/libs/trees.vue new file mode 100755 index 0000000..9c4d68b --- /dev/null +++ b/components/jyf-parser/libs/trees.vue @@ -0,0 +1,506 @@ +