commit dc9b1ce7e443c99087a6e23a3641f6f249e295f5 Author: weipengfei <2187978347@qq.com> Date: Sun Oct 8 14:17:20 2023 +0800 初始化仓库 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45dca11 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +.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 +*.bak diff --git a/App.vue b/App.vue new file mode 100644 index 0000000..4d3d6fe --- /dev/null +++ b/App.vue @@ -0,0 +1,128 @@ + + + diff --git a/api/api.js b/api/api.js new file mode 100644 index 0000000..f5545dc --- /dev/null +++ b/api/api.js @@ -0,0 +1,312 @@ +import request from "@/utils/request.js"; + +/** + * 获取云仓分类 + * + */ +export function cloudWarehouse(data) { + return request.get("store/product/cloudWarehouse", data, { noAuth: true }); +} +/** + * 获取云仓分类 + * + */ +export function getCityCloundShop(data) { + return request.get("city/get_cloud_shop", data); +} +/** + * 商品扫码枪查询商品是否存在 + * + */ +export function seachBarCodeAPI(data) { + return request.get("micro/seach_bar_code", data); +} + +/** + * 获取里海云仓商品 + * + */ +export function getProductSpuAPI(id, param) { + return request.get(`product/spu/cloud_merchant/${id}`, param, { noAuth: true }); +} +//获取云仓库店铺id +export function get_cloud_shop(street_code) { + return request.get(`city/get_cloud_shop?street_code=${street_code}`, {}, { noAuth: true }); +} +export function post_product_import(id) { + return request.post(`micro/product_import`, { id: id }, { noAuth: true }); +} +/** + * 公共接口 ,优惠券接口 , 行业此讯 , 手机号码注册 + * + */ +/** + * 获取主页数据 无需授权 + * + */ +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 }) +} + +export function getArticleCategoryLists() { + return request.get('article/category/lst?is_home='+1, {}, { 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 village(data) { + return request.get('v2/system/geo/lst', data, { noAuth: true }); +} + +/** + * 获取所在的村队数据 + * @param {Object} data + */ +export function brigade(data) { + return request.get('v2/system/brigade', data, { noAuth: true }); +} + +/* + 生产 -- 获取商户保证金信息支付接口 +*/ +export function paymerchant() { + return request.post(`user/margin`,{}); +} + +/* + 生产 -- 获取商户保证金信息接口 +*/ +export function merchant(data) { + return request.get(`store/merchant/margin`, data); +} + +//获取保证金缴纳列表 +export function marginlist(data) { + return request.get(`user/margin/list`,data); +} diff --git a/api/pay.js b/api/pay.js new file mode 100644 index 0000000..21b9700 --- /dev/null +++ b/api/pay.js @@ -0,0 +1,59 @@ +import oahttp from "@/utils/oahttp.js"; + +/** + * 充值 + */ +export const recharge = (data) => oahttp.post('/recharge/recharge', data) +/** + * 押金充值记录 + */ +export const deposit_recharge = (data) => oahttp.get('/recharge/deposit_lists', data) +/** + * 支付方式 + */ +export const payWay = (data) => oahttp.get('/pay/payWay', data) + +/** + * 预支付 + */ +export const payPrepay = (data) => oahttp.post('/pay/prepay', data) + +/** + * 支付配置 + */ +export const wechatJsConfig = (data) => oahttp.get('/wechat/jsConfig', data) + +/** + * 支付状态 + */ +export const payStatus = (data) => oahttp.get('/pay/payStatus', data) + +/** + * 充值记录 + */ +export const rechargeLists = (data) => oahttp.get('/recharge/lists', data) + +/** + * 余额明细 + */ +export const accountLogLists = (data) => oahttp.get('/account_log/lists', data) + +/** + * 月份统计 + */ +export const accountLogListsMonth = (data) => oahttp.get('/account_log/year_count', data) + +/** + * 余额提现 + */ +export const userWithdraw = (data) => oahttp.get('/user/withdraw', data) + +/** + * 提现记录 + */ +export const userWithdrawList = (data) => oahttp.get('/user/withdrawList', data) + +/** + * 可提现金额 + */ +export const getCurrCycleWithdraw = (data) => oahttp.get('/user/getCurrCycleWithdraw', data) \ No newline at end of file diff --git a/api/public.js b/api/public.js new file mode 100644 index 0000000..723b7d3 --- /dev/null +++ b/api/public.js @@ -0,0 +1,144 @@ +// +---------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +---------------------------------------------------------------------- +// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved. +// +---------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +---------------------------------------------------------------------- +// | Author: CRMEB Team +// +---------------------------------------------------------------------- +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 + }); +} +/** + * 绑定小程序账号 + * @param data object 小程序用户登陆信息 + */ +export function bindMp(data) { + return request.post("auth/bindMp", data, { + noAuth: true + }); +} +/** + * 绑定极光id + * @param data object 小程序用户登陆信息 + */ +export function bindJG(data) { + return request.post("auth/bindJg", 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/uniMP.js b/api/uniMP.js new file mode 100644 index 0000000..3562f10 --- /dev/null +++ b/api/uniMP.js @@ -0,0 +1,27 @@ +// +---------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +---------------------------------------------------------------------- +// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved. +// +---------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +---------------------------------------------------------------------- +// | Author: CRMEB Team +// +---------------------------------------------------------------------- +import request from "@/utils/request.js"; + +/** + * 获取供销平台版本信息 + */ +export function getGXconfig(data) { + return request.get("global/config", data); +} + + +/** + * 获取商城小程序信息 + */ + +export function miniapp(data) { + return request.get("miniapp/version?version=1", data); +} + diff --git a/api/user.js b/api/user.js new file mode 100644 index 0000000..4594d26 --- /dev/null +++ b/api/user.js @@ -0,0 +1,732 @@ +// +---------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +---------------------------------------------------------------------- +// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved. +// +---------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +---------------------------------------------------------------------- +// | Author: CRMEB Team +// +---------------------------------------------------------------------- +import request from "@/utils/request.js"; + +import request1 from "@/utils/requestb.js"; +import Cache from '@/utils/cache' +/** + * 获取版本信息 + */ +export function Appversion(data) { + return request.get(`app/version`, data, { + noAuth: true + }); +} +/** + * 提交提现 + */ +export function postCreateApplyAPI(merId, data) { + return request.post(`admin/${merId}/create_apply`, data); +} +/** + * 申请提现 + */ +export function getAdminApplyAPI(merId, data) { + return request.get(`admin/${merId}/apply`, data); +} +/** + * 提现记录 + */ +export function getAdminApplyListAPI(merId) { + return request.get(`admin/${merId}/lis_apply`); +} +/** + * 获取用户信息 + * + */ +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 + }); +} +/** + * 验证码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`) +} +// 商户账单管理 +export function getBillDetil() { + return request.get(`mer/financial_record`) +} + + + +//获取商户入驻所签署公司 + +export function merstreet(data) { + return request1.get(`company/street_company`, data); +} diff --git a/components/jyf-parser/jyf-parser.vue b/components/jyf-parser/jyf-parser.vue new file mode 100644 index 0000000..6294c26 --- /dev/null +++ b/components/jyf-parser/jyf-parser.vue @@ -0,0 +1,815 @@ + + + + + + diff --git a/components/jyf-parser/libs/CssHandler.js b/components/jyf-parser/libs/CssHandler.js new file mode 100644 index 0000000..f286db3 --- /dev/null +++ b/components/jyf-parser/libs/CssHandler.js @@ -0,0 +1,111 @@ +// +---------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +---------------------------------------------------------------------- +// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved. +// +---------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +---------------------------------------------------------------------- +// | Author: CRMEB Team +// +---------------------------------------------------------------------- +/* + 解析和匹配 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..30c59e9 --- /dev/null +++ b/components/jyf-parser/libs/MpHtmlParser.js @@ -0,0 +1,586 @@ +// +---------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +---------------------------------------------------------------------- +// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved. +// +---------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +---------------------------------------------------------------------- +// | Author: CRMEB Team +// +---------------------------------------------------------------------- +/* + 将 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..c7985ad --- /dev/null +++ b/components/jyf-parser/libs/config.js @@ -0,0 +1,89 @@ +// +---------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +---------------------------------------------------------------------- +// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved. +// +---------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +---------------------------------------------------------------------- +// | Author: CRMEB Team +// +---------------------------------------------------------------------- +/* 配置文件 */ +// #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..e8743fa --- /dev/null +++ b/components/jyf-parser/libs/handler.sjs @@ -0,0 +1,44 @@ +// +---------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +---------------------------------------------------------------------- +// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved. +// +---------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +---------------------------------------------------------------------- +// | Author: CRMEB Team +// +---------------------------------------------------------------------- +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..afaf0bc --- /dev/null +++ b/components/jyf-parser/libs/handler.wxs @@ -0,0 +1,53 @@ +// +---------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +---------------------------------------------------------------------- +// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved. +// +---------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +---------------------------------------------------------------------- +// | Author: CRMEB Team +// +---------------------------------------------------------------------- +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..c2ea476 --- /dev/null +++ b/components/jyf-parser/libs/trees.vue @@ -0,0 +1,485 @@ + +