Commit af53ee64 by 刘鹏

feat: 改变信息收集入口

parent f451ce8d
......@@ -2,10 +2,10 @@ package com.yidianling.im.helper
import android.annotation.SuppressLint
import android.content.Context
import androidx.core.content.ContextCompat
import androidx.appcompat.app.AppCompatActivity
import android.text.TextUtils
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.data.http.BaseAPIResponse
......@@ -35,6 +35,7 @@ import com.yidianling.im.http.ImRetrofitApi.Companion.getImRetrofitApi
import com.yidianling.im.router.ImIn
import com.yidianling.im.router.ImIn.isLogin
import com.yidianling.im.session.SessionHelper
import com.yidianling.im.ui.activity.CmsExamQuestionPaperActivity
import com.yidianling.im.ui.page.fragment.bean.ChatItemBean
import com.yidianling.uikit.business.session.fragment.YDLMessageFragment
import com.yidianling.uikit.business.session.helper.ChatStatusCacheHelper
......@@ -55,10 +56,11 @@ import java.net.URLEncoder
*/
object IMChatUtil {
private var loadingDialog: LoadingDialogFragment? = null
private const val USER_TYPE_EXPERT=2//专家
private const val USER_TYPE_ASSISTANT=3//助理
private const val USER_TYPE_USER=1//用户
lateinit var doctorId:String
private const val USER_TYPE_EXPERT = 2//专家
private const val USER_TYPE_ASSISTANT = 3//助理
private const val USER_TYPE_USER = 1//用户
lateinit var doctorId: String
/**
* 接口数据请求完成回调
*/
......@@ -85,14 +87,74 @@ object IMChatUtil {
* @param context
* @param chatItemBean
*/
@SuppressLint("CheckResult")
fun startChat(context: AppCompatActivity?, chatItemBean: ChatItemBean) {
SessionHelper.startP2PSession(
context,
chatItemBean.utype,
chatItemBean.toUid.toString(),
null,
P2PCustomActionHandlerImpl(chatItemBean)
)
if (context == null || (!isLogin(context, true))) {
return
}
if (loadingDialog == null) {
loadingDialog = newInstance(null)
}
if (context.supportFragmentManager != null && !context.isDestroyed) {
loadingDialog?.show(context.supportFragmentManager, null)
}
getImJavaApi().getUserType(chatItemBean.toUid.toString())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ res: BaseResponse<UserTypeBean> ->
if (res.code == 200 && res.data != null) {
if (res.data!!.collectEvent &&TextUtils.equals(res.data!!.userType, USER_TYPE_ASSISTANT.toString()) && res.data!!.collectEvent) {
//和助理私聊需要打开信息采集弹窗
prepareAssistantChatData(
context,
chatItemBean.toUid.toString(),
object : ChatDataRequestListener {
override fun onSuccess(expertInfo: IMExpertBuild) { //新前置信息收集入口
CmsExamQuestionPaperActivity.start(
context, chatItemBean.toUid.toString(), expertInfo,
0
)
}
})
} else {
SessionHelper.startP2PSession(
context,
chatItemBean.utype,
chatItemBean.toUid.toString(),
null,
P2PCustomActionHandlerImpl(chatItemBean)
)
}
} else {
if (loadingDialog != null && loadingDialog!!.isVisible) {
loadingDialog?.dismissAllowingStateLoss()
}
SessionHelper.startP2PSession(
context,
chatItemBean.utype,
chatItemBean.toUid.toString(),
null,
P2PCustomActionHandlerImpl(chatItemBean)
)
}
}, { throwable: Throwable? ->
if (loadingDialog != null && loadingDialog!!.isVisible) {
loadingDialog?.dismissAllowingStateLoss()
}
SessionHelper.startP2PSession(
context,
chatItemBean.utype,
chatItemBean.toUid.toString(),
null,
P2PCustomActionHandlerImpl(chatItemBean)
)
})
}
/**
......@@ -147,12 +209,24 @@ object IMChatUtil {
}) { t: Throwable? ->
handleError(context, t!!)
}
} else if (TextUtils.equals(res.data!!.userType, USER_TYPE_ASSISTANT.toString()) && res.data!!.collectEvent) {//助理
prepareAssistantChatData(context, toUid, object : ChatDataRequestListener {
override fun onSuccess(expertInfo: IMExpertBuild) { //新前置信息收集入口
CmsExamQuestionPaperActivity.start(
context,
toUid,
expertInfo,
isFromQingShu
)
}
})
} else {
prepareAssistantChatData(context, toUid, object : ChatDataRequestListener {
override fun onSuccess(expertInfo: IMExpertBuild) {
startChatSession(toUid, expertInfo, isFromQingShu, context)
}
})
}
} else {
if (loadingDialog != null && loadingDialog!!.isVisible) {
......@@ -165,8 +239,7 @@ object IMChatUtil {
loadingDialog?.dismissAllowingStateLoss()
}
handleError(context, throwable!!)
}
)
})
}
......@@ -197,7 +270,8 @@ object IMChatUtil {
isFromQingShu: Int,
context: AppCompatActivity
) {
AliYunRichLogsHelper.getInstance().sendRichLog(AliYunLogConfig.YUNXIN, "startChatSession 开启聊天会话")
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.YUNXIN, "startChatSession 开启聊天会话")
val p2PCustomActionHandlerImpl = P2PCustomActionHandlerImpl(toUid, expertInfo)
p2PCustomActionHandlerImpl.isFromQingShu = isFromQingShu
SessionHelper.startP2PSession(
......@@ -209,6 +283,18 @@ object IMChatUtil {
)
}
/**
* 信息收集前置页调用方法
* */
open fun startChatSessionByCms(
toUid: String,
expertInfo: IMExpertBuild,
isFromQingShu: Int,
context: AppCompatActivity
) {
startChatSession(toUid, expertInfo, isFromQingShu, context)
}
//====================准备私聊数据====================
/**
* 初始化聊天数据
......@@ -489,7 +575,7 @@ object IMChatUtil {
val showExpertList = !(promptRule == 1 || promptRule == 3)
if (actionHandler.userType == USER_TYPE_EXPERT && status == 2) { //当该专家离线时
sendRecommendExpertListMessage(1, showExpertList, toUid, actionHandler)
} else if (actionHandler.userType == USER_TYPE_EXPERT&& status >= 3) { //当该专家忙碌时
} else if (actionHandler.userType == USER_TYPE_EXPERT && status >= 3) { //当该专家忙碌时
sendRecommendExpertListMessage(2, showExpertList, toUid, actionHandler)
}
}
......
......@@ -10,8 +10,6 @@ import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.netease.nimlib.sdk.NIMClient
import com.netease.nimlib.sdk.msg.MsgService
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum
......@@ -22,12 +20,15 @@ import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.R
import com.yidianling.im.api.event.ImLogoutEvent
import com.yidianling.im.api.event.UpdateBottomBarUnreadNumEvent
import com.yidianling.im.bridge.P2PCustomActionHandlerImpl
import com.yidianling.im.config.constants.ImConstants
import com.yidianling.im.event.MessageListRefreshEvent
import com.yidianling.im.event.ReQureyUnreadNum
import com.yidianling.im.event.UpdateTabUnreadNumEvent
import com.yidianling.im.helper.MsgReceiveHelper
import com.yidianling.im.http.ImHttpImpl
import com.yidianling.im.router.ImIn
import com.yidianling.im.session.SessionHelper
import com.yidianling.im.ui.page.dialog.MessageChatSettingDialog
import com.yidianling.im.ui.page.fragment.ChatFragment
import com.yidianling.im.ui.page.fragment.InteractFragment
......@@ -37,18 +38,11 @@ import com.yidianling.im.ui.page.fragment.bean.UnreadMessageBean
import com.yidianling.im.ui.page.popupWindow.ChatSettingPopupWindow
import com.yidianling.im.ui.param.ClearMessageParam
import com.yidianling.im.ui.param.UnreadParam
import com.yidianling.uikit.business.session.view.CollectInfoPopupWindow
import com.yidianling.uikit.business.session.view.CollectInfoPopupWindow.OnSendMsgListener
import com.yidianling.uikit.custom.http.response.UserQuestInfoBean
import com.yidianling.uikit.custom.http.response.question.QuestionsInfoBean
import de.greenrobot.event.EventBus
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.im_new_multi_message_fragment.*
import java.io.BufferedInputStream
import java.io.IOException
import java.io.InputStream
import java.util.concurrent.TimeUnit
/**
......@@ -329,76 +323,15 @@ class NewMultiMessageFragment : BaseFragment() {
*/
private fun initKefu() {
ll_kefu.setOnClickListener {
// if (ImIn.isLogin()) {
// SessionHelper.startP2PSession(context, -1, ImConstants.KEFUXIAOYI, null,
// P2PCustomActionHandlerImpl(ImConstants.KEFUXIAOYI, "客服小壹", ImConstants.KEFUXIAOYI))
// } else {
// ToastUtil.toastShort("请登录后再试")
// }
// TODO: 6/23/21 测试入口
var collectInfoPopupWindow = activity?.let { it1 ->
CollectInfoPopupWindow(it1, object : OnSendMsgListener {
override fun sendMsg(content: String, result: List<QuestionsInfoBean>) {
}
override fun finishPage() {
activity!!.finish()
}
})
}
var cacheQuestion = String(activity?.let { it1 -> getAssertsFile(it1, "question.json") }!!)
if (cacheQuestion != null) {
var question = Gson().fromJson(cacheQuestion, QuestionsInfoBean::class.java)
collectInfoPopupWindow!!.show(ll_kefu)
collectInfoPopupWindow!!.setData(question)
}
}
}
fun getAssertsFile(context: Context, fileName: String): ByteArray? {
var inputStream: InputStream? = null
val assetManager = context.assets
try {
inputStream = assetManager.open(fileName)
if (inputStream == null) {
return null
}
var bis: BufferedInputStream? = null
val length: Int
try {
bis = BufferedInputStream(inputStream)
length = bis.available()
val data = ByteArray(length)
bis.read(data)
return data
} catch (e: IOException) {
} finally {
if (bis != null) {
try {
bis.close()
} catch (e: Exception) {
}
}
if (ImIn.isLogin()) {
SessionHelper.startP2PSession(context, -1, ImConstants.KEFUXIAOYI, null,
P2PCustomActionHandlerImpl(ImConstants.KEFUXIAOYI, "客服小壹", ImConstants.KEFUXIAOYI)
)
} else {
ToastUtil.toastShort("请登录后再试")
}
return null
} catch (e: IOException) {
e.printStackTrace()
}
return null
}
/**
* 设置页面背景色
*/
......
......@@ -26,7 +26,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.Observer;
import com.netease.nimlib.sdk.RequestCallback;
......@@ -77,7 +76,6 @@ import com.yidianling.uikit.business.session.helper.ChatStatusCacheHelper;
import com.yidianling.uikit.business.session.module.input.InputPanel;
import com.yidianling.uikit.business.session.module.list.MessageListPanelEx;
import com.yidianling.uikit.business.session.view.ChatPrivateTips;
import com.yidianling.uikit.business.session.view.CollectInfoPopupWindow;
import com.yidianling.uikit.business.session.view.CommonQuestionView;
import com.yidianling.uikit.business.session.view.ImCommentBannerView;
import com.yidianling.uikit.business.session.view.ImRedStarGradeView;
......@@ -86,9 +84,7 @@ import com.yidianling.uikit.custom.bridge.IP2PCustomActionHandler;
import com.yidianling.uikit.custom.http.ServiceImpl;
import com.yidianling.uikit.custom.http.response.CommonQuestionBean;
import com.yidianling.uikit.custom.http.response.NewUserMesBean;
import com.yidianling.uikit.custom.http.response.SubmitUserInfoBean;
import com.yidianling.uikit.custom.http.response.UserQuestInfoBean;
import com.yidianling.uikit.custom.http.response.question.QuestionsInfoBean;
import com.yidianling.uikit.custom.widget.ConfideOrderInfoView;
import com.yidianling.uikit.custom.widget.ExpertInfoDialog;
import com.yidianling.uikit.custom.widget.TitleBarBottom;
......@@ -154,7 +150,6 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
private int timeCount = 0;
protected AitManager aitManager;
private CollectInfoPopupWindow collectInfoPopupWindow;
private CircleImageView small_head_img; //小头像
private TextView help_num_tv; //帮助人数
......@@ -290,6 +285,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
private void initView() {
if (ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getUserType() == 3) {
//助理
rl_common_question_enter.setOnClickListener(v -> {
if (commonQuestionBeanList != null && commonQuestionBeanList.size() > 0) {
openOrCloseCommonQuestionLayout(true);
......@@ -304,54 +300,18 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
try {
YdlBuryPointUtil.sendPv("common_question_pager");
} catch (Exception e) {
e.printStackTrace();
}
getCommonQuestionListData();
}
ChatStatusCacheHelper.clearDataByKey("chatEvent");
}
if (ChatStatusCacheHelper.getStatusCache("collectEvent")) {
String time = Calendar.getInstance().get(Calendar.YEAR) + "-" + Calendar.getInstance().get(Calendar.MONTH) + Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
// if (!TextUtils.equals(time, SharedPreferencesEditor.getString("skip_time_" + ImIn.INSTANCE.getUserInfo().getUid()))) {
collectInfoPopupWindow = new CollectInfoPopupWindow(getActivity(), new CollectInfoPopupWindow.OnSendMsgListener() {
@Override
public void sendMsg(@NotNull String content, @NotNull List<? extends QuestionsInfoBean> result) {
if (TextUtils.isEmpty(content)) {//点击跳过后当天不再显示此弹窗
SharedPreferencesEditor.putString("skip_time_" + ImIn.INSTANCE.getUserInfo().getUid()
, time);
} else {
IMMessage textMessage = MessageBuilder.createTextMessage(sessionId, sessionType, content);
if (sendMessage(textMessage)) {
openOrCloseCommonQuestionLayout(false);
}
// submitUserCollect(result);
}
}
@Override
public void finishPage() {
getActivity().finish();
}
});
getUserInfoCollect();
if (!getActivity().isFinishing()) {
try {
YdlBuryPointUtil.sendPv("user_collect_pager");
} catch (Exception e) {
}
collectInfoPopupWindow.show(top_expert_info_cl);
}
// }
ChatStatusCacheHelper.clearDataByKey("collectEvent");
}
}
//有未完成订单或者有未评价订单时,显示订单布局
if (ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getInfo() != null) {
if (ActionHandlerStorage.getL(sessionId).getInfo().hasAvailableListenOrder == 2 || ActionHandlerStorage.getL(sessionId).getInfo().listenOrderCommentStatus == 1) {
//2专家 1用户
ConfideOrderInfoView confideOrderInfoView = new ConfideOrderInfoView(getContext(), sessionId);
confideOrderInfoView.setData(ActionHandlerStorage.getL(sessionId).getInfo());
rl_contain.addView(confideOrderInfoView);
......@@ -1405,46 +1365,6 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
});
}
@SuppressLint("CheckResult")
private void getUserInfoCollect() {
ServiceImpl.Companion.getInstance().preExamQuestionPaper()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(resp -> {
if (resp.data != null ) {
ServiceImpl.Companion.getInstance().getNewUserMes(new NewUserMesBean(""))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(hasCollectedInResp -> {
if (hasCollectedInResp.data != null && hasCollectedInResp.data.size() > 0) {
collectInfoPopupWindow.setData(resp.data);
} else {
collectInfoPopupWindow.setData(resp.data);
}
}, throwable -> {
collectInfoPopupWindow.setData(resp.data);
});
} else {
collectInfoPopupWindow.dismiss();
}
}, throwable -> {
collectInfoPopupWindow.dismiss();
});
}
@SuppressLint("CheckResult")
private void submitUserCollect(List<UserQuestInfoBean> result) {
SubmitUserInfoBean submitUserInfoBean = new SubmitUserInfoBean();
submitUserInfoBean.userInfoList = result;
ServiceImpl.Companion.getInstance().submitUserCollect(JSON.toJSONString(submitUserInfoBean))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(resp -> {
}, throwable -> {
});
}
private void showCheckAgeDialog() {
CommonDialog.create(getActivity())
.setLeftOnclick("返回", v -> {
......
package com.yidianling.uikit.business.session.view
import android.app.Activity
import android.content.Context
import android.graphics.drawable.BitmapDrawable
import android.os.Build
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.ViewGroup
import android.widget.PopupWindow
import androidx.annotation.RequiresApi
import com.yidianling.common.tools.ToastUtil
import com.yidianling.uikit.custom.http.response.question.QuestionsInfoBean
/**
* @author jiucheng
* @描述: 前置信息收集
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/12/10
*/
class CollectInfoPopupWindow(var mContext: Activity, var listener: OnSendMsgListener) :
PopupWindow(mContext) {
private var collectUserInformationView: QuestionInformationView
private var isFromBack = true
init {
height = ViewGroup.LayoutParams.MATCH_PARENT
width = ViewGroup.LayoutParams.MATCH_PARENT
setBackgroundDrawable(BitmapDrawable())
collectUserInformationView = QuestionInformationView(mContext, {
listener.sendMsg("", ArrayList())
isFromBack = false
dismiss()
}, {
dismiss()
listener.finishPage()
}, { _content, _list ->
listener.sendMsg(_content, _list)
isFromBack = false
dismiss()
})
collectUserInformationView.isFocusableInTouchMode = true
collectUserInformationView.setOnKeyListener { v, keyCode, event ->
if (keyCode == KeyEvent.KEYCODE_BACK) {
showSkipDialog()
true
}
false
}
contentView = collectUserInformationView
isFocusable = true
isTouchable = true
isOutsideTouchable = false
}
fun setData(questionInfo: QuestionsInfoBean) {
collectUserInformationView.setData(questionInfo)
}
override fun dismiss() {
if (isFromBack) {
showSkipDialog()
isFromBack = false
} else {
super.dismiss()
}
}
private fun showSkipDialog() {
collectUserInformationView.showSkipDialog()
}
fun show(v: View) {
v.post { showAtLocation(v, Gravity.BOTTOM, 0, 0) }
}
interface OnSendMsgListener {
fun sendMsg(content: String, result: List<QuestionsInfoBean>)
fun finishPage()
}
}
\ No newline at end of file
......@@ -147,7 +147,7 @@ class ServiceImpl private constructor() {
}
/**
* 创建答题信息
* 回答问题
*/
fun answerQuestion(id: String, params: String): Observable<BaseAPIResponse<String>> {
val body = RequestBody.create(
......
package com.yidianling.uikit.custom.http.response.question;
import com.yidianling.uikit.custom.http.response.question.RelatesBean;
import java.util.List;
......
package com.yidianling.uikit.custom.http.response.question;
/**
* @author liupeng
* <p>
* 测试前置-回答消息(区分其他类型与主诉类型)
* 用户APP -》灵犀
* type 70
* <p>
* 地址 https://note.youdao.com/ynoteshare1/index.html?id=ac018cb5b65b7d5fc5e961410b14621a&type=note
*/
public class AnswerQuestionType70RequestBean {
public String type = "70";
public AnswerQuestionRequestBean data;
}
......@@ -2,6 +2,11 @@ package com.yidianling.uikit.custom.http.response.question;
import java.util.List;
/**
* 题库信息
*
* @author liupeng
*/
public class QuestionsInfoBean {
......
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:parentTag="android.widget.LinearLayout">
android:orientation="vertical">
<RelativeLayout
......@@ -44,10 +43,9 @@
android:text="跳过"
android:textColor="@color/im_color_grey_999999"
android:textSize="14sp" />
</RelativeLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -58,9 +56,9 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/color_f8f8f8"
android:paddingBottom="12dp"
app:layout_constraintBottom_toTopOf="@id/cl_input"
app:layout_constraintTop_toTopOf="parent"
android:paddingBottom="12dp"
app:layout_constraintVertical_weight="1" />
<androidx.constraintlayout.widget.ConstraintLayout
......@@ -69,31 +67,31 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent">
app:layout_constraintBottom_toBottomOf="parent"
tools:visibility="visible">
<TextView
android:id="@+id/tv_problem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_f8f8f8"
android:paddingStart="12dp"
android:paddingBottom="13dp"
android:textColor="@color/color_242424"
android:textSize="14sp"
android:visibility="gone"
android:background="@color/color_f8f8f8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible"
tools:text="已选:" />
tools:text="已选:"
tools:visibility="visible" />
<EditText
android:id="@+id/et_input_problem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:gravity="top"
android:hint="请简单描述遇到的问题......"
android:background="@color/white"
android:maxHeight="200dp"
android:padding="12dp"
android:textColor="@color/color_242424"
......@@ -199,12 +197,11 @@
android:text="去沟通"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone"
tools:visibility="gone"
/>
app:layout_constraintBottom_toBottomOf="parent"
tools:visibility="gone" />
</androidx.constraintlayout.widget.ConstraintLayout>
</merge>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment