Commit c27adb13 by 刘鹏

feat :分配导医后置,时间判断前置

parent 2dc5f8aa
......@@ -6,7 +6,7 @@ ext {
// -------------- 业务模块 --------------
//第三步 若干
"m-confide" : "0.0.49.09",
"m-consultant" : "0.0.59.79",
"m-consultant" : "0.0.59.89",
"m-fm" : "0.0.30.03",
"m-user" : "0.0.61.37",
"m-home" : "0.0.22.65",
......@@ -28,7 +28,7 @@ ext {
"m-tests-api" : "0.0.2",
"m-user-api" : "0.0.10.17",
"m-home-api" : "0.0.4.2",
"m-im-api" : "0.0.12.22",
"m-im-api" : "0.0.12.23",
"m-dynamic-api" : "0.0.3.71",
//-------------- 功能组件 --------------
......@@ -89,7 +89,7 @@ ext {
//第三步 若干
"m-confide" : "0.0.49.09",
"m-consultant" : "0.0.59.79",
"m-consultant" : "0.0.59.89",
"m-fm" : "0.0.30.01",
"m-user" : "0.0.61.37",
"m-home" : "0.0.22.65",
......@@ -113,7 +113,7 @@ ext {
"m-tests-api" : "0.0.2",
"m-user-api" : "0.0.10.17",
"m-home-api" : "0.0.4.2",
"m-im-api" : "0.0.12.22",
"m-im-api" : "0.0.12.23",
"m-dynamic-api" : "0.0.3.71",
//-------------- 功能组件 --------------
......
......@@ -13,7 +13,6 @@ import com.yidianling.consultant.model.bean.ExpertSearchBean
import com.yidianling.consultant.model.bean.HeadData
import io.reactivex.Observable
import retrofit2.http.*
import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType
/**
......@@ -64,20 +63,6 @@ interface SearchApi {
fun getConsultAssistantRequest(@Query("switchKey") switchKey: String): Observable<BaseAPIResponse<Boolean>>
//获取咨询助理uid
/*
* location字段说明(sign1存储页面位置,1:首页导医入口进入2:M站入口进入3:问答列表页进入4:我的入口进入
* 5:情绪疏导在线咨询入口进入6:咨询列表页导医入口进入7:实用心理课入口进入8:实用心理课课程列表页进入9:测评解读页进入
* 10:搜索页面进入11:首页咨询列表进入12:厌学的真相在线咨询入口,0是小壹意向客户传0)
*
* ffrom_2 亲子教育添加字段
*naviType = "1";导医配置开关,返100跳转咨询tab,如果返其他则维持原有逻辑。
* */
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "Content-Type:application/json")
@GET("consult/assistant/chat-distribute")
fun getConsultAssistantUidRequest(@Query("location")location: Int,@Query("ffrom_2")ffrom:String?,@Query("naviType")naviType:String="1"): Observable<BaseAPIResponse<Long>>
//获取咨询助理uid
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "Content-Type:application/json")
@POST("doctor/querySpecialTopic")
fun getBigShotData(): Observable<BaseAPIResponse<ExpertSearchTopShowBean>>
......@@ -94,4 +79,16 @@ interface SearchApi {
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "Content-Type:application/json")
@GET("consult/assistant/chat-time-setting")
fun getJumpTypeRequest(): Observable<BaseAPIResponse<Int>>
/**
* 100 有配置接口
* */
@GET("consult/assistant/chat-route-config")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA,"Content-Type:application/json")
fun getChatRouteConfig(
@Query("location") location: Int,
@Query("naviType") naviType: String = "1"
): Observable<BaseAPIResponse<Long>>
}
\ No newline at end of file
......@@ -3,13 +3,12 @@ package com.yidianling.consultant.modular.singlton
import android.annotation.SuppressLint
import android.app.Activity
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.utils.YdlBuryPointUtil
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil
import com.ydl.ydlnet.YDLHttpUtils.Companion.obtainApi
import com.yidianling.consultant.ConsultAssistantCenterActivity
import com.yidianling.consultant.ExpertSearchActivity
import com.yidianling.consultant.constants.ConsultBIConstants
......@@ -29,8 +28,8 @@ class ConsultAssistantDialogUtils private constructor() {
companion object {
val INSTANCE by lazy { ConsultAssistantDialogUtils() }
var isSHowDesc=true
var REALATION_EDUCATION=false//是否跳转亲子教育字段,接口加ffrom2="learning"
var isSHowDesc = true
var REALATION_EDUCATION = false//是否跳转亲子教育字段,接口加ffrom2="learning"
}
var consultAssistantDialogFromHomePage: ConsultAssistantDialog? = null // 首页展示的dialog
......@@ -40,9 +39,9 @@ class ConsultAssistantDialogUtils private constructor() {
var consultAssistantActivityDialog: ConsultAssistantDialog? = null //咨询师列表activity页面展示的dialog
var confideListDialog: ConsultAssistantDialog? = null //倾诉列表activity页面展示的dialog
var expertSearchActivityPageHasShown: Boolean = false // 专家咨询列表activity页面是否已经展示
// var ASSISTANT_DIALOG_SP_TAG = "assistant_dialog_sp_tag" // 是否展示左侧文本的缓存key
var minWidth = 0 // 最小宽度
// var ASSISTANT_DIALOG_SP_TAG = "assistant_dialog_sp_tag" // 是否展示左侧文本的缓存key
var minWidth = 0 // 最小宽度
/**
......@@ -60,7 +59,9 @@ class ConsultAssistantDialogUtils private constructor() {
}
}
"doctor_list" -> {
if (!ConsultantIn.isLogin() || (ConsultantIn.getUserImpl().getUserInfo()?.user_type == 1 && ConsultantIn.isLogin())) {
if (!ConsultantIn.isLogin() || (ConsultantIn.getUserImpl()
.getUserInfo()?.user_type == 1 && ConsultantIn.isLogin())
) {
shouldShowDialog(activity, origin, fromActivity = fromActivity)
}
}
......@@ -94,7 +95,7 @@ class ConsultAssistantDialogUtils private constructor() {
if (origin == "home_index") {
showFromYdlHome(activity)
} else if (origin == "doctor_list") {
show(activity, origin,fromActivity)
show(activity, origin, fromActivity)
} else if (origin == "mine_index") {
showFromMine(activity)
}
......@@ -114,11 +115,17 @@ class ConsultAssistantDialogUtils private constructor() {
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
if (Utils.isFastClick()) {
return onClickAction()
}
//获取用户uid
ActionCountUtils.count("main_page|main_daoyi_entry_click")
YdlBuryPointUtil.sendClick("home_page_assistant_click")
ActionCountUtils.count(ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK, "1")
getConsultAssistantUid("",activity,1)
ActionCountUtils.count(
ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK,
"1"
)
getConsultAssistantUid("", activity, 1)
}
})
......@@ -143,17 +150,23 @@ class ConsultAssistantDialogUtils private constructor() {
fun showFromConfideListHome(activity: Activity) {
if (!activity.isFinishing) {
confideListDialog = ConsultAssistantDialog(
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
if (!ConsultantIn.getUserImpl().loginByOneKeyLogin(activity,true)){
return
}
ActionCountUtils.count(ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK, "17")
getConsultAssistantUid("",activity,17)
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
if (Utils.isFastClick()) {
return onClickAction()
}
if (!ConsultantIn.getUserImpl().loginByOneKeyLogin(activity, true)) {
return
}
ActionCountUtils.count(
ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK,
"17"
)
getConsultAssistantUid("", activity, 17)
}
})
})
confideListDialog?.show()
}
}
......@@ -179,9 +192,15 @@ class ConsultAssistantDialogUtils private constructor() {
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
if (Utils.isFastClick()) {
return onClickAction()
}
//获取用户uid
ActionCountUtils.count(ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK, "4")
getConsultAssistantUid("",activity,4)
ActionCountUtils.count(
ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK,
"4"
)
getConsultAssistantUid("", activity, 4)
}
})
......@@ -204,21 +223,21 @@ class ConsultAssistantDialogUtils private constructor() {
/**
* 咨询师列表页展示
*/
fun show(activity: Activity, origin:String,fromActivity: Boolean = false) {
fun show(activity: Activity, origin: String, fromActivity: Boolean = false) {
// 来自于fragment咨询师列表
if (!fromActivity) {
if (!expertSearchPageHasShown) {
expertSearchPageHasShown = true
showDialog(origin,activity)
showDialog(origin, activity)
} else {
showDialog(origin,activity)
showDialog(origin, activity)
}
} else {// 来自于activity咨询师列表
if (!expertSearchActivityPageHasShown) {
expertSearchActivityPageHasShown = true
showDialog(origin,activity, true)
showDialog(origin, activity, true)
} else {
showDialog(origin,activity, true)
showDialog(origin, activity, true)
}
}
}
......@@ -226,7 +245,7 @@ class ConsultAssistantDialogUtils private constructor() {
/**
* 咨询师列表页展示浮层
*/
fun showDialog(origin: String,activity: Activity, fromActivity: Boolean = false) {
fun showDialog(origin: String, activity: Activity, fromActivity: Boolean = false) {
if (!fromActivity) {
if (!activity.isFinishing) {
if (consultAssistantFragmentDialog == null) {
......@@ -234,13 +253,19 @@ class ConsultAssistantDialogUtils private constructor() {
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
ActionCountUtils.count(ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK, "6")
if (Utils.isFastClick()) {
return onClickAction()
}
ActionCountUtils.count(
ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK,
"6"
)
ActionCountUtils.count("app_consult_list_page|app_consult_list_daoyi_entry_click")
YdlBuryPointUtil.sendClick("assistant_list_click")
// 咨询师列表页面且未登录情况下,跳转登录页面
if (ConsultantIn.loginByOneKeyLogin(activity,true)) {
if (ConsultantIn.loginByOneKeyLogin(activity, true)) {
//获取用户uid
getConsultAssistantUid(origin,activity,6)
getConsultAssistantUid(origin, activity, 6)
}
}
......@@ -255,12 +280,15 @@ class ConsultAssistantDialogUtils private constructor() {
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
if (Utils.isFastClick()) {
return onClickAction()
}
ActionCountUtils.count("app_consult_list_page|app_consult_list_daoyi_entry_click")
YdlBuryPointUtil.sendClick("assistant_list_click")
// 咨询师列表页面且未登录情况下,跳转登录页面
if (ConsultantIn.loginByOneKeyLogin(activity,true)) {
if (ConsultantIn.loginByOneKeyLogin(activity, true)) {
//获取用户uid
getConsultAssistantUid(origin,activity,6)
getConsultAssistantUid(origin, activity, 6)
}
}
......@@ -310,7 +338,7 @@ class ConsultAssistantDialogUtils private constructor() {
*/
fun expertSearchResetStatus() {
//页面关闭后重置亲子列表状态
REALATION_EDUCATION=false
REALATION_EDUCATION = false
consultAssistantActivityDialog?.dismiss()
expertSearchActivityPageHasShown = false
......@@ -320,55 +348,63 @@ class ConsultAssistantDialogUtils private constructor() {
////////////////////////////////////// 咨询师列表页面的展示隐藏逻辑 代码块end ///////////////////////////////////////////////////
@SuppressLint("CheckResult")
fun getConsultAssistantUid(origin: String,activity: Activity,location:Int) {
if (origin=="doctor_list"){
fun getConsultAssistantUid(origin: String, activity: Activity, location: Int) {
if (origin == "doctor_list") {
// 请求接口获取咨询助理的uid
if (REALATION_EDUCATION){
getConsultAssistantUid(location, activity,"learning")
}else{
getConsultAssistantUid(location, activity,null)
if (REALATION_EDUCATION) {
getConsultAssistantUid(location, activity, "learning")
} else {
getConsultAssistantUid(location, activity, null)
}
}else{
} else {
// 请求接口获取咨询助理的uid
getConsultAssistantUid(location, activity,null)
getConsultAssistantUid(location, activity, null)
}
ActionCountUtils.count(ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK, location.toString())
ActionCountUtils.count(
ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK,
location.toString()
)
}
@SuppressLint("CheckResult")
private fun getConsultAssistantUid(location: Int, activity: Activity, ffrom:String?) {
SearchApi.getSearchApi().getConsultAssistantUidRequest(location, ffrom)
private fun getConsultAssistantUid(location: Int, activity: Activity, ffrom: String?) {
obtainApi(SearchApi::class.java).getChatRouteConfig(location)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
if (it.data==100L&&(location<=17)){
if (it.data == 100L && (location <= 17)) {
//跳转咨询tab栏目
if (location==1||location==4||location==6||location==3){
if (activity is ExpertSearchActivity &&!activity.isFinishing){
if (location == 1 || location == 4 || location == 6 || location == 3) {
if (activity is ExpertSearchActivity && !activity.isFinishing) {
activity.finish()
}
EventBus.getDefault().post(HomeModuleTabEvent(2))
}else{
if (activity.componentName.toString().contains("CourseListContainerActivity") ){
} else {
if (activity.componentName.toString()
.contains("CourseListContainerActivity")
) {
ActivityManager.getInstance()
.getSecondTaskActivity()?.finish()
activity.finish()
}else{
if (null!=activity&&!activity.isFinishing){
} else {
if (null != activity && !activity.isFinishing) {
activity.finish()
}
}
EventBus.getDefault().post(HomeModuleTabEvent(2))
}
}else{
if (it.code == "200" && it.data != 0.toLong() && null != activity) {
ConsultantIn.startP2PSession(activity as AppCompatActivity, it.data.toString())
} else {
ToastUtil.toastShort("咨询助理忙碌中,请稍后再试")
}
} else if (it.data == 0L) {
//去前置信息收集页
ConsultantIn.startP2PSession(
activity as AppCompatActivity,
location,
ffrom
)
}
if (null != activity && activity is ConsultAssistantCenterActivity && !activity.isFinishing) activity.finish()
}, object : ThrowableConsumer() {
......
......@@ -7,14 +7,13 @@ import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydl_router.manager.YDLRouterParams
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.ActivityManager.Companion.getInstance
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.ConsultAssistantCenterActivity
import com.yidianling.consultant.ExpertSearchActivity
import com.yidianling.consultant.HotSearchActivity
import com.yidianling.consultant.constants.ConsultBIConstants
import com.yidianling.consultant.model.SearchApi
import com.yidianling.consultant.router.ConsultantIn
......@@ -27,15 +26,15 @@ import io.reactivex.schedulers.Schedulers
class ConsultAssistantEntryUtils {
companion object {
@SuppressLint("CheckResult")
fun jumpConsultAssistant(activity: Activity, location: Int,ffrom2:String?) {
fun jumpConsultAssistant(activity: Activity, location: Int, ffrom2: String?) {
ActionCountUtils.count(
ConsultBIConstants.POSITION_DAOYI_ADVERTISEMENT_CLICK,
"$location"
)
if (ConsultantIn.loginByOneKeyLogin(activity,true)) {
if (ConsultantIn.loginByOneKeyLogin(activity, true)) {
// 请求接口获取咨询助理的uid
SearchApi.getSearchApi().getConsultAssistantUidRequest(location,ffrom2)
YDLHttpUtils.obtainApi(SearchApi::class.java).getChatRouteConfig(location)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
......@@ -44,35 +43,35 @@ class ConsultAssistantEntryUtils {
* 7使用心理课进入,8使用心理课列表页进入,9测评解读页进入,10搜索页进入,11注册引导页
* 0小壹点击前往
* */
if (it.data==100L&&(location<=11)){
//跳转咨询tab栏目
if (location==1||location==4||location==6||location==3){
if (activity is ExpertSearchActivity&&!activity.isFinishing){
activity.finish()
}
EventBus.getDefault().post(HomeModuleTabEvent(2))
}else{
if (activity.componentName.toString().contains("CourseListContainerActivity") ){
getInstance()
.getSecondTaskActivity()?.finish()
activity.finish()
}else{
if (null!=activity&&!activity.isFinishing){
if (it.data == 100L && (location <= 11)) {
//跳转咨询tab栏目
if (location == 1 || location == 4 || location == 6 || location == 3) {
if (activity is ExpertSearchActivity && !activity.isFinishing) {
activity.finish()
}
}
EventBus.getDefault().post(HomeModuleTabEvent(2))
}
}else{
if (it.code == "200" && it.data != 0.toLong() && null != activity) {
ConsultantIn.startP2PSession(
activity as AppCompatActivity,
it.data.toString()
)
EventBus.getDefault().post(HomeModuleTabEvent(2))
} else {
ToastUtil.toastShort("咨询助理忙碌中,请稍后再试")
if (activity.componentName.toString()
.contains("CourseListContainerActivity")
) {
getInstance()
.getSecondTaskActivity()?.finish()
activity.finish()
} else {
if (null != activity && !activity.isFinishing) {
activity.finish()
}
}
EventBus.getDefault().post(HomeModuleTabEvent(2))
}
} else if (it.data == 0L) {
//去前置信息收集页
ConsultantIn.startP2PSession(
activity as AppCompatActivity,
location,
ffrom2
)
}
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
......@@ -84,31 +83,34 @@ class ConsultAssistantEntryUtils {
}
/*
* 根据Type0,1跳自主,2跳导医
* 在跳自主的(type=1)情况下,点击item是跳专家详情页
*
* */
/*
* 根据Type0,1跳自主,2跳导医
* 在跳自主的(type=1)情况下,点击item是跳专家详情页
*
* */
@SuppressLint("CheckResult")
fun getTypeJump(activity: Activity, location: Int,doctorUid:Int,url:String?){
fun getTypeJump(activity: Activity, location: Int, doctorUid: Int, url: String?) {
SearchApi.getSearchApi().getJumpTypeRequest()
.subscribeOn((Schedulers.io()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe (Consumer {
when(it.code){
"200"->{
when(it.data){
0->{
.subscribe(Consumer {
when (it.code) {
"200" -> {
when (it.data) {
0 -> {
jumpToAutoTalk(activity, doctorUid)
}
1->{
if (url.isNullOrEmpty()){
1 -> {
if (url.isNullOrEmpty()) {
jumpToAutoTalk(activity, doctorUid)
}else{
} else {
if (url.startsWith("http")) {
YDLRouterManager.router(
IYDLRouterConstant.ROUTER_H5_H5,
YDLRouterParams().putExtra(IYDLRouterConstant.EXTRA_URL, url), ""
YDLRouterParams().putExtra(
IYDLRouterConstant.EXTRA_URL,
url
), ""
)
} else {
YDLRouterManager.router(url)
......@@ -116,20 +118,20 @@ class ConsultAssistantEntryUtils {
}
}
2->{
jumpConsultAssistant(activity,location,null)
2 -> {
jumpConsultAssistant(activity, location, null)
}
else->{
else -> {
jumpToAutoTalk(activity, doctorUid)
LogUtil.e(it.data.toString())
}
}
}
else->{
else -> {
ToastUtil.toastShort(it.code)
}
}
},object:ThrowableConsumer(){
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
}
......
......@@ -2,7 +2,6 @@ package com.yidianling.consultant.router
import android.app.Activity
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.im.api.service.IImService
import com.yidianling.user.api.service.IAppService
......@@ -22,6 +21,7 @@ object ConsultantIn {
fun getAppService(): IAppService {
return ModularServiceManager.provide(IAppService::class.java)
}
fun getUserService(): IUserService {
return ModularServiceManager.provide(IUserService::class.java)
}
......@@ -39,7 +39,14 @@ object ConsultantIn {
getImService().startP2PSession(context, toUid)
}
fun mainIntent(activity: Activity){
/**
* 去前置信息收集页
* */
fun startP2PSession(context: Activity, location: Int, ffrom2: String?) {
getImService().startP2PSession(context, location, ffrom2)
}
fun mainIntent(activity: Activity) {
getAppService().mainIntent(activity)
}
......@@ -48,7 +55,9 @@ object ConsultantIn {
}
fun toLogin(activity: Activity) {
activity.startActivity(ModularServiceManager.provide(IUserService::class.java).loginWayIntent(activity))
activity.startActivity(
ModularServiceManager.provide(IUserService::class.java).loginWayIntent(activity)
)
}
/**
......@@ -56,7 +65,7 @@ object ConsultantIn {
* @param isOpenDialog true:一键登录使用弹窗展示 false:一键登录使用全屏模式
* @return true:已登录,不触发登录跳转,false:未登录,优先一键登录
* */
fun loginByOneKeyLogin(context: Context, isOpenDialog: Boolean) :Boolean{
return getUserService().loginByOneKeyLogin(context,isOpenDialog)
fun loginByOneKeyLogin(context: Context, isOpenDialog: Boolean): Boolean {
return getUserService().loginByOneKeyLogin(context, isOpenDialog)
}
}
\ No newline at end of file
package com.yidianling.im.helper
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.text.TextUtils
import android.view.View
......@@ -17,6 +18,7 @@ import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.ui.LoadingDialogFragment
import com.ydl.ydlcommon.ui.LoadingDialogFragment.Companion.newInstance
import com.ydl.ydlcommon.utils.NetworkParamsUtils
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.UserInfoCache
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
......@@ -49,6 +51,7 @@ import com.yidianling.uikit.custom.http.response.RecommendExpertBean
import com.yidianling.uikit.custom.widget.TitleBarBottom
import com.yidianling.user.api.service.IUserService
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
import retrofit2.HttpException
import java.net.URLEncoder
......@@ -84,6 +87,58 @@ object IMChatUtil {
}
/**
* 跳转前置信息收集页
* */
@SuppressLint("CheckResult")
fun startCms(context: Activity, location: Int, ffrom2: String?) {
ImRetrofitApi.Companion.getImRetrofitApi()
.getSystemConfigByKeyword("lx_collect_card_config")
.compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
val skipTime = it.value1.toLong()
if (isJumpToIm(skipTime)) {
// 请求接口获取咨询助理的uid
getImJavaApi().getConsultAssistantUidRequest(location, ffrom2)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { uidBean ->
/*
* location=1首页,3问答列表页,4我的入口,5亲子在线咨询入口,6咨询列表页导医入口,
* 7使用心理课进入,8使用心理课列表页进入,9测评解读页进入,10搜索页进入,11注册引导页
* 0小壹点击前往
* */
if (uidBean.code == "200" && uidBean.data != 0.toLong()) {
startChat(context as AppCompatActivity, uidBean.data.toString(), 0)
} else {
ToastUtil.toastShort("咨询助理忙碌中,请稍后再试")
}
}
} else {
//没有时间限制,跳转到前置信息收集
CmsExamQuestionPaperActivity.start(context, location, ffrom2)
}
}
}
/***
* 判断今天是否展示过
* */
private fun isJumpToIm(skip_time: Long): Boolean {
val time = System.currentTimeMillis()
val skipTime = SharedPreferencesEditor.getString("skip_time_")
if (skipTime == null || skipTime.isEmpty()) {
return false
}
val timeDifference = (time - skipTime.toLong()) / 1000
return timeDifference < skip_time
}
/**
* 私聊列表进入,后置数据请求
*
* @param context
......@@ -107,7 +162,11 @@ object IMChatUtil {
.subscribe({ res: BaseResponse<UserTypeBean> ->
if (res.code == 200 && res.data != null) {
if (res.data!!.collectEvent &&TextUtils.equals(res.data!!.userType, USER_TYPE_ASSISTANT.toString())) {
if (res.data!!.collectEvent && TextUtils.equals(
res.data!!.userType,
USER_TYPE_ASSISTANT.toString()
)
) {
//和助理私聊需要打开信息采集弹窗
prepareAssistantChatData(
context,
......@@ -119,11 +178,12 @@ object IMChatUtil {
.compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe{
.subscribe {
CmsExamQuestionPaperActivity.start(
context, chatItemBean.toUid.toString(), expertInfo,
0, it.value1)
0, it.value1
)
}
}
})
......@@ -218,30 +278,12 @@ object IMChatUtil {
}) { t: Throwable? ->
handleError(context, t!!)
}
} else if (TextUtils.equals(res.data!!.userType, USER_TYPE_ASSISTANT.toString())) {//助理
prepareAssistantChatData(context, toUid, object : ChatDataRequestListener {
override fun onSuccess(expertInfo: IMExpertBuild) { //新前置信息收集入口
ImRetrofitApi.Companion.getImRetrofitApi()
.getSystemConfigByKeyword("lx_collect_card_config")
.compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe{
CmsExamQuestionPaperActivity.start(
context, toUid, expertInfo,
isFromQingShu, it.value1
)
}
}
})
} else {
prepareAssistantChatData(context, toUid, object : ChatDataRequestListener {
override fun onSuccess(expertInfo: IMExpertBuild) {
startChatSession(toUid, expertInfo, isFromQingShu, context)
}
})
}
} else {
if (loadingDialog != null && loadingDialog!!.isVisible) {
......@@ -254,7 +296,8 @@ object IMChatUtil {
loadingDialog?.dismissAllowingStateLoss()
}
handleError(context, throwable!!)
})
}
)
}
......
......@@ -135,4 +135,22 @@ interface ImRetrofitApi {
@GET("systemconfig/getSystemConfigByKeyword")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getSystemConfigByKeyword( @Query("keyword") keyword: String): Observable<BaseAPIResponse<SystemConfigByKeywordBean>>
//获取咨询助理uid
/*
* location字段说明(sign1存储页面位置,1:首页导医入口进入2:M站入口进入3:问答列表页进入4:我的入口进入
* 5:情绪疏导在线咨询入口进入6:咨询列表页导医入口进入7:实用心理课入口进入8:实用心理课课程列表页进入9:测评解读页进入
* 10:搜索页面进入11:首页咨询列表进入12:厌学的真相在线咨询入口,0是小壹意向客户传0)
*
* ffrom_2 亲子教育添加字段
*naviType = "1";导医配置开关,返100跳转咨询tab,如果返其他则维持原有逻辑。
* */
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "Content-Type:application/json")
@GET("consult/assistant/chat-distribute")
fun getConsultAssistantUidRequest(
@Query("location") location: Int,
@Query("ffrom_2") ffrom: String?,
@Query("naviType") naviType: String = "1"
): Observable<BaseAPIResponse<Long>>
}
\ No newline at end of file
......@@ -39,6 +39,7 @@ import com.yidianling.im.session.SessionHelper
import com.yidianling.im.session.extension.CustomAttachModifyTime
import com.yidianling.im.session.extension.CustomAttachSubScriptTime
import com.yidianling.im.session.extension.CustomAttachmentTest
import com.yidianling.im.ui.activity.CmsExamQuestionPaperActivity
import com.yidianling.im.ui.page.NewMultiMessageFragment
import com.yidianling.nimbase.common.media.picker.PickImageHelper
import com.yidianling.uikit.api.NimUIKit
......@@ -65,6 +66,10 @@ class IMServiceImpl : IImService {
IMChatUtil.startChat(context as AppCompatActivity, toUid, 0)
}
override fun startP2PSession(context: Activity, location: Int, ffrom2: String?) {
IMChatUtil.startCms(context,location,ffrom2)
}
override fun startP2PXiaoYi(context: Context) {
if (!ImIn.loginByOneKeyLogin(context,true)) {
return
......
......@@ -19,9 +19,11 @@ import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.R
import com.yidianling.im.api.bean.IMExpertBuild
import com.yidianling.im.helper.IMChatUtil
import com.yidianling.im.http.ImRetrofitApi
import com.yidianling.im.router.ImIn
import com.yidianling.listener.SoftKeyBoardListener
import com.yidianling.uikit.business.session.view.question.QuestionAdapter
......@@ -78,10 +80,13 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
companion object {
private lateinit var expertInfo: IMExpertBuild
private lateinit var toUid: String
private var toUid: String? = null
private var isFromQingShu: Int = 0
private var skip_time: Long = 0
private var location: Int = 0
private var ffrom2: String? = null
@JvmStatic
fun start(
context: Context, toUid: String, expertInfo: IMExpertBuild,
......@@ -94,6 +99,14 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
this.skip_time = skip_time.toLong()
context.startActivity(starter)
}
@JvmStatic
fun start(context: Context, location: Int, ffrom2: String?) {
val starter = Intent(context, CmsExamQuestionPaperActivity::class.java)
this.location = location
this.ffrom2 = ffrom2
context.startActivity(starter)
}
}
override fun layoutResId(): Int {
......@@ -103,11 +116,6 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
override fun initDataAndEvent() {
mType70RequestList.clear()
mType71RequestList.clear()
if (isJumpToIm()) {
//如果今天答过题,跳转到聊天界面
skipToIm()
return
}
//初始化
initRecycle()
//设置view事件
......@@ -132,7 +140,14 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
mQuestionAdapter.setOneCheckListener(object : QuestionOneCheckListener {
override fun itemClick(list: List<OptionsBean>, question: QuestionsBean) {
answerItemClick(list, question, "")
var otherInput = ""
list.forEachIndexed { index, optionsBean ->
if ("其他" == optionsBean.name) {
otherInput = et_input_problem.text.toString()
}
}
answerItemClick(list, question, otherInput)
hideInputAndKeyboark()
}
override fun showOtherEdit(list: List<OptionsBean>, question: QuestionsBean) {
......@@ -165,15 +180,28 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
override fun hideOtherEdit() {
//隐藏其他软键盘
et_input_problem.setText("")
cl_input.visibility = LinearLayout.GONE
hideInputMethod(et_input_problem)
hideInputAndKeyboark()
}
override fun zsItemClick(answer: String, postion: Int) {
//主诉
addType71Request(answer)
mackType2(answer)
override fun zsItemClick(
list: List<OptionsBean>,
question: QuestionsBean,
postion: Int
) {
var otherInput = ""
list.forEachIndexed { index, optionsBean ->
if ("其他" == optionsBean.name) {
otherInput = et_input_problem.text.toString()
}
}
//发送回答问题信息
sendAnswerText(list, otherInput)
//回答问题参数创建
val answerQuestionRequestBean = answerQuestionRequestBean(question, list, "")
//灵犀消息 参数创建
addType70Request(answerQuestionRequestBean)
makeType6(postion + 1)
}
......@@ -225,9 +253,10 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
//最后一题 点击发送
lastAnswer = et_input_problem.text.toString()
addType71Request(et_input_problem.text.toString())
tv_finish.visibility = View.VISIBLE
mackType2(lastAnswer)
setFirstAndLatQuestion("我们根据您的情况安排了一位高级咨询顾问,帮助您匹配最合适的咨询服务,点击按钮现在去沟通~")
//滑动到底部
recycle.scrollToPosition(mData.size - 1)
mData.forEachIndexed { index, _ ->
......@@ -243,11 +272,7 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
)
}
}
et_input_problem.setText("")
hideInputMethod(et_input_problem)
//隐藏输入框
cl_input.visibility = LinearLayout.GONE
hideInputAndKeyboark()
}
tv_cur_problem.setOnClickListener {
problemContent = et_input_problem.text.toString()
......@@ -328,6 +353,13 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
}
}
private fun hideInputAndKeyboark() {
et_input_problem.setText("")
hideInputMethod(et_input_problem)
//隐藏输入框
cl_input.visibility = LinearLayout.GONE
}
/**
* 回答问题
......@@ -429,9 +461,9 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
//设置数据,清空list数据
mData.clear()
//取到问候语
getFirstQuestion()
setFirstAndLatQuestion("你好,为了更好的帮助您我们需要了解些基本信息,我们将会严格保护你的隐私安全,请放心。")
//取出第二条消息
if (resp.data.questions.size > 0) {
if (resp.data.questionPaper != null) {
haveLingxiQuestion = true
setSecondQuestionByLx()
createExams()
......@@ -442,18 +474,16 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
} else {
//无答题数据,跳转到聊天界面
IMChatUtil.startChatSessionByCms(
toUid, expertInfo, isFromQingShu, this@CmsExamQuestionPaperActivity
)
jumpToIm()
}
}, {
//接口请求报错,跳转到聊天页面
IMChatUtil.startChatSessionByCms(
toUid, expertInfo, isFromQingShu, this@CmsExamQuestionPaperActivity
)
jumpToIm()
})
}
@SuppressLint("CheckResult")
private fun createExams() {
val createExamsRequestBean =
......@@ -482,9 +512,9 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
/***
* 取到问候语
* */
private fun getFirstQuestion() {
private fun setFirstAndLatQuestion(str: String) {
val questionMultiItem = QuestionMultiItem()
questionMultiItem.type1Text = "你好,为了更好的帮助您我们需要了解些基本信息,我们将会严格保护你的隐私安全,请放心。"
questionMultiItem.type1Text = str
questionMultiItem.viewType = 1
mData.add(questionMultiItem)
mQuestionAdapter.notifyDataSetChanged()
......@@ -510,10 +540,13 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
private fun sendAnswerText(list: List<OptionsBean>, otherInput: String) {
var answerStr = ""
list.forEach {
answerStr = "$answerStr#${it.name}"
answerStr = "$answerStr#${it.name} "
}
if (otherInput.isNotEmpty()) {
answerStr = "$answerStr \n \n otherInput"
answerStr = "$answerStr \n \n $otherInput"
}
if (!answerStr.contains("其他")) {
answerStr = answerStr.substring(1).replace("#", "、")
}
mackType2(answerStr)
......@@ -566,7 +599,6 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
//最后一提,
noMore = true
//显示输入框
cl_input.visibility = LinearLayout.VISIBLE
tv_problem.visibility = LinearLayout.GONE
......@@ -643,7 +675,9 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
type70RequestBean.data = answerQuestionRequestBean
type70RequestBean.fromUid = ImIn.getUserInfo()?.uid
type70RequestBean.toUid = toUid
toUid.let {
type70RequestBean.toUid = toUid
}
//添加回答数据到
mType70RequestList.add(type70RequestBean)
......@@ -658,30 +692,13 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
dataBean.answer = answer
answerQuestionType71RequestBean.data = dataBean
answerQuestionType71RequestBean.toUid = toUid
toUid.let {
answerQuestionType71RequestBean.toUid = toUid
}
answerQuestionType71RequestBean.fromUid = ImIn.getUserInfo()?.uid
mType71RequestList.add(answerQuestionType71RequestBean)
}
/***
* 判断今天是否展示过
* */
private fun isJumpToIm(): Boolean {
val time = System.currentTimeMillis()
val skipTime = SharedPreferencesEditor.getString("skip_time_")
if (skipTime == null || skipTime.isEmpty()) {
return false
}
val timeDifference = (time - skipTime.toLong()) / 1000
val second = 1000
val minute = second * 60
val hour = minute * 60
val day = hour * 24
return timeDifference < skip_time
}
/**
* 跳过填写dialog
* */
......@@ -706,29 +723,111 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
/**
* 跳过,直接取IM界面
* */
@SuppressLint("CheckResult")
private fun skipToIm() {
SharedPreferencesEditor.putString("skip_time_", System.currentTimeMillis().toString())
mType70RequestList.forEach {
instance.lingxiAnswerQuestion(JSON.toJSONString(it))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
}
mType71RequestList.forEach {
instance.lingxiAnswerQuestion(JSON.toJSONString(it))
if (toUid != null) {
//代表是聊天列表进来的
mType70RequestList.forEach {
instance.lingxiAnswerQuestion(JSON.toJSONString(it))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
}
mType71RequestList.forEach {
instance.lingxiAnswerQuestion(JSON.toJSONString(it))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
}
IMChatUtil.startChatSessionByCms(
toUid!!, expertInfo, isFromQingShu, this@CmsExamQuestionPaperActivity
)
Handler().postDelayed({
finish()
}, 1000L)
} else {
//代表是导医进来的 导医进来的需要获取导医后再发送消息
ImRetrofitApi.getImJavaApi()
.getConsultAssistantUidRequest(location, ffrom2)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
}
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ uidBean ->
if (uidBean.code == "200" && uidBean.data != 0.toLong()) {
mType70RequestList.forEach {
it.toUid = uidBean.data.toString()
instance.lingxiAnswerQuestion(JSON.toJSONString(it))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
}
mType71RequestList.forEach {
it.toUid = uidBean.data.toString()
instance.lingxiAnswerQuestion(JSON.toJSONString(it))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
}
IMChatUtil.startChat(
this@CmsExamQuestionPaperActivity,
uidBean.data.toString(),
0
)
Handler().postDelayed({
finish()
}, 1000L)
} else {
ToastUtil.toastShort("咨询助理忙碌中,请稍后再试")
}
}, {
ToastUtil.toastShort("咨询助理忙碌中,请稍后再试")
})
IMChatUtil.startChatSessionByCms(
toUid, expertInfo, isFromQingShu, this@CmsExamQuestionPaperActivity
)
finish()
}
}
/**
* 导医进来的跳转到咨询
* */
@SuppressLint("CheckResult")
private fun jumpToIm() {
if (toUid != null) {
IMChatUtil.startChatSessionByCms(
toUid!!, expertInfo, isFromQingShu, this@CmsExamQuestionPaperActivity
)
} else {
ImRetrofitApi.getImJavaApi()
.getConsultAssistantUidRequest(location, ffrom2)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ uidBean ->
if (uidBean.code == "200" && uidBean.data != 0.toLong()) {
IMChatUtil.startChat(
this@CmsExamQuestionPaperActivity,
uidBean.data.toString(),
0
)
finish()
} else {
ToastUtil.toastShort("咨询助理忙碌中,请稍后再试")
finish()
}
}, {
ToastUtil.toastShort("咨询助理忙碌中,请稍后再试")
finish()
})
}
}
// 隐藏键盘布局
private fun hideInputMethod(et: EditText) {
......
......@@ -123,7 +123,7 @@ public class QuestionAdapter extends BaseMultiItemQuickAdapter<QuestionMultiItem
}
oneCheckAdapter.getData().get(position).check = true;
oneCheckAdapter.notifyDataSetChanged();
mOneCheckListener.zsItemClick(data.get(position).name, item.type6Position);
mOneCheckListener.zsItemClick(getCheckOptionsBeans(oneCheckAdapter),item.questionsBean, item.type6Position);
}
});
}
......
......@@ -26,5 +26,5 @@ interface QuestionOneCheckListener {
/**
* 主诉单选点击 多选确定按钮点击获取item信息
*/
fun zsItemClick(answer: String, postion: Int)
fun zsItemClick(list: List<OptionsBean>,question: QuestionsBean, postion: Int)
}
\ No newline at end of file
......@@ -5,11 +5,7 @@ import android.app.Application
import android.content.Context
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.template.IProvider
import com.yidianling.im.api.bean.IMInitConfigBean
import com.yidianling.im.api.bean.IMLoginInfo
import com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
import com.yidianling.im.api.bean.IMRequestCallback
import com.yidianling.im.api.bean.IMSendCustomNotificationResultCallBack
import com.yidianling.im.api.bean.*
import com.yidianling.im.api.listener.ApiStringResponseCallback
/**
......@@ -25,6 +21,9 @@ interface IImService : IProvider {
// 打开私聊界面
fun startP2PSession(context: Activity, toUid: String)
// 打开信息前置收集页
fun startP2PSession(context: Activity, location: Int, ffrom2: String?)
fun setAccount(account: String)
fun setChattingAccountAll()
......@@ -43,6 +42,7 @@ interface IImService : IProvider {
fun logout()
fun clear()
/**
* 创建一条普通文本消息
* @param sessionId 聊天对象ID
......@@ -50,17 +50,37 @@ interface IImService : IProvider {
*/
fun createTextMessage(sessionId: String?, content: String, callback: IMRequestCallback<Void>)
fun sendSubscriptionTimeMessage(sessionId: String?, content: String, callback: IMRequestCallback<Void>)
fun sendSubscriptionTimeMessage(
sessionId: String?,
content: String,
callback: IMRequestCallback<Void>
)
fun showSelector(activity: Activity, requestCode: Int)
fun sendTestResultMessage(uid: String, content: String, title: String?, head: String?, url: String?, id: Int, share_url: String?, callback: IMRequestCallback<Void>)
fun sendTestResultMessage(
uid: String,
content: String,
title: String?,
head: String?,
url: String?,
id: Int,
share_url: String?,
callback: IMRequestCallback<Void>
)
fun startChat(context: Activity, toUid: String, flag: Int, canTalk: Int)
fun startChat(context : Activity ,toUid : String ,flag : Int , canTalk : Int, isFramQingsu: Int, isFromMessageList: Boolean)
fun startChat(
context: Activity,
toUid: String,
flag: Int,
canTalk: Int,
isFramQingsu: Int,
isFromMessageList: Boolean
)
fun startChatCloseReplaceChat(context : Activity ,toUid : String)
fun startChatCloseReplaceChat(context: Activity, toUid: String)
/**
......@@ -77,7 +97,11 @@ interface IImService : IProvider {
/**
* 发送自定义通知
*/
fun sendCustomNotification(toUid: String, content: String, callback: IMSendCustomNotificationResultCallBack)
fun sendCustomNotification(
toUid: String,
content: String,
callback: IMSendCustomNotificationResultCallBack
)
/**
* 注册自定通知接收器
......@@ -112,7 +136,14 @@ interface IImService : IProvider {
fun startKefuChat(context: Context, toUid: String, flag: Int, canTalk: Int)
//
fun startP2PSession(mContext: Context, userType: Int, account: String, toChatUsername: String, toName: String, head: String)
fun startP2PSession(
mContext: Context,
userType: Int,
account: String,
toChatUsername: String,
toName: String,
head: String
)
fun updateUserHead(head: String?)
......@@ -136,11 +167,18 @@ interface IImService : IProvider {
fun getChatUid(context: Context?, uid: String, callback: ApiStringResponseCallback)
fun chatScheule(context: Activity, userUrl: String, docUrl: String, dsmId: Int, title: String, toUid: Int)
fun chatScheule(
context: Activity,
userUrl: String,
docUrl: String,
dsmId: Int,
title: String,
toUid: Int
)
fun initIm(app: Application, activity: Class<out Activity>)
fun initIm(app: Application, activity: Class<out Activity>,imInitBean: IMInitConfigBean)
fun initIm(app: Application, activity: Class<out Activity>, imInitBean: IMInitConfigBean)
fun isWifiOr3G(activity: Activity): Boolean
}
\ 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