commit 81aba0c9b74f5111724ca7dfae116aecaa5cb8af Author: jia <1451658316@qq.com> Date: Sat Nov 18 10:47:46 2023 +0800 first commit diff --git a/api/config.js b/api/config.js new file mode 100644 index 0000000..93fcd12 --- /dev/null +++ b/api/config.js @@ -0,0 +1,6 @@ +import oahttp from "@/utils/oahttp.js"; + +/** + * 获取配置信息 + */ +export const getConfig = (data) => oahttp.get('/index/config', data, { noAuth:true }, true) diff --git a/api/file.js b/api/file.js new file mode 100644 index 0000000..61c335e --- /dev/null +++ b/api/file.js @@ -0,0 +1,50 @@ +import { + HTTP_REQUEST_URL_THREE, + HEADER, + TOKENNAME, +} from '@/config/app'; +import { + Toast +} from '../libs/uniApi'; +// import { checkLogin } from '../libs/login'; +import store from '../store'; + +function toLogin() { + store.commit("LOGOUT"); + uni.showToast({ + title: '璇风櫥褰', + icon: 'none', + duration: 1000 + }); +} + +function upLoad(url, data) { + let Url = HTTP_REQUEST_URL_THREE, + header = {} + if (store.state.app.token) header[TOKENNAME] = store.state.app.token; + return new Promise((reslove, reject) => { + uni.uploadFile({ + url: Url + '/api' + url, + filePath: data.filePath, + name: data.name, + success: (uploadFileRes) => { + uploadFileRes.data = JSON.parse(uploadFileRes.data) + if (uploadFileRes.data.code == 1) reslove(uploadFileRes.data) + else Toast('缃戠粶閿欒') + }, + fail: (err) => { + Toast('缃戠粶閿欒') + } + }) + }); +} + +export const upLoadImage = (data) => { + return upLoad('/upload/image', data) +} + +export const VIDEO_URL = HTTP_REQUEST_URL_THREE + '/api/upload/video' +export const FILE_URL = HTTP_REQUEST_URL_THREE + '/api/home_index/upload' +// im鏂囦欢涓婁紶 +// export const VIDEO_URL_IM = HTTP_REQUEST_URL_THREE + '/api/upload/video' +export const FILE_URL_IM = HTTP_REQUEST_URL_THREE + '/common/im/sendFileMsg' \ No newline at end of file diff --git a/api/index.js b/api/index.js new file mode 100644 index 0000000..6c38943 --- /dev/null +++ b/api/index.js @@ -0,0 +1,28 @@ +// let Token = localStorage.getItem("token") +let Token = uni.getStorageSync("token") +let request = (METHOD, URL, DATA) => { + return new Promise((reslove, reject) => { + uni.request({ + url: 'https://ceshi-im.lihaink.cn/' + URL, + method: METHOD, + data: { + ...DATA + }, + header: { + 'content-type': 'application/json', + "Authorization": Token || "" + + }, + success: function(res) { + reslove(res) + }, + fail: function(err) { + reject(err) + }, + + }); + }) +} + + +export default request; \ No newline at end of file diff --git a/api/oa.js b/api/oa.js new file mode 100644 index 0000000..353886b --- /dev/null +++ b/api/oa.js @@ -0,0 +1,12 @@ +import oahttp from "@/utils/oahttp.js"; + + +export const lists = (data) => oahttp.get('/logistic/lists', data) +//璇︽儏 +export const detail = (data) => oahttp.get('/logistic/detail', data) +//鎻愬彇鍟嗗搧 +export const takeGoods = (data) => oahttp.post('/logistic/takeGoods', data) + +//瀹屾垚閰嶉 +export const delivery = (data) => oahttp.post('/logistic/delivery', data) + diff --git a/api/oaApi.js b/api/oaApi.js new file mode 100644 index 0000000..ca79bff --- /dev/null +++ b/api/oaApi.js @@ -0,0 +1,60 @@ +import oahttp from "@/utils/oahttp.js"; + +/** + * 鑾峰彇浠e姙浜嬮」 宸插鐞嗕簨椤 + */ +export const getIndexListAPI = (data) => oahttp.get('/index/list', data) + +/** + * 鑾峰彇浠诲姟鍒楄〃 + */ +export const getTaskListAPI = (data) => oahttp.get('/task/list', data) + +/** + * 鑾峰彇鎴戠殑浠诲姟 + */ +export const getMyTaskListAPI = (data) => oahttp.get('/task/datalist', data) + +/** + * 鑾峰彇浠诲姟璇︽儏 + */ +export const getTaskDetailsAPI = (data) => oahttp.get('/task/read', data) +/** + * 鎴戝彂璧风殑瀹℃壒 + */ +export const getApproveMyListAPI = (data) => oahttp.get('/approve/my_list', data) +/** + * 鎴戝鎵圭殑 + */ +export const getHandleListAPI = (data) => oahttp.get('/approve/handle_list', data) +/** + * 鎶勯佺粰鎴戠殑 + */ +export const getCopyOfMyListAPI = (data) => oahttp.get('/approve/copy', data) +/* + * 寰呭姙浜嬮」 + */ +export const getApproveListAPI = (data) => oahttp.get('/approve/list', data) +/** + * 鑾峰彇涓汉涓績鏁版嵁 + */ +export const getUserIndexAPI = (data) => oahttp.get('/user/index', data) +/** + * 淇濆瓨涓汉淇℃伅淇敼 + */ +export const PostUserPerSubmitAPI = (data) => oahttp.post('/home_index/edit_personal', data) +/** + * 鑾峰彇瀹℃牳娴佺▼ + * index/get_flow?type=1 + */ +export const getFlowAPI = (data) => oahttp.get('/index/get_flow', data) +/** + * 鑾峰彇瀹℃牳姝ラ浜哄憳 + */ +export const getFlowUsersAPI = (data) => oahttp.get('/index/get_flow_users', data, { noVerify: true }) +/** 鑾峰彇閮ㄩ棬鏍戝舰鑺傜偣鍒楄〃 */ +export const getDepartmentTreeAPI = () => oahttp.get('/index/get_department_tree') +/** 鑾峰彇鏌愪釜閮ㄩ棬鐨勫憳宸 */ +export const getEmployeeAPI = (data) => oahttp.get('/index/get_employee', data) +/** 鍙戣捣瀹℃壒 */ +export const PostApproveAddAPI = (data) => oahttp.post('/approve/add', data) diff --git a/api/oaUser.js b/api/oaUser.js new file mode 100644 index 0000000..3ac68de --- /dev/null +++ b/api/oaUser.js @@ -0,0 +1,27 @@ +import oahttp from "@/utils/oahttp.js"; + +/** + * 鐧诲綍 + */ +export const loginAccount = (data, onReLogin = false) => oahttp.post('/login/login', data, { noAuth: true, onReLogin: onReLogin }) + +/** + * cesi + */ +export const test = (data) => oahttp.post('/index/config', data, { noAuth: true }) + +/** + * 涓汉涓績 + */ +export const userCenter = (data) => oahttp.get('/user/center', data) + +/** + * 涓汉淇℃伅 + */ +export const userInfo = (data) => oahttp.get('/home_index/userinfo', data) + +/** + * 淇敼瀵嗙爜 + */ +export const changePassword = (data) => oahttp.post('/home_index/edit_password', data) + diff --git a/api/pubic.js b/api/pubic.js new file mode 100644 index 0000000..4533f7f --- /dev/null +++ b/api/pubic.js @@ -0,0 +1,17 @@ +import request from '@/utils/request.js' +export function commonAuth(data) { + return request.post( + "auth", data, { + noAuth: true + } + ); +} +/** + * 灏忕▼搴忕敤鎴风櫥褰 + * @param data object 灏忕▼搴忕敤鎴风櫥闄嗕俊鎭 + */ +export function login(data) { + return request.post("auth/mp", data, { + noAuth: true + }); +} diff --git a/api/upload.js b/api/upload.js new file mode 100644 index 0000000..dc41137 --- /dev/null +++ b/api/upload.js @@ -0,0 +1,65 @@ +// import base from "@/config/baseUrl"; +// let baseUrl = 'https://ceshi.excellentkk.cn/api'; +import store from '../store'; +import { HTTP_REQUEST_URL_TWO, HTTP_REQUEST_URL_THREE, HEADER } from '@/config/app'; +let header = HEADER; + if (store.state.app.token){ + header.token = store.state.app.token; + } +function uploads(src, type) { + return new Promise((resolve, reject) => { + // console.log('涓婁紶', type === 'img' ? '鍥剧墖' : '瑙嗛', '锛', src) + let a = uni.uploadFile({ + // url: base.baseUrl + '/upload?token=', + url: HTTP_REQUEST_URL_TWO + '/api' + '/upload?token=', + filePath: src, + name: 'file', + success: (res) => { + let data = JSON.parse(res.data) + if (data.code != 1) { + uni.$u.toast(data.msg) + return false + } else { + resolve(data.data.url) // 杩斿洖绾夸笂鍦板潃 + } + }, + fail: (err) => { + reject(err) + console.log('upload-涓婁紶澶辫触', err) + } + }); + }) +} + +function oaUploads(src, type) { + return new Promise((resolve, reject) => { + // console.log('涓婁紶', type === 'img' ? '鍥剧墖' : '瑙嗛', '锛', src) + + let a = uni.uploadFile({ + url: HTTP_REQUEST_URL_THREE + '/api/common/upload', + filePath: src, + name: 'file', + header: header, + success: (res) => { + + let data = JSON.parse(res.data) + if (data.code == 0) { + resolve(data.data) // 杩斿洖绾夸笂鍦板潃 + } else { + uni.$u.toast(data.msg) + return false + } + }, + fail: (err) => { + reject(err) + console.log('upload-涓婁紶澶辫触', err) + } + }); + }) +} + + +export { + uploads, + oaUploads +} diff --git a/api/user.js b/api/user.js new file mode 100644 index 0000000..fca43c1 --- /dev/null +++ b/api/user.js @@ -0,0 +1,743 @@ +import request from "@/utils/request.js"; +import Cache from '@/utils/cache' +import http from "@/utils/http.js"; +/** + * 鑾峰彇鍚庡彴璐﹀彿瀵嗙爜 + */ +export const getBackstageAPI = (data) => http.get('/User/get_backstage', data) +// 鑾峰彇宸插綍鍏ュ叕鍙 +export const getEnterListMsgAPI = (data) => http.get('/enter/list', data) +// 褰曞叆鍏徃 +export const postEntercompanyAPI = (data) => request.post('entercompany', data) +// 鑾峰彇鍦板潃 +export const getSiteAPI = (data) => http.get('/User/index', data) +export const getShimingAPI = (data) => http.get('/User/get_shiming', data) +export const postRealnameAPI = (data) => http.post('/User/realname', data) +/** + * 鑾峰彇鐢ㄦ埛淇℃伅 + * + */ +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 + }); +} +/** + * 楠岃瘉鐮乲ey + */ +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'); +} +/* + * 璧勯噾鏄庣粏锛坱ypes|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); +} +/** + * + * 鎺ㄥ箍浣i噾/鎻愮幇鎬诲拰 + * @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); +} + +/* + * 鑾峰彇浣i噾鎺掑悕 + * */ +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"); +} + +/** + * 浣i噾杞叆 + * + */ +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); +} +/** + * 浣i噾璁板綍 + */ +export function brokerage_list(data) { + return request.get("user/brokerage_list", data); +} + +/** + * 浣i噾鏁版嵁 + */ +export function spreadInfo(data) { + return request.get("user/spread_info", data); +} + +// 鍥剧墖楠岃瘉鐮 +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); +} + +/** + * 鍥剧墖閾炬帴杞琤ase64 + * + */ +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); +} + +/* + 鑾峰彇浣i噾璇存槑 +*/ + +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) +} +/* + 鍙d护瑙f瀽 +*/ + +export function pwdResolution(data) { + return request.get(`command/copy?key=${data}`) +} +/* + 鑾峰彇浣i噾璇存槑 +*/ + +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}`) +} diff --git a/components/a-map-walking.vue b/components/a-map-walking.vue new file mode 100644 index 0000000..25c3052 --- /dev/null +++ b/components/a-map-walking.vue @@ -0,0 +1,86 @@ + + + + + \ No newline at end of file diff --git a/components/gb-popup/gb-popup.vue b/components/gb-popup/gb-popup.vue new file mode 100644 index 0000000..04701d5 --- /dev/null +++ b/components/gb-popup/gb-popup.vue @@ -0,0 +1,169 @@ + + + + + \ No newline at end of file diff --git a/components/index/detaila.vue b/components/index/detaila.vue new file mode 100644 index 0000000..22a5c6c --- /dev/null +++ b/components/index/detaila.vue @@ -0,0 +1,818 @@ + + + + + \ No newline at end of file diff --git a/components/index/detailb.vue b/components/index/detailb.vue new file mode 100644 index 0000000..316861a --- /dev/null +++ b/components/index/detailb.vue @@ -0,0 +1,720 @@ + + + + + \ No newline at end of file diff --git a/components/index/detailc.vue b/components/index/detailc.vue new file mode 100644 index 0000000..054b37a --- /dev/null +++ b/components/index/detailc.vue @@ -0,0 +1,471 @@ + + + + + \ No newline at end of file diff --git a/components/index/index.vue b/components/index/index.vue new file mode 100644 index 0000000..f254efa --- /dev/null +++ b/components/index/index.vue @@ -0,0 +1,481 @@ + + + + + \ No newline at end of file diff --git a/components/index/index1.vue b/components/index/index1.vue new file mode 100644 index 0000000..06b0430 --- /dev/null +++ b/components/index/index1.vue @@ -0,0 +1,509 @@ + + + + + \ No newline at end of file diff --git a/components/index/indexg.vue b/components/index/indexg.vue new file mode 100644 index 0000000..fe3b326 --- /dev/null +++ b/components/index/indexg.vue @@ -0,0 +1,448 @@ + + + + + \ No newline at end of file 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 +// +---------------------------------------------------------------------- +/* + 瑙f瀽鍜屽尮閰 Css 鐨勯夋嫨鍣 + github锛歨ttps://github.com/jin-yufeng/Parser + docs锛歨ttps://jin-yufeng.github.io/Parser + author锛欽inYufeng + 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 瑙f瀽涓洪傜敤浜庡皬绋嬪簭 rich-text 鐨 DOM 缁撴瀯 + github锛歨ttps://github.com/jin-yufeng/Parser + docs锛歨ttps://jin-yufeng.github.io/Parser + author锛欽inYufeng + 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); // 瑙e喅   澶辨晥 + 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, + // 浠g爜楂樹寒鍑芥暟 + 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 @@ + +