Commit 4779cea0 by 徐健

私聊改造項目完成

parent 31b740d3
......@@ -529,7 +529,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
//关注
@SuppressLint("CheckResult")
private void focus() {
if (ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getInfo() != null)
if (ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getInfo() != null) {
// 未关注才能进行关注
if (ActionHandlerStorage.getL(sessionId).getInfo().isFollowed == false) {
ActionHandlerStorage.getL(sessionId).getInfo().isFollowed = true;
......@@ -551,7 +551,9 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}
}, throwable -> {
ActionHandlerStorage.getL(sessionId).getInfo().isFollowed = false;
ToastUtil.toastShort(throwable.toString());});
ToastUtil.toastShort(throwable.toString());
});
}
}
}
......@@ -560,18 +562,30 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}
//初始化聊天顶部快捷菜单
@SuppressLint("CheckResult")
private void initMenu() {
View rela_zixun = rootView.findViewById(R.id.rela_zixun);
rela_zixun.setOnClickListener(view -> {
if (ActionHandlerStorage.getL(sessionId) != null) {
if (sessionId!= null && ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getInfo() != null) {
if (expertConsultServiceListDialog == null) {
if (getActivity() != null) {
expertConsultServiceListDialog = new ExpertConsultServiceListDialog(getActivity());
ServiceImpl.Companion.getInstance().serviceList(ActionHandlerStorage.getL(sessionId).getInfo().doctorId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(res -> {
if (res.data != null && res.data.size() > 0) {
if (getActivity() != null && expertConsultServiceListDialog == null) {
expertConsultServiceListDialog = new ExpertConsultServiceListDialog(getActivity(), res.data);
expertConsultServiceListDialog.show();
}
}else {
ToastUtil.toastShort("咨询师暂未发布服务");
}
}, throwable -> {
});
}else {
expertConsultServiceListDialog.show();
}
} else {
ToastUtil.toastShort("请退出聊天重试");
}
......
......@@ -54,4 +54,9 @@ interface ServiceApi{
@FormUrlEncoded
@POST("sq-active/focus")
fun focus(@FieldMap params: Map<String, String>): Observable<BaseResponse<FocusBean>>
//服务列表
@GET("consult/expert-page/products")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun serviceList(@Query("doctorId") doctorId: String): Observable<BaseAPIResponse<List<ServiceItemBean>>>
}
\ No newline at end of file
......@@ -76,4 +76,11 @@ class ServiceImpl private constructor(){
return RxUtils.mapObservable(param)
.flatMap { YDLHttpUtils.obtainApi(ServiceApi::class.java).focus(it) }
}
/**
* 服务列表
*/
fun serviceList(doctorId: String): Observable<BaseAPIResponse<List<ServiceItemBean>>> {
return YDLHttpUtils.obtainApi(ServiceApi::class.java).serviceList(doctorId)
}
}
\ No newline at end of file
package com.yidianling.uikit.custom.widget.expertConsultService.callback
import com.yidianling.uikit.custom.http.response.ServiceItemBean
interface ConsultServiceViewCallback {
fun onCloseClick() {}//关闭按钮点击
fun onBackClick() {}//返回列表点击
fun onItemClick(serviceId: Int) {} //服务列表点击
fun onItemClick(serviceId: ServiceItemBean.ProductsBean) {} //服务列表点击
}
\ No newline at end of file
......@@ -5,8 +5,14 @@ import android.util.AttributeSet
import android.view.View
import android.widget.LinearLayout
import android.widget.RelativeLayout
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.config.GlobalConfig
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.bean.GlobalInfo
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.im.R
import com.yidianling.uikit.custom.http.response.ServiceItemBean
import com.yidianling.uikit.custom.widget.expertConsultService.callback.ConsultServiceViewCallback
import kotlinx.android.synthetic.main.im_expert_consult_service_detail_view.view.*
......@@ -45,7 +51,89 @@ class ExpertConsultServiceDetailView : RelativeLayout {
/**
* 设置数据
*/
fun setData(bean: String) {
fun updateData(bean: ServiceItemBean.ProductsBean) {
consult_service_title.text = bean.productDto.name ?: ""
consult_service_desc.text = bean.productDto.desc ?: ""
//是否是套餐
if (bean.productDto.isPackage == 2) {
consult_service_is_package.text = "套餐"
consult_service_times.text = "${bean.productDto.packageNum}次"
consult_service_price_right.text = "/${bean.productSpecDtos.last().spec2}分钟" //例: 套餐展示"/60分钟"
//起售次数展示
consult_service_low_buy_time.visibility = View.VISIBLE
consult_service_low_buy_time.text = "(${bean.productDto.packageNum}次起售)"
} else {
consult_service_is_package.text = "单次"
consult_service_times.text = "1次"
consult_service_price_right.text = "/次"//例: 不是套餐展示"/次"
consult_service_low_buy_time.visibility = View.GONE
}
//可选时间类型
var timeStr = StringBuffer("")
var timeList: ArrayList<String> = ArrayList()
bean.productSpecDtos.forEach {
timeList.add(it.spec2)
}
//去重并按规则拼接
timeList.distinct().forEachIndexed { index, str ->
if (index == 0) {
timeStr.append("${str}分钟")
} else {
timeStr.append("/${str}分钟")
}
}
consult_service_once_time_type.text = timeStr.toString()
//可选服务类型
var serviceTypeStr = StringBuffer("")
var serviceTypeList: ArrayList<String> = ArrayList()
bean.productSpecDtos.forEach {
serviceTypeList.add(it.spec1)
}
//去重并按规则拼接
serviceTypeList.distinct().forEachIndexed { index, str ->
val typeStr = getServiceType(str)
if (typeStr != "未知") {
if (index == 0) {
serviceTypeStr.append("$typeStr")
} else {
serviceTypeStr.append("/$typeStr")
}
}
}
consult_service_service_type.text = serviceTypeStr.toString()
//价格,取productSpecDtos数组最后一个价格,不保留小数
consult_service_service_price.text = String.format(
"%.0f",
(bean.productSpecDtos.last().price)
)
consult_service_btn.setOnClickListener {
NewH5Activity.start(mContext, H5Params(HttpConfig.MH5_URL + "consult/#/pages/DownOrder/DownOrder?product_id=" + bean.productDto.id, null))
}
}
private fun getServiceType(index: String): String {
return when (index) {
"1" -> {
"文字"
}
"2" -> {
"电话"
}
"3" -> {
"当面"
}
"4" -> {
"视频"
}
else -> {
"未知"
}
}
}
}
\ No newline at end of file
package com.yidianling.uikit.custom.widget.expertConsultService.view
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.LinearLayout
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.config.HttpConfig
import com.yidianling.im.R
import com.yidianling.uikit.custom.http.response.ServiceItemBean
import com.yidianling.uikit.custom.widget.expertConsultService.callback.ConsultServiceViewCallback
import kotlinx.android.synthetic.main.im_expert_consult_service_item_view.view.*
......@@ -36,24 +41,53 @@ class ExpertConsultServiceItemView : LinearLayout {
orientation = HORIZONTAL
View.inflate(mContext, R.layout.im_expert_consult_service_item_view, this)
setOnClickListener {
//todo xj 接接口的时候修改成服务id
mListener?.onItemClick(0)
}
im_expert_service_list_btn.setOnClickListener {
//todo 去咨询
/**
* 设置数据
*/
@SuppressLint("SetTextI18n")
fun setData(bean: ServiceItemBean.ProductsBean) {
//是否是套餐
if (bean.productDto.isPackage == 2) {
//展示左上角套餐布局
service_item_package.visibility = View.VISIBLE
//服务名
service_item_title.text = " ${bean.productDto.name}"
//起售次数展示
service_item_low_buy_time.visibility = View.VISIBLE
service_item_low_buy_time.text = "(${bean.productDto.packageNum}次起售)"
} else {
//隐藏套餐布局
service_item_package.visibility = View.GONE
//服务名
service_item_title.text = bean.productDto.name ?: ""
//隐藏起售次数限制
service_item_low_buy_time.visibility = View.GONE
}
//价格,取productSpecDtos数组最后一个价格,不保留小数
service_item_price.text = String.format(
"%.0f",
(bean.productSpecDtos.last().price)
)
//时间,取productSpecDtos数组最后一个的时间
service_item_time.text = "/${bean.productSpecDtos.last().spec2}分钟"
//好评率,*20后 保留1位小数
service_item_feddbackrate.text = String.format(
"%.1f",
(bean.productDto.feedbackRate) * 20f
) + "%"
//销量
service_item_saleout_num.text = "销量${bean.productDto.saleoutAmount}"
setOnClickListener {
mListener?.onItemClick(bean)
}
/**
* 设置数据
*/
fun setData(bean: String) {
im_expert_service_list_btn.setOnClickListener {
NewH5Activity.start(mContext, H5Params(HttpConfig.MH5_URL + "consult/#/pages/DownOrder/DownOrder?product_id=" + bean.productDto.id, null))
}
}
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import android.widget.ScrollView
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.im.R
import com.yidianling.uikit.custom.http.response.ServiceItemBean
import com.yidianling.uikit.custom.widget.expertConsultService.callback.ConsultServiceViewCallback
import kotlinx.android.synthetic.main.im_expert_consult_service_list_dialog_layout.*
......@@ -23,11 +24,12 @@ import kotlinx.android.synthetic.main.im_expert_consult_service_list_dialog_layo
* 专家咨询服务列表弹框
* Created by xj on 2019/8/7.
*/
class ExpertConsultServiceListDialog(val mContext: Context): Dialog(mContext, R.style.dialog_default_style) {
class ExpertConsultServiceListDialog(val mContext: Context, val mList: List<ServiceItemBean>): Dialog(mContext, R.style.dialog_default_style) {
private var mConsultServiceListView: View? = null
private var mConsultServiceDetailView: View? = null
private var mConsultServiceListView: ExpertConsultServiceView? = null
private var mConsultServiceDetailView: ExpertConsultServiceDetailView? = null
private var mViewList: ArrayList<View> = ArrayList()
private var mSelectType: String = "全部"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
......@@ -42,39 +44,26 @@ class ExpertConsultServiceListDialog(val mContext: Context): Dialog(mContext, R.
window.attributes = params
var typeList:ArrayList<String> = ArrayList()
typeList.add("全部")
typeList.add("婚姻家庭")
typeList.add("恋爱情感")
typeList.add("性心理")
typeList.add("亲子关系")
typeList.add("人际社交")
typeList.add("精神疾病")
var serviceList:ArrayList<String> = ArrayList()
serviceList.add("全部")
serviceList.add("婚姻家庭")
serviceList.add("恋爱情感")
serviceList.add("性心理")
serviceList.add("亲子关系")
serviceList.add("人际社交")
serviceList.add("精神疾病")
typeList.add(mSelectType)//默认选中
mList.forEach { item ->
typeList.add(item.cateName)
}
mConsultServiceListView =
ExpertConsultServiceView(
mContext
)
(mConsultServiceListView as ExpertConsultServiceView).setDataAndClick(typeList, serviceList, object : ConsultServiceViewCallback {
(mConsultServiceListView as ExpertConsultServiceView).setDataAndClick(typeList, mList, object : ConsultServiceViewCallback {
override fun onCloseClick() {
dismiss()
}
override fun onItemClick(serviceId: Int) {
// todo 执行右滑动画和接口请求
override fun onItemClick(serviceBean: ServiceItemBean.ProductsBean) {
if (mConsultServiceDetailView != null) {
mConsultServiceDetailView?.updateData(serviceBean)
dialog_bottom_scroll_view.currentItem = 1
}
}
})
......@@ -85,7 +74,6 @@ class ExpertConsultServiceListDialog(val mContext: Context): Dialog(mContext, R.
ExpertConsultServiceDetailView(
mContext, object : ConsultServiceViewCallback {
override fun onBackClick() {
// todo 执行左滑动画
dialog_bottom_scroll_view.currentItem = 0
}
})
......
......@@ -6,6 +6,7 @@ import android.view.View
import android.widget.LinearLayout
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.im.R
import com.yidianling.uikit.custom.http.response.ServiceItemBean
import com.yidianling.uikit.custom.widget.expertConsultService.callback.ConsultServiceViewCallback
import kotlinx.android.synthetic.main.im_expert_consult_service_view.view.*
......@@ -13,7 +14,9 @@ class ExpertConsultServiceView : LinearLayout {
private var typeSelectedIndex: Int = 0
private var mTypeList: ArrayList<String> = ArrayList()
private var mServiceList: ArrayList<String> = ArrayList()
private var mServiceList: ArrayList<ServiceItemBean> = ArrayList()
private var mListener: ConsultServiceViewCallback? = null
constructor(context: Context) : super(context) {
mContext = context
......@@ -59,13 +62,13 @@ class ExpertConsultServiceView : LinearLayout {
*/
fun setDataAndClick(
typeList: ArrayList<String>,
serviceList: ArrayList<String>,
allServiceList: List<ServiceItemBean>,
listener: ConsultServiceViewCallback?
) {
mListener = listener
consult_service_dialog_close.setOnClickListener {
listener?.onCloseClick()
mListener?.onCloseClick()
}
// 设置顶部滚动类型数据
......@@ -82,30 +85,45 @@ class ExpertConsultServiceView : LinearLayout {
)
item.setData(str, index == typeSelectedIndex)
item.setOnClickListener {
resetSelected(index)
typeSelectedIndex = index
resetSelected()
selectTypeServiceList()
}
expert_consult_service_type_list.addView(item)
}
}
}
// 设置服务列表数据
if (serviceList != null && serviceList.size != 0) {
typeSelectedIndex = 0 // 初始化为全部选中
mServiceList.clear()
mServiceList.addAll(serviceList)
mServiceList.addAll(allServiceList)
// 设置服务列表数据
selectTypeServiceList()
}
mServiceList.forEachIndexed { index, str ->
val item = ExpertConsultServiceItemView(mContext!!, listener)
/**
* 刷新服务列表数据
*/
private fun selectTypeServiceList() {
expert_consult_service_service_list.removeAllViews()
if (mServiceList.size != 0) {
mServiceList.forEachIndexed { index, itemBean ->
//当选中String相同的时候,添加view,或者选中typeSelectedIndex==0的时候,展示全部
if (itemBean.cateName == mTypeList[typeSelectedIndex] || typeSelectedIndex == 0) {
itemBean.products.forEach {
val item = ExpertConsultServiceItemView(mContext!!, mListener)
item.setData(it)
expert_consult_service_service_list.addView(item)
}
}
}
}
}
private fun resetSelected(index: Int) {
typeSelectedIndex = index
/**
* 刷新类型列表数据
*/
private fun resetSelected() {
for (index in 0 until expert_consult_service_type_list.childCount) {
var view = expert_consult_service_type_list.getChildAt(index)
if (view is ExpertConsultServiceTypeItemView) {
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="1dp"/>
<solid android:color="#FF9500"/>
</shape>
\ No newline at end of file
......@@ -25,6 +25,7 @@
android:src="@drawable/im_expert_service_list_left_back" />
<TextView
android:id="@+id/consult_service_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="调节孕期情绪烦躁,建立积极心态面对新生活"
......@@ -73,6 +74,7 @@
android:layout_marginBottom="15dp"
android:text="相互了解,初步建立咨访关系,解答你心中关于咨询本身的一切疑惑,解答你心中关于咨询本身的一切疑惑,解答你心中关于咨询本身的一切疑惑,为你的困扰解决明确咨询目标与方案。相互了解,初步建立咨访关系,解答你心中关于咨询本身的一切疑惑,为你的困扰解决明确咨询目标与方案。相互了解,初步建立咨访关系,解答你心中关于咨询"
android:textColor="#666666"
android:fontFamily="sans-serif-thin"
android:textSize="14dp"
android:textStyle="bold" />
......@@ -127,6 +129,7 @@
android:orientation="horizontal">
<TextView
android:id="@+id/consult_service_is_package"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
......@@ -135,6 +138,7 @@
android:textSize="14dp" />
<TextView
android:id="@+id/consult_service_times"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
......@@ -177,6 +181,7 @@
android:orientation="horizontal">
<TextView
android:id="@+id/consult_service_once_time_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
......@@ -185,6 +190,7 @@
android:textSize="14dp" />
<TextView
android:id="@+id/consult_service_service_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
......@@ -322,6 +328,7 @@
android:textSize="10dp" />
<TextView
android:id="@+id/consult_service_service_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="320"
......@@ -330,15 +337,24 @@
android:textStyle="bold" />
<TextView
android:id="@+id/consult_service_price_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/次"
android:textColor="#666666"
android:textSize="10dp"
android:textStyle="bold" />
android:textSize="10dp" />
<TextView
android:id="@+id/consult_service_low_buy_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="(几次起售)"
android:visibility="gone"
android:textColor="#666666"
android:textSize="10dp" />
</LinearLayout>
<TextView
android:id="@+id/consult_service_btn"
android:layout_width="125dp"
android:layout_height="38dp"
android:background="@drawable/im_expert_service_detail_btn_bg"
......
......@@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal">
<LinearLayout
......@@ -13,14 +14,32 @@
android:paddingTop="10dp"
android:paddingBottom="18dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/service_item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="调节孕期情绪烦躁,建立积极心态面对新生活"
tools:text=" 调节孕期情绪烦躁,建立积极心态面对新生活"
android:textColor="#1A1A1A"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="@+id/service_item_package"
android:layout_width="24dp"
android:layout_height="14dp"
android:gravity="center"
android:text="套餐"
android:visibility="gone"
android:layout_marginTop="3dp"
android:textColor="#ffffff"
android:textSize="10dp"
android:background="@drawable/im_service_package_bg"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -42,6 +61,7 @@
android:textSize="10dp" />
<TextView
android:id="@+id/service_item_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="320"
......@@ -51,20 +71,31 @@
</LinearLayout>
<TextView
android:id="@+id/service_item_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/60分钟"
android:textColor="#999999"
android:textSize="12dp" />
<TextView
android:id="@+id/service_item_low_buy_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="(几次起售)"
android:visibility="gone"
android:textColor="#999999"
android:textSize="12dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="好评率"
android:layout_marginLeft="10dp"
android:textColor="#999999"
android:textSize="12dp" />
<TextView
android:id="@+id/service_item_feddbackrate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="99.9%"
......@@ -94,6 +125,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/service_item_saleout_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
......
......@@ -78,7 +78,7 @@
android:layout_weight="1"
android:autoLink="all"
android:background="#ffffff"
android:hint="放心聊天,信息保密"
android:hint="隐私保密,安心咨询"
android:maxHeight="72dp"
android:maxLines="4"
android:textColorHint="#999999"
......
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