commit 0b3817b036dee3722f32679e6187174e2743f353 Author: xiaohei <1494046114@qq.com> Date: Tue Nov 7 21:03:11 2023 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7ce6e50 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +*.local + +# Editor directories and files +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? \ No newline at end of file diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json new file mode 100644 index 0000000..582561b --- /dev/null +++ b/.hbuilderx/launch.json @@ -0,0 +1,16 @@ +{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ + // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 + "version": "0.0", + "configurations": [{ + "app-plus" : + { + "launchtype" : "local" + }, + "default" : + { + "launchtype" : "local" + }, + "type" : "uniCloud" + } + ] +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..f8a54cb --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + + + + + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..a5892c3 --- /dev/null +++ b/package.json @@ -0,0 +1,75 @@ +{ + "name": "uni-preset-vue", + "version": "0.0.0", + "scripts": { + "dev:app": "uni -p app", + "dev:app-android": "uni -p app-android", + "dev:app-ios": "uni -p app-ios", + "dev:custom": "uni -p", + "dev:h5": "uni", + "dev:h5:ssr": "uni --ssr", + "dev:mp-alipay": "uni -p mp-alipay", + "dev:mp-baidu": "uni -p mp-baidu", + "dev:mp-jd": "uni -p mp-jd", + "dev:mp-kuaishou": "uni -p mp-kuaishou", + "dev:mp-lark": "uni -p mp-lark", + "dev:mp-qq": "uni -p mp-qq", + "dev:mp-toutiao": "uni -p mp-toutiao", + "dev:mp-weixin": "uni -p mp-weixin", + "dev:quickapp-webview": "uni -p quickapp-webview", + "dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei", + "dev:quickapp-webview-union": "uni -p quickapp-webview-union", + "build:app": "uni build -p app", + "build:app-android": "uni build -p app-android", + "build:app-ios": "uni build -p app-ios", + "build:custom": "uni build -p", + "build:h5": "uni build", + "build:h5:ssr": "uni build --ssr", + "build:mp-alipay": "uni build -p mp-alipay", + "build:mp-baidu": "uni build -p mp-baidu", + "build:mp-jd": "uni build -p mp-jd", + "build:mp-kuaishou": "uni build -p mp-kuaishou", + "build:mp-lark": "uni build -p mp-lark", + "build:mp-qq": "uni build -p mp-qq", + "build:mp-toutiao": "uni build -p mp-toutiao", + "build:mp-weixin": "uni build -p mp-weixin", + "build:quickapp-webview": "uni build -p quickapp-webview", + "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei", + "build:quickapp-webview-union": "uni build -p quickapp-webview-union", + "type-check": "vue-tsc --noEmit" + }, + "dependencies": { + "@dcloudio/uni-app": "3.0.0-3081220230817001", + "@dcloudio/uni-app-plus": "3.0.0-3081220230817001", + "@dcloudio/uni-components": "3.0.0-3081220230817001", + "@dcloudio/uni-h5": "3.0.0-3081220230817001", + "@dcloudio/uni-mp-alipay": "3.0.0-3081220230817001", + "@dcloudio/uni-mp-baidu": "3.0.0-3081220230817001", + "@dcloudio/uni-mp-jd": "3.0.0-3081220230817001", + "@dcloudio/uni-mp-kuaishou": "3.0.0-3081220230817001", + "@dcloudio/uni-mp-lark": "3.0.0-3081220230817001", + "@dcloudio/uni-mp-qq": "3.0.0-3081220230817001", + "@dcloudio/uni-mp-toutiao": "3.0.0-3081220230817001", + "@dcloudio/uni-mp-weixin": "3.0.0-3081220230817001", + "@dcloudio/uni-quickapp-webview": "3.0.0-3081220230817001", + "dayjs": "^1.10.4", + "less": "^4.2.0", + "less-loader": "^11.1.3", + "mp-html": "^2.4.1", + "vant": "^4.7.3", + "vue": "^3.2.45", + "vue-i18n": "^9.1.9" + }, + "devDependencies": { + "@dcloudio/types": "^3.3.2", + "@dcloudio/uni-automator": "3.0.0-3081220230817001", + "@dcloudio/uni-cli-shared": "3.0.0-3081220230817001", + "@dcloudio/uni-stacktracey": "3.0.0-3081220230817001", + "@dcloudio/vite-plugin-uni": "3.0.0-3081220230817001", + "@vue/runtime-core": "^3.2.45", + "@vue/tsconfig": "^0.1.3", + "typescript": "^4.9.4", + "vite": "4.1.4", + "vue-tsc": "^1.0.24" + } +} diff --git a/shims-uni.d.ts b/shims-uni.d.ts new file mode 100644 index 0000000..ed4adcf --- /dev/null +++ b/shims-uni.d.ts @@ -0,0 +1,10 @@ +/// +import 'vue' + +declare module '@vue/runtime-core' { + type Hooks = App.AppInstance & Page.PageInstance; + + interface ComponentCustomOptions extends Hooks { + + } +} diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..a1cbbf1 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,17 @@ +.DS_Store +node_modules/ +platforms/ +dist/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +package-lock.json +unpackage/ + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..9c6dc79 --- /dev/null +++ b/src/App.vue @@ -0,0 +1,42 @@ + + \ No newline at end of file diff --git a/src/api/consult.js b/src/api/consult.js new file mode 100644 index 0000000..c7a3130 --- /dev/null +++ b/src/api/consult.js @@ -0,0 +1,21 @@ +/** + * @name 新闻咨询API + * @description 请求示例 + * @param {Object} data 请求参数 + * @param {String} url 请求地址 + * @param {String} method 请求类型 可以不设置,默认GET + */ +import request from '../utils/request'; + +/** + * 获取工作公告列表 + * @param {*} data + */ +const getNewAPI = function (data) { + return request({ + url: '/admin-api/people/news/page', + method: 'get', + data: data + }); +}; +export { getNewAPI }; diff --git a/src/api/enterprise.js b/src/api/enterprise.js new file mode 100644 index 0000000..12483b5 --- /dev/null +++ b/src/api/enterprise.js @@ -0,0 +1,103 @@ +/** + * @name 企业API + * @description 请求示例 + * @param {Object} data 请求参数 + * @param {String} url 请求地址 + * @param {String} method 请求类型 可以不设置,默认GET + */ +import request from '../utils/request'; + +/** + * 获得企业分页 + * @param {*} data + */ +const getEnterpriseListApi = function (data) { + return request({ + url: '/admin-api/people/enterprise/page', + method: 'get', + data: data + }); +}; + +/** + * 删除企业 + * @param {*} data + */ +const DeleteEnterpriseIdApi = function (id) { + return request({ + url: `/admin-api/people/enterprise/delete?id=${id}`, + method: 'delete' + }); +}; + +/** + * 创建企业 + * @param {*} data + */ +const createAffiliatedEnterprise = function (data) { + return request({ + url: '/admin-api/people/enterprise/create', + method: 'post', + data: data + }); +}; + +/** + * 创建诉求 + * @param {*} data + */ +const createAppealApi = function (data) { + return request({ + url: '/admin-api/people/appeal/create', + method: 'post', + data: data + }); +}; + +/** + * 获得诉求分页 + * @param {*} data + */ +const getAppealListApi = function (data) { + return request({ + url: '/admin-api/people/appeal/page', + method: 'get', + data: data + }); +}; + +/** + * 获得诉求详情 + * @param {*} data + */ +const getAppealIdApi = function (data) { + return request({ + url: '/admin-api/people/appeal/get', + method: 'get', + data: data + }); +}; + +/** + * 获得优质回复 + * @param {*} data + */ +const getPerfectReplyApi = function (data) { + return request({ + url: '/admin-api/people/appeal/perfect/reply/page', + method: 'get', + data: data + }); +}; + +/** + * 更新企业 + * @param {*} data + */ +const getEnterpriseApi = function (id) { + return request({ + url: `/admin-api/people/enterprise/get?id=${id}`, + method: 'get' + }); +}; +export { getEnterpriseListApi, DeleteEnterpriseIdApi, createAffiliatedEnterprise, createAppealApi, getAppealListApi, getAppealIdApi, getPerfectReplyApi, getEnterpriseApi }; diff --git a/src/api/index.js b/src/api/index.js new file mode 100644 index 0000000..26867d3 --- /dev/null +++ b/src/api/index.js @@ -0,0 +1,23 @@ +/** + * @name API管理 + * @description 导出所有的API模块 + **/ +import * as publicApi from './publicApi.js'; // 公共 API + +import * as consult from './consult'; // 咨询 +import * as enterprise from './enterprise'; // 企业 +import * as lifeApi from './lifeApi'; // 生活 +import * as peopleApi from './peopleApi'; // 民生 +import * as myApi from './myApi'; // 我的 + +export default { + data() { + return {}; + }, + consult, + enterprise, + publicApi, + lifeApi, + peopleApi, + myApi +}; diff --git a/src/api/lifeApi.js b/src/api/lifeApi.js new file mode 100644 index 0000000..83c19ad --- /dev/null +++ b/src/api/lifeApi.js @@ -0,0 +1,45 @@ +/** + * @name 生活API + * @description 请求示例 + * @param {Object} data 请求参数 + * @param {String} url 请求地址 + * @param {String} method 请求类型 可以不设置,默认GET + */ +import request from '../utils/request'; + +/** + * 生活对应栏目的分页查询 + * @param {*} data + */ +const lifeListApi = function (data) { + return request({ + url: '/admin-api/people/life/list', + method: 'post', + data: data + }); +}; + +/** + * 获得商户分页 + * @param {*} data + */ +const merchantPageApi = function (data) { + return request({ + url: '/admin-api/people/merchant/page', + method: 'get', + data: data + }); +}; + +/** + * 获得商户详情 + * @param {*} data + */ +const merchantGetApi = function (data) { + return request({ + url: '/admin-api/people/merchant/get', + method: 'get', + data: data + }); +}; +export { lifeListApi, merchantPageApi, merchantGetApi }; diff --git a/src/api/myApi.js b/src/api/myApi.js new file mode 100644 index 0000000..c57c6cd --- /dev/null +++ b/src/api/myApi.js @@ -0,0 +1,171 @@ +/** + * @name 我的 + * @description 请求示例 + * @param {Object} data 请求参数 + * @param {String} url 请求地址 + * @param {String} method 请求类型 可以不设置,默认GET + */ +import request from '../utils/request'; + +/** + * 获取工作公告列表 + * @param {*} data + */ +const nameAuthApi = function (data) { + return request({ + url: '/admin-api/system/auth/real/name/auth', + method: 'post', + data: data + }); +}; +/** + * 获取我的信息 + * @param {*} data + */ +const getUserInfoApi = function (data) { + return request({ + url: '/admin-api/system/user/profile/get/my/info', + method: 'post', + data: data + }); +}; + +/** + * 获得用户积分规则分页 + * @param {*} data + */ +const userIntegralRruleApi = function (data) { + return request( + { + url: '/admin-api/system/user-integral-rule/page', + method: 'get', + data: data + }, + false + ); +}; + +/** + * 获得用户积分明细分页 + * @param {*} data + */ +const userIntegralDetailApi = function (data) { + return request({ + url: '/admin-api/system/user-integral-detail/page', + method: 'get', + data: data + }); +}; + +/** + * 获得用户我的收藏分页 + * @param {*} data + */ +const myInfoPageApi = function (data) { + return request({ + url: '/admin-api/people/collection/myInfo/page', + method: 'get', + data: data + }); +}; + +/** + * 统计党员-群众点单数据 + * @param {*} data + */ +const myMasserCountApi = function (data) { + return request({ + url: '/admin-api/people/seek-help/count', + method: 'get', + data: data + }); +}; + +/** + * 党员认证 + * @param {*} data + */ +const myMemberAuthApi = function (data) { + return request({ + url: '/admin-api/system/auth/party/member/auth', + method: 'post', + data: data + }); +}; + +/** + * 创建群众点单回复 + * @param {*} data + */ +const replyCreateApi = function (data) { + return request({ + url: '/admin-api/people/seek-help-reply/create', + method: 'post', + data: data + }); +}; +/** + * 获得群众点单回复 + * @param {*} data + */ +const replyCreateGetApi = function (data) { + return request({ + url: '/admin-api/people/seek-help-reply/get', + method: 'get', + data: data + }); +}; +/** + * 更新群众点单回复 + * @param {*} data + */ +const replyCreatUpdateApi = function (data) { + return request({ + url: '/admin-api/people/seek-help-reply/update', + method: 'PUT', + data: data + }); +}; +/** + * 查询优质回复 + * @param {*} data + */ +const replyGoodPageApi = function (data) { + return request({ + url: '/admin-api/people/seek-help-reply/good-page', + method: 'get', + data: data + }); +}; + +// 发送验证码 +const sendSmSCodeApi = function (data) { + return request({ + url: '/admin-api/system/auth/send-sms-code', + method: 'get', + data: data + }); +}; + +const systemAuthSmsLogin = function (data) { + return request({ + url: '/admin-api/system/auth/sms-login', + method: 'get', + data: data + }); +}; +export { + nameAuthApi, + getUserInfoApi, + userIntegralRruleApi, + userIntegralDetailApi, + myInfoPageApi, + myMasserCountApi, + myMemberAuthApi, + replyCreateApi, + replyCreateGetApi, + replyCreatUpdateApi, + replyGoodPageApi, + sendSmSCodeApi, + systemAuthSmsLogin +}; diff --git a/src/api/peopleApi.js b/src/api/peopleApi.js new file mode 100644 index 0000000..f83aa6a --- /dev/null +++ b/src/api/peopleApi.js @@ -0,0 +1,526 @@ +/** + * @name 民生API + * @description 请求示例 + * @param {Object} data 请求参数 + * @param {String} url 请求地址 + * @param {String} method 请求类型 可以不设置,默认GET + */ +import request from '../utils/request'; + +/** + * 获得议事厅分页 + * @param {*} data + */ +const assemblyHallPageApi = function (data) { + return request({ + url: '/admin-api/people/assembly-hall/page', + method: 'get', + data: data + }); +}; +/** + * 获得人民调解员分页 + * @param {*} data + */ +const mediatorPageApi = function (data) { + return request({ + url: '/admin-api/people/mediator/page', + method: 'get', + data: data + }); +}; +/** + * 获得人民调解员详情 + * @param {*} data + */ +const mediatorGetApi = function (data) { + return request({ + url: '/admin-api/people/mediator/get', + method: 'get', + data: data + }); +}; + +/** + * 获得群众点单分页 + * @param {*} data + */ +const seekHelpPageApi = function (data) { + return request({ + url: '/admin-api/people/seek-help/page', + method: 'get', + data: data + }); +}; +/** + * 创建群众点单 + * @param {*} data + */ +const seekHelpCreateApi = function (data) { + return request({ + url: '/admin-api/people/seek-help/create', + method: 'post', + data: data + }); +}; + +/** + * 获得群众点单详情 + * @param {*} data + */ +const seekHelpGetApi = function (data) { + return request({ + url: '/admin-api/people/seek-help/get', + method: 'get', + data: data + }); +}; +const massesDetailUpdate = function (data) { + // 点单状态变化如:接单 + return request({ + url: '/admin-api/people/seek-help/update', + method: 'put', + data: data + }); +}; +const seekHelpApi = function (data) { + // 点单 进行帮助 + return request({ + url: `/admin-api/people/seek-help/help/${data.id}`, + method: 'put', + data: data + }); +}; +/** + * 获得法律法规分页 + * @param {*} data + */ +const lawsRegulationPageApi = function (data) { + return request({ + url: '/admin-api/people/laws-regulation/page', + method: 'get', + data: data + }); +}; + +/** + * 获得法律法规详情 + * @param {*} data + */ +const lawsRegulationGetApi = function (data) { + return request({ + url: '/admin-api/people/laws-regulation/get', + method: 'get', + data: data + }); +}; + +/** + * 获得调解案件分页分页 + * @param {*} data + */ +const casesListApi = function (data) { + return request({ + url: '/admin-api/people/cases/page', + method: 'get', + data: data + }); +}; + +/** + * 获得调解案件 + * @param {*} data + */ +const getCasesIdApi = function (data) { + return request({ + url: '/admin-api/people/cases/get', + method: 'get', + data: data + }); +}; + +/** + * 创建调解案件 + * @param {*} data + */ +const createCasesApi = function (data) { + return request({ + url: '/admin-api/people/cases/create', + method: 'post', + data: data + }); +}; + +/** + * 获得党建引领详情 + * @param {*} data + */ +const newsGetApi = function (data) { + return request({ + url: '/admin-api/people/news/get', + method: 'get', + data: data + }); +}; + +/** + * 获得医院分页 + * @param {*} data + */ +const hospitalPageApi = function (data) { + return request({ + url: '/admin-api/people/hospital/page', + method: 'get', + data: data + }); +}; + +/** + * 获得医院详情 + * @param {*} data + */ +const hospitalGetApi = function (data) { + return request({ + url: '/admin-api/people/hospital/get', + method: 'get', + data: data + }); +}; +/** + * 获得医生分页 + * @param {*} data + */ +const doctorPageApi = function (data) { + return request({ + url: '/admin-api/people/doctor/page', + method: 'get', + data: data + }); +}; + +/** + * 获得议事厅分页 + * @param {*} data + */ +const assemblyIdApi = function (data) { + return request({ + url: '/admin-api/people/assemblymen/create', + method: 'post', + data: data + }); +}; + +/** + * 获得议事厅分页 + * @param {*} data + */ +const assemblyhallIdApi = function (data) { + return request({ + url: '/admin-api/people/assembly-hall/get', + method: 'get', + data: data + }); +}; + +/** + * 获得评论分页 + * @param {*} data + */ +const commentPageApi = function (data) { + return request({ + url: '/admin-api/people/comment/page', + method: 'get', + data: data + }); +}; + +/** + * 创建评论 + * @param {*} data + */ +const commentCreateApi = function (data) { + return request({ + url: '/admin-api/people/comment/create', + method: 'post', + data: data + }); +}; + +/** + * 获得议事厅详情 + * @param {*} data + */ +const assemblyHallGetApi = function (data) { + return request({ + url: '/admin-api/people/assembly-hall/get', + method: 'get', + data: data + }); +}; +/** + * 星级党支部 + * @param {*} data + */ +const partyBranchApi = function (data) { + return request({ + url: '/admin-api/people/party-branch/page', + method: 'get', + data: data + }); +}; +/** + * 获得党建引领 - 获得新闻资讯及活动分页 + * @param {*} data + * @param {*} data.categoryId // 取字典新闻类型的键值 + */ +const newsPageApi = function (data) { + return request({ + url: '/admin-api/people/news/page', + method: 'get', + data: data + }); +}; + +/** + * 星级党支部详情 + * @param {*} data + */ +const partyBranchGetApi = function (data) { + return request({ + url: '/admin-api/people/party-branch/get', + method: 'get', + data: data + }); +}; +/** + * 获得优秀党员分页 - 五星党员 + * @param {*} data + */ +const excellentPartMemberPageApi = function (data) { + return request({ + url: '/admin-api/people/excellent-party-member/page', + method: 'get', + data: data + }); +}; + +/** + * 获取部门列表 + * @param {*} data + */ +const deptListApi = function (data) { + return request({ + url: '/admin-api/system/dept/list', + method: 'get', + data: data + }); +}; + +/** + * 获得优秀党员详情 + * @param {*} data + */ +const excellentPartMemberGetApi = function (data) { + return request({ + url: '/admin-api/people/excellent-party-member/get', + method: 'get', + data: data + }); +}; + +/** + * 获得办事处分页 - 最美乡村 + * @param {*} data + */ +const agencyPageApi = function (data) { + return request({ + url: '/admin-api/people/agency/page', + method: 'get', + data: data + }); +}; + +/** + * 获得村务公开分页 + * @param {*} data + */ +const villageAffairsPageApi = function (data) { + return request({ + url: '/admin-api/people/village-affairs/page', + method: 'get', + data: data + }); +}; + +/** + * 获得办事处分页 + * @param {*} data + */ +const agencyContentPageApi = function (data) { + return request({ + url: '/admin-api/people/agency-content/page', + method: 'get', + data: data + }); +}; + +/** + * 获得群众点单评论 + * @param {*} data + */ +const CrateAppraiseApi = function (data) { + return request({ + url: '/admin-api/people/seek-help/appraise', + method: 'put', + data: data + }); +}; + +/** + * 获得办事处内容详情 + * @param {*} data + */ +const agencyContentGetApi = function (data) { + return request({ + url: '/admin-api/people/agency-content/get', + method: 'get', + data: data + }); +}; + +/** + * 获得办事处分页详情 + * @param {*} data + */ +const agencyGetApi = function (data) { + return request({ + url: '/admin-api/people/agency/get', + method: 'get', + data: data + }); +}; + +/** + * 获得办事处内容 + 根据部门id + * @param {*} data + */ +const agencyContentGetOrgIdApi = function (data) { + return request({ + url: '/admin-api/people/agency-content/getOrgId', + method: 'get', + data: data + }); +}; + +/** + * 获得办事处内容 + 根据部门id + * @param {*} data + */ +const villageAffairsGetApi = function (data) { + return request({ + url: '/admin-api/people/village-affairs/get', + method: 'get', + data: data + }); +}; + +/** + * 获得党活动事件分页 + * @param {*} data + */ +const partyEventPageApi = function (data) { + return request({ + url: '/admin-api/people/party-event/page', + method: 'get', + data: data + }); +}; + +/** + * 获得党活动事件分页详情 + * @param {*} data + */ +const partyEventGetApi = function (data) { + return request({ + url: '/admin-api/people/party-event/get', + method: 'get', + data: data + }); +}; + +/** + * 创建患者 - 申请签约家庭医生 + * @param {*} data + */ +const patientCreateApi = function (data) { + return request({ + url: '/admin-api/people/patient/create', + method: 'post', + data: data + }); +}; +/** + * 获取网格列表 + * @param {*} data + */ +const getGridListApi = function (data) { + return request({ + url: '/admin-api/people/grid/page', + method: 'get', + data: data + }); +}; +/** + * 获取网格成员列表 + * @param {*} data + */ +const getGridMemberListApi = function (data) { + return request({ + url: '/admin-api/people/grid-member/page', + method: 'get', + data: data + }); +}; +export { + assemblyHallPageApi, + mediatorPageApi, + mediatorGetApi, + seekHelpPageApi, + seekHelpCreateApi, + seekHelpGetApi, + lawsRegulationPageApi, + lawsRegulationGetApi, + massesDetailUpdate, + seekHelpApi, + casesListApi, + getCasesIdApi, + createCasesApi, + newsGetApi, + hospitalPageApi, + hospitalGetApi, + doctorPageApi, + commentPageApi, + commentCreateApi, + assemblyHallGetApi, + newsPageApi, + assemblyIdApi, + assemblyhallIdApi, + partyBranchApi, + partyBranchGetApi, + excellentPartMemberPageApi, + deptListApi, + excellentPartMemberGetApi, + agencyPageApi, + villageAffairsPageApi, + agencyContentPageApi, + CrateAppraiseApi, + agencyContentGetApi, + agencyGetApi, + agencyContentGetOrgIdApi, + villageAffairsGetApi, + partyEventPageApi, + partyEventGetApi, + patientCreateApi, + getGridListApi, + getGridMemberListApi +}; diff --git a/src/api/publicApi.js b/src/api/publicApi.js new file mode 100644 index 0000000..06522a8 --- /dev/null +++ b/src/api/publicApi.js @@ -0,0 +1,209 @@ +/** + * @name 公共接口API + * @description 请求示例 + * @param {Object} data 请求参数 + * @param {String} url 请求地址 + * @param {String} method 请求类型 可以不设置,默认GET + */ +import request from '../utils/request'; + +/** + * 获得banner图分页 + * @param {*} data + */ +const getBannerApi = function (data) { + return request({ + url: '/admin-api/people/banner/page', + method: 'get', + data: data + }); +}; + +/** + * 获得字典类型的分页列表 + * @param {*} data + */ +const getDictDataApi = function (data) { + return request({ + url: '/admin-api/system/dict-data/page', + method: 'get', + data: data + }); +}; + +/** + * 上传文件 + * @param {*} data + */ +const uploadApi = function (data) { + return request({ + url: '/admin-api/infra/file/upload', + method: 'post', + data: data + }); +}; + +/** + * 分类树--查询下级分类 + * @param {*} data + * @param {*} data.bannerType // 字典TabBar模块 1民生、2生活... + * @param {*} data.parentId // 根据上级列表id查询下级列表 + */ +const recursionApi = function (data) { + return request( + { + url: '/admin-api/people/category/recursion', + method: 'get', + data: data + }, + false + ); +}; + +/** + * 创建点赞 + * @param {*} data + */ +const praiseCreateApi = function (data) { + return request({ + url: '/admin-api/people/praise/create', + method: 'post', + data: data + }); +}; + +/** + * 取消点赞 + * @param {*} data + */ +const praiseCancelApi = function (data) { + return request({ + url: '/admin-api/people/praise/cancel', + method: 'post', + data: data + }); +}; + +/** + * 创建分享 + * @param {*} data + */ +const shareCreateApi = function (data) { + return request({ + url: '/admin-api/people/share/create', + method: 'post', + data: data + }); +}; + +/** + * 创建用户收藏 + * @param {*} data + */ +const collectionCreateApi = function (data) { + return request({ + url: '/admin-api/people/collection/create', + method: 'post', + data: data + }); +}; +/** + * 取消用户收藏 + * @param {*} data + */ +const collectionCancelApi = function (data) { + return request({ + url: '/admin-api/people/collection/cancel', + method: 'post', + data: data + }); +}; + +/** + * 获得案件处理过程分页 + * @param {*} data + */ +const casesProcessPageApi = function (data) { + return request({ + url: '/admin-api/people/cases-process/page', + method: 'get', + data: data + }); +}; + +/** + * 获取部门树 + * @param {*} data + */ +const deptTreeApi = function (data) { + return request({ + url: '/admin-api/system/dept/tree', + method: 'get', + data: data + }); +}; + +/** + * 获得服务记录详情 + * @param {*} data + */ +const serveRecordGetApi = function (data) { + return request({ + url: '/admin-api/people/serve-record/get', + method: 'get', + data: data + }); +}; + +/** + * 获得服务记录分页 + * @param {*} data + */ +const serveRecordPageApi = function (data) { + return request({ + url: '/admin-api/people/serve-record/page', + method: 'get', + data: data + }); +}; + +/** + * 获得线上问诊分页 + * @param {*} data + */ +const inquiriesOnlinePageApi = function (data) { + return request({ + url: '/admin-api/people/inquiries-online/page', + method: 'get', + data: data + }); +}; + +/** + * 获得线上问诊详情 + * @param {*} data + */ +const inquiriesOnlineGetApi = function (data) { + return request({ + url: '/admin-api/people/inquiries-online/get', + method: 'get', + data: data + }); +}; +export { + getBannerApi, + getDictDataApi, + uploadApi, + recursionApi, + praiseCreateApi, + praiseCancelApi, + shareCreateApi, + collectionCreateApi, + collectionCancelApi, + casesProcessPageApi, + deptTreeApi, + serveRecordGetApi, + serveRecordPageApi, + inquiriesOnlineGetApi, + inquiriesOnlinePageApi +}; diff --git a/src/components/custom-nav-bar/custom-nav-bar.vue b/src/components/custom-nav-bar/custom-nav-bar.vue new file mode 100644 index 0000000..8caea4b --- /dev/null +++ b/src/components/custom-nav-bar/custom-nav-bar.vue @@ -0,0 +1,160 @@ + + + + \ No newline at end of file diff --git a/src/config/constant.js b/src/config/constant.js new file mode 100644 index 0000000..b09a5c8 --- /dev/null +++ b/src/config/constant.js @@ -0,0 +1,50 @@ +/** + * @name 常量 + * @description 多环境配置 + * @param {Boolean} debug 是否开启debug模式 + * @param {Object} env 当前的项目环境配置 + * @param {Object} systemInfo 当前的系统信息 + * @param {Boolean} isIPhone 判断机型是否是iPhone + * @param {Boolean} isIPhoneX 判断机型是否是iPhoneX系列 + * @param {Boolean} menu 小程序顶部胶囊按钮的信息 + * @param {Object} locationInfo 用户的当前位置信息 + */ +import env from './env'; + +import amap from "@/lib/wx-map-sdk/amap-wx.130.js"; +function getLocationInfo() { + const info = {}; + uni.getLocation(function(res) { + console.log('纬度:' + res.latitude); + console.log('经度:' + res.longitude); + }); + const myAmapFun = new amap.AMapWX({ + key: env.aMapKey + }); + myAmapFun.getRegeo({ + success: function (res) { + if (!res.length) { + return; + } + Object.assign(info, res[0]); + }, + fail: function (info) { + uni.showModal({ + title: info.errMsg + }); + } + }); + return info; +} +export default { + data() { + return {}; + }, + debug: true, + env, + systemInfo: uni.getSystemInfoSync(), + menu: uni.getSystemInfoSync(), + isIPhone: uni.getSystemInfoSync().model.indexOf('iPhone') >= 0, + isIPhoneX: uni.getSystemInfoSync().model.lastIndexOf('X') >= 0, + locationInfo: getLocationInfo() +}; \ No newline at end of file diff --git a/src/config/env.js b/src/config/env.js new file mode 100644 index 0000000..bebb3d3 --- /dev/null +++ b/src/config/env.js @@ -0,0 +1,35 @@ +/** + * @name 小程序环境 + * @description 多环境配置 + */ +const envName = 'development'; +const envs = [{ + envName: 'production', + appID: 'wx736395182f05a1b7', + appName: '介休网格通', + version: '1.0.0', + baseUrl: 'https://jxwgtjm.xuqidata.com:8088', + fileUrl: 'https://jiexiu.xuqidata.com:8083/jiexiujumin', + loginPath: '/admin-api/system/auth/wechat/app/login', + aMapKey: '29103dae675e5788eb011fb77ade8e3f', + pubkey: 'Si9veMEER0LGTcLL6xwRWxUB7UCF7jjb00548e0ddc1501de0f' + }, + { + envName: 'development', + appID: 'wxcee598c3eb71e48d', + appName: '智慧旭奇', + version: '1.0.0', + baseUrl: 'http://47.92.245.35:5002', + // 接口前缀 + fileUrl: 'http://47.92.245.35:5009/xq-ssg', + // 图片服务器 + loginPath: '/admin-api/system/auth/wechat/app/login', + // 登陆接口 + aMapKey: '6e488a3ed079adbb01de2ecb88ca5905', + // 高德地图key + pubkey: 'O9eM4Cv5bpi30mgUw9GEkf19KVE8KE8D00a46a6e50bb9465b2' // 吾来对话机器人平台key + } +]; + +const isFind = envs.find((item) => item.envName === envName); +export default isFind; \ No newline at end of file diff --git a/src/config/index.js b/src/config/index.js new file mode 100644 index 0000000..bd0149b --- /dev/null +++ b/src/config/index.js @@ -0,0 +1,13 @@ +/** + * @name Config + * @description 项目配置 + */ +import env from './env'; +import constant from './constant'; +export default { + data() { + return {}; + }, + env, + ...constant +}; diff --git a/src/env.d.ts b/src/env.d.ts new file mode 100644 index 0000000..d27eb5a --- /dev/null +++ b/src/env.d.ts @@ -0,0 +1,8 @@ +/// + +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/src/images/default-avatar.png b/src/images/default-avatar.png new file mode 100644 index 0000000..201174c Binary files /dev/null and b/src/images/default-avatar.png differ diff --git a/src/images/enterprise/icon-1.png b/src/images/enterprise/icon-1.png new file mode 100644 index 0000000..2f0d307 Binary files /dev/null and b/src/images/enterprise/icon-1.png differ diff --git a/src/images/enterprise/icon.png b/src/images/enterprise/icon.png new file mode 100644 index 0000000..2f6b6da Binary files /dev/null and b/src/images/enterprise/icon.png differ diff --git a/src/images/ic-arrow-black.png b/src/images/ic-arrow-black.png new file mode 100644 index 0000000..e96c93a Binary files /dev/null and b/src/images/ic-arrow-black.png differ diff --git a/src/images/ic-arrow-white.png b/src/images/ic-arrow-white.png new file mode 100644 index 0000000..9bcd3f4 Binary files /dev/null and b/src/images/ic-arrow-white.png differ diff --git a/src/images/ic-collection.png b/src/images/ic-collection.png new file mode 100644 index 0000000..4568d3d Binary files /dev/null and b/src/images/ic-collection.png differ diff --git a/src/images/ic-collection1.png b/src/images/ic-collection1.png new file mode 100644 index 0000000..b7a8f71 Binary files /dev/null and b/src/images/ic-collection1.png differ diff --git a/src/images/ic-give.png b/src/images/ic-give.png new file mode 100644 index 0000000..6ff93f9 Binary files /dev/null and b/src/images/ic-give.png differ diff --git a/src/images/ic-give1.png b/src/images/ic-give1.png new file mode 100644 index 0000000..e30e9c4 Binary files /dev/null and b/src/images/ic-give1.png differ diff --git a/src/images/ic-give2.png b/src/images/ic-give2.png new file mode 100644 index 0000000..174c0f0 Binary files /dev/null and b/src/images/ic-give2.png differ diff --git a/src/images/ic-radio.png b/src/images/ic-radio.png new file mode 100644 index 0000000..17eeffa Binary files /dev/null and b/src/images/ic-radio.png differ diff --git a/src/images/ic-radio1.png b/src/images/ic-radio1.png new file mode 100644 index 0000000..3c9b61d Binary files /dev/null and b/src/images/ic-radio1.png differ diff --git a/src/images/ic-share.png b/src/images/ic-share.png new file mode 100644 index 0000000..e394fd0 Binary files /dev/null and b/src/images/ic-share.png differ diff --git a/src/images/ic-success.png b/src/images/ic-success.png new file mode 100644 index 0000000..48b36f4 Binary files /dev/null and b/src/images/ic-success.png differ diff --git a/src/images/ic-you.png b/src/images/ic-you.png new file mode 100644 index 0000000..7fb72a4 Binary files /dev/null and b/src/images/ic-you.png differ diff --git a/src/images/icon-people.png b/src/images/icon-people.png new file mode 100644 index 0000000..3e5fcf3 Binary files /dev/null and b/src/images/icon-people.png differ diff --git a/src/images/icon1.png b/src/images/icon1.png new file mode 100644 index 0000000..0a6fe4c Binary files /dev/null and b/src/images/icon1.png differ diff --git a/src/images/icon2.png b/src/images/icon2.png new file mode 100644 index 0000000..d7c3246 Binary files /dev/null and b/src/images/icon2.png differ diff --git a/src/images/icon3.png b/src/images/icon3.png new file mode 100644 index 0000000..7bb450b Binary files /dev/null and b/src/images/icon3.png differ diff --git a/src/images/icon4.png b/src/images/icon4.png new file mode 100644 index 0000000..6783b0a Binary files /dev/null and b/src/images/icon4.png differ diff --git a/src/images/icon5.png b/src/images/icon5.png new file mode 100644 index 0000000..10f0922 Binary files /dev/null and b/src/images/icon5.png differ diff --git a/src/images/icon9.png b/src/images/icon9.png new file mode 100644 index 0000000..7bd1e17 Binary files /dev/null and b/src/images/icon9.png differ diff --git a/src/images/rate-icon.png b/src/images/rate-icon.png new file mode 100644 index 0000000..da2ba8c Binary files /dev/null and b/src/images/rate-icon.png differ diff --git a/src/images/search.png b/src/images/search.png new file mode 100644 index 0000000..5060ced Binary files /dev/null and b/src/images/search.png differ diff --git a/src/images/share-icon.png b/src/images/share-icon.png new file mode 100644 index 0000000..4596df0 Binary files /dev/null and b/src/images/share-icon.png differ diff --git a/src/images/tabbar/ic-consult.png b/src/images/tabbar/ic-consult.png new file mode 100644 index 0000000..269b20f Binary files /dev/null and b/src/images/tabbar/ic-consult.png differ diff --git a/src/images/tabbar/ic-enterprise.png b/src/images/tabbar/ic-enterprise.png new file mode 100644 index 0000000..eda2d72 Binary files /dev/null and b/src/images/tabbar/ic-enterprise.png differ diff --git a/src/images/tabbar/ic-life.png b/src/images/tabbar/ic-life.png new file mode 100644 index 0000000..0e1a1c0 Binary files /dev/null and b/src/images/tabbar/ic-life.png differ diff --git a/src/images/tabbar/ic-my.png b/src/images/tabbar/ic-my.png new file mode 100644 index 0000000..620f218 Binary files /dev/null and b/src/images/tabbar/ic-my.png differ diff --git a/src/images/tabbar/ic-people.png b/src/images/tabbar/ic-people.png new file mode 100644 index 0000000..00bc221 Binary files /dev/null and b/src/images/tabbar/ic-people.png differ diff --git a/src/images/void-icon2.png b/src/images/void-icon2.png new file mode 100644 index 0000000..fe41069 Binary files /dev/null and b/src/images/void-icon2.png differ diff --git a/src/lib/wux-weapp/animation-group/index.vue b/src/lib/wux-weapp/animation-group/index.vue new file mode 100644 index 0000000..6fb2d2e --- /dev/null +++ b/src/lib/wux-weapp/animation-group/index.vue @@ -0,0 +1,573 @@ + + + + diff --git a/src/lib/wux-weapp/backdrop/index.vue b/src/lib/wux-weapp/backdrop/index.vue new file mode 100644 index 0000000..d1cac21 --- /dev/null +++ b/src/lib/wux-weapp/backdrop/index.vue @@ -0,0 +1,87 @@ + + + + diff --git a/src/lib/wux-weapp/cascader/index.vue b/src/lib/wux-weapp/cascader/index.vue new file mode 100644 index 0000000..999b45e --- /dev/null +++ b/src/lib/wux-weapp/cascader/index.vue @@ -0,0 +1,489 @@ + + + + diff --git a/src/lib/wux-weapp/helpers/arrayTreeFilter.js b/src/lib/wux-weapp/helpers/arrayTreeFilter.js new file mode 100644 index 0000000..9210c34 --- /dev/null +++ b/src/lib/wux-weapp/helpers/arrayTreeFilter.js @@ -0,0 +1,25 @@ +'use strict'; +function arrayTreeFilter(e, r, t) { + (t = t || {}).childrenKeyName = t.childrenKeyName || 'children'; + var a = e || []; + var l = []; + var i = 0; + do { + var d = a.filter(function (e) { + return r(e, i); + })[0]; + if (!d) { + break; + } + l.push(d); + a = d[t.childrenKeyName] || []; + i += 1; + } while (0 < a.length); + return l; +} +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var _default = arrayTreeFilter; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/baseComponent.js b/src/lib/wux-weapp/helpers/baseComponent.js new file mode 100644 index 0000000..69736f7 --- /dev/null +++ b/src/lib/wux-weapp/helpers/baseComponent.js @@ -0,0 +1,141 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var _computedBehavior = _interopRequireDefault(require('./computedBehavior')); +var _relationsBehavior = _interopRequireDefault(require('./relationsBehavior')); +var _safeAreaBehavior = _interopRequireDefault(require('./safeAreaBehavior')); +var _safeSetDataBehavior = _interopRequireDefault(require('./safeSetDataBehavior')); +var _funcBehavior = _interopRequireDefault(require('./funcBehavior')); +var _compareVersion = _interopRequireDefault(require('./compareVersion')); +function _interopRequireDefault(e) { + return e && e.__esModule + ? e + : { + default: e + }; +} +function ownKeys(r, e) { + var t = Object.keys(r); + if (Object.getOwnPropertySymbols) { + var o = Object.getOwnPropertySymbols(r); + if (e) { + o = o.filter(function (e) { + return Object.getOwnPropertyDescriptor(r, e).enumerable; + }); + } + t.push.apply(t, o); + } + return t; +} +function _objectSpread(r) { + for (var e = 1; e < arguments.length; e++) { + if (null != arguments[e]) { + var t = arguments[e]; + } else { + } + e % 2 + ? ownKeys(t, true).forEach(function (e) { + _defineProperty(r, e, t[e]); + }) + : Object.getOwnPropertyDescriptors + ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(t)) + : ownKeys(t).forEach(function (e) { + Object.defineProperty(r, e, Object.getOwnPropertyDescriptor(t, e)); + }); + } + return r; +} +function _defineProperty(e, r, t) { + r in e + ? Object.defineProperty(e, r, { + value: t, + enumerable: true, + configurable: true, + writable: true + }) + : (e[r] = t); + return e; +} +function _toConsumableArray(e) { + return _arrayWithoutHoles(e) || _iterableToArray(e) || _nonIterableSpread(); +} +function _nonIterableSpread() { + throw new TypeError('Invalid attempt to spread non-iterable instance'); +} +function _iterableToArray(e) { + if (Symbol.iterator in Object(e) || '[object Arguments]' === Object.prototype.toString.call(e)) { + return Array.from(e); + } +} +function _arrayWithoutHoles(e) { + if (Array.isArray(e)) { + for (r = 0, t = new Array(e.length), void 0; r < e.length; r++) { + var r; + var t; + t[r] = e[r]; + } + return t; + } +} +var _wx$getSystemInfoSync = uni.getSystemInfoSync(); +var platform = _wx$getSystemInfoSync.platform; +var SDKVersion = _wx$getSystemInfoSync.SDKVersion; +var libVersion = '2.6.6'; +if ('devtools' === platform && (0, _compareVersion.default)(SDKVersion, libVersion) < 0 && wx && uni.showModal) { + uni.showModal({ + title: '提示', + content: '当前基础库版本('.concat(SDKVersion, ')过低,无法使用 Wux Weapp 组件库,请更新基础库版本 >=').concat(libVersion, ' 后重试。') + }); +} +var baseComponent = function (e) { + if (0 < arguments.length && void 0 !== e) { + var t = e; + } else { + } + t.externalClasses = ['wux-class', 'wux-hover-class'].concat(_toConsumableArray((t.externalClasses = t.externalClasses || []))); + t.behaviors = [_relationsBehavior.default, _safeSetDataBehavior.default].concat(_toConsumableArray((t.behaviors = t.behaviors || [])), [_computedBehavior.default]); + if (t.useSafeArea) { + t.behaviors = [].concat(_toConsumableArray(t.behaviors), [_safeAreaBehavior.default]); + delete t.useSafeArea; + } + if (t.useFunc) { + t.behaviors = [].concat(_toConsumableArray(t.behaviors), [_funcBehavior.default]); + delete t.useFunc; + } + if (t.useField) { + t.behaviors = [].concat(_toConsumableArray(t.behaviors), ['wx://form-field']); + delete t.useField; + } + if (t.useExport) { + t.behaviors = [].concat(_toConsumableArray(t.behaviors), ['wx://component-export']); + t.methods = _objectSpread( + { + export: function () { + return this; + } + }, + t.methods + ); + delete t.useExport; + } + t.options = _objectSpread( + { + multipleSlots: true, + addGlobalClass: true + }, + t.options + ); + if (t.properties) { + Object.keys(t.properties).forEach(function (e) { + var r = t.properties[e]; + if (Array.isArray(r.type)) { + r.optionalTypes = r.type; + } + }); + } + return Component(t); +}; +var _default = baseComponent; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/checkIPhoneX.js b/src/lib/wux-weapp/helpers/checkIPhoneX.js new file mode 100644 index 0000000..3cf2b29 --- /dev/null +++ b/src/lib/wux-weapp/helpers/checkIPhoneX.js @@ -0,0 +1,42 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.checkIPhoneX = exports.getSystemInfo = exports.safeAreaInset = void 0; +var systemInfo = null; +var safeAreaInset = { + top: 88, + left: 0, + right: 0, + bottom: 34 +}; +exports.safeAreaInset = safeAreaInset; +var getSystemInfo = function (e) { + if (!systemInfo || e) { + try { + systemInfo = uni.getSystemInfoSync(); + } catch (e) { + console.log('CatchClause', e); + console.log('CatchClause', e); + } + try { + safeAreaInset.top = systemInfo.statusBarHeight + systemInfo.safeArea.top; + safeAreaInset.bottom = systemInfo.screenHeight - systemInfo.safeArea.bottom; + } catch (e) { + console.log('CatchClause', e); + console.log('CatchClause', e); + } + } + return systemInfo; +}; +exports.getSystemInfo = getSystemInfo; +var isIPhoneX = function (e) { + var t = e.model; + var s = e.windowHeight; + var o = e.windowWidth; + return /iphone (x|12|13)/.test(t.toLowerCase()) || (812 <= s && 2 < s / o); +}; +var checkIPhoneX = function (e) { + return isIPhoneX(getSystemInfo(e)); +}; +(exports.checkIPhoneX = checkIPhoneX)(); diff --git a/src/lib/wux-weapp/helpers/classNames.js b/src/lib/wux-weapp/helpers/classNames.js new file mode 100644 index 0000000..9e75a17 --- /dev/null +++ b/src/lib/wux-weapp/helpers/classNames.js @@ -0,0 +1,42 @@ +'use strict'; +function _typeof(e) { + return (_typeof = + 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator + ? function (e) { + return typeof e; + } + : function (e) { + return e && 'function' == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? 'symbol' : typeof e; + })(e); +} +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var hasOwn = {}.hasOwnProperty; +function classNames() { + for (e = [], t = 0, void 0; t < arguments.length; t++) { + var e; + var t; + var o = arguments[t]; + if (o) { + var r = _typeof(o); + if ('string' === r || 'number' === r) e.push(o); + else if (Array.isArray(o) && o.length) { + var n = classNames.apply(null, o); + if (n) { + e.push(n); + } + } else if ('object' === r) { + for (var s in o) { + if (hasOwn.call(o, s) && o[s]) { + e.push(s); + } + } + } + } + } + return e.join(' '); +} +var _default = classNames; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/colors.js b/src/lib/wux-weapp/helpers/colors.js new file mode 100644 index 0000000..e7d1d49 --- /dev/null +++ b/src/lib/wux-weapp/helpers/colors.js @@ -0,0 +1,21 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.isPresetColor = exports.colors = void 0; +var colors = { + light: '#ddd', + stable: '#b2b2b2', + positive: '#387ef5', + calm: '#11c1f3', + balanced: '#33cd5f', + energized: '#ffc900', + assertive: '#ef473a', + royal: '#886aea', + dark: '#444' +}; +exports.colors = colors; +var isPresetColor = function (e) { + return !!e && (colors[e] ? colors[e] : e); +}; +exports.isPresetColor = isPresetColor; diff --git a/src/lib/wux-weapp/helpers/compareVersion.js b/src/lib/wux-weapp/helpers/compareVersion.js new file mode 100644 index 0000000..a5710e3 --- /dev/null +++ b/src/lib/wux-weapp/helpers/compareVersion.js @@ -0,0 +1,29 @@ +'use strict'; +function compareVersion(e, r) { + for (t = e.split('.'), a = r.split('.'), n = Math.max(t.length, a.length), void 0; t.length < n; ) { + var t; + var a; + var n; + t.push('0'); + } + for (; a.length < n; ) { + a.push('0'); + } + for (var o = 0; o < n; o++) { + var s = parseInt(t[o]); + var u = parseInt(a[o]); + if (u < s) { + return 1; + } + if (s < u) { + return -1; + } + } + return 0; +} +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var _default = compareVersion; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/computedBehavior.js b/src/lib/wux-weapp/helpers/computedBehavior.js new file mode 100644 index 0000000..85bb0ef --- /dev/null +++ b/src/lib/wux-weapp/helpers/computedBehavior.js @@ -0,0 +1,178 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var _isEmpty = _interopRequireDefault(require('./isEmpty')); +var _shallowEqual = _interopRequireDefault(require('./shallowEqual')); +function _interopRequireDefault(e) { + return e && e.__esModule + ? e + : { + default: e + }; +} +function _toConsumableArray(e) { + return _arrayWithoutHoles(e) || _iterableToArray(e) || _nonIterableSpread(); +} +function _nonIterableSpread() { + throw new TypeError('Invalid attempt to spread non-iterable instance'); +} +function _iterableToArray(e) { + if (Symbol.iterator in Object(e) || '[object Arguments]' === Object.prototype.toString.call(e)) { + return Array.from(e); + } +} +function _arrayWithoutHoles(e) { + if (Array.isArray(e)) { + for (r = 0, t = new Array(e.length), void 0; r < e.length; r++) { + var r; + var t; + t[r] = e[r]; + } + return t; + } +} +function ownKeys(r, e) { + var t = Object.keys(r); + if (Object.getOwnPropertySymbols) { + var n = Object.getOwnPropertySymbols(r); + if (e) { + n = n.filter(function (e) { + return Object.getOwnPropertyDescriptor(r, e).enumerable; + }); + } + t.push.apply(t, n); + } + return t; +} +function _objectSpread(r) { + for (var e = 1; e < arguments.length; e++) { + if (null != arguments[e]) { + var t = arguments[e]; + } else { + var t = {}; + } + e % 2 + ? ownKeys(t, true).forEach(function (e) { + _defineProperty(r, e, t[e]); + }) + : Object.getOwnPropertyDescriptors + ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(t)) + : ownKeys(t).forEach(function (e) { + Object.defineProperty(r, e, Object.getOwnPropertyDescriptor(t, e)); + }); + } + return r; +} +function _defineProperty(e, r, t) { + r in e + ? Object.defineProperty(e, r, { + value: t, + enumerable: true, + configurable: true, + writable: true + }) + : (e[r] = t); + return e; +} +function _slicedToArray(e, r) { + return _arrayWithHoles(e) || _iterableToArrayLimit(e, r) || _nonIterableRest(); +} +function _nonIterableRest() { + throw new TypeError('Invalid attempt to destructure non-iterable instance'); +} +function _iterableToArrayLimit(e, r) { + var t = []; + var n = true; + var o = false; + var i = void 0; + try { + for (u = e[Symbol.iterator](), void 0; !(n = (a = u.next()).done) && (t.push(a.value), !r || t.length !== r); n = true) { + var a; + var u; + } + } catch (e) { + console.log('CatchClause', e); + console.log('CatchClause', e); + o = true; + i = e; + } finally { + try { + n || null == u.return || u.return(); + } finally { + if (o) { + throw i; + } + } + } + return t; +} +function _arrayWithHoles(e) { + if (Array.isArray(e)) { + return e; + } +} +var ALL_DATA_KEY = '**'; +var trim = function (e) { + return (0 < arguments.length && void 0 !== e ? e : '').replace(/\s/g, ''); +}; +var _default = { + lifetimes: { + attached: function () { + this.initComputed(); + } + }, + definitionFilter: function (e) { + var r = e.computed; + if (void 0 === r) { + var n = {}; + } else { + var n = r; + } + var a = Object.keys(n).reduce(function (e, i) { + var r = _slicedToArray(Array.isArray(n[i]) ? n[i] : [ALL_DATA_KEY, n[i]], 2); + var t = r[0]; + var a = r[1]; + return _objectSpread( + {}, + e, + _defineProperty({}, t, function () { + if ('function' == typeof a) { + for (e = arguments.length, r = new Array(e), t = 0, void 0; t < e; t++) { + var e; + var r; + var t; + r[t] = arguments[t]; + } + var n = a.apply(this, r); + var o = this[i]; + (0, _isEmpty.default)(n) || (0, _shallowEqual.default)(n, o) || this.setData(_defineProperty({}, i, n)); + } + }) + ); + }, {}); + Object.assign((e.observers = e.observers || {}), a); + Object.assign((e.methods = e.methods || {}), { + initComputed: function (e, r) { + var t = 0 < arguments.length && void 0 !== e ? e : {}; + var n = 1 < arguments.length && void 0 !== r && r; + if (!this.runInitComputed || n) { + this.runInitComputed = false; + var that = this; + var i = _objectSpread({}, this, {}, t); + Object.keys(a).forEach(function (e) { + var r = trim(e) + .split(',') + .reduce(function (e, r) { + return [].concat(_toConsumableArray(e), [i[r]]); + }, []); + a[e].apply(that, r); + }); + this.runInitComputed = true; + } + } + }); + } +}; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/createFieldsStore.js b/src/lib/wux-weapp/helpers/createFieldsStore.js new file mode 100644 index 0000000..1b8d5e5 --- /dev/null +++ b/src/lib/wux-weapp/helpers/createFieldsStore.js @@ -0,0 +1,170 @@ +'use strict'; +function ownKeys(t, e) { + var r = Object.keys(t); + if (Object.getOwnPropertySymbols) { + var n = Object.getOwnPropertySymbols(t); + if (e) { + n = n.filter(function (e) { + return Object.getOwnPropertyDescriptor(t, e).enumerable; + }); + } + r.push.apply(r, n); + } + return r; +} +function _objectSpread(t) { + for (var e = 1; e < arguments.length; e++) { + if (null != arguments[e]) { + var r = arguments[e]; + } else { + var r = {}; + } + if (e % 2) { + ownKeys(r, true).forEach(function (e) { + _defineProperty(t, e, r[e]); + }); + } else { + Object.getOwnPropertyDescriptors + ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) + : ownKeys(r).forEach(function (e) { + Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(r, e)); + }); + } + } + return t; +} +function _defineProperty(e, t, r) { + t in e + ? Object.defineProperty(e, t, { + value: r, + enumerable: true, + configurable: true, + writable: true + }) + : (e[t] = r); + return e; +} +function _classCallCheck(e, t) { + if (!(e instanceof t)) { + throw new TypeError('Cannot call a class as a function'); + } +} +function _defineProperties(e, t) { + for (var r = 0; r < t.length; r++) { + var n = t[r]; + n.enumerable = n.enumerable || false; + n.configurable = true; + if ('value' in n) { + n.writable = true; + } + Object.defineProperty(e, n.key, n); + } +} +function _createClass(e, t, r) { + if (t) { + _defineProperties(e.prototype, t); + } + if (r) { + _defineProperties(e, r); + } + return e; +} +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = createFieldsStore; +var FieldsStore = (function () { + function t() { + if (0 < arguments.length && void 0 !== arguments[0]) { + var e = arguments[0]; + } else { + var e = {}; + } + _classCallCheck(this, t); + this.fields = e; + } + _createClass(t, [ + { + key: 'setFields', + value: function (e) { + Object.assign(this.fields, e); + } + }, + { + key: 'updateFields', + value: function (e) { + this.fields = e; + } + }, + { + key: 'clearField', + value: function (e) { + delete this.fields[e]; + } + }, + { + key: 'getValueFromFields', + value: function (e, t) { + var r = t[e]; + return r && 'value' in r ? r.value : r.initialValue; + } + }, + { + key: 'getAllFieldsName', + value: function () { + var e = this.fields; + return e ? Object.keys(e) : []; + } + }, + { + key: 'getField', + value: function (e) { + return _objectSpread({}, this.fields[e], { + name: e + }); + } + }, + { + key: 'getFieldValuePropValue', + value: function (e) { + var t = e.name; + var r = e.valuePropName; + var n = this.getField(t); + return _defineProperty({}, r, 'value' in n ? n.value : n.initialValue); + } + }, + { + key: 'getFieldValue', + value: function (e) { + return this.getValueFromFields(e, this.fields); + } + }, + { + key: 'getFieldsValue', + value: function (e) { + var that = this; + return (e || this.getAllFieldsName()).reduce(function (e, t) { + e[t] = that.getFieldValue(t); + return e; + }, {}); + } + }, + { + key: 'resetFields', + value: function (e) { + var n = this.fields; + return (e || this.getAllFieldsName()).reduce(function (e, t) { + var r = n[t]; + if (r) { + e[t] = r.initialValue; + } + return e; + }, {}); + } + } + ]); + return t; +})(); +function createFieldsStore(e) { + return new FieldsStore(e); +} diff --git a/src/lib/wux-weapp/helpers/debounce.js b/src/lib/wux-weapp/helpers/debounce.js new file mode 100644 index 0000000..eec906c --- /dev/null +++ b/src/lib/wux-weapp/helpers/debounce.js @@ -0,0 +1,41 @@ +'use strict'; +function debounce(t, o, i) { + var n; + var u; + var r; + var a; + var c; + function d() { + var e = +new Date() - a; + if (e < o && 0 <= e) { + n = setTimeout(d, o - e); + } else { + n = void 0; + i || ((c = t.apply(r, u)), n || (u = r = void 0)); + } + } + function e() { + r = this; + u = arguments; + a = +new Date(); + var e = i && !n; + n = n || setTimeout(d, o); + if (e) { + c = t.apply(r, u); + u = r = void 0; + } + return c; + } + e.cancel = function () { + if (void 0 !== n) { + clearTimeout(n); + n = void 0; + } + u = r = void 0; + }; + return e; +} +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = debounce; diff --git a/src/lib/wux-weapp/helpers/eventsMixin.js b/src/lib/wux-weapp/helpers/eventsMixin.js new file mode 100644 index 0000000..80382e8 --- /dev/null +++ b/src/lib/wux-weapp/helpers/eventsMixin.js @@ -0,0 +1,56 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = eventsMixin; +var defaultEvents = { + onChange: function () {} +}; +function eventsMixin() { + return { + data() { + return { + inputEvents: defaultEvents + }; + }, + lifetimes: { + created: function () { + this._oriTriggerEvent = this.triggerEvent; + this.triggerEvent = this._triggerEvent; + } + }, + props: { + events: { + type: Object, + value: defaultEvents + } + }, + definitionFilter: function (t) { + Object.assign((t.data = t.data || {}), { + inputEvents: Object.assign({}, defaultEvents, t.inputEvents) + }); + Object.assign((t.methods = t.methods || {}), { + _triggerEvent: function (t, e, n, i) { + var s = !(2 < arguments.length && void 0 !== n) || n; + if (3 < arguments.length) { + var a = i; + } else { + var a = void 0; + } + var r = this.inputEvents['on'.concat(t[0].toUpperCase()).concat(t.slice(1))]; + if (s && 'function' == typeof r) { + r.call(this, e); + } + this._oriTriggerEvent(t, e, a); + } + }); + Object.assign((t.observers = t.observers || {}), { + events: function (t) { + this.setData({ + inputEvents: Object.assign({}, defaultEvents, this.inputEvents, t) + }); + } + }); + } + }; +} diff --git a/src/lib/wux-weapp/helpers/funcBehavior.js b/src/lib/wux-weapp/helpers/funcBehavior.js new file mode 100644 index 0000000..8bef2f7 --- /dev/null +++ b/src/lib/wux-weapp/helpers/funcBehavior.js @@ -0,0 +1,92 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var mergeOptionsToData = function (t) { + if (0 < arguments.length && void 0 !== t) { + var e = t; + } else { + var e = {}; + } + var n = Object.assign({}, e); + for (var r in n) { + if (n.hasOwnProperty(r) && 'function' == typeof n[r]) { + delete n[r]; + } + } + return n; +}; +var bind = function (r, i) { + return function () { + for (t = arguments.length, e = new Array(t), n = 0, void 0; n < t; n++) { + var t; + var e; + var n; + e[n] = arguments[n]; + } + return e.length ? r.apply(i, e) : r.call(i); + }; +}; +var assign = function () { + for (t = arguments.length, e = new Array(t), n = 0, void 0; n < t; n++) { + var t; + var e; + var n; + e[n] = arguments[n]; + } + return Object.assign.apply(Object, [{}].concat(e)); +}; +var _default = { + definitionFilter: function (t) { + t.data = mergeOptionsToData(t.data); + t.data.in = false; + t.data.visible = false; + }, + methods: { + $mergeOptionsToData: mergeOptionsToData, + $mergeOptionsAndBindMethods: function (t, e) { + if (0 < arguments.length && void 0 !== t) { + var n = t; + } else { + var n = {}; + } + var r = 1 < arguments.length && void 0 !== e ? e : this.fns; + var i = Object.assign({}, n); + for (var a in i) { + if (i.hasOwnProperty(a) && 'function' == typeof i[a]) { + r[a] = bind(i[a], this); + delete i[a]; + } + } + return i; + }, + $setData: function () { + for (e = this, t = arguments.length, n = new Array(t), r = 0, void 0; r < t; r++) { + var e; + var t; + var n; + var r; + n[r] = arguments[r]; + } + var i = assign.apply(void 0, [{}].concat(n)); + return new Promise(function (t) { + e.setData(i, t); + }); + }, + $requestAnimationFrame: function (t, e) { + var n = 0 < arguments.length && void 0 !== t ? t : function () {}; + var r = 1 < arguments.length && void 0 !== e ? e : 16.666666666666668; + return new Promise(function (t) { + return setTimeout(t, r); + }).then(n); + } + }, + created: function () { + this.fns = {}; + }, + destroyed: function () { + this.fns = {}; + } +}; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/gestures.js b/src/lib/wux-weapp/helpers/gestures.js new file mode 100644 index 0000000..0ce5e7c --- /dev/null +++ b/src/lib/wux-weapp/helpers/gestures.js @@ -0,0 +1,49 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.getSwipeDirection = exports.getPointsDistance = exports.isNearbyPoints = exports.isEqualPoints = exports.getPointsNumber = exports.getTouchPoints = void 0; +var getTouchPoints = function (t, e) { + if (1 < arguments.length && void 0 !== e) { + var s = e; + } else { + var s = 0; + } + var o = t.touches; + var n = t.changedTouches; + var i = o && 0 < o.length; + var r = n && 0 < n.length; + if (!i && r) { + var a = n[s]; + } else { + var a = i ? o[s] : t; + } + return { + x: a.pageX, + y: a.pageY + }; +}; +exports.getTouchPoints = getTouchPoints; +var getPointsNumber = function (t) { + return (t.touches && t.touches.length) || (t.changedTouches && t.changedTouches.length); +}; +exports.getPointsNumber = getPointsNumber; +var isEqualPoints = function (t, e) { + return t.x === e.x && t.y === e.y; +}; +exports.isEqualPoints = isEqualPoints; +var isNearbyPoints = function (t, e, s) { + var o = 2 < arguments.length && void 0 !== s ? s : 25; + return (Math.abs(t.x - e.x) < o) & (Math.abs(t.y - e.y) < o); +}; +exports.isNearbyPoints = isNearbyPoints; +var getPointsDistance = function (t, e) { + var s = Math.abs(t.x - e.x); + var o = Math.abs(t.y - e.y); + return Math.sqrt(s * s + o * o); +}; +exports.getPointsDistance = getPointsDistance; +var getSwipeDirection = function (t, e, s, o) { + return Math.abs(t - e) >= Math.abs(s - o) ? (0 < t - e ? 'Left' : 'Right') : 0 < s - o ? 'Up' : 'Down'; +}; +exports.getSwipeDirection = getSwipeDirection; diff --git a/src/lib/wux-weapp/helpers/isEmpty.js b/src/lib/wux-weapp/helpers/isEmpty.js new file mode 100644 index 0000000..feb2fec --- /dev/null +++ b/src/lib/wux-weapp/helpers/isEmpty.js @@ -0,0 +1,31 @@ +'use strict'; +function _typeof(t) { + return (_typeof = + 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator + ? function (t) { + return typeof t; + } + : function (t) { + return t && 'function' == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? 'symbol' : typeof t; + })(t); +} +function isEmpty(t) { + if (Array.isArray(t)) { + return 0 === t.length; + } + if ('object' !== _typeof(t)) { + return !t; + } + if (t) { + for (var e in t) { + return false; + } + } + return true; +} +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var _default = isEmpty; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/mergeOptionsToData.js b/src/lib/wux-weapp/helpers/mergeOptionsToData.js new file mode 100644 index 0000000..79fa118 --- /dev/null +++ b/src/lib/wux-weapp/helpers/mergeOptionsToData.js @@ -0,0 +1,21 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var mergeOptionsToData = function (e) { + if (0 < arguments.length && void 0 !== e) { + var t = e; + } else { + var t = {}; + } + var o = Object.assign({}, t); + for (var r in o) { + if (o.hasOwnProperty(r) && 'function' == typeof o[r]) { + delete o[r]; + } + } + return o; +}; +var _default = mergeOptionsToData; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/popupMixin.js b/src/lib/wux-weapp/helpers/popupMixin.js new file mode 100644 index 0000000..841c21d --- /dev/null +++ b/src/lib/wux-weapp/helpers/popupMixin.js @@ -0,0 +1,338 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = popupMixin; +var _classNames3 = _interopRequireDefault(require('./classNames')); +var _eventsMixin = _interopRequireDefault(require('./eventsMixin')); +function _interopRequireDefault(e) { + return e && e.__esModule + ? e + : { + default: e + }; +} +function ownKeys(t, e) { + var i = Object.keys(t); + if (Object.getOwnPropertySymbols) { + var n = Object.getOwnPropertySymbols(t); + if (e) { + n = n.filter(function (e) { + return Object.getOwnPropertyDescriptor(t, e).enumerable; + }); + } + i.push.apply(i, n); + } + return i; +} +function _objectSpread(t) { + for (var e = 1; e < arguments.length; e++) { + if (null != arguments[e]) { + var i = arguments[e]; + } else { + var i = {}; + } + e % 2 + ? ownKeys(i, true).forEach(function (e) { + _defineProperty(t, e, i[e]); + }) + : Object.getOwnPropertyDescriptors + ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(i)) + : ownKeys(i).forEach(function (e) { + Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(i, e)); + }); + } + return t; +} +function _defineProperty(e, t, i) { + t in e + ? Object.defineProperty(e, t, { + value: i, + enumerable: true, + configurable: true, + writable: true + }) + : (e[t] = i); + return e; +} +var DEFAULT_TRIGGER = 'onClick'; +var CELL_NAME = '../cell/index'; +var FIELD_NAME = '../field/index'; +var defaultToolbar = { + title: '请选择', + cancelText: '取消', + confirmText: '确定' +}; +var defaultEvents = { + onChange: function () {}, + onConfirm: function () {}, + onCancel: function () {}, + onVisibleChange: function () {}, + onValueChange: function () {} +}; +var defaultPlatformProps = { + labelPropName: 'label', + format: function (e, t) { + return Array.isArray(e.displayValue) ? e.displayValue.join(',') : e.displayValue; + } +}; +var defaultFieldNames = { + label: 'label', + value: 'value', + children: 'children' +}; +function popupMixin() { + if (0 < arguments.length && void 0 !== arguments[0]) { + var i = arguments[0]; + } else { + var i = '#wux-picker'; + } + var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : defaultPlatformProps; + return { + data() { + return { + mounted: false, + popupVisible: false, + inputValue: [] + }; + }, + mixins: [ + (0, _eventsMixin.default)({ + defaultEvents: defaultEvents + }) + ], + props: { + toolbar: { + type: Object, + value: defaultToolbar + }, + trigger: { + type: String, + value: DEFAULT_TRIGGER + }, + defaultVisible: { + type: Boolean, + value: false + }, + visible: { + type: Boolean, + value: false + }, + controlled: { + type: Boolean, + value: false + }, + disabled: { + type: Boolean, + value: false + } + }, + methods: { + setVisibleState: function (t, e) { + var that = this; + var n = 1 < arguments.length && void 0 !== e ? e : function () {}; + if (this.popupVisible !== t) { + var a = { + mounted: true, + inputValue: this.value, + popupVisible: t + }; + this.setData( + t + ? a + : { + popupVisible: t + }, + function () { + if (t && that.hasFieldDecorator) { + var e = that.getFieldElem(); + if (e) { + e.changeValue(e.data.value); + } + } + n(); + } + ); + } + }, + fireVisibleChange: function (e) { + if (this.popupVisible !== e) { + this.controlled || this.setVisibleState(e); + this.setScrollValue(void 0); + this.$emit('visibleChange', { + detail: { + visible: e + } + }); + } + }, + open: function () { + this.fireVisibleChange(true); + }, + close: function (e) { + if ('function' == typeof e) { + var t = this.getPickerValue(this.scrollValue || this.inputValue); + e.call(this, this.formatPickerValue(t)); + } + this.fireVisibleChange(false); + }, + onClosed: function () { + this.picker = null; + this.setData({ + mounted: false, + inputValue: null + }); + }, + onConfirm: function () { + var that = this; + this.close(function (e) { + that.$emit('change', { + detail: e + }); + that.$emit('confirm', { + detail: e + }); + }); + }, + onCancel: function () { + var that = this; + this.close(function (e) { + return that.$emit('cancel', { + detail: e + }); + }); + }, + onValueChange: function (e) { + if (this.mounted) { + var t = e.detail.value; + this.cascade ? this.setCasecadeScrollValue(t) : this.setScrollValue(t); + this.updated(t, true); + this.$emit('valueChange', { + detail: this.formatPickerValue(e.detail) + }); + } + }, + getPickerValue: function (e) { + var t = 0 < arguments.length && void 0 !== e ? e : this.inputValue; + this.picker = this.picker || this.zpSelectComponent(i); + return this.picker && this.picker.getValue(t); + }, + formatPickerValue: function (e) { + return _objectSpread({}, e, _defineProperty({}, t.labelPropName, t.format(e, this))); + }, + getFieldElem: function () { + return (this.field = this.field || this.getRelationNodes(FIELD_NAME)[0]); + }, + setChildProps: function () { + var that = this; + if (!this.disabled) { + var e = this.getRelationNodes(CELL_NAME); + var t = this.trigger; + var a = void 0 === t ? DEFAULT_TRIGGER : t; + if (0 < e.length) { + e.forEach(function (e) { + var t = e.data.inputEvents; + var i = e.data.oriInputEvents || _objectSpread({}, t); + t[a] = function () { + if (i && i[a]) { + i[a].apply(i, arguments); + } + that.onTriggerClick(); + }; + e.setData({ + oriInputEvents: i, + inputEvents: t + }); + }); + } + } + }, + onTriggerClick: function () { + this.fireVisibleChange(!this.popupVisible); + }, + noop: function () {}, + updated: function (e, t) { + (this.hasFieldDecorator && !t) || + (this.inputValue !== e && + this.setData({ + inputValue: e + })); + }, + setScrollValue: function (e) { + this.scrollValue = e; + }, + setCasecadeScrollValue: function (e) { + if (e && this.scrollValue) { + var t = this.scrollValue.length; + if (t === e.length && this.scrollValue[t - 1] === e[t - 1]) { + return; + } + } + this.setScrollValue(e); + } + }, + lifetimes: { + ready: function () { + var e = this; + var t = e.defaultVisible; + var i = e.visible; + var n = e.controlled; + var a = (e.value, n ? i : t); + if ('defaultFieldNames' in this) { + this.setData({ + fieldNames: Object.assign({}, defaultFieldNames, this.defaultFieldNames) + }); + } + this.mounted = true; + this.scrollValue = void 0; + this.setVisibleState(a); + this.setChildProps(); + }, + detached: function () { + this.mounted = false; + } + }, + definitionFilter: function (e) { + var t; + Object.assign( + (e.relations = e.relations || {}), + (_defineProperty((t = {}), CELL_NAME, { + type: 'child', + observer: function () { + this.setChildProps(); + } + }), + _defineProperty(t, FIELD_NAME, { + type: 'ancestor' + }), + t) + ); + Object.assign((e.computed = e.computed || {}), { + classes: [ + 'prefixCls', + function (e) { + return { + wrap: (0, _classNames3.default)(e), + toolbar: ''.concat(e, '__toolbar'), + inner: ''.concat(e, '__inner'), + cancel: (0, _classNames3.default)(''.concat(e, '__button'), _defineProperty({}, ''.concat(e, '__button--cancel'), true)), + confirm: (0, _classNames3.default)(''.concat(e, '__button'), _defineProperty({}, ''.concat(e, '__button--confirm'), true)), + hover: ''.concat(e, '__button--hover'), + title: ''.concat(e, '__title') + }; + } + ] + }); + Object.assign((e.observers = e.observers || {}), { + visible: function (e) { + if (this.controlled) { + this.setVisibleState(e); + } + }, + value: function (e) { + this.updated(e); + } + }); + } + }; +} diff --git a/src/lib/wux-weapp/helpers/relationsBehavior.js b/src/lib/wux-weapp/helpers/relationsBehavior.js new file mode 100644 index 0000000..693861a --- /dev/null +++ b/src/lib/wux-weapp/helpers/relationsBehavior.js @@ -0,0 +1,93 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var _isEmpty = _interopRequireDefault(require('./isEmpty')); +var _debounce2 = _interopRequireDefault(require('./debounce')); +function _interopRequireDefault(e) { + return e && e.__esModule + ? e + : { + default: e + }; +} +function _defineProperty(e, t, n) { + t in e + ? Object.defineProperty(e, t, { + value: n, + enumerable: true, + configurable: true, + writable: true + }) + : (e[t] = n); + return e; +} +function bindFunc(e, t, n) { + var i = e[t]; + e[t] = function (e) { + if (n) { + n.call(this, e, _defineProperty({}, t, true)); + } + if (i) { + i.call(this, e); + } + }; +} +var methods = ['linked', 'linkChanged', 'unlinked']; +var extProps = ['observer']; +var _default = { + lifetimes: { + created: function () { + this._debounce = null; + }, + detached: function () { + if (this._debounce && this._debounce.cancel) { + this._debounce.cancel(); + } + } + }, + definitionFilter: function (e) { + var n = e.relations; + if (!(0, _isEmpty.default)(n)) { + var t = function (e) { + var t = n[e]; + methods.forEach(function (e) { + return bindFunc(t, e, t.observer); + }); + extProps.forEach(function (e) { + return delete t[e]; + }); + }; + for (var i in n) { + t(i); + } + } + Object.assign((e.methods = e.methods || {}), { + getRelationsName: function (e) { + if (0 < arguments.length && void 0 !== e) { + var t = e; + } else { + var t = ['parent', 'child', 'ancestor', 'descendant']; + } + return Object.keys(n || {}) + .map(function (e) { + return n[e] && t.includes(n[e].type) ? e : null; + }) + .filter(function (e) { + return !!e; + }); + }, + debounce: function (e, t, n) { + if (1 < arguments.length && void 0 !== t) { + var i = t; + } else { + var i = 0; + } + var r = 2 < arguments.length && void 0 !== n && n; + return (this._debounce = this._debounce || (0, _debounce2.default)(e.bind(this), i, r)).call(this); + } + }); + } +}; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/safeAreaBehavior.js b/src/lib/wux-weapp/helpers/safeAreaBehavior.js new file mode 100644 index 0000000..380fa74 --- /dev/null +++ b/src/lib/wux-weapp/helpers/safeAreaBehavior.js @@ -0,0 +1,71 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var _checkIPhoneX = require('./checkIPhoneX'); +function _defineProperty(e, t, o) { + if (t in e) { + Object.defineProperty(e, t, { + value: o, + enumerable: true, + configurable: true, + writable: true + }); + } else { + e[t] = o; + } + return e; +} +function _typeof(e) { + return (_typeof = + 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator + ? function (e) { + return typeof e; + } + : function (e) { + return e && 'function' == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? 'symbol' : typeof e; + })(e); +} +var defaultSafeArea = { + top: false, + bottom: false +}; +var setSafeArea = function (e) { + return 'boolean' == typeof e + ? Object.assign({}, defaultSafeArea, { + top: e, + bottom: e + }) + : null !== e && 'object' === _typeof(e) + ? Object.assign({}, defaultSafeArea) + : 'string' == typeof e + ? Object.assign({}, defaultSafeArea, _defineProperty({}, e, true)) + : defaultSafeArea; +}; +var _default = { + props: { + safeArea: { + type: [Boolean, String, Object], + optionalTypes: [Boolean, String, Object], + value: false + } + }, + watch: { + safeArea: function (e) { + this.setData({ + safeAreaConfig: setSafeArea(e) + }); + } + }, + definitionFilter: function (e) { + var t = ((0, _checkIPhoneX.getSystemInfo)() || {}).statusBarHeight; + var o = (0, _checkIPhoneX.checkIPhoneX)(); + Object.assign((e.data = e.data || {}), { + safeAreaConfig: defaultSafeArea, + statusBarHeight: t, + isIPhoneX: o + }); + } +}; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/safeSetDataBehavior.js b/src/lib/wux-weapp/helpers/safeSetDataBehavior.js new file mode 100644 index 0000000..899a0d5 --- /dev/null +++ b/src/lib/wux-weapp/helpers/safeSetDataBehavior.js @@ -0,0 +1,48 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var _default = { + lifetimes: { + created: function () { + this.nextCallback = null; + }, + detached: function () { + this.cancelNextCallback(); + } + }, + methods: { + safeSetData: function (t, a) { + var that = this; + this.pendingData = Object.assign({}, this, t); + a = this.setNextCallback(a); + this.setData(t, function () { + that.pendingData = null; + a(); + }); + }, + setNextCallback: function (a) { + var that = this; + var l = true; + this.nextCallback = function (t) { + if (l) { + l = false; + that.nextCallback = null; + a.call(that, t); + } + }; + this.nextCallback.cancel = function () { + l = false; + }; + return this.nextCallback; + }, + cancelNextCallback: function () { + if (null !== this.nextCallback) { + this.nextCallback.cancel(); + this.nextCallback = null; + } + } + } +}; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/shallowEqual.js b/src/lib/wux-weapp/helpers/shallowEqual.js new file mode 100644 index 0000000..324ba72 --- /dev/null +++ b/src/lib/wux-weapp/helpers/shallowEqual.js @@ -0,0 +1,40 @@ +'use strict'; +function _typeof(t) { + return (_typeof = + 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator + ? function (t) { + return typeof t; + } + : function (t) { + return t && 'function' == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? 'symbol' : typeof t; + })(t); +} +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; +var hasOwnProperty = Object.prototype.hasOwnProperty; +function is(t, e) { + return t === e ? 0 !== t || 0 !== e || 1 / t == 1 / e : t != t && e != e; +} +function shallowEqual(t, e) { + if (is(t, e)) { + return true; + } + if ('object' !== _typeof(t) || null === t || 'object' !== _typeof(e) || null === e) { + return false; + } + var o = Object.keys(t); + var r = Object.keys(e); + if (o.length !== r.length) { + return false; + } + for (var n = 0; n < o.length; n++) { + if (!hasOwnProperty.call(e, o[n]) || !is(t[o[n]], e[o[n]])) { + return false; + } + } + return true; +} +var _default = shallowEqual; +exports.default = _default; diff --git a/src/lib/wux-weapp/helpers/styleToCssString.js b/src/lib/wux-weapp/helpers/styleToCssString.js new file mode 100644 index 0000000..cd02f96 --- /dev/null +++ b/src/lib/wux-weapp/helpers/styleToCssString.js @@ -0,0 +1,83 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +var isUnitlessNumber = { + boxFlex: !(exports.default = void 0), + boxFlexGroup: true, + columnCount: true, + flex: true, + flexGrow: true, + flexPositive: true, + flexShrink: true, + flexNegative: true, + fontWeight: true, + lineClamp: true, + lineHeight: true, + opacity: true, + order: true, + orphans: true, + widows: true, + zIndex: true, + zoom: true, + fillOpacity: true, + strokeDashoffset: true, + strokeOpacity: true, + strokeWidth: true +}; +function prefixKey(e, t) { + return e + t.charAt(0).toUpperCase() + t.substring(1); +} +var prefixes = ['Webkit', 'ms', 'Moz', 'O']; +Object.keys(isUnitlessNumber).forEach(function (t) { + prefixes.forEach(function (e) { + isUnitlessNumber[prefixKey(e, t)] = isUnitlessNumber[t]; + }); +}); +var msPattern = /^ms-/; +var _uppercasePattern = /([A-Z])/g; +function hyphenate(e) { + return e.replace(_uppercasePattern, '-$1').toLowerCase(); +} +function hyphenateStyleName(e) { + return hyphenate(e).replace(msPattern, '-ms-'); +} +var isArray = Array.isArray; +var keys = Object.keys; +var unquotedContentValueRegex = /^(normal|none|(\b(url\([^)]*\)|chapter_counter|attr\([^)]*\)|(no-)?(open|close)-quote|inherit)((\b\s*)|$|\s+))+)$/; +function buildRule(e, t) { + if (isUnitlessNumber[e] || 'number' != typeof t) { + 'content' !== e || unquotedContentValueRegex.test(t) || (t = "'" + t.replace(/'/g, "\\'") + "'"); + } else { + t += 'px'; + } + return hyphenateStyleName(e) + ': ' + t + '; '; +} +function styleToCssString(e) { + var t = ''; + if ('string' == typeof e) { + return ';' === (e = e.trim()).slice(-1) ? ''.concat(e, ' ') : ''.concat(e, '; '); + } + if (!e || 0 === keys(e).length) { + return t; + } + for (r = keys(e), n = 0, s = r.length, void 0; n < s; n++) { + var r; + var n; + var s; + var o = r[n]; + var i = e[o]; + if (isArray(i)) { + for (a = 0, u = i.length, void 0; a < u; a++) { + var a; + var u; + t += buildRule(o, i[a]); + } + } else { + t += buildRule(o, i); + } + } + return t; +} +var _default = styleToCssString; +exports.default = _default; diff --git a/src/lib/wux-weapp/index.js b/src/lib/wux-weapp/index.js new file mode 100644 index 0000000..3015d1a --- /dev/null +++ b/src/lib/wux-weapp/index.js @@ -0,0 +1,19 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.$wuxBackdrop = exports.version = exports.getCtx = void 0; +var getCtx = function (e, t) { + var r = (1 < arguments.length && void 0 !== t ? t : getCurrentPages()[getCurrentPages().length - 1].zpSelectComponent)(e); + if (!r) { + throw new Error('无法找到对应的组件,请按文档说明使用组件'); + } + return r; +}; +exports.getCtx = getCtx; +var version = '3.8.9'; +exports.version = version; +var $wuxBackdrop = function (e, t) { + return getCtx(0 < arguments.length && void 0 !== e ? e : '#wux-backdrop', 1 < arguments.length ? t : void 0); +}; +exports.$wuxBackdrop = $wuxBackdrop; diff --git a/src/lib/wux-weapp/popup/index.vue b/src/lib/wux-weapp/popup/index.vue new file mode 100644 index 0000000..5af2513 --- /dev/null +++ b/src/lib/wux-weapp/popup/index.vue @@ -0,0 +1,359 @@ + + + + diff --git a/src/lib/wux-weapp/styles/index.css b/src/lib/wux-weapp/styles/index.css new file mode 100644 index 0000000..f90ac0d --- /dev/null +++ b/src/lib/wux-weapp/styles/index.css @@ -0,0 +1,583 @@ +.wux-text--left { + text-align: left !important; +} +.wux-text--right { + text-align: right !important; +} +.wux-text--center { + text-align: center !important; +} +.wux-text--justify { + text-align: justify !important; +} +.wux-text--nowrap { + text-align: nowrap !important; +} +.wux-text--lowercase { + text-transform: lowercase !important; +} +.wux-text--uppercase { + text-transform: uppercase !important; +} +.wux-text--capitalize { + text-transform: capitalize !important; +} +.wux-light { + color: #fff !important; +} +.wux-light--bg { + background-color: #fff !important; +} +.wux-light--border { + border-color: #fff !important; +} +.wux-stable { + color: #f8f8f8 !important; +} +.wux-stable--bg { + background-color: #f8f8f8 !important; +} +.wux-stable--border { + border-color: #f8f8f8 !important; +} +.wux-positive { + color: #387ef5 !important; +} +.wux-positive--bg { + background-color: #387ef5 !important; +} +.wux-positive--border { + border-color: #387ef5 !important; +} +.wux-calm { + color: #11c1f3 !important; +} +.wux-calm--bg { + background-color: #11c1f3 !important; +} +.wux-calm--border { + border-color: #11c1f3 !important; +} +.wux-balanced { + color: #33cd5f !important; +} +.wux-balanced--bg { + background-color: #33cd5f !important; +} +.wux-balanced--border { + border-color: #33cd5f !important; +} +.wux-energized { + color: #ffc900 !important; +} +.wux-energized--bg { + background-color: #ffc900 !important; +} +.wux-energized--border { + border-color: #ffc900 !important; +} +.wux-assertive { + color: #ef473a !important; +} +.wux-assertive--bg { + background-color: #ef473a !important; +} +.wux-assertive--border { + border-color: #ef473a !important; +} +.wux-royal { + color: #886aea !important; +} +.wux-royal--bg { + background-color: #886aea !important; +} +.wux-royal--border { + border-color: #886aea !important; +} +.wux-dark { + color: #444 !important; +} +.wux-dark--bg { + background-color: #444 !important; +} +.wux-dark--border { + border-color: #444 !important; +} +.wux-m--30, +.wux-margin--30 { + margin: 60rpx !important; +} +.wux-margin-top--30, +.wux-mt--30 { + margin-top: 60rpx !important; +} +.wux-margin-right--30, +.wux-mr--30 { + margin-right: 60rpx !important; +} +.wux-margin-bottom--30, +.wux-mb--30 { + margin-bottom: 60rpx !important; +} +.wux-margin-left--30, +.wux-ml--30 { + margin-left: 60rpx !important; +} +.wux-margin-vertical--30, +.wux-mv--30 { + margin: 60rpx 0 !important; +} +.wux-margin-horizontal--30, +.wux-mh--30 { + margin: 0 60rpx !important; +} +.wux-p--30, +.wux-padding--30 { + padding: 60rpx !important; +} +.wux-padding-top--30, +.wux-pt--30 { + padding-top: 60rpx !important; +} +.wux-padding-right--30, +.wux-pr--30 { + padding-right: 60rpx !important; +} +.wux-padding-bottom--30, +.wux-pb--30 { + padding-bottom: 60rpx !important; +} +.wux-padding-left--30, +.wux-pl--30 { + padding-left: 60rpx !important; +} +.wux-padding-vertical--30, +.wux-pv--30 { + padding: 60rpx 0 !important; +} +.wux-padding-horizontal--30, +.wux-ph--30 { + padding: 0 60rpx !important; +} +.wux-m--25, +.wux-margin--25 { + margin: 50rpx !important; +} +.wux-margin-top--25, +.wux-mt--25 { + margin-top: 50rpx !important; +} +.wux-margin-right--25, +.wux-mr--25 { + margin-right: 50rpx !important; +} +.wux-margin-bottom--25, +.wux-mb--25 { + margin-bottom: 50rpx !important; +} +.wux-margin-left--25, +.wux-ml--25 { + margin-left: 50rpx !important; +} +.wux-margin-vertical--25, +.wux-mv--25 { + margin: 50rpx 0 !important; +} +.wux-margin-horizontal--25, +.wux-mh--25 { + margin: 0 50rpx !important; +} +.wux-p--25, +.wux-padding--25 { + padding: 50rpx !important; +} +.wux-padding-top--25, +.wux-pt--25 { + padding-top: 50rpx !important; +} +.wux-padding-right--25, +.wux-pr--25 { + padding-right: 50rpx !important; +} +.wux-padding-bottom--25, +.wux-pb--25 { + padding-bottom: 50rpx !important; +} +.wux-padding-left--25, +.wux-pl--25 { + padding-left: 50rpx !important; +} +.wux-padding-vertical--25, +.wux-pv--25 { + padding: 50rpx 0 !important; +} +.wux-padding-horizontal--25, +.wux-ph--25 { + padding: 0 50rpx !important; +} +.wux-m--20, +.wux-margin--20 { + margin: 40rpx !important; +} +.wux-margin-top--20, +.wux-mt--20 { + margin-top: 40rpx !important; +} +.wux-margin-right--20, +.wux-mr--20 { + margin-right: 40rpx !important; +} +.wux-margin-bottom--20, +.wux-mb--20 { + margin-bottom: 40rpx !important; +} +.wux-margin-left--20, +.wux-ml--20 { + margin-left: 40rpx !important; +} +.wux-margin-vertical--20, +.wux-mv--20 { + margin: 40rpx 0 !important; +} +.wux-margin-horizontal--20, +.wux-mh--20 { + margin: 0 40rpx !important; +} +.wux-p--20, +.wux-padding--20 { + padding: 40rpx !important; +} +.wux-padding-top--20, +.wux-pt--20 { + padding-top: 40rpx !important; +} +.wux-padding-right--20, +.wux-pr--20 { + padding-right: 40rpx !important; +} +.wux-padding-bottom--20, +.wux-pb--20 { + padding-bottom: 40rpx !important; +} +.wux-padding-left--20, +.wux-pl--20 { + padding-left: 40rpx !important; +} +.wux-padding-vertical--20, +.wux-pv--20 { + padding: 40rpx 0 !important; +} +.wux-padding-horizontal--20, +.wux-ph--20 { + padding: 0 40rpx !important; +} +.wux-m--15, +.wux-margin--15 { + margin: 30rpx !important; +} +.wux-margin-top--15, +.wux-mt--15 { + margin-top: 30rpx !important; +} +.wux-margin-right--15, +.wux-mr--15 { + margin-right: 30rpx !important; +} +.wux-margin-bottom--15, +.wux-mb--15 { + margin-bottom: 30rpx !important; +} +.wux-margin-left--15, +.wux-ml--15 { + margin-left: 30rpx !important; +} +.wux-margin-vertical--15, +.wux-mv--15 { + margin: 30rpx 0 !important; +} +.wux-margin-horizontal--15, +.wux-mh--15 { + margin: 0 30rpx !important; +} +.wux-p--15, +.wux-padding--15 { + padding: 30rpx !important; +} +.wux-padding-top--15, +.wux-pt--15 { + padding-top: 30rpx !important; +} +.wux-padding-right--15, +.wux-pr--15 { + padding-right: 30rpx !important; +} +.wux-padding-bottom--15, +.wux-pb--15 { + padding-bottom: 30rpx !important; +} +.wux-padding-left--15, +.wux-pl--15 { + padding-left: 30rpx !important; +} +.wux-padding-vertical--15, +.wux-pv--15 { + padding: 30rpx 0 !important; +} +.wux-padding-horizontal--15, +.wux-ph--15 { + padding: 0 30rpx !important; +} +.wux-m--10, +.wux-margin--10 { + margin: 20rpx !important; +} +.wux-margin-top--10, +.wux-mt--10 { + margin-top: 20rpx !important; +} +.wux-margin-right--10, +.wux-mr--10 { + margin-right: 20rpx !important; +} +.wux-margin-bottom--10, +.wux-mb--10 { + margin-bottom: 20rpx !important; +} +.wux-margin-left--10, +.wux-ml--10 { + margin-left: 20rpx !important; +} +.wux-margin-vertical--10, +.wux-mv--10 { + margin: 20rpx 0 !important; +} +.wux-margin-horizontal--10, +.wux-mh--10 { + margin: 0 20rpx !important; +} +.wux-p--10, +.wux-padding--10 { + padding: 20rpx !important; +} +.wux-padding-top--10, +.wux-pt--10 { + padding-top: 20rpx !important; +} +.wux-padding-right--10, +.wux-pr--10 { + padding-right: 20rpx !important; +} +.wux-padding-bottom--10, +.wux-pb--10 { + padding-bottom: 20rpx !important; +} +.wux-padding-left--10, +.wux-pl--10 { + padding-left: 20rpx !important; +} +.wux-padding-vertical--10, +.wux-pv--10 { + padding: 20rpx 0 !important; +} +.wux-padding-horizontal--10, +.wux-ph--10 { + padding: 0 20rpx !important; +} +.wux-m--5, +.wux-margin--5 { + margin: 10rpx !important; +} +.wux-margin-top--5, +.wux-mt--5 { + margin-top: 10rpx !important; +} +.wux-margin-right--5, +.wux-mr--5 { + margin-right: 10rpx !important; +} +.wux-margin-bottom--5, +.wux-mb--5 { + margin-bottom: 10rpx !important; +} +.wux-margin-left--5, +.wux-ml--5 { + margin-left: 10rpx !important; +} +.wux-margin-vertical--5, +.wux-mv--5 { + margin: 10rpx 0 !important; +} +.wux-margin-horizontal--5, +.wux-mh--5 { + margin: 0 10rpx !important; +} +.wux-p--5, +.wux-padding--5 { + padding: 10rpx !important; +} +.wux-padding-top--5, +.wux-pt--5 { + padding-top: 10rpx !important; +} +.wux-padding-right--5, +.wux-pr--5 { + padding-right: 10rpx !important; +} +.wux-padding-bottom--5, +.wux-pb--5 { + padding-bottom: 10rpx !important; +} +.wux-padding-left--5, +.wux-pl--5 { + padding-left: 10rpx !important; +} +.wux-padding-vertical--5, +.wux-pv--5 { + padding: 10rpx 0 !important; +} +.wux-padding-horizontal--5, +.wux-ph--5 { + padding: 0 10rpx !important; +} +.wux-m--0, +.wux-margin--0 { + margin: 0rpx !important; +} +.wux-margin-top--0, +.wux-mt--0 { + margin-top: 0rpx !important; +} +.wux-margin-right--0, +.wux-mr--0 { + margin-right: 0rpx !important; +} +.wux-margin-bottom--0, +.wux-mb--0 { + margin-bottom: 0rpx !important; +} +.wux-margin-left--0, +.wux-ml--0 { + margin-left: 0rpx !important; +} +.wux-margin-vertical--0, +.wux-mv--0 { + margin: 0rpx 0 !important; +} +.wux-margin-horizontal--0, +.wux-mh--0 { + margin: 0 0rpx !important; +} +.wux-p--0, +.wux-padding--0 { + padding: 0rpx !important; +} +.wux-padding-top--0, +.wux-pt--0 { + padding-top: 0rpx !important; +} +.wux-padding-right--0, +.wux-pr--0 { + padding-right: 0rpx !important; +} +.wux-padding-bottom--0, +.wux-pb--0 { + padding-bottom: 0rpx !important; +} +.wux-padding-left--0, +.wux-pl--0 { + padding-left: 0rpx !important; +} +.wux-padding-vertical--0, +.wux-pv--0 { + padding: 0rpx 0 !important; +} +.wux-padding-horizontal--0, +.wux-ph--0 { + padding: 0 0rpx !important; +} +.wux-clearfix::after, +.wux-clearfix::before { + display: table; + content: ' '; +} +.wux-clearfix::after { + clear: both; +} +.wux-pull-right { + float: right !important; +} +.wux-pull-left { + float: left !important; +} +.wux-ellipsis { + width: auto; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + word-wrap: normal; +} +.wux-ellipsis--l2 { + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; +} +.wux-ellipsis--l3 { + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; +} +.wux-hairline, +.wux-hairline--bottom, +.wux-hairline--horizontal, +.wux-hairline--left, +.wux-hairline--right, +.wux-hairline--surrounded, +.wux-hairline--top, +.wux-hairline--vertical { + position: relative; +} +.wux-hairline--bottom::after, +.wux-hairline--horizontal::after, +.wux-hairline--left::after, +.wux-hairline--right::after, +.wux-hairline--surrounded::after, +.wux-hairline--top::after, +.wux-hairline--vertical::after, +.wux-hairline::after { + content: ' '; + position: absolute; + top: 0; + left: 0; + width: 200%; + height: 200%; + transform: scale(0.5); + transform-origin: 0 0; + pointer-events: none; + box-sizing: border-box; + border: 0 solid #d9d9d9; +} +.wux-hairline--top::after { + border-top-width: 1px; +} +.wux-hairline--right::after { + border-right-width: 1px; +} +.wux-hairline--bottom::after { + border-bottom-width: 1px; +} +.wux-hairline--left::after { + border-left-width: 1px; +} +.wux-hairline--horizontal::after { + border-width: 1px 0; +} +.wux-hairline--vertical::after { + border-width: 0 1px; +} +.wux-hairline--surrounded::after { + border-width: 1px; +} diff --git a/src/lib/wux-weapp/说明.md b/src/lib/wux-weapp/说明.md new file mode 100644 index 0000000..f8ca0f9 --- /dev/null +++ b/src/lib/wux-weapp/说明.md @@ -0,0 +1 @@ +# PS:注意,cascader 存在源码级别更改,按业务要求改造过 diff --git a/src/lib/wx-ai-im/WulAiSDK-1.1.3.js b/src/lib/wx-ai-im/WulAiSDK-1.1.3.js new file mode 100644 index 0000000..bd5ac8e --- /dev/null +++ b/src/lib/wx-ai-im/WulAiSDK-1.1.3.js @@ -0,0 +1,8799 @@ +'use strict'; +/** + * version: 1.1.0 + * feat(客户: 来也): + * 增加多 cmp 嗅探逻辑 + */ +module.exports = function (wx) { + var Modules = { + DeleteMsgInput: function () { + var a = {}; + this.setType = function (b) { + a.type = b; + }; + this.setConversationId = function (b) { + a.conversationId = b; + }; + this.setMsgs = function (b) { + a.msgs = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + DeleteMsg: function () { + var a = {}; + this.setMsgId = function (b) { + a.msgId = b; + }; + this.setMsgDataTime = function (b) { + a.msgDataTime = b; + }; + this.setDirect = function (b) { + a.direct = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + DeleteMsgOutput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + SearchMpInput: function () { + var a = {}; + this.setType = function (b) { + a.type = b; + }; + this.setId = function (b) { + a.id = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + SearchMpOutput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.setInfo = function (b) { + a.info = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + MpInfo: function () { + var a = {}; + this.setMpid = function (b) { + a.mpid = b; + }; + this.setName = function (b) { + a.name = b; + }; + this.setType = function (b) { + a.type = b; + }; + this.setTime = function (b) { + a.time = b; + }; + this.setPortraitUri = function (b) { + a.portraitUrl = b; + }; + this.setExtra = function (b) { + a.extra = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + PullMpInput: function () { + var a = {}; + this.setMpid = function (b) { + a.mpid = b; + }; + this.setTime = function (b) { + a.time = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + PullMpOutput: function () { + var a = {}; + this.setStatus = function (b) { + a.status = b; + }; + this.setInfo = function (b) { + a.info = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + MPFollowInput: function () { + var a = {}; + this.setId = function (b) { + a.id = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + MPFollowOutput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.setInfo = function (b) { + a.info = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + NotifyMsg: function () { + var a = {}; + this.setType = function (b) { + a.type = b; + }; + this.setTime = function (b) { + a.time = b; + }; + this.setChrmId = function (b) { + a.chrmId = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + SyncRequestMsg: function () { + var a = {}; + this.setSyncTime = function (b) { + a.syncTime = b || 0; + }; + this.setIspolling = function (b) { + a.ispolling = !!b; + }; + this.setIsweb = function (b) { + a.isweb = !!b; + }; + this.setIsPullSend = function (b) { + a.isPullSend = !!b; + }; + this.setSendBoxSyncTime = function (b) { + a.sendBoxSyncTime = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + UpStreamMessage: function () { + var a = {}; + this.setSessionId = function (b) { + a.sessionId = b; + }; + this.setClassname = function (b) { + a.classname = b; + }; + this.setContent = function (b) { + if (b) a.content = b; + }; + this.setPushText = function (b) { + a.pushText = b; + }; + this.setUserId = function (b) { + a.userId = b; + }; + this.setAppData = function (b) { + a.appData = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + DownStreamMessages: function () { + var a = {}; + this.setList = function (b) { + a.list = b; + }; + this.setSyncTime = function (b) { + a.syncTime = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + DownStreamMessage: function () { + var a = {}; + this.setFromUserId = function (b) { + a.fromUserId = b; + }; + this.setType = function (b) { + a.type = b; + }; + this.setGroupId = function (b) { + a.groupId = b; + }; + this.setClassname = function (b) { + a.classname = b; + }; + this.setContent = function (b) { + if (b) a.content = b; + }; + this.setDataTime = function (b) { + a.dataTime = b; + }; + this.setStatus = function (b) { + a.status = b; + }; + this.setMsgId = function (b) { + a.msgId = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + CreateDiscussionInput: function () { + var a = {}; + this.setName = function (b) { + a.name = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + CreateDiscussionOutput: function () { + var a = {}; + this.setId = function (b) { + a.id = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + ChannelInvitationInput: function () { + var a = {}; + this.setUsers = function (b) { + a.users = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + LeaveChannelInput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + QueryChatroomInfoInput: function () { + var a = {}; + this.setCount = function (b) { + a.count = b; + }; + this.setOrder = function (b) { + a.order = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + QueryChatroomInfoOutput: function () { + var a = {}; + this.setUserTotalNums = function (b) { + a.userTotalNums = b; + }; + this.setUserInfos = function (b) { + a.userInfos = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + ChannelEvictionInput: function () { + var a = {}; + this.setUser = function (b) { + a.user = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + RenameChannelInput: function () { + var a = {}; + this.setName = function (b) { + a.name = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + ChannelInfoInput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + ChannelInfoOutput: function () { + var a = {}; + this.setType = function (b) { + a.type = b; + }; + this.setChannelId = function (b) { + a.channelId = b; + }; + this.setChannelName = function (b) { + a.channelName = b; + }; + this.setAdminUserId = function (b) { + a.adminUserId = b; + }; + this.setFirstTenUserIds = function (b) { + a.firstTenUserIds = b; + }; + this.setOpenStatus = function (b) { + a.openStatus = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + ChannelInfosInput: function () { + var a = {}; + this.setPage = function (b) { + a.page = b; + }; + this.setNumber = function (b) { + a.number = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + ChannelInfosOutput: function () { + var a = {}; + this.setChannels = function (b) { + a.channels = b; + }; + this.setTotal = function (b) { + a.total = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + MemberInfo: function () { + var a = {}; + this.setUserId = function (b) { + a.userId = b; + }; + this.setUserName = function (b) { + a.userName = b; + }; + this.setUserPortrait = function (b) { + a.userPortrait = b; + }; + this.setExtension = function (b) { + a.extension = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GroupMembersInput: function () { + var a = {}; + this.setPage = function (b) { + a.page = b; + }; + this.setNumber = function (b) { + a.number = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GroupMembersOutput: function () { + var a = {}; + this.setMembers = function (b) { + a.members = b; + }; + this.setTotal = function (b) { + a.total = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GetUserInfoInput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GetUserInfoOutput: function () { + var a = {}; + this.setUserId = function (b) { + a.userId = b; + }; + this.setUserName = function (b) { + a.userName = b; + }; + this.setUserPortrait = function (b) { + a.userPortrait = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GetSessionIdInput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GetSessionIdOutput: function () { + var a = {}; + this.setSessionId = function (b) { + a.sessionId = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GetQNupTokenInput: function () { + var a = {}; + this.setType = function (b) { + a.type = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GetQNupTokenOutput: function () { + var a = {}; + this.setDeadline = function (b) { + a.deadline = b; + }; + this.setToken = function (b) { + a.token = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GetQNdownloadUrlInput: function () { + var a = {}; + this.setType = function (b) { + a.type = b; + }; + this.setKey = function (b) { + a.key = b; + }; + this.setFileName = function (b) { + a.fileName = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GetQNdownloadUrlOutput: function () { + var a = {}; + this.setDownloadUrl = function (b) { + a.downloadUrl = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + Add2BlackListInput: function () { + var a = {}; + this.setUserId = function (b) { + a.userId = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + RemoveFromBlackListInput: function () { + var a = {}; + this.setUserId = function (b) { + a.userId = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + QueryBlackListInput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + QueryBlackListOutput: function () { + var a = {}; + this.setUserIds = function (b) { + a.userIds = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + BlackListStatusInput: function () { + var a = {}; + this.setUserId = function (b) { + a.userId = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + BlockPushInput: function () { + var a = {}; + this.setBlockeeId = function (b) { + a.blockeeId = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + ModifyPermissionInput: function () { + var a = {}; + this.setOpenStatus = function (b) { + a.openStatus = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GroupInput: function () { + var a = {}; + this.setGroupInfo = function (b) { + for (var i = 0, arr = []; i < b.length; i++) { + arr.push({ + id: b[i].getContent().id, + name: b[i].getContent().name + }); + } + a.groupInfo = arr; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GroupOutput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GroupInfo: function () { + var a = {}; + this.setId = function (b) { + a.id = b; + }; + this.setName = function (b) { + a.name = b; + }; + this.getContent = function () { + return a; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GroupHashInput: function () { + var a = {}; + this.setUserId = function (b) { + a.userId = b; + }; + this.setGroupHashCode = function (b) { + a.groupHashCode = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + GroupHashOutput: function () { + var a = {}; + this.setResult = function (b) { + a.result = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + ChrmInput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + ChrmOutput: function () { + var a = {}; + this.setNothing = function (b) { + a.nothing = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + ChrmPullMsg: function () { + var a = {}; + this.setSyncTime = function (b) { + a.syncTime = b; + }; + this.setCount = function (b) { + a.count = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + RelationsInput: function () { + var a = {}; + this.setType = function (b) { + a.type = b; + }; + this.setMsg = function (b) { + a.msg = b; + }; + this.setCount = function (b) { + a.count = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + RelationsOutput: function () { + var a = {}; + this.setInfo = function (b) { + a.info = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + RelationInfo: function () { + var a = {}; + this.setType = function (b) { + a.type = b; + }; + this.setUserId = function (b) { + a.userId = b; + }; + this.setMsg = function (b) { + a.msg = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + HistoryMessageInput: function () { + var a = {}; + this.setTargetId = function (b) { + a.targetId = b; + }; + this.setDataTime = function (b) { + a.dataTime = b; + }; + this.setSize = function (b) { + a.size = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + HistoryMessagesOuput: function () { + var a = {}; + this.setList = function (b) { + a.list = b; + }; + this.setSyncTime = function (b) { + a.syncTime = b; + }; + this.setHasMsg = function (b) { + a.hasMsg = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + HistoryMsgInput: function () { + var a = {}; + this.setTargetId = function (b) { + a.targetId = b; + }; + this.setTime = function (b) { + a.time = b; + }; + this.setCount = function (b) { + a.count = b; + }; + this.setOrder = function (b) { + a.order = b; + }; + this.toArrayBuffer = function () { + return a; + }; + }, + HistoryMsgOuput: function () { + var a = {}; + this.setList = function (b) { + a.list = b; + }; + this.setSyncTime = function (b) { + a.syncTime = b; + }; + this.setHasMsg = function (b) { + a.hasMsg = b; + }; + this.toArrayBuffer = function () { + return a; + }; + } + }; + for (var f in Modules) { + Modules[f].decode = function (b) { + var back = {}, + val = JSON.parse(b) || eval("(" + b + ")"); + for (var i in val) { + back[i] = val[i]; + back["get" + i.charAt(0).toUpperCase() + i.slice(1)] = function () { + return val[i]; + }; + } + return back; + }; + } + + /* + * JavaScript MD5 + * https://github.com/blueimp/JavaScript-MD5 + * + * Copyright 2011, Sebastian Tschan + * https://blueimp.net + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/MIT + * + * Based on + * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message + * Digest Algorithm, as defined in RFC 1321. + * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009 + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for more info. + */ + + /*jslint bitwise: true */ + /*global unescape, define, module */ + + var RongIMLib = {}; + var tools = { + Timer: function () { + function Timer(config) { + this.timeout = 0; + this.timers = []; + this.timeout = config.timeout; + } + Timer.prototype.resume = function (callback) { + var timer = setTimeout(callback, this.timeout); + this.timers.push(timer); + }; + Timer.prototype.pause = function () { + for (var i = 0, max = this.timers.length; i < max; i++) { + var timer = this.timers[i]; + clearTimeout(timer); + } + }; + return Timer; + }(), + convertToken: function (token) { + var systemInfo = wx.getSystemInfoSync(); + var platform = systemInfo.platform; + // if (platform == 'android') { + // token = token.replace(/\+/g, '%2B'); + // } + return token; + }, + isFunction: function (func) { + return Object.prototype.toString.call(func) == '[object Function]'; + }, + isArray: function (func) { + return Object.prototype.toString.call(func) == '[object Array]'; + }, + request: function (option, callbacks) { + var url = option.url; + var method = option.method || "get"; + method = method.toUpperCase(); + var data = option.data || {}; + var header = option.header || {}; + return wx.request({ + url: url, + method: method, + data: data, + header: header, + success: callbacks.success, + fail: callbacks.fail + }); + }, + socket: function (option, callbacks) { + var url = option.url; + var method = option.method || "get"; + method = method.toUpperCase(); //必须大写 + var data = option.data || {}; + var header = option.header || {}; + wx.connectSocket({ + url: url, + data: data, + method: method, + header: header + }); + wx.onSocketOpen(function (res) { + callbacks.open(wx, res); + }); + wx.onSocketError(callbacks.error); + wx.onSocketMessage(callbacks.message); + wx.onSocketClose(callbacks.close); + return wx; + }, + tplEngine: function (temp, data, regexp) { + if (!(Object.prototype.toString.call(data) === "[object Array]")) { + data = [data]; + } + var ret = []; + for (var i = 0, j = data.length; i < j; i++) { + ret.push(replaceAction(data[i])); + } + return ret.join(""); + function replaceAction(object) { + return temp.replace(regexp || /{([^}]+)}/g, function (match, name) { + if (match.charAt(0) == '\\') { + return match.slice(1); + } + return object[name] != undefined ? object[name] : '{' + name + '}'; + }); + } + }, + Watcher: function () { + this.watcherList = []; + this.checkIndexOutBound = function (index, bound) { + var isOutBound = index > -1 && index < bound; + return isOutBound; + }; + this.add = function (watcher, force) { + if (force) { + this.watcherList.length = 0; + } + if (tools.isFunction(watcher)) { + this.watcherList.push(watcher); + } + }; + this.get = function (index) { + if (this.checkIndexOutBound(index, this.watcherList.length)) { + return this.watcherList[index]; + } + }; + this.count = function () { + return this.watcherList.length; + }; + this.removeAt = function (index) { + var isOutBound = this.checkIndexOutBound(index, this.watcherList.length); + if (isOutBound) { + this.watcherList.splice(index, 1); + } + }; + this.remove = function (watcher) { + if (!watcher) { + this.watcherList.length = 0; + return; + } + var watchers = watcher; + if (tools.isFunction(watcher)) { + watchers = [watcher]; + } + if (tools.isArray(watchers)) { + for (var i = 0, len = watchers.length; i < len; i++) { + for (var j = 0; j < this.watcherList.length; j++) { + if (watchers[i] === this.watcherList[j]) { + this.removeAt(i); + break; + } + } + } + } + }; + this.notify = function (content) { + for (var i = 0, len = this.watcherList.length; i < len; i++) { + this.watcherList[i](content); + } + }; + this.indexOf = function (watcher, index) { + var i = index || 0, + len = this.watcherList.length; + while (i < len) { + var _watcher = this.watcherList[i]; + if (_watcher === watcher) { + return i; + } + i++; + } + return -1; + }; + } + }; + (function (RongIMLib) { + /* + * Add integers, wrapping at 2^32. This uses 16-bit operations internally + * to work around bugs in some JS interpreters. + */ + function safe_add(x, y) { + var lsw = (x & 0xFFFF) + (y & 0xFFFF), + msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return msw << 16 | lsw & 0xFFFF; + } + + /* + * Bitwise rotate a 32-bit number to the left. + */ + function bit_rol(num, cnt) { + return num << cnt | num >>> 32 - cnt; + } + + /* + * These functions implement the four basic operations the algorithm uses. + */ + function md5_cmn(q, a, b, x, s, t) { + return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b); + } + function md5_ff(a, b, c, d, x, s, t) { + return md5_cmn(b & c | ~b & d, a, b, x, s, t); + } + function md5_gg(a, b, c, d, x, s, t) { + return md5_cmn(b & d | c & ~d, a, b, x, s, t); + } + function md5_hh(a, b, c, d, x, s, t) { + return md5_cmn(b ^ c ^ d, a, b, x, s, t); + } + function md5_ii(a, b, c, d, x, s, t) { + return md5_cmn(c ^ (b | ~d), a, b, x, s, t); + } + + /* + * Calculate the MD5 of an array of little-endian words, and a bit length. + */ + function binl_md5(x, len) { + /* append padding */ + x[len >> 5] |= 0x80 << len % 32; + x[(len + 64 >>> 9 << 4) + 14] = len; + var i, + olda, + oldb, + oldc, + oldd, + a = 1732584193, + b = -271733879, + c = -1732584194, + d = 271733878; + for (i = 0; i < x.length; i += 16) { + olda = a; + oldb = b; + oldc = c; + oldd = d; + a = md5_ff(a, b, c, d, x[i], 7, -680876936); + d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586); + c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819); + b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330); + a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897); + d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426); + c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341); + b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983); + a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416); + d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417); + c = md5_ff(c, d, a, b, x[i + 10], 17, -42063); + b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162); + a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682); + d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101); + c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290); + b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329); + a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510); + d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632); + c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713); + b = md5_gg(b, c, d, a, x[i], 20, -373897302); + a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691); + d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083); + c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335); + b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848); + a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438); + d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690); + c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961); + b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501); + a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467); + d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784); + c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473); + b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734); + a = md5_hh(a, b, c, d, x[i + 5], 4, -378558); + d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463); + c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562); + b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556); + a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060); + d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353); + c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632); + b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640); + a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174); + d = md5_hh(d, a, b, c, x[i], 11, -358537222); + c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979); + b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189); + a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487); + d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835); + c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520); + b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651); + a = md5_ii(a, b, c, d, x[i], 6, -198630844); + d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415); + c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905); + b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055); + a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571); + d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606); + c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523); + b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799); + a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359); + d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744); + c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380); + b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649); + a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070); + d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379); + c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259); + b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551); + a = safe_add(a, olda); + b = safe_add(b, oldb); + c = safe_add(c, oldc); + d = safe_add(d, oldd); + } + return [a, b, c, d]; + } + + /* + * Convert an array of little-endian words to a string + */ + function binl2rstr(input) { + var i, + output = ''; + for (i = 0; i < input.length * 32; i += 8) { + output += String.fromCharCode(input[i >> 5] >>> i % 32 & 0xFF); + } + return output; + } + + /* + * Convert a raw string to an array of little-endian words + * Characters >255 have their high-byte silently ignored. + */ + function rstr2binl(input) { + var i, + output = []; + output[(input.length >> 2) - 1] = undefined; + for (i = 0; i < output.length; i += 1) { + output[i] = 0; + } + for (i = 0; i < input.length * 8; i += 8) { + output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << i % 32; + } + return output; + } + + /* + * Calculate the MD5 of a raw string + */ + function rstr_md5(s) { + return binl2rstr(binl_md5(rstr2binl(s), s.length * 8)); + } + + /* + * Calculate the HMAC-MD5, of a key and some data (raw strings) + */ + function rstr_hmac_md5(key, data) { + var i, + bkey = rstr2binl(key), + ipad = [], + opad = [], + hash; + ipad[15] = opad[15] = undefined; + if (bkey.length > 16) { + bkey = binl_md5(bkey, key.length * 8); + } + for (i = 0; i < 16; i += 1) { + ipad[i] = bkey[i] ^ 0x36363636; + opad[i] = bkey[i] ^ 0x5C5C5C5C; + } + hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8); + return binl2rstr(binl_md5(opad.concat(hash), 512 + 128)); + } + + /* + * Convert a raw string to a hex string + */ + function rstr2hex(input) { + var hex_tab = '0123456789abcdef', + output = '', + x, + i; + for (i = 0; i < input.length; i += 1) { + x = input.charCodeAt(i); + output += hex_tab.charAt(x >>> 4 & 0x0F) + hex_tab.charAt(x & 0x0F); + } + return output; + } + + /* + * Encode a string as utf-8 + */ + function str2rstr_utf8(input) { + return unescape(encodeURIComponent(input)); + } + + /* + * Take string arguments and return either raw or hex encoded strings + */ + function raw_md5(s) { + return rstr_md5(str2rstr_utf8(s)); + } + function hex_md5(s) { + return rstr2hex(raw_md5(s)); + } + function raw_hmac_md5(k, d) { + return rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)); + } + function hex_hmac_md5(k, d) { + return rstr2hex(raw_hmac_md5(k, d)); + } + function md5(string, key, raw) { + if (!key) { + if (!raw) { + return hex_md5(string); + } + return raw_md5(string); + } + if (!raw) { + return hex_hmac_md5(key, string); + } + return raw_hmac_md5(key, string); + } + RongIMLib.md5 = md5; + // if (typeof define === 'function' && define.amd) { + // define('md5',function () { + // return md5; + // }); + // } else if (typeof module === 'object' && module.exports) { + // module.exports = md5; + // } else { + // $.md5 = md5; + // } + })(RongIMLib); + var __extends = this && this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + // var RongIMLib; + (function (RongIMLib) { + (function (MentionedType) { + MentionedType[MentionedType["ALL"] = 1] = "ALL"; + MentionedType[MentionedType["PART"] = 2] = "PART"; + })(RongIMLib.MentionedType || (RongIMLib.MentionedType = {})); + var MentionedType = RongIMLib.MentionedType; + (function (MethodType) { + MethodType[MethodType["CUSTOMER_SERVICE"] = 1] = "CUSTOMER_SERVICE"; + MethodType[MethodType["RECALL"] = 2] = "RECALL"; + })(RongIMLib.MethodType || (RongIMLib.MethodType = {})); + var MethodType = RongIMLib.MethodType; + (function (BlacklistStatus) { + /** + * 在黑名单中。 + */ + BlacklistStatus[BlacklistStatus["IN_BLACK_LIST"] = 0] = "IN_BLACK_LIST"; + /** + * 不在黑名单中。 + */ + BlacklistStatus[BlacklistStatus["NOT_IN_BLACK_LIST"] = 1] = "NOT_IN_BLACK_LIST"; + })(RongIMLib.BlacklistStatus || (RongIMLib.BlacklistStatus = {})); + var BlacklistStatus = RongIMLib.BlacklistStatus; + (function (ConnectionChannel) { + ConnectionChannel[ConnectionChannel["XHR_POLLING"] = 0] = "XHR_POLLING"; + ConnectionChannel[ConnectionChannel["WEBSOCKET"] = 1] = "WEBSOCKET"; + //外部调用 + ConnectionChannel[ConnectionChannel["HTTP"] = 0] = "HTTP"; + //外部调用 + ConnectionChannel[ConnectionChannel["HTTPS"] = 1] = "HTTPS"; + })(RongIMLib.ConnectionChannel || (RongIMLib.ConnectionChannel = {})); + var ConnectionChannel = RongIMLib.ConnectionChannel; + (function (CustomerType) { + CustomerType[CustomerType["ONLY_ROBOT"] = 1] = "ONLY_ROBOT"; + CustomerType[CustomerType["ONLY_HUMAN"] = 2] = "ONLY_HUMAN"; + CustomerType[CustomerType["ROBOT_FIRST"] = 3] = "ROBOT_FIRST"; + CustomerType[CustomerType["HUMAN_FIRST"] = 4] = "HUMAN_FIRST"; + })(RongIMLib.CustomerType || (RongIMLib.CustomerType = {})); + var CustomerType = RongIMLib.CustomerType; + (function (GetChatRoomType) { + GetChatRoomType[GetChatRoomType["NONE"] = 0] = "NONE"; + GetChatRoomType[GetChatRoomType["SQQUENCE"] = 1] = "SQQUENCE"; + GetChatRoomType[GetChatRoomType["REVERSE"] = 2] = "REVERSE"; + })(RongIMLib.GetChatRoomType || (RongIMLib.GetChatRoomType = {})); + var GetChatRoomType = RongIMLib.GetChatRoomType; + (function (ConnectionStatus) { + /** + * 连接成功。 + */ + ConnectionStatus[ConnectionStatus["CONNECTED"] = 0] = "CONNECTED"; + /** + * 连接中。 + */ + ConnectionStatus[ConnectionStatus["CONNECTING"] = 1] = "CONNECTING"; + /** + * 断开连接。 + */ + ConnectionStatus[ConnectionStatus["DISCONNECTED"] = 2] = "DISCONNECTED"; + /** + * 用户账户在其他设备登录,本机会被踢掉线。 + */ + ConnectionStatus[ConnectionStatus["KICKED_OFFLINE_BY_OTHER_CLIENT"] = 6] = "KICKED_OFFLINE_BY_OTHER_CLIENT"; + /** + * 网络不可用。 + */ + ConnectionStatus[ConnectionStatus["NETWORK_UNAVAILABLE"] = 3] = "NETWORK_UNAVAILABLE"; + /** + * 域名错误 + */ + ConnectionStatus[ConnectionStatus["DOMAIN_INCORRECT"] = 12] = "DOMAIN_INCORRECT"; + /** + * 连接关闭。 + */ + ConnectionStatus[ConnectionStatus["CONNECTION_CLOSED"] = 4] = "CONNECTION_CLOSED"; + })(RongIMLib.ConnectionStatus || (RongIMLib.ConnectionStatus = {})); + var ConnectionStatus = RongIMLib.ConnectionStatus; + (function (ConversationNotificationStatus) { + /** + * 免打扰状态,关闭对应会话的通知提醒。 + */ + ConversationNotificationStatus[ConversationNotificationStatus["DO_NOT_DISTURB"] = 0] = "DO_NOT_DISTURB"; + /** + * 提醒。 + */ + ConversationNotificationStatus[ConversationNotificationStatus["NOTIFY"] = 1] = "NOTIFY"; + })(RongIMLib.ConversationNotificationStatus || (RongIMLib.ConversationNotificationStatus = {})); + var ConversationNotificationStatus = RongIMLib.ConversationNotificationStatus; + (function (ConversationType) { + ConversationType[ConversationType["NONE"] = 0] = "NONE"; + ConversationType[ConversationType["PRIVATE"] = 1] = "PRIVATE"; + ConversationType[ConversationType["DISCUSSION"] = 2] = "DISCUSSION"; + ConversationType[ConversationType["GROUP"] = 3] = "GROUP"; + ConversationType[ConversationType["CHATROOM"] = 4] = "CHATROOM"; + ConversationType[ConversationType["CUSTOMER_SERVICE"] = 5] = "CUSTOMER_SERVICE"; + ConversationType[ConversationType["SYSTEM"] = 6] = "SYSTEM"; + //默认关注 MC + ConversationType[ConversationType["APP_PUBLIC_SERVICE"] = 7] = "APP_PUBLIC_SERVICE"; + //手工关注 MP + ConversationType[ConversationType["PUBLIC_SERVICE"] = 8] = "PUBLIC_SERVICE"; + })(RongIMLib.ConversationType || (RongIMLib.ConversationType = {})); + var ConversationType = RongIMLib.ConversationType; + (function (DiscussionInviteStatus) { + /** + * 开放邀请。 + */ + DiscussionInviteStatus[DiscussionInviteStatus["OPENED"] = 0] = "OPENED"; + /** + * 关闭邀请。 + */ + DiscussionInviteStatus[DiscussionInviteStatus["CLOSED"] = 1] = "CLOSED"; + })(RongIMLib.DiscussionInviteStatus || (RongIMLib.DiscussionInviteStatus = {})); + var DiscussionInviteStatus = RongIMLib.DiscussionInviteStatus; + (function (ErrorCode) { + ErrorCode[ErrorCode["MINI_PROGAM_SERVICE_NOT_OPEN"] = 20000] = "MINI_PROGAM_SERVICE_NOT_OPEN"; + /** + * 发送频率过快 + */ + ErrorCode[ErrorCode["SEND_FREQUENCY_TOO_FAST"] = 20604] = "SEND_FREQUENCY_TOO_FAST"; + ErrorCode[ErrorCode["RC_MSG_UNAUTHORIZED"] = 20406] = "RC_MSG_UNAUTHORIZED"; + /** + * 群组 Id 无效 + */ + ErrorCode[ErrorCode["RC_DISCUSSION_GROUP_ID_INVALID"] = 20407] = "RC_DISCUSSION_GROUP_ID_INVALID"; + /** + * 群组被禁言 + */ + ErrorCode[ErrorCode["FORBIDDEN_IN_GROUP"] = 22408] = "FORBIDDEN_IN_GROUP"; + /** + * 不在讨论组。 + */ + ErrorCode[ErrorCode["NOT_IN_DISCUSSION"] = 21406] = "NOT_IN_DISCUSSION"; + /** + * 不在群组。 + */ + ErrorCode[ErrorCode["NOT_IN_GROUP"] = 22406] = "NOT_IN_GROUP"; + /** + * 不在聊天室。 + */ + ErrorCode[ErrorCode["NOT_IN_CHATROOM"] = 23406] = "NOT_IN_CHATROOM"; + /** + *聊天室被禁言 + */ + ErrorCode[ErrorCode["FORBIDDEN_IN_CHATROOM"] = 23408] = "FORBIDDEN_IN_CHATROOM"; + /** + * 聊天室中成员被踢出 + */ + ErrorCode[ErrorCode["RC_CHATROOM_USER_KICKED"] = 23409] = "RC_CHATROOM_USER_KICKED"; + /** + * 聊天室不存在 + */ + ErrorCode[ErrorCode["RC_CHATROOM_NOT_EXIST"] = 23410] = "RC_CHATROOM_NOT_EXIST"; + /** + * 聊天室成员已满 + */ + ErrorCode[ErrorCode["RC_CHATROOM_IS_FULL"] = 23411] = "RC_CHATROOM_IS_FULL"; + /** + * 获取聊天室信息参数无效 + */ + ErrorCode[ErrorCode["RC_CHATROOM_PATAMETER_INVALID"] = 23412] = "RC_CHATROOM_PATAMETER_INVALID"; + /** + * 聊天室异常 + */ + ErrorCode[ErrorCode["CHATROOM_GET_HISTORYMSG_ERROR"] = 23413] = "CHATROOM_GET_HISTORYMSG_ERROR"; + /** + * 没有打开聊天室消息存储 + */ + ErrorCode[ErrorCode["CHATROOM_NOT_OPEN_HISTORYMSG_STORE"] = 23414] = "CHATROOM_NOT_OPEN_HISTORYMSG_STORE"; + ErrorCode[ErrorCode["TIMEOUT"] = -1] = "TIMEOUT"; + /** + * 未知原因失败。 + */ + ErrorCode[ErrorCode["UNKNOWN"] = -2] = "UNKNOWN"; + /** + * 加入讨论失败 + */ + ErrorCode[ErrorCode["JOIN_IN_DISCUSSION"] = 21407] = "JOIN_IN_DISCUSSION"; + /** + * 创建讨论组失败 + */ + ErrorCode[ErrorCode["CREATE_DISCUSSION"] = 21408] = "CREATE_DISCUSSION"; + /** + * 设置讨论组邀请状态失败 + */ + ErrorCode[ErrorCode["INVITE_DICUSSION"] = 21409] = "INVITE_DICUSSION"; + /** + *获取用户失败 + */ + ErrorCode[ErrorCode["GET_USERINFO_ERROR"] = 23407] = "GET_USERINFO_ERROR"; + /** + * 在黑名单中。 + */ + ErrorCode[ErrorCode["REJECTED_BY_BLACKLIST"] = 405] = "REJECTED_BY_BLACKLIST"; + /** + * 通信过程中,当前 Socket 不存在。 + */ + ErrorCode[ErrorCode["RC_NET_CHANNEL_INVALID"] = 30001] = "RC_NET_CHANNEL_INVALID"; + /** + * Socket 连接不可用。 + */ + ErrorCode[ErrorCode["RC_NET_UNAVAILABLE"] = 30002] = "RC_NET_UNAVAILABLE"; + /** + * 通信超时。 + */ + ErrorCode[ErrorCode["RC_MSG_RESP_TIMEOUT"] = 30003] = "RC_MSG_RESP_TIMEOUT"; + /** + * 导航操作时,Http 请求失败。 + */ + ErrorCode[ErrorCode["RC_HTTP_SEND_FAIL"] = 30004] = "RC_HTTP_SEND_FAIL"; + /** + * HTTP 请求失败。 + */ + ErrorCode[ErrorCode["RC_HTTP_REQ_TIMEOUT"] = 30005] = "RC_HTTP_REQ_TIMEOUT"; + /** + * HTTP 接收失败。 + */ + ErrorCode[ErrorCode["RC_HTTP_RECV_FAIL"] = 30006] = "RC_HTTP_RECV_FAIL"; + /** + * 导航操作的 HTTP 请求,返回不是200。 + */ + ErrorCode[ErrorCode["RC_NAVI_RESOURCE_ERROR"] = 30007] = "RC_NAVI_RESOURCE_ERROR"; + /** + * 导航数据解析后,其中不存在有效数据。 + */ + ErrorCode[ErrorCode["RC_NODE_NOT_FOUND"] = 30008] = "RC_NODE_NOT_FOUND"; + /** + * 导航数据解析后,其中不存在有效 IP 地址。 + */ + ErrorCode[ErrorCode["RC_DOMAIN_NOT_RESOLVE"] = 30009] = "RC_DOMAIN_NOT_RESOLVE"; + /** + * 创建 Socket 失败。 + */ + ErrorCode[ErrorCode["RC_SOCKET_NOT_CREATED"] = 30010] = "RC_SOCKET_NOT_CREATED"; + /** + * Socket 被断开。 + */ + ErrorCode[ErrorCode["RC_SOCKET_DISCONNECTED"] = 30011] = "RC_SOCKET_DISCONNECTED"; + /** + * PING 操作失败。 + */ + ErrorCode[ErrorCode["RC_PING_SEND_FAIL"] = 30012] = "RC_PING_SEND_FAIL"; + /** + * PING 超时。 + */ + ErrorCode[ErrorCode["RC_PONG_RECV_FAIL"] = 30013] = "RC_PONG_RECV_FAIL"; + /** + * 消息发送失败。 + */ + ErrorCode[ErrorCode["RC_MSG_SEND_FAIL"] = 30014] = "RC_MSG_SEND_FAIL"; + /** + * 做 connect 连接时,收到的 ACK 超时。 + */ + ErrorCode[ErrorCode["RC_CONN_ACK_TIMEOUT"] = 31000] = "RC_CONN_ACK_TIMEOUT"; + /** + * 参数错误。 + */ + ErrorCode[ErrorCode["RC_CONN_PROTO_VERSION_ERROR"] = 31001] = "RC_CONN_PROTO_VERSION_ERROR"; + /** + * 参数错误,App Id 错误。 + */ + ErrorCode[ErrorCode["RC_CONN_ID_REJECT"] = 31002] = "RC_CONN_ID_REJECT"; + /** + * 服务器不可用。 + */ + ErrorCode[ErrorCode["RC_CONN_SERVER_UNAVAILABLE"] = 31003] = "RC_CONN_SERVER_UNAVAILABLE"; + /** + * Token 错误。 + */ + ErrorCode[ErrorCode["RC_CONN_USER_OR_PASSWD_ERROR"] = 31004] = "RC_CONN_USER_OR_PASSWD_ERROR"; + /** + * App Id 与 Token 不匹配。 + */ + ErrorCode[ErrorCode["RC_CONN_NOT_AUTHRORIZED"] = 31005] = "RC_CONN_NOT_AUTHRORIZED"; + /** + * 重定向,地址错误。 + */ + ErrorCode[ErrorCode["RC_CONN_REDIRECTED"] = 31006] = "RC_CONN_REDIRECTED"; + /** + * NAME 与后台注册信息不一致。 + */ + ErrorCode[ErrorCode["RC_CONN_PACKAGE_NAME_INVALID"] = 31007] = "RC_CONN_PACKAGE_NAME_INVALID"; + /** + * APP 被屏蔽、删除或不存在。 + */ + ErrorCode[ErrorCode["RC_CONN_APP_BLOCKED_OR_DELETED"] = 31008] = "RC_CONN_APP_BLOCKED_OR_DELETED"; + /** + * 用户被屏蔽。 + */ + ErrorCode[ErrorCode["RC_CONN_USER_BLOCKED"] = 31009] = "RC_CONN_USER_BLOCKED"; + /** + * Disconnect,由服务器返回,比如用户互踢。 + */ + ErrorCode[ErrorCode["RC_DISCONN_KICK"] = 31010] = "RC_DISCONN_KICK"; + /** + * Disconnect,由服务器返回,比如用户互踢。 + */ + ErrorCode[ErrorCode["RC_DISCONN_EXCEPTION"] = 31011] = "RC_DISCONN_EXCEPTION"; + /** + * 协议层内部错误。query,上传下载过程中数据错误。 + */ + ErrorCode[ErrorCode["RC_QUERY_ACK_NO_DATA"] = 32001] = "RC_QUERY_ACK_NO_DATA"; + /** + * 协议层内部错误。 + */ + ErrorCode[ErrorCode["RC_MSG_DATA_INCOMPLETE"] = 32002] = "RC_MSG_DATA_INCOMPLETE"; + /** + * 未调用 init 初始化函数。 + */ + ErrorCode[ErrorCode["BIZ_ERROR_CLIENT_NOT_INIT"] = 33001] = "BIZ_ERROR_CLIENT_NOT_INIT"; + /** + * 数据库初始化失败。 + */ + ErrorCode[ErrorCode["BIZ_ERROR_DATABASE_ERROR"] = 33002] = "BIZ_ERROR_DATABASE_ERROR"; + /** + * 传入参数无效。 + */ + ErrorCode[ErrorCode["BIZ_ERROR_INVALID_PARAMETER"] = 33003] = "BIZ_ERROR_INVALID_PARAMETER"; + /** + * 通道无效。 + */ + ErrorCode[ErrorCode["BIZ_ERROR_NO_CHANNEL"] = 33004] = "BIZ_ERROR_NO_CHANNEL"; + /** + * 重新连接成功。 + */ + ErrorCode[ErrorCode["BIZ_ERROR_RECONNECT_SUCCESS"] = 33005] = "BIZ_ERROR_RECONNECT_SUCCESS"; + /** + * 连接中,再调用 connect 被拒绝。 + */ + ErrorCode[ErrorCode["BIZ_ERROR_CONNECTING"] = 33006] = "BIZ_ERROR_CONNECTING"; + /** + * 消息漫游服务未开通 + */ + ErrorCode[ErrorCode["MSG_ROAMING_SERVICE_UNAVAILABLE"] = 33007] = "MSG_ROAMING_SERVICE_UNAVAILABLE"; + ErrorCode[ErrorCode["MSG_INSERT_ERROR"] = 33008] = "MSG_INSERT_ERROR"; + ErrorCode[ErrorCode["MSG_DEL_ERROR"] = 33009] = "MSG_DEL_ERROR"; + /** + * 删除会话失败 + */ + ErrorCode[ErrorCode["CONVER_REMOVE_ERROR"] = 34001] = "CONVER_REMOVE_ERROR"; + /** + *拉取历史消息 + */ + ErrorCode[ErrorCode["CONVER_GETLIST_ERROR"] = 34002] = "CONVER_GETLIST_ERROR"; + /** + * 会话指定异常 + */ + ErrorCode[ErrorCode["CONVER_SETOP_ERROR"] = 34003] = "CONVER_SETOP_ERROR"; + /** + * 获取会话未读消息总数失败 + */ + ErrorCode[ErrorCode["CONVER_TOTAL_UNREAD_ERROR"] = 34004] = "CONVER_TOTAL_UNREAD_ERROR"; + /** + * 获取指定会话类型未读消息数异常 + */ + ErrorCode[ErrorCode["CONVER_TYPE_UNREAD_ERROR"] = 34005] = "CONVER_TYPE_UNREAD_ERROR"; + /** + * 获取指定用户ID&会话类型未读消息数异常 + */ + ErrorCode[ErrorCode["CONVER_ID_TYPE_UNREAD_ERROR"] = 34006] = "CONVER_ID_TYPE_UNREAD_ERROR"; + ErrorCode[ErrorCode["CONVER_CLEAR_ERROR"] = 34007] = "CONVER_CLEAR_ERROR"; + ErrorCode[ErrorCode["CONVER_GET_ERROR"] = 34008] = "CONVER_GET_ERROR"; + //群组异常信息 + /** + * + */ + ErrorCode[ErrorCode["GROUP_SYNC_ERROR"] = 35001] = "GROUP_SYNC_ERROR"; + /** + * 匹配群信息系异常 + */ + ErrorCode[ErrorCode["GROUP_MATCH_ERROR"] = 35002] = "GROUP_MATCH_ERROR"; + //聊天室异常 + /** + * 加入聊天室Id为空 + */ + ErrorCode[ErrorCode["CHATROOM_ID_ISNULL"] = 36001] = "CHATROOM_ID_ISNULL"; + /** + * 加入聊天室失败 + */ + ErrorCode[ErrorCode["CHARTOOM_JOIN_ERROR"] = 36002] = "CHARTOOM_JOIN_ERROR"; + /** + * 拉取聊天室历史消息失败 + */ + ErrorCode[ErrorCode["CHATROOM_HISMESSAGE_ERROR"] = 36003] = "CHATROOM_HISMESSAGE_ERROR"; + //黑名单异常 + /** + * 加入黑名单异常 + */ + ErrorCode[ErrorCode["BLACK_ADD_ERROR"] = 37001] = "BLACK_ADD_ERROR"; + /** + * 获得指定人员再黑名单中的状态异常 + */ + ErrorCode[ErrorCode["BLACK_GETSTATUS_ERROR"] = 37002] = "BLACK_GETSTATUS_ERROR"; + /** + * 移除黑名单异常 + */ + ErrorCode[ErrorCode["BLACK_REMOVE_ERROR"] = 37003] = "BLACK_REMOVE_ERROR"; + /** + * 获取草稿失败 + */ + ErrorCode[ErrorCode["DRAF_GET_ERROR"] = 38001] = "DRAF_GET_ERROR"; + /** + * 保存草稿失败 + */ + ErrorCode[ErrorCode["DRAF_SAVE_ERROR"] = 38002] = "DRAF_SAVE_ERROR"; + /** + * 删除草稿失败 + */ + ErrorCode[ErrorCode["DRAF_REMOVE_ERROR"] = 38003] = "DRAF_REMOVE_ERROR"; + /** + * 关注公众号失败 + */ + ErrorCode[ErrorCode["SUBSCRIBE_ERROR"] = 39001] = "SUBSCRIBE_ERROR"; + /** + * 关注公众号失败 + */ + ErrorCode[ErrorCode["QNTKN_FILETYPE_ERROR"] = 41001] = "QNTKN_FILETYPE_ERROR"; + /** + * 获取七牛token失败 + */ + ErrorCode[ErrorCode["QNTKN_GET_ERROR"] = 41002] = "QNTKN_GET_ERROR"; + /** + * cookie被禁用 + */ + ErrorCode[ErrorCode["COOKIE_ENABLE"] = 51001] = "COOKIE_ENABLE"; + ErrorCode[ErrorCode["GET_MESSAGE_BY_ID_ERROR"] = 61001] = "GET_MESSAGE_BY_ID_ERROR"; + // 没有注册DeviveId 也就是用户没有登陆 + ErrorCode[ErrorCode["HAVNODEVICEID"] = 24001] = "HAVNODEVICEID"; + // 已经存在 + ErrorCode[ErrorCode["DEVICEIDISHAVE"] = 24002] = "DEVICEIDISHAVE"; + // 成功 + ErrorCode[ErrorCode["SUCCESS"] = 0] = "SUCCESS"; + // 没有对应的用户或token + ErrorCode[ErrorCode["FEILD"] = 24009] = "FEILD"; + // voip为空 + ErrorCode[ErrorCode["VOIPISNULL"] = 24013] = "VOIPISNULL"; + // 不支持的Voip引擎 + ErrorCode[ErrorCode["NOENGINETYPE"] = 24010] = "NOENGINETYPE"; + // channleName 是空 + ErrorCode[ErrorCode["NULLCHANNELNAME"] = 24011] = "NULLCHANNELNAME"; + // 生成Voipkey失败 + ErrorCode[ErrorCode["VOIPDYANMICERROR"] = 24012] = "VOIPDYANMICERROR"; + // 没有配置voip + ErrorCode[ErrorCode["NOVOIP"] = 24014] = "NOVOIP"; + // 服务器内部错误 + ErrorCode[ErrorCode["INTERNALERRROR"] = 24015] = "INTERNALERRROR"; + //VOIP close + ErrorCode[ErrorCode["VOIPCLOSE"] = 24016] = "VOIPCLOSE"; + ErrorCode[ErrorCode["CLOSE_BEFORE_OPEN"] = 51001] = "CLOSE_BEFORE_OPEN"; + ErrorCode[ErrorCode["ALREADY_IN_USE"] = 51002] = "ALREADY_IN_USE"; + ErrorCode[ErrorCode["INVALID_CHANNEL_NAME"] = 51003] = "INVALID_CHANNEL_NAME"; + ErrorCode[ErrorCode["VIDEO_CONTAINER_IS_NULL"] = 51004] = "VIDEO_CONTAINER_IS_NULL"; + /** + * 删除消息数组长度为 0 . + */ + ErrorCode[ErrorCode["DELETE_MESSAGE_ID_IS_NULL"] = 61001] = "DELETE_MESSAGE_ID_IS_NULL"; + /*! + 己方取消已发出的通话请求 + */ + ErrorCode[ErrorCode["CANCEL"] = 1] = "CANCEL"; + /*! + 己方拒绝收到的通话请求 + */ + ErrorCode[ErrorCode["REJECT"] = 2] = "REJECT"; + /*! + 己方挂断 + */ + ErrorCode[ErrorCode["HANGUP"] = 3] = "HANGUP"; + /*! + 己方忙碌 + */ + ErrorCode[ErrorCode["BUSYLINE"] = 4] = "BUSYLINE"; + /*! + 己方未接听 + */ + ErrorCode[ErrorCode["NO_RESPONSE"] = 5] = "NO_RESPONSE"; + /*! + 己方不支持当前引擎 + */ + ErrorCode[ErrorCode["ENGINE_UN_SUPPORTED"] = 6] = "ENGINE_UN_SUPPORTED"; + /*! + 己方网络出错 + */ + ErrorCode[ErrorCode["NETWORK_ERROR"] = 7] = "NETWORK_ERROR"; + /*! + 对方取消已发出的通话请求 + */ + ErrorCode[ErrorCode["REMOTE_CANCEL"] = 11] = "REMOTE_CANCEL"; + /*! + 对方拒绝收到的通话请求 + */ + ErrorCode[ErrorCode["REMOTE_REJECT"] = 12] = "REMOTE_REJECT"; + /*! + 通话过程对方挂断 + */ + ErrorCode[ErrorCode["REMOTE_HANGUP"] = 13] = "REMOTE_HANGUP"; + /*! + 对方忙碌 + */ + ErrorCode[ErrorCode["REMOTE_BUSYLINE"] = 14] = "REMOTE_BUSYLINE"; + /*! + 对方未接听 + */ + ErrorCode[ErrorCode["REMOTE_NO_RESPONSE"] = 15] = "REMOTE_NO_RESPONSE"; + /*! + 对方网络错误 + */ + ErrorCode[ErrorCode["REMOTE_ENGINE_UN_SUPPORTED"] = 16] = "REMOTE_ENGINE_UN_SUPPORTED"; + /*! + 对方网络错误 + */ + ErrorCode[ErrorCode["REMOTE_NETWORK_ERROR"] = 17] = "REMOTE_NETWORK_ERROR"; + /*! + VoIP 不可用 + */ + ErrorCode[ErrorCode["VOIP_NOT_AVALIABLE"] = 18] = "VOIP_NOT_AVALIABLE"; + })(RongIMLib.ErrorCode || (RongIMLib.ErrorCode = {})); + var ErrorCode = RongIMLib.ErrorCode; + (function (VoIPMediaType) { + VoIPMediaType[VoIPMediaType["MEDIA_AUDIO"] = 1] = "MEDIA_AUDIO"; + VoIPMediaType[VoIPMediaType["MEDIA_VEDIO"] = 2] = "MEDIA_VEDIO"; + })(RongIMLib.VoIPMediaType || (RongIMLib.VoIPMediaType = {})); + var VoIPMediaType = RongIMLib.VoIPMediaType; + (function (MediaType) { + /** + * 图片。 + */ + MediaType[MediaType["IMAGE"] = 1] = "IMAGE"; + /** + * 声音。 + */ + MediaType[MediaType["AUDIO"] = 2] = "AUDIO"; + /** + * 视频。 + */ + MediaType[MediaType["VIDEO"] = 3] = "VIDEO"; + /** + * 通用文件。 + */ + MediaType[MediaType["FILE"] = 100] = "FILE"; + })(RongIMLib.MediaType || (RongIMLib.MediaType = {})); + var MediaType = RongIMLib.MediaType; + (function (MessageDirection) { + /** + * 发送消息。 + */ + MessageDirection[MessageDirection["SEND"] = 1] = "SEND"; + /** + * 接收消息。 + */ + MessageDirection[MessageDirection["RECEIVE"] = 2] = "RECEIVE"; + })(RongIMLib.MessageDirection || (RongIMLib.MessageDirection = {})); + var MessageDirection = RongIMLib.MessageDirection; + (function (FileType) { + FileType[FileType["IMAGE"] = 1] = "IMAGE"; + FileType[FileType["AUDIO"] = 2] = "AUDIO"; + FileType[FileType["VIDEO"] = 3] = "VIDEO"; + FileType[FileType["FILE"] = 4] = "FILE"; + })(RongIMLib.FileType || (RongIMLib.FileType = {})); + var FileType = RongIMLib.FileType; + (function (RealTimeLocationErrorCode) { + /** + * 未初始化 RealTimeLocation 实例 + */ + RealTimeLocationErrorCode[RealTimeLocationErrorCode["RC_REAL_TIME_LOCATION_NOT_INIT"] = -1] = "RC_REAL_TIME_LOCATION_NOT_INIT"; + /** + * 执行成功。 + */ + RealTimeLocationErrorCode[RealTimeLocationErrorCode["RC_REAL_TIME_LOCATION_SUCCESS"] = 0] = "RC_REAL_TIME_LOCATION_SUCCESS"; + /** + * 获取 RealTimeLocation 实例时返回 + * GPS 未打开。 + */ + RealTimeLocationErrorCode[RealTimeLocationErrorCode["RC_REAL_TIME_LOCATION_GPS_DISABLED"] = 1] = "RC_REAL_TIME_LOCATION_GPS_DISABLED"; + /** + * 获取 RealTimeLocation 实例时返回 + * 当前会话不支持位置共享。 + */ + RealTimeLocationErrorCode[RealTimeLocationErrorCode["RC_REAL_TIME_LOCATION_CONVERSATION_NOT_SUPPORT"] = 2] = "RC_REAL_TIME_LOCATION_CONVERSATION_NOT_SUPPORT"; + /** + * 获取 RealTimeLocation 实例时返回 + * 对方已发起位置共享。 + */ + RealTimeLocationErrorCode[RealTimeLocationErrorCode["RC_REAL_TIME_LOCATION_IS_ON_GOING"] = 3] = "RC_REAL_TIME_LOCATION_IS_ON_GOING"; + /** + * Join 时返回 + * 当前位置共享已超过最大支持人数。 + */ + RealTimeLocationErrorCode[RealTimeLocationErrorCode["RC_REAL_TIME_LOCATION_EXCEED_MAX_PARTICIPANT"] = 4] = "RC_REAL_TIME_LOCATION_EXCEED_MAX_PARTICIPANT"; + /** + * Join 时返回 + * 加入位置共享失败。 + */ + RealTimeLocationErrorCode[RealTimeLocationErrorCode["RC_REAL_TIME_LOCATION_JOIN_FAILURE"] = 5] = "RC_REAL_TIME_LOCATION_JOIN_FAILURE"; + /** + * Start 时返回 + * 发起位置共享失败。 + */ + RealTimeLocationErrorCode[RealTimeLocationErrorCode["RC_REAL_TIME_LOCATION_START_FAILURE"] = 6] = "RC_REAL_TIME_LOCATION_START_FAILURE"; + /** + * 网络不可用。 + */ + RealTimeLocationErrorCode[RealTimeLocationErrorCode["RC_REAL_TIME_LOCATION_NETWORK_UNAVAILABLE"] = 7] = "RC_REAL_TIME_LOCATION_NETWORK_UNAVAILABLE"; + })(RongIMLib.RealTimeLocationErrorCode || (RongIMLib.RealTimeLocationErrorCode = {})); + var RealTimeLocationErrorCode = RongIMLib.RealTimeLocationErrorCode; + (function (RealTimeLocationStatus) { + /** + * 空闲状态 (默认状态) + * 对方或者自己都未发起位置共享业务,或者位置共享业务已结束。 + */ + RealTimeLocationStatus[RealTimeLocationStatus["RC_REAL_TIME_LOCATION_STATUS_IDLE"] = 0] = "RC_REAL_TIME_LOCATION_STATUS_IDLE"; + /** + * 呼入状态 (待加入) + * 1. 对方发起了位置共享业务,此状态下,自己只能选择加入。 + * 2. 自己从已连接的位置共享中退出。 + */ + RealTimeLocationStatus[RealTimeLocationStatus["RC_REAL_TIME_LOCATION_STATUS_INCOMING"] = 1] = "RC_REAL_TIME_LOCATION_STATUS_INCOMING"; + /** + * 呼出状态 =(自己创建) + * 1. 自己发起位置共享业务,对方只能选择加入。 + * 2. 对方从已连接的位置共享业务中退出。 + */ + RealTimeLocationStatus[RealTimeLocationStatus["RC_REAL_TIME_LOCATION_STATUS_OUTGOING"] = 2] = "RC_REAL_TIME_LOCATION_STATUS_OUTGOING"; + /** + * 连接状态 (自己加入) + * 对方加入了自己发起的位置共享,或者自己加入了对方发起的位置共享。 + */ + RealTimeLocationStatus[RealTimeLocationStatus["RC_REAL_TIME_LOCATION_STATUS_CONNECTED"] = 3] = "RC_REAL_TIME_LOCATION_STATUS_CONNECTED"; + })(RongIMLib.RealTimeLocationStatus || (RongIMLib.RealTimeLocationStatus = {})); + var RealTimeLocationStatus = RongIMLib.RealTimeLocationStatus; + (function (ReceivedStatus) { + ReceivedStatus[ReceivedStatus["READ"] = 1] = "READ"; + ReceivedStatus[ReceivedStatus["LISTENED"] = 2] = "LISTENED"; + ReceivedStatus[ReceivedStatus["DOWNLOADED"] = 4] = "DOWNLOADED"; + ReceivedStatus[ReceivedStatus["RETRIEVED"] = 8] = "RETRIEVED"; + ReceivedStatus[ReceivedStatus["UNREAD"] = 0] = "UNREAD"; + })(RongIMLib.ReceivedStatus || (RongIMLib.ReceivedStatus = {})); + var ReceivedStatus = RongIMLib.ReceivedStatus; + (function (SearchType) { + /** + * 精确。 + */ + SearchType[SearchType["EXACT"] = 0] = "EXACT"; + /** + * 模糊。 + */ + SearchType[SearchType["FUZZY"] = 1] = "FUZZY"; + })(RongIMLib.SearchType || (RongIMLib.SearchType = {})); + var SearchType = RongIMLib.SearchType; + (function (SentStatus) { + /** + * 发送中。 + */ + SentStatus[SentStatus["SENDING"] = 10] = "SENDING"; + /** + * 发送失败。 + */ + SentStatus[SentStatus["FAILED"] = 20] = "FAILED"; + /** + * 已发送。 + */ + SentStatus[SentStatus["SENT"] = 30] = "SENT"; + /** + * 对方已接收。 + */ + SentStatus[SentStatus["RECEIVED"] = 40] = "RECEIVED"; + /** + * 对方已读。 + */ + SentStatus[SentStatus["READ"] = 50] = "READ"; + /** + * 对方已销毁。 + */ + SentStatus[SentStatus["DESTROYED"] = 60] = "DESTROYED"; + })(RongIMLib.SentStatus || (RongIMLib.SentStatus = {})); + var SentStatus = RongIMLib.SentStatus; + (function (ConnectionState) { + ConnectionState[ConnectionState["ACCEPTED"] = 0] = "ACCEPTED"; + ConnectionState[ConnectionState["UNACCEPTABLE_PROTOCOL_VERSION"] = 1] = "UNACCEPTABLE_PROTOCOL_VERSION"; + ConnectionState[ConnectionState["IDENTIFIER_REJECTED"] = 2] = "IDENTIFIER_REJECTED"; + ConnectionState[ConnectionState["SERVER_UNAVAILABLE"] = 3] = "SERVER_UNAVAILABLE"; + /** + * token无效 + */ + ConnectionState[ConnectionState["TOKEN_INCORRECT"] = 4] = "TOKEN_INCORRECT"; + ConnectionState[ConnectionState["NOT_AUTHORIZED"] = 5] = "NOT_AUTHORIZED"; + ConnectionState[ConnectionState["REDIRECT"] = 6] = "REDIRECT"; + ConnectionState[ConnectionState["PACKAGE_ERROR"] = 7] = "PACKAGE_ERROR"; + ConnectionState[ConnectionState["APP_BLOCK_OR_DELETE"] = 8] = "APP_BLOCK_OR_DELETE"; + ConnectionState[ConnectionState["BLOCK"] = 9] = "BLOCK"; + ConnectionState[ConnectionState["TOKEN_EXPIRE"] = 10] = "TOKEN_EXPIRE"; + ConnectionState[ConnectionState["DEVICE_ERROR"] = 11] = "DEVICE_ERROR"; + })(RongIMLib.ConnectionState || (RongIMLib.ConnectionState = {})); + var ConnectionState = RongIMLib.ConnectionState; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var RongIMClient = function () { + function RongIMClient() {} + RongIMClient.getInstance = function () { + if (!RongIMClient._instance) { + throw new Error("RongIMClient is not initialized. Call .init() method first."); + } + return RongIMClient._instance; + }; + /** + * 初始化 SDK,在整个应用全局只需要调用一次。 + * @param appKey 开发者后台申请的 AppKey,用来标识应用。 + * @param dataAccessProvider 必须是DataAccessProvider的实例 + */ + RongIMClient.init = function (appKey, dataAccessProvider, options) { + if (RongIMClient._instance) { + return RongIMClient._memoryStore.sdkInfo; + } + RongIMClient._instance = new RongIMClient(); + options = options || {}; + var protocol = options.protocol || "https://", + wsScheme = options.wsScheme || 'wss://'; + var isPolling = true; + RongIMClient._storageProvider = RongIMLib.LocalStorageProvider; + RongIMClient._Cahche = { + conversationList: [], + callbacks: [] + }; + var cmpList = ['cometproxy-cn.ronghub.com', 'mini-cn.ronghub.com']; + var opts = RongIMLib.ObjectTools.buildOptions(options, { + navi: protocol + 'nav.cn.ronghub.com', + api: protocol + 'api.cn.ronghub.com', + isPolling: true, + wsScheme: wsScheme, + cookieValidity: 1, + protocol: protocol, + openMp: true, + cmp: cmpList[0], + cmpList: cmpList, + maxConversationCount: 300 + }, protocol); + var pather = new RongIMLib.FeaturePatcher(); + pather.patchAll(); + var tempStore = { + token: "", + callback: null, + hasModules: true, + global: window, + lastReadTime: new RongIMLib.LimitableMap(), + conversationList: [], + appKey: appKey, + publicServiceMap: new RongIMLib.PublicServiceMap(), + providerType: 1, + deltaTime: 0, + filterMessages: [], + isSyncRemoteConverList: false, + isUseWebSQLProvider: false, + otherDevice: false, + custStore: {}, + converStore: { + latestMessage: {} + }, + connectAckTime: 0, + voipStategy: 0, + isFirstPingMsg: true, + depend: opts, + listenerList: RongIMClient._memoryStore.listenerList + }; + RongIMClient._memoryStore = tempStore; + if (dataAccessProvider && Object.prototype.toString.call(dataAccessProvider) == "[object Object]") { + // RongIMClient._memoryStore.isUseWebSQLProvider = true; 处理不同存储方案 + RongIMClient._dataAccessProvider = dataAccessProvider; + } else { + RongIMClient._dataAccessProvider = new RongIMLib.ServerDataProvider(); + } + RongIMClient._dataAccessProvider.init(appKey); + RongIMClient.MessageParams = { + TextMessage: { + objectName: "RC:TxtMsg", + msgTag: new RongIMLib.MessageTag(true, true) + }, + ImageMessage: { + objectName: "RC:ImgMsg", + msgTag: new RongIMLib.MessageTag(true, true) + }, + DiscussionNotificationMessage: { + objectName: "RC:DizNtf", + msgTag: new RongIMLib.MessageTag(true, true) + }, + VoiceMessage: { + objectName: "RC:VcMsg", + msgTag: new RongIMLib.MessageTag(true, true) + }, + RichContentMessage: { + objectName: "RC:ImgTextMsg", + msgTag: new RongIMLib.MessageTag(true, true) + }, + FileMessage: { + objectName: "RC:FileMsg", + msgTag: new RongIMLib.MessageTag(true, true) + }, + HandshakeMessage: { + objectName: "", + msgTag: new RongIMLib.MessageTag(true, true) + }, + UnknownMessage: { + objectName: "", + msgTag: new RongIMLib.MessageTag(true, true) + }, + LocationMessage: { + objectName: "RC:LBSMsg", + msgTag: new RongIMLib.MessageTag(true, true) + }, + InformationNotificationMessage: { + objectName: "RC:InfoNtf", + msgTag: new RongIMLib.MessageTag(true, true) + }, + ContactNotificationMessage: { + objectName: "RC:ContactNtf", + msgTag: new RongIMLib.MessageTag(true, true) + }, + ProfileNotificationMessage: { + objectName: "RC:ProfileNtf", + msgTag: new RongIMLib.MessageTag(true, true) + }, + CommandNotificationMessage: { + objectName: "RC:CmdNtf", + msgTag: new RongIMLib.MessageTag(true, true) + }, + PublicServiceRichContentMessage: { + objectName: "RC:PSImgTxtMsg", + msgTag: new RongIMLib.MessageTag(true, true) + }, + PublicServiceMultiRichContentMessage: { + objectName: "RC:PSMultiImgTxtMsg", + msgTag: new RongIMLib.MessageTag(true, true) + }, + JrmfReadPacketMessage: { + objectName: "RCJrmf:RpMsg", + msgTag: new RongIMLib.MessageTag(true, true) + }, + JrmfReadPacketOpenedMessage: { + objectName: "RCJrmf:RpOpendMsg", + msgTag: new RongIMLib.MessageTag(true, true) + }, + GroupNotificationMessage: { + objectName: "RC:GrpNtf", + msgTag: new RongIMLib.MessageTag(true, true) + }, + CommandMessage: { + objectName: "RC:CmdMsg", + msgTag: new RongIMLib.MessageTag(false, false) + }, + TypingStatusMessage: { + objectName: "RC:TypSts", + msgTag: new RongIMLib.MessageTag(false, false) + }, + PublicServiceCommandMessage: { + objectName: "RC:PSCmd", + msgTag: new RongIMLib.MessageTag(false, false) + }, + RecallCommandMessage: { + objectName: "RC:RcCmd", + msgTag: new RongIMLib.MessageTag(false, true) + }, + SyncReadStatusMessage: { + objectName: "RC:SRSMsg", + msgTag: new RongIMLib.MessageTag(false, false) + }, + ReadReceiptRequestMessage: { + objectName: "RC:RRReqMsg", + msgTag: new RongIMLib.MessageTag(false, false) + }, + ReadReceiptResponseMessage: { + objectName: "RC:RRRspMsg", + msgTag: new RongIMLib.MessageTag(false, false) + }, + ChangeModeResponseMessage: { + objectName: "RC:CsChaR", + msgTag: new RongIMLib.MessageTag(false, false) + }, + ChangeModeMessage: { + objectName: "RC:CSCha", + msgTag: new RongIMLib.MessageTag(false, false) + }, + EvaluateMessage: { + objectName: "RC:CsEva", + msgTag: new RongIMLib.MessageTag(false, false) + }, + CustomerContact: { + objectName: "RC:CsContact", + msgTag: new RongIMLib.MessageTag(false, false) + }, + HandShakeMessage: { + objectName: "RC:CsHs", + msgTag: new RongIMLib.MessageTag(false, false) + }, + HandShakeResponseMessage: { + objectName: "RC:CsHsR", + msgTag: new RongIMLib.MessageTag(false, false) + }, + SuspendMessage: { + objectName: "RC:CsSp", + msgTag: new RongIMLib.MessageTag(false, false) + }, + TerminateMessage: { + objectName: "RC:CsEnd", + msgTag: new RongIMLib.MessageTag(false, false) + }, + CustomerStatusUpdateMessage: { + objectName: "RC:CsUpdate", + msgTag: new RongIMLib.MessageTag(false, false) + }, + ReadReceiptMessage: { + objectName: "RC:ReadNtf", + msgTag: new RongIMLib.MessageTag(false, false) + } + // RCEUpdateStatusMessage: { objectName: "RCE:UpdateStatus", msgTag: new RongIMLib.MessageTag(false, false) } + }; + // if ('RongCallLib' in RongIMLib) { + RongIMClient.MessageParams["AcceptMessage"] = { + objectName: "RC:VCAccept", + msgTag: new RongIMLib.MessageTag(false, false) + }; + RongIMClient.MessageParams["RingingMessage"] = { + objectName: "RC:VCRinging", + msgTag: new RongIMLib.MessageTag(false, false) + }; + RongIMClient.MessageParams["SummaryMessage"] = { + objectName: "RC:VCSummary", + msgTag: new RongIMLib.MessageTag(false, false) + }; + RongIMClient.MessageParams["HungupMessage"] = { + objectName: "RC:VCHangup", + msgTag: new RongIMLib.MessageTag(false, false) + }; + RongIMClient.MessageParams["InviteMessage"] = { + objectName: "RC:VCInvite", + msgTag: new RongIMLib.MessageTag(false, false) + }; + RongIMClient.MessageParams["MediaModifyMessage"] = { + objectName: "RC:VCModifyMedia", + msgTag: new RongIMLib.MessageTag(false, false) + }; + RongIMClient.MessageParams["MemberModifyMessage"] = { + objectName: "RC:VCModifyMem", + msgTag: new RongIMLib.MessageTag(false, false) + }; + // } + RongIMClient.MessageType = { + TextMessage: "TextMessage", + ImageMessage: "ImageMessage", + DiscussionNotificationMessage: "DiscussionNotificationMessage", + VoiceMessage: "VoiceMessage", + RichContentMessage: "RichContentMessage", + HandshakeMessage: "HandshakeMessage", + UnknownMessage: "UnknownMessage", + LocationMessage: "LocationMessage", + InformationNotificationMessage: "InformationNotificationMessage", + ContactNotificationMessage: "ContactNotificationMessage", + ProfileNotificationMessage: "ProfileNotificationMessage", + CommandNotificationMessage: "CommandNotificationMessage", + CommandMessage: "CommandMessage", + TypingStatusMessage: "TypingStatusMessage", + ChangeModeResponseMessage: "ChangeModeResponseMessage", + ChangeModeMessage: "ChangeModeMessage", + EvaluateMessage: "EvaluateMessage", + HandShakeMessage: "HandShakeMessage", + HandShakeResponseMessage: "HandShakeResponseMessage", + SuspendMessage: "SuspendMessage", + TerminateMessage: "TerminateMessage", + CustomerContact: "CustomerContact", + CustomerStatusUpdateMessage: "CustomerStatusUpdateMessage", + SyncReadStatusMessage: "SyncReadStatusMessage", + ReadReceiptRequestMessage: "ReadReceiptRequestMessage", + ReadReceiptResponseMessage: "ReadReceiptResponseMessage", + FileMessage: 'FileMessage', + AcceptMessage: "AcceptMessage", + RingingMessage: "RingingMessage", + SummaryMessage: "SummaryMessage", + HungupMessage: "HungupMessage", + InviteMessage: "InviteMessage", + MediaModifyMessage: "MediaModifyMessage", + MemberModifyMessage: "MemberModifyMessage", + JrmfReadPacketMessage: "JrmfReadPacketMessage", + JrmfReadPacketOpenedMessage: "JrmfReadPacketOpenedMessage" + // RCEUpdateStatusMessage: "RCEUpdateStatusMessage" + }; + + RongIMClient.Conversation = RongIMClient._dataAccessProvider.Conversation; + }; + /** + * 连接服务器,在整个应用全局只需要调用一次,断线后 SDK 会自动重连。 + * + * @param token 从服务端获取的用户身份令牌(Token)。 + * @param callback 连接回调,返回连接的成功或者失败状态。 + */ + RongIMClient.connect = function (token, callback, userId) { + var key = "navi"; + var storage = RongIMClient._storageProvider; + key = storage.getItemKey(key); + var server = storage.getItem(key) || ""; + var isIP = function (str) { + var pattern = /^\d{1,3}(\.\d{1,3}){3}(:\d*)?$/; + return pattern.test(str); + }; + var domain = server.split(",")[0]; + if (isIP(domain)) { + storage.removeItem("rongSDK"); + } + RongIMLib.CheckParam.getInstance().check(["string", "object", "string|null|object|global|undefined"], "connect", true, arguments); + RongIMClient._dataAccessProvider.connect(token, callback, userId); + }; + RongIMClient.ready = function (callback) { + var isAlive = function () { + var isConnecting = false, + isConnected = false; + if (RongIMLib.Bridge._client && RongIMLib.Bridge._client.channel) { + isConnecting = RongIMLib.Bridge._client.channel.connectionStatus == RongIMLib.ConnectionStatus.CONNECTING; + isConnected = RongIMLib.Bridge._client.channel.connectionStatus == RongIMLib.ConnectionStatus.CONNECTED; + } + if (isConnected || isConnecting) { + return true; + } + return false; + }; + if (isAlive()) { + return callback(RongIMLib.Bridge._client); + } + var connectCallback = RongIMLib.RongIMClient._memoryStore.callback || { + onTokenIncorrect: function () { + console.error('内部重连, Token Error'); + }, + onError: function (code) { + console.error('内部重连失败,错误码: %d', code); + } + }; + // 连接不可用,进行重连 + RongIMClient.reconnect({ + onSuccess: function () { + RongIMLib.Bridge._client.channel.connectionStatus = RongIMLib.ConnectionStatus.CONNECTED; + callback(RongIMLib.Bridge._client); + }, + onTokenIncorrect: connectCallback.onTokenIncorrect, + onError: connectCallback.onError + }); + }; + + /** + var config = { + appkey: appkey, + token: token, + dataAccessProvider:dataAccessProvider, + opts: opts + }; + callback(_instance, userId); + */ + RongIMClient.initApp = function (config, callback) { + RongIMClient.init(config.appkey, config.dataAccessProvider, config.opts); + RongIMClient.connect(config.token, { + onSuccess: function (userId) { + callback(RongIMClient._instance, userId); + }, + onTokenIncorrect: function () { + throw new Error('token expired'); + }, + onError: function (errorCode) {} + }); + }; + RongIMClient.reconnect = function (callback) { + RongIMClient._dataAccessProvider.reconnect(callback); + }; + /** + * 注册消息类型,用于注册用户自定义的消息。 + * 内建的消息类型已经注册过,不需要再次注册。 + * 自定义消息声明需放在执行顺序最高的位置(在RongIMClient.init(appkey)之后即可) + * @param objectName 消息内置名称 + */ + RongIMClient.registerMessageType = function (messageType, objectName, messageTag, messageContent) { + RongIMClient._dataAccessProvider.registerMessageType(messageType, objectName, messageTag, messageContent); + RongIMClient.RegisterMessage[messageType].messageName = messageType; + RongIMClient.MessageType[messageType] = messageType; + RongIMClient.MessageParams[messageType] = { + objectName: objectName, + msgTag: messageTag + }; + }; + /** + * 设置连接状态变化的监听器。 + * + * @param listener 连接状态变化的监听器。 + */ + RongIMClient.setConnectionStatusListener = function (listener) { + if (RongIMClient._dataAccessProvider) { + RongIMClient._dataAccessProvider.setConnectionStatusListener(listener); + } else { + RongIMClient._memoryStore.listenerList.push(listener); + } + }; + /** + * 设置接收消息的监听器。 + * + * @param listener 接收消息的监听器。 + */ + RongIMClient.setOnReceiveMessageListener = function (listener) { + if (RongIMClient._dataAccessProvider) { + RongIMClient._dataAccessProvider.setOnReceiveMessageListener(listener); + } else { + RongIMClient._memoryStore.listenerList.push(listener); + } + }; + /** + * 清理所有连接相关的变量 + */ + RongIMClient.prototype.logout = function () { + this.clearCache(); + RongIMClient._dataAccessProvider.logout(); + }; + /** + * 断开连接。 + */ + RongIMClient.prototype.disconnect = function () { + RongIMClient._dataAccessProvider.disconnect(); + }; + RongIMClient.prototype.startCustomService = function (custId, callback, groupId) { + if (!custId || !callback) return; + var msg; + if (typeof groupId == 'undefined') { + msg = new RongIMLib.HandShakeMessage(); + } else { + msg = new RongIMLib.HandShakeMessage({ + groupid: groupId + }); + } + var me = this; + RongIMLib.RongIMClient._memoryStore.custStore["isInit"] = true; + RongIMClient.getInstance().sendMessage(RongIMLib.ConversationType.CUSTOMER_SERVICE, custId, msg, { + onSuccess: function (data) { + if (data.isBlack) { + callback.onError(); + me.stopCustomeService(custId, { + onSuccess: function () {}, + onError: function () {} + }); + } else { + callback.onSuccess(); + } + }, + onError: function () { + callback.onError(); + }, + onBefore: function () {} + }); + }; + RongIMClient.prototype.stopCustomeService = function (custId, callback) { + if (!custId || !callback) return; + var session = RongIMClient._memoryStore.custStore[custId]; + if (!session) return; + var msg = new RongIMLib.SuspendMessage({ + sid: session.sid, + uid: session.uid, + pid: session.pid + }); + this.sendCustMessage(custId, msg, { + onSuccess: function () { + // delete RongIMClient._memoryStore.custStore[custId]; + setTimeout(function () { + callback.onSuccess(); + }); + }, + onError: function () { + setTimeout(function () { + callback.onError(); + }); + } + }); + }; + RongIMClient.prototype.switchToHumanMode = function (custId, callback) { + if (!custId || !callback) return; + var session = RongIMClient._memoryStore.custStore[custId]; + if (!session) return; + var msg = new RongIMLib.ChangeModeMessage({ + sid: session.sid, + uid: session.uid, + pid: session.pid + }); + this.sendCustMessage(custId, msg, callback); + }; + RongIMClient.prototype.evaluateRebotCustomService = function (custId, isRobotResolved, sugest, callback) { + if (!custId || !callback) return; + var session = RongIMClient._memoryStore.custStore[custId]; + if (!session) return; + var msg = new RongIMLib.EvaluateMessage({ + sid: session.sid, + uid: session.uid, + pid: session.pid, + isRobotResolved: isRobotResolved, + sugest: sugest, + type: 0 + }); + this.sendCustMessage(custId, msg, callback); + }; + RongIMClient.prototype.evaluateHumanCustomService = function (custId, humanValue, sugest, callback) { + if (!custId || !callback) return; + var session = RongIMClient._memoryStore.custStore[custId]; + if (!session) return; + var msg = new RongIMLib.EvaluateMessage({ + sid: session.sid, + uid: session.uid, + pid: session.pid, + humanValue: humanValue, + sugest: sugest, + type: 1 + }); + this.sendCustMessage(custId, msg, callback); + }; + RongIMClient.prototype.sendCustMessage = function (custId, msg, callback) { + RongIMClient.getInstance().sendMessage(RongIMLib.ConversationType.CUSTOMER_SERVICE, custId, msg, { + onSuccess: function (data) { + callback.onSuccess(); + }, + onError: function () { + callback.onError(); + }, + onBefore: function () {} + }); + }; + /** + * 获取当前连接的状态。 + */ + RongIMClient.prototype.getCurrentConnectionStatus = function () { + return RongIMLib.Bridge._client.channel.connectionStatus; + }; + /** + * 获取当前使用的连接通道。 + */ + RongIMClient.prototype.getConnectionChannel = function () { + if (RongIMLib.Transportations._TransportType == RongIMLib.Socket.XHR_POLLING) { + return RongIMLib.ConnectionChannel.XHR_POLLING; + } else if (RongIMLib.Transportations._TransportType == RongIMLib.Socket.WEBSOCKET) { + return RongIMLib.ConnectionChannel.WEBSOCKET; + } + }; + /** + * 获取当前使用的本地储存提供者。 TODO + */ + RongIMClient.prototype.getStorageProvider = function () { + if (RongIMClient._memoryStore.providerType == 1) { + return "ServerDataProvider"; + } else { + return "OtherDataProvider"; + } + }; + /** + * 过滤聊天室消息(拉取最近聊天消息) + * @param {string[]} msgFilterNames + */ + RongIMClient.prototype.setFilterMessages = function (msgFilterNames) { + if (Object.prototype.toString.call(msgFilterNames) == "[object Array]") { + RongIMClient._memoryStore.filterMessages = msgFilterNames; + } + }; + RongIMClient.prototype.getAgoraDynamicKey = function (engineType, channelName, callback) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "object"], "getAgoraDynamicKey", false, arguments); + var modules = new Modules.VoipDynamicInput(); + modules.setEngineType(engineType); + modules.setChannelName(channelName); + RongIMClient.bridge.queryMsg(32, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, callback, "VoipDynamicOutput"); + }; + /** + * 获取当前连接用户的 UserId。 + */ + RongIMClient.prototype.getCurrentUserId = function () { + return RongIMLib.Bridge._client.userId; + }; + /** + * [getCurrentUserInfo 获取当前用户信息] + * @param {ResultCallback} callback [回调函数] + */ + // getCurrentUserInfo(callback: ResultCallback) { + // CheckParam.getInstance().check(["object"], "getCurrentUserInfo"); + // this.getUserInfo(Bridge._client.userId, callback); + // } + /** + * 获得用户信息 + * @param {string} userId [用户Id] + * @param {ResultCallback} callback [回调函数] + */ + // getUserInfo(userId: string, callback: ResultCallback) { + // CheckParam.getInstance().check(["string", "object"], "getUserInfo"); + // var user = new Modules.GetUserInfoInput(); + // user.setNothing(1); + // RongIMClient.bridge.queryMsg(5, MessageUtil.ArrayForm(user.toArrayBuffer()), userId, { + // onSuccess: function(info: any) { + // var userInfo = new UserInfo(info.userId, info.name, info.portraitUri); + // callback.onSuccess(userInfo); + // }, + // onError: function(err: any) { + // callback.onError(err); + // } + // }, "GetUserInfoOutput"); + // } + /** + * 获取服务器时间与本地时间的差值,单位为毫秒。 + * 计算公式:差值 = 本地时间毫秒数 - 服务器时间毫秒数 + * @param callback 获取的回调,返回差值。 + */ + RongIMClient.prototype.getDeltaTime = function () { + return RongIMClient._dataAccessProvider.getDelaTime(); + }; + // #region Message + RongIMClient.prototype.getMessage = function (messageId, callback) { + RongIMClient._dataAccessProvider.getMessage(messageId, callback); + }; + RongIMClient.prototype.deleteLocalMessages = function (conversationType, targetId, messageIds, callback) { + RongIMClient._dataAccessProvider.removeLocalMessage(conversationType, targetId, messageIds, callback); + }; + RongIMClient.prototype.updateMessage = function (message, callback) { + RongIMClient._dataAccessProvider.updateMessage(message, callback); + }; + RongIMClient.prototype.clearMessages = function (conversationType, targetId, callback) { + RongIMClient._dataAccessProvider.clearMessages(conversationType, targetId, { + onSuccess: function (bool) { + setTimeout(function () { + callback.onSuccess(bool); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + /**TODO 清楚本地存储的未读消息,目前清空内存中的未读消息 + * [clearMessagesUnreadStatus 清空指定会话未读消息] + * @param {ConversationType} conversationType [会话类型] + * @param {string} targetId [用户id] + * @param {ResultCallback} callback [返回值,参数回调] + */ + RongIMClient.prototype.clearMessagesUnreadStatus = function (conversationType, targetId, callback) { + RongIMClient._dataAccessProvider.updateMessages(conversationType, targetId, "readStatus", null, { + onSuccess: function (bool) { + setTimeout(function () { + callback.onSuccess(bool); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + RongIMClient.prototype.deleteRemoteMessages = function (conversationType, targetId, delMsgs, callback) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "array", "object"], "deleteRemoteMessages", false, arguments); + if (delMsgs.length == 0) { + callback.onError(RongIMLib.ErrorCode.DELETE_MESSAGE_ID_IS_NULL); + return; + } else if (delMsgs.length > 100) { + delMsgs.length = 100; + } + // 后续增加,去掉注释即可 + callback.onSuccess(true); + // var modules = new Modules.DeleteMsgInput(); + // modules.setType(conversationType); + // modules.setConversationId(targetId); + // modules.setMsgs(delMsgs); + // RongIMClient.bridge.queryMsg(33, MessageUtil.ArrayForm(modules.toArrayBuffer()), Bridge._client.userId, { + // onSuccess: function(info: any) { + // callback.onSuccess(true); + // }, + // onError: function(err: any) { + // callback.onError(err); + // } + // }, "DeleteMsgOutput"); + }; + /** + * [deleteMessages 删除消息记录。] + * @param {ConversationType} conversationType [description] + * @param {string} targetId [description] + * @param {number[]} messageIds [description] + * @param {ResultCallback} callback [description] + */ + RongIMClient.prototype.deleteMessages = function (conversationType, targetId, delMsgs, callback) { + RongIMClient._dataAccessProvider.removeMessage(conversationType, targetId, delMsgs, { + onSuccess: function (bool) { + setTimeout(function () { + callback.onSuccess(bool); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + RongIMClient.prototype.sendLocalMessage = function (message, callback) { + RongIMLib.CheckParam.getInstance().check(["object", "object"], "sendLocalMessage", false, arguments); + RongIMClient._dataAccessProvider.updateMessage(message); + this.sendMessage(message.conversationType, message.targetId, message.content, callback); + }; + /** + * [sendMessage 发送消息。] + * @param {ConversationType} conversationType [会话类型] + * @param {string} targetId [目标Id] + * @param {MessageContent} messageContent [消息类型] + * @param {SendMessageCallback} sendCallback [] + * @param {ResultCallback} resultCallback [返回值,函数回调] + * @param {string} pushContent [] + * @param {string} pushData [] + */ + RongIMClient.prototype.sendMessage = function (conversationType, targetId, messageContent, sendCallback, mentiondMsg, pushText, appData, methodType) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "object", "object", "undefined|object|null|global|boolean", "undefined|object|null|global|string", "undefined|object|null|global|string", "undefined|object|null|global|number"], "sendMessage", false, arguments); + RongIMClient._dataAccessProvider.sendMessage(conversationType, targetId, messageContent, sendCallback, mentiondMsg, pushText, appData, methodType); + }; + RongIMClient.prototype.sendReceiptResponse = function (conversationType, targetId, sendCallback) { + RongIMClient._dataAccessProvider.sendReceiptResponse(conversationType, targetId, sendCallback); + }; + RongIMClient.prototype.sendTypingStatusMessage = function (conversationType, targetId, messageName, sendCallback) { + RongIMClient._dataAccessProvider.sendTypingStatusMessage(conversationType, targetId, messageName, sendCallback); + }; + /** + * [sendStatusMessage description] + * @param {MessageContent} messageContent [description] + * @param {SendMessageCallback} sendCallback [description] + * @param {ResultCallback} resultCallback [description] + */ + RongIMClient.prototype.sendStatusMessage = function (messageContent, sendCallback, resultCallback) { + throw new Error("Not implemented yet"); + }; + /** + * [sendTextMessage 发送TextMessage快捷方式] + * @param {string} content [消息内容] + * @param {ResultCallback} resultCallback [返回值,参数回调] + */ + RongIMClient.prototype.sendTextMessage = function (conversationType, targetId, content, sendMessageCallback) { + RongIMClient._dataAccessProvider.sendTextMessage(conversationType, targetId, content, sendMessageCallback); + }; + RongIMClient.prototype.sendRecallMessage = function (content, sendMessageCallback) { + RongIMClient._dataAccessProvider.sendRecallMessage(content, sendMessageCallback); + }; + /** + * [insertMessage 向本地插入一条消息,不发送到服务器。] + * @param {ConversationType} conversationType [description] + * @param {string} targetId [description] + * @param {string} senderUserId [description] + * @param {MessageContent} content [description] + * @param {ResultCallback} callback [description] + */ + RongIMClient.prototype.insertMessage = function (conversationType, targetId, senderUserId, content, callback) { + RongIMClient._dataAccessProvider.addMessage(conversationType, targetId, content, callback); + }; + /** + * [getHistoryMessages 拉取历史消息记录。] + * @param {ConversationType} conversationType [会话类型] + * @param {string} targetId [用户Id] + * @param {number|null} pullMessageTime [拉取历史消息起始位置(格式为毫秒数),可以为null] + * @param {number} count [历史消息数量] + * @param {ResultCallback} callback [回调函数] + * @param {string} objectName [objectName] + */ + RongIMClient.prototype.getHistoryMessages = function (conversationType, targetId, timestamp, count, callback, objectname, direction) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "number|null|global|object", "number", "object", "undefined|object|null|global|string", "boolean|null|global|object"], "getHistoryMessages", false, arguments); + if (count > 20) { + throw new Error("HistroyMessage count must be less than or equal to 20!"); + } + if (conversationType.valueOf() < 0) { + throw new Error("ConversationType must be greater than -1"); + } + RongIMClient._dataAccessProvider.getHistoryMessages(conversationType, targetId, timestamp, count, callback, objectname, direction); + }; + RongIMClient.prototype.setMessageContent = function (messageId, content, objectName) { + RongIMClient._dataAccessProvider.setMessageContent(messageId, content, objectName); + }; + ; + /** + * [getRemoteHistoryMessages 拉取某个时间戳之前的消息] + * @param {ConversationType} conversationType [description] + * @param {string} targetId [description] + * @param {Date} dateTime [description] + * @param {number} count [description] + * @param {ResultCallback} callback [description] + */ + RongIMClient.prototype.getRemoteHistoryMessages = function (conversationType, targetId, timestamp, count, callback) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "number|null|global|object", "number", "object"], "getRemoteHistoryMessages", false, arguments); + if (count > 20) { + callback.onError(RongIMLib.ErrorCode.RC_CONN_PROTO_VERSION_ERROR); + return; + } + if (conversationType.valueOf() < 0) { + callback.onError(RongIMLib.ErrorCode.RC_CONN_PROTO_VERSION_ERROR); + return; + } + RongIMClient._dataAccessProvider.getRemoteHistoryMessages(conversationType, targetId, timestamp, count, callback); + }; + /** + * [hasRemoteUnreadMessages 是否有未接收的消息,jsonp方法] + * @param {string} appkey [appkey] + * @param {string} token [token] + * @param {ConnectCallback} callback [返回值,参数回调] + */ + RongIMClient.prototype.hasRemoteUnreadMessages = function (token, callback) { + RongIMClient._dataAccessProvider.hasRemoteUnreadMessages(token, callback); + }; + RongIMClient.prototype.getTotalUnreadCount = function (callback, conversationTypes) { + RongIMClient._dataAccessProvider.getTotalUnreadCount({ + onSuccess: function (count) { + setTimeout(function () { + callback.onSuccess(count); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }, conversationTypes); + }; + /** + * [getConversationUnreadCount 指定多种会话类型获取未读消息数] + * @param {ResultCallback} callback [返回值,参数回调。] + * @param {ConversationType[]} ...conversationTypes [会话类型。] + */ + RongIMClient.prototype.getConversationUnreadCount = function (conversationTypes, callback) { + RongIMClient._dataAccessProvider.getConversationUnreadCount(conversationTypes, { + onSuccess: function (count) { + setTimeout(function () { + callback.onSuccess(count); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + /** + * [getUnreadCount 指定用户、会话类型的未读消息总数。] + * @param {ConversationType} conversationType [会话类型] + * @param {string} targetId [用户Id] + */ + RongIMClient.prototype.getUnreadCount = function (conversationType, targetId, callback) { + RongIMClient._dataAccessProvider.getUnreadCount(conversationType, targetId, { + onSuccess: function (count) { + setTimeout(function () { + callback.onSuccess(count); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + RongIMClient.prototype.clearUnreadCountByTimestamp = function (conversationType, targetId, timestamp, callback) { + RongIMClient._dataAccessProvider.clearUnreadCountByTimestamp(conversationType, targetId, timestamp, callback); + }; + /** + * 清楚会话未读消息数 + * @param {ConversationType} conversationType 会话类型 + * @param {string} targetId 目标Id + * @param {ResultCallback} callback 返回值,函数回调 + */ + RongIMClient.prototype.clearUnreadCount = function (conversationType, targetId, callback) { + RongIMClient._dataAccessProvider.clearUnreadCount(conversationType, targetId, { + onSuccess: function (bool) { + setTimeout(function () { + callback.onSuccess(bool); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + RongIMClient.prototype.clearTotalUnreadCount = function (callback) { + RongIMClient._dataAccessProvider.clearTotalUnreadCount({ + onSuccess: function (bool) { + setTimeout(function () { + callback.onSuccess(bool); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + RongIMClient.prototype.clearLocalStorage = function (callback) { + RongIMClient._storageProvider.clearItem(); + callback(); + }; + RongIMClient.prototype.setMessageExtra = function (messageId, value, callback) { + RongIMClient._dataAccessProvider.setMessageExtra(messageId, value, { + onSuccess: function (bool) { + setTimeout(function () { + callback.onSuccess(bool); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + RongIMClient.prototype.setMessageReceivedStatus = function (messageUId, receivedStatus, callback) { + RongIMClient._dataAccessProvider.setMessageReceivedStatus(messageUId, receivedStatus, { + onSuccess: function (bool) { + setTimeout(function () { + callback.onSuccess(bool); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + RongIMClient.prototype.setMessageStatus = function (conersationType, targetId, timestamp, status, callback) { + RongIMClient._dataAccessProvider.setMessageStatus(conersationType, targetId, timestamp, status, callback); + }; + RongIMClient.prototype.setMessageSentStatus = function (messageId, sentStatus, callback) { + RongIMClient._dataAccessProvider.setMessageSentStatus(messageId, sentStatus, { + onSuccess: function (bool) { + setTimeout(function () { + callback.onSuccess(bool); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + // #endregion Message + // #region TextMessage Draft + /** + * clearTextMessageDraft 清除指定会话和消息类型的草稿。 + * @param {ConversationType} conversationType 会话类型 + * @param {string} targetId 目标Id + */ + RongIMClient.prototype.clearTextMessageDraft = function (conversationType, targetId) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "object"], "clearTextMessageDraft", false, arguments); + var key = "darf_" + conversationType + "_" + targetId; + delete RongIMClient._memoryStore[key]; + return true; + }; + /** + * [getTextMessageDraft 获取指定消息和会话的草稿。] + * @param {ConversationType} conversationType [会话类型] + * @param {string} targetId [目标Id] + */ + RongIMClient.prototype.getTextMessageDraft = function (conversationType, targetId) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "object"], "getTextMessageDraft", false, arguments); + if (targetId == "" || conversationType < 0) { + throw new Error("params error : " + RongIMLib.ErrorCode.DRAF_GET_ERROR); + } + var key = "darf_" + conversationType + "_" + targetId; + return RongIMClient._memoryStore[key]; + }; + /** + * [saveTextMessageDraft description] + * @param {ConversationType} conversationType [会话类型] + * @param {string} targetId [目标Id] + * @param {string} value [草稿值] + */ + RongIMClient.prototype.saveTextMessageDraft = function (conversationType, targetId, value) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "string", "object"], "saveTextMessageDraft", false, arguments); + var key = "darf_" + conversationType + "_" + targetId; + RongIMClient._memoryStore[key] = value; + return true; + }; + // #endregion TextMessage Draft + // #region Conversation + RongIMClient.prototype.searchConversationByContent = function (keyword, callback, conversationTypes) { + RongIMClient._dataAccessProvider.searchConversationByContent(keyword, callback, conversationTypes); + }; + RongIMClient.prototype.searchMessageByContent = function (conversationType, targetId, keyword, timestamp, count, total, callback) { + RongIMClient._dataAccessProvider.searchMessageByContent(conversationType, targetId, keyword, timestamp, count, total, callback); + }; + RongIMClient.prototype.clearCache = function () { + RongIMClient._dataAccessProvider.clearCache(); + }; + RongIMClient.prototype.clearConversations = function (callback) { + var conversationTypes = []; + for (var _i = 1; _i < arguments.length; _i++) { + conversationTypes[_i - 1] = arguments[_i]; + } + if (conversationTypes.length == 0) { + conversationTypes = [RongIMLib.ConversationType.CHATROOM, RongIMLib.ConversationType.CUSTOMER_SERVICE, RongIMLib.ConversationType.DISCUSSION, RongIMLib.ConversationType.GROUP, RongIMLib.ConversationType.PRIVATE, RongIMLib.ConversationType.SYSTEM, RongIMLib.ConversationType.PUBLIC_SERVICE, RongIMLib.ConversationType.APP_PUBLIC_SERVICE]; + } + RongIMClient._dataAccessProvider.clearConversations(conversationTypes, { + onSuccess: function (bool) { + setTimeout(function () { + callback.onSuccess(bool); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + /** + * [getConversation 获取指定会话,此方法需在getConversationList之后执行] + * @param {ConversationType} conversationType [会话类型] + * @param {string} targetId [目标Id] + * @param {ResultCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.getConversation = function (conversationType, targetId, callback) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "object"], "getConversation", false, arguments); + RongIMClient._dataAccessProvider.getConversation(conversationType, targetId, { + onSuccess: function (conver) { + setTimeout(function () { + callback.onSuccess(conver); + }); + }, + onError: function (error) { + setTimeout(function () { + callback.onError(error); + }); + } + }); + }; + /** + * [pottingConversation 组装会话列表] + * @param {any} tempConver [临时会话] + * conver_conversationType_targetId_no. + * msg_conversationType_targetId_no. + */ + RongIMClient.prototype.pottingConversation = function (tempConver) { + var self = this, + isUseReplace = false; + RongIMClient._dataAccessProvider.getConversation(tempConver.type, tempConver.userId, { + onSuccess: function (conver) { + if (!conver) { + conver = new RongIMLib.Conversation(); + } else { + isUseReplace = true; + } + conver.conversationType = tempConver.type; + conver.targetId = tempConver.userId; + conver.latestMessage = RongIMLib.MessageUtil.messageParser(tempConver.msg); + conver.latestMessageId = conver.latestMessage.messageId; + conver.objectName = conver.latestMessage.objectName; + conver.receivedStatus = conver.latestMessage.receivedStatus; + conver.receivedTime = conver.latestMessage.receiveTime; + conver.sentStatus = conver.latestMessage.sentStatus; + conver.sentTime = conver.latestMessage.sentTime; + var mentioneds = RongIMClient._storageProvider.getItem("mentioneds_" + RongIMLib.Bridge._client.userId + '_' + conver.conversationType + '_' + conver.targetId); + if (mentioneds) { + var info = JSON.parse(mentioneds); + conver.mentionedMsg = info[tempConver.type + "_" + tempConver.userId]; + } + if (!isUseReplace) { + if (RongIMLib.MessageUtil.supportLargeStorage()) { + var count = RongIMClient._storageProvider.getItem("cu" + RongIMLib.Bridge._client.userId + tempConver.type + tempConver.userId); + conver.unreadMessageCount = Number(count); + } else { + conver.unreadMessageCount = 0; + } + } + // if (conver.conversationType == ConversationType.PRIVATE) { + // self.getUserInfo(tempConver.userId, >{ + // onSuccess: function(info: UserInfo) { + // conver.conversationTitle = info.name; + // conver.senderUserName = info.name; + // conver.senderUserId = info.userId; + // conver.senderPortraitUri = info.portraitUri; + // }, + // onError: function(error: ErrorCode) { } + // }); + // } else + if (conver.conversationType == RongIMLib.ConversationType.DISCUSSION) { + self.getDiscussion(tempConver.userId, { + onSuccess: function (info) { + conver.conversationTitle = info.name; + }, + onError: function (error) {} + }); + } + RongIMClient._dataAccessProvider.addConversation(conver, { + onSuccess: function (data) {} + }); + }, + onError: function (error) {} + }); + }; + RongIMClient.prototype.sortConversationList = function (conversationList) { + var convers = []; + for (var i = 0, len = conversationList.length; i < len; i++) { + if (!conversationList[i]) { + continue; + } + if (conversationList[i].isTop) { + convers.push(conversationList[i]); + conversationList.splice(i, 1); + continue; + } + for (var j = 0; j < len - i - 1; j++) { + if (conversationList[j].sentTime < conversationList[j + 1].sentTime) { + var swap = conversationList[j]; + conversationList[j] = conversationList[j + 1]; + conversationList[j + 1] = swap; + } + } + } + return RongIMClient._memoryStore.conversationList = convers.concat(conversationList); + }; + RongIMClient.prototype.getConversationList = function (callback, conversationTypes, count, isGetHiddenConvers) { + RongIMLib.CheckParam.getInstance().check(["object", "null|array|object|global", "number|undefined|null|object|global", "boolean|undefined|null|object|global"], "getConversationList", false, arguments); + var me = this; + RongIMClient._dataAccessProvider.getConversationList({ + onSuccess: function (data) { + if (conversationTypes || RongIMClient._dataAccessProvider) { + setTimeout(function () { + callback.onSuccess(data); + }); + } else { + setTimeout(function () { + callback.onSuccess(RongIMClient._memoryStore.conversationList); + }); + } + }, + onError: function (error) { + if (error === RongIMLib.ErrorCode.TIMEOUT) { + callback.onError(error); + } else { + callback.onSuccess([]); + } + } + }, conversationTypes, count, isGetHiddenConvers); + }; + RongIMClient.prototype.getRemoteConversationList = function (callback, conversationTypes, count, isGetHiddenConvers) { + RongIMLib.CheckParam.getInstance().check(["object", "null|array|object|global", "number|undefined|null|object|global", "boolean|undefined|null|object|global"], "getRemoteConversationList", false, arguments); + RongIMClient._dataAccessProvider.getRemoteConversationList(callback, conversationTypes, count, isGetHiddenConvers); + }; + RongIMClient.prototype.updateConversation = function (conversation) { + return RongIMClient._dataAccessProvider.updateConversation(conversation); + }; + /** + * [createConversation 创建会话。] + * @param {number} conversationType [会话类型] + * @param {string} targetId [目标Id] + * @param {string} converTitle [会话标题] + * @param {boolean} islocal [是否同步到服务器,ture:同步,false:不同步] + */ + RongIMClient.prototype.createConversation = function (conversationType, targetId, converTitle) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "string"], "createConversation", false, arguments); + var conver = new RongIMLib.Conversation(); + conver.targetId = targetId; + conver.conversationType = conversationType; + conver.conversationTitle = converTitle; + conver.latestMessage = {}; + conver.unreadMessageCount = 0; + return conver; + }; + //TODO 删除本地和服务器、删除本地和服务器分开 + RongIMClient.prototype.removeConversation = function (conversationType, targetId, callback) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "object"], "removeConversation", false, arguments); + RongIMClient._dataAccessProvider.removeConversation(conversationType, targetId, callback); + }; + RongIMClient.prototype.setConversationHidden = function (conversationType, targetId, isHidden) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "boolean"], "setConversationHidden", false, arguments); + RongIMClient._dataAccessProvider.setConversationHidden(conversationType, targetId, isHidden); + }; + RongIMClient.prototype.setConversationToTop = function (conversationType, targetId, isTop, callback) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "boolean", "object"], "setConversationToTop", false, arguments); + RongIMClient._dataAccessProvider.setConversationToTop(conversationType, targetId, isTop, { + onSuccess: function (bool) { + setTimeout(function () { + callback.onSuccess(bool); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }); + }; + // #endregion Conversation + // #region Notifications + /** + * [getConversationNotificationStatus 获取指定用户和会话类型免提醒。] + * @param {ConversationType} conversationType [会话类型] + * @param {string} targetId [目标Id] + * @param {ResultCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.getConversationNotificationStatus = function (conversationType, targetId, callback) { + throw new Error("Not implemented yet"); + }; + /** + * [setConversationNotificationStatus 设置指定用户和会话类型免提醒。] + * @param {ConversationType} conversationType [会话类型] + * @param {string} targetId [目标Id] + * @param {ResultCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.setConversationNotificationStatus = function (conversationType, targetId, notificationStatus, callback) { + throw new Error("Not implemented yet"); + }; + /** + * [getNotificationQuietHours 获取免提醒消息时间。] + * @param {GetNotificationQuietHoursCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.getNotificationQuietHours = function (callback) { + throw new Error("Not implemented yet"); + }; + /** + * [removeNotificationQuietHours 移除免提醒消息时间。] + * @param {GetNotificationQuietHoursCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.removeNotificationQuietHours = function (callback) { + throw new Error("Not implemented yet"); + }; + /** + * [setNotificationQuietHours 设置免提醒消息时间。] + * @param {GetNotificationQuietHoursCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.setNotificationQuietHours = function (startTime, spanMinutes, callback) { + throw new Error("Not implemented yet"); + }; + // #endregion Notifications + // #region Discussion + /** + * [addMemberToDiscussion 加入讨论组] + * @param {string} discussionId [讨论组Id] + * @param {string[]} userIdList [讨论中成员] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.addMemberToDiscussion = function (discussionId, userIdList, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "array", "object"], "addMemberToDiscussion", false, arguments); + RongIMClient._dataAccessProvider.addMemberToDiscussion(discussionId, userIdList, callback); + }; + /** + * [createDiscussion 创建讨论组] + * @param {string} name [讨论组名称] + * @param {string[]} userIdList [讨论组成员] + * @param {CreateDiscussionCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.createDiscussion = function (name, userIdList, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "array", "object"], "createDiscussion", false, arguments); + RongIMClient._dataAccessProvider.createDiscussion(name, userIdList, callback); + }; + /** + * [getDiscussion 获取讨论组信息] + * @param {string} discussionId [讨论组Id] + * @param {ResultCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.getDiscussion = function (discussionId, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "object"], "getDiscussion", false, arguments); + RongIMClient._dataAccessProvider.getDiscussion(discussionId, callback); + }; + /** + * [quitDiscussion 退出讨论组] + * @param {string} discussionId [讨论组Id] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.quitDiscussion = function (discussionId, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "object"], "quitDiscussion", false, arguments); + RongIMClient._dataAccessProvider.quitDiscussion(discussionId, callback); + }; + /** + * [removeMemberFromDiscussion 将指定成员移除讨论租] + * @param {string} discussionId [讨论组Id] + * @param {string} userId [被移除的用户Id] + * @param {OperationCallback} callback [返回值,参数回调] + */ + RongIMClient.prototype.removeMemberFromDiscussion = function (discussionId, userId, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "string", "object"], "removeMemberFromDiscussion", false, arguments); + RongIMClient._dataAccessProvider.removeMemberFromDiscussion(discussionId, userId, callback); + }; + /** + * [setDiscussionInviteStatus 设置讨论组邀请状态] + * @param {string} discussionId [讨论组Id] + * @param {DiscussionInviteStatus} status [邀请状态] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.setDiscussionInviteStatus = function (discussionId, status, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "number", "object"], "setDiscussionInviteStatus", false, arguments); + RongIMClient._dataAccessProvider.setDiscussionInviteStatus(discussionId, status, callback); + }; + /** + * [setDiscussionName 设置讨论组名称] + * @param {string} discussionId [讨论组Id] + * @param {string} name [讨论组名称] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.setDiscussionName = function (discussionId, name, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "string", "object"], "setDiscussionName", false, arguments); + RongIMClient._dataAccessProvider.setDiscussionName(discussionId, name, callback); + }; + // #endregion Discussion + // #region Group + /** + * [加入群组] + * @param {string} groupId [群组Id] + * @param {string} groupName [群组名称] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.joinGroup = function (groupId, groupName, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "string", "object"], "joinGroup", false, arguments); + RongIMClient._dataAccessProvider.joinGroup(groupId, groupName, callback); + }; + /** + * [退出群组] + * @param {string} groupId [群组Id] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.quitGroup = function (groupId, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "object"], "quitGroup", false, arguments); + RongIMClient._dataAccessProvider.quitGroup(groupId, callback); + }; + /** + * [同步群组信息] + * @param {Array} groups [群组列表] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.syncGroup = function (groups, callback) { + RongIMLib.CheckParam.getInstance().check(["array", "object"], "syncGroup", false, arguments); + RongIMClient._dataAccessProvider.syncGroup(groups, callback); + }; + // #endregion Group + // #region ChatRoom + /** + * [加入聊天室。] + * @param {string} chatroomId [聊天室Id] + * @param {number} messageCount [拉取消息数量,-1为不拉去消息] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.joinChatRoom = function (chatroomId, messageCount, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "number", "object"], "joinChatRoom", false, arguments); + if (chatroomId == "") { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.CHATROOM_ID_ISNULL); + }); + return; + } + RongIMClient._dataAccessProvider.joinChatRoom(chatroomId, messageCount, callback); + }; + RongIMClient.prototype.setChatroomHisMessageTimestamp = function (chatRoomId, timestamp) { + RongIMLib.CheckParam.getInstance().check(["string", "number"], "setChatroomHisMessageTimestamp", false, arguments); + RongIMClient._dataAccessProvider.setChatroomHisMessageTimestamp(chatRoomId, timestamp); + }; + RongIMClient.prototype.getChatRoomHistoryMessages = function (chatRoomId, count, order, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "number", "number", "object"], "getChatRoomHistoryMessages", false, arguments); + RongIMClient._dataAccessProvider.getChatRoomHistoryMessages(chatRoomId, count, order, callback); + }; + RongIMClient.prototype.getChatRoomInfo = function (chatRoomId, count, order, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "number", "number", "object"], "getChatRoomInfo", false, arguments); + RongIMClient._dataAccessProvider.getChatRoomInfo(chatRoomId, count, order, callback); + }; + /** + * [退出聊天室] + * @param {string} chatroomId [聊天室Id] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.quitChatRoom = function (chatroomId, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "object"], "quitChatRoom", false, arguments); + RongIMClient._dataAccessProvider.quitChatRoom(chatroomId, callback); + }; + // #endregion ChatRoom + // #region Public Service + RongIMClient.prototype.getRemotePublicServiceList = function (callback, pullMessageTime) { + if (RongIMClient._memoryStore.depend.openMp) { + var modules = new Modules.PullMpInput(), + self = this; + if (!pullMessageTime) { + modules.setTime(0); + } else { + modules.setTime(pullMessageTime); + } + modules.setMpid(""); + RongIMClient.bridge.queryMsg(28, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, { + onSuccess: function (data) { + //TODO 找出最大时间 + // self.lastReadTime.set(conversationType + targetId, MessageUtil.int64ToTimestamp(data.syncTime)); + RongIMClient._memoryStore.publicServiceMap.publicServiceList.length = 0; + RongIMClient._memoryStore.publicServiceMap.publicServiceList = data; + callback.onSuccess(data); + }, + onError: function () {} + }, "PullMpOutput"); + } + }; + /** + * [getPublicServiceList ]获取本地的公共账号列表 + * @param {ResultCallback} callback [返回值,参数回调] + */ + RongIMClient.prototype.getPublicServiceList = function (callback) { + if (RongIMClient._memoryStore.depend.openMp) { + RongIMLib.CheckParam.getInstance().check(["object"], "getPublicServiceList", false, arguments); + this.getRemotePublicServiceList(callback); + } + }; + /** + * [getPublicServiceProfile ] 获取某公共服务信息。 + * @param {PublicServiceType} publicServiceType [公众服务类型。] + * @param {string} publicServiceId [公共服务 Id。] + * @param {ResultCallback} callback [公共账号信息回调。] + */ + RongIMClient.prototype.getPublicServiceProfile = function (publicServiceType, publicServiceId, callback) { + if (RongIMClient._memoryStore.depend.openMp) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "object"], "getPublicServiceProfile", false, arguments); + var profile = RongIMClient._memoryStore.publicServiceMap.get(publicServiceType, publicServiceId); + callback.onSuccess(profile); + } + }; + /** + * [pottingPublicSearchType ] 公众好查询类型 + * @param {number} bussinessType [ 0-all 1-mp 2-mc] + * @param {number} searchType [0-exact 1-fuzzy] + */ + RongIMClient.prototype.pottingPublicSearchType = function (bussinessType, searchType) { + if (RongIMClient._memoryStore.depend.openMp) { + var bits = 0; + if (bussinessType == 0) { + bits |= 3; + if (searchType == 0) { + bits |= 12; + } else { + bits |= 48; + } + } else if (bussinessType == 1) { + bits |= 1; + if (searchType == 0) { + bits |= 8; + } else { + bits |= 32; + } + } else { + bits |= 2; + if (bussinessType == 0) { + bits |= 4; + } else { + bits |= 16; + } + } + return bits; + } + }; + /** + * [searchPublicService ]按公众服务类型搜索公众服务。 + * @param {SearchType} searchType [搜索类型枚举。] + * @param {string} keywords [搜索关键字。] + * @param {ResultCallback} callback [搜索结果回调。] + */ + RongIMClient.prototype.searchPublicService = function (searchType, keywords, callback) { + if (RongIMClient._memoryStore.depend.openMp) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "object"], "searchPublicService", false, arguments); + var modules = new Modules.SearchMpInput(); + modules.setType(this.pottingPublicSearchType(0, searchType)); + modules.setId(keywords); + RongIMClient.bridge.queryMsg(29, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, callback, "SearchMpOutput"); + } + }; + /** + * [searchPublicServiceByType ]按公众服务类型搜索公众服务。 + * @param {PublicServiceType} publicServiceType [公众服务类型。] + * @param {SearchType} searchType [搜索类型枚举。] + * @param {string} keywords [搜索关键字。] + * @param {ResultCallback} callback [搜索结果回调。] + */ + RongIMClient.prototype.searchPublicServiceByType = function (publicServiceType, searchType, keywords, callback) { + if (RongIMClient._memoryStore.depend.openMp) { + RongIMLib.CheckParam.getInstance().check(["number", "number", "string", "object"], "searchPublicServiceByType", false, arguments); + var type = publicServiceType == RongIMLib.ConversationType.APP_PUBLIC_SERVICE ? 2 : 1; + var modules = new Modules.SearchMpInput(); + modules.setType(this.pottingPublicSearchType(type, searchType)); + modules.setId(keywords); + RongIMClient.bridge.queryMsg(29, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, callback, "SearchMpOutput"); + } + }; + /** + * [subscribePublicService ] 订阅公众号。 + * @param {PublicServiceType} publicServiceType [公众服务类型。] + * @param {string} publicServiceId [公共服务 Id。] + * @param {OperationCallback} callback [订阅公众号回调。] + */ + RongIMClient.prototype.subscribePublicService = function (publicServiceType, publicServiceId, callback) { + if (RongIMClient._memoryStore.depend.openMp) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "object"], "subscribePublicService", false, arguments); + var modules = new Modules.MPFollowInput(), + me = this, + follow = publicServiceType == RongIMLib.ConversationType.APP_PUBLIC_SERVICE ? "mcFollow" : "mpFollow"; + modules.setId(publicServiceId); + RongIMClient.bridge.queryMsg(follow, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, { + onSuccess: function () { + me.getRemotePublicServiceList({ + onSuccess: function () {}, + onError: function () {} + }); + callback.onSuccess(); + }, + onError: function (code) { + callback.onError(code); + } + }, "MPFollowOutput"); + } + }; + /** + * [unsubscribePublicService ] 取消订阅公众号。 + * @param {PublicServiceType} publicServiceType [公众服务类型。] + * @param {string} publicServiceId [公共服务 Id。] + * @param {OperationCallback} callback [取消订阅公众号回调。] + */ + RongIMClient.prototype.unsubscribePublicService = function (publicServiceType, publicServiceId, callback) { + if (RongIMClient._memoryStore.depend.openMp) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "object"], "unsubscribePublicService", false, arguments); + var modules = new Modules.MPFollowInput(), + me = this, + follow = publicServiceType == RongIMLib.ConversationType.APP_PUBLIC_SERVICE ? "mcUnFollow" : "mpUnFollow"; + modules.setId(publicServiceId); + RongIMClient.bridge.queryMsg(follow, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, { + onSuccess: function () { + RongIMClient._memoryStore.publicServiceMap.remove(publicServiceType, publicServiceId); + callback.onSuccess(); + }, + onError: function (code) { + callback.onError(code); + } + }, "MPFollowOutput"); + } + }; + // #endregion Public Service + // #region Blacklist + /** + * [加入黑名单] + * @param {string} userId [将被加入黑名单的用户Id] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.addToBlacklist = function (userId, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "object"], "addToBlacklist", false, arguments); + RongIMClient._dataAccessProvider.addToBlacklist(userId, callback); + }; + /** + * [获取黑名单列表] + * @param {GetBlacklistCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.getBlacklist = function (callback) { + RongIMLib.CheckParam.getInstance().check(["object"], "getBlacklist", false, arguments); + RongIMClient._dataAccessProvider.getBlacklist(callback); + }; + /** + * [得到指定人员再黑名单中的状态] + * @param {string} userId [description] + * @param {ResultCallback} callback [返回值,函数回调] + */ + //TODO 如果人员不在黑名单中,获取状态会出现异常 + RongIMClient.prototype.getBlacklistStatus = function (userId, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "object"], "getBlacklistStatus", false, arguments); + RongIMClient._dataAccessProvider.getBlacklistStatus(userId, callback); + }; + /** + * [将指定用户移除黑名单] + * @param {string} userId [将被移除的用户Id] + * @param {OperationCallback} callback [返回值,函数回调] + */ + RongIMClient.prototype.removeFromBlacklist = function (userId, callback) { + RongIMLib.CheckParam.getInstance().check(["string", "object"], "removeFromBlacklist", false, arguments); + RongIMClient._dataAccessProvider.removeFromBlacklist(userId, callback); + }; + RongIMClient.prototype.getFileToken = function (fileType, callback) { + RongIMLib.CheckParam.getInstance().check(["number", "object"], "getQnTkn", false, arguments); + RongIMClient._dataAccessProvider.getFileToken(fileType, callback); + }; + RongIMClient.prototype.getFileUrl = function (fileType, fileName, oriName, callback) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "string|global|object|null", "object"], "getQnTkn", false, arguments); + RongIMClient._dataAccessProvider.getFileUrl(fileType, fileName, oriName, callback); + }; + ; + // #endregion Blacklist + // #region Real-time Location Service + RongIMClient.prototype.addRealTimeLocationListener = function (conversationType, targetId, listener) { + throw new Error("Not implemented yet"); + }; + RongIMClient.prototype.getRealTimeLocation = function (conversationType, targetId) { + throw new Error("Not implemented yet"); + }; + RongIMClient.prototype.getRealTimeLocationCurrentState = function (conversationType, targetId) { + throw new Error("Not implemented yet"); + }; + RongIMClient.prototype.getRealTimeLocationParticipants = function (conversationType, targetId) { + throw new Error("Not implemented yet"); + }; + RongIMClient.prototype.joinRealTimeLocation = function (conversationType, targetId) { + throw new Error("Not implemented yet"); + }; + RongIMClient.prototype.quitRealTimeLocation = function (conversationType, targetId) { + throw new Error("Not implemented yet"); + }; + RongIMClient.prototype.startRealTimeLocation = function (conversationType, targetId) { + throw new Error("Not implemented yet"); + }; + RongIMClient.prototype.updateRealTimeLocationStatus = function (conversationType, targetId, latitude, longitude) { + throw new Error("Not implemented yet"); + }; + // #endregion Real-time Location Service + // # startVoIP + RongIMClient.prototype.startCall = function (converType, targetId, userIds, mediaType, extra, callback) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "array", "number", "string", "object"], "startCall", false, arguments); + if (RongIMClient._memoryStore.voipStategy) { + RongIMClient._voipProvider.startCall(converType, targetId, userIds, mediaType, extra, callback); + } else { + callback.onError(RongIMLib.ErrorCode.VOIP_NOT_AVALIABLE); + } + }; + RongIMClient.prototype.joinCall = function (mediaType, callback) { + RongIMLib.CheckParam.getInstance().check(['number', 'object'], "joinCall", false, arguments); + if (RongIMClient._memoryStore.voipStategy) { + RongIMClient._voipProvider.joinCall(mediaType, callback); + } else { + callback.onError(RongIMLib.ErrorCode.VOIP_NOT_AVALIABLE); + } + }; + RongIMClient.prototype.hungupCall = function (converType, targetId, reason) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "number"], "hungupCall", false, arguments); + if (RongIMClient._memoryStore.voipStategy) { + RongIMClient._voipProvider.hungupCall(converType, targetId, reason); + } + }; + RongIMClient.prototype.changeMediaType = function (converType, targetId, mediaType, callback) { + RongIMLib.CheckParam.getInstance().check(["number", "string", "number", "object"], "changeMediaType", false, arguments); + if (RongIMClient._memoryStore.voipStategy) { + RongIMClient._voipProvider.changeMediaType(converType, targetId, mediaType, callback); + } else { + callback.onError(RongIMLib.ErrorCode.VOIP_NOT_AVALIABLE); + } + }; + // # endVoIP + RongIMClient.prototype.getUnreadMentionedMessages = function (conversationType, targetId) { + return RongIMClient._dataAccessProvider.getUnreadMentionedMessages(conversationType, targetId); + }; + RongIMClient.prototype.clearListeners = function () { + RongIMClient._dataAccessProvider.clearListeners(); + }; + // UserStatus start + RongIMClient.prototype.getUserStatus = function (userId, callback) { + RongIMClient._dataAccessProvider.getUserStatus(userId, callback); + }; + RongIMClient.prototype.setUserStatus = function (status, callback) { + RongIMClient._dataAccessProvider.setUserStatus(status, callback); + }; + RongIMClient.prototype.subscribeUserStatus = function (userIds, callback) { + RongIMClient._dataAccessProvider.subscribeUserStatus(userIds, callback); + }; + RongIMClient.prototype.setOnReceiveStatusListener = function (callback) { + RongIMClient._dataAccessProvider.setOnReceiveStatusListener(callback); + }; + RongIMClient.MessageType = {}; + RongIMClient.RegisterMessage = {}; + RongIMClient._memoryStore = { + listenerList: [] + }; + RongIMClient.isNotPullMsg = false; + return RongIMClient; + }(); + RongIMLib.RongIMClient = RongIMClient; + + // //兼容AMD CMD + // if ("function" === typeof require && "object" === typeof module && module && module.id && "object" === typeof exports && exports) { + // module.exports = RongIMLib; + // } + // else if ("function" === typeof define && define.amd) { + // var browser = navigator.appName, b_version = navigator.appVersion, version = b_version.split(";"), isPolling = false; + // if (version.length > 1) { + // var trim_Version = parseInt(version[1].replace(/[ ]/g, "").replace(/MSIE/g, "")); + // if (trim_Version < 10) { + // isPolling = true; + // } + // } + // if (isPolling) { + // define("RongIMLib", ['md5'], function () { + // return RongIMLib; + // }); + // } + // else { + // // var lurl: string = RongIMClient._memoryStore.depend.long; + // // var burl: string = RongIMClient._memoryStore.depend.byteBuffer; + // // var purl: string = RongIMClient._memoryStore.depend.protobuf; + // define("RongIMLib", ['md5'], function () { + // return RongIMLib; + // }); + // } + // } + // else { + // window.RongIMClient = RongIMClient; + // } + })(RongIMLib); + //用于连接通道 + + // var RongIMLib; + (function (RongIMLib) { + (function (Qos) { + Qos[Qos["AT_MOST_ONCE"] = 0] = "AT_MOST_ONCE"; + Qos[Qos["AT_LEAST_ONCE"] = 1] = "AT_LEAST_ONCE"; + Qos[Qos["EXACTLY_ONCE"] = 2] = "EXACTLY_ONCE"; + Qos[Qos["DEFAULT"] = 3] = "DEFAULT"; + })(RongIMLib.Qos || (RongIMLib.Qos = {})); + var Qos = RongIMLib.Qos; + (function (Type) { + Type[Type["CONNECT"] = 1] = "CONNECT"; + Type[Type["CONNACK"] = 2] = "CONNACK"; + Type[Type["PUBLISH"] = 3] = "PUBLISH"; + Type[Type["PUBACK"] = 4] = "PUBACK"; + Type[Type["QUERY"] = 5] = "QUERY"; + Type[Type["QUERYACK"] = 6] = "QUERYACK"; + Type[Type["QUERYCON"] = 7] = "QUERYCON"; + Type[Type["SUBSCRIBE"] = 8] = "SUBSCRIBE"; + Type[Type["SUBACK"] = 9] = "SUBACK"; + Type[Type["UNSUBSCRIBE"] = 10] = "UNSUBSCRIBE"; + Type[Type["UNSUBACK"] = 11] = "UNSUBACK"; + Type[Type["PINGREQ"] = 12] = "PINGREQ"; + Type[Type["PINGRESP"] = 13] = "PINGRESP"; + Type[Type["DISCONNECT"] = 14] = "DISCONNECT"; + })(RongIMLib.Type || (RongIMLib.Type = {})); + var Type = RongIMLib.Type; + var _topic = ["invtDiz", "crDiz", "qnUrl", "userInf", "dizInf", "userInf", "joinGrp", "quitDiz", "exitGrp", "evctDiz", ["", "ppMsgP", "pdMsgP", "pgMsgP", "chatMsg", "pcMsgP", "", "pmcMsgN", "pmpMsgN"], "pdOpen", "rename", "uGcmpr", "qnTkn", "destroyChrm", "createChrm", "exitChrm", "queryChrm", "joinChrm", "pGrps", "addBlack", "rmBlack", "getBlack", "blackStat", "addRelation", "qryRelation", "delRelation", "pullMp", "schMp", "qnTkn", "qnUrl", "qryVoipK", "delMsg", "qryCHMsg"]; + var Channel = function () { + function Channel(address, cb, self) { + var that = this; + that.connectionStatus = -1; + that.delOnChangedCount = 0; + var depend = RongIMLib.RongIMClient._memoryStore.depend; + var servers = depend.cmpList; + that.socket = Socket.getInstance().createServer(); + var startConnect = function (cmp) { + RongIMLib.RongIMClient._memoryStore.depend.cmp = cmp; + that.url = cmp + "/websocket?appId=" + self.appId + "&token=" + encodeURIComponent(self.token) + "&sdkVer=" + self.sdkVer + "&apiVer=" + self.apiVer; + that.self = self; + that.socket.connect(that.url, cb); + }; + var detectByGet = function () { + var totalTimer = new tools.Timer({ + timeout: 1 * 1000 * 15 + }); + var timers = []; + var xhrs = []; + var isFinished = false; + var clearHandler = function () { + for (var i = 0; i < timers.length; i++) { + var timer = timers[i]; + clearTimeout(timer); + } + for (var i = 0; i < xhrs.length; i++) { + var xhr = xhrs[i]; + xhr.abort(); + } + timers.length = 0; + xhrs.length = 0; + }; + var request = function (config, callback) { + var url = config.url; + var time = config.time; + if (isFinished) { + return; + } + var timer = setTimeout(function () { + var onSuccess = function () { + if (isFinished) { + return; + } + clearHandler(); + isFinished = true; + totalTimer.pause(); + callback(url); + }; + var xhr = tools.request({ + url: url + }, { + success: onSuccess, + fail: function (code) { + console.log(code); + } + }); + xhrs.push(xhr); + }, time); + timers.push(timer); + }; + var snifferCallback = function (url) { + var reg = /(http|https):\/\/([^\/]+)/i; + var host = url.match(reg)[2]; + startConnect(host); + }; + var snifferTpl = '{protocol}{server}/ping?r={random}'; + for (var i = 0; i < servers.length; i++) { + var server = servers[i]; + if (server) { + server = tools.tplEngine(snifferTpl, { + protocol: depend.protocol, + server: server, + random: +new Date() + }); + request({ + url: server, + time: i * 1000 + }, snifferCallback); + } + } + totalTimer.resume(function () { + clearHandler(); + that.socket.fire("StatusChanged", ConnectionStatus.NETWORK_UNAVAILABLE); + }); + }; + detectByGet(); + + //this.url = address.host + "/websocket?appId=" + self.appId + "&token=" + encodeURIComponent(self.token) + "&sdkVer=" + self.sdkVer + "&apiVer=" + self.apiVer; + + //注册状态改变观察者 + if (typeof Channel._ConnectionStatusListener == "object" && "onChanged" in Channel._ConnectionStatusListener) { + var me = this; + me.socket.on("StatusChanged", function (code) { + if (me.connectionStatus === RongIMLib.ConnectionStatus.DISCONNECTED && code === RongIMLib.ConnectionStatus.NETWORK_UNAVAILABLE) { + me.connectionStatus = code; + return; + } + me.connectionStatus = code; + if (code === RongIMLib.ConnectionStatus.NETWORK_UNAVAILABLE) { + var temp = RongIMLib.RongIMClient._storageProvider.getItemKey("navi"); + var naviServer = RongIMLib.RongIMClient._storageProvider.getItem(temp); + var naviPort = naviServer.split(",")[0].split(":")[1]; + naviPort && naviPort.length < 4 || RongIMLib.RongIMClient._storageProvider.setItem("rongSDK", ""); + // TODO 判断拆分 naviServer 后的数组长度。 + if (!RongIMLib.RongIMClient._memoryStore.depend.isPolling && naviPort && naviPort.length < 4) { + Bridge._client.handler.connectCallback.pauseTimer(); + var temp = RongIMLib.RongIMClient._storageProvider.getItemKey("navi"); + var server = RongIMLib.RongIMClient._storageProvider.getItem("RongBackupServer"); + if (server) { + var arrs = server.split(","); + if (arrs.length < 2) { + throw new Error("navi server is empty,postion:StatusChanged"); + } + RongIMLib.RongIMClient._storageProvider.setItem(temp, RongIMLib.RongIMClient._storageProvider.getItem("RongBackupServer")); + var url = RongIMLib.Bridge._client.channel.socket.currentURL; + Bridge._client.channel.socket.currentURL = arrs[0] + url.substring(url.indexOf("/"), url.length); + if (Bridge._client.channel && Bridge._client.channel.connectionStatus != RongIMLib.ConnectionStatus.CONNECTED && Bridge._client.channel.connectionStatus != RongIMLib.ConnectionStatus.CONNECTING) { + RongIMLib.RongIMClient.connect(RongIMLib.RongIMClient._memoryStore.token, RongIMLib.RongIMClient._memoryStore.callback); + } + } + } + } + if (code === RongIMLib.ConnectionStatus.DISCONNECTED && !RongIMLib.RongIMClient._memoryStore.otherDevice) { + Channel._ConnectionStatusListener.onChanged(RongIMLib.ConnectionStatus.DISCONNECTED); + self.clearHeartbeat(); + return; + } else if (code === RongIMLib.ConnectionStatus.DISCONNECTED && RongIMLib.RongIMClient._memoryStore.otherDevice) { + return; + } + Channel._ConnectionStatusListener.onChanged(code); + if (RongIMLib.RongIMClient._memoryStore.otherDevice) { + if (me.delOnChangedCount > 5) { + delete Channel._ConnectionStatusListener["onChanged"]; + } + me.delOnChangedCount++; + } + }); + } else { + throw new Error("setConnectStatusListener:Parameter format is incorrect"); + } + //注册message观察者 + this.socket.on("message", self.handler.handleMessage); + //注册断开连接观察者 + this.socket.on("disconnect", function (status) { + self.channel.socket.fire("StatusChanged", status ? status : 2); + }); + } + Channel.prototype.writeAndFlush = function (val) { + this.socket.send(val); + }; + Channel.prototype.reconnect = function (callback) { + RongIMLib.MessageIdHandler.clearMessageId(); + this.socket = this.socket.reconnect(); + if (callback) { + this.self.reconnectObj = callback; + } + }; + Channel.prototype.disconnect = function (status) { + this.socket.disconnect(status); + }; + return Channel; + }(); + RongIMLib.Channel = Channel; + var Socket = function () { + function Socket() { + this.socket = null; + this._events = {}; + } + Socket.getInstance = function () { + return new Socket(); + }; + Socket.prototype.connect = function (url, cb) { + if (this.socket) { + if (url) { + RongIMLib.RongIMClient._storageProvider.setItem("rongSDK", this.checkTransport()); + this.on("connect", cb || new Function()); + } + if (url) { + this.currentURL = url; + } + this.socket.createTransport(url); + } + return this; + }; + Socket.prototype.createServer = function () { + var transport = this.getTransport(this.checkTransport()); + if (transport === null) { + throw new Error("the channel was not supported"); + } + return transport; + }; + Socket.prototype.getTransport = function (transportType) { + var isPolling = RongIMLib.RongIMClient._memoryStore.depend.isPolling; + if (isPolling) { + this.socket = new RongIMLib.PollingTransportation(this); + } else { + this.socket = new RongIMLib.SocketTransportation(this); + } + return this; + }; + Socket.prototype.send = function (data) { + if (this.socket) { + var isPolling = RongIMLib.RongIMClient._memoryStore.depend.isPolling; + if (!isPolling) { + this.socket.send(data); + } else { + this.socket.send(this._encode(data)); + } + } + }; + Socket.prototype.onMessage = function (data) { + this.fire("message", data); + }; + Socket.prototype.disconnect = function (status) { + if (RongIMLib.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT === status) { + RongIMLib.RongIMClient._memoryStore.otherDevice = true; + } + this.socket.disconnect(status); + this.fire("disconnect", status); + return this; + }; + Socket.prototype.reconnect = function () { + if (this.currentURL && RongIMLib.RongIMClient._storageProvider.getItem("rongSDK")) { + return this.connect(this.currentURL, null); + } else { + throw new Error("reconnect:no have URL"); + } + }; + /** + * [checkTransport 返回通道类型] + */ + Socket.prototype.checkTransport = function () { + if (RongIMLib.RongIMClient._memoryStore.depend.isPolling) { + RongIMLib.Transportations._TransportType = Socket.XHR_POLLING; + } + return RongIMLib.Transportations._TransportType; + }; + Socket.prototype.fire = function (x, args) { + if (x in this._events) { + for (var i = 0, ii = this._events[x].length; i < ii; i++) { + this._events[x][i](args); + } + } + return this; + }; + Socket.prototype.on = function (x, func) { + if (!(typeof func == "function" && x)) { + return this; + } + if (x in this._events) { + RongIMLib.MessageUtil.indexOf(this._events, func) == -1 && this._events[x].push(func); + } else { + this._events[x] = [func]; + } + return this; + }; + Socket.prototype.removeEvent = function (x, fn) { + if (x in this._events) { + for (var a = 0, l = this._events[x].length; a < l; a++) { + if (this._events[x][a] == fn) { + this._events[x].splice(a, 1); + } + } + } + return this; + }; + Socket.prototype._encode = function (x) { + var str = "?messageid=" + x.getMessageId() + "&header=" + x.getHeaderFlag() + "&sessionid=" + RongIMLib.RongIMClient._storageProvider.getItem("sId" + RongIMLib.Navigation.Endpoint.userId); + if (!/(PubAckMessage|QueryConMessage)/.test(x._name)) { + str += "&topic=" + x.getTopic() + "&targetid=" + (x.getTargetId() || ""); + } + return { + url: str, + data: "getData" in x ? x.getData() : "" + }; + }; + //消息通道常量,所有和通道相关判断均用 XHR_POLLING WEBSOCKET两属性 + Socket.WEBSOCKET = "websocket"; + return Socket; + }(); + RongIMLib.Socket = Socket; + //连接端消息累 + var Client = function () { + function Client(token, appId) { + this.timeoutMillis = 100000; + this.timeout_ = 0; + this.sdkVer = "2.3.1"; + this.apiVer = Math.floor(Math.random() * 1e6); + this.channel = null; + this.handler = null; + this.userId = ""; + this.reconnectObj = {}; + this.heartbeat = 0; + this.pullMsgHearbeat = 0; + this.chatroomId = ""; + this.SyncTimeQueue = []; + this.cacheMessageIds = []; + this.token = token; + this.appId = appId; + this.SyncTimeQueue.state = "complete"; + } + Client.prototype.resumeTimer = function () { + if (!this.timeout_) { + this.timeout_ = setTimeout(function () { + if (!this.timeout_) { + return; + } + try { + this.channel.disconnect(); + } catch (e) { + throw new Error(e); + } + clearTimeout(this.timeout_); + this.timeout_ = 0; + this.channel.reconnect(); + this.channel.socket.fire("StatusChanged", 5); + }, this.timeoutMillis); + } + }; + Client.prototype.pauseTimer = function () { + if (this.timeout_) { + clearTimeout(this.timeout_); + this.timeout_ = 0; + } + }; + Client.prototype.connect = function (_callback) { + if (RongIMLib.Transportations._TransportType == Socket.WEBSOCKET) { + // if (!window.WebSocket) { + // _callback.onError(RongIMLib.ConnectionState.UNACCEPTABLE_PROTOCOL_VERSION); + // return; + // } + } + //实例消息处理类 + this.handler = new MessageHandler(this); + //设置连接回调 + this.handler.setConnectCallback(_callback); + //实例通道类型 + var me = this; + this.channel = new Channel(RongIMLib.Navigation.Endpoint, function () { + RongIMLib.Transportations._TransportType == Socket.WEBSOCKET && me.keepLive(); + }, this); + //触发状态改变观察者 + this.channel.socket.fire("StatusChanged", 1); + }; + Client.prototype.checkSocket = function (callback) { + var me = this; + me.channel.writeAndFlush(new RongIMLib.PingReqMessage()); + var checkTimeout = setInterval(function () { + if (!RongIMLib.RongIMClient._memoryStore.isFirstPingMsg) { + callback.onSuccess(); + clearInterval(checkTimeout); + } else { + if (count > 15) { + clearInterval(checkTimeout); + callback.onError(); + } + } + count++; + }, 200), + count = 0; + }; + Client.prototype.keepLive = function () { + if (this.heartbeat > 0) { + clearInterval(this.heartbeat); + } + var me = this; + me.heartbeat = setInterval(function () { + me.resumeTimer(); + me.channel.writeAndFlush(new RongIMLib.PingReqMessage()); + }, 30000); + if (me.pullMsgHearbeat > 0) { + clearInterval(me.pullMsgHearbeat); + } + me.pullMsgHearbeat = setInterval(function () { + me.syncTime(true, undefined, undefined, false); + }, 180000); + }; + Client.prototype.clearHeartbeat = function () { + clearInterval(this.heartbeat); + this.heartbeat = 0; + this.pauseTimer(); + clearInterval(this.pullMsgHearbeat); + this.pullMsgHearbeat = 0; + }; + Client.prototype.publishMessage = function (_topic, _data, _targetId, _callback, _msg) { + RongIMLib.RongIMClient.ready(function (_client) { + var msgId = RongIMLib.MessageIdHandler.messageIdPlus(_client.channel.reconnect); + if (!msgId) { + return; + } + var msg = new RongIMLib.PublishMessage(_topic, _data, _targetId); + msg.setMessageId(msgId); + if (_callback) { + msg.setQos(Qos.AT_LEAST_ONCE); + _client.handler.putCallback(new RongIMLib.PublishCallback(_callback.onSuccess, _callback.onError), msg.getMessageId(), _msg); + } else { + msg.setQos(Qos.AT_MOST_ONCE); + } + _client.channel.writeAndFlush(msg); + }); + }; + Client.prototype.queryMessage = function (_topic, _data, _targetId, _qos, _callback, pbtype) { + RongIMLib.RongIMClient.ready(function (_client) { + if (_topic == "userInf") { + if (Client.userInfoMapping[_targetId]) { + _callback.onSuccess(Client.userInfoMapping[_targetId]); + return; + } + } + var msgId = RongIMLib.MessageIdHandler.messageIdPlus(_client.channel.reconnect); + if (!msgId) { + return; + } + var msg = new RongIMLib.QueryMessage(_topic, _data, _targetId); + msg.setMessageId(msgId); + msg.setQos(_qos); + _client.handler.putCallback(new RongIMLib.QueryCallback(_callback.onSuccess, _callback.onError), msg.getMessageId(), pbtype); + _client.channel.writeAndFlush(msg); + }); + }; + Client.prototype.invoke = function (isPullMsg, chrmId, offlineMsg) { + var time, + modules, + str, + me = this, + target, + temp = this.SyncTimeQueue.shift(); + if (temp == undefined) { + return; + } + this.SyncTimeQueue.state = "pending"; + var storageSyncTime = RongIMLib.MessageUtil.getSyncTime(); + if (temp.type != 2) { + //普通消息 + time = storageSyncTime.received; + modules = new Modules.SyncRequestMsg(); + modules.setIspolling(false); + str = "pullMsg"; + target = this.userId; + var sendBoxTime = storageSyncTime.send; + modules.setSendBoxSyncTime(sendBoxTime); + } else { + //聊天室消息 + target = temp.chrmId || me.chatroomId; + time = RongIMLib.RongIMClient._memoryStore.lastReadTime.get(target + Bridge._client.userId + "CST") || 0; + modules = new Modules.ChrmPullMsg(); + modules.setCount(0); + str = "chrmPull"; + if (!target) { + throw new Error("syncTime:Received messages of chatroom but was not init"); + } + } + //判断服务器给的时间是否消息本地存储的时间,小于的话不执行拉取操作,进行一下步队列操作 + if (temp.pulltime <= time) { + this.SyncTimeQueue.state = "complete"; + this.invoke(isPullMsg, target); + return; + } + if (isPullMsg && 'setIsPullSend' in modules) { + modules.setIsPullSend(true); + } + modules.setSyncTime(time); + //发送queryMessage请求 + + var isInCache = function (messageUId) { + var result = false; + for (var i = 0, len = me.cacheMessageIds.length; i < len; i++) { + var uId = me.cacheMessageIds[i]; + if (uId == messageUId) { + result = true; + break; + } + } + return result; + }; + this.queryMessage(str, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), target, Qos.AT_LEAST_ONCE, { + onSuccess: function (collection) { + var sync = RongIMLib.MessageUtil.int64ToTimestamp(collection.syncTime), + symbol = target; + //把返回时间戳存入本地,普通消息key为userid,聊天室消息key为userid+'CST';value都为服务器返回的时间戳 + if (str == "chrmPull") { + symbol += Bridge._client.userId + "CST"; + RongIMLib.RongIMClient._memoryStore.lastReadTime.set(symbol, sync); + } + + //把拉取到的消息逐条传给消息监听器 + var list = collection.list; + var len = list.length; + for (var i = 0, count = len; i < len; i++) { + if (!isInCache(list[i].msgId)) { + Bridge._client.handler.onReceived(list[i], undefined, offlineMsg, --count); + var arrLen = me.cacheMessageIds.unshift(list[i].msgId); + if (arrLen > 200) { + me.cacheMessageIds.length = 180; + } + } + } + if (len <= 200 && str == 'pullMsg') { + var RongIMClient = RongIMLib.RongIMClient; + var Conversation = RongIMClient._dataAccessProvider.Conversation; + var conversationList = RongIMClient._memoryStore.conversationList; + Conversation._notify(conversationList); + } + + //防止因离线消息造成会话列表不为空而无法从服务器拉取会话列表。 + offlineMsg && (RongIMLib.RongIMClient._memoryStore.isSyncRemoteConverList = true); + me.SyncTimeQueue.state = "complete"; + me.invoke(isPullMsg, target); + }, + onError: function (error) { + me.SyncTimeQueue.state = "complete"; + me.invoke(isPullMsg, target); + } + }, "DownStreamMessages"); + }; + Client.prototype.syncTime = function (_type, pullTime, chrmId, offlineMsg) { + this.SyncTimeQueue.push({ + type: _type, + chrmId: chrmId, + pulltime: pullTime + }); + //如果队列中只有一个成员并且状态已经完成就执行invoke方法 + if (this.SyncTimeQueue.length == 1 && this.SyncTimeQueue.state == "complete") { + this.invoke(!_type, chrmId, offlineMsg); + } + }; + Client.prototype.__init = function (f) { + this.channel = new Channel(RongIMLib.Navigation.Endpoint, f, this); + }; + Client.userInfoMapping = {}; + return Client; + }(); + RongIMLib.Client = Client; + //连接类,实现imclient与connect_client的连接 + var Bridge = function () { + function Bridge() {} + Bridge.getInstance = function () { + return new Bridge(); + }; + //连接服务器 + Bridge.prototype.connect = function (appKey, token, callback) { + // if (!window["Modules"]) { + RongIMLib.RongIMClient._memoryStore.hasModules = false; + // return; + // } + Bridge._client = new RongIMLib.Navigation().connect(appKey, token, callback); + return Bridge._client; + }; + Bridge.prototype.setListener = function (_changer) { + if (typeof _changer == "object") { + if (typeof _changer.onChanged == "function") { + Channel._ConnectionStatusListener = _changer; + } else if (typeof _changer.onReceived == "function") { + Channel._ReceiveMessageListener = _changer; + } + } + }; + Bridge.prototype.reconnect = function (callabck) { + Bridge._client.channel.reconnect(callabck); + }; + Bridge.prototype.disconnect = function () { + Bridge._client.clearHeartbeat(); + Bridge._client.channel.disconnect(2); + }; + //执行queryMessage请求 + Bridge.prototype.queryMsg = function (topic, content, targetId, callback, pbname) { + if (typeof topic != "string") { + topic = _topic[topic]; + } + Bridge._client.queryMessage(topic, content, targetId, Qos.AT_MOST_ONCE, callback, pbname); + }; + //发送消息 执行publishMessage 请求 + Bridge.prototype.pubMsg = function (topic, content, targetId, callback, msg, methodType) { + if (typeof methodType == 'number') { + if (methodType == RongIMLib.MethodType.CUSTOMER_SERVICE) { + Bridge._client.publishMessage("pcuMsgP", content, targetId, callback, msg); + } else if (methodType == RongIMLib.MethodType.RECALL) { + Bridge._client.publishMessage("recallMsg", content, targetId, callback, msg); + } + } else { + Bridge._client.publishMessage(_topic[10][topic], content, targetId, callback, msg); + } + }; + return Bridge; + }(); + RongIMLib.Bridge = Bridge; + var MessageHandler = function () { + function MessageHandler(client) { + this.map = {}; + this.connectCallback = null; + if (!Channel._ReceiveMessageListener) { + throw new Error("please set onReceiveMessageListener"); + } + this._onReceived = Channel._ReceiveMessageListener.onReceived; + this._client = client; + this.syncMsgMap = new Object(); + } + //把对象推入回调对象队列中,并启动定时器 + MessageHandler.prototype.putCallback = function (callbackObj, _publishMessageId, _msg) { + var item = { + Callback: callbackObj, + Message: _msg + }; + item.Callback.resumeTimer(); + this.map[_publishMessageId] = item; + }; + //设置连接回调对象,启动定时器 + MessageHandler.prototype.setConnectCallback = function (_connectCallback) { + if (_connectCallback) { + this.connectCallback = new RongIMLib.ConnectAck(_connectCallback.onSuccess, _connectCallback.onError, this._client); + this.connectCallback.resumeTimer(); + } + }; + MessageHandler.prototype.onReceived = function (msg, pubAckItem, offlineMsg, leftCount) { + //实体对象 + var entity, + //解析完成的消息对象 + message, + //会话对象 + con; + if (msg._name != "PublishMessage") { + entity = msg; + //RongIMLib.RongIMClient._storageProvider.setItem(this._client.userId, RongIMLib.MessageUtil.int64ToTimestamp(entity.dataTime)); + } else { + if (msg.getTopic() == "s_ntf") { + entity = Modules.NotifyMsg.decode(msg.getData()); + this._client.syncTime(entity.type, RongIMLib.MessageUtil.int64ToTimestamp(entity.time), entity.chrmId); + return; + } else if (msg.getTopic() == "s_msg") { + entity = Modules.DownStreamMessage.decode(msg.getData()); + var timestamp = RongIMLib.MessageUtil.int64ToTimestamp(entity.dataTime); + // Martin:edit RongIMLib.RongIMClient._storageProvider.setItem(this._client.userId, timestamp); 移动至 下方 messageParser + // RongIMLib.RongIMClient._memoryStore.lastReadTime.get(this._client.userId, timestamp); + } else { + if (Bridge._client.sdkVer && Bridge._client.sdkVer == "1.0.0") { + return; + } + entity = Modules.UpStreamMessage.decode(msg.getData()); + var tmpTopic = msg.getTopic(); + var tmpType = tmpTopic.substr(0, 2); + if (tmpType == "pp") { + entity.type = 1; + } else if (tmpType == "pd") { + entity.type = 2; + } else if (tmpType == "pg") { + entity.type = 3; + } else if (tmpType == "ch") { + entity.type = 4; + } else if (tmpType == "pc") { + entity.type = 5; + } + //复用字段,targetId 以此为准 + entity.groupId = msg.getTargetId(); + entity.fromUserId = this._client.userId; + entity.dataTime = Date.parse(new Date().toString()); + } + if (!entity) { + return; + } + } + //解析实体对象为消息对象。 + message = RongIMLib.MessageUtil.messageParser(entity, this._onReceived, offlineMsg); + if (pubAckItem) { + message.messageUId = pubAckItem.getMessageUId(); + message.sentTime = pubAckItem.getTimestamp(); + } + if (message === null) { + return; + } + var msgTag = RongIMLib.RongIMClient.MessageParams[message.messageType].msgTag.getMessageTag(); + if (msgTag == 3 || msgTag == 1) { + RongIMLib.MessageUtil.updateSyncTime(message); + } + // 设置会话时间戳并且判断是否传递 message 发送消息未处理会话时间戳 + // key:'converST_' + 当前用户 + conversationType + targetId + // RongIMClient._storageProvider.setItem('converST_' + Bridge._client.userId + message.conversationType + message.targetId, message.sentTime); + if (msgTag == 3 || msgTag == 1) { + RongIMLib.RongIMClient._dataAccessProvider.getConversation(message.conversationType, message.targetId, { + onSuccess: function (con) { + if (!con) { + con = RongIMLib.RongIMClient.getInstance().createConversation(message.conversationType, message.targetId, ""); + } + if (message.messageDirection == RongIMLib.MessageDirection.RECEIVE && (entity.status & 64) == 64) { + var mentioneds = RongIMLib.RongIMClient._storageProvider.getItem("mentioneds_" + Bridge._client.userId + '_' + message.conversationType + '_' + message.targetId); + var key = message.conversationType + '_' + message.targetId, + info = {}; + if (message.content && message.content.mentionedInfo) { + info[key] = { + uid: message.messageUId, + time: message.sentTime, + mentionedInfo: message.content.mentionedInfo + }; + RongIMLib.RongIMClient._storageProvider.setItem("mentioneds_" + Bridge._client.userId + '_' + message.conversationType + '_' + message.targetId, JSON.stringify(info)); + mentioneds = JSON.stringify(info); + } + if (mentioneds) { + var info = JSON.parse(mentioneds); + con.mentionedMsg = info[key]; + } + } + if (con.conversationType != 0 && message.senderUserId != Bridge._client.userId && message.receivedStatus != RongIMLib.ReceivedStatus.RETRIEVED && message.messageType != RongIMLib.RongIMClient.MessageType["ReadReceiptRequestMessage"] && message.messageType != RongIMLib.RongIMClient.MessageType["ReadReceiptResponseMessage"]) { + con.unreadMessageCount = con.unreadMessageCount + 1; + if (RongIMLib.MessageUtil.supportLargeStorage()) { + var count = RongIMLib.RongIMClient._storageProvider.getItem("cu" + Bridge._client.userId + con.conversationType + con.targetId); // 与本地存储会话合并 + RongIMLib.RongIMClient._storageProvider.setItem("cu" + Bridge._client.userId + con.conversationType + message.targetId, Number(count) + 1); + } + } + con.receivedTime = new Date().getTime(); + con.receivedStatus = message.receivedStatus; + con.senderUserId = message.sendUserId; + con.notificationStatus = RongIMLib.ConversationNotificationStatus.DO_NOT_DISTURB; + con.latestMessageId = message.messageId; + con.latestMessage = message; + con.sentTime = message.sentTime; + RongIMLib.RongIMClient._dataAccessProvider.addConversation(con, { + onSuccess: function (data) { + if (!offlineMsg) { + var RongIMClient = RongIMLib.RongIMClient; + var Conversation = RongIMClient._dataAccessProvider.Conversation; + var conversationList = RongIMClient._memoryStore.conversationList; + Conversation._notify(conversationList); + } + }, + onError: function () {} + }); + }, + onError: function (error) {} + }); + } + var d = new Date(), + m = d.getMonth() + 1, + date = d.getFullYear() + '/' + (m.toString().length == 1 ? '0' + m : m) + '/' + d.getDate(); + var dealtime = new Date(date).getTime() - message.sentTime < 0; + if (RongIMLib.MessageUtil.supportLargeStorage() && message.messageType === RongIMLib.RongIMClient.MessageType["ReadReceiptRequestMessage"] && dealtime && message.messageDirection == RongIMLib.MessageDirection.SEND) { + var sentkey = Bridge._client.userId + message.content.messageUId + "SENT"; + RongIMLib.RongIMClient._storageProvider.setItem(sentkey, JSON.stringify({ + count: 0, + dealtime: message.sentTime, + userIds: {} + })); + } else if (RongIMLib.MessageUtil.supportLargeStorage() && message.messageType === RongIMLib.RongIMClient.MessageType["ReadReceiptRequestMessage"] && dealtime) { + var reckey = Bridge._client.userId + message.conversationType + message.targetId + 'RECEIVED', + recData = JSON.parse(RongIMLib.RongIMClient._storageProvider.getItem(reckey)); + if (recData) { + if (message.senderUserId in recData) { + if (recData[message.senderUserId].uIds && recData[message.senderUserId].uIds && recData[message.senderUserId].uIds.indexOf(message.content.messageUId) == -1) { + // 如果是前一天的 MessaageUId 把数组清空。 + new Date(date).getTime() - recData[message.senderUserId].dealtime < 0 || (recData[message.senderUserId].uIds.length = 0); + recData[message.senderUserId].uIds.push(message.content.messageUId); + recData[message.senderUserId].dealtime = message.sentTime; + recData[message.senderUserId].isResponse = false; + RongIMLib.RongIMClient._storageProvider.setItem(reckey, JSON.stringify(recData)); + } else { + return; + } + } else { + var objSon = { + uIds: [message.content.messageUId], + dealtime: message.sentTime, + isResponse: false + }; + recData[message.senderUserId] = objSon; + RongIMLib.RongIMClient._storageProvider.setItem(reckey, JSON.stringify(recData)); + } + } else { + var obj = {}; + obj[message.senderUserId] = { + uIds: [message.content.messageUId], + dealtime: message.sentTime, + isResponse: false + }; + RongIMLib.RongIMClient._storageProvider.setItem(reckey, JSON.stringify(obj)); + } + } + if (RongIMLib.MessageUtil.supportLargeStorage() && message.messageType === RongIMLib.RongIMClient.MessageType["ReadReceiptResponseMessage"] && dealtime) { + var receiptResponseMsg = message.content, + uIds = receiptResponseMsg.receiptMessageDic[Bridge._client.userId], + sentkey = "", + sentObj; + message.receiptResponse || (message.receiptResponse = {}); + if (uIds) { + var cbuIds = []; + for (var i = 0, len = uIds.length; i < len; i++) { + sentkey = Bridge._client.userId + uIds[i] + "SENT"; + sentObj = JSON.parse(RongIMLib.RongIMClient._storageProvider.getItem(sentkey)); + if (sentObj && !(message.senderUserId in sentObj.userIds)) { + if (new Date(date).getTime() - sentObj.dealtime > 0) { + RongIMLib.RongIMClient._storageProvider.removeItem(sentkey); + } else { + cbuIds.push(uIds[i]); + sentObj.count += 1; + sentObj.userIds[message.senderUserId] = message.sentTime; + message.receiptResponse[uIds[i]] = sentObj.count; + RongIMLib.RongIMClient._storageProvider.setItem(sentkey, JSON.stringify(sentObj)); + } + } + } + receiptResponseMsg.receiptMessageDic[Bridge._client.userId] = cbuIds; + message.content = receiptResponseMsg; + } + } + var that = this; + if (RongIMLib.RongIMClient._voipProvider && ['AcceptMessage', 'RingingMessage', 'HungupMessage', 'InviteMessage', 'MediaModifyMessage', 'MemberModifyMessage'].indexOf(message.messageType) > -1) { + RongIMLib.RongIMClient._voipProvider.onReceived(message); + } else { + var lcount = leftCount || 0; + RongIMLib.RongIMClient._dataAccessProvider.addMessage(message.conversationType, message.targetId, message, { + onSuccess: function (ret) { + that._onReceived(ret, lcount); + }, + onError: function (error) { + that._onReceived(message, lcount); + } + }); + } + }; + MessageHandler.prototype.handleMessage = function (msg) { + if (!msg) { + return; + } + switch (msg._name) { + case "ConnAckMessage": + Bridge._client.handler.connectCallback.process(msg.getStatus(), msg.getUserId(), msg.getTimestamp()); + break; + case "PublishMessage": + if (!msg.getSyncMsg() && msg.getQos() != 0) { + Bridge._client.channel.writeAndFlush(new RongIMLib.PubAckMessage(msg.getMessageId())); + } + // TODO && -> + if (msg.getSyncMsg() && !RongIMLib.RongIMClient._memoryStore.depend.isPolling) { + Bridge._client.handler.syncMsgMap[msg.getMessageId()] = msg; + } else { + //如果是PublishMessage就把该对象给onReceived方法执行处理 + Bridge._client.handler.onReceived(msg); + } + break; + case "QueryAckMessage": + if (msg.getQos() != 0) { + Bridge._client.channel.writeAndFlush(new RongIMLib.QueryConMessage(msg.getMessageId())); + } + var temp = Bridge._client.handler.map[msg.getMessageId()]; + if (temp) { + //执行回调操作 + temp.Callback.process(msg.getStatus(), msg.getData(), msg.getDate(), temp.Message); + delete Bridge._client.handler.map[msg.getMessageId()]; + } + break; + case "PubAckMessage": + var item = Bridge._client.handler.map[msg.getMessageId()]; + if (item) { + item.Callback.process(msg.getStatus() || 0, msg.getMessageUId(), msg.getTimestamp(), item.Message, msg.getMessageId()); + delete Bridge._client.handler.map[msg.getMessageId()]; + } else { + Bridge._client.handler.onReceived(Bridge._client.handler.syncMsgMap[msg.messageId], msg); + delete Bridge._client.handler.syncMsgMap[msg.getMessageId()]; + } + break; + case "PingRespMessage": + if (RongIMLib.RongIMClient._memoryStore.isFirstPingMsg) { + RongIMLib.RongIMClient._memoryStore.isFirstPingMsg = false; + } else { + Bridge._client.pauseTimer(); + } + break; + case "DisconnectMessage": + Bridge._client.channel.disconnect(msg.getStatus()); + break; + default: + } + }; + return MessageHandler; + }(); + RongIMLib.MessageHandler = MessageHandler; + })(RongIMLib || (RongIMLib = {})); + /// + + // var RongIMLib; + (function (RongIMLib) { + var MessageCallback = function () { + function MessageCallback(error) { + this.timeout = null; + this.onError = null; + if (error && typeof error == "number") { + this.timeoutMillis = error; + } else { + this.timeoutMillis = 30000; + this.onError = error; + } + } + MessageCallback.prototype.resumeTimer = function () { + var me = this; + if (this.timeoutMillis > 0 && !this.timeout) { + this.timeout = setTimeout(function () { + me.readTimeOut(true); + }, this.timeoutMillis); + } + }; + MessageCallback.prototype.pauseTimer = function () { + if (this.timeout) { + clearTimeout(this.timeout); + this.timeout = null; + } + }; + MessageCallback.prototype.readTimeOut = function (isTimeout) { + if (isTimeout && this.onError) { + this.onError(RongIMLib.ErrorCode.TIMEOUT); + } else { + this.pauseTimer(); + } + }; + return MessageCallback; + }(); + RongIMLib.MessageCallback = MessageCallback; + var CallbackMapping = function () { + function CallbackMapping() { + this.publicServiceList = []; + } + CallbackMapping.getInstance = function () { + return new CallbackMapping(); + }; + CallbackMapping.prototype.pottingProfile = function (item) { + var temp; + this.profile = new RongIMLib.PublicServiceProfile(); + temp = JSON.parse(item.extra); + this.profile.isGlobal = temp.isGlobal; + this.profile.introduction = temp.introduction; + this.profile.menu = temp.menu; + this.profile.hasFollowed = temp.follow; + this.profile.publicServiceId = item.mpid; + this.profile.name = item.name; + this.profile.portraitUri = item.portraitUrl; + this.profile.conversationType = item.type == "mc" ? RongIMLib.ConversationType.APP_PUBLIC_SERVICE : RongIMLib.ConversationType.PUBLIC_SERVICE; + this.publicServiceList.push(this.profile); + }; + CallbackMapping.prototype.mapping = function (entity, tag) { + switch (tag) { + case "GetUserInfoOutput": + var userInfo = new RongIMLib.UserInfo(entity.userId, entity.userName, entity.userPortrait); + return userInfo; + case "GetQNupTokenOutput": + return { + deadline: RongIMLib.MessageUtil.int64ToTimestamp(entity.deadline), + token: entity.token + }; + case "GetQNdownloadUrlOutput": + return { + downloadUrl: entity.downloadUrl + }; + case "CreateDiscussionOutput": + return entity.id; + case "ChannelInfoOutput": + var disInfo = new RongIMLib.Discussion(); + disInfo.creatorId = entity.adminUserId; + disInfo.id = entity.channelId; + disInfo.memberIdList = entity.firstTenUserIds; + disInfo.name = entity.channelName; + disInfo.isOpen = entity.openStatus; + return disInfo; + case "GroupHashOutput": + return entity.result; + case "QueryBlackListOutput": + return entity.userIds; + case "SearchMpOutput": + case "PullMpOutput": + if (entity.info) { + var self = this; + Array.forEach(entity.info, function (item) { + setTimeout(self.pottingProfile(item), 100); + }); + } + return this.publicServiceList; + default: + return entity; + } + }; + return CallbackMapping; + }(); + RongIMLib.CallbackMapping = CallbackMapping; + var PublishCallback = function (_super) { + __extends(PublishCallback, _super); + function PublishCallback(_cb, _timeout) { + _super.call(this, _timeout); + this._cb = _cb; + this._timeout = _timeout; + } + PublishCallback.prototype.process = function (_status, messageUId, timestamp, _msg, messageId) { + this.readTimeOut(); + if (_status == 0) { + if (_msg) { + _msg.setSentStatus = _status; + } + // Martin:edit RongIMLib.RongIMClient._storageProvider.setItem(RongIMLib.Bridge._client.userId, timestamp); + RongIMLib.MessageUtil.updateSyncTime({ + messageDirection: RongIMLib.MessageDirection.SEND, + sentTime: timestamp + }); + RongIMLib.RongIMClient._memoryStore.lastReadTime.get(RongIMLib.Bridge._client.userId, timestamp); + this._cb({ + messageUId: messageUId, + timestamp: timestamp, + messageId: messageId + }); + } else { + this._timeout(_status); + } + }; + PublishCallback.prototype.readTimeOut = function (x) { + MessageCallback.prototype.readTimeOut.call(this, x); + }; + return PublishCallback; + }(MessageCallback); + RongIMLib.PublishCallback = PublishCallback; + var QueryCallback = function (_super) { + __extends(QueryCallback, _super); + function QueryCallback(_cb, _timeout) { + _super.call(this, _timeout); + this._cb = _cb; + this._timeout = _timeout; + } + QueryCallback.prototype.process = function (status, data, serverTime, pbtype) { + this.readTimeOut(); + if (pbtype && data && status == 0) { + try { + data = CallbackMapping.getInstance().mapping(Modules[pbtype].decode(data), pbtype); + } catch (e) { + this._timeout(RongIMLib.ErrorCode.UNKNOWN); + return; + } + if ("GetUserInfoOutput" == pbtype) { + //pb类型为GetUserInfoOutput的话就把data放入userinfo缓存队列 + RongIMLib.Client.userInfoMapping[data.userId] = data; + } + this._cb(data); + } else { + status > 0 ? this._timeout(status) : this._cb(status); + } + }; + QueryCallback.prototype.readTimeOut = function (x) { + MessageCallback.prototype.readTimeOut.call(this, x); + }; + return QueryCallback; + }(MessageCallback); + RongIMLib.QueryCallback = QueryCallback; + var ConnectAck = function (_super) { + __extends(ConnectAck, _super); + function ConnectAck(_cb, _timeout, client) { + _super.call(this, _timeout); + this._client = client; + this._cb = _cb; + this._timeout = _timeout; + } + ConnectAck.prototype.process = function (status, userId, timestamp) { + this.readTimeOut(); + var self = this; + if (status == 0) { + self._client.userId = userId; + if (this._client.reconnectObj.onSuccess) { + this._client.reconnectObj.onSuccess(userId); + delete this._client.reconnectObj.onSuccess; + } else { + self._cb(userId); + var RongIMClient = RongIMLib.RongIMClient; + var depend = RongIMClient._memoryStore.depend; + var maxConversationCount = depend.maxConversationCount; + RongIMClient._dataAccessProvider.getRemoteConversationList({ + onSuccess: function (conversationList) { + var Conversation = RongIMClient._dataAccessProvider.Conversation; + Conversation._notify(conversationList); + }, + onError: function (code) { + console.log('内部获取列表失败: %d', code); + } + }, null, maxConversationCount); + } + if (!RongIMLib.RongIMClient.isNotPullMsg) { + self._client.syncTime(undefined, undefined, undefined, true); + } + RongIMLib.Bridge._client.channel.socket.fire("StatusChanged", 0); + RongIMLib.RongIMClient._memoryStore.connectAckTime = timestamp; + if (!(new Date().getTime() - timestamp)) { + RongIMLib.RongIMClient._memoryStore.deltaTime = 0; + } else { + RongIMLib.RongIMClient._memoryStore.deltaTime = new Date().getTime() - timestamp; + } + } else if (status == 6) { + //重定向 连错 CMP + var x = {}; + var me = this; + new RongIMLib.Navigation().getServerEndpoint(this._client.token, this._client.appId, function () { + me._client.clearHeartbeat(); + new RongIMLib.Client(me._client.token, me._client.appId).__init.call(x, function () { + RongIMLib.Transportations._TransportType == "websocket" && me._client.keepLive(); + }); + me._client.channel.socket.fire("StatusChanged", 2); + }, me._timeout, false); + } else { + RongIMLib.Bridge._client.channel.socket.socket._status = status; + if (this._client.reconnectObj.onError) { + this._client.reconnectObj.onError(status); + delete this._client.reconnectObj.onError; + } else { + this._timeout(status); + } + } + }; + ConnectAck.prototype.readTimeOut = function (x) { + MessageCallback.prototype.readTimeOut.call(this, x); + }; + return ConnectAck; + }(MessageCallback); + RongIMLib.ConnectAck = ConnectAck; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var md5 = RongIMLib.md5; + var Navigation = function () { + function Navigation() {} + Navigation.prototype.connect = function (appId, token, callback) { + var oldAppId = RongIMLib.RongIMClient._storageProvider.getItem("appId"); + //如果appid和本地存储的不一样,清空所有本地存储数据 + if (oldAppId && oldAppId != appId) { + RongIMLib.RongIMClient._storageProvider.clearItem(); + RongIMLib.RongIMClient._storageProvider.setItem("appId", appId); + } + if (!oldAppId) { + RongIMLib.RongIMClient._storageProvider.setItem("appId", appId); + } + var connectToken = tools.convertToken(token); + var client = new RongIMLib.Client(connectToken, appId); + var me = this; + this.getServerEndpoint(token, appId, function () { + client.connect(callback); + }, callback.onError, true); + return client; + }; + Navigation.prototype.getServerEndpoint = function (_token, _appId, _onsuccess, _onerror, unignore) { + _onsuccess(); + }; + Navigation.Endpoint = new Object(); + return Navigation; + }(); + RongIMLib.Navigation = Navigation; + })(RongIMLib || (RongIMLib = {})); + // TODO: 统一变量、方法等命名规范 + + // var RongIMLib; + (function (RongIMLib) { + /** + * 消息基类 + */ + var BaseMessage = function () { + function BaseMessage(arg) { + this._name = "BaseMessage"; + this.lengthSize = 0; + if (arg instanceof RongIMLib.Header) { + this._header = arg; + } else { + this._header = new RongIMLib.Header(arg, false, RongIMLib.Qos.AT_MOST_ONCE, false); + } + } + BaseMessage.prototype.read = function (In, length) { + this.readMessage(In, length); + }; + BaseMessage.prototype.write = function (Out) { + var binaryHelper = new RongIMLib.BinaryHelper(); + var out = binaryHelper.convertStream(Out); + this._headerCode = this.getHeaderFlag(); + out.write(this._headerCode); + this.writeMessage(out); + return out; + }; + BaseMessage.prototype.getHeaderFlag = function () { + return this._header.encode(); + }; + BaseMessage.prototype.getLengthSize = function () { + return this.lengthSize; + }; + BaseMessage.prototype.toBytes = function () { + return this.write([]).getBytesArray(); + }; + BaseMessage.prototype.isRetained = function () { + return this._header.retain; + }; + BaseMessage.prototype.setRetained = function (retain) { + this._header.retain = retain; + }; + BaseMessage.prototype.setQos = function (qos) { + this._header.qos = Object.prototype.toString.call(qos) == "[object Object]" ? qos : RongIMLib.Qos[qos]; + }; + BaseMessage.prototype.setDup = function (dup) { + this._header.dup = dup; + }; + BaseMessage.prototype.isDup = function () { + return this._header.dup; + }; + BaseMessage.prototype.getType = function () { + return this._header.type; + }; + BaseMessage.prototype.getQos = function () { + return this._header.qos; + }; + BaseMessage.prototype.messageLength = function () { + return 0; + }; + BaseMessage.prototype.writeMessage = function (out) {}; + BaseMessage.prototype.readMessage = function (In, length) {}; + BaseMessage.prototype.init = function (args) { + var valName, + nana, + me = this; + for (nana in args) { + if (!args.hasOwnProperty(nana)) { + continue; + } + valName = nana.replace(/^\w/, function (x) { + var tt = x.charCodeAt(0); + return "set" + (tt >= 0x61 ? String.fromCharCode(tt & ~32) : x); + }); + if (valName in me) { + if (nana == "status") { + me[valName](disconnectStatus[args[nana]] ? disconnectStatus[args[nana]] : args[nana]); + } else { + me[valName](args[nana]); + } + } + } + }; + return BaseMessage; + }(); + RongIMLib.BaseMessage = BaseMessage; + /** + *连接消息类型 + */ + var ConnectMessage = function (_super) { + __extends(ConnectMessage, _super); + function ConnectMessage(header) { + _super.call(this, arguments.length == 0 || arguments.length == 3 ? RongIMLib.Type.CONNECT : arguments[0]); + this._name = "ConnectMessage"; + this.CONNECT_HEADER_SIZE = 12; + this.protocolId = "RCloud"; + this.binaryHelper = new RongIMLib.BinaryHelper(); + this.protocolVersion = 3; + switch (arguments.length) { + case 0: + case 1: + case 3: + if (!arguments[0] || arguments[0].length > 64) { + throw new Error("ConnectMessage:Client Id cannot be null and must be at most 64 characters long: " + arguments[0]); + } + this.clientId = arguments[0]; + this.cleanSession = arguments[1]; + this.keepAlive = arguments[2]; + break; + } + } + ConnectMessage.prototype.messageLength = function () { + var payloadSize = this.binaryHelper.toMQttString(this.clientId).length; + payloadSize += this.binaryHelper.toMQttString(this.willTopic).length; + payloadSize += this.binaryHelper.toMQttString(this.will).length; + payloadSize += this.binaryHelper.toMQttString(this.appId).length; + payloadSize += this.binaryHelper.toMQttString(this.token).length; + return payloadSize + this.CONNECT_HEADER_SIZE; + }; + ConnectMessage.prototype.readMessage = function (stream) { + this.protocolId = stream.readUTF(); + this.protocolVersion = stream.readByte(); + var cFlags = stream.readByte(); + this.hasAppId = (cFlags & 128) > 0; + this.hasToken = (cFlags & 64) > 0; + this.retainWill = (cFlags & 32) > 0; + this.willQos = cFlags >> 3 & 3; + this.hasWill = (cFlags & 4) > 0; + this.cleanSession = (cFlags & 32) > 0; + this.keepAlive = stream.read() * 256 + stream.read(); + this.clientId = stream.readUTF(); + if (this.hasWill) { + this.willTopic = stream.readUTF(); + this.will = stream.readUTF(); + } + if (this.hasAppId) { + try { + this.appId = stream.readUTF(); + } catch (ex) { + throw new Error(ex); + } + } + if (this.hasToken) { + try { + this.token = stream.readUTF(); + } catch (ex) { + throw new Error(ex); + } + } + return stream; + }; + ConnectMessage.prototype.writeMessage = function (out) { + var stream = this.binaryHelper.convertStream(out); + stream.writeUTF(this.protocolId); + stream.write(this.protocolVersion); + var flags = this.cleanSession ? 2 : 0; + flags |= this.hasWill ? 4 : 0; + flags |= this.willQos ? this.willQos >> 3 : 0; + flags |= this.retainWill ? 32 : 0; + flags |= this.hasToken ? 64 : 0; + flags |= this.hasAppId ? 128 : 0; + stream.write(flags); + stream.writeChar(this.keepAlive); + stream.writeUTF(this.clientId); + if (this.hasWill) { + stream.writeUTF(this.willTopic); + stream.writeUTF(this.will); + } + if (this.hasAppId) { + stream.writeUTF(this.appId); + } + if (this.hasToken) { + stream.writeUTF(this.token); + } + return stream; + }; + return ConnectMessage; + }(BaseMessage); + RongIMLib.ConnectMessage = ConnectMessage; + /** + *连接应答类型 + */ + var ConnAckMessage = function (_super) { + __extends(ConnAckMessage, _super); + function ConnAckMessage(header) { + _super.call(this, arguments.length == 0 ? RongIMLib.Type.CONNACK : arguments.length == 1 ? arguments[0] instanceof RongIMLib.Header ? arguments[0] : RongIMLib.Type.CONNACK : null); + this._name = "ConnAckMessage"; + this.MESSAGE_LENGTH = 2; + this.binaryHelper = new RongIMLib.BinaryHelper(); + var me = this; + switch (arguments.length) { + case 0: + case 1: + if (!(arguments[0] instanceof RongIMLib.Header)) { + if (arguments[0] in RongIMLib.ConnectionState) { + if (arguments[0] == null) { + throw new Error("ConnAckMessage:The status of ConnAskMessage can't be null"); + } + me.setStatus(arguments[0]); + } + } + break; + } + } + ; + ConnAckMessage.prototype.messageLength = function () { + var length = this.MESSAGE_LENGTH; + if (this.userId) { + length += this.binaryHelper.toMQttString(this.userId).length; + } + return length; + }; + ; + ConnAckMessage.prototype.readMessage = function (_in, msglength) { + _in.read(); + var result = +_in.read(); + if (result >= 0 && result <= 12) { + this.setStatus(result); + } else { + throw new Error("Unsupported CONNACK code:" + result); + } + if (msglength > this.MESSAGE_LENGTH) { + this.setUserId(_in.readUTF()); + var sessionId = _in.readUTF(); + var timestamp = _in.readLong(); + this.setTimestamp(timestamp); + } + }; + ; + ConnAckMessage.prototype.writeMessage = function (out) { + var stream = this.binaryHelper.convertStream(out); + stream.write(128); + switch (+status) { + case 0: + case 1: + case 2: + case 5: + case 6: + stream.write(+status); + break; + case 3: + case 4: + stream.write(3); + break; + default: + throw new Error("Unsupported CONNACK code:" + status); + } + if (this.userId) { + stream.writeUTF(this.userId); + } + return stream; + }; + ; + ConnAckMessage.prototype.setStatus = function (x) { + this.status = x; + }; + ; + ConnAckMessage.prototype.setUserId = function (_userId) { + this.userId = _userId; + }; + ; + ConnAckMessage.prototype.getStatus = function () { + return this.status; + }; + ; + ConnAckMessage.prototype.getUserId = function () { + return this.userId; + }; + ; + ConnAckMessage.prototype.setTimestamp = function (x) { + this.timestrap = x; + }; + ; + ConnAckMessage.prototype.getTimestamp = function () { + return this.timestrap; + }; + return ConnAckMessage; + }(BaseMessage); + RongIMLib.ConnAckMessage = ConnAckMessage; + /** + *断开消息类型 + */ + var DisconnectMessage = function (_super) { + __extends(DisconnectMessage, _super); + function DisconnectMessage(header) { + _super.call(this, header instanceof RongIMLib.Header ? header : RongIMLib.Type.DISCONNECT); + this._name = "DisconnectMessage"; + this.MESSAGE_LENGTH = 2; + this.binaryHelper = new RongIMLib.BinaryHelper(); + if (!(header instanceof RongIMLib.Header)) { + if (header in RongIMLib.ConnectionStatus) { + this.status = header; + } + } + } + DisconnectMessage.prototype.messageLength = function () { + return this.MESSAGE_LENGTH; + }; + DisconnectMessage.prototype.readMessage = function (_in) { + _in.read(); + var result = +_in.read(); + if (result >= 0 && result <= 5) { + this.setStatus(disconnectStatus[result] ? disconnectStatus[result] : result); + } else { + throw new Error("Unsupported CONNACK code:" + result); + } + }; + DisconnectMessage.prototype.writeMessage = function (Out) { + var out = this.binaryHelper.convertStream(Out); + out.write(0); + if (+status >= 1 && +status <= 3) { + out.write(+status - 1); + } else { + throw new Error("Unsupported CONNACK code:" + status); + } + }; + DisconnectMessage.prototype.setStatus = function (x) { + this.status = x; + }; + ; + DisconnectMessage.prototype.getStatus = function () { + return this.status; + }; + ; + return DisconnectMessage; + }(BaseMessage); + RongIMLib.DisconnectMessage = DisconnectMessage; + /** + *请求消息信令 + */ + var PingReqMessage = function (_super) { + __extends(PingReqMessage, _super); + function PingReqMessage(header) { + _super.call(this, header && header instanceof RongIMLib.Header ? header : RongIMLib.Type.PINGREQ); + this._name = "PingReqMessage"; + } + return PingReqMessage; + }(BaseMessage); + RongIMLib.PingReqMessage = PingReqMessage; + /** + *响应消息信令 + */ + var PingRespMessage = function (_super) { + __extends(PingRespMessage, _super); + function PingRespMessage(header) { + _super.call(this, header && header instanceof RongIMLib.Header ? header : RongIMLib.Type.PINGRESP); + this._name = "PingRespMessage"; + } + return PingRespMessage; + }(BaseMessage); + RongIMLib.PingRespMessage = PingRespMessage; + /** + *封装MesssageId + */ + var RetryableMessage = function (_super) { + __extends(RetryableMessage, _super); + function RetryableMessage(argu) { + _super.call(this, argu); + this._name = "RetryableMessage"; + this.binaryHelper = new RongIMLib.BinaryHelper(); + } + RetryableMessage.prototype.messageLength = function () { + return 2; + }; + RetryableMessage.prototype.writeMessage = function (Out) { + var out = this.binaryHelper.convertStream(Out), + Id = this.getMessageId(), + lsb = Id & 255, + msb = (Id & 65280) >> 8; + out.write(msb); + out.write(lsb); + return out; + }; + RetryableMessage.prototype.readMessage = function (_in, msgLength) { + var msgId = _in.read() * 256 + _in.read(); + this.setMessageId(parseInt(msgId, 10)); + }; + RetryableMessage.prototype.setMessageId = function (_messageId) { + this.messageId = _messageId; + }; + RetryableMessage.prototype.getMessageId = function () { + return this.messageId; + }; + return RetryableMessage; + }(BaseMessage); + RongIMLib.RetryableMessage = RetryableMessage; + /** + *发送消息应答(双向) + *qos为1必须给出应答(所有消息类型一样) + */ + var PubAckMessage = function (_super) { + __extends(PubAckMessage, _super); + function PubAckMessage(header) { + _super.call(this, header instanceof RongIMLib.Header ? header : RongIMLib.Type.PUBACK); + this.msgLen = 2; + this.date = 0; + this.millisecond = 0; + this.timestamp = 0; + this.binaryHelper = new RongIMLib.BinaryHelper(); + this._name = "PubAckMessage"; + if (!(header instanceof RongIMLib.Header)) { + _super.prototype.setMessageId.call(this, header); + } + } + PubAckMessage.prototype.messageLength = function () { + return this.msgLen; + }; + PubAckMessage.prototype.writeMessage = function (Out) { + var out = this.binaryHelper.convertStream(Out); + RetryableMessage.prototype.writeMessage.call(this, out); + }; + PubAckMessage.prototype.readMessage = function (_in, msgLength) { + RetryableMessage.prototype.readMessage.call(this, _in); + this.date = _in.readInt(); + this.status = _in.read() * 256 + _in.read(); + this.millisecond = _in.read() * 256 + _in.read(); + this.timestamp = this.date * 1000 + this.millisecond; + this.messageUId = _in.readUTF(); + }; + PubAckMessage.prototype.setStatus = function (x) { + this.status = x; + }; + PubAckMessage.prototype.setTimestamp = function (timestamp) { + this.timestamp = timestamp; + }; + PubAckMessage.prototype.setMessageUId = function (messageUId) { + this.messageUId = messageUId; + }; + PubAckMessage.prototype.getStatus = function () { + return this.status; + }; + PubAckMessage.prototype.getDate = function () { + return this.date; + }; + PubAckMessage.prototype.getTimestamp = function () { + return this.timestamp; + }; + PubAckMessage.prototype.getMessageUId = function () { + return this.messageUId; + }; + return PubAckMessage; + }(RetryableMessage); + RongIMLib.PubAckMessage = PubAckMessage; + /** + *发布消息 + */ + var PublishMessage = function (_super) { + __extends(PublishMessage, _super); + function PublishMessage(header, two, three) { + _super.call(this, arguments.length == 1 && header instanceof RongIMLib.Header ? header : arguments.length == 3 ? RongIMLib.Type.PUBLISH : 0); + this._name = "PublishMessage"; + this.binaryHelper = new RongIMLib.BinaryHelper(); + this.syncMsg = false; + if (arguments.length == 3) { + this.topic = header; + this.targetId = three; + this.data = typeof two == "string" ? this.binaryHelper.toMQttString(two) : two; + } + } + PublishMessage.prototype.messageLength = function () { + var length = 10; + length += this.binaryHelper.toMQttString(this.topic).length; + length += this.binaryHelper.toMQttString(this.targetId).length; + length += this.data.length; + return length; + }; + PublishMessage.prototype.writeMessage = function (Out) { + var out = this.binaryHelper.convertStream(Out); + out.writeUTF(this.topic); + out.writeUTF(this.targetId); + RetryableMessage.prototype.writeMessage.apply(this, arguments); + out.write(this.data); + }; + ; + PublishMessage.prototype.readMessage = function (_in, msgLength) { + var pos = 6; + this.date = _in.readInt(); + this.topic = _in.readUTF(); + pos += this.binaryHelper.toMQttString(this.topic).length; + this.targetId = _in.readUTF(); + pos += this.binaryHelper.toMQttString(this.targetId).length; + RetryableMessage.prototype.readMessage.apply(this, arguments); + this.data = new Array(msgLength - pos); + this.data = _in.read(this.data); + }; + ; + PublishMessage.prototype.setTopic = function (x) { + this.topic = x; + }; + PublishMessage.prototype.setData = function (x) { + this.data = x; + }; + PublishMessage.prototype.setTargetId = function (x) { + this.targetId = x; + }; + PublishMessage.prototype.setDate = function (x) { + this.date = x; + }; + PublishMessage.prototype.setSyncMsg = function (x) { + this.syncMsg = x; + }; + //是否是其他端同步过来的消息 + PublishMessage.prototype.getSyncMsg = function () { + return this.syncMsg; + }; + PublishMessage.prototype.getTopic = function () { + return this.topic; + }; + PublishMessage.prototype.getData = function () { + return this.data; + }; + PublishMessage.prototype.getTargetId = function () { + return this.targetId; + }; + PublishMessage.prototype.getDate = function () { + return this.date; + }; + return PublishMessage; + }(RetryableMessage); + RongIMLib.PublishMessage = PublishMessage; + /** + *请求查询 + */ + var QueryMessage = function (_super) { + __extends(QueryMessage, _super); + function QueryMessage(header, two, three) { + _super.call(this, header instanceof RongIMLib.Header ? header : arguments.length == 3 ? RongIMLib.Type.QUERY : null); + this.binaryHelper = new RongIMLib.BinaryHelper(); + this._name = "QueryMessage"; + if (arguments.length == 3) { + this.data = typeof two == "string" ? this.binaryHelper.toMQttString(two) : two; + this.topic = header; + this.targetId = three; + } + } + QueryMessage.prototype.messageLength = function () { + var length = 0; + length += this.binaryHelper.toMQttString(this.topic).length; + length += this.binaryHelper.toMQttString(this.targetId).length; + length += 2; + length += this.data.length; + return length; + }; + QueryMessage.prototype.writeMessage = function (Out) { + var out = this.binaryHelper.convertStream(Out); + out.writeUTF(this.topic); + out.writeUTF(this.targetId); + RetryableMessage.prototype.writeMessage.call(this, out); + out.write(this.data); + }; + QueryMessage.prototype.readMessage = function (_in, msgLength) { + var pos = 0; + this.topic = _in.readUTF(); + this.targetId = _in.readUTF(); + pos += this.binaryHelper.toMQttString(this.topic).length; + pos += this.binaryHelper.toMQttString(this.targetId).length; + this.readMessage.apply(this, arguments); + pos += 2; + this.data = new Array(msgLength - pos); + _in.read(this.data); + }; + QueryMessage.prototype.setTopic = function (x) { + this.topic = x; + }; + QueryMessage.prototype.setData = function (x) { + this.data = x; + }; + QueryMessage.prototype.setTargetId = function (x) { + this.targetId = x; + }; + QueryMessage.prototype.getTopic = function () { + return this.topic; + }; + QueryMessage.prototype.getData = function () { + return this.data; + }; + QueryMessage.prototype.getTargetId = function () { + return this.targetId; + }; + return QueryMessage; + }(RetryableMessage); + RongIMLib.QueryMessage = QueryMessage; + /** + *请求查询确认 + */ + var QueryConMessage = function (_super) { + __extends(QueryConMessage, _super); + function QueryConMessage(messageId) { + _super.call(this, messageId instanceof RongIMLib.Header ? messageId : RongIMLib.Type.QUERYCON); + this._name = "QueryConMessage"; + if (!(messageId instanceof RongIMLib.Header)) { + _super.prototype.setMessageId.call(this, messageId); + } + } + return QueryConMessage; + }(RetryableMessage); + RongIMLib.QueryConMessage = QueryConMessage; + /** + *请求查询应答 + */ + var QueryAckMessage = function (_super) { + __extends(QueryAckMessage, _super); + function QueryAckMessage(header) { + _super.call(this, header); + this._name = "QueryAckMessage"; + this.binaryHelper = new RongIMLib.BinaryHelper(); + } + QueryAckMessage.prototype.readMessage = function (In, msgLength) { + RetryableMessage.prototype.readMessage.call(this, In); + this.date = In.readInt(); + this.setStatus(In.read() * 256 + In.read()); + if (msgLength > 0) { + this.data = new Array(msgLength - 8); + this.data = In.read(this.data); + } + }; + QueryAckMessage.prototype.getData = function () { + return this.data; + }; + QueryAckMessage.prototype.getStatus = function () { + return this.status; + }; + QueryAckMessage.prototype.getDate = function () { + return this.date; + }; + QueryAckMessage.prototype.setDate = function (x) { + this.date = x; + }; + QueryAckMessage.prototype.setStatus = function (x) { + this.status = x; + }; + QueryAckMessage.prototype.setData = function (x) { + this.data = x; + }; + return QueryAckMessage; + }(RetryableMessage); + RongIMLib.QueryAckMessage = QueryAckMessage; + })(RongIMLib || (RongIMLib = {})); + /// + + // var RongIMLib; + (function (RongIMLib) { + /** + * 把消息对象写入流中 + * 发送消息时用到 + */ + var MessageOutputStream = function () { + function MessageOutputStream(_out) { + var binaryHelper = new RongIMLib.BinaryHelper(); + this.out = binaryHelper.convertStream(_out); + } + MessageOutputStream.prototype.writeMessage = function (msg) { + if (msg instanceof RongIMLib.BaseMessage) { + msg.write(this.out); + } + }; + return MessageOutputStream; + }(); + RongIMLib.MessageOutputStream = MessageOutputStream; + /** + * 流转换为消息对象 + * 服务器返回消息时用到 + */ + var MessageInputStream = function () { + function MessageInputStream(In, isPolling) { + if (!isPolling) { + var _in = new RongIMLib.BinaryHelper().convertStream(In); + this.flags = _in.readByte(); + this._in = _in; + } else { + this.flags = In["headerCode"]; + } + this.header = new RongIMLib.Header(this.flags); + this.isPolling = isPolling; + this.In = In; + } + MessageInputStream.prototype.readMessage = function () { + switch (this.header.getType()) { + case 1: + this.msg = new RongIMLib.ConnectMessage(this.header); + break; + case 2: + this.msg = new RongIMLib.ConnAckMessage(this.header); + break; + case 3: + this.msg = new RongIMLib.PublishMessage(this.header); + this.msg.setSyncMsg(this.header.getSyncMsg()); + break; + case 4: + this.msg = new RongIMLib.PubAckMessage(this.header); + break; + case 5: + this.msg = new RongIMLib.QueryMessage(this.header); + break; + case 6: + this.msg = new RongIMLib.QueryAckMessage(this.header); + break; + case 7: + this.msg = new RongIMLib.QueryConMessage(this.header); + break; + case 9: + case 11: + case 13: + this.msg = new RongIMLib.PingRespMessage(this.header); + break; + case 8: + case 10: + case 12: + this.msg = new RongIMLib.PingReqMessage(this.header); + break; + case 14: + this.msg = new RongIMLib.DisconnectMessage(this.header); + break; + default: + throw new Error("No support for deserializing " + this.header.getType() + " messages"); + } + if (this.isPolling) { + this.msg.init(this.In); + } else { + this.msg.read(this._in, this.In.length - 1); + } + return this.msg; + }; + return MessageInputStream; + }(); + RongIMLib.MessageInputStream = MessageInputStream; + var Header = function () { + function Header(_type, _retain, _qos, _dup) { + this.retain = false; + this.qos = RongIMLib.Qos.AT_LEAST_ONCE; + this.dup = false; + this.syncMsg = false; + if (_type && +_type == _type && arguments.length == 1) { + this.retain = (_type & 1) > 0; + this.qos = (_type & 6) >> 1; + this.dup = (_type & 8) > 0; + this.type = _type >> 4 & 15; + this.syncMsg = (_type & 8) == 8; + } else { + this.type = _type; + this.retain = _retain; + this.qos = _qos; + this.dup = _dup; + } + } + Header.prototype.getSyncMsg = function () { + return this.syncMsg; + }; + Header.prototype.getType = function () { + return this.type; + }; + Header.prototype.encode = function () { + var me = this; + switch (this.qos) { + case RongIMLib.Qos[0]: + me.qos = RongIMLib.Qos.AT_MOST_ONCE; + break; + case RongIMLib.Qos[1]: + me.qos = RongIMLib.Qos.AT_LEAST_ONCE; + break; + case RongIMLib.Qos[2]: + me.qos = RongIMLib.Qos.EXACTLY_ONCE; + break; + case RongIMLib.Qos[3]: + me.qos = RongIMLib.Qos.DEFAULT; + break; + } + var _byte = this.type << 4; + _byte |= this.retain ? 1 : 0; + _byte |= this.qos << 1; + _byte |= this.dup ? 8 : 0; + return _byte; + }; + Header.prototype.toString = function () { + return "Header [type=" + this.type + ",retain=" + this.retain + ",qos=" + this.qos + ",dup=" + this.dup + "]"; + }; + return Header; + }(); + RongIMLib.Header = Header; + /** + * 二进制帮助对象 + */ + var BinaryHelper = function () { + function BinaryHelper() {} + BinaryHelper.prototype.writeUTF = function (str, isGetBytes) { + var back = [], + byteSize = 0; + for (var i = 0, len = str.length; i < len; i++) { + var code = str.charCodeAt(i); + if (code >= 0 && code <= 127) { + byteSize += 1; + back.push(code); + } else if (code >= 128 && code <= 2047) { + byteSize += 2; + back.push(192 | 31 & code >> 6); + back.push(128 | 63 & code); + } else if (code >= 2048 && code <= 65535) { + byteSize += 3; + back.push(224 | 15 & code >> 12); + back.push(128 | 63 & code >> 6); + back.push(128 | 63 & code); + } + } + for (var i = 0, len = back.length; i < len; i++) { + if (back[i] > 255) { + back[i] &= 255; + } + } + if (isGetBytes) { + return back; + } + if (byteSize <= 255) { + return [0, byteSize].concat(back); + } else { + return [byteSize >> 8, byteSize & 255].concat(back); + } + }; + BinaryHelper.prototype.readUTF = function (arr) { + if (Object.prototype.toString.call(arr) == "[object String]") { + return arr; + } + var UTF = "", + _arr = arr; + for (var i = 0, len = _arr.length; i < len; i++) { + if (_arr[i] < 0) { + _arr[i] += 256; + } + ; + var one = _arr[i].toString(2), + v = one.match(/^1+?(?=0)/); + if (v && one.length == 8) { + var bytesLength = v[0].length, + // store = _arr[i].toString(2).slice(7 - bytesLength); + store = ''; + for (var st = 0; st < bytesLength; st++) { + store += _arr[st + i].toString(2).slice(2); + } + UTF += String.fromCharCode(parseInt(store, 2)); + i += bytesLength - 1; + } else { + UTF += String.fromCharCode(_arr[i]); + } + } + return UTF; + }; + /** + * [convertStream 将参数x转化为RongIMStream对象] + * @param {any} x [参数] + */ + BinaryHelper.prototype.convertStream = function (x) { + if (x instanceof RongIMStream) { + return x; + } else { + return new RongIMStream(x); + } + }; + BinaryHelper.prototype.toMQttString = function (str) { + return this.writeUTF(str); + }; + return BinaryHelper; + }(); + RongIMLib.BinaryHelper = BinaryHelper; + var RongIMStream = function () { + function RongIMStream(arr) { + //当前流执行的起始位置 + this.position = 0; + //当前流写入的多少字节 + this.writen = 0; + this.poolLen = 0; + this.binaryHelper = new BinaryHelper(); + this.pool = arr; + this.poolLen = arr.length; + } + RongIMStream.prototype.check = function () { + return this.position >= this.pool.length; + }; + RongIMStream.prototype.readInt = function () { + if (this.check()) { + return -1; + } + var end = ""; + for (var i = 0; i < 4; i++) { + var t = this.pool[this.position++].toString(16); + if (t.length == 1) { + t = "0" + t; + } + end += t.toString(16); + } + return parseInt(end, 16); + }; + RongIMStream.prototype.readLong = function () { + if (this.check()) { + return -1; + } + var end = ""; + for (var i = 0; i < 8; i++) { + var t = this.pool[this.position++].toString(16); + if (t.length == 1) { + t = "0" + t; + } + end += t; + } + return parseInt(end, 16); + }; + RongIMStream.prototype.readTimestamp = function () { + if (this.check()) { + return -1; + } + var end = ""; + for (var i = 0; i < 8; i++) { + end += this.pool[this.position++].toString(16); + } + end = end.substring(2, 8); + return parseInt(end, 16); + }; + RongIMStream.prototype.readUTF = function () { + if (this.check()) { + return -1; + } + var big = this.readByte() << 8 | this.readByte(); + return this.binaryHelper.readUTF(this.pool.subarray(this.position, this.position += big)); + }; + RongIMStream.prototype.readByte = function () { + if (this.check()) { + return -1; + } + var val = this.pool[this.position++]; + if (val > 255) { + val &= 255; + } + return val; + }; + RongIMStream.prototype.read = function (bytesArray) { + if (bytesArray) { + return this.pool.subarray(this.position, this.poolLen); + } else { + return this.readByte(); + } + }; + RongIMStream.prototype.write = function (_byte) { + var b = _byte; + if (Object.prototype.toString.call(b).toLowerCase() == "[object array]") { + [].push.apply(this.pool, b); + } else { + if (+b == b) { + if (b > 255) { + b &= 255; + } + this.pool.push(b); + this.writen++; + } + } + return b; + }; + RongIMStream.prototype.writeChar = function (v) { + if (+v != v) { + throw new Error("writeChar:arguments type is error"); + } + this.write(v >> 8 & 255); + this.write(v & 255); + this.writen += 2; + }; + RongIMStream.prototype.writeUTF = function (str) { + var val = this.binaryHelper.writeUTF(str); + [].push.apply(this.pool, val); + this.writen += val.length; + }; + RongIMStream.prototype.toComplements = function () { + var _tPool = this.pool; + for (var i = 0; i < this.poolLen; i++) { + if (_tPool[i] > 128) { + _tPool[i] -= 256; + } + } + return _tPool; + }; + RongIMStream.prototype.getBytesArray = function (isCom) { + if (isCom) { + return this.toComplements(); + } + return this.pool; + }; + return RongIMStream; + }(); + RongIMLib.RongIMStream = RongIMStream; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var PollingTransportation = function () { + function PollingTransportation(socket) { + this.empty = new Function(); + this.connected = false; + this.pid = +new Date() + Math.random() + ""; + this.queue = []; + this.socket = socket; + return this; + } + PollingTransportation.prototype.createTransport = function (url, method) { + if (!url) { + throw new Error("Url is empty,Please check it!"); + } + ; + this.url = url; + var sid = RongIMLib.RongIMClient._storageProvider.getItem("sId" + RongIMLib.Navigation.Endpoint.userId), + me = this; + if (sid) { + setTimeout(function () { + me.onSuccess("{\"status\":0,\"userId\":\"" + RongIMLib.Navigation.Endpoint.userId + "\",\"headerCode\":32,\"messageId\":0,\"sessionid\":\"" + sid + "\"}"); + me.connected = true; + }, 500); + return this; + } + this.getRequest(url, true); + return this; + }; + PollingTransportation.prototype.getRequest = function (url, isconnect, options) { + options = options || {}; + var callback = options.callback || function () {}; + var me = this; + var pid = encodeURIComponent(me.pid); + var protocol = RongIMLib.RongIMClient._memoryStore.depend.protocol; + var tpl = '{protocol}{url}&pid={pid}'; + var url = tools.tplEngine(tpl, { + protocol: protocol, + url: url, + pid: pid + }); + me.xhr = tools.request({ + url: url, + data: { + t: Math.random() + } + }, { + success: function (res) { + var isError = res.statusCode == 400; + if (isError) { + me.onError(); + return; + } + var data = res.data; + if (data.status == 3) { + return me.onError(RongIMLib.ErrorCode.MINI_PROGAM_SERVICE_NOT_OPEN); + } + me.onSuccess(JSON.stringify(data), isconnect); + callback(); + }, + fail: function () { + me.onError(); + } + }); + }; + /** + * [send 发送消息,Method:POST] + * queue 为消息队列,待通道可用发送所有等待消息 + * @param {string} data [需要传入comet格式数据,此处只负责通讯通道,数据转换在外层处理] + */ + PollingTransportation.prototype.send = function (data) { + var me = this; + var path = data.url; + var host = RongIMLib.RongIMClient._memoryStore.depend.cmp; + var protocol = RongIMLib.RongIMClient._memoryStore.depend.protocol; + var pid = encodeURIComponent(me.pid); + var tpl = '{protocol}{host}/websocket{path}&pid={pid}'; + var url = tools.tplEngine(tpl, { + protocol: protocol, + host: host, + path: path, + pid: pid + }); + var body = JSON.stringify(data.data); + var self = this; + me.sendxhr = tools.request({ + url: url, + method: 'POST', + data: body + }, { + success: function (res) { + var _data = res.data; + if (!_data) { + return; + } + var isBadReq = res.statusCode == 400; + if (isBadReq) { + self.onClose(); + self.socket.fire('StatusChanged', RongIMLib.ConnectionStatus.NETWORK_UNAVAILABLE); + return; + } + _data = JSON.stringify(_data); + me.onData(_data); + }, + fail: function (e) { + console.log('inner sendmessage error', e); + } + }); + }; + PollingTransportation.prototype.onData = function (data, header) { + var self = this, + val = JSON.parse(data); + if (val.userId) { + RongIMLib.Navigation.Endpoint.userId = val.userId; + } + if (header) { + RongIMLib.RongIMClient._storageProvider.setItem("sId" + RongIMLib.Navigation.Endpoint.userId, header); + } + if (!RongIMLib.MessageUtil.isArray(val)) { + val = [val]; + } + Array.forEach(val, function (m) { + self.socket.fire("message", new RongIMLib.MessageInputStream(m, true).readMessage()); + }); + return ""; + }; + PollingTransportation.prototype.onClose = function () { + if (this.xhr) { + this.xhr.abort(); + this.xhr = null; + } + if (this.sendxhr) { + this.sendxhr.abort(); + this.sendxhr = null; + } + }; + PollingTransportation.prototype.disconnect = function () { + RongIMLib.RongIMClient._storageProvider.removeItem("sId" + RongIMLib.Navigation.Endpoint.userId); + RongIMLib.RongIMClient._storageProvider.removeItem(RongIMLib.Navigation.Endpoint.userId + "msgId"); + this.onClose(); + }; + PollingTransportation.prototype.reconnect = function () { + this.disconnect(); + this.createTransport(this.url); + }; + PollingTransportation.prototype.onSuccess = function (responseText, isconnect) { + var txt = responseText.match(/"sessionid":"\S+?(?=")/); + this.onData(responseText, txt ? txt[0].slice(13) : 0); + if (/"headerCode":-32,/.test(responseText)) { + RongIMLib.RongIMClient._storageProvider.removeItem("sId" + RongIMLib.Navigation.Endpoint.userId); + RongIMLib.RongIMClient._storageProvider.removeItem(RongIMLib.Navigation.Endpoint.userId + "msgId"); + return; + } + var host = RongIMLib.RongIMClient._memoryStore.depend.cmp; + var ret = JSON.parse(responseText); + // token 无效,不再进行轮询 + if (ret.status == 4) { + RongIMLib.RongIMClient._storageProvider.removeItem("sId" + RongIMLib.Navigation.Endpoint.userId); + RongIMLib.RongIMClient._storageProvider.removeItem(RongIMLib.Navigation.Endpoint.userId + "msgId"); + return; + } + this.getRequest(host + "/pullmsg.js?sessionid=" + RongIMLib.RongIMClient._storageProvider.getItem("sId" + RongIMLib.Navigation.Endpoint.userId) + "×trap=" + encodeURIComponent(new Date().getTime() + Math.random() + "")); + this.connected = true; + isconnect && this.socket.fire("connect"); + }; + PollingTransportation.prototype.onError = function (code) { + RongIMLib.RongIMClient._storageProvider.removeItem("sId" + RongIMLib.Navigation.Endpoint.userId); + RongIMLib.RongIMClient._storageProvider.removeItem(RongIMLib.Navigation.Endpoint.userId + "msgId"); + this.onClose(); + this.connected = false; + code = code || RongIMLib.ConnectionStatus.NETWORK_UNAVAILABLE; + this.socket.fire("disconnect", code); + }; + return PollingTransportation; + }(); + RongIMLib.PollingTransportation = PollingTransportation; + })(RongIMLib || (RongIMLib = {})); + + //objectname映射 + var typeMapping = { + "RC:TxtMsg": "TextMessage", + "RC:ImgMsg": "ImageMessage", + "RC:VcMsg": "VoiceMessage", + "RC:ImgTextMsg": "RichContentMessage", + "RC:FileMsg": "FileMessage", + "RC:LBSMsg": "LocationMessage", + "RC:InfoNtf": "InformationNotificationMessage", + "RC:ContactNtf": "ContactNotificationMessage", + "RC:ProfileNtf": "ProfileNotificationMessage", + "RC:CmdNtf": "CommandNotificationMessage", + "RC:DizNtf": "DiscussionNotificationMessage", + "RC:CmdMsg": "CommandMessage", + "RC:TypSts": "TypingStatusMessage", + "RC:CsChaR": "ChangeModeResponseMessage", + "RC:CsHsR": "HandShakeResponseMessage", + "RC:CsEnd": "TerminateMessage", + "RC:CsSp": "SuspendMessage", + "RC:CsUpdate": "CustomerStatusUpdateMessage", + "RC:ReadNtf": "ReadReceiptMessage", + "RC:VCAccept": "AcceptMessage", + "RC:VCRinging": "RingingMessage", + "RC:VCSummary": "SummaryMessage", + "RC:VCHangup": "HungupMessage", + "RC:VCInvite": "InviteMessage", + "RC:VCModifyMedia": "MediaModifyMessage", + "RC:VCModifyMem": "MemberModifyMessage", + "RC:CsContact": "CustomerContact", + "RC:PSImgTxtMsg": "PublicServiceRichContentMessage", + "RC:PSMultiImgTxtMsg": "PublicServiceMultiRichContentMessage", + "RC:GrpNtf": "GroupNotificationMessage", + "RC:PSCmd": "PublicServiceCommandMessage", + "RC:RcCmd": "RecallCommandMessage", + "RC:SRSMsg": "SyncReadStatusMessage", + "RC:RRReqMsg": "ReadReceiptRequestMessage", + "RC:RRRspMsg": "ReadReceiptResponseMessage", + "RCJrmf:RpMsg": "JrmfReadPacketMessage", + "RCJrmf:RpOpendMsg": "JrmfReadPacketOpenedMessage" + // "RCE:UpdateStatus": "RCEUpdateStatusMessage" + }, + //自定义消息类型 + registerMessageTypeMapping = {}, + HistoryMsgType = { + 4: "qryCMsg", + 2: "qryDMsg", + 3: "qryGMsg", + 1: "qryPMsg", + 6: "qrySMsg", + 7: "qryPMsg", + 8: "qryPMsg", + 5: "qryCMsg" + }, + disconnectStatus = { + 1: 6 + }; + + // var RongIMLib; + (function (RongIMLib) { + /** + * 通道标识类 + */ + var Transportations = function () { + function Transportations() {} + Transportations._TransportType = RongIMLib.Socket.WEBSOCKET; + return Transportations; + }(); + RongIMLib.Transportations = Transportations; + var MessageUtil = function () { + function MessageUtil() {} + MessageUtil.supportLargeStorage = function () { + return true; + }; + /** + *4680000 为localstorage最小容量5200000字节的90%,超过90%将删除之前过早的存储 + */ + MessageUtil.checkStorageSize = function () { + return JSON.stringify(localStorage).length < 4680000; + }; + MessageUtil.getFirstKey = function (obj) { + var str = ""; + for (var key in obj) { + str = key; + break; + } + return str; + }; + MessageUtil.isEmpty = function (obj) { + var empty = true; + for (var key in obj) { + empty = false; + break; + } + return empty; + }; + MessageUtil.ArrayForm = function (typearray) { + if (Object.prototype.toString.call(typearray) == "[object ArrayBuffer]") { + var arr = new Int8Array(typearray); + return [].slice.call(arr); + } + return typearray; + }; + MessageUtil.ArrayFormInput = function (typearray) { + if (Object.prototype.toString.call(typearray) == "[object ArrayBuffer]") { + var arr = new Uint8Array(typearray); + return arr; + } + return typearray; + }; + MessageUtil.indexOf = function (arr, item, from) { + for (var l = arr.length, i = from < 0 ? Math.max(0, +from) : from || 0; i < l; i++) { + if (arr[i] == item) { + return i; + } + } + return -1; + }; + MessageUtil.isArray = function (obj) { + return Object.prototype.toString.call(obj) == "[object Array]"; + }; + //遍历,只能遍历数组 + MessageUtil.forEach = function (arr, func) { + if ([].forEach) { + return function (arr, func) { + [].forEach.call(arr, func); + }; + } else { + return function (arr, func) { + for (var i = 0; i < arr.length; i++) { + func.call(arr, arr[i], i, arr); + } + }; + } + }; + MessageUtil.remove = function (array, func) { + for (var i = 0, len = array.length; i < len; i++) { + if (func(array[i])) { + return array.splice(i, 1)[0]; + } + } + return null; + }; + MessageUtil.int64ToTimestamp = function (obj, isDate) { + if (obj.low === undefined) { + return obj; + } + var low = obj.low; + if (low < 0) { + low += 0xffffffff + 1; + } + low = low.toString(16); + var timestamp = parseInt(obj.high.toString(16) + "00000000".replace(new RegExp("0{" + low.length + "}$"), low), 16); + if (isDate) { + return new Date(timestamp); + } + return timestamp; + }; + var getSyncTimeKey = function (message) { + var _client = RongIMLib.Bridge._client || {}; + var userId = _client.userId; + var direction = message.messageDirection == 1 ? 'send' : 'received'; + var tpl = '{userId}_{direction}box'; + return tools.tplEngine(tpl, { + userId: userId, + direction: direction + }); + }; + MessageUtil.updateSyncTime = function (message) { + var key = getSyncTimeKey(message); + var sentTime = message.sentTime; + var storage = RongIMLib.RongIMClient._storageProvider; + storage.setItem(key, sentTime); + }; + MessageUtil.getSyncTime = function () { + var sendKey = getSyncTimeKey({ + messageDirection: RongIMLib.MessageDirection.SEND + }); + var receivedKey = getSyncTimeKey({ + messageDirection: RongIMLib.MessageDirection.RECEIVED + }); + var storage = RongIMLib.RongIMClient._storageProvider; + return { + send: storage.getItem(sendKey) || 0, + received: storage.getItem(receivedKey) || 0 + }; + }; + //消息转换方法 + MessageUtil.messageParser = function (entity, onReceived, offlineMsg) { + var message = new RongIMLib.Message(), + content = entity.content, + de, + objectName = entity.classname, + val, + isUseDef = false; + try { + if (RongIMLib.RongIMClient._memoryStore.depend.isPolling) { + val = new RongIMLib.BinaryHelper().readUTF(content.offset ? MessageUtil.ArrayForm(content.buffer).slice(content.offset, content.limit) : content); + de = JSON.parse(val); + } else { + val = new RongIMLib.BinaryHelper().readUTF(content.offset ? MessageUtil.ArrayFormInput(content.buffer).subarray(content.offset, content.limit) : content); + de = JSON.parse(val); + } + } catch (ex) { + de = val; + isUseDef = true; + } + //映射为具体消息对象 + if (objectName in typeMapping) { + message.content = new RongIMLib[typeMapping[objectName]](de); + message.messageType = typeMapping[objectName]; + } else if (objectName in registerMessageTypeMapping) { + var content = new RongIMLib.RongIMClient.RegisterMessage[registerMessageTypeMapping[objectName]](de); + if (isUseDef) { + message.content = content.decode(de); + } else { + message.content = content; + } + message.messageType = registerMessageTypeMapping[objectName]; + } else { + message.content = new RongIMLib.UnknownMessage({ + content: de, + objectName: objectName + }); + message.messageType = "UnknownMessage"; + } + //根据实体对象设置message对象] + var dateTime = MessageUtil.int64ToTimestamp(entity.dataTime); + if (dateTime > 0) { + message.sentTime = dateTime; + } else { + message.sentTime = +new Date(); + } + message.senderUserId = entity.fromUserId; + message.conversationType = entity.type; + if (entity.fromUserId == RongIMLib.Bridge._client.userId) { + message.targetId = entity.groupId; + } else { + message.targetId = /^[234]$/.test(entity.type || entity.getType()) ? entity.groupId : message.senderUserId; + } + if (entity.direction == 1) { + message.messageDirection = RongIMLib.MessageDirection.SEND; + message.senderUserId = RongIMLib.Bridge._client.userId; + } else { + if (message.senderUserId == RongIMLib.Bridge._client.userId) { + message.messageDirection = RongIMLib.MessageDirection.SEND; + } else { + message.messageDirection = RongIMLib.MessageDirection.RECEIVE; + } + } + message.receivedStatus = RongIMLib.ReceivedStatus.READ; + if ((entity.status & 2) == 2) { + message.receivedStatus = RongIMLib.ReceivedStatus.RETRIEVED; + } + message.messageUId = entity.msgId; + message.receivedTime = new Date().getTime(); + message.messageId = message.conversationType + "_" + ~~(Math.random() * 0xffffff); + message.objectName = objectName; + message.offLineMessage = offlineMsg ? true : false; + if (!offlineMsg) { + if (RongIMLib.RongIMClient._memoryStore.connectAckTime > message.sentTime) { + message.offLineMessage = true; + } + } + return message; + }; + //适配SSL + // static schemeArrs: Array = [["http", "ws"], ["https", "wss"]]; + MessageUtil.sign = { + converNum: 1, + msgNum: 1, + isMsgStart: true, + isConvStart: true + }; + return MessageUtil; + }(); + RongIMLib.MessageUtil = MessageUtil; + /** + * 工具类 + */ + var MessageIdHandler = function () { + function MessageIdHandler() {} + MessageIdHandler.init = function () { + this.messageId = 0; + }; + MessageIdHandler.messageIdPlus = function (method) { + if (this.messageId >= 65535) { + method(); + return false; + } + this.messageId += 1; + return this.messageId; + }; + MessageIdHandler.clearMessageId = function () { + this.messageId = 0; + }; + MessageIdHandler.getMessageId = function () { + return this.messageId; + }; + MessageIdHandler.messageId = 0; + return MessageIdHandler; + }(); + RongIMLib.MessageIdHandler = MessageIdHandler; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var MessageContent = function () { + function MessageContent(data) { + throw new Error("This method is abstract, you must implement this method in inherited class."); + } + MessageContent.obtain = function () { + throw new Error("This method is abstract, you must implement this method in inherited class."); + }; + return MessageContent; + }(); + RongIMLib.MessageContent = MessageContent; + var NotificationMessage = function (_super) { + __extends(NotificationMessage, _super); + function NotificationMessage() { + _super.apply(this, arguments); + } + return NotificationMessage; + }(MessageContent); + RongIMLib.NotificationMessage = NotificationMessage; + var StatusMessage = function (_super) { + __extends(StatusMessage, _super); + function StatusMessage() { + _super.apply(this, arguments); + } + return StatusMessage; + }(MessageContent); + RongIMLib.StatusMessage = StatusMessage; + var ModelUtil = function () { + function ModelUtil() {} + ModelUtil.modelClone = function (object) { + var obj = {}; + for (var item in object) { + if (item != "messageName" && "encode" != item) { + obj[item] = object[item]; + } + } + return obj; + }; + ModelUtil.modleCreate = function (fields, msgType) { + if (fields.length < 1) { + throw new Error("Array is empty -> registerMessageType.modleCreate"); + } + var Object = function (message) { + var me = this; + for (var index in fields) { + me[fields[index]] = message[fields[index]]; + } + Object.prototype.messageName = msgType; + Object.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + }; + return Object; + }; + return ModelUtil; + }(); + RongIMLib.ModelUtil = ModelUtil; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var CustomerStatusMessage = function () { + function CustomerStatusMessage(message) { + this.messageName = "CustomerStatusMessage"; + this.status = message.status; + } + CustomerStatusMessage.obtain = function () { + return null; + }; + CustomerStatusMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return CustomerStatusMessage; + }(); + RongIMLib.CustomerStatusMessage = CustomerStatusMessage; + /** + * 客服转换响应消息的类型名 + */ + var ChangeModeResponseMessage = function () { + function ChangeModeResponseMessage(message) { + this.messageName = "ChangeModeResponseMessage"; + this.code = message.code; + this.data = message.data; + this.msg = message.msg; + } + ChangeModeResponseMessage.obtain = function () { + return null; + }; + ChangeModeResponseMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return ChangeModeResponseMessage; + }(); + RongIMLib.ChangeModeResponseMessage = ChangeModeResponseMessage; + /** + * 客服转换消息的类型名 + * 此消息不计入未读消息数 + */ + var ChangeModeMessage = function () { + function ChangeModeMessage(message) { + this.messageName = "ChangeModeMessage"; + this.uid = message.uid; + this.sid = message.sid; + this.pid = message.pid; + } + ChangeModeMessage.obtain = function () { + return null; + }; + ChangeModeMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return ChangeModeMessage; + }(); + RongIMLib.ChangeModeMessage = ChangeModeMessage; + var CustomerStatusUpdateMessage = function () { + function CustomerStatusUpdateMessage(message) { + this.messageName = "CustomerStatusUpdateMessage"; + this.serviceStatus = message.serviceStatus; + this.sid = message.sid; + } + CustomerStatusUpdateMessage.obtain = function () { + return null; + }; + CustomerStatusUpdateMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return CustomerStatusUpdateMessage; + }(); + RongIMLib.CustomerStatusUpdateMessage = CustomerStatusUpdateMessage; + var HandShakeMessage = function () { + function HandShakeMessage(message) { + this.messageName = "HandShakeMessage"; + message && (this.groupid = message.groupid); + } + HandShakeMessage.obtain = function () { + return null; + }; + HandShakeMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return HandShakeMessage; + }(); + RongIMLib.HandShakeMessage = HandShakeMessage; + var CustomerContact = function () { + function CustomerContact(message) { + this.messageName = "CustomerContact"; + this.page = message.page; + this.nickName = message.nickName; + this.routingInfo = message.routingInfo; + this.info = message.info; + this.requestInfo = message.requestInfo; + } + CustomerContact.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return CustomerContact; + }(); + RongIMLib.CustomerContact = CustomerContact; + var EvaluateMessage = function () { + function EvaluateMessage(message) { + this.messageName = "EvaluateMessage"; + this.uid = message.uid; + this.sid = message.sid; + this.pid = message.pid; + this.source = message.source; + this.suggest = message.suggest; + this.isresolve = message.isresolve; + this.type = message.type; + } + EvaluateMessage.obtain = function () { + return null; + }; + EvaluateMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return EvaluateMessage; + }(); + RongIMLib.EvaluateMessage = EvaluateMessage; + /** + * 客服握手响应消息的类型名 + */ + var HandShakeResponseMessage = function () { + function HandShakeResponseMessage(message) { + this.messageName = "HandShakeResponseMessage"; + this.msg = message.msg; + this.status = message.status; + this.data = message.data; + } + HandShakeResponseMessage.obtain = function () { + return null; + }; + HandShakeResponseMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return HandShakeResponseMessage; + }(); + RongIMLib.HandShakeResponseMessage = HandShakeResponseMessage; + var SuspendMessage = function () { + function SuspendMessage(message) { + this.messageName = "SuspendMessage"; + this.uid = message.uid; + this.sid = message.sid; + this.pid = message.pid; + } + SuspendMessage.obtain = function () { + return null; + }; + SuspendMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return SuspendMessage; + }(); + RongIMLib.SuspendMessage = SuspendMessage; + var TerminateMessage = function () { + function TerminateMessage(message) { + this.messageName = "TerminateMessage"; + this.code = message.code; + this.msg = message.msg; + this.sid = message.sid; + } + TerminateMessage.obtain = function () { + return null; + }; + TerminateMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return TerminateMessage; + }(); + RongIMLib.TerminateMessage = TerminateMessage; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var IsTypingStatusMessage = function () { + function IsTypingStatusMessage(data) { + this.messageName = "IsTypingStatusMessage"; + var msg = data; + } + IsTypingStatusMessage.prototype.encode = function () { + return undefined; + }; + IsTypingStatusMessage.prototype.getMessage = function () { + return null; + }; + return IsTypingStatusMessage; + }(); + RongIMLib.IsTypingStatusMessage = IsTypingStatusMessage; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var InformationNotificationMessage = function () { + function InformationNotificationMessage(message) { + this.messageName = "InformationNotificationMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> InformationNotificationMessage."); + } + this.message = message.message; + this.extra = message.extra; + if (message.user) { + this.user = message.user; + } + } + InformationNotificationMessage.obtain = function (message) { + return new InformationNotificationMessage({ + message: message, + extra: "" + }); + }; + InformationNotificationMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return InformationNotificationMessage; + }(); + RongIMLib.InformationNotificationMessage = InformationNotificationMessage; + var CommandMessage = function () { + function CommandMessage(message) { + this.messageName = "CommandMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> CommandMessage."); + } + try { + if (Object.prototype.toString.call(message.data) == "[object String]") { + this.data = JSON.parse(message.data); + } else { + this.data = message.data; + } + } catch (e) { + this.data = message.data; + } + this.name = message.name; + this.extra = message.extra; + } + CommandMessage.obtain = function (data) { + return new CommandMessage({ + data: data, + extra: "" + }); + }; + CommandMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return CommandMessage; + }(); + RongIMLib.CommandMessage = CommandMessage; + var ContactNotificationMessage = function () { + function ContactNotificationMessage(message) { + this.messageName = "ContactNotificationMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> ContactNotificationMessage."); + } + this.operation = message.operation; + this.targetUserId = message.targetUserId; + this.message = message.message; + this.extra = message.extra; + this.sourceUserId = message.sourceUserId; + if (message.user) { + this.user = message.user; + } + } + ContactNotificationMessage.obtain = function (operation, sourceUserId, targetUserId, message) { + return new InformationNotificationMessage({ + operation: operation, + sourceUserId: sourceUserId, + targetUserId: targetUserId, + message: message + }); + }; + ContactNotificationMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + ContactNotificationMessage.CONTACT_OPERATION_ACCEPT_RESPONSE = "ContactOperationAcceptResponse"; + ContactNotificationMessage.CONTACT_OPERATION_REJECT_RESPONSE = "ContactOperationRejectResponse"; + ContactNotificationMessage.CONTACT_OPERATION_REQUEST = "ContactOperationRequest"; + return ContactNotificationMessage; + }(); + RongIMLib.ContactNotificationMessage = ContactNotificationMessage; + var ProfileNotificationMessage = function () { + function ProfileNotificationMessage(message) { + this.messageName = "ProfileNotificationMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> ProfileNotificationMessage."); + } + this.operation = message.operation; + try { + if (Object.prototype.toString.call(message.data) == "[object String]") { + this.data = JSON.parse(message.data); + } else { + this.data = message.data; + } + } catch (e) { + this.data = message.data; + } + this.extra = message.extra; + if (message.user) { + this.user = message.user; + } + } + ProfileNotificationMessage.obtain = function (operation, data) { + return new ProfileNotificationMessage({ + operation: operation, + data: data + }); + }; + ProfileNotificationMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return ProfileNotificationMessage; + }(); + RongIMLib.ProfileNotificationMessage = ProfileNotificationMessage; + var CommandNotificationMessage = function () { + function CommandNotificationMessage(message) { + this.messageName = "CommandNotificationMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> ProfileNotificationMessage."); + } + try { + if (Object.prototype.toString.call(message.data) == "[object String]") { + this.data = JSON.parse(message.data); + } else { + this.data = message.data; + } + } catch (e) { + this.data = message.data; + } + this.name = message.name; + this.extra = message.extra; + if (message.user) { + this.user = message.user; + } + } + CommandNotificationMessage.obtain = function (name, data) { + return new CommandNotificationMessage({ + name: name, + data: data, + extra: "" + }); + }; + CommandNotificationMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return CommandNotificationMessage; + }(); + RongIMLib.CommandNotificationMessage = CommandNotificationMessage; + var DiscussionNotificationMessage = function () { + function DiscussionNotificationMessage(message) { + this.messageName = "DiscussionNotificationMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> DiscussionNotificationMessage."); + } + this.extra = message.extra; + this.extension = message.extension; + this.type = message.type; + this.isHasReceived = message.isHasReceived; + this.operation = message.operation; + this.user = message.user; + if (message.user) { + this.user = message.user; + } + } + DiscussionNotificationMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return DiscussionNotificationMessage; + }(); + RongIMLib.DiscussionNotificationMessage = DiscussionNotificationMessage; + var GroupNotificationMessage = function () { + function GroupNotificationMessage(msg) { + this.messageName = "GroupNotificationMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> GroupNotificationMessage."); + } + msg.operatorUserId && (this.operatorUserId = msg.operatorUserId); + msg.operation && (this.operation = msg.operation); + msg.data && (this.data = msg.data); + msg.message && (this.message = msg.message); + } + GroupNotificationMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return GroupNotificationMessage; + }(); + RongIMLib.GroupNotificationMessage = GroupNotificationMessage; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var TextMessage = function () { + function TextMessage(message) { + this.messageName = "TextMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> TextMessage."); + } + this.content = message.content; + this.extra = message.extra; + if (message.user) { + this.user = message.user; + } + if (message.mentionedInfo) { + this.mentionedInfo = message.mentionedInfo; + } + } + TextMessage.obtain = function (text) { + return new TextMessage({ + extra: "", + content: text + }); + }; + TextMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return TextMessage; + }(); + RongIMLib.TextMessage = TextMessage; + var TypingStatusMessage = function () { + function TypingStatusMessage(message) { + this.messageName = "TypingStatusMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> TypingStatusMessage."); + } + this.typingContentType = message.typingContentType; + this.data = message.data; + } + TypingStatusMessage.obtain = function (typingContentType, data) { + return new TypingStatusMessage({ + typingContentType: typingContentType, + data: data + }); + }; + TypingStatusMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return TypingStatusMessage; + }(); + RongIMLib.TypingStatusMessage = TypingStatusMessage; + var ReadReceiptMessage = function () { + function ReadReceiptMessage(message) { + this.messageName = "ReadReceiptMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> ReadReceiptMessage."); + } + this.lastMessageSendTime = message.lastMessageSendTime; + this.messageUId = message.messageUId; + this.type = message.type; + } + ReadReceiptMessage.obtain = function (messageUId, lastMessageSendTime, type) { + return new ReadReceiptMessage({ + messageUId: messageUId, + lastMessageSendTime: lastMessageSendTime, + type: type + }); + }; + ReadReceiptMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return ReadReceiptMessage; + }(); + RongIMLib.ReadReceiptMessage = ReadReceiptMessage; + var VoiceMessage = function () { + function VoiceMessage(message) { + this.messageName = "VoiceMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> VoiceMessage."); + } + this.content = message.content; + this.duration = message.duration; + this.extra = message.extra; + if (message.user) { + this.user = message.user; + } + if (message.mentionedInfo) { + this.mentionedInfo = message.mentionedInfo; + } + } + VoiceMessage.obtain = function (base64Content, duration) { + return new VoiceMessage({ + content: base64Content, + duration: duration, + extra: "" + }); + }; + VoiceMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return VoiceMessage; + }(); + RongIMLib.VoiceMessage = VoiceMessage; + var RecallCommandMessage = function () { + function RecallCommandMessage(message) { + this.messageName = "RecallCommandMessage"; + this.messageUId = message.messageUId; + this.conversationType = message.conversationType; + this.targetId = message.targetId; + this.sentTime = message.sentTime; + message.extra && (this.extra = message.extra); + message.user && (this.user = message.user); + } + RecallCommandMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return RecallCommandMessage; + }(); + RongIMLib.RecallCommandMessage = RecallCommandMessage; + var ImageMessage = function () { + function ImageMessage(message) { + this.messageName = "ImageMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> ImageMessage."); + } + this.content = message.content; + this.imageUri = message.imageUri; + message.extra && (this.extra = message.extra); + message.user && (this.user = message.user); + if (message.mentionedInfo) { + this.mentionedInfo = message.mentionedInfo; + } + } + ImageMessage.obtain = function (content, imageUri) { + return new ImageMessage({ + content: content, + imageUri: imageUri, + extra: "" + }); + }; + ImageMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return ImageMessage; + }(); + RongIMLib.ImageMessage = ImageMessage; + var LocationMessage = function () { + function LocationMessage(message) { + this.messageName = "LocationMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> LocationMessage."); + } + this.latitude = message.latitude; + this.longitude = message.longitude; + this.poi = message.poi; + this.content = message.content; + this.extra = message.extra; + if (message.user) { + this.user = message.user; + } + if (message.mentionedInfo) { + this.mentionedInfo = message.mentionedInfo; + } + } + LocationMessage.obtain = function (latitude, longitude, poi, content) { + return new LocationMessage({ + latitude: latitude, + longitude: longitude, + poi: poi, + content: content, + extra: "" + }); + }; + LocationMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return LocationMessage; + }(); + RongIMLib.LocationMessage = LocationMessage; + var RichContentMessage = function () { + function RichContentMessage(message) { + this.messageName = "RichContentMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> RichContentMessage."); + } + this.title = message.title; + this.content = message.content; + this.imageUri = message.imageUri; + this.extra = message.extra; + this.url = message.url; + if (message.user) { + this.user = message.user; + } + } + RichContentMessage.obtain = function (title, content, imageUri, url) { + return new RichContentMessage({ + title: title, + content: content, + imageUri: imageUri, + url: url, + extra: "" + }); + }; + RichContentMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return RichContentMessage; + }(); + RongIMLib.RichContentMessage = RichContentMessage; + var JrmfReadPacketMessage = function () { + function JrmfReadPacketMessage(message) { + this.messageName = 'JrmfReadPacketMessage'; + message && (this.message = message); + } + JrmfReadPacketMessage.prototype.encode = function () { + return ""; + }; + return JrmfReadPacketMessage; + }(); + RongIMLib.JrmfReadPacketMessage = JrmfReadPacketMessage; + var JrmfReadPacketOpenedMessage = function () { + function JrmfReadPacketOpenedMessage(message) { + this.messageName = 'JrmfReadPacketOpenedMessage'; + message && (this.message = message); + } + JrmfReadPacketOpenedMessage.prototype.encode = function () { + return ""; + }; + return JrmfReadPacketOpenedMessage; + }(); + RongIMLib.JrmfReadPacketOpenedMessage = JrmfReadPacketOpenedMessage; + var UnknownMessage = function () { + function UnknownMessage(message) { + this.messageName = "UnknownMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> UnknownMessage."); + } + this.message = message; + } + UnknownMessage.prototype.encode = function () { + return ""; + }; + return UnknownMessage; + }(); + RongIMLib.UnknownMessage = UnknownMessage; + var PublicServiceCommandMessage = function () { + function PublicServiceCommandMessage(message) { + this.messageName = "PublicServiceCommandMessage"; + if (arguments.length == 0) { + throw new Error("Can not instantiate with empty parameters, use obtain method instead -> PublicServiceCommandMessage."); + } + this.content = message.content; + this.extra = message.extra; + this.menuItem = message.menuItem; + if (message.user) { + this.user = message.user; + } + if (message.mentionedInfo) { + this.mentionedInfo = message.mentionedInfo; + } + } + PublicServiceCommandMessage.obtain = function (item) { + return new PublicServiceCommandMessage({ + content: "", + command: "", + menuItem: item, + extra: "" + }); + }; + PublicServiceCommandMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return PublicServiceCommandMessage; + }(); + RongIMLib.PublicServiceCommandMessage = PublicServiceCommandMessage; + var PublicServiceMultiRichContentMessage = function () { + function PublicServiceMultiRichContentMessage(messages) { + this.messageName = "PublicServiceMultiRichContentMessage"; + this.richContentMessages = messages; + } + PublicServiceMultiRichContentMessage.prototype.encode = function () { + return null; + }; + return PublicServiceMultiRichContentMessage; + }(); + RongIMLib.PublicServiceMultiRichContentMessage = PublicServiceMultiRichContentMessage; + var SyncReadStatusMessage = function () { + function SyncReadStatusMessage(message) { + this.messageName = "SyncReadStatusMessage"; + message.lastMessageSendTime && (this.lastMessageSendTime = message.lastMessageSendTime); + } + SyncReadStatusMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return SyncReadStatusMessage; + }(); + RongIMLib.SyncReadStatusMessage = SyncReadStatusMessage; + var ReadReceiptRequestMessage = function () { + function ReadReceiptRequestMessage(message) { + this.messageName = "ReadReceiptRequestMessage"; + message.messageUId && (this.messageUId = message.messageUId); + } + ReadReceiptRequestMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return ReadReceiptRequestMessage; + }(); + RongIMLib.ReadReceiptRequestMessage = ReadReceiptRequestMessage; + var ReadReceiptResponseMessage = function () { + function ReadReceiptResponseMessage(message) { + this.messageName = "ReadReceiptResponseMessage"; + message.receiptMessageDic && (this.receiptMessageDic = message.receiptMessageDic); + } + ReadReceiptResponseMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return ReadReceiptResponseMessage; + }(); + RongIMLib.ReadReceiptResponseMessage = ReadReceiptResponseMessage; + var PublicServiceRichContentMessage = function () { + function PublicServiceRichContentMessage(message) { + this.messageName = "PublicServiceRichContentMessage"; + this.richContentMessage = message; + } + PublicServiceRichContentMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return PublicServiceRichContentMessage; + }(); + RongIMLib.PublicServiceRichContentMessage = PublicServiceRichContentMessage; + var FileMessage = function () { + function FileMessage(message) { + this.messageName = "FileMessage"; + message.name && (this.name = message.name); + message.size && (this.size = message.size); + message.type && (this.type = message.type); + message.fileUrl && (this.fileUrl = message.fileUrl); + message.extra && (this.extra = message.extra); + message.user && (this.user = message.user); + } + FileMessage.obtain = function (msg) { + return new FileMessage({ + name: msg.name, + size: msg.size, + type: msg.type, + fileUrl: msg.fileUrl + }); + }; + FileMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return FileMessage; + }(); + RongIMLib.FileMessage = FileMessage; + var AcceptMessage = function () { + function AcceptMessage(message) { + this.messageName = "AcceptMessage"; + this.callId = message.callId; + this.mediaType = message.mediaType; + } + AcceptMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return AcceptMessage; + }(); + RongIMLib.AcceptMessage = AcceptMessage; + var RingingMessage = function () { + function RingingMessage(message) { + this.messageName = "RingingMessage"; + this.callId = message.callId; + } + RingingMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return RingingMessage; + }(); + RongIMLib.RingingMessage = RingingMessage; + var SummaryMessage = function () { + function SummaryMessage(message) { + this.messageName = "SummaryMessage"; + this.caller = message.caller; + this.inviter = message.inviter; + this.mediaType = message.mediaType; + this.memberIdList = message.memberIdList; + this.startTime = message.startTime; + this.connectedTime = message.connectedTime; + this.duration = message.duration; + this.status = message.status; + } + SummaryMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return SummaryMessage; + }(); + RongIMLib.SummaryMessage = SummaryMessage; + var HungupMessage = function () { + function HungupMessage(message) { + this.messageName = "HungupMessage"; + this.callId = message.callId; + this.reason = message.reason; + } + HungupMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return HungupMessage; + }(); + RongIMLib.HungupMessage = HungupMessage; + var InviteMessage = function () { + function InviteMessage(message) { + this.messageName = "InviteMessage"; + this.callId = message.callId; + this.engineType = message.engineType; + this.channelInfo = message.channelInfo; + this.mediaType = message.mediaType; + this.extra = message.extra; + this.inviteUserIds = message.inviteUserIds; + } + InviteMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return InviteMessage; + }(); + RongIMLib.InviteMessage = InviteMessage; + var MediaModifyMessage = function () { + function MediaModifyMessage(message) { + this.messageName = "MediaModifyMessage"; + this.callId = message.callId; + this.mediaType = message.mediaType; + } + MediaModifyMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return MediaModifyMessage; + }(); + RongIMLib.MediaModifyMessage = MediaModifyMessage; + var MemberModifyMessage = function () { + function MemberModifyMessage(message) { + this.messageName = "MemberModifyMessage"; + this.modifyMemType = message.modifyMemType; + this.callId = message.callId; + this.caller = message.caller; + this.engineType = message.engineType; + this.channelInfo = message.channelInfo; + this.mediaType = message.mediaType; + this.extra = message.extra; + this.inviteUserIds = message.inviteUserIds; + this.existedMemberStatusList = message.existedMemberStatusList; + } + MemberModifyMessage.prototype.encode = function () { + return JSON.stringify(RongIMLib.ModelUtil.modelClone(this)); + }; + return MemberModifyMessage; + }(); + RongIMLib.MemberModifyMessage = MemberModifyMessage; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var ChannelInfo = function () { + function ChannelInfo(Id, Key) { + this.Id = Id; + this.Key = Key; + } + return ChannelInfo; + }(); + RongIMLib.ChannelInfo = ChannelInfo; + var UserStatus = function () { + function UserStatus(platform, online, status) { + this.platform = platform; + this.online = online; + this.status = status; + } + return UserStatus; + }(); + RongIMLib.UserStatus = UserStatus; + var MentionedInfo = function () { + function MentionedInfo(type, userIdList, mentionedContent) {} + return MentionedInfo; + }(); + RongIMLib.MentionedInfo = MentionedInfo; + var DeleteMessage = function () { + function DeleteMessage(msgId, msgDataTime, direct) { + this.msgId = msgId; + this.msgDataTime = msgDataTime; + this.direct = direct; + } + return DeleteMessage; + }(); + RongIMLib.DeleteMessage = DeleteMessage; + var CustomServiceConfig = function () { + function CustomServiceConfig(isBlack, companyName, companyUrl) {} + return CustomServiceConfig; + }(); + RongIMLib.CustomServiceConfig = CustomServiceConfig; + var CustomServiceSession = function () { + function CustomServiceSession(uid, cid, pid, isQuited, type, adminHelloWord, adminOfflineWord) {} + return CustomServiceSession; + }(); + RongIMLib.CustomServiceSession = CustomServiceSession; + var Conversation = function () { + function Conversation(conversationTitle, conversationType, draft, isTop, latestMessage, latestMessageId, notificationStatus, objectName, receivedStatus, receivedTime, senderUserId, senderUserName, sentStatus, sentTime, targetId, unreadMessageCount, senderPortraitUri, isHidden, mentionedMsg, hasUnreadMention) { + this.conversationTitle = conversationTitle; + this.conversationType = conversationType; + this.draft = draft; + this.isTop = isTop; + this.latestMessage = latestMessage; + this.latestMessageId = latestMessageId; + this.notificationStatus = notificationStatus; + this.objectName = objectName; + this.receivedStatus = receivedStatus; + this.receivedTime = receivedTime; + this.senderUserId = senderUserId; + this.senderUserName = senderUserName; + this.sentStatus = sentStatus; + this.sentTime = sentTime; + this.targetId = targetId; + this.unreadMessageCount = unreadMessageCount; + this.senderPortraitUri = senderPortraitUri; + this.isHidden = isHidden; + this.mentionedMsg = mentionedMsg; + this.hasUnreadMention = hasUnreadMention; + } + Conversation.prototype.setTop = function () { + RongIMLib.RongIMClient._dataAccessProvider.addConversation(this, { + onSuccess: function (data) {} + }); + }; + return Conversation; + }(); + RongIMLib.Conversation = Conversation; + var Discussion = function () { + function Discussion(creatorId, id, memberIdList, name, isOpen) { + this.creatorId = creatorId; + this.id = id; + this.memberIdList = memberIdList; + this.name = name; + this.isOpen = isOpen; + } + return Discussion; + }(); + RongIMLib.Discussion = Discussion; + var Group = function () { + function Group(id, name, portraitUri) { + this.id = id; + this.name = name; + this.portraitUri = portraitUri; + } + return Group; + }(); + RongIMLib.Group = Group; + var Message = function () { + function Message(content, conversationType, extra, objectName, messageDirection, messageId, receivedStatus, receivedTime, senderUserId, sentStatus, sentTime, targetId, messageType, messageUId, isLocalMessage, offLineMessage, receiptResponse) { + this.content = content; + this.conversationType = conversationType; + this.extra = extra; + this.objectName = objectName; + this.messageDirection = messageDirection; + this.messageId = messageId; + this.receivedStatus = receivedStatus; + this.receivedTime = receivedTime; + this.senderUserId = senderUserId; + this.sentStatus = sentStatus; + this.sentTime = sentTime; + this.targetId = targetId; + this.messageType = messageType; + this.messageUId = messageUId; + this.isLocalMessage = isLocalMessage; + this.offLineMessage = offLineMessage; + this.receiptResponse = receiptResponse; + } + return Message; + }(); + RongIMLib.Message = Message; + var MessageTag = function () { + function MessageTag(isCounted, isPersited) { + this.isCounted = isCounted; + this.isPersited = isPersited; + } + MessageTag.prototype.getMessageTag = function () { + if (this.isCounted && this.isPersited) { + return 3; + } else if (this.isCounted) { + return 2; + } else if (this.isPersited) { + return 1; + } else if (!this.isCounted && !this.isPersited) { + return 0; + } + }; + return MessageTag; + }(); + RongIMLib.MessageTag = MessageTag; + var PublicServiceMenuItem = function () { + function PublicServiceMenuItem(id, name, type, sunMenuItems, url) { + this.id = id; + this.name = name; + this.type = type; + this.sunMenuItems = sunMenuItems; + this.url = url; + } + return PublicServiceMenuItem; + }(); + RongIMLib.PublicServiceMenuItem = PublicServiceMenuItem; + // TODO: TBD + var PublicServiceProfile = function () { + function PublicServiceProfile(conversationType, introduction, menu, name, portraitUri, publicServiceId, hasFollowed, isGlobal) { + this.conversationType = conversationType; + this.introduction = introduction; + this.menu = menu; + this.name = name; + this.portraitUri = portraitUri; + this.publicServiceId = publicServiceId; + this.hasFollowed = hasFollowed; + this.isGlobal = isGlobal; + } + return PublicServiceProfile; + }(); + RongIMLib.PublicServiceProfile = PublicServiceProfile; + var UserInfo = function () { + function UserInfo(id, name, portraitUri) { + this.id = id; + this.name = name; + this.portraitUri = portraitUri; + } + return UserInfo; + }(); + RongIMLib.UserInfo = UserInfo; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var ServerDataProvider = function () { + function ServerDataProvider() {} + var RongIMClient = RongIMLib.RongIMClient; + var watcher = new tools.Watcher(); + var Conversation = { + watch: function (_watcher) { + watcher.add(_watcher); + var conversationList = RongIMClient._memoryStore.conversationList; + watcher.notify(conversationList); + }, + unwatch: function (_watcher) { + watcher.remove(_watcher); + }, + _notify: function (conversationList) { + watcher.notify(conversationList); + } + }; + ServerDataProvider.prototype.Conversation = Conversation; + ServerDataProvider.prototype.init = function (appKey) { + new RongIMLib.FeatureDectector(); + }; + ServerDataProvider.prototype.connect = function (token, callback) { + RongIMLib.RongIMClient.bridge = RongIMLib.Bridge.getInstance(); + RongIMLib.RongIMClient._memoryStore.token = token; + RongIMLib.RongIMClient._memoryStore.callback = callback; + var isConnecting = false, + isConnected = false; + if (RongIMLib.Bridge._client && RongIMLib.Bridge._client.channel) { + isConnecting = RongIMLib.Bridge._client.channel.connectionStatus == RongIMLib.ConnectionStatus.CONNECTING; + isConnected = RongIMLib.Bridge._client.channel.connectionStatus == RongIMLib.ConnectionStatus.CONNECTED; + } + if (isConnected || isConnecting) { + return; + } + //循环设置监听事件,追加之后清空存放事件数据 + for (var i = 0, len = RongIMLib.RongIMClient._memoryStore.listenerList.length; i < len; i++) { + RongIMLib.RongIMClient.bridge["setListener"](RongIMLib.RongIMClient._memoryStore.listenerList[i]); + } + RongIMLib.RongIMClient._memoryStore.listenerList.length = 0; + RongIMLib.RongIMClient.bridge.connect(RongIMLib.RongIMClient._memoryStore.appKey, token, { + onSuccess: function (data) { + setTimeout(function () { + callback.onSuccess(data); + }); + }, + onError: function (e) { + if (e == RongIMLib.ConnectionState.TOKEN_INCORRECT || !e) { + setTimeout(function () { + RongIMLib.Bridge._client.channel.connectionStatus = RongIMLib.ConnectionStatus.DISCONNECTED; + callback.onTokenIncorrect(); + }); + } else { + setTimeout(function () { + callback.onError(e); + }); + } + } + }); + }; + ServerDataProvider.prototype.reconnect = function (callback) { + RongIMLib.MessageIdHandler.clearMessageId(); + var token = RongIMLib.RongIMClient._memoryStore.token; + RongIMLib.RongIMClient.connect(token, callback); + }; + ServerDataProvider.prototype.logout = function () { + RongIMLib.RongIMClient.bridge.disconnect(); + RongIMLib.RongIMClient.bridge = null; + }; + ServerDataProvider.prototype.disconnect = function () { + if (RongIMLib.RongIMClient.bridge) { + RongIMLib.RongIMClient.bridge.disconnect(); + } + }; + ServerDataProvider.prototype.sendReceiptResponse = function (conversationType, targetId, sendCallback) { + var rspkey = RongIMLib.Bridge._client.userId + conversationType + targetId + 'RECEIVED', + me = this; + if (RongIMLib.MessageUtil.supportLargeStorage()) { + var valObj = JSON.parse(RongIMLib.RongIMClient._storageProvider.getItem(rspkey)); + if (valObj) { + var vals = []; + for (var key in valObj) { + var tmp = {}; + tmp[key] = valObj[key].uIds; + valObj[key].isResponse || vals.push(tmp); + } + if (vals.length == 0) { + sendCallback.onSuccess(); + return; + } + var interval = setInterval(function () { + if (vals.length == 1) { + clearInterval(interval); + } + var obj = vals.splice(0, 1)[0]; + var rspMsg = new RongIMLib.ReadReceiptResponseMessage({ + receiptMessageDic: obj + }); + me.sendMessage(conversationType, targetId, rspMsg, { + onSuccess: function (msg) { + var senderUserId = RongIMLib.MessageUtil.getFirstKey(obj); + valObj[senderUserId].isResponse = true; + RongIMLib.RongIMClient._storageProvider.setItem(rspkey, JSON.stringify(valObj)); + sendCallback.onSuccess(msg); + }, + onError: function (error, msg) { + sendCallback.onError(error, msg); + } + }); + }, 200); + } else { + sendCallback.onSuccess(); + } + } else { + sendCallback.onSuccess(); + } + }; + ServerDataProvider.prototype.sendTypingStatusMessage = function (conversationType, targetId, messageName, sendCallback) { + var me = this; + if (messageName in RongIMLib.RongIMClient.MessageParams) { + me.sendMessage(conversationType, targetId, RongIMLib.TypingStatusMessage.obtain(RongIMLib.RongIMClient.MessageParams[messageName].objectName, ""), { + onSuccess: function () { + setTimeout(function () { + sendCallback.onSuccess(); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + sendCallback.onError(errorCode, null); + }); + }, + onBefore: function () {} + }); + } + }; + ServerDataProvider.prototype.sendRecallMessage = function (content, sendMessageCallback) { + var msg = new RongIMLib.RecallCommandMessage({ + conversationType: content.conversationType, + targetId: content.targetId, + sentTime: content.sentTime, + messageUId: content.messageUId, + extra: content.extra, + user: content.user + }); + this.sendMessage(content.conversationType, content.senderUserId, msg, sendMessageCallback, false, null, null, 2); + }; + ServerDataProvider.prototype.sendTextMessage = function (conversationType, targetId, content, sendMessageCallback) { + var msgContent = RongIMLib.TextMessage.obtain(content); + this.sendMessage(conversationType, targetId, msgContent, sendMessageCallback); + }; + ServerDataProvider.prototype.getRemoteHistoryMessages = function (conversationType, targetId, timestamp, count, callback) { + if (count <= 1) { + throw new Error("the count must be greater than 1."); + } + var modules = new Modules.HistoryMessageInput(), + self = this; + modules.setTargetId(targetId); + if (timestamp === 0 || timestamp > 0) { + modules.setDataTime(timestamp); + } else { + modules.setDataTime(RongIMLib.RongIMClient._memoryStore.lastReadTime.get(conversationType + targetId)); + } + modules.setSize(count); + RongIMLib.RongIMClient.bridge.queryMsg(HistoryMsgType[conversationType], RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), targetId, { + onSuccess: function (data) { + var hasMore = data.hasMsg; + RongIMLib.RongIMClient._memoryStore.lastReadTime.set(conversationType + targetId, RongIMLib.MessageUtil.int64ToTimestamp(data.syncTime)); + var list = data.list.reverse(), + tempMsg = null, + tempDir; + if (RongIMLib.MessageUtil.supportLargeStorage()) { + for (var i = 0, len = list.length; i < len; i++) { + tempMsg = RongIMLib.MessageUtil.messageParser(list[i]); + var key = RongIMLib.Bridge._client.userId + tempMsg.messageUId + "SENT"; + var data = RongIMLib.RongIMClient._storageProvider.getItem(key); + if (tempDir) { + tempDir = JSON.parse(data); + tempMsg.receiptResponse || (tempMsg.receiptResponse = {}); + tempMsg.receiptResponse[tempMsg.messageUId] = tempDir.count; + } + if (!tempMsg.targetId) { + tempMsg.targetId = targetId; + } + list[i] = tempMsg; + } + } else { + for (var i = 0, len = list.length; i < len; i++) { + list[i] = RongIMLib.MessageUtil.messageParser(list[i]); + } + } + setTimeout(function () { + callback.onSuccess(list, hasMore); + }); + }, + onError: function (error) { + setTimeout(function () { + if (error === RongIMLib.ErrorCode.TIMEOUT) { + callback.onError(error); + } else { + callback.onSuccess([], false); + } + }); + } + }, "HistoryMessagesOuput"); + }; + ServerDataProvider.prototype.hasRemoteUnreadMessages = function (token, callback) { + // window.RCCallback = function (x) { + + // xss.parentNode.removeChild(xss); + // }; + + var url = RongIMLib.RongIMClient._memoryStore.depend.api + "/message/exist.js?appKey=" + encodeURIComponent(RongIMLib.RongIMClient._memoryStore.appKey) + "&token=" + encodeURIComponent(token) + "&callBack=RCCallback&_=" + Date.now(); + tools.request({ + url: url, + //仅为示例,并非真实的接口地址 + // method : method, //get + data: { + t: Math.random() + } + }, { + success: function () { + setTimeout(function () { + callback.onSuccess(!!+x.status); + }); + }, + fail: function () { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.UNKNOWN); + }); + } + }); + }; + ServerDataProvider.prototype.getRemoteConversationList = function (callback, conversationTypes, count) { + var modules = new Modules.RelationsInput(), + self = this; + modules.setType(1); + if (typeof count == 'undefined') { + modules.setCount(0); + } else { + modules.setCount(count); + } + RongIMLib.RongIMClient.bridge.queryMsg(26, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, { + onSuccess: function (list) { + if (list.info) { + list.info = list.info.reverse(); + for (var i = 0, len = list.info.length; i < len; i++) { + RongIMLib.RongIMClient.getInstance().pottingConversation(list.info[i]); + } + } + if (conversationTypes) { + var convers = []; + Array.forEach(conversationTypes, function (converType) { + Array.forEach(RongIMLib.RongIMClient._memoryStore.conversationList, function (item) { + if (item.conversationType == converType) { + convers.push(item); + } + }); + }); + callback.onSuccess(RongIMLib.RongIMClient._memoryStore.conversationList); + } else { + callback.onSuccess(RongIMLib.RongIMClient._memoryStore.conversationList); + } + }, + onError: function (error) { + if (error === RongIMLib.ErrorCode.TIMEOUT) { + callback.onError(error); + } else { + callback.onSuccess([]); + } + } + }, "RelationsOutput"); + }; + ServerDataProvider.prototype.addMemberToDiscussion = function (discussionId, userIdList, callback) { + var modules = new Modules.ChannelInvitationInput(); + modules.setUsers(userIdList); + RongIMLib.RongIMClient.bridge.queryMsg(0, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), discussionId, { + onSuccess: function () { + setTimeout(function () { + callback.onSuccess(); + }); + }, + onError: function () { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.JOIN_IN_DISCUSSION); + }); + } + }); + }; + ServerDataProvider.prototype.createDiscussion = function (name, userIdList, callback) { + var modules = new Modules.CreateDiscussionInput(), + self = this; + modules.setName(name); + RongIMLib.RongIMClient.bridge.queryMsg(1, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, { + onSuccess: function (discussId) { + if (userIdList.length > 0) { + self.addMemberToDiscussion(discussId, userIdList, { + onSuccess: function () {}, + onError: function (error) { + setTimeout(function () { + callback.onError(error); + }); + } + }); + } + setTimeout(function () { + callback.onSuccess(discussId); + }); + }, + onError: function () { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.CREATE_DISCUSSION); + }); + } + }, "CreateDiscussionOutput"); + }; + ServerDataProvider.prototype.getDiscussion = function (discussionId, callback) { + var modules = new Modules.ChannelInfoInput(); + modules.setNothing(1); + RongIMLib.RongIMClient.bridge.queryMsg(4, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), discussionId, { + onSuccess: function (data) { + setTimeout(function () { + callback.onSuccess(data); + }); + }, + onError: function (errorCode) { + setTimeout(function () { + callback.onError(errorCode); + }); + } + }, "ChannelInfoOutput"); + }; + ServerDataProvider.prototype.quitDiscussion = function (discussionId, callback) { + var modules = new Modules.LeaveChannelInput(); + modules.setNothing(1); + RongIMLib.RongIMClient.bridge.queryMsg(7, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), discussionId, callback); + }; + ServerDataProvider.prototype.removeMemberFromDiscussion = function (discussionId, userId, callback) { + var modules = new Modules.ChannelEvictionInput(); + modules.setUser(userId); + RongIMLib.RongIMClient.bridge.queryMsg(9, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), discussionId, callback); + }; + ServerDataProvider.prototype.setDiscussionInviteStatus = function (discussionId, status, callback) { + var modules = new Modules.ModifyPermissionInput(); + modules.setOpenStatus(status.valueOf()); + RongIMLib.RongIMClient.bridge.queryMsg(11, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), discussionId, { + onSuccess: function (x) { + setTimeout(function () { + callback.onSuccess(); + }); + }, + onError: function () { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.INVITE_DICUSSION); + }); + } + }); + }; + ServerDataProvider.prototype.setDiscussionName = function (discussionId, name, callback) { + var modules = new Modules.RenameChannelInput(); + modules.setName(name); + RongIMLib.RongIMClient.bridge.queryMsg(12, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), discussionId, { + onSuccess: function () { + setTimeout(function () { + callback.onSuccess(); + }); + }, + onError: function (errcode) { + callback.onError(errcode); + } + }); + }; + ServerDataProvider.prototype.joinGroup = function (groupId, groupName, callback) { + var modules = new Modules.GroupInfo(); + modules.setId(groupId); + modules.setName(groupName); + var _mod = new Modules.GroupInput(); + _mod.setGroupInfo([modules]); + RongIMLib.RongIMClient.bridge.queryMsg(6, RongIMLib.MessageUtil.ArrayForm(_mod.toArrayBuffer()), groupId, { + onSuccess: function () { + setTimeout(function () { + callback.onSuccess(); + }); + }, + onError: function (errcode) { + callback.onError(errcode); + } + }, "GroupOutput"); + }; + ServerDataProvider.prototype.quitGroup = function (groupId, callback) { + var modules = new Modules.LeaveChannelInput(); + modules.setNothing(1); + RongIMLib.RongIMClient.bridge.queryMsg(8, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), groupId, { + onSuccess: function () { + setTimeout(function () { + callback.onSuccess(); + }); + }, + onError: function (errcode) { + callback.onError(errcode); + } + }); + }; + ServerDataProvider.prototype.syncGroup = function (groups, callback) { + //去重操作 + for (var i = 0, part = [], info = [], len = groups.length; i < len; i++) { + if (part.length === 0 || !(groups[i].id in part)) { + part.push(groups[i].id); + var groupinfo = new Modules.GroupInfo(); + groupinfo.setId(groups[i].id); + groupinfo.setName(groups[i].name); + info.push(groupinfo); + } + } + var modules = new Modules.GroupHashInput(); + modules.setUserId(RongIMLib.Bridge._client.userId); + modules.setGroupHashCode(md5(part.sort().join(""))); + RongIMLib.RongIMClient.bridge.queryMsg(13, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, { + onSuccess: function (result) { + //1为群信息不匹配需要发送给服务器进行同步,0不需要同步 + if (result === 1) { + var val = new Modules.GroupInput(); + val.setGroupInfo(info); + RongIMLib.RongIMClient.bridge.queryMsg(20, RongIMLib.MessageUtil.ArrayForm(val.toArrayBuffer()), RongIMLib.Bridge._client.userId, { + onSuccess: function () { + setTimeout(function () { + callback.onSuccess(); + }); + }, + onError: function () { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.GROUP_MATCH_ERROR); + }); + } + }, "GroupOutput"); + } else { + setTimeout(function () { + callback.onSuccess(); + }); + } + }, + onError: function () { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.GROUP_SYNC_ERROR); + }); + } + }, "GroupHashOutput"); + }; + ServerDataProvider.prototype.joinChatRoom = function (chatroomId, messageCount, callback) { + var e = new Modules.ChrmInput(); + e.setNothing(1); + RongIMLib.Bridge._client.chatroomId = chatroomId; + RongIMLib.RongIMClient.bridge.queryMsg(19, RongIMLib.MessageUtil.ArrayForm(e.toArrayBuffer()), chatroomId, { + onSuccess: function () { + callback.onSuccess(); + var modules = new Modules.ChrmPullMsg(); + messageCount == 0 && (messageCount = -1); + modules.setCount(messageCount); + modules.setSyncTime(0); + RongIMLib.Bridge._client.queryMessage("chrmPull", RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), chatroomId, 1, { + onSuccess: function (collection) { + var sync = RongIMLib.MessageUtil.int64ToTimestamp(collection.syncTime); + RongIMLib.RongIMClient._memoryStore.lastReadTime.set(chatroomId + RongIMLib.Bridge._client.userId + "CST", sync); + var list = collection.list; + if (RongIMLib.RongIMClient._memoryStore.filterMessages.length > 0) { + for (var i = 0, mlen = list.length; i < mlen; i++) { + for (var j = 0, flen = RongIMLib.RongIMClient._memoryStore.filterMessages.length; j < flen; j++) { + if (RongIMLib.RongIMClient.MessageParams[RongIMLib.RongIMClient._memoryStore.filterMessages[j]].objectName != list[i].classname) { + RongIMLib.Bridge._client.handler.onReceived(list[i]); + } + } + } + } else { + for (var i = 0, len = list.length; i < len; i++) { + RongIMLib.Bridge._client.handler.onReceived(list[i]); + } + } + }, + onError: function (x) { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.CHATROOM_HISMESSAGE_ERROR); + }); + } + }, "DownStreamMessages"); + }, + onError: function () { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.CHARTOOM_JOIN_ERROR); + }); + } + }, "ChrmOutput"); + }; + ServerDataProvider.prototype.getChatRoomInfo = function (chatRoomId, count, order, callback) { + var modules = new Modules.QueryChatroomInfoInput(); + modules.setCount(count); + modules.setOrder(order); + RongIMLib.RongIMClient.bridge.queryMsg("queryChrmI", RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), chatRoomId, { + onSuccess: function (list) { + var userInfos = list.userInfos; + userInfos.forEach(function (item) { + item.time = RongIMLib.MessageUtil.int64ToTimestamp(item.time); + }); + setTimeout(function () { + callback.onSuccess(list); + }); + }, + onError: function (errcode) { + callback.onError(errcode); + } + }, "QueryChatroomInfoOutput"); + }; + ServerDataProvider.prototype.quitChatRoom = function (chatroomId, callback) { + var e = new Modules.ChrmInput(); + e.setNothing(1); + RongIMLib.RongIMClient.bridge.queryMsg(17, RongIMLib.MessageUtil.ArrayForm(e.toArrayBuffer()), chatroomId, { + onSuccess: function () { + setTimeout(function () { + callback.onSuccess(); + }); + }, + onError: function (errcode) { + callback.onError(errcode); + } + }, "ChrmOutput"); + }; + ServerDataProvider.prototype.setChatroomHisMessageTimestamp = function (chatRoomId, timestamp) { + RongIMLib.RongIMClient._memoryStore.lastReadTime.set('chrhis_' + chatRoomId, timestamp); + }; + ServerDataProvider.prototype.getChatRoomHistoryMessages = function (chatRoomId, count, order, callback) { + var modules = new Modules.HistoryMsgInput(); + modules.setTargetId(chatRoomId); + var timestamp = RongIMLib.RongIMClient._memoryStore.lastReadTime.get('chrhis_' + chatRoomId) || 0; + modules.setTime(timestamp); + modules.setCount(count); + modules.setOrder(order); + RongIMLib.RongIMClient.bridge.queryMsg(34, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, { + onSuccess: function (data) { + RongIMLib.RongIMClient._memoryStore.lastReadTime.set('chrhis_' + chatRoomId, RongIMLib.MessageUtil.int64ToTimestamp(data.syncTime)); + var list = data.list.reverse(); + for (var i = 0, len = list.length; i < len; i++) { + list[i] = RongIMLib.MessageUtil.messageParser(list[i]); + } + setTimeout(function () { + callback.onSuccess(list, !!data.hasMsg); + }); + }, + onError: function (error) { + setTimeout(function () { + if (error === RongIMLib.ErrorCode.TIMEOUT) { + callback.onError(error); + } else { + callback.onSuccess([], false); + } + }); + } + }, "HistoryMsgOuput"); + }; + ServerDataProvider.prototype.setMessageStatus = function (conversationType, targetId, timestamp, status, callback) { + callback.onSuccess(true); + }; + ServerDataProvider.prototype.addToBlacklist = function (userId, callback) { + var modules = new Modules.Add2BlackListInput(); + modules.setUserId(userId); + RongIMLib.RongIMClient.bridge.queryMsg(21, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), userId, { + onSuccess: function () { + callback.onSuccess(); + }, + onError: function () { + callback.onError(RongIMLib.ErrorCode.BLACK_ADD_ERROR); + } + }); + }; + ServerDataProvider.prototype.getBlacklist = function (callback) { + var modules = new Modules.QueryBlackListInput(); + modules.setNothing(1); + RongIMLib.RongIMClient.bridge.queryMsg(23, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, callback, "QueryBlackListOutput"); + }; + ServerDataProvider.prototype.getBlacklistStatus = function (userId, callback) { + var modules = new Modules.BlackListStatusInput(); + modules.setUserId(userId); + RongIMLib.RongIMClient.bridge.queryMsg(24, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), userId, { + onSuccess: function (status) { + setTimeout(function () { + callback.onSuccess(RongIMLib.BlacklistStatus[status]); + }); + }, + onError: function () { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.BLACK_GETSTATUS_ERROR); + }); + } + }); + }; + ServerDataProvider.prototype.removeFromBlacklist = function (userId, callback) { + var modules = new Modules.RemoveFromBlackListInput(); + modules.setUserId(userId); + RongIMLib.RongIMClient.bridge.queryMsg(22, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), userId, { + onSuccess: function () { + callback.onSuccess(); + }, + onError: function () { + callback.onError(RongIMLib.ErrorCode.BLACK_REMOVE_ERROR); + } + }); + }; + ServerDataProvider.prototype.getFileToken = function (fileType, callback) { + if (!/(1|2|3|4)/.test(fileType.toString())) { + callback.onError(RongIMLib.ErrorCode.QNTKN_FILETYPE_ERROR); + return; + } + var modules = new Modules.GetQNupTokenInput(); + modules.setType(fileType); + RongIMLib.RongIMClient.bridge.queryMsg(30, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, { + onSuccess: function (data) { + setTimeout(function () { + callback.onSuccess(data); + }); + }, + onError: function (errcode) { + callback.onError(errcode); + } + }, "GetQNupTokenOutput"); + }; + ServerDataProvider.prototype.getFileUrl = function (fileType, fileName, oriName, callback) { + if (!/(1|2|3|4)/.test(fileType.toString())) { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.QNTKN_FILETYPE_ERROR); + }); + return; + } + var modules = new Modules.GetQNdownloadUrlInput(); + modules.setType(fileType); + modules.setKey(fileName); + if (oriName) { + modules.setFileName(oriName); + } + RongIMLib.RongIMClient.bridge.queryMsg(31, RongIMLib.MessageUtil.ArrayForm(modules.toArrayBuffer()), RongIMLib.Bridge._client.userId, { + onSuccess: function (data) { + setTimeout(function () { + callback.onSuccess(data); + }); + }, + onError: function (errcode) { + callback.onError(errcode); + } + }, "GetQNdownloadUrlOutput"); + }; + // methodType 1 : 多客服(客服后台使用); 2 : 消息撤回 + ServerDataProvider.prototype.sendMessage = function (conversationType, targetId, messageContent, sendCallback, mentiondMsg, pushText, appData, methodType) { + if (!RongIMLib.Bridge._client.channel) { + sendCallback.onError(RongIMLib.ErrorCode.RC_NET_UNAVAILABLE, null); + return; + } + var modules = new Modules.UpStreamMessage(); + if (mentiondMsg && (conversationType == RongIMLib.ConversationType.DISCUSSION || conversationType == RongIMLib.ConversationType.GROUP)) { + modules.setSessionId(7); + } else { + modules.setSessionId(RongIMLib.RongIMClient.MessageParams[messageContent.messageName].msgTag.getMessageTag()); + } + pushText && modules.setPushText(pushText); + appData && modules.setAppData(appData); + if ((conversationType == RongIMLib.ConversationType.DISCUSSION || conversationType == RongIMLib.ConversationType.GROUP) && messageContent.messageName == RongIMLib.RongIMClient.MessageType["ReadReceiptResponseMessage"]) { + var rspMsg = messageContent; + if (rspMsg.receiptMessageDic) { + var ids = []; + for (var key in rspMsg.receiptMessageDic) { + ids.push(key); + } + modules.setUserId(ids); + } + } + if ((conversationType == RongIMLib.ConversationType.DISCUSSION || conversationType == RongIMLib.ConversationType.GROUP) && messageContent.messageName == RongIMLib.RongIMClient.MessageType["SyncReadStatusMessage"]) { + modules.setUserId(RongIMLib.Bridge._client.userId); + } + modules.setClassname(RongIMLib.RongIMClient.MessageParams[messageContent.messageName].objectName); + modules.setContent(messageContent.encode()); + var content = modules.toArrayBuffer(); + if (Object.prototype.toString.call(content) == "[object ArrayBuffer]") { + content = [].slice.call(new Int8Array(content)); + } + var me = this, + msg = new RongIMLib.Message(); + var c = this.getConversation(conversationType, targetId); + if (RongIMLib.RongIMClient.MessageParams[messageContent.messageName].msgTag.getMessageTag() == 3) { + if (!c) { + c = RongIMLib.RongIMClient.getInstance().createConversation(conversationType, targetId, ""); + } + c.sentTime = new Date().getTime(); + c.sentStatus = RongIMLib.SentStatus.SENDING; + c.senderUserName = ""; + c.senderUserId = RongIMLib.Bridge._client.userId; + c.notificationStatus = RongIMLib.ConversationNotificationStatus.DO_NOT_DISTURB; + c.latestMessage = msg; + c.unreadMessageCount = 0; + RongIMLib.RongIMClient._dataAccessProvider.addConversation(c, { + onSuccess: function (data) {} + }); + } + RongIMLib.RongIMClient._memoryStore.converStore = c; + msg.content = messageContent; + msg.conversationType = conversationType; + msg.senderUserId = RongIMLib.Bridge._client.userId; + msg.objectName = RongIMLib.RongIMClient.MessageParams[messageContent.messageName].objectName; + msg.targetId = targetId; + msg.sentTime = new Date().getTime(); + msg.messageDirection = RongIMLib.MessageDirection.SEND; + msg.sentStatus = RongIMLib.SentStatus.SENT; + msg.messageType = messageContent.messageName; + RongIMLib.RongIMClient.bridge.pubMsg(conversationType.valueOf(), content, targetId, { + onSuccess: function (data) { + if ((conversationType == RongIMLib.ConversationType.DISCUSSION || conversationType == RongIMLib.ConversationType.GROUP) && messageContent.messageName == RongIMLib.RongIMClient.MessageType["ReadReceiptRequestMessage"]) { + var reqMsg = msg.content; + var sentkey = RongIMLib.Bridge._client.userId + reqMsg.messageUId + "SENT"; + RongIMLib.RongIMClient._storageProvider.setItem(sentkey, JSON.stringify({ + count: 0, + dealtime: data.timestamp, + userIds: {} + })); + } + if (RongIMLib.RongIMClient.MessageParams[msg.messageType].msgTag.getMessageTag() == 3) { + RongIMLib.RongIMClient._memoryStore.converStore.latestMessage = msg; + var RongIMClient = RongIMLib.RongIMClient; + var Conversation = RongIMClient._dataAccessProvider.Conversation; + Conversation._notify(RongIMClient._memoryStore.conversationList); + RongIMLib.RongIMClient._dataAccessProvider.addMessage(conversationType, targetId, msg, { + onSuccess: function (ret) { + msg = ret; + msg.messageUId = data.messageUId; + msg.sentTime = data.timestamp; + msg.sentStatus = RongIMLib.SentStatus.SENT; + msg.messageId = data.messageId; + RongIMLib.RongIMClient._dataAccessProvider.updateMessage(msg); + }, + onError: function () {} + }); + } + setTimeout(function () { + msg.sentTime = data.timestamp; + msg.messageUId = data.messageUId; + sendCallback.onSuccess(msg); + }); + }, + onError: function (errorCode) { + msg.sentStatus = RongIMLib.SentStatus.FAILED; + if (RongIMLib.RongIMClient.MessageParams[msg.messageType].msgTag.getMessageTag() == 3) { + RongIMLib.RongIMClient._memoryStore.converStore.latestMessage = msg; + } + RongIMLib.RongIMClient._dataAccessProvider.addMessage(conversationType, targetId, msg, { + onSuccess: function (ret) { + msg.messageId = ret.messageId; + RongIMLib.RongIMClient._dataAccessProvider.updateMessage(msg); + }, + onError: function () {} + }); + setTimeout(function () { + sendCallback.onError(errorCode, msg); + }); + } + }, null, methodType); + sendCallback.onBefore && sendCallback.onBefore(RongIMLib.MessageIdHandler.messageId); + msg.messageId = RongIMLib.MessageIdHandler.messageId + ""; + }; + ServerDataProvider.prototype.setConnectionStatusListener = function (listener) { + if (RongIMLib.RongIMClient.bridge) { + RongIMLib.RongIMClient.bridge.setListener(listener); + } else { + RongIMLib.RongIMClient._memoryStore.listenerList.push(listener); + } + }; + ServerDataProvider.prototype.setOnReceiveMessageListener = function (listener) { + if (RongIMLib.RongIMClient.bridge) { + RongIMLib.RongIMClient.bridge.setListener(listener); + } else { + RongIMLib.RongIMClient._memoryStore.listenerList.push(listener); + } + }; + ServerDataProvider.prototype.registerMessageType = function (messageType, objectName, messageTag, messageContent) { + if (!messageType) { + throw new Error("messageType can't be empty,postion -> registerMessageType"); + } + if (!objectName) { + throw new Error("objectName can't be empty,postion -> registerMessageType"); + } + if (Object.prototype.toString.call(messageContent) == "[object Array]") { + var regMsg = RongIMLib.ModelUtil.modleCreate(messageContent, messageType); + RongIMLib.RongIMClient.RegisterMessage[messageType] = regMsg; + } else if (Object.prototype.toString.call(messageContent) == "[object Function]" || Object.prototype.toString.call(messageContent) == "[object Object]") { + if (!messageContent.encode) { + throw new Error("encode method has not realized or messageName is undefined-> registerMessageType"); + } + if (!messageContent.decode) { + throw new Error("decode method has not realized -> registerMessageType"); + } + } else { + throw new Error("The index of 3 parameter was wrong type must be object or function or array-> registerMessageType"); + } + registerMessageTypeMapping[objectName] = messageType; + }; + ServerDataProvider.prototype.addConversation = function (conversation, callback) { + var isAdd = true; + for (var i = 0, len = RongIMLib.RongIMClient._memoryStore.conversationList.length; i < len; i++) { + if (RongIMLib.RongIMClient._memoryStore.conversationList[i].conversationType === conversation.conversationType && RongIMLib.RongIMClient._memoryStore.conversationList[i].targetId === conversation.targetId) { + RongIMLib.RongIMClient._memoryStore.conversationList.unshift(RongIMLib.RongIMClient._memoryStore.conversationList.splice(i, 1)[0]); + isAdd = false; + break; + } + } + if (isAdd) { + RongIMLib.RongIMClient._memoryStore.conversationList.unshift(conversation); + } + callback.onSuccess(true); + }; + ServerDataProvider.prototype.updateConversation = function (conversation) { + var conver; + for (var i = 0, len = RongIMLib.RongIMClient._memoryStore.conversationList.length; i < len; i++) { + if (conversation.conversationType === RongIMLib.RongIMClient._memoryStore.conversationList[i].conversationType && conversation.targetId === RongIMLib.RongIMClient._memoryStore.conversationList[i].targetId) { + conversation.conversationTitle && (RongIMLib.RongIMClient._memoryStore.conversationList[i].conversationTitle = conversation.conversationTitle); + conversation.senderUserName && (RongIMLib.RongIMClient._memoryStore.conversationList[i].senderUserName = conversation.senderUserName); + conversation.senderPortraitUri && (RongIMLib.RongIMClient._memoryStore.conversationList[i].senderPortraitUri = conversation.senderPortraitUri); + conversation.latestMessage && (RongIMLib.RongIMClient._memoryStore.conversationList[i].latestMessage = conversation.latestMessage); + break; + } + } + return conver; + }; + ServerDataProvider.prototype.removeConversation = function (conversationType, targetId, callback) { + var mod = new Modules.RelationsInput(); + mod.setType(conversationType); + RongIMLib.RongIMClient.bridge.queryMsg(27, RongIMLib.MessageUtil.ArrayForm(mod.toArrayBuffer()), targetId, { + onSuccess: function () { + var conversations = RongIMLib.RongIMClient._memoryStore.conversationList; + var len = conversations.length; + for (var i = 0; i < len; i++) { + if (conversations[i].conversationType == conversationType && targetId == conversations[i].targetId) { + conversations.splice(i, 1); + break; + } + } + callback.onSuccess(true); + }, + onError: function () { + setTimeout(function () { + callback.onError(RongIMLib.ErrorCode.CONVER_REMOVE_ERROR); + }); + } + }); + }; + ServerDataProvider.prototype.getMessage = function (messageId, callback) { + callback.onSuccess(new RongIMLib.Message()); + }; + ServerDataProvider.prototype.addMessage = function (conversationType, targetId, message, callback) { + if (callback) { + callback.onSuccess(message); + } + }; + ServerDataProvider.prototype.removeMessage = function (conversationType, targetId, messageIds, callback) { + RongIMLib.RongIMClient.getInstance().deleteRemoteMessages(conversationType, targetId, messageIds, callback); + }; + ServerDataProvider.prototype.removeLocalMessage = function (conversationType, targetId, timestamps, callback) { + callback.onSuccess(true); + }; + ServerDataProvider.prototype.updateMessage = function (message, callback) { + if (callback) { + callback.onSuccess(message); + } + }; + ServerDataProvider.prototype.clearMessages = function (conversationType, targetId, callback) { + callback.onSuccess(true); + }; + ServerDataProvider.prototype.updateMessages = function (conversationType, targetId, key, value, callback) { + var me = this; + if (key == "readStatus") { + if (RongIMLib.RongIMClient._memoryStore.conversationList.length > 0) { + me.getConversationList({ + onSuccess: function (list) { + Array.forEach(list, function (conver) { + if (conver.conversationType == conversationType && conver.targetId == targetId) { + conver.unreadMessageCount = 0; + } + }); + }, + onError: function (errorCode) { + callback.onError(errorCode); + } + }, null); + } + } + callback.onSuccess(true); + }; + ServerDataProvider.prototype.getConversation = function (conversationType, targetId, callback) { + var conver = null; + for (var i = 0, len = RongIMLib.RongIMClient._memoryStore.conversationList.length; i < len; i++) { + if (RongIMLib.RongIMClient._memoryStore.conversationList[i].conversationType == conversationType && RongIMLib.RongIMClient._memoryStore.conversationList[i].targetId == targetId) { + conver = RongIMLib.RongIMClient._memoryStore.conversationList[i]; + if (RongIMLib.MessageUtil.supportLargeStorage()) { + var count = RongIMLib.RongIMClient._storageProvider.getItem("cu" + RongIMLib.Bridge._client.userId + conversationType + targetId); + if (conver.unreadMessageCount == 0) { + conver.unreadMessageCount = Number(count); + } + } + } + } + callback && callback.onSuccess(conver); + return conver; + }; + ServerDataProvider.prototype.getConversationList = function (callback, conversationTypes, count, isHidden) { + var _Cache = RongIMLib.RongIMClient._Cahche; + var memoryStore = RongIMLib.RongIMClient._memoryStore; + var conversationList = memoryStore.conversationList; + // 通过过会话列表后,从内存中获取 + if (_Cache.isSyncConversations) { + return callback.onSuccess(conversationList); + } + RongIMLib.RongIMClient.getInstance().getRemoteConversationList({ + onSuccess: function (list) { + if (RongIMLib.MessageUtil.supportLargeStorage()) { + memoryStore.conversationList = list; + _Cache.isSyncConversations = true; + Array.forEach(memoryStore.conversationList, function (item) { + var count = RongIMLib.RongIMClient._storageProvider.getItem("cu" + RongIMLib.Bridge._client.userId + item.conversationType + item.targetId); + if (item.unreadMessageCount == 0) { + item.unreadMessageCount = Number(count); + } + }); + } + RongIMLib.RongIMClient._memoryStore.isSyncRemoteConverList = false; + callback.onSuccess(list); + }, + onError: function (errorcode) { + callback.onSuccess([]); + } + }, conversationTypes, count, isHidden); + _Cache.isRunning = true; + }; + ServerDataProvider.prototype.clearCache = function () { + var memoryStore = RongIMLib.RongIMClient._memoryStore || {}; + memoryStore.conversationList = []; + memoryStore.isSyncRemoteConverList = true; + }; + ServerDataProvider.prototype.clearConversations = function (conversationTypes, callback) { + Array.forEach(conversationTypes, function (conversationType) { + Array.forEach(RongIMLib.RongIMClient._memoryStore.conversationList, function (conver) { + if (conversationType == conver.conversationType) { + RongIMLib.RongIMClient.getInstance().removeConversation(conver.conversationType, conver.targetId, { + onSuccess: function () {}, + onError: function () {} + }); + } + }); + }); + callback.onSuccess(true); + }; + ServerDataProvider.prototype.setMessageContent = function (messageId, content, objectname) {}; + ; + ServerDataProvider.prototype.getHistoryMessages = function (conversationType, targetId, timestamp, count, callback) { + RongIMLib.RongIMClient.getInstance().getRemoteHistoryMessages(conversationType, targetId, timestamp, count, callback); + }; + ServerDataProvider.prototype.getTotalUnreadCount = function (callback, conversationTypes) { + var count = 0; + if (conversationTypes) { + for (var i = 0, len = conversationTypes.length; i < len; i++) { + Array.forEach(RongIMLib.RongIMClient._memoryStore.conversationList, function (conver) { + if (conver.conversationType == conversationTypes[i]) { + count += conver.unreadMessageCount; + } + }); + } + } else { + Array.forEach(RongIMLib.RongIMClient._memoryStore.conversationList, function (conver) { + count += conver.unreadMessageCount; + }); + } + callback.onSuccess(count); + }; + ServerDataProvider.prototype.getConversationUnreadCount = function (conversationTypes, callback) { + var count = 0; + Array.forEach(conversationTypes, function (converType) { + Array.forEach(RongIMLib.RongIMClient._memoryStore.conversationList, function (conver) { + if (conver.conversationType == converType) { + count += conver.unreadMessageCount; + } + }); + }); + callback.onSuccess(count); + }; + ServerDataProvider.prototype.getUnreadCount = function (conversationType, targetId, callback) { + this.getConversation(conversationType, targetId, { + onSuccess: function (conver) { + callback.onSuccess(conver ? conver.unreadMessageCount : 0); + }, + onError: function (error) { + callback.onError(error); + } + }); + }; + ServerDataProvider.prototype.clearUnreadCountByTimestamp = function (conversationType, targetId, timestamp, callback) { + callback.onSuccess(true); + }; + ServerDataProvider.prototype.cleanMentioneds = function (conver) { + if (conver) { + conver.mentionedMsg = null; + var targetId = conver.targetId; + var conversationType = conver.conversationType; + var mentioneds = RongIMLib.RongIMClient._storageProvider.getItem("mentioneds_" + RongIMLib.Bridge._client.userId + '_' + conversationType + '_' + targetId); + if (mentioneds) { + var info = JSON.parse(mentioneds); + delete info[conversationType + "_" + targetId]; + if (!RongIMLib.MessageUtil.isEmpty(info)) { + RongIMLib.RongIMClient._storageProvider.setItem("mentioneds_" + RongIMLib.Bridge._client.userId + '_' + conversationType + '_' + targetId, JSON.stringify(info)); + } else { + RongIMLib.RongIMClient._storageProvider.removeItem("mentioneds_" + RongIMLib.Bridge._client.userId + '_' + conversationType + '_' + targetId); + } + } + } + }; + ServerDataProvider.prototype.clearUnreadCount = function (conversationType, targetId, callback) { + this.getConversation(conversationType, targetId, { + onSuccess: function (conver) { + if (conver) { + var isNotifyConversation = conver.unreadMessageCount; + if (RongIMLib.MessageUtil.supportLargeStorage()) { + RongIMLib.RongIMClient._storageProvider.removeItem("cu" + RongIMLib.Bridge._client.userId + conversationType + targetId); + } + conver.unreadMessageCount = 0; + conver.mentionedMsg = null; + var mentioneds = RongIMLib.RongIMClient._storageProvider.getItem("mentioneds_" + RongIMLib.Bridge._client.userId + '_' + conversationType + '_' + targetId); + if (mentioneds) { + isNotifyConversation = true; + var info = JSON.parse(mentioneds); + delete info[conversationType + "_" + targetId]; + if (!RongIMLib.MessageUtil.isEmpty(info)) { + RongIMLib.RongIMClient._storageProvider.setItem("mentioneds_" + RongIMLib.Bridge._client.userId + '_' + conversationType + '_' + targetId, JSON.stringify(info)); + } else { + RongIMLib.RongIMClient._storageProvider.removeItem("mentioneds_" + RongIMLib.Bridge._client.userId + '_' + conversationType + '_' + targetId); + } + } + } + callback.onSuccess(true); + isNotifyConversation && Conversation._notify(RongIMClient._memoryStore.conversationList); + }, + onError: function (error) { + callback.onError(error); + } + }); + }; + ServerDataProvider.prototype.clearTotalUnreadCount = function (callback) { + var list = RongIMLib.RongIMClient._memoryStore.conversationList; + var me = this; + var isNotifyConversation = false; + if (list) { + // 清除 mentioneds、清除 list 中的 unreadMessageCount + for (var i = 0; i < list.length; i++) { + var conver = list[i]; + if (conver) { + isNotifyConversation = conver.unreadMessageCount ? true : isNotifyConversation; + conver.unreadMessageCount = 0; + me.cleanMentioneds(conver); + } + } + } + var unreadKeys = RongIMLib.RongIMClient._storageProvider.getItemKeyList("cu" + RongIMLib.Bridge._client.userId); + isNotifyConversation = unreadKeys.length ? true : isNotifyConversation; + for (var i = 0; i < unreadKeys.length; i++) { + var key = unreadKeys[i]; + RongIMLib.RongIMClient._storageProvider.removeItem(key); + } + setTimeout(() => { + callback.onSuccess(true); + isNotifyConversation && Conversation._notify(RongIMClient._memoryStore.conversationList); + }); + }; + ServerDataProvider.prototype.setConversationToTop = function (conversationType, targetId, isTop, callback) { + var me = this; + this.getConversation(conversationType, targetId, { + onSuccess: function (conver) { + conver.isTop = isTop; + me.addConversation(conver, callback); + callback.onSuccess(true); + }, + onError: function (error) { + callback.onError(error); + } + }); + }; + ServerDataProvider.prototype.clearListeners = function () {}; + ServerDataProvider.prototype.setServerInfo = function (info) {}; + ServerDataProvider.prototype.getUnreadMentionedMessages = function (conversationType, targetId) { + return null; + }; + ServerDataProvider.prototype.setConversationHidden = function (conversationType, targetId, isHidden) {}; + ServerDataProvider.prototype.setMessageExtra = function (messageId, value, callback) { + callback.onSuccess(true); + }; + ServerDataProvider.prototype.setMessageReceivedStatus = function (messageId, receivedStatus, callback) { + callback.onSuccess(true); + }; + ServerDataProvider.prototype.setMessageSentStatus = function (messageId, sentStatus, callback) { + callback.onSuccess(true); + }; + ServerDataProvider.prototype.getAllConversations = function (callback) { + callback.onSuccess([]); + }; + ServerDataProvider.prototype.getConversationByContent = function (keywords, callback) { + callback.onSuccess([]); + }; + ServerDataProvider.prototype.getMessagesFromConversation = function (conversationType, targetId, keywords, callback) { + callback.onSuccess([]); + }; + ServerDataProvider.prototype.searchConversationByContent = function (keyword, callback, conversationTypes) { + callback.onSuccess([]); + }; + ServerDataProvider.prototype.searchMessageByContent = function (conversationType, targetId, keyword, timestamp, count, total, callback) { + callback.onSuccess([]); + }; + ServerDataProvider.prototype.getDelaTime = function () { + return RongIMLib.RongIMClient._memoryStore.deltaTime; + }; + ServerDataProvider.prototype.getUserStatus = function (userId, callback) { + callback.onSuccess(new RongIMLib.UserStatus()); + }; + ServerDataProvider.prototype.setUserStatus = function (userId, callback) { + callback.onSuccess(true); + }; + ServerDataProvider.prototype.subscribeUserStatus = function (userIds, callback) { + callback.onSuccess(true); + }; + ServerDataProvider.prototype.setOnReceiveStatusListener = function (callback) { + callback(); + }; + return ServerDataProvider; + }(); + RongIMLib.ServerDataProvider = ServerDataProvider; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + // static _instance: LocalStorageProvider = new LocalStorageProvider(); + var prefix = 'rong_'; + function LocalStorageProvider() { + var d = new Date(), + m = d.getMonth() + 1, + date = d.getFullYear() + '/' + (m.toString().length == 1 ? '0' + m : m) + '/' + d.getDate(), + nowDate = new Date(date).getTime(); + for (var key in localStorage) { + if (key.lastIndexOf('RECEIVED') > -1) { + var recObj = JSON.parse(localStorage.getItem(key)); + for (var key_1 in recObj) { + nowDate - recObj[key_1].dealtime > 0 && delete recObj[key_1]; + } + if (RongIMLib.ObjectTools.isEmpty(recObj)) { + localStorage.removeItem(key); + } else { + localStorage.setItem(key, JSON.stringify(recObj)); + } + } + if (key.lastIndexOf('SENT') > -1) { + var sentObj = JSON.parse(localStorage.getItem(key)); + nowDate - sentObj.dealtime > 0 && localStorage.removeItem(key); + } + } + } + RongIMLib.LocalStorageProvider = { + setItem: function (composedKey, object) { + if (composedKey) { + composedKey.indexOf(prefix) == -1 && (composedKey = prefix + composedKey); + wx.setStorageSync(composedKey, object); + } + }, + getItem: function (composedKey) { + if (composedKey) { + composedKey.indexOf(prefix) == -1 && (composedKey = prefix + composedKey); + return wx.getStorageSync(composedKey); + } + return ""; + }, + getItemKey: function (composedStr) { + if (composedStr.indexOf('rong_') == -1) { + composedStr = 'rong_' + composedStr; + } + var item = ""; + var res = wx.getStorageInfoSync(); + var keys = res.keys; + keys.forEach(function (key) { + if (key.indexOf(composedStr) == 0) { + item = key; + } + }); + return item; + }, + getItemKeyList: function (composedStr) { + var prefix = 'rong_'; + if (composedStr.indexOf(prefix) == -1) { + composedStr = prefix + composedStr; + } + var itemList = []; + var res = wx.getStorageInfoSync(); + var keys = res.keys; + keys.forEach(function (key) { + if (key.indexOf(composedStr) == 0) { + key = key.substring(prefix.length); + itemList.push(key); + } + }); + return itemList; + }, + removeItem: function (composedKey) { + if (composedKey) { + composedKey.indexOf(prefix) == -1 && (composedKey = prefix + composedKey); + wx.removeStorageSync(composedKey); + } + }, + clearItem: function () { + var res = wx.getStorageInfoSync(); + var keys = res.keys; + keys.forEach(function (key) { + if (key.indexOf(prefix) == 0) { + wx.removeStorageSync(key); + } + }); + }, + //单位:字节 + onOutOfQuota: function () { + return JSON.stringify(localStorage).length; + } + }; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + RongIMLib.FeatureDectector = function () { + // load protobuf + + // RongIMLib.Transportations._TransportType = RongIMLib.Socket.WEBSOCKET; + // if ("WebSocket" in window && "ArrayBuffer" in window && WebSocket.prototype.CLOSED === 3 && !RongIMLib.RongIMClient._memoryStore.depend.isPolling) { + // var str = RongIMLib.RongIMClient._memoryStore.depend.protobuf; + // this.script.src = str; + // this.head.appendChild(this.script); + // } + // else { + // RongIMLib.Transportations._TransportType = "xhr-polling"; + // window["Modules"] = Polling; + // } + }; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var FeaturePatcher = function () { + function FeaturePatcher() {} + FeaturePatcher.prototype.patchAll = function () { + this.patchJSON(); + this.patchForEach(); + }; + FeaturePatcher.prototype.patchForEach = function () { + if (!Array.forEach) { + Array.forEach = function (arr, func) { + for (var i = 0; i < arr.length; i++) { + func.call(arr, arr[i], i, arr); + } + }; + } + }; + FeaturePatcher.prototype.patchJSON = function () {}; + return FeaturePatcher; + }(); + RongIMLib.FeaturePatcher = FeaturePatcher; + })(RongIMLib || (RongIMLib = {})); + + // var RongIMLib; + (function (RongIMLib) { + var ObjectTools = function () { + function ObjectTools() {} + ObjectTools.isEmpty = function (obj) { + var empty = true; + for (var key in obj) { + empty = false; + break; + } + return empty; + }; + ObjectTools.buildOptions = function (one, opts, protocol) { + if (typeof one == 'object') { + for (var key in opts) { + if (key == 'navi' || key == 'api') { + one[key] && (opts[key] = protocol + one[key]); + } else { + one[key] && (opts[key] = one[key]); + } + } + } + return opts; + }; + return ObjectTools; + }(); + RongIMLib.ObjectTools = ObjectTools; + var PublicServiceMap = function () { + function PublicServiceMap() { + this.publicServiceList = []; + } + PublicServiceMap.prototype.get = function (publicServiceType, publicServiceId) { + for (var i = 0, len = this.publicServiceList.length; i < len; i++) { + if (this.publicServiceList[i].conversationType == publicServiceType && publicServiceId == this.publicServiceList[i].publicServiceId) { + return this.publicServiceList[i]; + } + } + }; + PublicServiceMap.prototype.add = function (publicServiceProfile) { + var isAdd = true, + me = this; + for (var i = 0, len = this.publicServiceList.length; i < len; i++) { + if (me.publicServiceList[i].conversationType == publicServiceProfile.conversationType && publicServiceProfile.publicServiceId == me.publicServiceList[i].publicServiceId) { + this.publicServiceList.unshift(this.publicServiceList.splice(i, 1)[0]); + isAdd = false; + break; + } + } + if (isAdd) { + this.publicServiceList.unshift(publicServiceProfile); + } + }; + PublicServiceMap.prototype.replace = function (publicServiceProfile) { + var me = this; + for (var i = 0, len = this.publicServiceList.length; i < len; i++) { + if (me.publicServiceList[i].conversationType == publicServiceProfile.conversationType && publicServiceProfile.publicServiceId == me.publicServiceList[i].publicServiceId) { + me.publicServiceList.splice(i, 1, publicServiceProfile); + break; + } + } + }; + PublicServiceMap.prototype.remove = function (conversationType, publicServiceId) { + var me = this; + for (var i = 0, len = this.publicServiceList.length; i < len; i++) { + if (me.publicServiceList[i].conversationType == conversationType && publicServiceId == me.publicServiceList[i].publicServiceId) { + this.publicServiceList.splice(i, 1); + break; + } + } + }; + return PublicServiceMap; + }(); + RongIMLib.PublicServiceMap = PublicServiceMap; + /** + * 会话工具类。 + */ + var ConversationMap = function () { + function ConversationMap() { + this.conversationList = []; + } + ConversationMap.prototype.get = function (conversavtionType, targetId) { + for (var i = 0, len = this.conversationList.length; i < len; i++) { + if (this.conversationList[i].conversationType == conversavtionType && this.conversationList[i].targetId == targetId) { + return this.conversationList[i]; + } + } + return null; + }; + ConversationMap.prototype.add = function (conversation) { + var isAdd = true; + for (var i = 0, len = this.conversationList.length; i < len; i++) { + if (this.conversationList[i].conversationType === conversation.conversationType && this.conversationList[i].targetId === conversation.targetId) { + this.conversationList.unshift(this.conversationList.splice(i, 1)[0]); + isAdd = false; + break; + } + } + if (isAdd) { + this.conversationList.unshift(conversation); + } + }; + /** + * [replace 替换会话] + * 会话数组存在的情况下调用add方法会是当前会话被替换且返回到第一个位置,导致用户本地一些设置失效,所以提供replace方法 + */ + ConversationMap.prototype.replace = function (conversation) { + for (var i = 0, len = this.conversationList.length; i < len; i++) { + if (this.conversationList[i].conversationType === conversation.conversationType && this.conversationList[i].targetId === conversation.targetId) { + this.conversationList.splice(i, 1, conversation); + break; + } + } + }; + ConversationMap.prototype.remove = function (conversation) { + for (var i = 0, len = this.conversationList.length; i < len; i++) { + if (this.conversationList[i].conversationType === conversation.conversationType && this.conversationList[i].targetId === conversation.targetId) { + this.conversationList.splice(i, 1); + break; + } + } + }; + return ConversationMap; + }(); + RongIMLib.ConversationMap = ConversationMap; + var CheckParam = function () { + function CheckParam() {} + CheckParam.getInstance = function () { + if (!CheckParam._instance) { + CheckParam._instance = new CheckParam(); + } + return CheckParam._instance; + }; + CheckParam.prototype.check = function (f, position, d, c) { + if (RongIMLib.RongIMClient._dataAccessProvider || d) { + for (var g = 0, e = c.length; g < e; g++) { + if (!new RegExp(this.getType(c[g])).test(f[g])) { + throw new Error("The index of " + g + " parameter was wrong type " + this.getType(c[g]) + " [" + f[g] + "] -> position:" + position); + } + } + } else { + throw new Error("The parameter is incorrect or was not yet instantiated RongIMClient -> position:" + position); + } + }; + CheckParam.prototype.getType = function (str) { + var temp = Object.prototype.toString.call(str).toLowerCase(); + return temp.slice(8, temp.length - 1); + }; + return CheckParam; + }(); + RongIMLib.CheckParam = CheckParam; + var LimitableMap = function () { + function LimitableMap(limit) { + this.map = {}; + this.keys = []; + this.limit = limit || 10; + } + LimitableMap.prototype.set = function (key, value) { + this.map[key] = value; + }; + LimitableMap.prototype.get = function (key) { + return this.map[key] || 0; + }; + LimitableMap.prototype.remove = function (key) { + delete this.map[key]; + }; + return LimitableMap; + }(); + RongIMLib.LimitableMap = LimitableMap; + var RongAjax = function () { + function RongAjax(options) { + var me = this; + me.xmlhttp = null; + me.options = options; + var hasCORS = typeof XMLHttpRequest !== "undefined" && "withCredentials" in new XMLHttpRequest(); + if ("undefined" != typeof XMLHttpRequest && hasCORS) { + me.xmlhttp = new XMLHttpRequest(); + } else if ("undefined" != typeof XDomainRequest) { + me.xmlhttp = new XDomainRequest(); + } else { + me.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } + } + RongAjax.prototype.send = function (callback) { + var me = this; + me.options.url || (me.options.url = "http://upload.qiniu.com/putb64/-1"); + me.xmlhttp.onreadystatechange = function () { + if (me.xmlhttp.readyState == 4) { + if (me.options.type) { + callback(); + } else { + callback(JSON.parse(me.xmlhttp.responseText.replace(/'/g, '"'))); + } + } + }; + me.xmlhttp.open("POST", me.options.url, true); + me.xmlhttp.withCredentials = false; + if ("setRequestHeader" in me.xmlhttp) { + if (me.options.type) { + me.xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8"); + } else { + me.xmlhttp.setRequestHeader("Content-type", "application/octet-stream"); + me.xmlhttp.setRequestHeader('Authorization', "UpToken " + me.options.token); + } + } + me.xmlhttp.send(me.options.type ? "appKey=" + me.options.appKey + "&deviceId=" + me.options.deviceId + "×tamp=" + me.options.timestamp + "&deviceInfo=" + me.options.deviceInfo + "&privateInfo=" + JSON.stringify(me.options.privateInfo) : me.options.base64); + }; + return RongAjax; + }(); + RongIMLib.RongAjax = RongAjax; + })(RongIMLib || (RongIMLib = {})); + return RongIMLib; +}(wx); \ No newline at end of file diff --git a/src/lib/wx-map-sdk/amap-wx.130.js b/src/lib/wx-map-sdk/amap-wx.130.js new file mode 100644 index 0000000..bc1f371 --- /dev/null +++ b/src/lib/wx-map-sdk/amap-wx.130.js @@ -0,0 +1,849 @@ +function AMapWX(a) { + this.key = a.key; + this.requestConfig = { + key: a.key, + s: 'rsx', + platform: 'WXJS', + appname: a.key, + sdkversion: '1.2.0', + logversion: '2.0' + }; + this.MeRequestConfig = { + key: a.key, + serviceName: 'https://restapi.amap.com/rest/me' + }; +} +AMapWX.prototype.getWxLocation = function (a, b) { + uni.getLocation({ + type: 'gcj02', + success: function (c) { + c = c.longitude + ',' + c.latitude; + uni.setStorage({ + key: 'userLocation', + data: c + }); + b(c); + }, + fail: function (c) { + uni.getStorage({ + key: 'userLocation', + success: function (d) { + if (d.data) { + b(d.data); + } + } + }); + a.fail({ + errCode: '0', + errMsg: c.errMsg || '' + }); + } + }); +}; +AMapWX.prototype.getMEKeywordsSearch = function (a) { + if (!a.options) { + return a.fail({ + errCode: '0', + errMsg: '\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570' + }); + } + var b = a.options; + var c = this.MeRequestConfig; + var d = { + key: c.key, + s: 'rsx', + platform: 'WXJS', + appname: a.key, + sdkversion: '1.2.0', + logversion: '2.0' + }; + if (b.layerId) { + d.layerId = b.layerId; + } + if (b.keywords) { + d.keywords = b.keywords; + } + if (b.city) { + d.city = b.city; + } + if (b.filter) { + d.filter = b.filter; + } + if (b.sortrule) { + d.sortrule = b.sortrule; + } + if (b.pageNum) { + d.pageNum = b.pageNum; + } + if (b.pageSize) { + d.pageSize = b.pageSize; + } + if (b.sig) { + d.sig = b.sig; + } + uni.request({ + url: c.serviceName + '/cpoint/datasearch/local', + data: d, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (e) { + if ((e = e.data) && e.status && '1' === e.status && 0 === e.code) { + a.success(e.data); + } else { + a.fail({ + errCode: '0', + errMsg: e + }); + } + }, + fail: function (e) { + a.fail({ + errCode: '0', + errMsg: e.errMsg || '' + }); + } + }); +}; +AMapWX.prototype.getMEIdSearch = function (a) { + if (!a.options) { + return a.fail({ + errCode: '0', + errMsg: '\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570' + }); + } + var b = a.options; + var c = this.MeRequestConfig; + var d = { + key: c.key, + s: 'rsx', + platform: 'WXJS', + appname: a.key, + sdkversion: '1.2.0', + logversion: '2.0' + }; + if (b.layerId) { + d.layerId = b.layerId; + } + if (b.id) { + d.id = b.id; + } + if (b.sig) { + d.sig = b.sig; + } + uni.request({ + url: c.serviceName + '/cpoint/datasearch/id', + data: d, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (e) { + if ((e = e.data) && e.status && '1' === e.status && 0 === e.code) { + a.success(e.data); + } else { + a.fail({ + errCode: '0', + errMsg: e + }); + } + }, + fail: function (e) { + a.fail({ + errCode: '0', + errMsg: e.errMsg || '' + }); + } + }); +}; +AMapWX.prototype.getMEPolygonSearch = function (a) { + if (!a.options) { + return a.fail({ + errCode: '0', + errMsg: '\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570' + }); + } + var b = a.options; + var c = this.MeRequestConfig; + var d = { + key: c.key, + s: 'rsx', + platform: 'WXJS', + appname: a.key, + sdkversion: '1.2.0', + logversion: '2.0' + }; + if (b.layerId) { + d.layerId = b.layerId; + } + if (b.keywords) { + d.keywords = b.keywords; + } + if (b.polygon) { + d.polygon = b.polygon; + } + if (b.filter) { + d.filter = b.filter; + } + if (b.sortrule) { + d.sortrule = b.sortrule; + } + if (b.pageNum) { + d.pageNum = b.pageNum; + } + if (b.pageSize) { + d.pageSize = b.pageSize; + } + if (b.sig) { + d.sig = b.sig; + } + uni.request({ + url: c.serviceName + '/cpoint/datasearch/polygon', + data: d, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (e) { + (e = e.data) && e.status && '1' === e.status && 0 === e.code + ? a.success(e.data) + : a.fail({ + errCode: '0', + errMsg: e + }); + }, + fail: function (e) { + a.fail({ + errCode: '0', + errMsg: e.errMsg || '' + }); + } + }); +}; +AMapWX.prototype.getMEaroundSearch = function (a) { + if (!a.options) { + return a.fail({ + errCode: '0', + errMsg: '\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570' + }); + } + var b = a.options; + var c = this.MeRequestConfig; + var d = { + key: c.key, + s: 'rsx', + platform: 'WXJS', + appname: a.key, + sdkversion: '1.2.0', + logversion: '2.0' + }; + if (b.layerId) { + d.layerId = b.layerId; + } + if (b.keywords) { + d.keywords = b.keywords; + } + if (b.center) { + d.center = b.center; + } + if (b.radius) { + d.radius = b.radius; + } + if (b.filter) { + d.filter = b.filter; + } + if (b.sortrule) { + d.sortrule = b.sortrule; + } + if (b.pageNum) { + d.pageNum = b.pageNum; + } + if (b.pageSize) { + d.pageSize = b.pageSize; + } + if (b.sig) { + d.sig = b.sig; + } + uni.request({ + url: c.serviceName + '/cpoint/datasearch/around', + data: d, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (e) { + (e = e.data) && e.status && '1' === e.status && 0 === e.code + ? a.success(e.data) + : a.fail({ + errCode: '0', + errMsg: e + }); + }, + fail: function (e) { + a.fail({ + errCode: '0', + errMsg: e.errMsg || '' + }); + } + }); +}; +AMapWX.prototype.getGeo = function (a) { + var b = this.requestConfig; + var c = a.options; + b = { + key: this.key, + extensions: 'all', + s: b.s, + platform: b.platform, + appname: this.key, + sdkversion: b.sdkversion, + logversion: b.logversion + }; + if (c.address) { + b.address = c.address; + } + if (c.city) { + b.city = c.city; + } + if (c.batch) { + b.batch = c.batch; + } + if (c.sig) { + b.sig = c.sig; + } + uni.request({ + url: 'https://restapi.amap.com/v3/geocode/geo', + data: b, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (d) { + (d = d.data) && d.status && '1' === d.status + ? a.success(d) + : a.fail({ + errCode: '0', + errMsg: d + }); + }, + fail: function (d) { + a.fail({ + errCode: '0', + errMsg: d.errMsg || '' + }); + } + }); +}; +AMapWX.prototype.getRegeo = function (a) { + function b(d) { + var e = that.requestConfig; + uni.request({ + url: 'https://restapi.amap.com/v3/geocode/regeo', + data: { + key: that.key, + location: d, + extensions: 'all', + s: e.s, + platform: e.platform, + appname: that.key, + sdkversion: e.sdkversion, + logversion: e.logversion + }, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (g) { + if (g.data.status && '1' == g.data.status) { + g = g.data.regeocode; + var h = g.addressComponent; + var f = []; + var k = g.roads[0].name + '\u9644\u8FD1'; + var m = d.split(',')[0]; + var n = d.split(',')[1]; + if (g.pois && g.pois[0]) { + k = g.pois[0].name + '\u9644\u8FD1'; + var l = g.pois[0].location; + if (l) { + m = parseFloat(l.split(',')[0]); + n = parseFloat(l.split(',')[1]); + } + } + if (h.provice) { + f.push(h.provice); + } + if (h.city) { + f.push(h.city); + } + if (h.district) { + f.push(h.district); + } + h.streetNumber && h.streetNumber.street && h.streetNumber.number ? (f.push(h.streetNumber.street), f.push(h.streetNumber.number)) : f.push(g.roads[0].name); + f = f.join(''); + a.success([ + { + iconPath: a.iconPath, + width: a.iconWidth, + height: a.iconHeight, + name: f, + desc: k, + longitude: m, + latitude: n, + id: 0, + regeocodeData: g + } + ]); + } else { + a.fail({ + errCode: g.data.infocode, + errMsg: g.data.info + }); + } + }, + fail: function (g) { + a.fail({ + errCode: '0', + errMsg: g.errMsg || '' + }); + } + }); + } + var that = this; + a.location + ? b(a.location) + : that.getWxLocation(a, function (d) { + b(d); + }); +}; +AMapWX.prototype.getWeather = function (a) { + function b(g) { + var h = 'base'; + if (a.type && 'forecast' == a.type) { + h = 'all'; + } + uni.request({ + url: 'https://restapi.amap.com/v3/weather/weatherInfo', + data: { + key: that.key, + city: g, + extensions: h, + s: e.s, + platform: e.platform, + appname: that.key, + sdkversion: e.sdkversion, + logversion: e.logversion + }, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (f) { + if (f.data.status && '1' == f.data.status) { + if (f.data.lives) { + if ((f = f.data.lives) && 0 < f.length) { + f = f[0]; + var k = { + city: { + text: '\u57CE\u5E02', + data: f.city + }, + weather: { + text: '\u5929\u6C14', + data: f.weather + }, + temperature: { + text: '\u6E29\u5EA6', + data: f.temperature + }, + winddirection: { + text: '\u98CE\u5411', + data: f.winddirection + '\u98CE' + }, + windpower: { + text: '\u98CE\u529B', + data: f.windpower + '\u7EA7' + }, + humidity: { + text: '\u6E7F\u5EA6', + data: f.humidity + '%' + } + }; + k.liveData = f; + a.success(k); + } + } else { + if (f.data.forecasts && f.data.forecasts[0]) { + a.success({ + forecast: f.data.forecasts[0] + }); + } + } + } else { + a.fail({ + errCode: f.data.infocode, + errMsg: f.data.info + }); + } + }, + fail: function (f) { + a.fail({ + errCode: '0', + errMsg: f.errMsg || '' + }); + } + }); + } + function c(g) { + uni.request({ + url: 'https://restapi.amap.com/v3/geocode/regeo', + data: { + key: that.key, + location: g, + extensions: 'all', + s: e.s, + platform: e.platform, + appname: that.key, + sdkversion: e.sdkversion, + logversion: e.logversion + }, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (h) { + if (h.data.status && '1' == h.data.status) { + h = h.data.regeocode; + if (h.addressComponent) { + var f = h.addressComponent.adcode; + } else { + if (h.aois && 0 < h.aois.length) { + f = h.aois[0].adcode; + } + } + b(f); + } else { + a.fail({ + errCode: h.data.infocode, + errMsg: h.data.info + }); + } + }, + fail: function (h) { + a.fail({ + errCode: '0', + errMsg: h.errMsg || '' + }); + } + }); + } + var that = this; + var e = that.requestConfig; + a.city + ? b(a.city) + : that.getWxLocation(a, function (g) { + c(g); + }); +}; +AMapWX.prototype.getPoiAround = function (a) { + function b(e) { + e = { + key: that.key, + location: e, + s: d.s, + platform: d.platform, + appname: that.key, + sdkversion: d.sdkversion, + logversion: d.logversion + }; + if (a.querytypes) { + e.types = a.querytypes; + } + if (a.querykeywords) { + e.keywords = a.querykeywords; + } + uni.request({ + url: 'https://restapi.amap.com/v3/place/around', + data: e, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (g) { + if (g.data.status && '1' == g.data.status) { + if ((g = g.data) && g.pois) { + for (h = [], f = 0, void 0; f < g.pois.length; f++) { + var h; + var f; + if (0 == f) { + var k = a.iconPathSelected; + } else { + var k = a.iconPath; + } + h.push({ + latitude: parseFloat(g.pois[f].location.split(',')[1]), + longitude: parseFloat(g.pois[f].location.split(',')[0]), + iconPath: k, + width: 22, + height: 32, + id: f, + name: g.pois[f].name, + address: g.pois[f].address + }); + } + a.success({ + markers: h, + poisData: g.pois + }); + } + } else { + a.fail({ + errCode: g.data.infocode, + errMsg: g.data.info + }); + } + }, + fail: function (g) { + a.fail({ + errCode: '0', + errMsg: g.errMsg || '' + }); + } + }); + } + var that = this; + var d = that.requestConfig; + a.location + ? b(a.location) + : that.getWxLocation(a, function (e) { + b(e); + }); +}; +AMapWX.prototype.getStaticmap = function (a) { + function b(e) { + c.push('location=' + e); + if (a.zoom) { + c.push('zoom=' + a.zoom); + } + if (a.size) { + c.push('size=' + a.size); + } + if (a.scale) { + c.push('scale=' + a.scale); + } + if (a.markers) { + c.push('markers=' + a.markers); + } + if (a.labels) { + c.push('labels=' + a.labels); + } + if (a.paths) { + c.push('paths=' + a.paths); + } + if (a.traffic) { + c.push('traffic=' + a.traffic); + } + e = 'https://restapi.amap.com/v3/staticmap?' + c.join('&'); + a.success({ + url: e + }); + } + var c = []; + c.push('key=' + this.key); + var d = this.requestConfig; + c.push('s=' + d.s); + c.push('platform=' + d.platform); + c.push('appname=' + d.appname); + c.push('sdkversion=' + d.sdkversion); + c.push('logversion=' + d.logversion); + a.location + ? b(a.location) + : this.getWxLocation(a, function (e) { + b(e); + }); +}; +AMapWX.prototype.getInputtips = function (a) { + var b = Object.assign({}, this.requestConfig); + if (a.location) { + b.location = a.location; + } + if (a.keywords) { + b.keywords = a.keywords; + } + if (a.type) { + b.type = a.type; + } + if (a.city) { + b.city = a.city; + } + if (a.citylimit) { + b.citylimit = a.citylimit; + } + uni.request({ + url: 'https://restapi.amap.com/v3/assistant/inputtips', + data: b, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (c) { + if (c && c.data && c.data.tips) { + a.success({ + tips: c.data.tips + }); + } + }, + fail: function (c) { + a.fail({ + errCode: '0', + errMsg: c.errMsg || '' + }); + } + }); +}; +AMapWX.prototype.getDrivingRoute = function (a) { + var b = Object.assign({}, this.requestConfig); + if (a.origin) { + b.origin = a.origin; + } + if (a.destination) { + b.destination = a.destination; + } + if (a.strategy) { + b.strategy = a.strategy; + } + if (a.waypoints) { + b.waypoints = a.waypoints; + } + if (a.avoidpolygons) { + b.avoidpolygons = a.avoidpolygons; + } + if (a.avoidroad) { + b.avoidroad = a.avoidroad; + } + uni.request({ + url: 'https://restapi.amap.com/v3/direction/driving', + data: b, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (c) { + if (c && c.data && c.data.route) { + a.success({ + paths: c.data.route.paths, + taxi_cost: c.data.route.taxi_cost || '' + }); + } + }, + fail: function (c) { + a.fail({ + errCode: '0', + errMsg: c.errMsg || '' + }); + } + }); +}; +AMapWX.prototype.getWalkingRoute = function (a) { + var b = Object.assign({}, this.requestConfig); + if (a.origin) { + b.origin = a.origin; + } + if (a.destination) { + b.destination = a.destination; + } + uni.request({ + url: 'https://restapi.amap.com/v3/direction/walking', + data: b, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (c) { + if (c && c.data && c.data.route) { + a.success({ + paths: c.data.route.paths + }); + } + }, + fail: function (c) { + a.fail({ + errCode: '0', + errMsg: c.errMsg || '' + }); + } + }); +}; +AMapWX.prototype.getTransitRoute = function (a) { + var b = Object.assign({}, this.requestConfig); + if (a.origin) { + b.origin = a.origin; + } + if (a.destination) { + b.destination = a.destination; + } + if (a.strategy) { + b.strategy = a.strategy; + } + if (a.city) { + b.city = a.city; + } + if (a.cityd) { + b.cityd = a.cityd; + } + uni.request({ + url: 'https://restapi.amap.com/v3/direction/transit/integrated', + data: b, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (c) { + if (c && c.data && c.data.route) { + c = c.data.route; + a.success({ + distance: c.distance || '', + taxi_cost: c.taxi_cost || '', + transits: c.transits + }); + } + }, + fail: function (c) { + a.fail({ + errCode: '0', + errMsg: c.errMsg || '' + }); + } + }); +}; +AMapWX.prototype.getRidingRoute = function (a) { + var b = Object.assign({}, this.requestConfig); + if (a.origin) { + b.origin = a.origin; + } + if (a.destination) { + b.destination = a.destination; + } + uni.request({ + url: 'https://restapi.amap.com/v3/direction/riding', + data: b, + method: 'GET', + header: { + 'content-type': 'application/json' + }, + success: function (c) { + if (c && c.data && c.data.route) { + a.success({ + paths: c.data.route.paths + }); + } + }, + fail: function (c) { + a.fail({ + errCode: '0', + errMsg: c.errMsg || '' + }); + } + }); +}; +export default { AMapWX }; diff --git a/src/lib/wx-promise-pro/README.md b/src/lib/wx-promise-pro/README.md new file mode 100644 index 0000000..6192265 --- /dev/null +++ b/src/lib/wx-promise-pro/README.md @@ -0,0 +1,85 @@ +# wx-promise-pro + + + +[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-) + + + +✨ 强大、优雅的微信小程序异步库 🚀 + +[![npm](https://img.shields.io/npm/v/wx-promise-pro.svg)](https://www.npmjs.com/package/wx-promise-pro) [![npm](https://img.shields.io/npm/dt/wx-promise-pro.svg)](https://www.npmjs.com/package/wx-promise-pro) [![Financial Contributors on Open Collective](https://opencollective.com/wx-promise-pro/all/badge.svg?label=financial+contributors)](https://opencollective.com/wx-promise-pro) + +[![NPM](https://nodei.co/npm/wx-promise-pro.png?compact=true)](https://nodei.co/npm/wx-promise-pro/) + +## 优势 + +- 方便集成:一处引用,处处使用 +- 把微信小程序所有异步 API promise 化并挂在到`wx.pro` 对象下 +- 支持 ES2018 `finally` 特性 +- 支持 TypeScript 开发 + +## 安装 + +> 你也可以直接把 `dist` 目录下的 `wx-promise-pro.js` 拷贝到项目里使用 + +```bash +$ npm i wx-promise-pro -S +# or +$ yarn add wx-promise-pro +``` + +## 初始化 + +```js +import { promisifyAll, promisify } from 'wx-promise-pro'; +// promisify all wx‘s api +promisifyAll(); +// promisify single api +promisify(wx.getSystemInfo)().then(console.log); +``` + +## 示例代码 + +```js +wx.pro.showLoading({ + title: '加载中', + mask: true, +}); +wx.pro + .request({ + url: 'https://cnodejs.org/api/v1/topics', + data: {}, + method: 'GET', + header: { 'content-type': 'application/json' }, + }) + .then((res) => { + console.log(res); + }) + .catch((err) => { + console.log(err); + }) + .finally(() => { + wx.pro.hideLoading(); + }); +``` + +## 贡献者 ✨ + +感谢如下贡献者的贡献 ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + + + +

Shenshun Weng

💻

kala888

💻

Yiming Li

🐛
+ + + + + diff --git a/src/lib/wx-promise-pro/index.js b/src/lib/wx-promise-pro/index.js new file mode 100644 index 0000000..476837e --- /dev/null +++ b/src/lib/wx-promise-pro/index.js @@ -0,0 +1,39 @@ +import { asyncMethods } from './methods'; + +// polyfill for finally +if (!Promise.prototype.finally) { + Promise.prototype.finally = function (callback) { + const P = this.constructor; + return this.then( + (value) => P.resolve(callback()).then(() => value), + (reason) => + P.resolve(callback()).then(() => { + throw reason; + }) + ); + }; +} + +// core method +export const promisify = (api) => { + return (args = {}) => { + return new Promise((resolve, reject) => { + api({ + fail: reject, + success: resolve, + ...args + }); + }); + }; +}; +export const promisifyAll = () => { + uni.pro = {}; + Object.keys(wx).forEach((key) => { + if (asyncMethods.indexOf(key) >= 0) { + uni.pro[key] = promisify(uni[key]); + } else if (key !== 'createSignal') { + uni.pro[key] = uni[key]; + } + }); +}; +export default promisifyAll; diff --git a/src/lib/wx-promise-pro/methods.js b/src/lib/wx-promise-pro/methods.js new file mode 100644 index 0000000..8fba2ce --- /dev/null +++ b/src/lib/wx-promise-pro/methods.js @@ -0,0 +1,2 @@ +// 指定微信api支持Promise风格 +export const asyncMethods = ['downloadFile', 'request', 'uploadFile', 'connectSocket']; diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..eedbdf7 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,93 @@ +import App from './App'; + +// 全局mixins,用于实现setData等功能,请勿删除!'; +// import zpMixins from '@/uni_modules/zp-mixins/index.js'; + +// 2. 引入组件样式 +import 'vant/lib/index.css'; +import { + Button, + Tab, + Tabs, + Empty, + Loading, + Icon, + CellGroup, + Cell, + NavBar, + Popup, + Picker, + Rate, + SwipeCell, + Search, + Uploader, + NoticeBar, + Checkbox, + Cascader, + Grid, + GridItem, + Dialog, + Field, + TimePicker, + DatePicker, + Form +} from 'vant'; + +import share from '@/utils/share.js' +import tootls from './utils/util.map.js' + +// #ifndef VUE3 +import Vue from 'vue'; + +// Vue.prototype.$tootls = tootls + + +// 导入并挂载全局的分享方法 + +Vue.config.productionTip = false; +App.mpType = 'app'; +const app = new Vue({ + ...App +}); +app.$mount(); + +// #endif + +// #ifdef VUE3 +import { + createSSRApp +} from 'vue'; +export function createApp() { + const app = createSSRApp(App); + app.config.globalProperties.$tootls = tootls; + app.use(Button); + app.use(Tab); + app.use(Tabs); + app.use(Empty); + app.use(Loading); + app.use(Icon); + app.use(CellGroup); + app.use(Cell); + app.use(NavBar); + app.use(Popup); + app.use(Picker); + app.use(Rate); + app.use(SwipeCell); + app.use(Search); + app.use(Uploader); + app.use(NoticeBar); + app.use(Checkbox); + app.use(Cascader); + app.use(Grid); + app.use(GridItem); + app.use(Dialog); + app.use(Field); + app.use(TimePicker); + app.use(DatePicker); + app.use(Form); + // app.mixin(zpMixins); + return { + app + }; +} +// #endif \ No newline at end of file diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..d3593eb --- /dev/null +++ b/src/manifest.json @@ -0,0 +1,83 @@ +{ + "name" : "", + "appid" : "", + "description" : "", + "versionName" : "1.0.0", + "versionCode" : "100", + "transformPx" : false, + /* 5+App特有相关 */ + "app-plus" : { + "usingComponents" : true, + "nvueStyleCompiler" : "uni-app", + "compilerVersion" : 3, + "splashscreen" : { + "alwaysShowBeforeRender" : true, + "waiting" : true, + "autoclose" : true, + "delay" : 0 + }, + /* 模块配置 */ + "modules" : {}, + /* 应用发布信息 */ + "distribute" : { + /* android打包配置 */ + "android" : { + "permissions" : [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + /* ios打包配置 */ + "ios" : {}, + /* SDK配置 */ + "sdkConfigs" : {} + } + }, + /* 快应用特有相关 */ + "quickapp" : {}, + /* 小程序特有相关 */ + "mp-weixin" : { + "appid" : "", + "setting" : { + "urlCheck" : false + }, + "usingComponents" : true + }, + "mp-alipay" : { + "usingComponents" : true + }, + "mp-baidu" : { + "usingComponents" : true + }, + "mp-toutiao" : { + "usingComponents" : true + }, + "uniStatistics" : { + "enable" : false + }, + "vueVersion" : "3", + "h5" : { + "sdkConfigs" : { + "maps" : { + "amap" : { + "key" : "29103dae675e5788eb011fb77ade8e3f", + "securityJsCode" : "", + "serviceHost" : "" + } + } + } + } +} diff --git a/src/miniprogram_npm/dayjs/index.js b/src/miniprogram_npm/dayjs/index.js new file mode 100644 index 0000000..4dad4de --- /dev/null +++ b/src/miniprogram_npm/dayjs/index.js @@ -0,0 +1,518 @@ +module.exports = (function () { + var __MODS__ = {}; + var __DEFINE__ = function (modId, func, req) { + var m = { + exports: {}, + _tempexports: {} + }; + __MODS__[modId] = { + status: 0, + func: func, + req: req, + m: m + }; + }; + var __REQUIRE__ = function (modId, source) { + if (!__MODS__[modId]) { + return require(source); + } + if (!__MODS__[modId].status) { + var m = __MODS__[modId].m; + m._exports = m._tempexports; + var desp = Object.getOwnPropertyDescriptor(m, 'exports'); + if (desp && desp.configurable) { + Object.defineProperty(m, 'exports', { + set: function (val) { + if (typeof val === 'object' && val !== m._exports) { + m._exports.__proto__ = val.__proto__; + Object.keys(val).forEach(function (k) { + m._exports[k] = val[k]; + }); + } + m._tempexports = val; + }, + get: function () { + return m._tempexports; + } + }); + } + __MODS__[modId].status = 1; + __MODS__[modId].func(__MODS__[modId].req, m, m.exports); + } + return __MODS__[modId].m.exports; + }; + __DEFINE__( + 1683361815807, + function (require, module, exports) { + !(function (t, e) { + if ('object' == typeof exports && 'undefined' != typeof module) { + module.exports = e(); + } else { + if ('function' == typeof define && define.amd) { + define(e); + } else { + (t = 'undefined' != typeof globalThis ? globalThis : t || self).dayjs = e(); + } + } + })(this, function () { + var t = 1000; + var e = 60000; + var n = 3600000; + var r = 'millisecond'; + var i = 'second'; + var s = 'minute'; + var u = 'hour'; + var a = 'day'; + var o = 'week'; + var f = 'month'; + var h = 'quarter'; + var c = 'year'; + var d = 'date'; + var l = 'Invalid Date'; + var $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/; + var y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g; + var M = { + name: 'en', + weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), + months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), + ordinal: function (t) { + var e = ['th', 'st', 'nd', 'rd']; + var n = t % 100; + return '[' + t + (e[(n - 20) % 10] || e[n] || e[0]) + ']'; + } + }; + var m = function (t, e, n) { + var r = String(t); + return !r || r.length >= e ? t : '' + Array(e + 1 - r.length).join(n) + t; + }; + var v = { + s: m, + z: function (t) { + var e = -t.utcOffset(); + var n = Math.abs(e); + var r = Math.floor(n / 60); + var i = n % 60; + return (e <= 0 ? '+' : '-') + m(r, 2, '0') + ':' + m(i, 2, '0'); + }, + m: function t(e, n) { + if (e.date() < n.date()) { + return -t(n, e); + } + var r = 12 * (n.year() - e.year()) + (n.month() - e.month()); + var i = e.clone().add(r, f); + var s = n - i < 0; + var u = e.clone().add(r + (s ? -1 : 1), f); + return +(-(r + (n - i) / (s ? i - u : u - i)) || 0); + }, + a: function (t) { + return t < 0 ? Math.ceil(t) || 0 : Math.floor(t); + }, + p: function (t) { + return ( + { + M: f, + y: c, + w: o, + d: a, + D: d, + h: u, + m: s, + s: i, + ms: r, + Q: h + }[t] || + String(t || '') + .toLowerCase() + .replace(/s$/, '') + ); + }, + u: function (t) { + return void 0 === t; + } + }; + var g = 'en'; + var D = {}; + D[g] = M; + var p = function (t) { + return t instanceof _; + }; + var S = function t(e, n, r) { + var i; + if (!e) { + return g; + } + if ('string' == typeof e) { + var s = e.toLowerCase(); + if (D[s]) { + i = s; + } + if (n) { + D[s] = n; + i = s; + } + var u = e.split('-'); + if (!i && u.length > 1) { + return t(u[0]); + } + } else { + var a = e.name; + D[a] = e; + i = a; + } + if (!r && i) { + g = i; + } + return i || (!r && g); + }; + var w = function (t, e) { + if (p(t)) { + return t.clone(); + } + if ('object' == typeof e) { + var n = e; + } else { + var n = {}; + } + n.date = t; + n.args = arguments; + return new _(n); + }; + var O = v; + O.l = S; + O.i = p; + O.w = function (t, e) { + return w(t, { + locale: e.$L, + utc: e.$u, + x: e.$x, + $offset: e.$offset + }); + }; + var _ = (function () { + function M(t) { + this.$L = S(t.locale, null, true); + this.parse(t); + } + var m = M.prototype; + m.parse = function (t) { + this.$d = (function (t) { + var e = t.date; + var n = t.utc; + if (null === e) { + return new Date(NaN); + } + if (O.u(e)) { + return new Date(); + } + if (e instanceof Date) { + return new Date(e); + } + if ('string' == typeof e && !/Z$/i.test(e)) { + var r = e.match($); + if (r) { + var i = r[2] - 1 || 0; + var s = (r[7] || '0').substring(0, 3); + return n + ? new Date(Date.UTC(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s)) + : new Date(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s); + } + } + return new Date(e); + })(t); + this.$x = t.x || {}; + this.init(); + }; + m.init = function () { + var t = this.$d; + this.$y = t.getFullYear(); + this.$M = t.getMonth(); + this.$D = t.getDate(); + this.$W = t.getDay(); + this.$H = t.getHours(); + this.$m = t.getMinutes(); + this.$s = t.getSeconds(); + this.$ms = t.getMilliseconds(); + }; + m.$utils = function () { + return O; + }; + m.isValid = function () { + return !(this.$d.toString() === l); + }; + m.isSame = function (t, e) { + var n = w(t); + return this.startOf(e) <= n && n <= this.endOf(e); + }; + m.isAfter = function (t, e) { + return w(t) < this.startOf(e); + }; + m.isBefore = function (t, e) { + return this.endOf(e) < w(t); + }; + m.$g = function (t, e, n) { + return O.u(t) ? this[e] : this.set(n, t); + }; + m.unix = function () { + return Math.floor(this.valueOf() / 1000); + }; + m.valueOf = function () { + return this.$d.getTime(); + }; + m.startOf = function (t, e) { + var that = this; + var r = !!O.u(e) || e; + var h = O.p(t); + var l = function (t, e) { + var i = O.w(that.$u ? Date.UTC(that.$y, e, t) : new Date(that.$y, e, t), that); + return r ? i : i.endOf(a); + }; + var $ = function (t, e) { + return O.w(that.toDate()[t].apply(that.toDate('s'), (r ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e)), that); + }; + var y = this.$W; + var M = this.$M; + var m = this.$D; + var v = 'set' + (this.$u ? 'UTC' : ''); + switch (h) { + case c: + return r ? l(1, 0) : l(31, 11); + case f: + return r ? l(1, M) : l(0, M + 1); + case o: + var g = this.$locale().weekStart || 0; + var D = (y < g ? y + 7 : y) - g; + return l(r ? m - D : m + (6 - D), M); + case a: + case d: + return $(v + 'Hours', 0); + case u: + return $(v + 'Minutes', 1); + case s: + return $(v + 'Seconds', 2); + case i: + return $(v + 'Milliseconds', 3); + default: + return this.clone(); + } + }; + m.endOf = function (t) { + return this.startOf(t, false); + }; + m.$set = function (t, e) { + var n; + var o = O.p(t); + var h = 'set' + (this.$u ? 'UTC' : ''); + var l = ((n = {}), + (n[a] = h + 'Date'), + (n[d] = h + 'Date'), + (n[f] = h + 'Month'), + (n[c] = h + 'FullYear'), + (n[u] = h + 'Hours'), + (n[s] = h + 'Minutes'), + (n[i] = h + 'Seconds'), + (n[r] = h + 'Milliseconds'), + n)[o]; + if (o === a) { + var $ = this.$D + (e - this.$W); + } else { + var $ = e; + } + if (o === f || o === c) { + var y = this.clone().set(d, 1); + y.$d[l]($); + y.init(); + this.$d = y.set(d, Math.min(this.$D, y.daysInMonth())).$d; + } else { + if (l) { + this.$d[l]($); + } + } + this.init(); + return this; + }; + m.set = function (t, e) { + return this.clone().$set(t, e); + }; + m.get = function (t) { + return this[O.p(t)](); + }; + m.add = function (r, h) { + var d; + var that = this; + r = Number(r); + var $ = O.p(h); + var y = function (t) { + var e = w(that); + return O.w(e.date(e.date() + Math.round(t * r)), that); + }; + if ($ === f) { + return this.set(f, this.$M + r); + } + if ($ === c) { + return this.set(c, this.$y + r); + } + if ($ === a) { + return y(1); + } + if ($ === o) { + return y(7); + } + var M = ((d = {}), (d[s] = e), (d[u] = n), (d[i] = t), d)[$] || 1; + var m = this.$d.getTime() + r * M; + return O.w(m, this); + }; + m.subtract = function (t, e) { + return this.add(-1 * t, e); + }; + m.format = function (t) { + var that = this; + var n = this.$locale(); + if (!this.isValid()) { + return n.invalidDate || l; + } + var r = t || 'YYYY-MM-DDTHH:mm:ssZ'; + var i = O.z(this); + var s = this.$H; + var u = this.$m; + var a = this.$M; + var o = n.weekdays; + var f = n.months; + var h = function (t, n, i, s) { + return (t && (t[n] || t(that, r))) || i[n].slice(0, s); + }; + var c = function (t) { + return O.s(s % 12 || 12, t, '0'); + }; + var d = + n.meridiem || + function (t, e, n) { + var r = t < 12 ? 'AM' : 'PM'; + return n ? r.toLowerCase() : r; + }; + var $ = { + YY: String(this.$y).slice(-2), + YYYY: this.$y, + M: a + 1, + MM: O.s(a + 1, 2, '0'), + MMM: h(n.monthsShort, a, f, 3), + MMMM: h(f, a), + D: this.$D, + DD: O.s(this.$D, 2, '0'), + d: String(this.$W), + dd: h(n.weekdaysMin, this.$W, o, 2), + ddd: h(n.weekdaysShort, this.$W, o, 3), + dddd: o[this.$W], + H: String(s), + HH: O.s(s, 2, '0'), + h: c(1), + hh: c(2), + a: d(s, u, true), + A: d(s, u, false), + m: String(u), + mm: O.s(u, 2, '0'), + s: String(this.$s), + ss: O.s(this.$s, 2, '0'), + SSS: O.s(this.$ms, 3, '0'), + Z: i + }; + return r.replace(y, function (t, e) { + return e || $[t] || i.replace(':', ''); + }); + }; + m.utcOffset = function () { + return 15 * -Math.round(this.$d.getTimezoneOffset() / 15); + }; + m.diff = function (r, d, l) { + var $; + var y = O.p(d); + var M = w(r); + var m = (M.utcOffset() - this.utcOffset()) * e; + var v = this - M; + var g = O.m(this, M); + g = + (($ = {}), + ($[c] = g / 12), + ($[f] = g), + ($[h] = g / 3), + ($[o] = (v - m) / 604800000), + ($[a] = (v - m) / 86400000), + ($[u] = v / n), + ($[s] = v / e), + ($[i] = v / t), + $)[y] || v; + return l ? g : O.a(g); + }; + m.daysInMonth = function () { + return this.endOf(f).$D; + }; + m.$locale = function () { + return D[this.$L]; + }; + m.locale = function (t, e) { + if (!t) { + return this.$L; + } + var n = this.clone(); + var r = S(t, e, true); + if (r) { + n.$L = r; + } + return n; + }; + m.clone = function () { + return O.w(this.$d, this); + }; + m.toDate = function () { + return new Date(this.valueOf()); + }; + m.toJSON = function () { + return this.isValid() ? this.toISOString() : null; + }; + m.toISOString = function () { + return this.$d.toISOString(); + }; + m.toString = function () { + return this.$d.toUTCString(); + }; + return M; + })(); + var T = _.prototype; + w.prototype = T; + [ + ['$ms', r], + ['$s', i], + ['$m', s], + ['$H', u], + ['$W', a], + ['$M', f], + ['$y', c], + ['$D', d] + ].forEach(function (t) { + T[t[1]] = function (e) { + return this.$g(e, t[0], t[1]); + }; + }); + w.extend = function (t, e) { + t.$i || (t(e, _, w), (t.$i = true)); + return w; + }; + w.locale = S; + w.isDayjs = p; + w.unix = function (t) { + return w(1000 * t); + }; + w.en = D[g]; + w.Ls = D; + w.p = {}; + return w; + }); + }, + function (modId) { + var map = {}; + return __REQUIRE__(map[modId], modId); + } + ); + return __REQUIRE__(1683361815807); +})(); +//miniprogram-npm-outsideDeps=[] +//# sourceMappingURL=index.js.map diff --git a/src/miniprogram_npm/dayjs/index.js.map b/src/miniprogram_npm/dayjs/index.js.map new file mode 100644 index 0000000..66ff3ab --- /dev/null +++ b/src/miniprogram_npm/dayjs/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["dayjs.min.js"],"names":[],"mappings":";;;;;;;AAAA","file":"index.js","sourcesContent":["!function(t,e){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=e():\"function\"==typeof define&&define.amd?define(e):(t=\"undefined\"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){var t=1e3,e=6e4,n=36e5,r=\"millisecond\",i=\"second\",s=\"minute\",u=\"hour\",a=\"day\",o=\"week\",f=\"month\",h=\"quarter\",c=\"year\",d=\"date\",l=\"Invalid Date\",$=/^(\\d{4})[-/]?(\\d{1,2})?[-/]?(\\d{0,2})[Tt\\s]*(\\d{1,2})?:?(\\d{1,2})?:?(\\d{1,2})?[.:]?(\\d+)?$/,y=/\\[([^\\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:\"en\",weekdays:\"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday\".split(\"_\"),months:\"January_February_March_April_May_June_July_August_September_October_November_December\".split(\"_\"),ordinal:function(t){var e=[\"th\",\"st\",\"nd\",\"rd\"],n=t%100;return\"[\"+t+(e[(n-20)%10]||e[n]||e[0])+\"]\"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:\"\"+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?\"+\":\"-\")+m(r,2,\"0\")+\":\"+m(i,2,\"0\")},m:function t(e,n){if(e.date()1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n=\"object\"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t)}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if(\"string\"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||\"0\").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return O},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t) + + + + + + + + diff --git a/src/miniprogram_npm/mp-html/node/node-el.vue b/src/miniprogram_npm/mp-html/node/node-el.vue new file mode 100644 index 0000000..27bae75 --- /dev/null +++ b/src/miniprogram_npm/mp-html/node/node-el.vue @@ -0,0 +1,124 @@ + + + + diff --git a/src/miniprogram_npm/mp-html/node/node.vue b/src/miniprogram_npm/mp-html/node/node.vue new file mode 100644 index 0000000..2b687d0 --- /dev/null +++ b/src/miniprogram_npm/mp-html/node/node.vue @@ -0,0 +1,479 @@ + + + + diff --git a/src/miniprogram_npm/mp-html/parser.js b/src/miniprogram_npm/mp-html/parser.js new file mode 100644 index 0000000..f219735 --- /dev/null +++ b/src/miniprogram_npm/mp-html/parser.js @@ -0,0 +1,410 @@ +"use strict"; +function t(t) { + for (var i = Object.create(null), e = t.split(","), s = e.length; s--;) i[e[s]] = !0; + return i; +} +function i(t, i) { + for (var e = t.indexOf("&"); -1 !== e;) { + var s = t.indexOf(";", e + 3), + a = void 0; + if (-1 === s) break; + "#" === t[e + 1] ? (a = parseInt(("x" === t[e + 2] ? "0" : "") + t.substring(e + 2, s)), isNaN(a) || (t = t.substr(0, e) + String.fromCharCode(a) + t.substr(s + 1))) : (a = t.substring(e + 1, s), (n.entities[a] || "amp" === a && i) && (t = t.substr(0, e) + (n.entities[a] || "&") + t.substr(s + 1))), e = t.indexOf("&", e + 1); + } + return t; +} +function e(t) { + for (var i = t.length - 1, e = i; e >= -1; e--) (-1 === e || t[e].c || !t[e].name || "div" !== t[e].name && "p" !== t[e].name && "h" !== t[e].name[0] || (t[e].attrs.style || "").includes("inline")) && (i - e >= 5 && t.splice(e + 1, i - e, { + name: "div", + attrs: {}, + children: t.slice(e + 1, i + 1) + }), i = e - 1); +} +function s(t) { + this.options = t.data || {}, this.tagStyle = Object.assign({}, n.tagStyle, this.options.tagStyle), this.imgList = t.imgList || [], this.imgList._unloadimgs = 0, this.plugins = t.plugins || [], this.attrs = Object.create(null), this.stack = [], this.nodes = [], this.pre = (this.options.containerStyle || "").includes("white-space") && this.options.containerStyle.includes("pre") ? 2 : 0; +} +function a(t) { + this.handler = t; +} +var n = { + trustTags: t("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,ruby,rt,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video"), + blockTags: t("address,article,aside,body,caption,center,cite,footer,header,html,nav,pre,section"), + ignoreTags: t("area,base,canvas,embed,frame,head,iframe,input,link,map,meta,param,rp,script,source,style,textarea,title,track,wbr"), + voidTags: t("area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr"), + entities: { + lt: "<", + gt: ">", + quot: '"', + apos: "'", + ensp: " ", + emsp: " ", + nbsp: " ", + semi: ";", + ndash: "–", + mdash: "—", + middot: "·", + lsquo: "‘", + rsquo: "’", + ldquo: "“", + rdquo: "”", + bull: "•", + hellip: "…", + larr: "←", + uarr: "↑", + rarr: "→", + darr: "↓" + }, + tagStyle: { + address: "font-style:italic", + big: "display:inline;font-size:1.2em", + caption: "display:table-caption;text-align:center", + center: "text-align:center", + cite: "font-style:italic", + dd: "margin-left:40px", + mark: "background-color:yellow", + pre: "font-family:monospace;white-space:pre", + s: "text-decoration:line-through", + small: "display:inline;font-size:0.8em", + strike: "text-decoration:line-through", + u: "text-decoration:underline" + }, + svgDict: { + animatetransform: "animateTransform", + lineargradient: "linearGradient", + viewbox: "viewBox", + attributename: "attributeName", + repeatcount: "repeatCount", + repeatdur: "repeatDur" + } + }, + r = {}, + o = uni.getSystemInfoSync(), + h = o.windowWidth, + l = o.system, + c = t(" ,\r,\n,\t,\f"), + d = 0; +s.prototype.parse = function (t) { + for (var i = this.plugins.length; i--;) this.plugins[i].onUpdate && (t = this.plugins[i].onUpdate(t, n) || t); + for (new a(this).parse(t); this.stack.length;) this.popNode(); + return this.nodes.length > 50 && e(this.nodes), this.nodes; +}, s.prototype.expose = function () { + for (var t = this.stack.length; t--;) { + var i = this.stack[t]; + if (i.c || "a" === i.name || "video" === i.name || "audio" === i.name) return; + i.c = 1; + } +}, s.prototype.hook = function (t) { + for (var i = this.plugins.length; i--;) if (this.plugins[i].onParse && !1 === this.plugins[i].onParse(t, this)) return !1; + return !0; +}, s.prototype.getUrl = function (t) { + var i = this.options.domain; + return "/" === t[0] ? "/" === t[1] ? t = (i ? i.split("://")[0] : "http") + ":" + t : i && (t = i + t) : !i || t.includes("data:") || t.includes("://") || (t = i + "/" + t), t; +}, s.prototype.parseStyle = function (t) { + var i = t.attrs, + e = (this.tagStyle[t.name] || "").split(";").concat((i.style || "").split(";")), + s = {}, + a = ""; + i.id && !this.xml && (this.options.useAnchor ? this.expose() : "img" !== t.name && "a" !== t.name && "video" !== t.name && "audio" !== t.name && (i.id = void 0)), i.width && (s.width = parseFloat(i.width) + (i.width.includes("%") ? "%" : "px"), i.width = void 0), i.height && (s.height = parseFloat(i.height) + (i.height.includes("%") ? "%" : "px"), i.height = void 0); + for (var n = 0, r = e.length; n < r; n++) { + var o = e[n].split(":"); + if (!(o.length < 2)) { + var l = o.shift().trim().toLowerCase(), + d = o.join(":").trim(); + if ("-" === d[0] && d.lastIndexOf("-") > 0 || d.includes("safe")) a += ";".concat(l, ":").concat(d);else if (!s[l] || d.includes("import") || !s[l].includes("import")) { + if (d.includes("url")) { + var p = d.indexOf("(") + 1; + if (p) { + for (; '"' === d[p] || "'" === d[p] || c[d[p]];) p++; + d = d.substr(0, p) + this.getUrl(d.substr(p)); + } + } else d.includes("rpx") && (d = d.replace(/[0-9.]+\s*rpx/g, function (t) { + return parseFloat(t) * h / 750 + "px"; + })); + s[l] = d; + } + } + } + return t.attrs.style = a, s; +}, s.prototype.onTagName = function (t) { + this.tagName = this.xml ? t : t.toLowerCase(), "svg" === this.tagName && (this.xml = (this.xml || 0) + 1); +}, s.prototype.onAttrName = function (t) { + t = this.xml ? t : t.toLowerCase(), "data-" === t.substr(0, 5) ? "data-src" !== t || this.attrs.src ? "img" === this.tagName || "a" === this.tagName ? this.attrName = t : this.attrName = void 0 : this.attrName = "src" : (this.attrName = t, this.attrs[t] = "T"); +}, s.prototype.onAttrVal = function (t) { + var e = this.attrName || ""; + "style" === e || "href" === e ? this.attrs[e] = i(t, !0) : e.includes("src") ? this.attrs[e] = this.getUrl(i(t, !0)) : e && (this.attrs[e] = t); +}, s.prototype.onOpenTag = function (t) { + var i = Object.create(null); + i.name = this.tagName, i.attrs = this.attrs, this.attrs = Object.create(null); + var e = i.attrs, + s = this.stack[this.stack.length - 1], + a = s ? s.children : this.nodes, + o = this.xml ? t : n.voidTags[i.name]; + if (r[i.name] && (e.class = r[i.name] + (e.class ? " " + e.class : "")), "embed" === i.name) { + var l = e.src || ""; + l.includes(".mp4") || l.includes(".3gp") || l.includes(".m3u8") || (e.type || "").includes("video") ? i.name = "video" : (l.includes(".mp3") || l.includes(".wav") || l.includes(".aac") || l.includes(".m4a") || (e.type || "").includes("audio")) && (i.name = "audio"), e.autostart && (e.autoplay = "T"), e.controls = "T"; + } + if ("video" !== i.name && "audio" !== i.name || ("video" !== i.name || e.id || (e.id = "v" + d++), e.controls || e.autoplay || (e.controls = "T"), i.src = [], e.src && (i.src.push(e.src), e.src = void 0), this.expose()), o) { + if (!this.hook(i) || n.ignoreTags[i.name]) return void ("base" !== i.name || this.options.domain ? "source" === i.name && s && ("video" === s.name || "audio" === s.name) && e.src && s.src.push(e.src) : this.options.domain = e.href); + var c = this.parseStyle(i); + if ("img" === i.name) { + if (e.src && (e.src.includes("webp") && (i.webp = "T"), e.src.includes("data:") && !e["original-src"] && (e.ignore = "T"), !e.ignore || i.webp || e.src.includes("cloud://"))) { + for (var p = this.stack.length; p--;) { + var u = this.stack[p]; + "table" !== u.name || i.webp || e.src.includes("cloud://") || (!c.display || c.display.includes("inline") ? i.t = "inline-block" : i.t = c.display, c.display = void 0); + var g = u.attrs.style || ""; + if (!g.includes("flex:") || g.includes("flex:0") || g.includes("flex: 0") || c.width && !(parseInt(c.width) > 100)) { + if (g.includes("flex") && "100%" === c.width) for (var f = p + 1; f < this.stack.length; f++) { + var m = this.stack[f].attrs.style || ""; + if (!m.includes(";width") && !m.includes(" width") && 0 !== m.indexOf("width")) { + c.width = ""; + break; + } + } else g.includes("inline-block") && (c.width && "%" === c.width[c.width.length - 1] ? (u.attrs.style += ";max-width:" + c.width, c.width = "") : u.attrs.style += ";max-width:100%"); + } else { + c.width = "100% !important", c.height = ""; + for (var v = p + 1; v < this.stack.length; v++) this.stack[v].attrs.style = (this.stack[v].attrs.style || "").replace("inline-", ""); + } + "a" === u.name ? i.a = u.attrs : u.c = 1; + } + i.i = this.imgList.length; + var y = e["original-src"] || e.src; + if (this.imgList.includes(y)) { + var x = y.indexOf("://"); + if (-1 !== x) { + x += 3; + for (var b = y.substr(0, x); x < y.length && "/" !== y[x]; x++) b += Math.random() > .5 ? y[x].toUpperCase() : y[x]; + b += y.substr(x), y = b; + } + } + this.imgList.push(y), i.t || (this.imgList._unloadimgs += 1); + } + "inline" === c.display && (c.display = ""), e.ignore && (c["max-width"] = c["max-width"] || "100%", e.style += ";-webkit-touch-callout:none"), parseInt(c.width) > h && (c.height = void 0), isNaN(parseInt(c.width)) || (i.w = "T"), !isNaN(parseInt(c.height)) && (!c.height.includes("%") || s && (s.attrs.style || "").includes("height")) && (i.h = "T"); + } else if ("svg" === i.name) return a.push(i), this.stack.push(i), void this.popNode(); + for (var w in c) c[w] && (e.style += ";".concat(w, ":").concat(c[w].replace(" !important", ""))); + e.style = e.style.substr(1) || void 0; + } else ("pre" === i.name || (e.style || "").includes("white-space") && e.style.includes("pre")) && 2 !== this.pre && (this.pre = i.pre = 1), i.children = [], this.stack.push(i); + a.push(i); +}, s.prototype.onCloseTag = function (t) { + t = this.xml ? t : t.toLowerCase(); + var i; + for (i = this.stack.length; i-- && this.stack[i].name !== t;); + if (-1 !== i) for (; this.stack.length > i;) this.popNode();else if ("p" === t || "br" === t) { + var e = this.stack.length ? this.stack[this.stack.length - 1].children : this.nodes; + e.push({ + name: t, + attrs: { + class: r[t], + style: this.tagStyle[t] + } + }); + } +}, s.prototype.popNode = function () { + var t = this.stack.pop(), + i = t.attrs, + s = t.children, + a = this.stack[this.stack.length - 1], + r = a ? a.children : this.nodes; + if (!this.hook(t) || n.ignoreTags[t.name]) return "title" === t.name && s.length && "text" === s[0].type && this.options.setTitle && uni.setNavigationBarTitle({ + title: s[0].text + }), void r.pop(); + if (t.pre && 2 !== this.pre) { + this.pre = t.pre = void 0; + for (var o = this.stack.length; o--;) this.stack[o].pre && (this.pre = 1); + } + if ("svg" === t.name) { + if (this.xml > 1) return void this.xml--; + var l = "", + c = i.style; + return i.style = "", i.xmlns = "http://www.w3.org/2000/svg", function t(i) { + if ("text" === i.type) return void (l += i.text); + var e = n.svgDict[i.name] || i.name; + l += "<" + e; + for (var s in i.attrs) { + var a = i.attrs[s]; + a && (l += " ".concat(n.svgDict[s] || s, '="').concat(a, '"')); + } + if (i.children) { + l += ">"; + for (var r = 0; r < i.children.length; r++) t(i.children[r]); + l += ""; + } else l += "/>"; + }(t), t.name = "img", t.attrs = { + src: "data:image/svg+xml;utf8," + l.replace(/#/g, "%23"), + style: c, + ignore: "T" + }, t.children = void 0, void (this.xml = !1); + } + var d = {}; + if (i.align && ("table" === t.name ? "center" === i.align ? d["margin-inline-start"] = d["margin-inline-end"] = "auto" : d.float = i.align : d["text-align"] = i.align, i.align = void 0), i.dir && (d.direction = i.dir, i.dir = void 0), "font" === t.name && (i.color && (d.color = i.color, i.color = void 0), i.face && (d["font-family"] = i.face, i.face = void 0), i.size)) { + var p = parseInt(i.size); + isNaN(p) || (p < 1 ? p = 1 : p > 7 && (p = 7), d["font-size"] = ["x-small", "small", "medium", "large", "x-large", "xx-large", "xxx-large"][p - 1]), i.size = void 0; + } + if ((i.class || "").includes("align-center") && (d["text-align"] = "center"), Object.assign(d, this.parseStyle(t)), "table" !== t.name && parseInt(d.width) > h && (d["max-width"] = "100%", d["box-sizing"] = "border-box"), n.blockTags[t.name]) t.name = "div";else if (n.trustTags[t.name] || this.xml) { + if ("a" === t.name || "ad" === t.name) this.expose();else if ("video" === t.name || "audio" === t.name) (d.height || "").includes("auto") && (d.height = void 0), t.children = void 0;else if ("ul" !== t.name && "ol" !== t.name || !t.c) { + if ("table" === t.name) { + var u = parseFloat(i.cellpadding), + g = parseFloat(i.cellspacing), + f = parseFloat(i.border), + m = d["border-color"], + v = d["border-style"]; + if (t.c && (isNaN(u) && (u = 2), isNaN(g) && (g = 2)), f && (i.style += ";border:".concat(f, "px ").concat(v || "solid", " ").concat(m || "gray")), t.flag && t.c) { + t.flag = void 0, d.display = "grid", g ? (d["grid-gap"] = g + "px", d.padding = g + "px") : f && (i.style += ";border-left:0;border-top:0"); + var y = [], + x = [], + b = [], + w = {}; + !function t(i) { + for (var e = 0; e < i.length; e++) "tr" === i[e].name ? x.push(i[e]) : t(i[e].children || []); + }(s); + for (var k = 1; k <= x.length; k++) { + for (var N = 1, T = 0; T < x[k - 1].children.length; T++) { + var O = x[k - 1].children[T]; + if ("td" === O.name || "th" === O.name) { + for (; w[k + "." + N];) N++; + O.c = 1; + var C = O.attrs.style || "", + S = C.indexOf("width") ? C.indexOf(";width") : 0; + if (-1 !== S) { + var I = C.indexOf(";", S + 6); + -1 === I && (I = C.length), O.attrs.colspan || (y[N] = C.substring(S ? S + 7 : 6, I)), C = C.substr(0, S) + C.substr(I); + } + if (C += ";display:flex", -1 !== (S = C.indexOf("vertical-align"))) { + var j = C.substr(S + 15, 10); + j.includes("middle") ? C += ";align-items:center" : j.includes("bottom") && (C += ";align-items:flex-end"); + } else C += ";align-items:center"; + if (-1 !== (S = C.indexOf("text-align"))) { + var A = C.substr(S + 11, 10); + A.includes("center") ? C += ";justify-content: center" : A.includes("right") && (C += ";justify-content: right"); + } + if (C = (f ? ";border:".concat(f, "px ").concat(v || "solid", " ").concat(m || "gray") + (g ? "" : ";border-right:0;border-bottom:0") : "") + (u ? ";padding:".concat(u, "px") : "") + ";" + C, O.attrs.colspan && (C += ";grid-column-start:".concat(N, ";grid-column-end:").concat(N + parseInt(O.attrs.colspan)), O.attrs.rowspan || (C += ";grid-row-start:".concat(k, ";grid-row-end:").concat(k + 1)), N += parseInt(O.attrs.colspan) - 1), O.attrs.rowspan) { + C += ";grid-row-start:".concat(k, ";grid-row-end:").concat(k + parseInt(O.attrs.rowspan)), O.attrs.colspan || (C += ";grid-column-start:".concat(N, ";grid-column-end:").concat(N + 1)); + for (var L = 1; L < O.attrs.rowspan; L++) for (var z = 0; z < (O.attrs.colspan || 1); z++) w[k + L + "." + (N - z)] = 1; + } + C && (O.attrs.style = C), b.push(O), N++; + } + } + if (1 === k) { + for (var q = "", U = 1; U < N; U++) q += (y[U] ? y[U] : "auto") + " "; + d["grid-template-columns"] = q; + } + } + t.children = b; + } else t.c && (d.display = "table"), isNaN(g) || (d["border-spacing"] = g + "px"), (f || u || t.c) && function i(e) { + for (var s = 0; s < e.length; s++) { + var a = e[s]; + t.c && (a.c = 1), "th" === a.name || "td" === a.name ? (f && (a.attrs.style = "border:".concat(f, "px ").concat(v || "solid", " ").concat(m || "gray", ";").concat(a.attrs.style || "")), u && (a.attrs.style = "padding:".concat(u, "px;").concat(a.attrs.style || ""))) : a.children && i(a.children); + } + }(s); + if (this.options.scrollTable && !(i.style || "").includes("inline")) { + var F = Object.assign({}, t); + t.name = "div", t.attrs = { + style: "overflow-x:auto;padding:1px" + }, t.children = [F], i = F.attrs; + } + } else if ("td" !== t.name && "th" !== t.name || !i.colspan && !i.rowspan) { + if ("ruby" === t.name) { + t.name = "span"; + for (var V = 0; V < s.length - 1; V++) "text" === s[V].type && "rt" === s[V + 1].name && (s[V] = { + name: "span", + attrs: { + style: "display:inline-block;text-align:center" + }, + children: [{ + name: "div", + attrs: { + style: "font-size:50%;" + (s[V + 1].attrs.style || "") + }, + children: s[V + 1].children + }, s[V]] + }, s.splice(V + 1, 1)); + } + } else for (var D = this.stack.length; D--;) if ("table" === this.stack[D].name) { + this.stack[D].flag = 1; + break; + } + } else { + var B = { + a: "lower-alpha", + A: "upper-alpha", + i: "lower-roman", + I: "upper-roman" + }; + B[i.type] && (i.style += ";list-style-type:" + B[i.type], i.type = void 0), t.c = 1; + for (var P = s.length; P--;) "li" === s[P].name && (s[P].c = 1); + } + } else t.name = "span"; + if ((d.display || "").includes("flex") && !t.c) for (var Z = s.length; Z--;) { + var _ = s[Z]; + _.f && (_.attrs.style = (_.attrs.style || "") + _.f, _.f = void 0); + } + var G = a && ((a.attrs.style || "").includes("flex") || (a.attrs.style || "").includes("grid")) && !t.c && !(d.display || "").includes("inline"); + G && (t.f = ";max-width:100%"), s.length >= 50 && t.c && !(d.display || "").includes("flex") && e(s); + for (var M in d) if (d[M]) { + var W = ";".concat(M, ":").concat(d[M].replace(" !important", "")); + G && (M.includes("flex") && "flex-direction" !== M || "align-self" === M || M.includes("grid") || "-" === d[M][0] || M.includes("width") && W.includes("%")) ? (t.f += W, "width" === M && (i.style += ";width:100%")) : i.style += W; + } + i.style = i.style.substr(1) || void 0; +}, s.prototype.onText = function (t) { + if (!this.pre) { + for (var e, s = "", a = 0, n = t.length; a < n; a++) c[t[a]] ? (" " !== s[s.length - 1] && (s += " "), "\n" !== t[a] || e || (e = !0)) : s += t[a]; + if (" " === s && e) return; + t = s; + } + var r = Object.create(null); + if (r.type = "text", r.text = i(t), this.hook(r)) { + "force" === this.options.selectable && l.includes("iOS") && !uni.canIUse("rich-text.user-select") && this.expose(); + (this.stack.length ? this.stack[this.stack.length - 1].children : this.nodes).push(r); + } +}, a.prototype.parse = function (t) { + this.content = t || "", this.i = 0, this.start = 0, this.state = this.text; + for (var i = this.content.length; -1 !== this.i && this.i < i;) this.state(); +}, a.prototype.checkClose = function (t) { + var i = "/" === this.content[this.i]; + return !!(">" === this.content[this.i] || i && ">" === this.content[this.i + 1]) && (t && this.handler[t](this.content.substring(this.start, this.i)), this.i += i ? 2 : 1, this.start = this.i, this.handler.onOpenTag(i), "script" === this.handler.tagName ? (this.i = this.content.indexOf("= "a" && t <= "z" || t >= "A" && t <= "Z") this.start !== this.i && this.handler.onText(this.content.substring(this.start, this.i)), this.start = ++this.i, this.state = this.tagName;else if ("/" === t || "!" === t || "?" === t) { + this.start !== this.i && this.handler.onText(this.content.substring(this.start, this.i)); + var i = this.content[this.i + 2]; + if ("/" === t && (i >= "a" && i <= "z" || i >= "A" && i <= "Z")) return this.i += 2, this.start = this.i, void (this.state = this.endTag); + var e = "--\x3e"; + "!" === t && "-" === this.content[this.i + 2] && "-" === this.content[this.i + 3] || (e = ">"), this.i = this.content.indexOf(e, this.i), -1 !== this.i && (this.i += e.length, this.start = this.i); + } else this.i++; +}, a.prototype.tagName = function () { + if (c[this.content[this.i]]) { + for (this.handler.onTagName(this.content.substring(this.start, this.i)); c[this.content[++this.i]];); + this.i < this.content.length && !this.checkClose() && (this.start = this.i, this.state = this.attrName); + } else this.checkClose("onTagName") || this.i++; +}, a.prototype.attrName = function () { + var t = this.content[this.i]; + if (c[t] || "=" === t) { + this.handler.onAttrName(this.content.substring(this.start, this.i)); + for (var i = "=" === t, e = this.content.length; ++this.i < e;) if (t = this.content[this.i], !c[t]) { + if (this.checkClose()) return; + if (i) return this.start = this.i, void (this.state = this.attrVal); + if ("=" !== this.content[this.i]) return this.start = this.i, void (this.state = this.attrName); + i = !0; + } + } else this.checkClose("onAttrName") || this.i++; +}, a.prototype.attrVal = function () { + var t = this.content[this.i], + i = this.content.length; + if ('"' === t || "'" === t) { + if (this.start = ++this.i, this.i = this.content.indexOf(t, this.i), -1 === this.i) return; + this.handler.onAttrVal(this.content.substring(this.start, this.i)); + } else for (; this.i < i; this.i++) { + if (c[this.content[this.i]]) { + this.handler.onAttrVal(this.content.substring(this.start, this.i)); + break; + } + if (this.checkClose("onAttrVal")) return; + } + for (; c[this.content[++this.i]];); + this.i < i && !this.checkClose() && (this.start = this.i, this.state = this.attrName); +}, a.prototype.endTag = function () { + var t = this.content[this.i]; + if (c[t] || ">" === t || "/" === t) { + if (this.handler.onCloseTag(this.content.substring(this.start, this.i)), ">" !== t && (this.i = this.content.indexOf(">", this.i), -1 === this.i)) return; + this.start = ++this.i, this.state = this.text; + } else this.i++; +}, module.exports = s; \ No newline at end of file diff --git a/src/packages/enterprise/pages/create-enterprise/create-enterprise.vue b/src/packages/enterprise/pages/create-enterprise/create-enterprise.vue new file mode 100644 index 0000000..15dc371 --- /dev/null +++ b/src/packages/enterprise/pages/create-enterprise/create-enterprise.vue @@ -0,0 +1,181 @@ + + + + \ No newline at end of file diff --git a/src/packages/enterprise/pages/details/details.vue b/src/packages/enterprise/pages/details/details.vue new file mode 100644 index 0000000..dabdd25 --- /dev/null +++ b/src/packages/enterprise/pages/details/details.vue @@ -0,0 +1,340 @@ + + + + \ No newline at end of file diff --git a/src/packages/enterprise/pages/discount/discount-details.vue b/src/packages/enterprise/pages/discount/discount-details.vue new file mode 100644 index 0000000..775f324 --- /dev/null +++ b/src/packages/enterprise/pages/discount/discount-details.vue @@ -0,0 +1,72 @@ + + + + \ No newline at end of file diff --git a/src/packages/enterprise/pages/discount/discount-list.vue b/src/packages/enterprise/pages/discount/discount-list.vue new file mode 100644 index 0000000..aea2ffa --- /dev/null +++ b/src/packages/enterprise/pages/discount/discount-list.vue @@ -0,0 +1,199 @@ + + + + \ No newline at end of file diff --git a/src/packages/enterprise/pages/discount/discount.vue b/src/packages/enterprise/pages/discount/discount.vue new file mode 100644 index 0000000..07d609a --- /dev/null +++ b/src/packages/enterprise/pages/discount/discount.vue @@ -0,0 +1,228 @@ + + + + \ No newline at end of file diff --git a/src/packages/enterprise/pages/issue-appeal/issue-appeal.vue b/src/packages/enterprise/pages/issue-appeal/issue-appeal.vue new file mode 100644 index 0000000..d660acc --- /dev/null +++ b/src/packages/enterprise/pages/issue-appeal/issue-appeal.vue @@ -0,0 +1,444 @@ + + + + \ No newline at end of file diff --git a/src/packages/enterprise/pages/my-appeal/my-appeal.vue b/src/packages/enterprise/pages/my-appeal/my-appeal.vue new file mode 100644 index 0000000..80471dd --- /dev/null +++ b/src/packages/enterprise/pages/my-appeal/my-appeal.vue @@ -0,0 +1,345 @@ + + + + \ No newline at end of file diff --git a/src/packages/enterprise/pages/relation-enterprise/relation-enterprise.vue b/src/packages/enterprise/pages/relation-enterprise/relation-enterprise.vue new file mode 100644 index 0000000..91f56a3 --- /dev/null +++ b/src/packages/enterprise/pages/relation-enterprise/relation-enterprise.vue @@ -0,0 +1,211 @@ + + + + \ No newline at end of file diff --git a/src/packages/life/pages/life-list/life-list.vue b/src/packages/life/pages/life-list/life-list.vue new file mode 100644 index 0000000..9c73756 --- /dev/null +++ b/src/packages/life/pages/life-list/life-list.vue @@ -0,0 +1,243 @@ + + + + \ No newline at end of file diff --git a/src/packages/life/pages/scenic-list/scenic-list.vue b/src/packages/life/pages/scenic-list/scenic-list.vue new file mode 100644 index 0000000..bd71e1a --- /dev/null +++ b/src/packages/life/pages/scenic-list/scenic-list.vue @@ -0,0 +1,303 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/account/account.vue b/src/packages/my/pages/account/account.vue new file mode 100644 index 0000000..1daff46 --- /dev/null +++ b/src/packages/my/pages/account/account.vue @@ -0,0 +1,146 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/appeal/appeal.vue b/src/packages/my/pages/appeal/appeal.vue new file mode 100644 index 0000000..f227bff --- /dev/null +++ b/src/packages/my/pages/appeal/appeal.vue @@ -0,0 +1,146 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/certification/certification.vue b/src/packages/my/pages/certification/certification.vue new file mode 100644 index 0000000..eee815d --- /dev/null +++ b/src/packages/my/pages/certification/certification.vue @@ -0,0 +1,317 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/collection/collection.vue b/src/packages/my/pages/collection/collection.vue new file mode 100644 index 0000000..1d6a5a9 --- /dev/null +++ b/src/packages/my/pages/collection/collection.vue @@ -0,0 +1,191 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/create-server-record/create-server-record.vue b/src/packages/my/pages/create-server-record/create-server-record.vue new file mode 100644 index 0000000..d863e6a --- /dev/null +++ b/src/packages/my/pages/create-server-record/create-server-record.vue @@ -0,0 +1,468 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/integral/integral.vue b/src/packages/my/pages/integral/integral.vue new file mode 100644 index 0000000..9f0d641 --- /dev/null +++ b/src/packages/my/pages/integral/integral.vue @@ -0,0 +1,251 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/mediate/mediate.vue b/src/packages/my/pages/mediate/mediate.vue new file mode 100644 index 0000000..b1192e2 --- /dev/null +++ b/src/packages/my/pages/mediate/mediate.vue @@ -0,0 +1,146 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/message-center/message-center.vue b/src/packages/my/pages/message-center/message-center.vue new file mode 100644 index 0000000..a4ce4e1 --- /dev/null +++ b/src/packages/my/pages/message-center/message-center.vue @@ -0,0 +1,146 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/my-masses/my-masses-appraise.vue b/src/packages/my/pages/my-masses/my-masses-appraise.vue new file mode 100644 index 0000000..ea5a466 --- /dev/null +++ b/src/packages/my/pages/my-masses/my-masses-appraise.vue @@ -0,0 +1,295 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/my-masses/my-masses-details.vue b/src/packages/my/pages/my-masses/my-masses-details.vue new file mode 100644 index 0000000..2e9184e --- /dev/null +++ b/src/packages/my/pages/my-masses/my-masses-details.vue @@ -0,0 +1,739 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/my-masses/my-masses-reply.vue b/src/packages/my/pages/my-masses/my-masses-reply.vue new file mode 100644 index 0000000..251df1c --- /dev/null +++ b/src/packages/my/pages/my-masses/my-masses-reply.vue @@ -0,0 +1,514 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/my-masses/my-masses.vue b/src/packages/my/pages/my-masses/my-masses.vue new file mode 100644 index 0000000..4f88ab5 --- /dev/null +++ b/src/packages/my/pages/my-masses/my-masses.vue @@ -0,0 +1,444 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/my-patient-details/my-patient-details.vue b/src/packages/my/pages/my-patient-details/my-patient-details.vue new file mode 100644 index 0000000..edb2095 --- /dev/null +++ b/src/packages/my/pages/my-patient-details/my-patient-details.vue @@ -0,0 +1,458 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/my-patient/my-patient.vue b/src/packages/my/pages/my-patient/my-patient.vue new file mode 100644 index 0000000..c65a8f9 --- /dev/null +++ b/src/packages/my/pages/my-patient/my-patient.vue @@ -0,0 +1,191 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/party-member-auth/party-member-auth.vue b/src/packages/my/pages/party-member-auth/party-member-auth.vue new file mode 100644 index 0000000..b661446 --- /dev/null +++ b/src/packages/my/pages/party-member-auth/party-member-auth.vue @@ -0,0 +1,231 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/patient/patient.vue b/src/packages/my/pages/patient/patient.vue new file mode 100644 index 0000000..1d1e1c3 --- /dev/null +++ b/src/packages/my/pages/patient/patient.vue @@ -0,0 +1,99 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/random-clap/random-clap.vue b/src/packages/my/pages/random-clap/random-clap.vue new file mode 100644 index 0000000..26929b5 --- /dev/null +++ b/src/packages/my/pages/random-clap/random-clap.vue @@ -0,0 +1,146 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/role/role.vue b/src/packages/my/pages/role/role.vue new file mode 100644 index 0000000..b540966 --- /dev/null +++ b/src/packages/my/pages/role/role.vue @@ -0,0 +1,194 @@ + + + + \ No newline at end of file diff --git a/src/packages/my/pages/setup/setup.vue b/src/packages/my/pages/setup/setup.vue new file mode 100644 index 0000000..bfb490b --- /dev/null +++ b/src/packages/my/pages/setup/setup.vue @@ -0,0 +1,216 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/ai-im/ai-im.vue b/src/packages/people/pages/ai-im/ai-im.vue new file mode 100644 index 0000000..c6ec125 --- /dev/null +++ b/src/packages/people/pages/ai-im/ai-im.vue @@ -0,0 +1,41 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/apply-doctor/apply-doctor.vue b/src/packages/people/pages/apply-doctor/apply-doctor.vue new file mode 100644 index 0000000..d0233cc --- /dev/null +++ b/src/packages/people/pages/apply-doctor/apply-doctor.vue @@ -0,0 +1,527 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/area-detail/area-detail.vue b/src/packages/people/pages/area-detail/area-detail.vue new file mode 100644 index 0000000..cbb699c --- /dev/null +++ b/src/packages/people/pages/area-detail/area-detail.vue @@ -0,0 +1,153 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/area/area.vue b/src/packages/people/pages/area/area.vue new file mode 100644 index 0000000..92fad44 --- /dev/null +++ b/src/packages/people/pages/area/area.vue @@ -0,0 +1,518 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/assembly-detail/assembly-detail.vue b/src/packages/people/pages/assembly-detail/assembly-detail.vue new file mode 100644 index 0000000..084144e --- /dev/null +++ b/src/packages/people/pages/assembly-detail/assembly-detail.vue @@ -0,0 +1,388 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/assembly/assembly.vue b/src/packages/people/pages/assembly/assembly.vue new file mode 100644 index 0000000..48f1496 --- /dev/null +++ b/src/packages/people/pages/assembly/assembly.vue @@ -0,0 +1,466 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/doctor-archives/doctor-archives.vue b/src/packages/people/pages/doctor-archives/doctor-archives.vue new file mode 100644 index 0000000..28b3626 --- /dev/null +++ b/src/packages/people/pages/doctor-archives/doctor-archives.vue @@ -0,0 +1,138 @@ + + + + diff --git a/src/packages/people/pages/doctor-my/doctor-my.vue b/src/packages/people/pages/doctor-my/doctor-my.vue new file mode 100644 index 0000000..f2c44f6 --- /dev/null +++ b/src/packages/people/pages/doctor-my/doctor-my.vue @@ -0,0 +1,221 @@ + + + + diff --git a/src/packages/people/pages/doctor/doctor.vue b/src/packages/people/pages/doctor/doctor.vue new file mode 100644 index 0000000..3deea10 --- /dev/null +++ b/src/packages/people/pages/doctor/doctor.vue @@ -0,0 +1,297 @@ + + + + diff --git a/src/packages/people/pages/guide-detail/guide-detail.vue b/src/packages/people/pages/guide-detail/guide-detail.vue new file mode 100644 index 0000000..a5b45f8 --- /dev/null +++ b/src/packages/people/pages/guide-detail/guide-detail.vue @@ -0,0 +1,221 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/guide/guide.vue b/src/packages/people/pages/guide/guide.vue new file mode 100644 index 0000000..d900445 --- /dev/null +++ b/src/packages/people/pages/guide/guide.vue @@ -0,0 +1,385 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/inquiries-create/inquiries-create.vue b/src/packages/people/pages/inquiries-create/inquiries-create.vue new file mode 100644 index 0000000..db4a53a --- /dev/null +++ b/src/packages/people/pages/inquiries-create/inquiries-create.vue @@ -0,0 +1,281 @@ + + + + diff --git a/src/packages/people/pages/law-list/law-list.vue b/src/packages/people/pages/law-list/law-list.vue new file mode 100644 index 0000000..2265fc7 --- /dev/null +++ b/src/packages/people/pages/law-list/law-list.vue @@ -0,0 +1,133 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/masses-appraise/masses-appraise.vue b/src/packages/people/pages/masses-appraise/masses-appraise.vue new file mode 100644 index 0000000..cda94b2 --- /dev/null +++ b/src/packages/people/pages/masses-appraise/masses-appraise.vue @@ -0,0 +1,254 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/masses-create/masses-create.vue b/src/packages/people/pages/masses-create/masses-create.vue new file mode 100644 index 0000000..30eee33 --- /dev/null +++ b/src/packages/people/pages/masses-create/masses-create.vue @@ -0,0 +1,578 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/masses-detail/masses-detail.vue b/src/packages/people/pages/masses-detail/masses-detail.vue new file mode 100644 index 0000000..c9e0f43 --- /dev/null +++ b/src/packages/people/pages/masses-detail/masses-detail.vue @@ -0,0 +1,581 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/masses/masses.vue b/src/packages/people/pages/masses/masses.vue new file mode 100644 index 0000000..735ce1e --- /dev/null +++ b/src/packages/people/pages/masses/masses.vue @@ -0,0 +1,418 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/mediate-create/mediate-create.vue b/src/packages/people/pages/mediate-create/mediate-create.vue new file mode 100644 index 0000000..1b6e9b7 --- /dev/null +++ b/src/packages/people/pages/mediate-create/mediate-create.vue @@ -0,0 +1,541 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/mediate-detail/mediate-detail.vue b/src/packages/people/pages/mediate-detail/mediate-detail.vue new file mode 100644 index 0000000..5f55571 --- /dev/null +++ b/src/packages/people/pages/mediate-detail/mediate-detail.vue @@ -0,0 +1,345 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/mediate-my-details/mediate-my-details.vue b/src/packages/people/pages/mediate-my-details/mediate-my-details.vue new file mode 100644 index 0000000..a120ed8 --- /dev/null +++ b/src/packages/people/pages/mediate-my-details/mediate-my-details.vue @@ -0,0 +1,432 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/mediate-my-list/mediate-my-list.vue b/src/packages/people/pages/mediate-my-list/mediate-my-list.vue new file mode 100644 index 0000000..022adfc --- /dev/null +++ b/src/packages/people/pages/mediate-my-list/mediate-my-list.vue @@ -0,0 +1,326 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/mediate-select/mediate-select.vue b/src/packages/people/pages/mediate-select/mediate-select.vue new file mode 100644 index 0000000..b73813b --- /dev/null +++ b/src/packages/people/pages/mediate-select/mediate-select.vue @@ -0,0 +1,323 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/mediate/mediate.vue b/src/packages/people/pages/mediate/mediate.vue new file mode 100644 index 0000000..32ed624 --- /dev/null +++ b/src/packages/people/pages/mediate/mediate.vue @@ -0,0 +1,322 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/party-branch/party-branch.vue b/src/packages/people/pages/party-branch/party-branch.vue new file mode 100644 index 0000000..ea7acf0 --- /dev/null +++ b/src/packages/people/pages/party-branch/party-branch.vue @@ -0,0 +1,322 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/second/second-community.vue b/src/packages/people/pages/second/second-community.vue new file mode 100644 index 0000000..314d892 --- /dev/null +++ b/src/packages/people/pages/second/second-community.vue @@ -0,0 +1,240 @@ + + + + \ No newline at end of file diff --git a/src/packages/people/pages/second/second.vue b/src/packages/people/pages/second/second.vue new file mode 100644 index 0000000..847d70d --- /dev/null +++ b/src/packages/people/pages/second/second.vue @@ -0,0 +1,653 @@ + + + \ No newline at end of file diff --git a/src/packages/public/pages/chief-expert/chief-expert.vue b/src/packages/public/pages/chief-expert/chief-expert.vue new file mode 100644 index 0000000..7540b86 --- /dev/null +++ b/src/packages/public/pages/chief-expert/chief-expert.vue @@ -0,0 +1,99 @@ + + + + \ No newline at end of file diff --git a/src/packages/public/pages/details/details-no-ops.vue b/src/packages/public/pages/details/details-no-ops.vue new file mode 100644 index 0000000..c03d079 --- /dev/null +++ b/src/packages/public/pages/details/details-no-ops.vue @@ -0,0 +1,185 @@ + + + + \ No newline at end of file diff --git a/src/packages/public/pages/details/details.vue b/src/packages/public/pages/details/details.vue new file mode 100644 index 0000000..83f4d88 --- /dev/null +++ b/src/packages/public/pages/details/details.vue @@ -0,0 +1,679 @@ + + + + \ No newline at end of file diff --git a/src/packages/public/pages/inquiry/inquiry-detail.vue b/src/packages/public/pages/inquiry/inquiry-detail.vue new file mode 100644 index 0000000..d3e28bf --- /dev/null +++ b/src/packages/public/pages/inquiry/inquiry-detail.vue @@ -0,0 +1,542 @@ + + + + \ No newline at end of file diff --git a/src/packages/public/pages/inquiry/inquiry-list.vue b/src/packages/public/pages/inquiry/inquiry-list.vue new file mode 100644 index 0000000..a8091b2 --- /dev/null +++ b/src/packages/public/pages/inquiry/inquiry-list.vue @@ -0,0 +1,262 @@ + + + + \ No newline at end of file diff --git a/src/packages/public/pages/service-record/service-record-detail.vue b/src/packages/public/pages/service-record/service-record-detail.vue new file mode 100644 index 0000000..969f6bb --- /dev/null +++ b/src/packages/public/pages/service-record/service-record-detail.vue @@ -0,0 +1,282 @@ + + + + \ No newline at end of file diff --git a/src/packages/public/pages/service-record/service-record.vue b/src/packages/public/pages/service-record/service-record.vue new file mode 100644 index 0000000..4b9c16a --- /dev/null +++ b/src/packages/public/pages/service-record/service-record.vue @@ -0,0 +1,275 @@ + + + + \ No newline at end of file diff --git a/src/packages/public/pages/web-view/web-view.vue b/src/packages/public/pages/web-view/web-view.vue new file mode 100644 index 0000000..d1f191e --- /dev/null +++ b/src/packages/public/pages/web-view/web-view.vue @@ -0,0 +1,58 @@ + + + + \ No newline at end of file diff --git a/src/pages.json b/src/pages.json new file mode 100644 index 0000000..a76cdbf --- /dev/null +++ b/src/pages.json @@ -0,0 +1,451 @@ +{ + "pages": [{ + "path": "pages/guide/index", + "style": { + "navigationBarTitleText": "引导页", + "navigationStyle": "custom", + "disableScroll": true + } + }, { + "path": "pages/people/people", + "style": {} + }, + { + "path": "pages/life/life", + "style": {} + }, { + "path": "pages/enterprise/enterprise", + "style": {} + }, + { + "path": "pages/consult/consult", + "style": {} + }, + { + "path": "pages/my/my", + "style": {} + }, + { + "path": "pages/authorize/authorize", + "style": { + "navigationStyle": "custom" + } + }, + { + "path": "pages/phone/index", + "style": {} + }, + { + "path": "pages/agreement/user-agreement", + "style": {} + } + ], + "subPackages": [{ + "root": "packages/enterprise", + "pages": [{ + "path": "pages/my-appeal/my-appeal", + "name": "enterprise", + "style": {} + }, + { + "path": "pages/details/details", + "name": "enterprise", + "style": {} + }, + { + "path": "pages/issue-appeal/issue-appeal", + "name": "enterprise", + "style": {} + }, + { + "path": "pages/relation-enterprise/relation-enterprise", + "name": "enterprise", + "style": {} + }, + { + "path": "pages/create-enterprise/create-enterprise", + "name": "enterprise", + "style": {} + }, + { + "path": "pages/discount/discount", + "name": "enterprise", + "style": {} + }, + { + "path": "pages/discount/discount-details", + "name": "enterprise", + "style": {} + }, + { + "path": "pages/discount/discount-list", + "name": "enterprise", + "style": {} + } + ] + }, + { + "root": "packages/life", + "pages": [{ + "path": "pages/life-list/life-list", + "name": "life", + "style": {} + }, + { + "path": "pages/scenic-list/scenic-list", + "name": "life", + "style": {} + } + ] + }, + { + "root": "packages/people/", + "pages": [{ + "path": "pages/second/second", + "name": "people", + "style": {} + }, + { + "path": "pages/second/second-community", + "name": "people", + "style": {} + }, + { + "path": "pages/masses/masses", + "name": "people", + "style": {} + }, + { + "path": "pages/masses-create/masses-create", + "name": "people", + "style": {} + }, + { + "path": "pages/masses-detail/masses-detail", + "name": "people", + "style": {} + }, + { + "path": "pages/masses-appraise/masses-appraise", + "name": "people", + "style": {} + }, + { + "path": "pages/mediate/mediate", + "name": "people", + "style": {} + }, + { + "path": "pages/mediate-select/mediate-select", + "name": "people", + "style": {} + }, + { + "path": "pages/mediate-create/mediate-create", + "name": "people", + "style": {} + }, + { + "path": "pages/mediate-detail/mediate-detail", + "name": "people", + "style": {} + }, + { + "path": "pages/mediate-my-list/mediate-my-list", + "name": "people", + "style": {} + }, + { + "path": "pages/mediate-my-details/mediate-my-details", + "name": "people", + "style": {} + }, + { + "path": "pages/law-list/law-list", + "name": "people", + "style": {} + }, + { + "path": "pages/assembly/assembly", + "name": "people", + "style": {} + }, + { + "path": "pages/assembly-detail/assembly-detail", + "name": "people", + "style": {} + }, + { + "path": "pages/party-branch/party-branch", + "name": "people", + "style": {} + }, + { + "path": "pages/guide/guide", + "name": "people", + "style": {} + }, + { + "path": "pages/guide-detail/guide-detail", + "name": "people", + "style": {} + }, + { + "path": "pages/area/area", + "name": "people", + "style": {} + }, + { + "path": "pages/area-detail/area-detail", + "name": "people", + "style": {} + }, + { + "path": "pages/doctor/doctor", + "name": "people", + "style": {} + }, + { + "path": "pages/doctor-archives/doctor-archives", + "name": "people", + "style": {} + }, + { + "path": "pages/apply-doctor/apply-doctor", + "name": "people", + "style": {} + }, + { + "path": "pages/doctor-my/doctor-my", + "name": "people", + "style": {} + }, + { + "path": "pages/inquiries-create/inquiries-create", + "name": "people", + "style": {} + }, + { + "path": "pages/ai-im/ai-im", + "name": "people", + "style": {} + } + ] + }, + { + "root": "packages/public/", + "pages": [{ + "path": "pages/details/details", + "name": "public", + "style": {} + }, + { + "path": "pages/details/details-no-ops", + "name": "public", + "style": {} + }, + { + "path": "pages/service-record/service-record", + "name": "public", + "style": {} + }, + { + "path": "pages/service-record/service-record-detail", + "name": "public", + "style": {} + }, + { + "path": "pages/inquiry/inquiry-list", + "name": "public", + "style": {} + }, + { + "path": "pages/inquiry/inquiry-detail", + "name": "public", + "style": {} + }, + { + "path": "pages/web-view/web-view", + "name": "public", + "style": {} + }, + { + "path": "pages/chief-expert/chief-expert", + "name": "public", + "style": {} + } + ] + }, + { + "root": "packages/my/", + "pages": [{ + "path": "pages/message-center/message-center", + "name": "my", + "style": {} + }, + { + "path": "pages/integral/integral", + "name": "my", + "style": {} + }, + { + "path": "pages/appeal/appeal", + "name": "my", + "style": {} + }, + { + "path": "pages/random-clap/random-clap", + "name": "my", + "style": {} + }, + { + "path": "pages/collection/collection", + "name": "my", + "style": {} + }, + { + "path": "pages/mediate/mediate", + "name": "my", + "style": {} + }, + { + "path": "pages/account/account", + "name": "my", + "style": {} + }, + { + "path": "pages/role/role", + "name": "my", + "style": {} + }, + { + "path": "pages/certification/certification", + "name": "my", + "style": {} + }, + { + "path": "pages/setup/setup", + "name": "my", + "style": {} + }, + { + "path": "pages/party-member-auth/party-member-auth", + "name": "my", + "style": {} + }, + { + "path": "pages/my-masses/my-masses", + "name": "my", + "style": {} + }, + { + "path": "pages/my-masses/my-masses-details", + "name": "my", + "style": {} + }, + { + "path": "pages/patient/patient", + "name": "my", + "style": {} + }, + { + "path": "pages/my-patient/my-patient", + "name": "my", + "style": {} + }, + { + "path": "pages/my-patient-details/my-patient-details", + "name": "my", + "style": {} + }, + { + "path": "pages/create-server-record/create-server-record", + "name": "my", + "style": {} + }, + { + "path": "pages/my-masses/my-masses-appraise", + "name": "my", + "style": {} + }, + { + "path": "pages/my-masses/my-masses-reply", + "name": "my", + "style": {} + } + ] + } + ], + "tabBar": { + "custom": false, + "color": "#000000", + "selectedColor": "#FE3B53", + "backgroundColor": "#ffffff", + "position": "bottom", + "borderStyle": "black", + "list": [{ + "pagePath": "pages/people/people", + "text": "民生", + "iconPath": "static/images/tabbar/ic-people.png", + "selectedIconPath": "static/images/tabbar/ic-people.png" + }, + { + "pagePath": "pages/life/life", + "text": "生活", + "iconPath": "static/images/tabbar/ic-life.png", + "selectedIconPath": "static/images/tabbar/ic-life.png" + }, + { + "pagePath": "pages/enterprise/enterprise", + "text": "惠企", + "iconPath": "static/images/tabbar/ic-enterprise.png", + "selectedIconPath": "static/images/tabbar/ic-enterprise.png" + }, + { + "pagePath": "pages/consult/consult", + "text": "资讯", + "iconPath": "static/images/tabbar/ic-consult.png", + "selectedIconPath": "static/images/tabbar/ic-consult.png" + }, + { + "pagePath": "pages/my/my", + "text": "我的", + "iconPath": "static/images/tabbar/ic-my.png", + "selectedIconPath": "static/images/tabbar/ic-my.png" + } + ] + }, + "useExtendedLib": {}, + "permission": { + "scope.userLocation": { + "desc": "你的位置信息将用于小程序位置接口的效果展示" + } + }, + "requiredBackgroundModes": [ + "audio", + "location" + ], + "requiredPrivateInfos": [ + "getLocation" + ], + "plugins": { + "myPlugin": { + "version": "1.4.0", + "provider": "wx3572fa9e027e055a" + } + }, + "sitemapLocation": "sitemap.json", + "easycom": { + "autoscan": true, + "custom": { + "^custom-nav-bar$": "@/components/custom-nav-bar/custom-nav-bar" + } + }, + "globalStyle": { + "backgroundTextStyle": "dark", + "navigationBarBackgroundColor": "#fff", + "navigationBarTitleText": "", + "navigationBarTextStyle": "black", + "navigationStyle": "custom" + } +} \ No newline at end of file diff --git a/src/pages/agreement/user-agreement.vue b/src/pages/agreement/user-agreement.vue new file mode 100644 index 0000000..d18c1c3 --- /dev/null +++ b/src/pages/agreement/user-agreement.vue @@ -0,0 +1,85 @@ + + + + diff --git a/src/pages/authorize/authorize.vue b/src/pages/authorize/authorize.vue new file mode 100644 index 0000000..de01d43 --- /dev/null +++ b/src/pages/authorize/authorize.vue @@ -0,0 +1,283 @@ + + + + \ No newline at end of file diff --git a/src/pages/consult/consult.vue b/src/pages/consult/consult.vue new file mode 100644 index 0000000..d3fbb41 --- /dev/null +++ b/src/pages/consult/consult.vue @@ -0,0 +1,242 @@ + + + \ No newline at end of file diff --git a/src/pages/enterprise/enterprise.vue b/src/pages/enterprise/enterprise.vue new file mode 100644 index 0000000..f192348 --- /dev/null +++ b/src/pages/enterprise/enterprise.vue @@ -0,0 +1,554 @@ + + + \ No newline at end of file diff --git a/src/pages/guide/index.vue b/src/pages/guide/index.vue new file mode 100644 index 0000000..e37b49d --- /dev/null +++ b/src/pages/guide/index.vue @@ -0,0 +1,42 @@ + + + + \ No newline at end of file diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue new file mode 100644 index 0000000..ecac4f5 --- /dev/null +++ b/src/pages/index/index.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/src/pages/life/life.vue b/src/pages/life/life.vue new file mode 100644 index 0000000..82cf78c --- /dev/null +++ b/src/pages/life/life.vue @@ -0,0 +1,523 @@ + + + \ No newline at end of file diff --git a/src/pages/my/my.vue b/src/pages/my/my.vue new file mode 100644 index 0000000..0d06cc4 --- /dev/null +++ b/src/pages/my/my.vue @@ -0,0 +1,593 @@ + + + \ No newline at end of file diff --git a/src/pages/people/people.vue b/src/pages/people/people.vue new file mode 100644 index 0000000..2cf559b --- /dev/null +++ b/src/pages/people/people.vue @@ -0,0 +1,380 @@ + + + \ No newline at end of file diff --git a/src/pages/phone/index.vue b/src/pages/phone/index.vue new file mode 100644 index 0000000..755b0e6 --- /dev/null +++ b/src/pages/phone/index.vue @@ -0,0 +1,311 @@ + + + + \ No newline at end of file diff --git a/src/shime-uni.d.ts b/src/shime-uni.d.ts new file mode 100644 index 0000000..5ecbb26 --- /dev/null +++ b/src/shime-uni.d.ts @@ -0,0 +1,6 @@ +export {} + +declare module "vue" { + type Hooks = App.AppInstance & Page.PageInstance; + interface ComponentCustomOptions extends Hooks {} +} \ No newline at end of file diff --git a/src/static/images/default-avatar.png b/src/static/images/default-avatar.png new file mode 100644 index 0000000..201174c Binary files /dev/null and b/src/static/images/default-avatar.png differ diff --git a/src/static/images/enterprise/icon-1.png b/src/static/images/enterprise/icon-1.png new file mode 100644 index 0000000..2f0d307 Binary files /dev/null and b/src/static/images/enterprise/icon-1.png differ diff --git a/src/static/images/enterprise/icon.png b/src/static/images/enterprise/icon.png new file mode 100644 index 0000000..2f6b6da Binary files /dev/null and b/src/static/images/enterprise/icon.png differ diff --git a/src/static/images/ic-arrow-black.png b/src/static/images/ic-arrow-black.png new file mode 100644 index 0000000..e96c93a Binary files /dev/null and b/src/static/images/ic-arrow-black.png differ diff --git a/src/static/images/ic-arrow-white.png b/src/static/images/ic-arrow-white.png new file mode 100644 index 0000000..9bcd3f4 Binary files /dev/null and b/src/static/images/ic-arrow-white.png differ diff --git a/src/static/images/ic-collection.png b/src/static/images/ic-collection.png new file mode 100644 index 0000000..4568d3d Binary files /dev/null and b/src/static/images/ic-collection.png differ diff --git a/src/static/images/ic-collection1.png b/src/static/images/ic-collection1.png new file mode 100644 index 0000000..b7a8f71 Binary files /dev/null and b/src/static/images/ic-collection1.png differ diff --git a/src/static/images/ic-give.png b/src/static/images/ic-give.png new file mode 100644 index 0000000..6ff93f9 Binary files /dev/null and b/src/static/images/ic-give.png differ diff --git a/src/static/images/ic-give1.png b/src/static/images/ic-give1.png new file mode 100644 index 0000000..e30e9c4 Binary files /dev/null and b/src/static/images/ic-give1.png differ diff --git a/src/static/images/ic-give2.png b/src/static/images/ic-give2.png new file mode 100644 index 0000000..174c0f0 Binary files /dev/null and b/src/static/images/ic-give2.png differ diff --git a/src/static/images/ic-radio.png b/src/static/images/ic-radio.png new file mode 100644 index 0000000..17eeffa Binary files /dev/null and b/src/static/images/ic-radio.png differ diff --git a/src/static/images/ic-radio1.png b/src/static/images/ic-radio1.png new file mode 100644 index 0000000..3c9b61d Binary files /dev/null and b/src/static/images/ic-radio1.png differ diff --git a/src/static/images/ic-share.png b/src/static/images/ic-share.png new file mode 100644 index 0000000..e394fd0 Binary files /dev/null and b/src/static/images/ic-share.png differ diff --git a/src/static/images/ic-success.png b/src/static/images/ic-success.png new file mode 100644 index 0000000..48b36f4 Binary files /dev/null and b/src/static/images/ic-success.png differ diff --git a/src/static/images/ic-you.png b/src/static/images/ic-you.png new file mode 100644 index 0000000..7fb72a4 Binary files /dev/null and b/src/static/images/ic-you.png differ diff --git a/src/static/images/icon-people.png b/src/static/images/icon-people.png new file mode 100644 index 0000000..3e5fcf3 Binary files /dev/null and b/src/static/images/icon-people.png differ diff --git a/src/static/images/icon1.png b/src/static/images/icon1.png new file mode 100644 index 0000000..0a6fe4c Binary files /dev/null and b/src/static/images/icon1.png differ diff --git a/src/static/images/icon2.png b/src/static/images/icon2.png new file mode 100644 index 0000000..d7c3246 Binary files /dev/null and b/src/static/images/icon2.png differ diff --git a/src/static/images/icon3.png b/src/static/images/icon3.png new file mode 100644 index 0000000..7bb450b Binary files /dev/null and b/src/static/images/icon3.png differ diff --git a/src/static/images/icon4.png b/src/static/images/icon4.png new file mode 100644 index 0000000..6783b0a Binary files /dev/null and b/src/static/images/icon4.png differ diff --git a/src/static/images/icon5.png b/src/static/images/icon5.png new file mode 100644 index 0000000..10f0922 Binary files /dev/null and b/src/static/images/icon5.png differ diff --git a/src/static/images/icon9.png b/src/static/images/icon9.png new file mode 100644 index 0000000..7bd1e17 Binary files /dev/null and b/src/static/images/icon9.png differ diff --git a/src/static/images/rate-icon.png b/src/static/images/rate-icon.png new file mode 100644 index 0000000..da2ba8c Binary files /dev/null and b/src/static/images/rate-icon.png differ diff --git a/src/static/images/search.png b/src/static/images/search.png new file mode 100644 index 0000000..5060ced Binary files /dev/null and b/src/static/images/search.png differ diff --git a/src/static/images/share-icon.png b/src/static/images/share-icon.png new file mode 100644 index 0000000..4596df0 Binary files /dev/null and b/src/static/images/share-icon.png differ diff --git a/src/static/images/tabbar/ic-consult.png b/src/static/images/tabbar/ic-consult.png new file mode 100644 index 0000000..269b20f Binary files /dev/null and b/src/static/images/tabbar/ic-consult.png differ diff --git a/src/static/images/tabbar/ic-enterprise.png b/src/static/images/tabbar/ic-enterprise.png new file mode 100644 index 0000000..eda2d72 Binary files /dev/null and b/src/static/images/tabbar/ic-enterprise.png differ diff --git a/src/static/images/tabbar/ic-life.png b/src/static/images/tabbar/ic-life.png new file mode 100644 index 0000000..0e1a1c0 Binary files /dev/null and b/src/static/images/tabbar/ic-life.png differ diff --git a/src/static/images/tabbar/ic-my.png b/src/static/images/tabbar/ic-my.png new file mode 100644 index 0000000..620f218 Binary files /dev/null and b/src/static/images/tabbar/ic-my.png differ diff --git a/src/static/images/tabbar/ic-people.png b/src/static/images/tabbar/ic-people.png new file mode 100644 index 0000000..00bc221 Binary files /dev/null and b/src/static/images/tabbar/ic-people.png differ diff --git a/src/static/images/void-icon2.png b/src/static/images/void-icon2.png new file mode 100644 index 0000000..fe41069 Binary files /dev/null and b/src/static/images/void-icon2.png differ diff --git a/src/static/logo.png b/src/static/logo.png new file mode 100644 index 0000000..b5771e2 Binary files /dev/null and b/src/static/logo.png differ diff --git a/src/static/packages/enterprise/image/camera.png b/src/static/packages/enterprise/image/camera.png new file mode 100644 index 0000000..21c398c Binary files /dev/null and b/src/static/packages/enterprise/image/camera.png differ diff --git a/src/static/packages/enterprise/image/card-icon.png b/src/static/packages/enterprise/image/card-icon.png new file mode 100644 index 0000000..9f35998 Binary files /dev/null and b/src/static/packages/enterprise/image/card-icon.png differ diff --git a/src/static/packages/enterprise/image/card.png b/src/static/packages/enterprise/image/card.png new file mode 100644 index 0000000..b701de0 Binary files /dev/null and b/src/static/packages/enterprise/image/card.png differ diff --git a/src/static/packages/enterprise/image/enterprise-none.png b/src/static/packages/enterprise/image/enterprise-none.png new file mode 100644 index 0000000..a7224c9 Binary files /dev/null and b/src/static/packages/enterprise/image/enterprise-none.png differ diff --git a/src/static/packages/enterprise/image/ic-check-select.png b/src/static/packages/enterprise/image/ic-check-select.png new file mode 100644 index 0000000..17eeffa Binary files /dev/null and b/src/static/packages/enterprise/image/ic-check-select.png differ diff --git a/src/static/packages/enterprise/image/ic-check.png b/src/static/packages/enterprise/image/ic-check.png new file mode 100644 index 0000000..3c9b61d Binary files /dev/null and b/src/static/packages/enterprise/image/ic-check.png differ diff --git a/src/static/packages/enterprise/image/my-appeal.png b/src/static/packages/enterprise/image/my-appeal.png new file mode 100644 index 0000000..0e32256 Binary files /dev/null and b/src/static/packages/enterprise/image/my-appeal.png differ diff --git a/src/static/packages/my/image/accomplish.png b/src/static/packages/my/image/accomplish.png new file mode 100644 index 0000000..3a78989 Binary files /dev/null and b/src/static/packages/my/image/accomplish.png differ diff --git a/src/static/packages/my/image/integral.png b/src/static/packages/my/image/integral.png new file mode 100644 index 0000000..0c45638 Binary files /dev/null and b/src/static/packages/my/image/integral.png differ diff --git a/src/static/packages/my/image/login_bg.png b/src/static/packages/my/image/login_bg.png new file mode 100644 index 0000000..3f2b690 Binary files /dev/null and b/src/static/packages/my/image/login_bg.png differ diff --git a/src/static/packages/my/image/logo_bg.png b/src/static/packages/my/image/logo_bg.png new file mode 100644 index 0000000..58aea6d Binary files /dev/null and b/src/static/packages/my/image/logo_bg.png differ diff --git a/src/static/packages/my/image/masses.png b/src/static/packages/my/image/masses.png new file mode 100644 index 0000000..79dc3f1 Binary files /dev/null and b/src/static/packages/my/image/masses.png differ diff --git a/src/static/packages/my/image/order.png b/src/static/packages/my/image/order.png new file mode 100644 index 0000000..1e71d94 Binary files /dev/null and b/src/static/packages/my/image/order.png differ diff --git a/src/static/packages/my/image/person.png b/src/static/packages/my/image/person.png new file mode 100644 index 0000000..32bfc1c Binary files /dev/null and b/src/static/packages/my/image/person.png differ diff --git a/src/static/packages/my/image/reply.png b/src/static/packages/my/image/reply.png new file mode 100644 index 0000000..60ec35b Binary files /dev/null and b/src/static/packages/my/image/reply.png differ diff --git a/src/static/packages/my/image/search.png b/src/static/packages/my/image/search.png new file mode 100644 index 0000000..5060ced Binary files /dev/null and b/src/static/packages/my/image/search.png differ diff --git a/src/static/packages/my/image/worker.png b/src/static/packages/my/image/worker.png new file mode 100644 index 0000000..db03ea0 Binary files /dev/null and b/src/static/packages/my/image/worker.png differ diff --git a/src/static/packages/people/images/ic-Inquiries.png b/src/static/packages/people/images/ic-Inquiries.png new file mode 100644 index 0000000..080e623 Binary files /dev/null and b/src/static/packages/people/images/ic-Inquiries.png differ diff --git a/src/static/packages/people/images/ic-xia.png b/src/static/packages/people/images/ic-xia.png new file mode 100644 index 0000000..306df0f Binary files /dev/null and b/src/static/packages/people/images/ic-xia.png differ diff --git a/src/static/packages/people/images/icon10.png b/src/static/packages/people/images/icon10.png new file mode 100644 index 0000000..fc94ffc Binary files /dev/null and b/src/static/packages/people/images/icon10.png differ diff --git a/src/static/packages/people/images/icon2.png b/src/static/packages/people/images/icon2.png new file mode 100644 index 0000000..f948c13 Binary files /dev/null and b/src/static/packages/people/images/icon2.png differ diff --git a/src/static/packages/people/images/icon3.png b/src/static/packages/people/images/icon3.png new file mode 100644 index 0000000..3e5eb54 Binary files /dev/null and b/src/static/packages/people/images/icon3.png differ diff --git a/src/static/packages/people/images/icon7.png b/src/static/packages/people/images/icon7.png new file mode 100644 index 0000000..eaa2312 Binary files /dev/null and b/src/static/packages/people/images/icon7.png differ diff --git a/src/static/packages/people/images/icon9.png b/src/static/packages/people/images/icon9.png new file mode 100644 index 0000000..7bd1e17 Binary files /dev/null and b/src/static/packages/people/images/icon9.png differ diff --git a/src/static/packages/public/images/Chief_physician.png b/src/static/packages/public/images/Chief_physician.png new file mode 100644 index 0000000..7a2d62f Binary files /dev/null and b/src/static/packages/public/images/Chief_physician.png differ diff --git a/src/static/packages/public/pages/web-view/img.jpg b/src/static/packages/public/pages/web-view/img.jpg new file mode 100644 index 0000000..ba83f73 Binary files /dev/null and b/src/static/packages/public/pages/web-view/img.jpg differ diff --git a/src/style/normalize.less b/src/style/normalize.less new file mode 100644 index 0000000..2006c89 --- /dev/null +++ b/src/style/normalize.less @@ -0,0 +1,62 @@ +page { + height: 100%; + font-family: 'Microsoft YaHei', '微软雅黑', 'MicrosoftJhengHei', '华文细黑', Helvetica, Arial, 'sans-serif'; + font-size: 26rpx; + background-color: #ffffff; + font-weight: 400; +} + +view, +image, +icon, +scroll-view, +text, +button, +checkbox, +form, +input, +label, +navigator, +audio, +video, +canvas { + box-sizing: border-box; + margin: 0; + padding: 0; + border: 0; + outline: 0; +} + +scroll-view { + height: 100%; +} + +form, +image { + display: block; +} + +button { + padding: 0; + margin: 0; + border-radius: 0; + height: 100%; + display: block; + line-height: inherit; + font-size: inherit; + color: inherit; + background: none; + -webkit-appearance: none; + border: none; +} + +button::after { + content: none; +} + +input, +textarea { + font-family: 'Microsoft YaHei', '微软雅黑', 'MicrosoftJhengHei', '华文细黑', Helvetica, Arial, 'sans-serif'; + font-size: 26rpx; + z-index: 0; +} diff --git a/src/style/public.less b/src/style/public.less new file mode 100644 index 0000000..232117f --- /dev/null +++ b/src/style/public.less @@ -0,0 +1,138 @@ +/* 单行超出显示点点点 */ +.uniline { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +/* 多行超出显示点点点 */ +.multi-line { + overflow: hidden; + display: -webkit-box; + text-overflow: ellipsis; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; +} + +/* 多行超出显示点点点 */ +.multi-line-3 { + overflow: hidden; + display: -webkit-box; + text-overflow: ellipsis; + -webkit-box-orient: vertical; + -webkit-line-clamp: 3; +} + +.red { + color: red; + font-size: 28rpx; + font-weight: 400; +} + +.flex { + display: flex; + display: -webkit-flex; +} + +.flex-v-center { + align-items: center; + -webkit-align-items: center; +} + +.flex-center { + justify-content: center; + -webkit-justify-content: center; + align-items: center; + -webkit-align-items: center; +} + +.flex-between { + justify-content: space-between; + -webkit-justify-content: space-between; +} + +.flex-around { + justify-content: space-around; + -webkit-justify-content: space-around; +} + +.flex-evenly { + justify-content: space-evenly; + -webkit-justify-content: space-evenly; +} + +.flex-v-between { + align-content: space-between; + -webkit-align-content: space-between; +} + +.flex-v-end { + align-content: flex-end; + -webkit-align-content: flex-end; +} + +.flex-v-start { + align-content: flex-start; + -webkit-align-content: flex-start; +} + +.flex-end { + justify-content: flex-end; + -webkit-justify-content: flex-end; +} + +.flex-col { + flex-direction: column; + -webkit-flex-direction: column; +} + +.flex1 { + flex: 1; + -webkit-flex: 1; +} + +.flex0 { + flex: none; + -webkit-flex: none; +} + +.flex-start { + justify-content: flex-start; + -webkit-justify-content: flex-start; +} + +.text-line-1 { + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 1; + -webkit-box-orient: vertical; + word-break: break-all; +} + +.text-line-2 { + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + word-break: break-all; +} + +.text-line-3 { + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + word-break: break-all; +} + +.text-line-4 { + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + word-break: break-all; +} diff --git a/src/style/theme.less b/src/style/theme.less new file mode 100644 index 0000000..00faa65 --- /dev/null +++ b/src/style/theme.less @@ -0,0 +1,15 @@ +/* 颜色主题 */ +page { + --title-guides-color: #ffced6; // 标题辅助线 + --nav-bar-background-color: #ffffff; + --nav-bar-icon-color: #999999; // 导航栏返回按钮样式 + --nav-bar-text-color: #333333; // 导航栏左侧文案样式 + --item-dominant-color: #fe3b53; // 项目主色 + --tab-active-text-color: #fe3b53; // 所有tabs选中颜色 + --tabs-bottom-bar-color: #fe3b53; // // 所有tabs选中下划线颜色 +} + +// margin +.m-b-28 { + margin-bottom: 28rpx; +} diff --git a/src/uni.scss b/src/uni.scss new file mode 100644 index 0000000..288300d --- /dev/null +++ b/src/uni.scss @@ -0,0 +1,76 @@ +/** + * 这里是uni-app内置的常用样式变量 + * + * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量 + * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App + * + */ + +/** + * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能 + * + * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 + */ + +/* 颜色变量 */ + +/* 行为相关颜色 */ +$uni-color-primary: #007aff; +$uni-color-success: #4cd964; +$uni-color-warning: #f0ad4e; +$uni-color-error: #dd524d; + +/* 文字基本颜色 */ +$uni-text-color: #333; // 基本色 +$uni-text-color-inverse: #fff; // 反色 +$uni-text-color-grey: #999; // 辅助灰色,如加载更多的提示信息 +$uni-text-color-placeholder: #808080; +$uni-text-color-disable: #c0c0c0; + +/* 背景颜色 */ +$uni-bg-color: #fff; +$uni-bg-color-grey: #f8f8f8; +$uni-bg-color-hover: #f1f1f1; // 点击状态颜色 +$uni-bg-color-mask: rgba(0, 0, 0, 0.4); // 遮罩颜色 + +/* 边框颜色 */ +$uni-border-color: #c8c7cc; + +/* 尺寸变量 */ + +/* 文字尺寸 */ +$uni-font-size-sm: 12px; +$uni-font-size-base: 14px; +$uni-font-size-lg: 16; + +/* 图片尺寸 */ +$uni-img-size-sm: 20px; +$uni-img-size-base: 26px; +$uni-img-size-lg: 40px; + +/* Border Radius */ +$uni-border-radius-sm: 2px; +$uni-border-radius-base: 3px; +$uni-border-radius-lg: 6px; +$uni-border-radius-circle: 50%; + +/* 水平间距 */ +$uni-spacing-row-sm: 5px; +$uni-spacing-row-base: 10px; +$uni-spacing-row-lg: 15px; + +/* 垂直间距 */ +$uni-spacing-col-sm: 4px; +$uni-spacing-col-base: 8px; +$uni-spacing-col-lg: 12px; + +/* 透明度 */ +$uni-opacity-disabled: 0.3; // 组件禁用态的透明度 + +/* 文章场景相关 */ +$uni-color-title: #2c405a; // 文章标题颜色 +$uni-font-size-title: 20px; +$uni-color-subtitle: #555; // 二级标题颜色 +$uni-font-size-subtitle: 18px; +$uni-color-paragraph: #3f536e; // 文章段落颜色 +$uni-font-size-paragraph: 15px; \ No newline at end of file diff --git a/src/uni_modules/mp-html/README.md b/src/uni_modules/mp-html/README.md new file mode 100644 index 0000000..dcfcc2c --- /dev/null +++ b/src/uni_modules/mp-html/README.md @@ -0,0 +1,193 @@ +## 为减小组件包的大小,默认组件包中不包含编辑、latex 公式等扩展功能,需要使用扩展功能的请参考下方的 插件扩展 栏的说明 + +## 功能介绍 +- 全端支持(含 `v3、NVUE`) +- 支持丰富的标签(包括 `table`、`video`、`svg` 等) +- 支持丰富的事件效果(自动预览图片、链接处理等) +- 支持设置占位图(加载中、出错时、预览时) +- 支持锚点跳转、长按复制等丰富功能 +- 支持大部分 *html* 实体 +- 丰富的插件(关键词搜索、内容编辑、`latex` 公式等) +- 效率高、容错性强且轻量化 + +查看 [功能介绍](https://jin-yufeng.gitee.io/mp-html/#/overview/feature) 了解更多 + +## 使用方法 +- `uni_modules` 方式 + 1. 点击右上角的 `使用 HBuilder X 导入插件` 按钮直接导入项目或点击 `下载插件 ZIP` 按钮下载插件包并解压到项目的 `uni_modules/mp-html` 目录下 + 2. 在需要使用页面的 `(n)vue` 文件中添加 + ```html + + + ``` + ```javascript + export default { + data() { + return { + html: '
Hello World!
' + } + } + } + ``` + 3. 需要更新版本时在 `HBuilder X` 中右键 `uni_modules/mp-html` 目录选择 `从插件市场更新` 即可 + +- 源码方式 + 1. 从 [github](https://github.com/jin-yufeng/mp-html/tree/master/dist/uni-app) 或 [gitee](https://gitee.com/jin-yufeng/mp-html/tree/master/dist/uni-app) 下载源码 + 插件市场的 **非 uni_modules 版本** 无法更新,不建议从插件市场获取 + 2. 在需要使用页面的 `(n)vue` 文件中添加 + ```html + + ``` + ```javascript + import mpHtml from '@/components/mp-html/mp-html' + export default { + // HBuilderX 2.5.5+ 可以通过 easycom 自动引入 + components: { + mpHtml + }, + data() { + return { + html: '
Hello World!
' + } + } + } + ``` + +- npm 方式 + 1. 在项目根目录下执行 + ```bash + npm install mp-html + ``` + 2. 在需要使用页面的 `(n)vue` 文件中添加 + ```html + + ``` + ```javascript + import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html' + export default { + // 不可省略 + components: { + mpHtml + }, + data() { + return { + html: '
Hello World!
' + } + } + } + ``` + 3. 需要更新版本时执行以下命令即可 + ```bash + npm update mp-html + ``` + + 使用 *cli* 方式运行的项目,通过 *npm* 方式引入时,需要在 *vue.config.js* 中配置 *transpileDependencies*,详情可见 [#330](https://github.com/jin-yufeng/mp-html/issues/330#issuecomment-913617687) + 如果在 **nvue** 中使用还要将 `dist/uni-app/static` 目录下的内容拷贝到项目的 `static` 目录下,否则无法运行 + +查看 [快速开始](https://jin-yufeng.gitee.io/mp-html/#/overview/quickstart) 了解更多 + +## 组件属性 + +| 属性 | 类型 | 默认值 | 说明 | +|:---:|:---:|:---:|---| +| container-style | String | | 容器的样式([2.1.0+](https://jin-yufeng.gitee.io/mp-html/#/changelog/changelog#v210)) | +| content | String | | 用于渲染的 html 字符串 | +| copy-link | Boolean | true | 是否允许外部链接被点击时自动复制 | +| domain | String | | 主域名(用于链接拼接) | +| error-img | String | | 图片出错时的占位图链接 | +| lazy-load | Boolean | false | 是否开启图片懒加载 | +| loading-img | String | | 图片加载过程中的占位图链接 | +| pause-video | Boolean | true | 是否在播放一个视频时自动暂停其他视频 | +| preview-img | Boolean | true | 是否允许图片被点击时自动预览 | +| scroll-table | Boolean | false | 是否给每个表格添加一个滚动层使其能单独横向滚动 | +| selectable | Boolean | false | 是否开启文本长按复制 | +| set-title | Boolean | true | 是否将 title 标签的内容设置到页面标题 | +| show-img-menu | Boolean | true | 是否允许图片被长按时显示菜单 | +| tag-style | Object | | 设置标签的默认样式 | +| use-anchor | Boolean | false | 是否使用锚点链接 | + +查看 [属性](https://jin-yufeng.gitee.io/mp-html/#/basic/prop) 了解更多 + +## 组件事件 + +| 名称 | 触发时机 | +|:---:|---| +| load | dom 树加载完毕时 | +| ready | 图片加载完毕时 | +| error | 发生渲染错误时 | +| imgtap | 图片被点击时 | +| linktap | 链接被点击时 | +| play | 音视频播放时 | + +查看 [事件](https://jin-yufeng.gitee.io/mp-html/#/basic/event) 了解更多 + +## api +组件实例上提供了一些 `api` 方法可供调用 + +| 名称 | 作用 | +|:---:|---| +| in | 将锚点跳转的范围限定在一个 scroll-view 内 | +| navigateTo | 锚点跳转 | +| getText | 获取文本内容 | +| getRect | 获取富文本内容的位置和大小 | +| setContent | 设置富文本内容 | +| imgList | 获取所有图片的数组 | +| pauseMedia | 暂停播放音视频([2.2.2+](https://jin-yufeng.gitee.io/mp-html/#/changelog/changelog#v222)) | +| setPlaybackRate | 设置音视频播放速率([2.4.0+](https://jin-yufeng.gitee.io/mp-html/#/changelog/changelog#v240)) | + +查看 [api](https://jin-yufeng.gitee.io/mp-html/#/advanced/api) 了解更多 + +## 插件扩展 +除基本功能外,本组件还提供了丰富的扩展,可按照需要选用 + +| 名称 | 作用 | +|:---:|---| +| audio | 音乐播放器 | +| editable | 富文本 **编辑**([示例项目](https://mp-html.oss-cn-hangzhou.aliyuncs.com/editable.zip)) | +| emoji | 解析 emoji | +| highlight | 代码块高亮显示 | +| markdown | 渲染 markdown | +| search | 关键词搜索 | +| style | 匹配 style 标签中的样式 | +| txv-video | 使用腾讯视频 | +| img-cache | 图片缓存 by [@PentaTea](https://github.com/PentaTea) | +| latex | 渲染 latex 公式 by [@Zeng-J](https://github.com/Zeng-J) | + +从插件市场导入的包中 **不含有** 扩展插件,使用插件需通过微信小程序 `富文本插件` 获取或参考以下方法进行打包: +1. 获取完整组件包 + ```bash + npm install mp-html + ``` +2. 编辑 `tools/config.js` 中的 `plugins` 项,选择需要的插件 +3. 生成新的组件包 + 在 `node_modules/mp-html` 目录下执行 + ```bash + npm install + npm run build:uni-app + ``` +4. 拷贝 `dist/uni-app` 中的内容到项目根目录 + +查看 [插件](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin) 了解更多 + +## 关于 nvue +`nvue` 使用原生渲染,不支持部分 `css` 样式,为实现和 `html` 相同的效果,组件内部通过 `web-view` 进行渲染,性能上差于原生,根据 `weex` 官方建议,`web` 标签仅应用在非常规的降级场景。因此,如果通过原生的方式(如 `richtext`)能够满足需要,则不建议使用本组件,如果有较多的富文本内容,则可以直接使用 `vue` 页面 +由于渲染方式与其他端不同,有以下限制: +1. 不支持 `lazy-load` 属性 +2. 视频不支持全屏播放 +3. 如果在 `flex-direction: row` 的容器中使用,需要给组件设置宽度或设置 `flex: 1` 占满剩余宽度 + +纯 `nvue` 模式下,[此问题](https://ask.dcloud.net.cn/question/119678) 修复前,不支持通过 `uni_modules` 引入,需要本地引入(将 [dist/uni-app](https://github.com/jin-yufeng/mp-html/tree/master/dist/uni-app) 中的内容拷贝到项目根目录下) + +## 立即体验 +![富文本插件](https://mp-html.oss-cn-hangzhou.aliyuncs.com/qrcode.jpg) + +## 问题反馈 +遇到问题时,请先查阅 [常见问题](https://jin-yufeng.gitee.io/mp-html/#/question/faq) 和 [issue](https://github.com/jin-yufeng/mp-html/issues) 中是否已有相同的问题 +可通过 [issue](https://github.com/jin-yufeng/mp-html/issues/new/choose) 、插件问答或发送邮件到 [mp_html@126.com](mailto:mp_html@126.com) 提问,不建议在评论区提问(不方便回复) +提问请严格按照 [issue 模板](https://github.com/jin-yufeng/mp-html/issues/new/choose) ,描述清楚使用环境、`html` 内容或可复现的 `demo` 项目以及复现方式,对于 **描述不清**、**无法复现** 或重复的问题将不予回复 + +欢迎加入 `QQ` 交流群: +群1(已满):`699734691` +群2:`778239129` + +查看 [问题反馈](https://jin-yufeng.gitee.io/mp-html/#/question/feedback) 了解更多 diff --git a/src/uni_modules/mp-html/changelog.md b/src/uni_modules/mp-html/changelog.md new file mode 100644 index 0000000..e313d38 --- /dev/null +++ b/src/uni_modules/mp-html/changelog.md @@ -0,0 +1,129 @@ +## v2.4.2(2023-05-14) +1. `A` `editable` 插件支持修改文字颜色 [详细](https://github.com/jin-yufeng/mp-html/issues/254) +2. `F` 修复了 `svg` 中有 `style` 不生效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/505) +3. `F` 修复了使用旧版编译器可能报错 `Bad attr nodes` 的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/472) +4. `F` 修复了 `app` 端可能出现无法读取 `lazyLoad` 的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/513) +5. `F` 修复了 `editable` 插件在点击换图时未拼接 `domain` 的问题 [详细](https://github.com/jin-yufeng/mp-html/pull/497) by [@TwoKe945](https://github.com/TwoKe945) +6. `F` 修复了 `latex` 插件部分情况下不显示的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/515) +7. `F` 修复了 `editable` 插件点击音视频时其他标签框不消失的问题 +## v2.4.1(2022-12-25) +1. `F` 修复了没有图片时 `ready` 事件可能不触发的问题 +2. `F` 修复了加载过程中可能出现 `Root label not found` 错误的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/470) +3. `F` 修复了 `audio` 插件退出页面可能会报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/457) +4. `F` 修复了 `vue3` 运行到 `app` 在 `HBuilder X 3.6.10` 以上报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/480) +5. `F` 修复了 `nvue` 端链接中包含 `%22` 时可能无法显示的问题 +6. `F` 修复了 `vue3` 使用 `highlight` 插件可能报错的问题 +## v2.4.0(2022-08-27) +1. `A` 增加了 [setPlaybackRate](https://jin-yufeng.gitee.io/mp-html/#/advanced/api#setPlaybackRate) 的 `api`,可以设置音视频的播放速率 [详细](https://github.com/jin-yufeng/mp-html/issues/452) +2. `A` 示例小程序代码开源 [详细](https://github.com/jin-yufeng/mp-html-demo) +3. `U` 优化 `ready` 事件触发时机,未设置懒加载的情况下基本可以准确触发 [详细](https://github.com/jin-yufeng/mp-html/issues/195) +4. `U` `highlight` 插件在编辑状态下不进行高亮处理,便于编辑 +5. `F` 修复了 `flex` 布局下图片大小可能不正确的问题 +6. `F` 修复了 `selectable` 属性没有设置 `force` 也可能出现渲染异常的问题 +7. `F` 修复了表格中的图片大小可能不正确的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/448) +8. `F` 修复了含有合并单元格的表格可能无法设置竖直对齐的问题 +9. `F` 修复了 `editable` 插件在 `scroll-view` 中使用时工具条位置可能不正确的问题 +10. `F` 修复了 `vue3` 使用 [search](advanced/plugin#search) 插件可能导致错误换行的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/449) +## v2.3.2(2022-08-13) +1. `A` 增加 [latex](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#latex) 插件,可以渲染数学公式 [详细](https://github.com/jin-yufeng/mp-html/pull/447) by [@Zeng-J](https://github.com/Zeng-J) +2. `U` 优化根节点下有很多标签的长内容渲染速度 +3. `U` `highlight` 插件适配 `lang-xxx` 格式 +4. `F` 修复了 `table` 标签设置 `border` 属性后可能无法修改边框样式的问题 [详细](https://github.com/jin-yufeng/mp-html/pull/439) by [@zouxingjie](https://github.com/zouxingjie) +5. `F` 修复了 `editable` 插件输入连续空格无效的问题 +6. `F` 修复了 `vue3` 图片设置 `inline` 会报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/438) +7. `F` 修复了 `vue3` 使用 `table` 可能报错的问题 +## v2.3.1(2022-05-20) +1. `U` `app` 端支持使用本地图片 +2. `U` 优化了微信小程序 `selectable` 属性在 `ios` 端的处理 [详细](https://jin-yufeng.gitee.io/mp-html/#/basic/prop#selectable) +3. `F` 修复了 `editable` 插件不在顶部时 `tooltip` 位置可能错误的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/430) +4. `F` 修复了 `vue3` 运行到微信小程序可能报错丢失内容的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/414) +5. `F` 修复了 `vue3` 部分标签可能被错误换行的问题 +6. `F` 修复了 `editable` 插件 `app` 端插入视频无法预览的问题 +## v2.3.0(2022-04-01) +1. `A` 增加了 `play` 事件,音视频播放时触发,可用于与页面其他音视频进行互斥播放 [详细](basic/event#play) +2. `U` `show-img-menu` 属性支持控制预览时是否长按弹出菜单 +3. `U` 优化 `wxs` 处理,提高渲染性能 [详细](https://developers.weixin.qq.com/community/develop/article/doc/0006cc2b204740f601bd43fa25a413) +4. `U` `video` 标签支持 `object-fit` 属性 +5. `U` 增加支持一些常用实体编码 [详细](https://github.com/jin-yufeng/mp-html/issues/418) +6. `F` 修复了图片仅设置高度可能不显示的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/410) +7. `F` 修复了 `video` 标签高度设置为 `auto` 不显示的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/411) +8. `F` 修复了使用 `grid` 布局时可能样式错误的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/413) +9. `F` 修复了含有合并单元格的表格部分情况下显示异常的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/417) +10. `F` 修复了 `editable` 插件连续插入内容时顺序不正确的问题 +11. `F` 修复了 `uni-app` 包 `vue3` 使用 `audio` 插件报错的问题 +12. `F` 修复了 `uni-app` 包 `highlight` 插件使用自定义的 `prism.min.js` 报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/416) +## v2.2.2(2022-02-26) +1. `A` 增加了 [pauseMedia](https://jin-yufeng.gitee.io/mp-html/#/advanced/api#pauseMedia) 的 `api`,可用于暂停播放音视频 [详细](https://github.com/jin-yufeng/mp-html/issues/317) +2. `U` 优化了长内容的加载速度 +3. `U` 适配 `vue3` [#389](https://github.com/jin-yufeng/mp-html/issues/389)、[#398](https://github.com/jin-yufeng/mp-html/pull/398) by [@zhouhuafei](https://github.com/zhouhuafei)、[#400](https://github.com/jin-yufeng/mp-html/issues/400) +4. `F` 修复了小程序端图片高度设置为百分比时可能不显示的问题 +5. `F` 修复了 `highlight` 插件部分情况下可能显示不完整的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/403) +## v2.2.1(2021-12-24) +1. `A` `editable` 插件增加上下移动标签功能 +2. `U` `editable` 插件支持在文本中间光标处插入内容 +3. `F` 修复了 `nvue` 端设置 `margin` 后可能导致高度不正确的问题 +4. `F` 修复了 `highlight` 插件使用压缩版的 `prism.css` 可能导致背景失效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/367) +5. `F` 修复了编辑状态下使用 `emoji` 插件内容为空时可能报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/371) +6. `F` 修复了使用 `editable` 插件后将 `selectable` 属性设置为 `force` 不生效的问题 +## v2.2.0(2021-10-12) +1. `A` 增加 `customElements` 配置项,便于添加自定义功能性标签 [详细](https://github.com/jin-yufeng/mp-html/issues/350) +2. `A` `editable` 插件增加切换音视频自动播放状态的功能 [详细](https://github.com/jin-yufeng/mp-html/pull/341) by [@leeseett](https://github.com/leeseett) +3. `A` `editable` 插件删除媒体标签时触发 `remove` 事件,便于删除已上传的文件 +4. `U` `editable` 插件 `insertImg` 方法支持同时插入多张图片 [详细](https://github.com/jin-yufeng/mp-html/issues/342) +5. `U` `editable` 插入图片和音视频时支持拼接 `domian` 主域名 +6. `F` 修复了内部链接参数中包含 `://` 时被认为是外部链接的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/356) +7. `F` 修复了部分 `svg` 标签名或属性名大小写不正确时不生效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/351) +8. `F` 修复了 `nvue` 页面运行到非 `app` 平台时可能样式错误的问题 +## v2.1.5(2021-08-13) +1. `A` 增加支持标签的 `dir` 属性 +2. `F` 修复了 `ruby` 标签文字与拼音没有居中对齐的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/325) +3. `F` 修复了音视频标签内有 `a` 标签时可能无法播放的问题 +4. `F` 修复了 `externStyle` 中的 `class` 名包含下划线或数字时可能失效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/326) +5. `F` 修复了 `h5` 端引入 `externStyle` 可能不生效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/326) +## v2.1.4(2021-07-14) +1. `F` 修复了 `rt` 标签无法设置样式的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/318) +2. `F` 修复了表格中有单元格同时合并行和列时可能显示不正确的问题 +3. `F` 修复了 `app` 端无法关闭图片长按菜单的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/322) +4. `F` 修复了 `editable` 插件只能添加图片链接不能修改的问题 [详细](https://github.com/jin-yufeng/mp-html/pull/312) by [@leeseett](https://github.com/leeseett) +## v2.1.3(2021-06-12) +1. `A` `editable` 插件增加 `insertTable` 方法 +2. `U` `editable` 插件支持编辑表格中的空白单元格 [详细](https://github.com/jin-yufeng/mp-html/issues/310) +3. `F` 修复了 `externStyle` 中使用伪类可能失效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/298) +4. `F` 修复了多个组件同时使用时 `tag-style` 属性时可能互相影响的问题 [详细](https://github.com/jin-yufeng/mp-html/pull/305) by [@woodguoyu](https://github.com/woodguoyu) +5. `F` 修复了包含 `linearGradient` 的 `svg` 可能无法显示的问题 +6. `F` 修复了编译到头条小程序时可能报错的问题 +7. `F` 修复了 `nvue` 端不触发 `click` 事件的问题 +8. `F` 修复了 `editable` 插件尾部插入时无法撤销的问题 +9. `F` 修复了 `editable` 插件的 `insertHtml` 方法只能在末尾插入的问题 +10. `F` 修复了 `editable` 插件插入音频不显示的问题 +## v2.1.2(2021-04-24) +1. `A` 增加了 [img-cache](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#img-cache) 插件,可以在 `app` 端缓存图片 [详细](https://github.com/jin-yufeng/mp-html/issues/292) by [@PentaTea](https://github.com/PentaTea) +2. `U` 支持通过 `container-style` 属性设置 `white-space` 来保留连续空格和换行符 [详细](https://jin-yufeng.gitee.io/mp-html/#/question/faq#space) +3. `U` 代码风格符合 [standard](https://standardjs.com) 标准 +4. `U` `editable` 插件编辑状态下支持预览视频 [详细](https://github.com/jin-yufeng/mp-html/issues/286) +5. `F` 修复了 `svg` 标签内嵌 `svg` 时无法显示的问题 +6. `F` 修复了编译到支付宝和头条小程序时部分区域不可复制的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/291) +## v2.1.1(2021-04-09) +1. 修复了对 `p` 标签设置 `tag-style` 可能不生效的问题 +2. 修复了 `svg` 标签中的文本无法显示的问题 +3. 修复了使用 `editable` 插件编辑表格时可能报错的问题 +4. 修复了使用 `highlight` 插件运行到头条小程序时可能没有样式的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/280) +5. 修复了使用 `editable` 插件 `editable` 属性为 `false` 时会报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/284) +6. 修复了 `style` 插件连续子选择器失效的问题 +7. 修复了 `editable` 插件无法修改图片和字体大小的问题 +## v2.1.0.2(2021-03-21) +修复了 `nvue` 端使用可能报错的问题 +## v2.1.0(2021-03-20) +1. `A` 增加了 [container-style](https://jin-yufeng.gitee.io/mp-html/#/basic/prop#container-style) 属性 [详细](https://gitee.com/jin-yufeng/mp-html/pulls/1) +2. `A` 增加支持 `strike` 标签 +3. `A` `editable` 插件增加 `placeholder` 属性 [详细](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#editable) +4. `A` `editable` 插件增加 `insertHtml` 方法 [详细](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#editable) +5. `U` 外部样式支持标签名选择器 [详细](https://jin-yufeng.gitee.io/mp-html/#/overview/quickstart#setting) +6. `F` 修复了 `nvue` 端部分情况下可能不显示的问题 +## v2.0.5(2021-03-12) +1. `U` [linktap](https://jin-yufeng.gitee.io/mp-html/#/basic/event#linktap) 事件增加返回内部文本内容 `innerText` [详细](https://github.com/jin-yufeng/mp-html/issues/271) +2. `U` [selectable](https://jin-yufeng.gitee.io/mp-html/#/basic/prop#selectable) 属性设置为 `force` 时能够在微信 `iOS` 端生效(文本块会变成 `inline-block`) [详细](https://github.com/jin-yufeng/mp-html/issues/267) +3. `F` 修复了部分情况下竖向无法滚动的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/182) +4. `F` 修复了多次修改富文本数据时部分内容可能不显示的问题 +5. `F` 修复了 [腾讯视频](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#txv-video) 插件可能无法播放的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/265) +6. `F` 修复了 [highlight](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#highlight) 插件没有设置高亮语言时没有应用默认样式的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/276) by [@fuzui](https://github.com/fuzui) diff --git a/src/uni_modules/mp-html/components/mp-html/mp-html.vue b/src/uni_modules/mp-html/components/mp-html/mp-html.vue new file mode 100644 index 0000000..d4cad07 --- /dev/null +++ b/src/uni_modules/mp-html/components/mp-html/mp-html.vue @@ -0,0 +1,498 @@ + + + + + diff --git a/src/uni_modules/mp-html/components/mp-html/node/node.vue b/src/uni_modules/mp-html/components/mp-html/node/node.vue new file mode 100644 index 0000000..c8fa062 --- /dev/null +++ b/src/uni_modules/mp-html/components/mp-html/node/node.vue @@ -0,0 +1,576 @@ +