1:修改在帮助中,使用平台的客服功能,如果对方是客服,自己不用充值可以聊天
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.xscm.moduleutil.bean
|
||||
|
||||
/**
|
||||
* 项目名称:羽声语音
|
||||
* 时间:2026/1/14 18:47
|
||||
* 用途:app配置的客服用户id和name
|
||||
*/
|
||||
class AppCustomerBean {
|
||||
var user_id: String = ""
|
||||
var user_name: String = ""
|
||||
}
|
||||
@@ -449,6 +449,9 @@ public interface ApiServer {
|
||||
@GET(Constants.GET_MY_INFO)
|
||||
Call<BaseModel<UserInfo>> getMyInfo();
|
||||
|
||||
@GET(Constants.GET_APP_CUSTOMER_SERVICE)
|
||||
Call<BaseModel<AppCustomerBean>> appCustomerService();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_DEL_SONG)
|
||||
Call<BaseModel<String>> delSong(@Field("room_id") String room_id, @Field("did") String did);
|
||||
|
||||
@@ -2757,6 +2757,32 @@ public class RetrofitClient {
|
||||
});
|
||||
}
|
||||
|
||||
public void appCustomerService(BaseObserver<AppCustomerBean> observer) {
|
||||
sApiServer.appCustomerService().enqueue(new Callback<BaseModel<AppCustomerBean>>() {
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<AppCustomerBean>> call, Response<BaseModel<AppCustomerBean>> response) {
|
||||
if (response.code() == 200) {
|
||||
BaseModel<AppCustomerBean> listBaseModel = response.body();
|
||||
if (listBaseModel.getCode() == 1)
|
||||
observer.onNext(listBaseModel.getData());
|
||||
else if (listBaseModel.getCode() == 301) {
|
||||
setCode301(listBaseModel.getMsg());
|
||||
} else if (listBaseModel.getCode() == 0) {
|
||||
ToastUtils.showShort(listBaseModel.getMsg());
|
||||
}
|
||||
}else {
|
||||
ToastUtils.showLong("客服信息不正确");
|
||||
LogUtils.e("appCustomerService", response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<AppCustomerBean>> call, Throwable t) {
|
||||
LogUtils.e("appCustomerService", t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getUserTagList(BaseObserver<List<UserTagBean>> observer) {
|
||||
sApiServer.getUserTagList().enqueue(new Callback<BaseModel<List<UserTagBean>>>() {
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.text.TextUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.blankj.utilcode.util.SPUtils;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.AppCustomerBean;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
|
||||
@@ -233,6 +234,16 @@ public class SpUtil {
|
||||
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getString(SPConstants.TOKEN);
|
||||
}
|
||||
|
||||
public static void setAppCustomerBean(AppCustomerBean appCustomerBean) {
|
||||
String s = JSON.toJSONString(appCustomerBean);
|
||||
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put("appCustomerBean", s, true);
|
||||
}
|
||||
|
||||
public static AppCustomerBean getAppCustomerBean() {
|
||||
String s = SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getString("appCustomerBean");
|
||||
return JSON.parseObject(s, AppCustomerBean.class);
|
||||
}
|
||||
|
||||
public static void setBoolean(String key, boolean value) {
|
||||
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put(key, value, true);
|
||||
}
|
||||
|
||||
@@ -244,6 +244,7 @@ public class Constants {
|
||||
public static final String CANCEL = "/api/Login/cancel";//注销账号
|
||||
public static final String POST_MODIFY_HIDE_STATUS = "/api/UserData/modify_hide_status";//设置隐身进入
|
||||
public static final String GET_MY_INFO = "/api/User/get_user_info";//点击我的获取个人数据
|
||||
public static final String GET_APP_CUSTOMER_SERVICE = "/api/banner/app_customer_service";//获取平台客服用户Id
|
||||
public static final String GET_USER_HOME = "/api/User/get_user_home";//点击获取个人数据
|
||||
public static final String POST_DEL_SONG = "/api/RoomSong/del_song";//删除已点歌曲
|
||||
public static final String POST_SEARCH_USER = "/api/RoomSong/search_song";//已点列表搜索
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.tencent.mm.opensdk.modelbiz.WXOpenCustomerServiceChat;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIC2CChatActivity;
|
||||
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.R;
|
||||
@@ -43,6 +44,7 @@ import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.WebUrlConstants;
|
||||
import com.xscm.moduleutil.bean.AppCustomerBean;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
@@ -393,15 +395,25 @@ public class WebViewActivity extends BaseMvpActivity<IPresenter,ActivityWebViewB
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void customerService() {
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId(); // 填移动应用(App)的 AppId
|
||||
IWXAPI api = WXAPIFactory.createWXAPI(mContext, appId);
|
||||
|
||||
// 判断当前版本是否支持拉起客服会话
|
||||
WXOpenCustomerServiceChat.Req req = new WXOpenCustomerServiceChat.Req();
|
||||
req.corpId = "ww1de4300858c0b461"; // 企业ID
|
||||
req.url = "https://work.weixin.qq.com/kfid/kfcb3d23a59c188a0e7"; // 客服URL
|
||||
api.sendReq(req);
|
||||
public void customerService(String user_id, String nickname) {
|
||||
// TODO: 2026/1/14 客服,今天更改成使用下面的,使用本程序中的用户,让进行私聊
|
||||
// String appId = CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId(); // 填移动应用(App)的 AppId
|
||||
// IWXAPI api = WXAPIFactory.createWXAPI(mContext, appId);
|
||||
//
|
||||
//// 判断当前版本是否支持拉起客服会话
|
||||
// WXOpenCustomerServiceChat.Req req = new WXOpenCustomerServiceChat.Req();
|
||||
// req.corpId = "ww1de4300858c0b461"; // 企业ID
|
||||
// req.url = "https://work.weixin.qq.com/kfid/kfcb3d23a59c188a0e7"; // 客服URL
|
||||
// api.sendReq(req);
|
||||
AppCustomerBean appCustomerBean = new AppCustomerBean();
|
||||
appCustomerBean.setUser_id(user_id);
|
||||
appCustomerBean.setUser_name(nickname);
|
||||
SpUtil.setAppCustomerBean(appCustomerBean);
|
||||
Intent intent = new Intent(mContext, TUIC2CChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, "u"+user_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, nickname);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
|
||||
@@ -18,6 +18,7 @@ public class NewsContacts {
|
||||
void getOfficialNotice();
|
||||
void getMyInfo();
|
||||
|
||||
void appCustomerService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.xscm.modulemain.activity.msg.fragment;
|
||||
|
||||
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
@@ -50,6 +52,7 @@ public class NewsFragment extends BaseMvpFragment<NewsPresenter, FragmentNewsBin
|
||||
super.onResume();
|
||||
MvpPre.getOfficialNotice();
|
||||
MvpPre.getMyInfo();
|
||||
MvpPre.appCustomerService();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,6 +61,7 @@ public class NewsFragment extends BaseMvpFragment<NewsPresenter, FragmentNewsBin
|
||||
if (!hidden){
|
||||
MvpPre.getOfficialNotice();
|
||||
MvpPre.getMyInfo();
|
||||
MvpPre.appCustomerService();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,11 +148,13 @@ public class NewsFragment extends BaseMvpFragment<NewsPresenter, FragmentNewsBin
|
||||
mBinding.tvXtNr.setText("");
|
||||
}
|
||||
if (newsDataBeans.getSystem_no_read_count()>0) {
|
||||
mBinding.tvXtCount.setVisibility(VISIBLE);
|
||||
mBinding.tvXtCount.setText(newsDataBeans.getSystem_no_read_count()+"");
|
||||
}else {
|
||||
mBinding.tvXtCount.setVisibility(View.GONE);
|
||||
}
|
||||
if (newsDataBeans.getAnnouncement_read_count()>0) {
|
||||
mBinding.tvOfficialCount.setVisibility(VISIBLE);
|
||||
mBinding.tvOfficialCount.setText(newsDataBeans.getAnnouncement_read_count()+"");
|
||||
}else {
|
||||
mBinding.tvOfficialCount.setVisibility(View.GONE);
|
||||
|
||||
@@ -3,16 +3,24 @@ package com.xscm.modulemain.activity.msg.presenter;
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.msg.contacts.NewsContacts;
|
||||
import com.xscm.moduleutil.bean.AppCustomerBean;
|
||||
import com.xscm.moduleutil.bean.NewsDataBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class NewsPresenter extends BasePresenter<NewsContacts.View> implements NewsContacts.IHomePre {
|
||||
|
||||
private NewsContacts.View mView;
|
||||
|
||||
public NewsPresenter(NewsContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,6 +33,9 @@ public class NewsPresenter extends BasePresenter<NewsContacts.View> implements N
|
||||
|
||||
@Override
|
||||
public void onNext(NewsDataBean newsDataBeans) {
|
||||
if (MvpRef == null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getOfficialNoticeList(newsDataBeans);
|
||||
}
|
||||
});
|
||||
@@ -40,8 +51,27 @@ public class NewsPresenter extends BasePresenter<NewsContacts.View> implements N
|
||||
|
||||
@Override
|
||||
public void onNext(UserInfo userInfo) {
|
||||
if (MvpRef == null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().myInfoSuccess(userInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appCustomerService() {
|
||||
api.appCustomerService(new BaseObserver<AppCustomerBean>(){
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(AppCustomerBean appCustomerBean) {
|
||||
SpUtil.setAppCustomerBean(appCustomerBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,65 +43,6 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_official"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_62"
|
||||
android:layout_marginStart="@dimen/dp_16"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_gg"
|
||||
android:layout_width="@dimen/dp_50"
|
||||
android:layout_height="@dimen/dp_50"
|
||||
android:src="@mipmap/gg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_gfgg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
android:layout_toEndOf="@+id/im_gg"
|
||||
android:text="官方公告"
|
||||
android:textColor="@color/color_FF333333"
|
||||
android:textSize="@dimen/sp_16" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_nr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tv_gfgg"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_toEndOf="@+id/im_gg"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
tools:text="Chat with your friends"
|
||||
android:textColor="@color/color_FF666666"
|
||||
android:textSize="@dimen/sp_12" />
|
||||
|
||||
<com.tencent.qcloud.tuikit.timcommon.component.UnreadCountTextView
|
||||
android:id="@+id/tv_official_count"
|
||||
android:layout_width="@dimen/dp_15"
|
||||
android:layout_height="@dimen/dp_15"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
tools:text="1"
|
||||
android:textColor="@color/white" />
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/view_line"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/conversation_list_divide_line_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@color/conversation_divide_line_color"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_system"
|
||||
android:layout_width="match_parent"
|
||||
@@ -152,6 +93,67 @@
|
||||
android:textColor="@color/white" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
|
||||
<View
|
||||
android:id="@+id/view_line"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/conversation_list_divide_line_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@color/conversation_divide_line_color"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_official"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_62"
|
||||
android:layout_marginStart="@dimen/dp_16"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_gg"
|
||||
android:layout_width="@dimen/dp_50"
|
||||
android:layout_height="@dimen/dp_50"
|
||||
android:src="@mipmap/gg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_gfgg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
android:layout_toEndOf="@+id/im_gg"
|
||||
android:text="官方公告"
|
||||
android:textColor="@color/color_FF333333"
|
||||
android:textSize="@dimen/sp_16" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_nr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tv_gfgg"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_toEndOf="@+id/im_gg"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
tools:text="Chat with your friends"
|
||||
android:textColor="@color/color_FF666666"
|
||||
android:textSize="@dimen/sp_12" />
|
||||
|
||||
<com.tencent.qcloud.tuikit.timcommon.component.UnreadCountTextView
|
||||
android:id="@+id/tv_official_count"
|
||||
android:layout_width="@dimen/dp_15"
|
||||
android:layout_height="@dimen/dp_15"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
tools:text="1"
|
||||
android:textColor="@color/white" />
|
||||
</RelativeLayout>
|
||||
|
||||
<com.xscm.moduleutil.widget.ScrollViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUIExtensionEventListener;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUIExtensionInfo;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUIValueCallback;
|
||||
import com.tencent.qcloud.tuicore.util.SPUtils;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.bean.ChatFace;
|
||||
import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
|
||||
@@ -71,6 +72,10 @@ import com.tencent.qcloud.tuikit.tuichat.util.ChatMessageBuilder;
|
||||
import com.tencent.qcloud.tuikit.tuichat.util.ChatMessageParser;
|
||||
import com.tencent.qcloud.tuikit.tuichat.util.TUIChatLog;
|
||||
import com.tencent.qcloud.tuikit.tuichat.util.TUIChatUtils;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -253,6 +258,7 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
||||
this.can_chat_money = can_chat_money;
|
||||
}
|
||||
}
|
||||
|
||||
private userInd getUserInfo(){
|
||||
SharedPreferences sp = getContext().getSharedPreferences("Vespa", Context.MODE_PRIVATE);
|
||||
String s= sp.getString("userInfo","");
|
||||
@@ -268,7 +274,20 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
||||
private boolean isChock(){
|
||||
userInd userInfo = getUserInfo();
|
||||
|
||||
if (userInfo != null && mChatInfo.getType()==1) {
|
||||
String userId="";
|
||||
SharedPreferences sp = getContext().getSharedPreferences("Vespa", Context.MODE_PRIVATE);
|
||||
try {
|
||||
String s = sp.getString("appCustomerBean", "");
|
||||
if (!s.isEmpty()) {
|
||||
JSONObject jsonObject = new JSONObject(s);
|
||||
userId = jsonObject.optString("user_id", ""); // 如果user_id不存在,返回空字符串
|
||||
// 使用userId...
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (userInfo != null && mChatInfo.getType()==1 && !mChatInfo.getId().equals("u"+userId) ) {
|
||||
if (userInfo.getIs_can_chat() == 0 && userInfo.getCan_chat_money() > 0) {
|
||||
Toast.makeText(getContext(), "充值不足"+userInfo.getCan_chat_money()+"元,您无法发送消息", Toast.LENGTH_LONG).show();
|
||||
ARouter.getInstance().build("/modulevocal/RechargeActivity").navigation();
|
||||
|
||||
Reference in New Issue
Block a user