commit 8eae987862c85bd8a6254ba059b6fb0e7d0091d6 Author: yangtao Date: Thu Mar 21 17:52:58 2024 +0800 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c44574 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +.DS_Store +node_modules +/dist +.hbuilderx + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? +build.sh +.idea +unpackage \ No newline at end of file diff --git a/App.vue b/App.vue new file mode 100644 index 0000000..4fc5a03 --- /dev/null +++ b/App.vue @@ -0,0 +1,324 @@ + + diff --git a/androidPrivacy.json b/androidPrivacy.json new file mode 100644 index 0000000..8b67533 --- /dev/null +++ b/androidPrivacy.json @@ -0,0 +1,28 @@ +{ + "version" : "1", + "prompt" : "template", + "title" : "服务协议与隐私政策", + "message" : "\t请务必审慎阅读、充分理解“服务协议与 隐私政策”各条款,包括但不限于:为了 向你提供即时通讯、内容分享等服务,我 们需要收集你的设备信息、操作日志等个 人信息。你可以在“设置”中查看、变更、删除个人信息并管理你的授权。
\r\r +\t你可以阅读 《用户协议》《隐私政策》了解详细信息。如你同意,请点击“我同意”开始接受我们的服务。", + "buttonAccept" : "同意并接受", + "buttonRefuse" : "暂不同意", + "second" : { + "title" : "确认提示", + "message" : "进入应用前,你需先同意《用户协议》《隐私政策》,否则将退出应用。", + "buttonAccept" : "同意并继续", + "buttonRefuse" : "退出应用" + }, + "styles" : { + "backgroundColor" : "#fff", + "borderRadius" : "5px", + "title" : { + "color" : "#000" + }, + "buttonAccept" : { + "color" : "#fff" + }, + "buttonRefuse" : { + "color" : "#ccc" + } + } +} diff --git a/api/activity.js b/api/activity.js new file mode 100644 index 0000000..ca9ca16 --- /dev/null +++ b/api/activity.js @@ -0,0 +1,256 @@ + +import request from "@/utils/request.js"; + +/** + * 拼团列表 + * + */ +export function getCombinationList(data) { + return request.get('store/product/group/lst', data, { + noAuth: true + }); +} +/** + * 拼团参与人 + * + */ +export function getCombinationUser(data) { + return request.get('store/product/group/count', data, { + noAuth: true + }); +} +/** + * 活动分类 + * + */ +export function getActivitycategory(type) { + return request.get('product/spu/active/category/' + type, {}, { + noAuth: true + }); +} + +/** + * 拼团详情 + * + */ +export function getCombinationDetail(id) { + return request.get('store/product/group/detail/' + id, {}, { + noAuth: true + }); +} + +/** + * 拼团 开团 + */ +export function getCombinationPink(id) { + return request.get("store/product/group/get/" + id); +} + + +/** + * 拼团 取消开团 + */ +export function postCombinationRemove(data) { + return request.post("store/product/group/cancel", data); +} + +/** + * 秒杀产品详情 + * @param int id + */ +export function getSeckillDetail(id) { + return request.get('store/product/seckill/detail/' + id, {}, { + noAuth: true + }); +} + + +/** + * 拼团海报 + * @param object data + * + */ +export function getCombinationPoster(data) { + return request.post('combination/poster', data) +} + + + +/** + * 获取秒杀小程序二维码 + */ +export function seckillCode(id, data) { + return request.get("seckill/code/" + id, data); +} + +/** + * 获取拼团小程序二维码 + */ +export function scombinationCode(id) { + return request.get("combination/code/" + id); +} +/** + * 秒杀产品时间区间 + * + */ +export function getSeckillIndexTime() { + return request.get('store/product/seckill/select', {}, { + noAuth: true + }); +} +/** + * 秒杀产品列表 + * @param int time + * @param object data + */ +export function getSeckillList(data) { + return request.get('store/product/seckill/lst', data, { + noAuth: true + }); + +} +/** + * 预售列表 + */ +export function getPresellList(data) { + return request.get('store/product/presell/lst', data, { + noAuth: true + }); +} +/** + * 助力列表 + */ +export function getAssistList(data) { + return request.get('store/product/assist/lst', data, { + noAuth: true + }); +} + +/** + * 助力列表 -- 发起助力 + */ +export function initiateAssistApi(id) { + return request.post('store/product/assist/create/' + id); +} +/** + * 助力详情 + */ +export function getAssistDetail(id,data) { + return request.get('store/product/assist/detail/' + id,data); +} +/** + * 助力好友 + */ +export function assistHelpList(id, data) { + return request.get('store/product/assist/user/' + id, data); +} +/** + * 预售协议 + */ +export function presellAgreement() { + return request.get('store/product/presell/agree'); +} +/** + * 已助力成功数据 + */ +export function assistUserData(data) { + return request.get('store/product/assist/count', data, { + noAuth: true + }); +} +/** + * 为好友助力 + */ +export function postAssistHelp(id) { + return request.post('store/product/assist/set/' + id); +} +/** + * 获取助力查看分享次数 + */ +export function getAssistUser(id) { + return request.get('store/product/assist/share/' + id); +} +/** + * 助力记录列表 + */ +export function getBargainUserList(data) { + return request.get('store/product/assist/set/lst', data); +} +/** + * 助力记录列表 -- 取消 + */ +export function getBargainUserCancel(id) { + return request.post('store/product/assist/set/delete/' + id); +} +/** + * 活动专题列表 + */ +export function getTopicList(id, data) { + return request.get(`activity/lst/${id}`, data, { + noAuth: true + }); +} +/** + * 活动专题详情 + */ +export function getTopicDetail(id) { + return request.get(`activity/info/${id}`,{}, { + noAuth: true + }); +} +/** + * 活动专题商品 + */ +export function getTopicProLst(data) { + return request.get(`product/spu/labels`,data, { + noAuth: true + }); +} +/** + * 获取本地服务商户列表 + */ +export function getMerchantServiceLst(data) { + return request.get(`store/merchant/local`,data, { + noAuth: true + }); +} +/** + * 获取优惠券列表 + */ +export function getCouponLst(data) { + return request.get(`coupon/getlst`,data, { + noAuth: true + }); +} +/** + * 获取优惠券列表 + */ +export function getNewPeopleCouponLst(data) { + return request.get(`coupon/new_people`,data, { + noAuth: true + }); +} +/** + * 获取热卖排行列表 + */ +export function hotRankingApi(data) { + return request.get(`product/spu/get_hot_ranking`,data, { + noAuth: true + }); +} +/** + * 热卖排行列表分类 + */ +export function spuTop(data) { + return request.get(`store/product/category/hotranking`, {}, { + noAuth: true + }); +} +/** + * 热卖排行列表 + */ +export function spuTopList(data) { + return request.get(`product/spu/get_hot_ranking`, data, { + noAuth: true + }); +} \ No newline at end of file diff --git a/api/admin.js b/api/admin.js new file mode 100644 index 0000000..9566dee --- /dev/null +++ b/api/admin.js @@ -0,0 +1,225 @@ + +import request from "@/utils/request.js"; + +/** + * 统计数据 + */ +export function getStatisticsInfo() { + return request.get("admin/order/statistics", {}, { login: true }); +} +/** + * 订单月统计 + */ +export function getStatisticsMonth(where) { + return request.get("admin/order/data", where, { login: true }); +} +/** + * 订单月统计 + */ +export function getAdminOrderList(where) { + return request.get("admin/order/list", where, { login: true }); +} +/** + * 订单改价 + */ +export function setAdminOrderPrice(merId,id,data) { + return request.post("admin/"+merId+"/price/"+id, data, { login: true }); +} +/** + * 订单备注 + */ +export function setAdminOrderRemark(merId,id,data) { + return request.post("admin/"+merId+"/mark/" +id, data, { login: true }); +} +/** + * 订单详情 + */ +export function getAdminOrderDetail(merId, orderId) { + return request.get("admin/"+merId+"/order/" + orderId, {}, { login: true }); +} +/** + * 订单发货信息获取 + */ +export function getAdminOrderDelivery(orderId) { + return request.get( "admin/order/delivery/gain/" + orderId,{},{ login: true }); +} +/** + * 订单发货保存 + */ +export function setAdminOrderDelivery(merId,id,data) { + return request.post("admin/"+merId+"/delivery/"+ id, data, { login: true }); +} +/** + * 订单统计图 + */ +export function getStatisticsTime(data) { + return request.get("admin/order/time", data, { login: true }); +} +/** + * 线下付款订单确认付款 + */ +export function setOfflinePay(merId, data) { + return request.post("admin/"+merId+"/order/offline", data, { login: true }); +} +/** + * 订单确认退款 + */ +export function setOrderRefund(merId,data) { + return request.post("admin/"+merId+"/order/refund", data, { login: true }); +} + +/** + * 获取快递公司 + * @returns {*} + */ +export function getLogistics() { + return request.get("logistics", {}, { login: false }); +} +/** + * 订单核销 + * @returns {*} + */ +export function orderVerific(merId, id, data) { + return request.post(`verifier/${merId}/${id}`,data); +} +/** + * 核销订单详情 + * @returns {*} + */ +export function verifierOrder(mer_id,code) { + return request.get("verifier/"+mer_id+"/order/"+code); +} +/** + * 订单统计数 + * @returns {*} + */ +export function orderStatistics(mer_id) { + return request.get("admin/"+mer_id+"/statistics"); +} +/** + * 每日成交额 + * @returns {*} + */ +export function orderPrice(where, mer_id) { + return request.get("admin/"+mer_id+"/order_price", where, { login: true }); +} +/** + * 订单列表 + * @returns {*} + */ +export function getOrderList(where, merId) { + return request.get(`admin/${merId}/order_list`, where, { login: true }); +} +/** + * 退款订单列表 + * @returns {*} + */ +export function getRefundOrderList(where, merId) { + return request.get(`server/${merId}/refund/lst`, where, { login: true }); +} +/** + * 营业额统计 + * @returns {*} + */ +export function turnoverStatistics(where, merId) { + return request.get(`admin/${merId}/pay_price`, where, { login: true }); +} +/** + * 订单统计 + * @returns {*} + */ +export function orderNumberStatistics(where, merId) { + return request.get(`admin/${merId}/pay_number`, where, { login: true }); +} +/** + * 获取订单打印默认配置 + * @returns {*} + */ +export function orderDeliveryInfo(merId) { + return request.get(`admin/${merId}/mer_form`); +} +/** + * 获取电子面单列表 + * @returns {*} + */ +export function orderExportTemp(data) { + return request.get("store/expr/temps", data); +} +/** + * 是否开始电子面单和同城配送 + * @returns {*} + */ +export function getTempAndDelivery(merId) { + return request.get(`admin/${merId}/delivery_config`); +} +/** + * 获取同城配送门店列表 + * @returns {*} + */ +export function getDeliveryStoreLst(merId) { + return request.get(`admin/${merId}/delivery_options`); +} +/** + * 退款订单信息 + * @returns {*} + */ +export function getRefundOrderInfo(merId,id) { + return request.get(`server/${merId}/refund/get/${id}`); +} +/** + * 提交退款订单信息 + * @returns {*} + */ +export function refundOrderSubmit(merId,id,data) { + return request.post(`server/${merId}/refund/status/${id}`,data, { login: true }); +} +/** + * 退款单确认收货 + * @returns {*} + */ +export function refundOrderReceive(merId,id) { + return request.post(`server/${merId}/refund/confirm/${id}`,{}, { login: true }); +} +/** + * 退款单详情 + */ +export function getRefundOrderDetail(merId, orderId) { + return request.get(`server/${merId}/refund/detail/${orderId}`,{}, { login: true }); +} +/** + * 添加退款单备注信息 + */ +export function setRefundMark(merId, orderId, data) { + return request.post(`server/${merId}/refund/mark/${orderId}`,data, { login: true }); +} +/** + * 去核销 + * @param object data +*/ +export function orderCancellation(merId,id){ + return request.post(`admin/${merId}/verify/${id}`); +} +/** + * 手动退款 -- 订单详情 + */ +export function getRefundOrderApi(merId, orderId) { + return request.get(`server/${merId}/refund/check/${orderId}`,{}, { login: true }); +} +/** + * 手动退款 -- 确认退款 + */ +export function confirmRefundApi(merId, data) { + return request.post(`server/${merId}/refund/create`,data, { login: true }); +} +/** + * 手动退款 -- 计算退款金额 + */ +export function computeRefundPrice(merId,data) { + return request.post(`server/${merId}/refund/compute`,data, { login: true }); +} +/** + * 扫码上传 -- 上传图片 + */ +export function scanUpload(field,token,data) { + return request.post(`scan_upload/image/${field}/${token}`,data, { login: true }); +} \ No newline at end of file diff --git a/api/api.js b/api/api.js new file mode 100644 index 0000000..9207bb4 --- /dev/null +++ b/api/api.js @@ -0,0 +1,340 @@ + +import request from "@/utils/request.js"; +/** + * 公共接口 ,优惠券接口 , 行业此讯 , 手机号码注册 + * +*/ +/** + * 获取主页数据 无需授权 + * +*/ +export function getIndexData() +{ + return request.get("common/home",{},{ noAuth : true}); +} +/** + * 获取app版本 + */ +export function getAppVersion() { + return request.get('appVersion',{},{noAuth:true}); +} +/** + * 获取登录授权login + * +*/ +export function getLogo() +{ + return request.get('wechat/get_logo', {}, { noAuth : true}); +} +/** + * 保存form_id + * @param string formId + */ +export function setFormId(formId) { + return request.post("wechat/set_form_id", { formId: formId}); +} +/** + * 领取优惠卷 + * @param int couponId + * +*/ +export function setCouponReceive(couponId){ + return request.post('coupon/receive/'+couponId); +} +/** + * 商铺优惠券列表 + * @param object data +*/ +export function getShopCoupons(id){ + return request.get('coupon/store/'+id,{},{ noAuth: true}) +} +/** + * 商品优惠券列表 + * @param object data +*/ +export function getCoupons(data){ + return request.get('coupon/product',data,{ noAuth: true}) +} +/** + * 我的优惠券 + * @param int types 0全部 1未使用 2已使用 +*/ +export function getUserCoupons(data){ + return request.get('coupon/list',data) +} +/** + * 文章分类列表 + * +*/ +export function getArticleCategoryList(){ + return request.get('article/category/lst',{},{noAuth:true}) +} +/** + * 文章列表 + * @param int cid + * +*/ +export function getArticleList(cid,data){ + return request.get('article/lst/' + cid, data,{noAuth:true}) +} +/** + * 文章 热门列表 + * +*/ +export function getArticleHotList(){ + return request.get('article/hot/list',{},{noAuth:true}); +} +/** + * 文章 轮播列表 + * +*/ +export function getArticleBannerList(){ + return request.get('article/banner/list',{},{noAuth:true}) +} +/** + * 文章详情 + * @param int id + * +*/ +export function getArticleDetails(id){ + return request.get('article/detail/'+id,{},{noAuth:true}); +} +/** + * 手机号+验证码登录接口 + * @param object data +*/ +export function loginMobile(data){ + return request.post('login/mobile',data,{noAuth:true}) +} +/** + * 获取短信KEY + * @param object phone +*/ +export function verifyCode(){ + return request.get('verify_code', {},{noAuth:true}) +} +/** + * 验证码发送 + * @param object phone +*/ +export function registerVerify(phone, reset, key, code){ + return request.post('register/verify', { phone: phone, type: reset === undefined ? 'reset' : reset, key: key, code: code },{noAuth:true}) +} +/** + * 手机号注册 + * @param object data + * +*/ +export function phoneRegister(data){ + return request.post('register',data,{noAuth:true}); +} +/** + * 手机号修改密码 + * @param object data + * +*/ +export function phoneRegisterReset(data){ + return request.post('register/reset',data,{noAuth:true}) +} +/** + * 手机号+密码登录 + * @param object data + * +*/ +export function phoneLogin(data){ + return request.post('login',data,{noAuth:true}) +} +/* h5切换公众号登陆 */ +export function switchH5Login(data) { + return request.post("user/switch", data); +} +/** 绑定手机号 */ +export function bindingPhone(data){ + return request.post('user/binding',data); +} +/** 修改手机号 */ +export function modifyPhone(data){ + return request.post('user/change/phone',data); +} +/** 修改密码 */ +export function modifyPassword(data){ + return request.post('user/change/password',data); +} +/** 退出登錄 */ +export function logout(){ + return request.get('logout'); +} +/** 获取订阅消息id */ +export function getTemlIds(){ + return request.get('wechat/teml_ids', {}, { noAuth:true}); +} +/** 首页拼团数据 */ +export function pink(){ + return request.get('pink', {}, { noAuth:true}); +} +/** 获取城市信息 */ +export function getCity() { + return request.get('system/city/lst', { }, { noAuth: true }); +} +export function getCityV2(pid) { + return request.get('v2/system/city/lst/'+pid, {}, {noAuth: true}); +} +export function getCityList(address){ + return request.get('v2/system/city', {address}, {noAuth: true}); +} +/** 获取小程序直播列表 */ +export function getLiveList(page,limit) { + return request.get('wechat/live', { page, limit}, { noAuth: true }); +} +/* APP登录 */ +export function wechatAppAuth(data) { + return request.post("auth/app", data, { noAuth: true }); +} +/* APPLE登录 */ +export function appleAppAuth(data) { + return request.post("auth/apple", data, { noAuth: true }); +} +/* 小程序获取手机号解密 */ +export function appletsDecrypt(data) { + return request.post("user/mp/binding", data); +} +/** + * 获取首页DIY; + */ +export function getDiy(data) { + return request.get('diy',data,{ noAuth: true }); +} +/** + * 获取首页微页面; + */ +export function getPageDiy(data) { + return request.get(`micro`, data, { + noAuth: true + }); +} +/** + * 滑块信息 + * @param {Object} data + */ +export function getAjcaptcha(data) { + return request.get("ajcaptcha", data, { + noAuth: true + }); +} +/** + * 滑块验证 + * @param {Object} data + */ +export function ajcaptchaCheck(data) { + return request.post("ajcheck", data, { + noAuth: true + }); +} +/** + * 滑块信息 + * @param {Object} data + */ +export function getOpenAdv() { + return request.get("open_screen", {}, { + noAuth: true + }); +} +/** + * diy-秒杀 + * @param {Object} data + */ +export function getSeckillData(data) { + return request.get("diy/seckill", data, { + noAuth: true + }); +} +/** + * diy-预售 + * @param {Object} data + */ +export function getPresellData(data) { + return request.get("diy/presell", data, { + noAuth: true + }); +} +/** + * diy-助力 + * @param {Object} data + */ +export function getAssistData(data) { + return request.get("diy/assist",data, { + noAuth: true + }); +} +/** + * diy-拼团 + * @param {Object} data + */ +export function getCombinationData(data) { + return request.get("diy/group", data, { + noAuth: true + }); +} +/** + * diy-商品列表 + * @param {Object} data + */ +export function getProductData(data) { + return request.get("diy/spu", data, { + noAuth: true + }); +} +/** + * diy-社区列表 + * @param {Object} data + */ +export function graphicLstData(data) { + return request.get("diy/community",data, { + noAuth: true + }); +} +/** + * diy-商户列表 + * @param {Object} data + */ +export function storeList(data) { + return request.get("diy/store",data, { + noAuth: true + }); +} +/** + * diy-优惠券列表 + * @param {Object} data + */ +export function getCouponData(data) { + return request.get("diy/coupon", data, { + noAuth: true + }); +} +/** + * diy-小程序直播 + * @param {Object} data + */ +export function getLiveData(data) { + return request.get("diy/broadcast", data, { + noAuth: true + }); +} +/** + * diy-热卖排行 + * @param {Object} data + */ +export function hotRankingList(data) { + return request.get("diy/hot_top", data, { + noAuth: true + }); +} +/** + * diy-首页二级分类 + * @param {Object} data + */ +export function getCateData(data) { + return request.get("diy/category", data, { + noAuth: true + }); +} \ No newline at end of file diff --git a/api/community.js b/api/community.js new file mode 100644 index 0000000..e23586a --- /dev/null +++ b/api/community.js @@ -0,0 +1,130 @@ + +import request from "@/utils/request.js"; + +/** 获取话题分类*/ +export function getTopicList() { + return request.get('community/category/lst', {}, { + noAuth: true + }); +} +/**已购商品列表*/ +export function boughtLstApi(data) { + return request.get('community/pay_product/lst', data); +} +/** 收藏图文列表*/ +export function collectLstApi(data) { + return request.get('community/rela_product/lst', data); +} +/** 浏览图文列表*/ +export function browseLstApi(data) { + return request.get('community/hist_product/lst', data); +} +/** 发布图文*/ +export function createPlantApi(data) { + return request.post('community/create', data); +} +/*图文编辑*/ +export function updatePlantApi(id, data) { + return request.post(`community/update/${id}`, data); +} +/*删除图文*/ +export function deletePlantApi(id) { + return request.post(`community/delete/${id}`); +} +/** 图文详情*/ +export function plantDetailApi(id) { + return request.get(`community/show/${id}`, {}, { + noAuth: true + }); +} +/** 订单关联图文商品*/ +export function orderAssociatePlantApi(orderId) { + return request.get(`community/order/${orderId}`, {}, { + noAuth: true + }); +} +/**评论列表*/ +export function replyLstApi(id, data) { + return request.get(`community/${id}/reply`, data, { + noAuth: true + }); +} +/**发布评论*/ +export function replyCreateApi(id, data) { + return request.post(`community/reply/create/${id}`, data); +} +/**点赞评论*/ +export function starCommentApi(id, data) { + return request.post(`community/reply/start/${id}`, data); +} +/**关注用户*/ +export function followAuthorApi(id, data) { + return request.post(`community/fans/${id}`, data); +} +/**全部图文列表*/ +export function graphicLstApi(data) { + return request.get(`community/lst`, data, { + noAuth: true + }); +} +/**视频列表*/ +export function videoList(data) { + return request.get(`community/video_lst`, data, { + noAuth: true + }); +} +/**自己的视频列表*/ +export function myVideoList(id,data) { + return request.get(`community/user/community_video/${id}`, data, { + noAuth: true + }); +} +/**文章点赞*/ +export function graphicStartApi(id, status) { + return request.post(`community/start/${id}`, status); +} +/**用户详情*/ +export function userInfoApi(id) { + return request.get(`community/user/info/${id}`); +} +/**关注人的文章列表*/ +export function focusArticleLst(data) { + return request.get(`community/focuslst`, data, { + noAuth: true + }); +} +/**用户的文章列表*/ +export function userArticleLst(id, data) { + return request.get(`community/user/community/${id}`, data); +} +/**赞过的图文*/ +export function starArticleLst(data) { + return request.get(`community/start/lst`, data); +} +/**我的关注*/ +export function myFocusLst(data) { + return request.get(`community/focus/lst`, data); +} +/**我的粉丝*/ +export function myFansLst(data) { + return request.get(`community/fans/lst`, data); +} +/**热门搜索*/ +export function hotSearchLst() { + return request.get(`common/commuunity/hot_keyword`,{}, { + noAuth: true + }); +} +/**热门搜索*/ +export function graphicProApi(id) { + return request.get(`product/spu/get/${id}`, {}, { + noAuth: true + }); +} +/*视频分享二维码*/ + +export function getVideoCode(id, data) { + return request.get(`community/qrcode/${id}`, data, { + noAuth: true + }); +} \ No newline at end of file diff --git a/api/order.js b/api/order.js new file mode 100644 index 0000000..456d6ec --- /dev/null +++ b/api/order.js @@ -0,0 +1,335 @@ + +import request from "@/utils/request.js"; + +/** + * 获取购物车列表 + * @param numType boolean true 购物车数量,false=购物车产品数量 + */ +export function getCartCounts() { + return request.get("user/cart/count"); +} +/** + * 获取购物车列表 + * + */ +export function getCartList() { + return request.get("user/cart/lst"); +} + +/** + * 修改购物车数量 + * @param int cartId 购物车id + * @param int number 修改数量 + */ +export function changeCartNum(cartId, data) { + return request.post("user/cart/change/"+cartId,data); +} +/** + * 清除购物车 + * @param object ids +*/ +export function cartDel(data){ + return request.post('user/cart/delete', data); +} +/** + * 购物车商品属性 + * @param object ids +*/ +export function cartProductAttr(id){ + return request.get(`store/product/get_attr_value/${id}`); +} +/** + * 订单列表 + * @param object data +*/ +export function getOrderList(data){ + return request.get('order/list',data); +} + +/** + * 订单产品信息 + * @param string unique +*/ +export function orderProduct(orderId){ + return request.get('reply/product/'+orderId); +} + +/** + * 订单评价 + * @param object data + * +*/ +export function orderComment(id,data){ + return request.post('reply/'+id,data); +} + +/** + * 订单支付 + * @param object data +*/ +export function orderPay(id,data){ + return request.post('order/pay/'+id,data); +} + +/** + * 积分商品订单支付 + * @param object data +*/ +export function integralOrderPay(id,data){ + return request.post('order/points/pay/'+id,data); +} +/** + * 订单统计数据 +*/ +export function orderData(){ + return request.get('order/number') +} + +/** + * 订单取消 + * @param string id + * +*/ +// export function orderCancel(id){ +// return request.post('order/cancel',{id:id}); +// } + +/** + * 未支付订单取消 + * @param string id + * +*/ +export function unOrderCancel(id){ + return request.post('order/cancel/'+id); +} + +/** + * 删除已完成订单 + * @param string uni + * +*/ +export function orderDel(id){ + return request.post('order/del/'+id); +} + +/** + * 订单详情 + * @param string uni +*/ +export function getOrderDetail(uni){ + return request.get('order/detail/'+uni); +} + +/** + * 订单详情 + * @param string uni +*/ +export function groupOrderDetail(uni){ + return request.get('order/group_order_detail/'+uni); +} + +// 支付状态订单 +export function getPayOrder(uni){ + return request.get('order/status/'+uni); +} + +/** + * 再次下单 + * @param string uni + * +*/ +export function orderAgain(data){ + return request.post('user/cart/again',data); +} + +/** + * 订单收货 + * @param string uni + * +*/ +export function orderTake(uni){ + return request.post('order/take/'+uni); +} + +/** + * 订单查询物流信息 + * @returns {*} + */ +export function express(id) { + return request.post("order/express/" + id); +} +/** + * 退款单查询物流信息 + * @returns {*} + */ +export function refundOrderExpress(merId,id) { + return request.get(`server/${merId}/refund/express/${id}`); +} +/** + * 获取退款理由 + * +*/ +export function ordeRefundReason(){ + return request.get('order/refund/reason'); +} + +/** + * 订单退款审核 + * @param object data +*/ +export function orderRefundVerify(data){ + return request.post('order/refund/verify',data); +} + +/** + * 订单确认获取订单详细信息 + * @param string cartId +*/ +export function orderConfirm(data){ + return request.post('order/check', data); +} +/** + * 订单确认获取订单详细信息 + * @param string cartId +*/ +export function getOrderConfirm(data){ + return request.post('v2/order/check', data); +} +/** + * 获取当前金额能使用的优惠卷 + * @param string price + * +*/ +export function getCouponsOrderPrice(price, data){ + return request.get('coupons/order/' + price, data) +} + + + +/** + * 计算订单金额 + * @param key + * @param data + * @returns {*} + */ +export function postOrderComputed(key, data) { + return request.post("/order/computed/" + key, data); +} + +// 生成订单 +export function orderCreate(data) { + return request.post("order/create",data,{ noAuth : true }); +} +// 新的生成订单 +export function createOrder(data) { + return request.post("v2/order/create",data,{ noAuth : true }); +} +// 未支付订单 +export function groupOrderList(data) { + return request.get("order/group_order_list",data,{ noAuth : true }); +} + +// 批量退款列表 +export function refundBatch(id) { + return request.get("refund/batch_product/"+id,{ noAuth : true }); +} + +// 退款商品 +export function refundProduct(id,data) { + return request.get("refund/product/"+id,data,{ noAuth : true }); +} + +// 申请退款 +export function refundApply(id,data) { + return request.post("refund/apply/"+id,data,{ noAuth : true }); +} + +// 退款理由 +export function refundMessage() { + return request.get("common/refund_message",{ noAuth : true }); +} + +// 退款列表 +export function refundList(data) { + return request.get("refund/list",data,{ noAuth : true }); +} + +// 退款详情 +export function refundDetail(id) { + return request.get("refund/detail/"+id,{ noAuth : true }); +} + +// 物流列表 +export function expressList() { + return request.get("common/express"); +} + +// 退回商品提交 +export function refundBackGoods(id,data) { + return request.post("refund/back_goods/"+id,data,{ noAuth : true }); +} + +// 退款记录删除 +export function refundDel(id) { + return request.post("refund/del/"+id,{ noAuth : true }); +} + +// 退款记录删除 +export function refundExpress(id) { + return request.get("refund/express/"+id,{ noAuth : true }); +} + +// 核销二维码 +export function verifyCode(id) { + return request.get("order/verify_code/"+id); +} +/** + * 预售尾款支付 + * @param object data +*/ +export function presellOrderPay(id,data){ + return request.post('presell/pay/'+id,data); +} + +/** + * 发票订单 + * @param object data +*/ +export function receiptOrder(data){ + return request.get('user/receipt/order',data); +} +/** + * 发票订单 + * @param object data +*/ +export function getReceiptOrder(id){ + return request.get('user/receipt/order/'+id); +} +/** + * 发票订单 + * @param object data +*/ +export function getCallBackUrlApi(key){ + return request.get('common/pay_key/'+key, {},{ noAuth : true}); +} +/** + * 发票订单 + * @param object data +*/ +export function develiveryDetail(id){ + return request.get(`order/delivery/${id}`); +} +/** + * 订单申请开票 + * @param object data +*/ +export function applyInvoiceApi(id, data){ + return request.post(`order/receipt/${id}`, data); +} +/** + * 退款单取消申请 + * @param object data +*/ +export function refundCancelApi(id){ + return request.post(`refund/cancel/${id}`); +} \ No newline at end of file diff --git a/api/points_mall.js b/api/points_mall.js new file mode 100644 index 0000000..6de26fc --- /dev/null +++ b/api/points_mall.js @@ -0,0 +1,70 @@ +// +---------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +---------------------------------------------------------------------- +// | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved. +// +---------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +---------------------------------------------------------------------- +// | Author: CRMEB Team +// +---------------------------------------------------------------------- +import request from "@/utils/request.js"; +/** + * 积分商城--banner和金刚区 + */ +export function getIntegralHome() { + return request.get("points/home",{},{noAuth: true}); +} +/** + * 积分商城--积分兑换区间 + */ +export function getIntegralScope() { + return request.get("points/scope",{},{noAuth: true}); +} +/** + * 积分商城--商品列表 + */ +export function getIntegralGoodsList(data) { + return request.get("points/lst",data,{noAuth: true}); +} +/** + * 积分商城--商品列表 + */ +export function getIntegralProductDetail(id) { + return request.get(`points/detail/${id}`,{},{noAuth: true}); +} +/** + * 积分商城--生成订单 + */ +export function integralOrderConfirm(data) { + return request.post(`order/v3/check`,data,{noAuth: true}); +} +/** + * 积分商城--下单 + */ +export function integralOrderCreate(data) { + return request.post(`order/v3/create`,data,{noAuth: true}); +} +/** + * 积分商城--订单列表 + */ +export function integralOrderList(data) { + return request.get(`points/order/lst`,data,{noAuth: true}); +} +/** + * 积分商城--订单详情 + */ +export function integralOrderDetail(id) { + return request.get(`points/order/detail/${id}`,{},{noAuth: true}); +} +/** + * 积分商城--订单详情 + */ +export function integralOrderTake(id) { + return request.post(`points/order/take/${id}`,{},{noAuth: true}); +} +/** + * 积分商城--删除 + */ +export function integralOrderDelete(id) { + return request.post(`points/order/deleate/${id}`,{},{noAuth: true}); +} \ No newline at end of file diff --git a/api/product.js b/api/product.js new file mode 100644 index 0000000..f2befa8 --- /dev/null +++ b/api/product.js @@ -0,0 +1,206 @@ + +import request from "@/utils/request.js"; + +/** + * 商品列表 + */ +export function productLstApi(merId, data) { + return request.get(`server/${merId}/product/lst`, data, { login: true }); +} + +/** + * 商品列表 -- 删除 + */ +export function productDeleteApi(merId, id) { + return request.post(`server/${merId}/product/delete/${id}`, {}, { login: true }); +} +/** + * 商品列表 -- 上下架 + */ +export function productOffApi(merId, id, data) { + return request.post(`server/${merId}/product/status/${id}`, data, { login: true }); +} + +/* + 售罄商品 -- 列表头部 +*/ + +export function productTitle(merId, data) { + return request.get(`server/${merId}/product/title`, data, { login: true }); +} + +/* + 回收站商品,彻底删除 +*/ + +export function productDestory(merId, id, data) { + return request.post(`server/${merId}/product/destory/${id}`, data, { login: true }); +} + +/* + 还原 +*/ + +export function productRestore(merId, id) { + return request.post(`server/${merId}/product/restore/${id}`, {}, { login: true }); +} + +/* + 添加或修改商品, 获取商品品牌 +*/ + +export function categoryBrandlist(merId) { + return request.get(`server/${merId}/category/brandlist`, {}, { login: true }); +} + +/* + 添加修改商品, 获取商户分类 +*/ + +export function categorySelect(merId) { + return request.get(`server/${merId}/category/select`, {}, { login: true }) +} + +/* + 添加修改商品, 获取平台分类 +*/ + +export function categoryList(merId) { + return request.get(`server/${merId}/category/list`, {}, { login: true }) +} + +/* + 商品管理, 添加商品 +*/ + +export function productCreate(merId, data) { + return request.post(`server/${merId}/product/create`, data, { login: true }) +} +/** + * 商品列表 -- 设置推荐 + */ +export function productRecommendApi(merId, id, data) { + return request.post(`server/${merId}/product/good/${id}`, data, { login: true }); +} + +/* + 获取规格列表 +*/ + +export function attrList(merId, data) { + return request.get(`server/${merId}/attr/lst`, data, { login: true }) +} +/* + 请求运费模板 +*/ +export function templateList(merId, data) { + return request.get(`server/${merId}/template/lst`, data, { login: true }) +} +/* + 运费模板 -- 删除 +*/ +export function templateDelete(merId, data) { + return request.post(`server/${merId}/template/delete`, data, { login: true }) +} +/** + * 运费模板 -- 详情 + */ +export function templateDetail(merId, id) { + return request.get(`server/${merId}/template/detail/${id}`, {}, { login: true }); +} +/* + 运费模板 -- 添加 +*/ +export function templateCreate(merId, data) { + return request.post(`server/${merId}/template/create`, data, { login: true }); +} +/* + 运费模板 -- 编辑 +*/ +export function templateUpdate(merId, id, data) { + return request.post(`server/${merId}/template/update/${id}`, data, { login: true }); +} +/** + * 店铺分类 -- 列表 + */ +export function storeClassifyLst(merId) { + return request.get(`server/${merId}/category/lst`, {}, { login: true }); +} +/** + * 店铺分类 -- 列表(删除) + */ +export function storeClassifyDel(merId, id) { + return request.post(`server/${merId}/category/delete/${id}`, {}, { login: true }); +} +/** + * 上级分类 -- 商户列表 + */ +export function merClassifyLst(merId) { + return request.get(`server/${merId}/category/select`, {}, { login: true }); +} +/** + * 店铺分类 -- 添加 + */ +export function merClassifyAdd(merId, data) { + return request.post(`server/${merId}/category/create`, data, { login: true }); +} +/** + * 店铺分类 -- 详情 + */ +export function merClassifyDetail(merId, id) { + return request.get(`server/${merId}/category/detail/${id}`, {}, { login: true }); +} +/** + * 店铺分类 -- 编辑 + */ +export function merClassifyUpdate(merId, id, data) { + return request.post(`server/${merId}/category/update/${id}`, data, { login: true }); +} +/** + * 商品规格项目 -- 列表 + */ +export function specificationLst(merId, data) { + return request.get(`server/${merId}/attr/lst`, data, { login: true }); +} +/** + * 商品规格项目 -- 删除 + */ +export function specificationDel(merId, data) { + return request.post(`server/${merId}/attr/delete`, data, { login: true }); +} +/** + * 商品规格项目 -- 添加 + */ +export function specificationAdd(merId, data) { + return request.post(`server/${merId}/attr/create`, data, { login: true }); +} +/** + * 商品规格项目 -- 编辑 + */ +export function specificationUpdate(merId, id, data) { + return request.post(`server/${merId}/attr/update/${id}`, data, { login: true }); +} +/** + * 商品规格项目 -- 详情 + */ +export function specificationDetail(merId, id) { + return request.get(`server/${merId}/attr/detail/${id}`, {}, { login: true }); +} +/* + 请求商品详情 +*/ +export function productDetail(merId, id) { + return request.get(`server/${merId}/product/detail/${id}`, {}, {login: true}); +} +/* + 编辑商品 +*/ +export function productUpdate(merId, id, data) { + return request.post(`server/${merId}/product/update/${id}`, data, { login: true }); +} +/* + 添加商品 -- 获取送货方式信息 +*/ +export function getDeliveryType(merId) { + return request.get(`server/${merId}/product/config`, {}, { login: true }); +} diff --git a/api/public.js b/api/public.js new file mode 100644 index 0000000..9b3ca84 --- /dev/null +++ b/api/public.js @@ -0,0 +1,116 @@ + +import request from "@/utils/request.js"; +import wechat from "@/libs/wechat.js"; + +/** + * 获取微信sdk配置 + * @returns {*} + */ +export function getWechatConfig() { + return request.get( + "wechat/config", { + url: wechat.signLink() + }, { + noAuth: true + } + ); +} + +/** + * 获取微信sdk配置 + * @returns {*} + */ +export function wechatAuth(code, spread, login_type) { + return request.get( + "auth/wechat", { + code, + spread, + login_type + }, { + noAuth: true + } + ); +} + +export function commonAuth(data) { + return request.post( + "auth", data, { + noAuth: true + } + ); +} +/** + * 获取登录授权login + * + */ +export function getLogo() { + return request.get('wechat/get_logo', {}, { + noAuth: true + }); +} +/** + * 小程序用户登录 + * @param data object 小程序用户登陆信息 + */ +export function login(data) { + return request.post("auth/mp", data, { + noAuth: true + }); +} +/** + * 分享 + * @returns {*} + */ +export function getShare() { + return request.get("share", {}, { + noAuth: true + }); +} +/** + * 获取关注海报 + * @returns {*} + */ +export function follow() { + return request.get("wechat/follow", {}, { + noAuth: true + }); +} +/** + * 获取图片base64 + * @retins {*} + * */ +export function imageBase64(image, code) { + return request.post( + "common/base64", { + image: image, + code: code + }, { + noAuth: true + } + ); +} +// 配置 +export function getconfig(data) { + return request.get("config",data,{noAuth: true}); +} +// 浏览记录 +export function history(data) { + return request.post("common/visit",data); +} +export function getSubscribe(){ + return request.get("subscribe", {}, { + noAuth: true + }); +} +export function getVersion() { + return request.get("version",{},{noAuth: true}); +} +/** + * 获取组件底部菜单 + * @param data object 获取组件底部菜单 + */ +export function getNavigation(data) { + return request.get("navigation", data, { + noAuth: true + }); +} \ No newline at end of file diff --git a/api/store.js b/api/store.js new file mode 100644 index 0000000..ede35ab --- /dev/null +++ b/api/store.js @@ -0,0 +1,579 @@ + +import request from "@/utils/request.js"; +/** + * 获取产品详情 + * @param int id + * + */ +export function getProductDetail(id) { + return request.get('store/product/detail/' + id, {}, { + noAuth: true + }); +} +/** + * 获取产品详情参数 + * @param int id + * + */ +export function getProductParmas(id) { + return request.get('store/product/show/' + id, {}, { + noAuth: true + }); +} +/** + * 获取店铺推荐商品 + * @param int id + * + */ +export function getStoreRecommend(id) { + return request.get('store/product/good_list/' + id, {}, { + noAuth: true + }); +} +/** + * 获取预览商品详情 + * @param int id + * + */ +export function getPreviewProDetail(data) { + return request.get('store/product/preview', data, { + noAuth: true + }); +} +/** + * 产品分享二维码 推广员 + * @param int id + */ +export function getProductCode(id, data) { + return request.get('store/product/qrcode/' + id, data); +} +/** + * 添加收藏 + * @param int id + * @param string category product=普通产品,product_seckill=秒杀产品 + */ +export function collectAdd(data) { + return request.post('user/relation/create', data); +} +/** + * 删除收藏产品 + * @param int id + * @param string category product=普通产品,product_seckill=秒杀产品 + */ +export function collectDel(data) { + return request.post('user/relation/delete', data); +} +/** + * 购车添加 + * + */ +export function postCartAdd(data) { + return request.post('user/cart/create', data); +} +/** + * 获取分类列表 + * + */ +export function getCategoryList() { + return request.get('store/product/category/lst', {}, { + noAuth: true + }); +} +/** + * 获取产品列表 + * @param object data + */ +export function getProductslist(data) { + if (data.brand_id && Array.isArray(data.brand_id)) { + data = { + ...data + } + data.brand_id = data.brand_id.toString() + } + return request.get('product/spu/lst', data, { + noAuth: true + }); +} +/** + * 获取优惠券商品列表 + * @param object data + */ +export function getCouponProductlist(data) { + if (data.brand_id && Array.isArray(data.brand_id)) { + data = { + ...data + } + data.brand_id = data.brand_id.toString() + } + return request.get('product/spu/coupon_product', data, { + noAuth: true + }); +} +/** + * 获取品牌列表 + * @param object data + */ +export function getBrandlist(data) { + return request.get('store/product/brand/lst', data, { + noAuth: true + }); +} +/** + * 获取推荐产品 + * + */ +export function getProductHot(page, limit) { + return request.get("product/spu/recommend", { + page: page === undefined ? 1 : page, + limit: limit === undefined ? 10 : limit + }, { + noAuth: true + }); +} +/** + * 获取商户推荐产品 + * + */ +export function getMerProductHot(id,data) { + return request.get(`product/spu/recommend`, { + page: data.page === undefined ? 1 : data.page, + limit: data.limit === undefined ? 10 : data.limit, + mer_id: id || '' + }, { + noAuth: true + }); +} +/** + * 批量收藏 + * + * @param object id + * @param string category + */ +export function collectAll(data) { + return request.post('user/relation/batch/create', data); +} +/** + * 首页产品的轮播图和产品信息 + * @param int type + * + */ +export function getGroomList(type, data) { + return request.get('product/spu/hot/' + type, data, { + noAuth: true + }); +} +/** + * 获取商品收藏列表 + * @param object data + */ +export function getCollectUserList(data) { + return request.get('user/relation/product/lst', data) +} +/** + * 获取商品收藏列表 -- 删除 + * @param object data + */ +export function userCollectDel(data) { + return request.post('user/relation/batch/delete', data) +} +/** + * 获取产品评论 + * @param int id + * @param object data + * + */ +export function getReplyList(id, data) { + return request.get('store/product/reply/lst/' + id, data, { + noAuth: true + }) +} +/** + * 产品评价数量和好评度 + * @param int id + */ +export function getReplyConfig(id) { + return request.get('reply/config/' + id); +} +/** + * 获取搜索关键字获取 + * + */ +export function getSearchKeyword() { + return request.get('common/hot_keyword', {}, { + noAuth: true + }); +} +/** + * 今日热搜列表 + * + */ +export function getTodayHotSearch() { + return request.get('product/spu/hot_lst', {}, { + noAuth: true + }); +} +/** + * 热销排行分类 + * + */ +export function getHotRanking() { + return request.get('product/spu/hot_top', {}, { + noAuth: true + }); +} +/** + * 商户列表 + * @returns {*} + */ +export function storeMerchantList(data) { + return request.get("store/merchant/lst", data, { + noAuth: true + }); +} +/** + * 获取商铺详情 + * @param {Object} id 商铺id + * @param {Object} data 商铺数据 + */ +export function getStoreDetail(id, data) { + return request.get("store/merchant/detail/" + id, data, { + noAuth: true + }); +} +/** + * 获取商铺商品列表 + * @param {Object} id 商铺 id + * @param {Object} data 商铺商品列表数据 + */ +export function getStoreGoods(id, data) { + return request.get("product/spu/merchant/" + id, data, { + noAuth: true + }); +} +/** + * 获取商铺分类列表 + * @param {Object} id 商铺 id + * @param {Object} data + */ +export function getStoreCategory(id, data) { + return request.get("store/merchant/category/lst/" + id, data, { + noAuth: true + }); +} +/** + * 关注商铺 + * @param {Object} type_id 商铺 id + */ +export function followStore(type_id) { + return request.post("user/relation/create", { + type: 10, + type_id: type_id + }); +} +/** + * 取消商铺关注 + * @param {Object} type_id 商铺 id + */ +export function unfollowStore(type_id) { + return request.post("user/relation/delete", { + type: 10, + type_id: type_id + }); +} +/** + * 获取商铺优惠券 + * @param {Object} id + */ +export function getStoreCoupon(id) { + return request.get("coupon/store/" + id, { + noAuth: true + }); +} +/** + * 获取商铺优惠券 + */ +export function getMerchantLst(data) { + return request.get("user/relation/merchant/lst", data, { + noAuth: true + }); +} +/** + * 物流信息 + */ +export function express(id) { + return request.post("ordero/express/" + id, { + noAuth: true + }); +} +/** + * 子集分类 + * @returns {*} + */ +export function storeCategory(pid) { + return request.get("store/product/category", pid, { + noAuth: true + }); +} +/** + * 分销说明 + * @returns {*} + */ +export function bagExplain() { + return request.get("store/product/bag/explain"); +} +/** + * 分销礼包推荐列表 + * @returns {*} + */ +export function bagRecommend() { + return request.get("product/spu/bag/recommend"); +} +/** + * 分销礼包列表 + * @returns {*} + */ +export function productBag(data) { + + return request.get("product/spu/bag", data, { + noAuth: true + }); +} +/** + * 商铺二维码 + * @returns {*} + */ +export function merchantQrcode(id, data) { + return request.get("store/merchant/qrcode/" + id, data, { + noAuth: true + }); +} +/** + * 推荐商品 + * @returns {*} + */ +export function merchantProduct(id, data) { + if (data.brand_id && Array.isArray(data.brand_id)) { + data = { + ...data + } + data.brand_id = data.brand_id.toString() + } + return request.get("product/spu/merchant/" + id, data, { + noAuth: true + }); +} +/** + * 推荐商品banner + * @returns {*} + */ +export function getHotBanner(type) { + return request.get("common/hot_banner/" + type, {}, { + noAuth: true + }); +} +/** + * 商户入驻表单 + * @returns {*} + */ +export function create(data) { + return request.post("intention/create", data); +} +/** + * 商户入驻短信验证码 + * @returns {*} + */ +export function verify(data) { + return request.post("auth/verify", data); +} +/** + * 获取秒杀商品详情 + * @param int id + * + */ +export function getSeckillProductDetail(id) { + return request.get('store/product/seckill/detail/' + id, {}, { + noAuth: true + }); +} +/** + * 获取秒杀商品详情参数 + * @param int id + * + */ +// export function getSeckillProductParmas(id) { +// return request.get('store/product/seckill/show/' + id, {}, { +// noAuth: true +// }); +// } +/** + * 直播推荐列表 + * @returns {*} + */ +export function getLiveList(data) { + return request.get(`broadcast/hot`, data, { + noAuth: true + }); +} +/** + * 直播列表 + * @returns {*} + */ +export function getBroadcastListApi(data) { + return request.get("broadcast/lst", data, { + noAuth: true + }); +} +/** + * 商户分类 + * @returns {*} + */ +export function merClassifly() { + return request.get("intention/cate", {}, { + noAuth: true + }); +} +/** + * 获取预售商品详情 + * @param int id + * + */ +export function getPresellProductDetail(id) { + return request.get('store/product/presell/detail/' + id, {}, { + noAuth: true + }); +} +/** + * 获取商户申请记录 + * @param int id + * + */ +export function getApplicationRecordList(data) { + return request.get('intention/lst', data); +} +/** + * 获取商户申请详情 + * @param int id + * + */ +export function getGoodsDetails(id) { + return request.get('intention/detail/' + id, {}); +} +/** + * 修改入驻信息 + * @param int id + * + */ +export function updateGoodsRecord(id, data) { + return request.post('intention/update/' + id, data); +} +/** + * 获取定位详细地址 + * @param int id + * + */ +export function getGeocoder(data) { + return request.get(`lbs/geocoder?location=${data.lat},${data.long}`, {}, { + noAuth: true + }); +} +/** + * 获取店铺类型 + * @param int id + * + */ +export function getStoreTypeApi(data) { + return request.get('intention/type', data, { + noAuth: true + }); +} +/** + * 获取参数列表 + * @param int id + * + */ +export function getParmasList(data) { + return request.get('product/spu/params', data, { + noAuth: true + }); +} +/** + * 获取参数值列表 + * @param int id + * + */ +export function getParmasValue(id) { + return request.get(`product/spu/params_value/${id}`, {}, { + noAuth: true + }); +} +/** + * 到货通知 + * + */ +export function arrivalNoticeApi(data) { + return request.post('store/product/increase_take',data); +} +/* + 获取图片验证码 +*/ +export function getCaptcha() { + return request.get('captcha'); +} +/* + 获取店铺资质 +*/ +export function storeCertificate(data) { + return request.post(`store/certificate/${data.merId}`, data) +} +/** + * 本地服务列表 + * @returns {*} + */ +export function storeServiceList(id, data) { + return request.get(`product/spu/local/${id}`, data, { + noAuth: true + }); +} +/** + * 复制口令 + * @returns {*} + */ +export function copyPasswordApi(data) { + return request.get(`product/spu/copy`, data, { + noAuth: true + }); +} +/** + * 口令搜索 + * @returns {*} + */ +export function copyPasswordSearch(data) { + return request.get(`command/copy`, data, { + noAuth: true + }); +} +/** + * 套餐列表 + * @returns {*} + */ +export function getDiscountsLst(data) { + return request.get(`discounts/lst`, data, { + noAuth: true + }); +} +/** + * 套餐--立即购买 + * @returns {*} + */ +export function discountsCartAdd(data) { + return request.post('user/cart/batchCreate', data); +} +/** + * 商品--价格说明 + * @returns {*} + */ +export function priceRuleApi(id) { + return request.get(`store/product/price_rule/${id}`, {}, { + noAuth: true + }); +} \ No newline at end of file diff --git a/api/user.js b/api/user.js new file mode 100644 index 0000000..64d347a --- /dev/null +++ b/api/user.js @@ -0,0 +1,763 @@ + +import request from "@/utils/request.js"; +import Cache from '@/utils/cache' +/** + * 获取用户信息 + * + */ +export function getUserInfo() { + return request.get('user'); +} +/** + * 头像 + * + */ +export function editAvatar(data) { + return request.post('user/change/info',data); +} + +// 修改昵称 +export function updateInfo(data) { + return request.post('user/change/avatar',data); +} +/** + * h5用户登录 + * @param data object 用户账号密码 + */ +export function loginH5(data) { + return request.post("auth/login", data, { + noAuth: true + }); +} +/** + * h5用户手机号登录 + * @param data object 用户手机号 也只能 + */ +export function loginMobile(data) { + return request.post("auth/smslogin", data, { + noAuth: true + }); +} +/** + * h5用户手机号登录 + * @param data object + */ +export function loginMpPhone(data) { + return request.post("auth/mp_phone", data, { + noAuth: true + }); +} +/** + * h5获取登录授权auth_token + * @param data object + */ +export function getAuthType(data) { + return request.post("auth/mp_login_type", data, { + noAuth: true + }); +} +/** + * 验证码key + */ +export function getCodeApi() { + return request.get("verify_code", {}, { + noAuth: true + }); +} + +/** + * h5用户发送验证码 + * @param data object 用户手机号 + */ +export function registerVerify(data) { + return request.post("auth/verify", data, { + noAuth: true + }); +} +/** + * h5用户手机号注册 + * @param data object 用户手机号 验证码 密码 + */ +export function register(data) { + return request.post("auth/register", data, { + noAuth: true + }); +} + +/** + * 用户手机号修改密码 + * @param data object 用户手机号 验证码 密码 + */ +export function registerReset(data) { + return request.post("/register/reset", data, { + noAuth: true + }); +} +/** + * 用户手机号忘记密码 + */ +export function registerForget(data) { + return request.post("user/change_pwd", data, { + noAuth: true + }); +} +/** + * 获取用户中心菜单 + * + */ +export function getMenuList() { + return request.get("common/menus",{},{noAuth: true}); +} +/* + * 签到用户信息 + * */ +export function getSignUser() { + return request.get("user/sign/info"); +} + +/** + * 获取签到配置 + * + */ +export function getSignConfig() { + return request.get('sign/config') +} +/** + * 获取签到列表 + * @param object data + */ +export function getSignList(data) { + return request.get('user/sign/lst', data); +} +/** + * 用户签到 + */ +export function setSignIntegral() { + return request.post('user/sign/create') +} + +/** + * 签到列表(年月) + * @param object data + * + */ +export function getSignMonthList(data) { + return request.get('user/sign/month', data) +} +/** + * 活动状态 + * + */ +export function userActivity() { + return request.get('user/activity'); +} +/* + * 资金明细(types|0=全部,1=消费,2=充值,3=返佣) + * */ +export function getCommissionInfo(q, types) { + return request.get("user/bill", q); +} +/* + * 提现列表 + * */ +export function extractLst(data) { + return request.get("user/extract/lst", data); +} +/* + * 积分记录 + * */ +export function getIntegralList(data) { + return request.get("user/integral/lst", data); +} + +/** + * 获取分销海报图片 + * + */ +export function spreadBanner() { + //#ifdef H5 + return request.get('user/spread_image', { + type: 'wechat' + }); + //#endif + //#ifdef MP + return request.get('user/spread_image', { + type: 'routine' + }); + //#endif +} +/** + * + * 获取推广用户一级和二级 + * @param object data + */ +export function spreadPeople(data) { + return request.get('user/spread_list', data); +} +/** + * + * 推广佣金/提现总和 + * @param int type + */ +export function spreadCount(type) { + return request.get('spread/count/' + type); +} +/* + * 推广数据 + * */ +export function getSpreadInfo() { + return request.get("/commission"); +} +/** + * + * 推广订单 + * @param object data + */ +export function spreadOrder(data) { + return request.get('user/spread_order', data); +} +/* + * 获取推广人排行 + * */ +export function getRankList(data) { + return request.get("user/spread_top", data); +} +/* + * 获取佣金排名 + * */ +export function getBrokerageRank(q) { + return request.get("user/brokerage_top", q); +} +/** + * 提现申请 + * @param object data + */ +export function extractCash(data) { + return request.post('user/extract/create', data) +} +/** + * 提现银行/提现最低金额 + * + */ +export function extractBank() { + return request.get('user/extract/banklst'); +} +/** + * 会员等级列表 + * + */ +export function userLevelGrade() { + return request.get('user/level/grade'); +} +/** + * 获取某个等级任务 + * @param int id 任务id + */ +export function userLevelTask(id) { + return request.get('user/level/task/' + id); +} +/** + * 检查用户是否可以成为会员 + * + */ +export function userLevelDetection() { + return request.get('user/level/detection'); +} +/** + * + * 地址列表 + * @param object data + */ +export function getAddressList(data) { + return request.get('user/address/lst', data); +} +/** + * 设置默认地址 + * @param int id + */ +export function setAddressDefault(id) { + return request.post('user/address/update/' + id) +} +/** + * 修改 添加地址 + * @param object data + */ +export function editAddress(data) { + return request.post('user/address/create', data); +} +/** + * 删除地址 + * @param int id + * + */ +export function delAddress(id) { + return request.post('user/address/delete/' + id) +} +/** + * 获取单个地址 + * @param int id + */ +export function getAddressDetail(id) { + return request.get('user/address/detail/' + id); +} +/** + * 修改用户信息 + * @param object + */ +export function userEdit(data) { + return request.post('user/edit', data); +} +/* + * 退出登录 + * */ +export function getLogout() { + return request.post("logout"); +} +/** + * 佣金转入 + * + */ +export function rechargeBrokerage(data) { + return request.post('user/recharge/brokerage', data) +} +/** + * 小程序充值 + * + */ +export function rechargeRoutine(data) { + return request.post('recharge/routine', data) +} +/* + * 公众号充值 + * */ +export function rechargeWechat(data) { + return request.post("user/recharge", data); +} +/** + * 获取默认地址 + * + */ +export function getAddressDefault() { + return request.get('address/default'); +} +/** + * 充值金额选择 + */ +export function getRechargeApi() { + return request.get("common/recharge_quota"); +} +/** + * 登陆记录 + */ +export function setVisit(data) { + return request.post('user/set_visit', { ...data + }, { + noAuth: true + }); +} +/** + * 客服列表 + */ +export function serviceList(data) { + return request.get("service/list", data); +} +/** + * 客服列表 + */ +export function serviceLogin(key, data) { + return request.post("service/scan_login/" + key, data); +} +/** + * 客服获取客户列表 + */ +export function serviceUserList(mer_id, data) { + return request.get("service/user_list/"+mer_id, data); +} +/** + * 用户获取聊天记录详情 + */ +export function getChatRecord(to_uid, data) { + return request.get("service/history/" + to_uid, data); +} +/** + * 客服获取聊天记录详情 + */ +export function getMerHistory(userid, mer_id, data) { + return request.get("service/mer_history/" + mer_id + '/' + userid, data); +} +/** + * 静默绑定推广人 + * @param {Object} puid + */ +export function spread(puid) { + Cache.set("spread", puid || 0); + return request.post("user/spread", { + spread_spid: puid + }); +} +/** + * 反馈类型 + */ +export function feedbackType() { + return request.get("common/feedback_type"); +} +/** + * 提交反馈 + */ +export function feedback(data) { + return request.post("user/feedback", { ...data + }); +} +/** + * 反馈列表 + */ +export function feedbackList(data) { + return request.get("user/feedback/list", data); +} +/** + * 反馈列表 + */ +export function feedbackDetail(id) { + return request.get("user/feedback/detail/" + id); +} +/** + * 浏览记录 + */ +export function historyList(data) { + return request.get("user/history", data); +} +/** + * 删除浏览记录 + */ +export function historyDelete(id) { + return request.post("user/history/delete/" + id); +} +/** + * 批量删除浏览记录 + */ +export function historyBatchDelete(data) { + return request.post("user/history/batch/delete", data); +} +/** + * 批量收藏浏览记录 + */ +export function historyBatchCollect(data) { + return request.post("user/relation/batch/create", data); +} +/** + * 佣金记录 + */ +export function brokerage_list(data) { + return request.get("user/brokerage_list", data); +} +/** + * 佣金数据 + */ +export function spreadInfo() { + return request.get("user/spread_info"); +} +// 图片验证码 +export function getCaptcha() { + return request.get('captcha', {}, { + noAuth: true + }); +} +// 用户账户列表 +export function userAcc() { + return request.get('user/account', {}, { + noAuth: true + }); +} +// 创建发票 +export function invoiceSave(data) { + return request.post('user/receipt/create', data); +} +// 编辑发票 +export function invoiceUpdate(id, data) { + return request.post('user/receipt/update/' + id, data); +} +// 获取默认发票 +export function invoiceDefault(id) { + return request.post('user/receipt/is_default/' + id); +} +// 发票抬头--列表 +export function invoice(data) { + return request.get('user/receipt/lst', data); +} +// 发票抬头--删除 +export function invoiceDelete(id) { + return request.post('user/receipt/delete/' + id); +} +// 发票--详情 +export function invoiceDetail(id) { + return request.get('user/receipt/detail/' + id); +} +/** + * 新版分享海报信息获取 + * + */ +export function spreadMsg(data) { + return request.get('user/v2/spread_image', data); +} +/** + * 图片链接转base64 + * + */ +export function imgToBase(data) { + return request.post('common/base64', data); +} +/** + * 获取协议 + * + */ +export function getAgreementApi(key) { + return request.get('agreement/'+key,{},{noAuth: true}); +} +/** + * 获取协议 + * + */ +export function getIntegralInfo() { + return request.get('user/integral/info'); +} +/** + * 获取店铺列表 + * + */ +export function getStoreList(data) { + return request.get('user/services', data); +} +/* + 获取佣金说明 +*/ +export function commissionDescription() { + return request.get('agreement/sys_extension_agree') +} +/* + 获取用户分销等级信息 +*/ +export function getBrokerageInfo() { + return request.get('user/brokerage/info') +} +/* + 获取用户分销等级表格数据 +*/ +export function getBrokerageGrade() { + return request.get('user/brokerage/all') +} +/* + 分销员升级提醒 +*/ +export function brokerageNotice(data) { + return request.get(`user/brokerage/notice`, data) +} +/* + 口令解析 +*/ +export function pwdResolution(data) { + return request.get(`command/copy?key=${data}`) +} +/* + 获取佣金说明 +*/ +export function getInstructions(key) { + return request.get(`agreement/${key}`) +} +/* + 会员信息 +*/ +export function memberInfo() { + return request.get('user/member/info') +} +/** + * 成长值记录 + * @param object data + * + */ +export function growthValueRecord(data) { + return request.get('user/member/log', data) +} +/** + * 协议规则列表 + * @param object data + * + */ +export function cacheLst() { + return request.get('agreement_lst',{}, {noAuth: true}) +} +/** + * 协议规则列表对应的数据 + * @param object data + * + */ +export function cacheInfo(key) { + return request.get(`agreement/${key}`,{}, {noAuth: true}) +} +/** + * 注销账户 + * @param object data + * + */ +export function userOut(data) { + return request.post(`user/cancel`, data) +} +/** + * 获取聊天用户信息 + * @param object data + * + */ +export function serviceUser(merId, uid) { + return request.get(`service/user/${merId}/${uid}`) +} +/** + * 保存聊天用户备注 + * @param object data + * + */ +export function serviceSaveMark(merId, uid, mark) { + return request.post(`service/mark/${merId}/${uid}`, {mark}) +} +/** + * 获取会员卡类型 + * @param object data + * + */ +export function memberCard() { + return request.get(`svip/pay_lst`) +} +/** + * 开通付费会员--支付 + * @param object data + * + */ +export function memberCardCreate(id, data) { + return request.post(`svip/pay/${id}`, data) +} +/** + * 付费会员权益 + * @param object data + * + */ +export function memberEquity() { + return request.get(`svip/user_info`, {}, {noAuth: true}) +} +/** + * 付费会员优惠券 + * @param object data + * + */ +export function memberCouponLst() { + return request.get(`svip/coupon_lst`, {}, {noAuth: true}) +} +/** + * 付费会员优惠券--领取 + * @param object data + * + */ +export function receiveMemberCoupon(id) { + return request.post(`svip/coupon_receive/${id}`) +} +/** + * 付费会员--会员商品 + * @param object data + * + */ +export function groomList(data) { + return request.get(`svip/product_lst`, data, {noAuth: true}) +} +/** + * 客服聊天--撤回消息 + * @param object data + * + */ +export function chatReverstApi(id) { + return request.post(`service/recall/${id}`) +} +/** + * 客服聊天--判断店铺是否有在线客服 + * @param object data + * + */ +export function hasServiceApi(id) { + return request.get(`has_service/${id}`) +} +/** + * 银行卡提现--银行卡信息 + * @param object data + * + */ +export function getBankInfo() { + return request.get(`user/extract/history_bank`) +} +/** + * 用户设置--信息 + * @param object data + * + */ +export function getUserSetting() { + return request.get(`user/fields/info`) +} +/** + * 用户设置--修改 + * @param object data + * + */ +export function userSettingEdit(data) { + return request.post(`user/fields/save`, data) +} +/** + * 报名活动--详情 + * @param object data + * + */ +export function registrateDetail(id) { + return request.get(`system/form/detail/${id}`,{}, {noAuth: true}) +} +/** + * 报名活动--提交数据 + * @param object data + * + */ +export function registrateCreate(id,data) { + return request.post(`user/form/create/${id}`, data) +} +/** + * 报名活动--列表 + * @param object data + * + */ +export function getRechargeList(data) { + return request.get(`system/form/lst`, data, {noAuth: true}) +} +/** + * 报名活动--记录 + * @param object data + * + */ +export function getRechargeRecordList(data) { + return request.get(`user/form/lst`, data) +} +/** + * 报名活动--分享海报 + * @param object data + * + */ +export function registratePoster(id) { + return request.get(`system/form/share_posters/${id}`, {}) +} +/** + * 报名活动--提交记录详情 + * @param object data + * + */ +export function registrateRecordDetail(id) { + return request.get(`user/form/show/${id}`) +} +/** + * 系统表单--表单详情数据 + * @param object data + * + */ +export function systemFormData(id) { + return request.get(`system/form/info/${id}`, {}, {noAuth: true}) +} \ No newline at end of file diff --git a/components/BaseMoney.vue b/components/BaseMoney.vue new file mode 100644 index 0000000..6c7c5b3 --- /dev/null +++ b/components/BaseMoney.vue @@ -0,0 +1,111 @@ + + + + + diff --git a/components/Loading/index.vue b/components/Loading/index.vue new file mode 100644 index 0000000..a87ddf6 --- /dev/null +++ b/components/Loading/index.vue @@ -0,0 +1,66 @@ + + + + \ No newline at end of file diff --git a/components/PriceChange/index.vue b/components/PriceChange/index.vue new file mode 100644 index 0000000..4ddf3b7 --- /dev/null +++ b/components/PriceChange/index.vue @@ -0,0 +1,152 @@ + + + + \ No newline at end of file diff --git a/components/WaterfallsFlow/WaterfallsFlow.vue b/components/WaterfallsFlow/WaterfallsFlow.vue new file mode 100644 index 0000000..2f88616 --- /dev/null +++ b/components/WaterfallsFlow/WaterfallsFlow.vue @@ -0,0 +1,204 @@ + + + + + diff --git a/components/WaterfallsFlowItem/WaterfallsFlowItem.vue b/components/WaterfallsFlowItem/WaterfallsFlowItem.vue new file mode 100644 index 0000000..391bc49 --- /dev/null +++ b/components/WaterfallsFlowItem/WaterfallsFlowItem.vue @@ -0,0 +1,358 @@ + + + + diff --git a/components/adc/index.vue b/components/adc/index.vue new file mode 100644 index 0000000..6a579d1 --- /dev/null +++ b/components/adc/index.vue @@ -0,0 +1,181 @@ + + + + + diff --git a/components/addInvoicing/index.vue b/components/addInvoicing/index.vue new file mode 100644 index 0000000..3286083 --- /dev/null +++ b/components/addInvoicing/index.vue @@ -0,0 +1,604 @@ + + + + + diff --git a/components/addcartWindow/index.vue b/components/addcartWindow/index.vue new file mode 100644 index 0000000..0219f53 --- /dev/null +++ b/components/addcartWindow/index.vue @@ -0,0 +1,346 @@ + + + + + diff --git a/components/addressWindow/index.vue b/components/addressWindow/index.vue new file mode 100644 index 0000000..c980270 --- /dev/null +++ b/components/addressWindow/index.vue @@ -0,0 +1,190 @@ + + + + diff --git a/components/alert/index.vue b/components/alert/index.vue new file mode 100644 index 0000000..913d928 --- /dev/null +++ b/components/alert/index.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/components/areaWindow/index.vue b/components/areaWindow/index.vue new file mode 100644 index 0000000..0f565bd --- /dev/null +++ b/components/areaWindow/index.vue @@ -0,0 +1,266 @@ + + + + + diff --git a/components/bindmobile.vue b/components/bindmobile.vue new file mode 100644 index 0000000..f34ec98 --- /dev/null +++ b/components/bindmobile.vue @@ -0,0 +1,319 @@ + + + + + diff --git a/components/cash/index.vue b/components/cash/index.vue new file mode 100644 index 0000000..28b707d --- /dev/null +++ b/components/cash/index.vue @@ -0,0 +1,140 @@ + + + + + diff --git a/components/checkCoupon/index.vue b/components/checkCoupon/index.vue new file mode 100644 index 0000000..0b54383 --- /dev/null +++ b/components/checkCoupon/index.vue @@ -0,0 +1,388 @@ + + + + + diff --git a/components/checkDelivery/index.vue b/components/checkDelivery/index.vue new file mode 100644 index 0000000..d3d1059 --- /dev/null +++ b/components/checkDelivery/index.vue @@ -0,0 +1,178 @@ + + + + + diff --git a/components/combinNav/index.vue b/components/combinNav/index.vue new file mode 100644 index 0000000..6a91fc0 --- /dev/null +++ b/components/combinNav/index.vue @@ -0,0 +1,318 @@ + + + + + diff --git a/components/comment.vue b/components/comment.vue new file mode 100644 index 0000000..dc7fd64 --- /dev/null +++ b/components/comment.vue @@ -0,0 +1,479 @@ + + + + + diff --git a/components/copyPassword/index.vue b/components/copyPassword/index.vue new file mode 100644 index 0000000..68e5e34 --- /dev/null +++ b/components/copyPassword/index.vue @@ -0,0 +1,147 @@ + + + + + diff --git a/components/countDown/index.vue b/components/countDown/index.vue new file mode 100644 index 0000000..accfe38 --- /dev/null +++ b/components/countDown/index.vue @@ -0,0 +1,174 @@ + + + + + diff --git a/components/couponListWindow/index.vue b/components/couponListWindow/index.vue new file mode 100644 index 0000000..66d1cca --- /dev/null +++ b/components/couponListWindow/index.vue @@ -0,0 +1,238 @@ + + + + diff --git a/components/cusPreviewImg/index.vue b/components/cusPreviewImg/index.vue new file mode 100644 index 0000000..1a27fa2 --- /dev/null +++ b/components/cusPreviewImg/index.vue @@ -0,0 +1,159 @@ + + + + + diff --git a/components/customTab.vue b/components/customTab.vue new file mode 100644 index 0000000..a9b5fdd --- /dev/null +++ b/components/customTab.vue @@ -0,0 +1,124 @@ + + + + + diff --git a/components/discountDetails/index.vue b/components/discountDetails/index.vue new file mode 100644 index 0000000..7b1b4a3 --- /dev/null +++ b/components/discountDetails/index.vue @@ -0,0 +1,153 @@ + + + + diff --git a/components/easy-loadimage/easy-loadimage.vue b/components/easy-loadimage/easy-loadimage.vue new file mode 100644 index 0000000..a8c3da4 --- /dev/null +++ b/components/easy-loadimage/easy-loadimage.vue @@ -0,0 +1,177 @@ + + + + + diff --git a/components/eidtUserModal/index.vue b/components/eidtUserModal/index.vue new file mode 100644 index 0000000..f7af8e1 --- /dev/null +++ b/components/eidtUserModal/index.vue @@ -0,0 +1,290 @@ + + + + diff --git a/components/emptyPage.vue b/components/emptyPage.vue new file mode 100644 index 0000000..0cefa8f --- /dev/null +++ b/components/emptyPage.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/components/freightGuarantee/index.vue b/components/freightGuarantee/index.vue new file mode 100644 index 0000000..e3e139a --- /dev/null +++ b/components/freightGuarantee/index.vue @@ -0,0 +1,216 @@ + + + + diff --git a/components/goodList/index.vue b/components/goodList/index.vue new file mode 100644 index 0000000..c219608 --- /dev/null +++ b/components/goodList/index.vue @@ -0,0 +1,179 @@ + + + + + diff --git a/components/guide/index.vue b/components/guide/index.vue new file mode 100644 index 0000000..84589a5 --- /dev/null +++ b/components/guide/index.vue @@ -0,0 +1,187 @@ + + + + \ No newline at end of file diff --git a/components/home/index.vue b/components/home/index.vue new file mode 100644 index 0000000..c3a59cc --- /dev/null +++ b/components/home/index.vue @@ -0,0 +1,116 @@ + + + + diff --git a/components/index.vue b/components/index.vue new file mode 100644 index 0000000..e38e397 --- /dev/null +++ b/components/index.vue @@ -0,0 +1,176 @@ + + + + + diff --git a/components/invoiceGoods/index.vue b/components/invoiceGoods/index.vue new file mode 100644 index 0000000..fd654db --- /dev/null +++ b/components/invoiceGoods/index.vue @@ -0,0 +1,262 @@ + + + + diff --git a/components/jyf-parser/jyf-parser.vue b/components/jyf-parser/jyf-parser.vue new file mode 100644 index 0000000..68b0ca7 --- /dev/null +++ b/components/jyf-parser/jyf-parser.vue @@ -0,0 +1,825 @@ + + + + + + diff --git a/components/jyf-parser/libs/CssHandler.js b/components/jyf-parser/libs/CssHandler.js new file mode 100644 index 0000000..9168e17 --- /dev/null +++ b/components/jyf-parser/libs/CssHandler.js @@ -0,0 +1,103 @@ + +/* + 解析和匹配 Css 的选择器 + github:https://github.com/jin-yufeng/Parser + docs:https://jin-yufeng.github.io/Parser + author:JinYufeng + update:2020/03/15 +*/ +var cfg = require('./config.js'); +class CssHandler { + constructor(tagStyle) { + var styles = Object.assign({}, cfg.userAgentStyles); + for (var item in tagStyle) + styles[item] = (styles[item] ? styles[item] + ';' : '') + tagStyle[item]; + this.styles = styles; + } + getStyle = data => this.styles = new CssParser(data, this.styles).parse(); + match(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; +class CssParser { + constructor(data, init) { + this.data = data; + this.floor = 0; + this.i = 0; + this.list = []; + this.res = init; + this.state = this.Space; + } + parse() { + for (var c; c = this.data[this.i]; this.i++) + this.state(c); + return this.res; + } + section = () => this.data.substring(this.start, this.i); + isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); + // 状态机 + Space(c) { + if (c == '.' || c == '#' || this.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; + } + Comment() { + this.i = this.data.indexOf('*/', this.i) + 1; + if (!this.i) this.i = this.data.length; + this.state = this.Space; + } + Ignore(c) { + if (c == '{') this.floor++; + else if (c == '}' && !--this.floor) this.state = this.Space; + } + Name(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 (!this.isLetter(c) && (c < '0' || c > '9') && c != '-' && c != '_') + this.state = this.Ignore; + } + NameSpace(c) { + if (c == '{') this.Content(); + else if (c == ',') this.Comma(); + else if (!cfg.blankChar[c]) this.state = this.Ignore; + } + Comma() { + while (cfg.blankChar[this.data[++this.i]]); + if (this.data[this.i] == '{') this.Content(); + else { + this.start = this.i--; + this.state = this.Name; + } + } + Content() { + 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 100644 index 0000000..602cab7 --- /dev/null +++ b/components/jyf-parser/libs/MpHtmlParser.js @@ -0,0 +1,578 @@ + +/* + 将 html 解析为适用于小程序 rich-text 的 DOM 结构 + github:https://github.com/jin-yufeng/Parser + docs:https://jin-yufeng.github.io/Parser + author:JinYufeng + update:2020/04/13 +*/ +var cfg = require('./config.js'), + blankChar = cfg.blankChar, + CssHandler = require('./CssHandler.js'), + { + screenWidth, + system + } = wx.getSystemInfoSync(); +// #ifdef MP-BAIDU || MP-ALIPAY || MP-TOUTIAO +var entities = { + lt: '<', + gt: '>', + amp: '&', + quot: '"', + apos: "'", + nbsp: '\xA0', + ensp: '\u2002', + emsp: '\u2003', + ndash: '–', + mdash: '—', + middot: '·', + lsquo: '‘', + rsquo: '’', + ldquo: '“', + rdquo: '”', + bull: '•', + hellip: '…', + permil: '‰', + copy: '©', + reg: '®', + trade: '™', + times: '×', + divide: '÷', + cent: '¢', + pound: '£', + yen: '¥', + euro: '€', + sect: '§' +}; +// #endif +var emoji; // emoji 补丁包 https://jin-yufeng.github.io/Parser/#/instructions?id=emoji +class MpHtmlParser { + constructor(data, options = {}) { + this.attrs = {}; + this.compress = options.compress; + this.CssHandler = new CssHandler(options.tagStyle, screenWidth); + this.data = data; + this.domain = options.domain; + this.DOM = []; + this.i = this.start = this.audioNum = this.imgNum = this.videoNum = 0; + this.protocol = this.domain && this.domain.includes('://') ? this.domain.split('://')[0] : ''; + this.state = this.Text; + this.STACK = []; + this.useAnchor = options.useAnchor; + this.xml = options.xml; + } + parse() { + 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()); + // #ifdef MP-BAIDU || MP-TOUTIAO + // 将顶层标签的一些样式提取出来给 rich-text + (function f(ns) { + for (var i = ns.length, n; n = ns[--i];) { + if (n.type == 'text') continue; + if (!n.c) { + var style = n.attrs.style; + if (style) { + var j, k, res; + if ((j = style.indexOf('display')) != -1) + res = style.substring(j, (k = style.indexOf(';', j)) == -1 ? style.length : k); + if ((j = style.indexOf('float')) != -1) + res += ';' + style.substring(j, (k = style.indexOf(';', j)) == -1 ? style.length : k); + n.attrs.contain = res; + } + } else f(n.children); + } + })(this.DOM); + // #endif + if (this.DOM.length) { + this.DOM[0].PoweredBy = 'Parser'; + if (this.title) this.DOM[0].title = this.title; + } + return this.DOM; + } + // 设置属性 + setAttr() { + var name = this.getName(this.attrName); + if (cfg.trustAttrs[name]) { + if (!this.attrVal) { + if (cfg.boolAttrs[name]) this.attrs[name] = 'T'; + } else if (name == 'src') this.attrs[name] = this.getUrl(this.attrVal.replace(/&/g, '&')); + else this.attrs[name] = this.attrVal; + } + this.attrVal = ''; + while (blankChar[this.data[this.i]]) this.i++; + if (this.isClose()) this.setNode(); + else { + this.start = this.i; + this.state = this.AttrName; + } + } + // 设置文本节点 + setText() { + 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 tmp = []; + for (let i = text.length, c; c = text[--i];) + if (!blankChar[c] || (!blankChar[tmp[0]] && (c = ' '))) tmp.unshift(c); + text = tmp.join(''); + if (text == ' ') return; + } + // 处理实体 + var siblings = this.siblings(), + i = -1, + j, en; + while (1) { + if ((i = text.indexOf('&', i + 1)) == -1) break; + if ((j = text.indexOf(';', i + 2)) == -1) break; + if (text[i + 1] == '#') { + en = parseInt((text[i + 2] == 'x' ? '0' : '') + text.substring(i + 2, j)); + if (!isNaN(en)) text = text.substr(0, i) + String.fromCharCode(en) + text.substring(j + 1); + } else { + en = text.substring(i + 1, j); + // #ifdef MP-WEIXIN || MP-QQ || APP-PLUS + if (en == 'nbsp') text = text.substr(0, i) + '\xA0' + text.substr(j + 1); // 解决   失效 + else if (en != 'lt' && en != 'gt' && en != 'amp' && en != 'ensp' && en != 'emsp' && en != 'quot' && en != 'apos') { + i && siblings.push({ + type: 'text', + text: text.substr(0, i) + }) + siblings.push({ + type: 'text', + text: `&${en};`, + en: 1 + }) + text = text.substr(j + 1); + i = -1; + } + // #endif + // #ifdef MP-BAIDU || MP-ALIPAY || MP-TOUTIAO + if (entities[en]) text = text.substr(0, i) + entities[en] + text.substr(j + 1); + // #endif + } + } + text && siblings.push({ + type: 'text', + text + }) + } + // 设置元素节点 + setNode() { + var node = { + name: this.tagName.toLowerCase(), + attrs: this.attrs + }, + close = cfg.selfClosingTags[node.name] || (this.xml && this.data[this.i] == '/'); + this.attrs = {}; + if (!cfg.ignoreTags[node.name]) { + this.matchAttr(node); + 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.STACK[this.STACK.length - 1], + attrs = node.attrs; + if (parent && attrs.src) + if (parent.name == 'video' || parent.name == 'audio') + parent.attrs.source.push(attrs.src); + else { + var i, media = attrs.media; + if (parent.name == 'picture' && !parent.attrs.src && !(attrs.src.indexOf('.webp') && system.includes('iOS')) && + (!media || (media.includes('px') && + (((i = media.indexOf('min-width')) != -1 && (i = media.indexOf(':', i + 8)) != -1 && screenWidth > parseInt( + media.substr(i + 1))) || + ((i = media.indexOf('max-width')) != -1 && (i = media.indexOf(':', i + 8)) != -1 && screenWidth < parseInt( + media.substr(i + 1))))))) + parent.attrs.src = 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; + } + // 移除标签 + remove(node) { + var name = node.name, + j = this.i; + while (1) { + if ((this.i = this.data.indexOf('', this.i)) == -1) this.i = this.data.length; + // 处理 svg + if (name == 'svg') { + var src = this.data.substring(j, this.i + 1); + if (!node.attrs.xmlns) src = ' xmlns="http://www.w3.org/2000/svg"' + src; + var i = j; + while (this.data[j] != '<') j--; + src = this.data.substring(j, i) + src; + var parent = this.STACK[this.STACK.length - 1]; + if (node.attrs.width == '100%' && parent && (parent.attrs.style || '').includes('inline')) + parent.attrs.style = 'width:300px;max-width:100%;' + parent.attrs.style; + this.siblings().push({ + name: 'img', + attrs: { + src: 'data:image/svg+xml;utf8,' + src.replace(/#/g, '%23'), + ignore: 'T' + } + }) + } + return; + } + } + } + // 处理属性 + matchAttr(node) { + var attrs = node.attrs, + style = this.CssHandler.match(node.name, attrs, node) + (attrs.style || ''), + styleObj = {}; + if (attrs.id) { + if (this.compress & 1) attrs.id = void 0; + else if (this.useAnchor) this.bubble(); + } + if ((this.compress & 2) && attrs.class) attrs.class = void 0; + switch (node.name) { + case 'img': + if (attrs['data-src']) { + attrs.src = attrs.src || attrs['data-src']; + attrs['data-src'] = void 0; + } + if (attrs.src && !attrs.ignore) { + if (this.bubble()) attrs.i = (this.imgNum++).toString(); + else attrs.ignore = 'T'; + } + break; + case 'a': + case 'ad': + // #ifdef APP-PLUS + case 'iframe': + case 'embed': + // #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 'video': + case 'audio': + if (!attrs.id) attrs.id = node.name + (++this[`${node.name}Num`]); + else this[`${node.name}Num`]++; + if (node.name == 'video') { + if (attrs.width) { + style = `width:${parseFloat(attrs.width) + (attrs.width.includes('%') ? '%' : 'px')};${style}`; + attrs.width = void 0; + } + if (attrs.height) { + style = `height:${parseFloat(attrs.height) + (attrs.height.includes('%') ? '%' : 'px')};${style}`; + attrs.height = void 0; + } + if (this.videoNum > 3) node.lazyLoad = true; + } + attrs.source = []; + if (attrs.src) attrs.source.push(attrs.src); + if (!attrs.controls && !attrs.autoplay) + console.warn(`存在没有 controls 属性的 ${node.name} 标签,可能导致无法播放`, node); + 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.c = void 0; + break; + } + } + if (attrs.align) { + styleObj['text-align'] = attrs.align; + attrs.align = void 0; + } + // 压缩 style + var styles = style.replace(/"/g, '"').replace(/&/g, '&').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.includes('-webkit') || value.includes('-moz') || value.includes('-ms') || value.includes('-o') || value + .includes( + 'safe')) + style += `;${key}:${value}`; + else if (!styleObj[key] || value.includes('import') || !styleObj[key].includes('import')) + styleObj[key] = value; + } + if (node.name == 'img' && parseInt(styleObj.width || attrs.width) > screenWidth) + styleObj.height = 'auto'; + for (var key in styleObj) { + var value = styleObj[key]; + 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($) * screenWidth / 750 + 'px'); + else if (key == 'white-space' && value.includes('pre')) + this.pre = node.pre = true; + style += `;${key}:${value}`; + } + style = style.substr(1); + if (style) attrs.style = style; + } + // 节点出栈处理 + popNode(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; + } + if (node.name == 'head' || (cfg.filter && cfg.filter(node, this) == false)) + return this.siblings().pop(); + var attrs = node.attrs; + // 替换一些标签名 + if (node.name == 'picture') { + node.name = 'img'; + if (!attrs.src && (node.children[0] || '').name == 'img') + attrs.src = node.children[0].attrs.src; + if (attrs.src && !attrs.ignore) + attrs.i = (this.imgNum++).toString(); + return node.children = void 0; + } + if (cfg.blockTags[node.name]) node.name = 'div'; + else if (!cfg.trustTags[node.name]) node.name = 'span'; + // 处理列表 + if (node.c) { + 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 = node.children.length; i--;) + node.children[i].floor = floor; + } else if (node.name == 'ol') { + for (let i = 0, num = 1, child; child = node.children[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 = attrs.cellpadding, + spacing = attrs.cellspacing, + border = attrs.border; + if (node.c) { + this.bubble(); + if (!padding) padding = 2; + if (!spacing) spacing = 2; + } + if (border) attrs.style = `border:${border}px solid gray;${attrs.style || ''}`; + if (spacing) 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 || []); + } + })(node.children) + } + this.CssHandler.pop && this.CssHandler.pop(node); + // 自动压缩 + if (node.name == 'div' && !Object.keys(attrs).length) { + var siblings = this.siblings(); + if (node.children.length == 1 && node.children[0].name == 'div') + siblings[siblings.length - 1] = node.children[0]; + } + } + // 工具函数 + bubble() { + for (var i = this.STACK.length, item; item = this.STACK[--i];) { + if (cfg.richOnlyTags[item.name]) { + if (item.name == 'table' && !Object.hasOwnProperty.call(item, 'c')) item.c = 1; + return false; + } + item.c = 1; + } + return true; + } + getName = val => this.xml ? val : val.toLowerCase(); + getUrl(url) { + if (url[0] == '/') { + if (url[1] == '/') url = this.protocol + ':' + 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; + } + isClose = () => this.data[this.i] == '>' || (this.data[this.i] == '/' && this.data[this.i + 1] == '>'); + section = () => this.data.substring(this.start, this.i); + siblings = () => this.STACK.length ? this.STACK[this.STACK.length - 1].children : this.DOM; + // 状态机 + Text(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 == '!') { + this.setText(); + this.Comment(); + } + } + } + Comment() { + 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; + } + TagName(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(); + } + } + AttrName(c) { + var blank = blankChar[c]; + if (blank) { + this.attrName = this.section(); + c = this.data[this.i]; + } + if (c == '=') { + if (!blank) this.attrName = this.section(); + while (blankChar[this.data[++this.i]]); + this.start = this.i--; + this.state = this.AttrValue; + } else if (blank) this.setAttr(); + else if (this.isClose()) { + this.attrName = this.section(); + this.setAttr(); + } + } + AttrValue(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(); + } + EndTag(c) { + if (blankChar[c] || c == '>' || c == '/') { + var name = this.getName(this.section()); + 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); + } 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 100644 index 0000000..d4286b2 --- /dev/null +++ b/components/jyf-parser/libs/config.js @@ -0,0 +1,81 @@ + +/* 配置文件 */ +// #ifdef MP-WEIXIN +const canIUse = wx.canIUse('editor'); // 高基础库标识,用于兼容 +// #endif +module.exports = { + // 过滤器函数 + filter: null, + // 代码高亮函数 + highlight: null, + // 文本处理函数 + onText: null, + blankChar: makeMap(' ,\xA0,\t,\r,\n,\f'), + // 块级标签,将被转为 div + blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,section' + ( + // #ifdef MP-WEIXIN + canIUse ? '' : + // #endif + ',pre')), + // 将被移除的标签 + ignoreTags: makeMap( + 'area,base,basefont,canvas,command,frame,input,isindex,keygen,link,map,meta,param,script,source,style,svg,textarea,title,track,use,wbr' + // #ifdef MP-WEIXIN + + (canIUse ? ',rp' : '') + // #endif + // #ifndef APP-PLUS + + ',embed,iframe' + // #endif + ), + // 只能被 rich-text 显示的标签 + richOnlyTags: makeMap('a,colgroup,fieldset,legend,picture,table' + // #ifdef MP-WEIXIN + + (canIUse ? ',bdi,bdo,caption,rt,ruby' : '') + // #endif + ), + // 自闭合的标签 + selfClosingTags: makeMap( + 'area,base,basefont,br,col,circle,ellipse,embed,frame,hr,img,input,isindex,keygen,line,link,meta,param,path,polygon,rect,source,track,use,wbr' + ), + // 信任的属性 + trustAttrs: makeMap( + 'align,alt,app-id,author,autoplay,border,cellpadding,cellspacing,class,color,colspan,controls,data-src,dir,face,height,href,id,ignore,loop,media,muted,name,path,poster,rowspan,size,span,src,start,style,type,unit-id,width,xmlns' + ), + // bool 型的属性 + boolAttrs: makeMap('autoplay,controls,ignore,loop,muted'), + // 信任的标签 + 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' + // #ifdef MP-WEIXIN + + (canIUse ? ',bdi,bdo,caption,pre,rt,ruby' : '') + // #endif + // #ifdef APP-PLUS + + ',embed,iframe' + // #endif + ), + // 默认的标签样式 + 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', + img: 'max-width:100%', + mark: 'background-color:yellow', + picture: 'max-width:100%', + 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 = {}, + list = str.split(','); + for (var i = list.length; i--;) + map[list[i]] = true; + return map; +} diff --git a/components/jyf-parser/libs/handler.sjs b/components/jyf-parser/libs/handler.sjs new file mode 100644 index 0000000..144bdb1 --- /dev/null +++ b/components/jyf-parser/libs/handler.sjs @@ -0,0 +1,36 @@ + +var inlineTags = { + 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 +} +export default { + // 从顶层标签的样式中取出一些给 rich-text + getStyle: function(style) { + if (style) { + var i, j, res = ''; + if ((i = style.indexOf('display')) != -1) + res = style.substring(i, (j = style.indexOf(';', i)) == -1 ? style.length : j); + if ((i = style.indexOf('float')) != -1) + res += ';' + style.substring(i, (j = style.indexOf(';', i)) == -1 ? style.length : j); + return res; + } + }, + getNode: function(item) { + return [item]; + }, + // 是否通过 rich-text 显示 + useRichText: function(item) { + return !item.c && !inlineTags[item.name] && (item.attrs.style || '').indexOf('display:inline') == -1; + } +} diff --git a/components/jyf-parser/libs/handler.wxs b/components/jyf-parser/libs/handler.wxs new file mode 100644 index 0000000..17e71ee --- /dev/null +++ b/components/jyf-parser/libs/handler.wxs @@ -0,0 +1,45 @@ + +var inlineTags = { + 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 +} +module.exports = { + // 从顶层标签的样式中取出一些给 rich-text + getStyle: function(style) { + if (style) { + var i, j, res = ''; + if ((i = style.indexOf('display')) != -1) + res = style.substring(i, (j = style.indexOf(';', i)) == -1 ? style.length : j); + if ((i = style.indexOf('float')) != -1) + res += ';' + style.substring(i, (j = style.indexOf(';', i)) == -1 ? style.length : j); + return res; + } + }, + // 处理懒加载 + getNode: function(item, imgLoad) { + if (!imgLoad && item.attrs.i != '0') { + var img = { + name: 'img', + attrs: JSON.parse(JSON.stringify(item.attrs)) + } + delete img.attrs.src; + img.attrs.style += ';width:20px;height:20px'; + return [img]; + } else return [item]; + }, + // 是否通过 rich-text 显示 + useRichText: function(item) { + return !item.c && !inlineTags[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 100644 index 0000000..03639c6 --- /dev/null +++ b/components/jyf-parser/libs/trees.vue @@ -0,0 +1,488 @@ + +