17 changed files with 8419 additions and 0 deletions
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
{ |
||||
"navigationBarTitleText": "指派医生", |
||||
"navigationStyle": "default", |
||||
"usingComponents": { |
||||
"popupDoctorDetail": "/components/popupDoctorDetail/index", |
||||
"doctorAvatar": "/components/doctorAvatar/index", |
||||
"van-cascader": "@vant/weapp/cascader/index", |
||||
"van-popup": "@vant/weapp/popup/index", |
||||
"van-dialog": "@vant/weapp/dialog/index", |
||||
"pagination": "/components/pagination/index" |
||||
} |
||||
} |
@ -0,0 +1,204 @@
@@ -0,0 +1,204 @@
|
||||
page { |
||||
background-color: rgba(246, 246, 246, 1); |
||||
} |
||||
.page { |
||||
.header { |
||||
padding: 32rpx 32rpx 2rpx; |
||||
background-color: #fff; |
||||
.tip { |
||||
font-size: 28rpx; |
||||
color: rgba(20, 21, 21, 1); |
||||
.link { |
||||
color: rgba(0, 180, 197, 1); |
||||
} |
||||
} |
||||
.search-wrap { |
||||
margin-top: 32rpx; |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 22rpx; |
||||
.search { |
||||
flex: 1; |
||||
padding: 20rpx 30rpx; |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 20rpx; |
||||
border-radius: 122rpx; |
||||
background-color: rgba(246, 246, 246, 1); |
||||
.icon { |
||||
width: 32rpx; |
||||
height: 32rpx; |
||||
} |
||||
.input { |
||||
flex: 1; |
||||
text-align: center; |
||||
font-size: 28rpx; |
||||
color: #000; |
||||
} |
||||
.place-input { |
||||
color: rgba(205, 205, 205, 1); |
||||
} |
||||
} |
||||
.reset { |
||||
padding: 10rpx; |
||||
font-size: 28rpx; |
||||
color: #00b4c5; |
||||
} |
||||
} |
||||
.options { |
||||
display: flex; |
||||
align-items: center; |
||||
justify-content: space-between; |
||||
.option-wrap { |
||||
flex: 1; |
||||
.option { |
||||
padding: 30rpx 10rpx; |
||||
display: flex; |
||||
align-items: center; |
||||
justify-content: center; |
||||
.option-text { |
||||
max-width: 4em; |
||||
font-size: 32rpx; |
||||
color: rgba(20, 21, 21, 1); |
||||
overflow: hidden; |
||||
white-space: nowrap; |
||||
text-overflow: ellipsis; |
||||
} |
||||
.icon { |
||||
width: 24rpx; |
||||
height: 24rpx; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.list { |
||||
padding: 26rpx 32rpx 300rpx; |
||||
.list-item { |
||||
margin-bottom: 24rpx; |
||||
display: flex; |
||||
align-items: center; |
||||
.radio { |
||||
transform: scale(0.7); |
||||
} |
||||
.card { |
||||
flex: 1; |
||||
padding: 32rpx; |
||||
border-radius: 16rpx; |
||||
background-color: #fff; |
||||
display: flex; |
||||
gap: 24rpx; |
||||
.avatar { |
||||
flex-shrink: 0; |
||||
position: relative; |
||||
width: 112rpx; |
||||
height: 112rpx; |
||||
} |
||||
.wrap { |
||||
flex: 1; |
||||
.w-header { |
||||
.name { |
||||
margin-right: 10rpx; |
||||
display: inline; |
||||
font-size: 36rpx; |
||||
color: rgba(20, 21, 21, 1); |
||||
font-weight: bold; |
||||
} |
||||
.label { |
||||
display: inline; |
||||
font-size: 28rpx; |
||||
color: rgba(20, 21, 21, 1); |
||||
} |
||||
.line { |
||||
margin: 0 10rpx; |
||||
display: inline-block; |
||||
width: 1px; |
||||
height: 24rpx; |
||||
background-color: rgba(205, 205, 205, 1); |
||||
} |
||||
} |
||||
.w-container { |
||||
margin-top: 24rpx; |
||||
.hostipal { |
||||
margin-right: 12rpx; |
||||
font-size: 28rpx; |
||||
color: rgba(20, 21, 21, 1); |
||||
} |
||||
.tag { |
||||
margin-right: 12rpx; |
||||
display: inline-block; |
||||
padding: 0 8rpx; |
||||
border-radius: 4rpx; |
||||
font-size: 24rpx; |
||||
color: rgba(255, 255, 255, 1); |
||||
line-height: 32rpx; |
||||
background-color: rgba(0, 180, 197, 1); |
||||
} |
||||
.site { |
||||
display: inline-block; |
||||
padding: 0 8rpx; |
||||
font-size: 24rpx; |
||||
color: rgba(148, 87, 30, 1); |
||||
line-height: 32rpx; |
||||
border-radius: 4rpx; |
||||
background-color: rgba(250, 229, 206, 1); |
||||
} |
||||
} |
||||
.w-footer { |
||||
margin-top: 14rpx; |
||||
display: flex; |
||||
gap: 12rpx; |
||||
flex-wrap: wrap; |
||||
.wf-label { |
||||
flex-shrink: 0; |
||||
width: 48rpx; |
||||
height: 32rpx; |
||||
} |
||||
.wf-tag { |
||||
flex-shrink: 0; |
||||
padding: 0 8rpx; |
||||
font-size: 22rpx; |
||||
color: rgba(0, 180, 197, 1); |
||||
line-height: 32rpx; |
||||
border: 1px solid rgba(191, 239, 244, 1); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.footer { |
||||
position: fixed; |
||||
bottom: 0; |
||||
left: 0; |
||||
padding: 32rpx 32rpx calc(env(safe-area-inset-bottom) + 32rpx); |
||||
width: 100%; |
||||
box-sizing: border-box; |
||||
display: flex; |
||||
gap: 26rpx; |
||||
align-items: center; |
||||
justify-content: space-between; |
||||
background-color: #fff; |
||||
box-shadow: 0 -10rpx 20rpx rgba(0, 0, 0, 0.1); |
||||
.cancel { |
||||
width: 230rpx; |
||||
height: 84rpx; |
||||
text-align: center; |
||||
line-height: 88rpx; |
||||
font-size: 32rpx; |
||||
color: rgba(1, 180, 197, 1); |
||||
border-radius: 96rpx 96rpx 96rpx 96rpx; |
||||
border: 1px solid #01b4c5; |
||||
} |
||||
.submit { |
||||
flex: 1; |
||||
height: 88rpx; |
||||
text-align: center; |
||||
line-height: 88rpx; |
||||
font-size: 32rpx; |
||||
color: #fff; |
||||
background: linear-gradient(90deg, #00b4c5 0%, #54e2b4 100%); |
||||
border-radius: 96rpx; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,291 @@
@@ -0,0 +1,291 @@
|
||||
const app = getApp<IAppOption>(); |
||||
|
||||
Page({ |
||||
data: { |
||||
showDetail: false, |
||||
popupDoctorDetail: {}, |
||||
|
||||
showResolve: false, |
||||
|
||||
showArea: false, |
||||
fieldNames: { text: "label", value: "value", children: "children" }, |
||||
area: [], |
||||
|
||||
id: "", |
||||
|
||||
DoctorTitleType: {}, |
||||
hospitalClassification: {}, |
||||
hospitalLevel: {}, |
||||
SpecialtyList: [], |
||||
|
||||
search: "", |
||||
hospitalId: "", |
||||
HospitalName: "", |
||||
provinceId: "", |
||||
cityId: "", |
||||
countyId: "", |
||||
ProvinceName: "", |
||||
CityName: "", |
||||
CountyName: "", |
||||
specialtyId: "", |
||||
SpecialtyName: "", |
||||
|
||||
pagination: { |
||||
page: 1, |
||||
pages: 1, |
||||
count: 1, |
||||
}, |
||||
list: [], |
||||
|
||||
DoctorId: "", |
||||
|
||||
params: {}, |
||||
|
||||
caseId: "", |
||||
detailInvite: false, |
||||
feedBackInvite: false, |
||||
}, |
||||
onLoad(options) { |
||||
this.setData({ |
||||
caseId: options.cid, |
||||
}); |
||||
app.waitLogin().then(() => { |
||||
this.getList(); |
||||
this.getDoctorDict(); |
||||
this.getHostipalDict(); |
||||
this.getArea(); |
||||
}); |
||||
}, |
||||
getDoctorDict() { |
||||
wx.ajax({ |
||||
method: "GET", |
||||
url: "?r=takeda/reg/doctor-dict", |
||||
data: {}, |
||||
}).then((res) => { |
||||
const SpecialtyList: any = []; |
||||
res.DoctorSpecialtyLabel.forEach((item: any) => { |
||||
SpecialtyList.push(...item.options); |
||||
}); |
||||
this.setData({ |
||||
DoctorTitleType: res.DoctorTitleType, |
||||
SpecialtyList, |
||||
}); |
||||
}); |
||||
}, |
||||
getHostipalDict() { |
||||
wx.ajax({ |
||||
method: "GET", |
||||
url: "?r=takeda/reg/hospital-dict", |
||||
data: {}, |
||||
}).then((res) => { |
||||
this.setData({ |
||||
hospitalClassification: res.hospitalClassification, |
||||
hospitalLevel: res.hospitalLevel, |
||||
}); |
||||
}); |
||||
}, |
||||
getArea() { |
||||
wx.ajax({ |
||||
method: "GET", |
||||
url: "/js/area.json", |
||||
isJSON: true, |
||||
}).then((res) => { |
||||
this.setData({ |
||||
area: res, |
||||
}); |
||||
}); |
||||
}, |
||||
handleSearch() { |
||||
this.setData({ |
||||
list: [], |
||||
}); |
||||
this.getList(); |
||||
}, |
||||
handleReset() { |
||||
this.setData({ |
||||
search: "", |
||||
hospitalId: "", |
||||
HospitalName: "", |
||||
provinceId: "", |
||||
cityId: "", |
||||
countyId: "", |
||||
ProvinceName: "", |
||||
CityName: "", |
||||
CountyName: "", |
||||
specialtyId: "", |
||||
SpecialtyName: "", |
||||
}); |
||||
this.handleSearch(); |
||||
}, |
||||
getList(newPage = 1) { |
||||
const { caseId, search, hospitalId, provinceId, cityId, countyId, specialtyId } = this.data; |
||||
wx.ajax({ |
||||
method: "GET", |
||||
url: "?r=takeda/chat/get-invite-doctor-list", |
||||
data: { |
||||
caseId, |
||||
search, |
||||
hospitalId, |
||||
provinceId, |
||||
cityId, |
||||
countyId, |
||||
specialtyId, |
||||
page: newPage, |
||||
}, |
||||
}).then((res) => { |
||||
const list = res.page === 1 ? res.list : [...this.data.list, ...res.list]; |
||||
this.setData({ |
||||
list, |
||||
pagination: { |
||||
page: res.page, |
||||
pages: res.pages, |
||||
count: res.count, |
||||
}, |
||||
}); |
||||
}); |
||||
}, |
||||
onReachBottom() { |
||||
const { page, pages } = this.data.pagination; |
||||
if (pages > page) { |
||||
this.getList(page + 1); |
||||
} |
||||
}, |
||||
handlePopupDetail(e) { |
||||
const { index } = e.currentTarget.dataset; |
||||
const { list, hospitalClassification } = this.data; |
||||
const item: any = list[index]; |
||||
this.setData({ |
||||
showDetail: true, |
||||
popupDoctorDetail: { |
||||
DoctorLevel: item.doctorLevel, |
||||
DoctorImg: item.doctorImg, |
||||
DoctorName: item.doctorName, |
||||
DoctorTitleName: item.doctorTitleName || item.doctorOtherTitle, |
||||
HospitalName: item.hospitalName, |
||||
HospitalClassificationName: hospitalClassification[item.HospitalClassification], |
||||
HospitalLevelName: item.hospitalLevelName, |
||||
CityName: item.cityName, |
||||
CountyName: item.countyName, |
||||
Introduce: item.doctorIntroduce, |
||||
department: item.doctorDept, |
||||
specialty: item.doctorSpecialty, |
||||
}, |
||||
}); |
||||
}, |
||||
handlePopupClose() { |
||||
this.setData({ |
||||
showDetail: false, |
||||
}); |
||||
}, |
||||
handleHostipal() { |
||||
wx.navigateTo({ |
||||
url: `/module1/pages/sHostipal/index`, |
||||
events: { |
||||
acceptDataFromOpenedPage: (data: any) => { |
||||
this.setData({ |
||||
HospitalId: data.hid, |
||||
HospitalName: data.hname, |
||||
}); |
||||
this.handleSearch(); |
||||
}, |
||||
}, |
||||
}); |
||||
}, |
||||
handleArea() { |
||||
this.setData({ |
||||
showArea: true, |
||||
}); |
||||
}, |
||||
onClose() { |
||||
this.setData({ |
||||
showArea: false, |
||||
showResolve: false, |
||||
}); |
||||
}, |
||||
onFinish(e: any) { |
||||
this.setData({ |
||||
provinceId: e.detail.selectedOptions[0].value, |
||||
ProvinceName: e.detail.selectedOptions[0].label, |
||||
cityId: e.detail.selectedOptions[1].value, |
||||
CityName: e.detail.selectedOptions[1].label, |
||||
countyId: e.detail.selectedOptions[2].value, |
||||
CountyName: e.detail.selectedOptions[2].label, |
||||
showArea: false, |
||||
}); |
||||
this.handleSearch(); |
||||
}, |
||||
handleSpecialChange(e: any) { |
||||
const index = e.detail.value; |
||||
const { SpecialtyList } = this.data; |
||||
const item: any = SpecialtyList[index]; |
||||
this.setData({ |
||||
specialtyId: item.value, |
||||
SpecialtyName: item.label, |
||||
}); |
||||
this.handleSearch(); |
||||
}, |
||||
|
||||
handleRadio(e) { |
||||
const { index } = e.currentTarget.dataset; |
||||
const { list } = this.data; |
||||
this.setData({ |
||||
DoctorId: (list as any)[index].doctorId, |
||||
}); |
||||
}, |
||||
handleSubmit() { |
||||
const { feedBackInvite, caseId, DoctorId, params, detailInvite } = this.data; |
||||
if (!DoctorId) { |
||||
wx.showToast({ |
||||
title: "请选择指派医生", |
||||
icon: "none", |
||||
}); |
||||
} |
||||
if (feedBackInvite) { |
||||
wx.ajax({ |
||||
method: "POST", |
||||
url: "?r=takeda/case/add-feedback", |
||||
data: { |
||||
caseId, |
||||
dealDoctorId: DoctorId, |
||||
...params, |
||||
}, |
||||
}).then(() => { |
||||
wx.redirectTo({ |
||||
url: `/module1/pages/casesDetail/index?id=${caseId}`, |
||||
}); |
||||
}); |
||||
return; |
||||
} |
||||
|
||||
if (detailInvite) { |
||||
wx.ajax({ method: "POST", url: "?r=takeda/case/invite-doctor", data: { caseId, dealDoctorId: DoctorId } }).then( |
||||
(res) => { |
||||
wx.navigateTo({ |
||||
url: `/module1/pages/entryCasesResult/index?isf=${res.isSubscribe}&wxi=${encodeURIComponent(res.wxImg)}&cid=${res.caseId}`, |
||||
}); |
||||
}, |
||||
); |
||||
return; |
||||
} |
||||
const url = caseId ? "?r=takeda/case/save-case" : "?r=takeda/case/create-case"; |
||||
wx.ajax({ |
||||
method: "POST", |
||||
url, |
||||
data: { |
||||
...params, |
||||
caseId, |
||||
isSubmit: 1, |
||||
dealDoctorId: DoctorId, |
||||
}, |
||||
}).then((res) => { |
||||
wx.reLaunch({ |
||||
url: `/module1/pages/entryCasesResult/index?isf=${res.isSubscribe}&wxi=${encodeURIComponent(res.wxImg)}&cid=${res.caseId || caseId}`, |
||||
}); |
||||
}); |
||||
}, |
||||
handleBack() { |
||||
wx.navigateBack(); |
||||
}, |
||||
}); |
||||
|
||||
export {}; |
@ -0,0 +1,97 @@
@@ -0,0 +1,97 @@
|
||||
<view class="page"> |
||||
<view class="header"> |
||||
<view class="tip">邀请医生进行病历反馈,提交后医生将收到消息提醒</view> |
||||
<view class="search-wrap"> |
||||
<view class="search"> |
||||
<image class="icon" src="{{imageUrl}}icon-search.png?t={{Timestamp}}"></image> |
||||
<input |
||||
model:value="{{search}}" |
||||
class="input" |
||||
placeholder-class="place-input" |
||||
placeholder="搜索医生名" |
||||
type="text" |
||||
confirm-type="search" |
||||
bindconfirm="handleSearch" |
||||
/> |
||||
</view> |
||||
<view class="reset" bind:tap="handleReset">重置</view> |
||||
</view> |
||||
<view class="options"> |
||||
<view class="option-wrap" bind:tap="handleHostipal"> |
||||
<view class="option"> |
||||
<text class="option-text">{{HospitalName || '医院'}}</text> |
||||
<image class="icon" src="{{imageUrl}}triangle-down.png?t={{Timestamp}}"></image> |
||||
</view> |
||||
</view> |
||||
<view class="option-wrap" bind:tap="handleArea"> |
||||
<view class="option"> |
||||
<text class="option-text">{{CountyName || '地区'}}</text> |
||||
<image class="icon" src="{{imageUrl}}triangle-down.png?t={{Timestamp}}"></image> |
||||
</view> |
||||
</view> |
||||
<picker class="option-wrap" range="{{SpecialtyList}}" range-key="label" bindchange="handleSpecialChange"> |
||||
<view class="option"> |
||||
<text class="option-text">{{SpecialtyName || '医生专长'}}</text> |
||||
<image class="icon" src="{{imageUrl}}triangle-down.png?t={{Timestamp}}"></image> |
||||
</view> |
||||
</picker> |
||||
</view> |
||||
</view> |
||||
<view class="container"> |
||||
<radio-group> |
||||
<view class="list"> |
||||
<view class="list-item" wx:for="{{list}}" wx:key="DoctorId"> |
||||
<radio class="radio" value="{{item.DoctorId}}" bind:tap="handleRadio" data-index="{{index}}"></radio> |
||||
<view class="card" bind:tap="handlePopupDetail" data-index="{{index}}"> |
||||
<doctorAvatar class="avatar" src="{{item.doctorImg}}" level="{{item.doctorLevel}}"></doctorAvatar> |
||||
<view class="wrap"> |
||||
<view class="w-header"> |
||||
<view class="name">{{item.doctorName}}</view> |
||||
<view class="label">{{item.doctorTitleName || item.doctorOtherTitle}}</view> |
||||
<block wx:for-item="depart" wx:for="{{item.doctorDept}}" wx:key="departmentId"> |
||||
<view class="line"></view> |
||||
<view class="label">{{depart.DepartmentName}}</view> |
||||
</block> |
||||
</view> |
||||
<view class="w-container"> |
||||
<text class="hostipal">{{item.hospitalName}}</text> |
||||
<view class="tag">{{item.hospitalClassificationName}}{{item.hospitalLevelName}}</view> |
||||
<view class="site" wx:if="{{item.cityName}}"> |
||||
{{item.cityName}}{{item.countyName?'/':''}}{{item.countyName}} |
||||
</view> |
||||
</view> |
||||
<view class="w-footer"> |
||||
<image class="wf-label" src="{{imageUrl}}text-specialty.png?t={{Timestamp}}" mode="aspectFit"></image> |
||||
<view class="wf-tag" wx:for="{{item.doctorSpecialty}}" wx:for-item="spec" wx:key="SpecialtyId"> |
||||
{{spec.SpecialtyName}} |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
<pagination pagination="{{pagination}}"></pagination> |
||||
</view> |
||||
</radio-group> |
||||
</view> |
||||
<view class="footer"> |
||||
<view class="cancel" bind:tap="handleBack">返回</view> |
||||
<view class="submit" bind:tap="handleSubmit">确认提交</view> |
||||
</view> |
||||
</view> |
||||
|
||||
<popupDoctorDetail |
||||
show="{{showDetail}}" |
||||
params="{{popupDoctorDetail}}" |
||||
bind:close="handlePopupClose" |
||||
></popupDoctorDetail> |
||||
|
||||
<van-popup show="{{ showArea }}" round position="bottom"> |
||||
<van-cascader |
||||
value="{{ cascaderValue }}" |
||||
title="请选择所在地区" |
||||
options="{{ area }}" |
||||
field-names="{{fieldNames}}" |
||||
bind:close="onClose" |
||||
bind:finish="onFinish" |
||||
/> |
||||
</van-popup> |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
var dispCbs = []; |
||||
var dispIns = []; |
||||
|
||||
function Dispatcher() { |
||||
dispIns.push(this); |
||||
dispCbs.push({}); |
||||
} |
||||
|
||||
Dispatcher.prototype = { |
||||
on(type, cb) { |
||||
let cbtypes = dispCbs[dispIns.indexOf(this)]; |
||||
let cbs = cbtypes[type] = cbtypes[type] || []; |
||||
if (!~cbs.indexOf(cb)) { |
||||
cbs.push(cb); |
||||
} |
||||
}, |
||||
|
||||
off(type, cb) { |
||||
let cbtypes = dispCbs[dispIns.indexOf(this)]; |
||||
let cbs = cbtypes[type] = cbtypes[type] || []; |
||||
let curTypeCbIdx = cbs.indexOf(cb); |
||||
if (~curTypeCbIdx) { |
||||
cbs.splice(curTypeCbIdx, 1); |
||||
} |
||||
}, |
||||
|
||||
fire(type, ...args) { |
||||
let cbtypes = dispCbs[dispIns.indexOf(this)]; |
||||
let cbs = cbtypes[type] = cbtypes[type] || []; |
||||
|
||||
for (let i = 0; i < cbs.length; i++) { |
||||
cbs[i].apply(null, args); |
||||
} |
||||
} |
||||
|
||||
}; |
||||
module.exports = Dispatcher; |
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
var obsCbs = obsCbs || []; |
||||
var obsObjs = obsObjs || []; |
||||
var cloneObjs = cloneObjs || []; |
||||
|
||||
function newOne(obj){ |
||||
obsObjs.push(obj); |
||||
obsCbs.push([]); |
||||
cloneObjs.push(Object.assign({}, obj)); |
||||
} |
||||
|
||||
module.exports = { |
||||
del(obj, cb){ |
||||
let curObjIdx = obsObjs.indexOf(obj); |
||||
if(~curObjIdx){ |
||||
let cbs = obsCbs[curObjIdx]; |
||||
let curCbIdx = cbs.indexOf(cb); |
||||
if(~curCbIdx){ |
||||
cbs.splice(curCbIdx, 1); |
||||
if(!cbs.length){ |
||||
obsObjs.splice(curObjIdx, 1); |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
add(obj, cb){ |
||||
let curIdx = obsObjs.indexOf(obj); |
||||
if(!~curIdx){ |
||||
curIdx = obsObjs.length; |
||||
newOne(obj); |
||||
} |
||||
let cbs = obsCbs[curIdx]; |
||||
cbs.push(cb); |
||||
for(let key in obj){ |
||||
Object.defineProperty(obj, key, { |
||||
set: function(val){ |
||||
cloneObjs[curIdx][key] = val; |
||||
for(let i = 0; i < cbs.length; i++){ |
||||
cbs[i].apply(obj, [val, key]); |
||||
} |
||||
}, |
||||
get: function(){ |
||||
return cloneObjs[curIdx][key]; |
||||
} |
||||
}); |
||||
} |
||||
return obj; |
||||
}, |
||||
}; |
@ -0,0 +1,266 @@
@@ -0,0 +1,266 @@
|
||||
import websdk from "@/sdk/Easemob-chat-4.3.1"; |
||||
import config from "./WebIMConfig"; |
||||
|
||||
console.group = console.group || {}; |
||||
console.groupEnd = console.groupEnd || {}; |
||||
|
||||
const window = {}; |
||||
const WebIM = window.WebIM = websdk; |
||||
WebIM.message = websdk.message |
||||
window.WebIM.config = config; |
||||
//var DOMParser = window.DOMParser = xmldom.DOMParser;
|
||||
//let document = window.document = new DOMParser().parseFromString("<?xml version='1.0'?>\n", "text/xml");
|
||||
|
||||
WebIM.isDebug = function (option) { |
||||
if (option) { |
||||
WebIM.config.isDebug = option.isDebug |
||||
openDebug(WebIM.config.isDebug) |
||||
} |
||||
|
||||
function openDebug(value) { |
||||
function ts() { |
||||
const d = new Date(); |
||||
const Hours = d.getHours(); // 获取当前小时数(0-23)
|
||||
const Minutes = d.getMinutes(); // 获取当前分钟数(0-59)
|
||||
const Seconds = d.getSeconds(); // 获取当前秒数(0-59)
|
||||
return `${Hours < 10 ? `0${ Hours}` : Hours }:${ Minutes < 10 ? `0${ Minutes}` : Minutes }:${ Seconds < 10 ? `0${ Seconds}` : Seconds } `; |
||||
} |
||||
|
||||
|
||||
// if (value) {
|
||||
// Strophe.Strophe.Connection.prototype.rawOutput = function(data){
|
||||
// try{
|
||||
// console.group("%csend # " + ts(), "color: blue; font-size: large");
|
||||
// console.log("%c" + data, "color: blue");
|
||||
// console.groupEnd();
|
||||
// }
|
||||
// catch(e){
|
||||
// console.log(e);
|
||||
// }
|
||||
// };
|
||||
// }else{
|
||||
// Strophe.Strophe.Connection.prototype.rawOutput = function(){};
|
||||
// }
|
||||
|
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Set autoSignIn as true (autoSignInName and autoSignInPwd are configured below), |
||||
* You can auto signed in each time when you refresh the page in dev model. |
||||
*/ |
||||
WebIM.config.autoSignIn = false; |
||||
if (WebIM.config.autoSignIn) { |
||||
WebIM.config.autoSignInName = "lwz2"; |
||||
WebIM.config.autoSignInPwd = "1"; |
||||
} |
||||
|
||||
|
||||
// var stropheConn = new window.Strophe.Connection("ws://im-api.easemob.com/ws/", {
|
||||
// inactivity: 30,
|
||||
// maxRetries: 5,
|
||||
// pollingTime: 4500
|
||||
// });
|
||||
//
|
||||
// stropheConn.connect(
|
||||
// '$t$' + 'YWMtmbQEBKKIEeaGmMtXyg5n1wAAAVlkQvGO2WOJGlMCEJKM4VV9GCMnb_XLCXU',
|
||||
// function() {
|
||||
// console.log(arguments, 'ggogogo');
|
||||
// }, stropheConn.wait, stropheConn.hold);
|
||||
WebIM.parseEmoji = function (msg) { |
||||
if (typeof WebIM.Emoji === "undefined" || typeof WebIM.Emoji.map === "undefined") { |
||||
return msg; |
||||
} |
||||
const emoji = WebIM.Emoji; |
||||
var reg = null; |
||||
const msgList = []; |
||||
const objList = []; |
||||
for (const face in emoji.map) { |
||||
if (emoji.map.hasOwnProperty(face)) { |
||||
while (msg.includes(face)) { |
||||
msg = msg.replace(face, `^${ emoji.map[face] }^`); |
||||
} |
||||
} |
||||
} |
||||
const ary = msg.split("^"); |
||||
var reg = /^e.*g$/; |
||||
for (var i = 0; i < ary.length; i++) { |
||||
if (ary[i] != "") { |
||||
msgList.push(ary[i]); |
||||
} |
||||
} |
||||
for (var i = 0; i < msgList.length; i++) { |
||||
if (reg.test(msgList[i])) { |
||||
var obj = {}; |
||||
obj.data = msgList[i]; |
||||
obj.type = "emoji"; |
||||
objList.push(obj); |
||||
} |
||||
else { |
||||
var obj = {}; |
||||
obj.data = msgList[i]; |
||||
obj.type = "txt"; |
||||
objList.push(obj); |
||||
} |
||||
} |
||||
return objList; |
||||
}; |
||||
|
||||
WebIM.time = function () { |
||||
const date = new Date(); |
||||
const Hours = date.getHours(); |
||||
const Minutes = date.getMinutes(); |
||||
const Seconds = date.getSeconds(); |
||||
const time = `${date.getFullYear() }-${ date.getMonth() + 1 }-${ date.getDate() } ${ |
||||
Hours < 10 ? `0${ Hours}` : Hours }:${ Minutes < 10 ? `0${ Minutes}` : Minutes }:${ Seconds < 10 ? `0${ Seconds}` : Seconds}`;
|
||||
return time; |
||||
}; |
||||
|
||||
WebIM.Emoji = { |
||||
path: "../../../../../images/faces/", |
||||
map: { |
||||
"[):]": "ee_1.png", |
||||
"[:D]": "ee_2.png", |
||||
"[;)]": "ee_3.png", |
||||
"[:-o]": "ee_4.png", |
||||
"[:p]": "ee_5.png", |
||||
"[(H)]": "ee_6.png", |
||||
"[:@]": "ee_7.png", |
||||
"[:s]": "ee_8.png", |
||||
"[:$]": "ee_9.png", |
||||
"[:(]": "ee_10.png", |
||||
"[:'(]": "ee_11.png", |
||||
"[<o)]": "ee_12.png", |
||||
"[(a)]": "ee_13.png", |
||||
"[8o|]": "ee_14.png", |
||||
"[8-|]": "ee_15.png", |
||||
"[+o(]": "ee_16.png", |
||||
"[|-)]": "ee_17.png", |
||||
"[:|]": "ee_18.png", |
||||
"[*-)]": "ee_19.png", |
||||
"[:-#]": "ee_20.png", |
||||
"[^o)]": "ee_21.png", |
||||
"[:-*]": "ee_22.png", |
||||
"[8-)]": "ee_23.png", |
||||
"[del]": "btn_del.png", |
||||
"[(|)]": "ee_24.png", |
||||
"[(u)]": "ee_25.png", |
||||
"[(S)]": "ee_26.png", |
||||
"[(*)]": "ee_27.png", |
||||
"[(#)]": "ee_28.png", |
||||
"[(R)]": "ee_29.png", |
||||
"[({)]": "ee_30.png", |
||||
"[(})]": "ee_31.png", |
||||
"[(k)]": "ee_32.png", |
||||
"[(F)]": "ee_33.png", |
||||
"[(W)]": "ee_34.png", |
||||
"[(D)]": "ee_35.png" |
||||
} |
||||
}; |
||||
|
||||
WebIM.EmojiObj = { |
||||
// 相对 emoji.js 路径
|
||||
path: "../../../../../images/faces/", |
||||
map1: { |
||||
"[):]": "ee_1.png", |
||||
"[:D]": "ee_2.png", |
||||
"[;)]": "ee_3.png", |
||||
"[:-o]": "ee_4.png", |
||||
"[:p]": "ee_5.png", |
||||
"[(H)]": "ee_6.png", |
||||
"[:@]": "ee_7.png" |
||||
}, |
||||
map2: { |
||||
"[:s]": "ee_8.png", |
||||
"[:$]": "ee_9.png", |
||||
"[:(]": "ee_10.png", |
||||
"[:'(]": "ee_11.png", |
||||
"[<o)]": "ee_12.png", |
||||
"[(a)]": "ee_13.png", |
||||
"[8o|]": "ee_14.png" |
||||
}, |
||||
map3: { |
||||
"[8-|]": "ee_15.png", |
||||
"[+o(]": "ee_16.png", |
||||
"[|-)]": "ee_17.png", |
||||
"[:|]": "ee_18.png", |
||||
"[*-)]": "ee_19.png", |
||||
"[:-#]": "ee_20.png", |
||||
"[del]": "del.png" |
||||
}, |
||||
map4: { |
||||
"[^o)]": "ee_21.png", |
||||
"[:-*]": "ee_22.png", |
||||
"[8-)]": "ee_23.png", |
||||
"[(|)]": "ee_24.png", |
||||
"[(u)]": "ee_25.png", |
||||
"[(S)]": "ee_26.png", |
||||
"[(*)]": "ee_27.png" |
||||
}, |
||||
map5: { |
||||
"[(#)]": "ee_28.png", |
||||
"[(R)]": "ee_29.png", |
||||
"[({)]": "ee_30.png", |
||||
"[(})]": "ee_31.png", |
||||
"[(k)]": "ee_32.png", |
||||
"[(F)]": "ee_33.png", |
||||
"[(W)]": "ee_34.png", |
||||
"[(D)]": "ee_35.png" |
||||
}, |
||||
map6: { |
||||
"[del]": "del.png" |
||||
} |
||||
}; |
||||
|
||||
|
||||
WebIM.conn = new WebIM.connection({ |
||||
appKey: WebIM.config.appkey, |
||||
isMultiLoginSessions: WebIM.config.isMultiLoginSessions, |
||||
https: true, //typeof WebIM.config.https === "boolean" ? WebIM.config.https : location.protocol === "https:",
|
||||
url: WebIM.config.socketServer, |
||||
apiUrl: WebIM.config.apiURL, |
||||
isAutoLogin: false, |
||||
heartBeatWait: 30000, //WebIM.config.heartBeatWait,
|
||||
autoReconnectNumMax: WebIM.config.autoReconnectNumMax, |
||||
autoReconnectInterval: WebIM.config.autoReconnectInterval, |
||||
isDebug: WebIM.config.isDebug, |
||||
deviceId: WebIM.config.deviceId |
||||
}); |
||||
|
||||
// async response
|
||||
// WebIM.conn.listen({
|
||||
// onOpened: () => dispatch({type: Types.ON_OPEND})
|
||||
// })
|
||||
Math.uuid = function (len, radix) { |
||||
const CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); |
||||
const chars = CHARS; const uuid = []; let i; |
||||
radix = radix || chars.length; |
||||
|
||||
if (len) { |
||||
// Compact form
|
||||
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]; |
||||
} else { |
||||
// rfc4122, version 4 form
|
||||
let r; |
||||
|
||||
// rfc4122 requires these characters
|
||||
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; |
||||
uuid[14] = '4'; |
||||
|
||||
// Fill in random data. At i==19 set the high bits of clock sequence
|
||||
// as
|
||||
// per rfc4122, sec. 4.1.5
|
||||
for (i = 0; i < 36; i++) { |
||||
if (!uuid[i]) { |
||||
r = 0 | Math.random() * 16; |
||||
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r]; |
||||
} |
||||
} |
||||
} |
||||
|
||||
return uuid.join(''); |
||||
}; |
||||
// export default WebIM;
|
||||
module.exports = { |
||||
"default": WebIM |
||||
}; |
@ -0,0 +1,88 @@
@@ -0,0 +1,88 @@
|
||||
/** |
||||
* git do not control webim.config.js |
||||
* everyone should copy webim.config.js to webim.config.js |
||||
* and have their own configs. |
||||
* In this way , others won't be influenced by this config while git pull. |
||||
* |
||||
*/ |
||||
|
||||
// for react native
|
||||
const location = { |
||||
protocol: "https", |
||||
}; |
||||
|
||||
const config = { |
||||
/* |
||||
* socket server |
||||
*/ |
||||
// socketServer: "wss://im-api.easemob.com/ws/", //小程序2.0sdk线上环境 请使用2.0版本sdk
|
||||
// socketServer: "wss://im-api-hsb.easemob.com/ws/", //小程序2.0sdk沙箱环境 请使用2.0版本sdk
|
||||
// socketServer: 'wss://im-api-new-hsb.easemob.com/websocket', //小程序沙箱环境
|
||||
socketServer: "wss://im-api-wechat.easemob.com/websocket", //小程序线上环境
|
||||
// socketServer: 'wss://hk-wx.easemob.com/websocket',
|
||||
/* |
||||
* Backend REST API URL |
||||
*/ |
||||
// apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com',
|
||||
apiURL: "https://a1.easemob.com", // 线上环境
|
||||
// apiURL: "https://a1-hsb.easemob.com", // 沙箱环境
|
||||
// apiURL: 'https://hk-test.easemob.com',
|
||||
/* |
||||
* Application AppKey |
||||
*/ |
||||
appkey: "1110180510146396#dream", |
||||
/* |
||||
* Whether to use HTTPS '1177161227178308#xcx' |
||||
* @parameter {Boolean} true or false |
||||
*/ |
||||
https: false, |
||||
/* |
||||
* isMultiLoginSessions |
||||
* true: A visitor can sign in to multiple webpages and receive messages at all the webpages. |
||||
* false: A visitor can sign in to only one webpage and receive messages at the webpage. |
||||
*/ |
||||
isMultiLoginSessions: false, |
||||
/** |
||||
* Whether to use window.doQuery() |
||||
* @parameter {boolean} true or false |
||||
*/ |
||||
isWindowSDK: false, |
||||
/** |
||||
* isSandBox=true: xmppURL: 'im-api.sandbox.easemob.com', apiURL: '//a1.sdb.easemob.com', |
||||
* isSandBox=false: xmppURL: 'im-api.easemob.com', apiURL: '//a1.easemob.com', |
||||
* @parameter {boolean} true or false |
||||
*/ |
||||
isSandBox: false, |
||||
/** |
||||
* Whether to console.log in strophe.log() |
||||
* @parameter {boolean} true or false |
||||
*/ |
||||
isDebug: true, |
||||
/** |
||||
* will auto connect the xmpp server autoReconnectNumMax times in background when client is offline. |
||||
* won't auto connect if autoReconnectNumMax=0. |
||||
*/ |
||||
autoReconnectNumMax: 5, |
||||
/** |
||||
* the interval secons between each atuo reconnectting. |
||||
* works only if autoReconnectMaxNum >= 2. |
||||
*/ |
||||
autoReconnectInterval: 2, |
||||
/** |
||||
* webrtc supports WebKit and https only |
||||
*/ |
||||
isWebRTC: false, |
||||
/* |
||||
* Set to auto sign-in |
||||
*/ |
||||
isAutoLogin: true, |
||||
|
||||
heartBeatWait: 30000, |
||||
|
||||
/* |
||||
* 需要替换成自己的声网 appId,此 appId 有限量,仅供参考使用,同时获取声网 token 的接口仅能供此 appId 使用,换成自己的 appId 后需要自己去实现 app server 获取声网token。 |
||||
*/ |
||||
AgoraAppId: "15cb0d28b87b425ea613fc46f7c9f974", |
||||
}; |
||||
|
||||
export default config; |
Loading…
Reference in new issue