宅男在线永久免费观看网直播,亚洲欧洲日产国码无码久久99,野花社区在线观看视频,亚洲人交乣女bbw,一本一本久久a久久精品综合不卡

全部
常見問題
產(chǎn)品動態(tài)
精選推薦

Pro系統(tǒng)開啟游客咨詢客服功能的代碼修改教程

管理 管理 編輯 刪除

涉及大量代碼修改,請備份相關(guān)被修改文件

邏輯如下

本身客服系統(tǒng)自帶游客功能,對代碼進行了適當?shù)男薷?,讓游客信息能順利入?/p>

不可忽視的問題

找大佬繼續(xù)優(yōu)化

  1. 游客uid用的時間戳,如果你的已注冊會員數(shù)量達到10位數(shù),會與已注冊會員沖突,而且當并發(fā)比較高的時候,比如恰好1秒內(nèi)有2個游客同時咨詢,也會沖突
  2. 為了讓游客獲取到聊天記錄,取消了聊天記錄的驗證(需要大佬解決),會泄露
  3. 沒有對游客聊天記錄定時清理

php代碼修改

app/controller/api/v2/user/StoreService.php

修改從第46行開始,將 ??function record? 后面的 {}? 里面的內(nèi)容修改為

        [$uidTo, $limit, $toUid, $touristUid] = $request->getMore([
            [['uidTo', 'd'], 0],
            [['limit', 'd'], 10],
            [['toUid', 'd'], 0],
            [['touristUid', 'd'], 0],
        ], true);
        $uid = $request->uid();
        if (!$uid) {
            $uid = $touristUid;
        }
        return app('json')->successful($services->getRecord($uid, $uidTo, $limit, $toUid));

app/websocket/Manager.php

跳到第85行,將 ???function onOpen? 里面的代碼修改為

        $fd = $this->websocket->getSender();
        $type = $request->get('type');
        $token = $request->get('token', '');
        $touristUid = $request->get('tourist_uid', '');
        $tourist = !!$touristUid;
        /*if (!$token || !in_array($type, self::USER_TYPE)) {
            return $this->websocket->close();
        }*/
        if ($token === 'undefined' || $token === 'false') {
            $token = '';
        }
        if ($token === '') {
            $tourist = true;
            if (empty($touristUid)) {
                $touristUid = time();
            }
        }
        // 只有用戶模式下才能使用游客模式
        if ($type !== self::USER_TYPE[1] && $tourist) {
            return $this->websocket->close();
        }

        $types = self::USER_TYPE;
        $this->nowRoom->type(array_flip($types)[$type]);
        try {
            $data = $this->exec($type, 'login', [$fd, $request->get('form_type', null), ['token' => $token, 'tourist' => $tourist], $this->response])->getData();
        } catch (\Throwable $e) {
            return $this->websocket->close();
        }
        if ($tourist) {
            $data['status'] = 200;
            $data['data']['uid'] = $touristUid;
        }
        if ($data['status'] != 200 || !($data['data']['uid'] ?? null)) {
            return $this->websocket->close();
        }
        $this->resetPingTimeout($this->pingInterval + $this->pingTimeout);
        $uid = $data['data']['uid'];
        $type = array_search($type, self::USER_TYPE);
        $this->login($type, $uid, $fd);
        $this->nowRoom->add((string)$fd, $uid, 0, $tourist ? 1 : 0);
        $this->send($fd, $this->response->message('ping', ['now' => time()]));
        return $this->send($fd, $this->response->success($data['data']));

app/websocket/BaseHandler.php

找到第61行,將 ???abstract public function login(array $data = [], Response $response);? 修改為
???abstract public function login($data, Response $response);

找到第126行,將 ???$data['is_tourist'] = $data['is_tourist'] ?? 0;? 修改為
???$data['is_tourist'] = $isTourist ? 1 : 0;

app/websocket/handler/目錄下的四個文件,依次修改

找到 ???public function login(array $data = [], Response $response)? 修改為
???public function login($data, Response $response)

并且在 {? 后面添加以下代碼

        if (!is_array($data)) {
            $data = [];
        }

route/api.php

搜索 v2.user.StoreService/record? ,將整行代碼移動到下方 授權(quán)不通過,不會拋出異常繼續(xù)執(zhí)行? 的 {}? 里面

前端Vue代碼修改

所有代碼目錄以 view/uniapp? 為根目錄

api/user.js

找到 ???function getChatRecord? ,將 {}? 的代碼修改為

	return request.get("v2/user/service/record", data, {
		noAuth: true
	});

libs/new_chat.js

找到第82行到101行,將代碼修改為

	onStart: function(token, form_type, tourist_uid) {
		let wssUrl = `${VUE_APP_WS_URL}`
		this.ws = uni.connectSocket({
			// #ifdef H5
			url: wss(wssUrl + '?type=user&token=' + token + '&form_type=' + form_type + '&tourist_uid=' + tourist_uid),
			// #endif
			// #ifdef MP || APP-PLUS
			url: wssUrl + '?type=user&token=' + token + '&form_type=' + form_type + '&tourist_uid=' + tourist_uid,
			// #endif
			header: {
				'content-type': 'application/json'
			},
			method: 'GET',
			success: (res) => {}
		});
		this.ws.onOpen(this.onSocketOpen.bind(this))
		this.ws.onError(this.onError.bind(this));
		this.ws.onMessage(this.onMessage.bind(this))
		this.ws.onClose(this.onClose.bind(this));
	}

pages/customer_list/chat.vue

代碼修改較多,直接貼整個script代碼段,請將 ? 的內(nèi)容修改成以下代碼


最后使用HBuilder重新打包前端

請登錄后查看

地瓜葉 最后編輯于2022-10-27 11:37:14

快捷回復
回復
回復
回復({{post_count}}) {{!is_user ? '我的回復' :'全部回復'}}
排序 默認正序 回復倒序 點贊倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level || item.bbs_level }}

作者 管理員 企業(yè)

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推薦': '推薦'}}
{{item.is_suggest == 1? '取消推薦': '推薦'}}
沙發(fā) 板凳 地板 {{item.floor}}#
{{item.user_info.title || '暫無簡介'}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
打賞
已打賞¥{{item.reward_price}}
{{item.like_count}}
{{item.showReply ? '取消回復' : '回復'}}
刪除
回復
回復

{{itemc.user_info.nickname}}

{{itemc.user_name}}

回復 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}
打賞
已打賞¥{{itemc.reward_price}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回復' : '回復'}}
刪除
回復
回復
查看更多
打賞
已打賞¥{{reward_price}}
3468
{{like_count}}
{{collect_count}}
添加回復 ({{post_count}})

相關(guān)推薦

快速安全登錄

使用微信掃碼登錄
{{item.label}} 加精
{{item.label}} {{item.label}} 板塊推薦 常見問題 產(chǎn)品動態(tài) 精選推薦 首頁頭條 首頁動態(tài) 首頁推薦
取 消 確 定
回復
回復
問題:
問題自動獲取的帖子內(nèi)容,不準確時需要手動修改. [獲取答案]
答案:
提交
bug 需求 取 消 確 定
打賞金額
當前余額:¥{{rewardUserInfo.reward_price}}
{{item.price}}元
請輸入 0.1-{{reward_max_price}} 范圍內(nèi)的數(shù)值
打賞成功
¥{{price}}
完成 確認打賞

微信登錄/注冊

切換手機號登錄

{{ bind_phone ? '綁定手機' : '手機登錄'}}

{{codeText}}
切換微信登錄/注冊
暫不綁定
CRMEB客服

CRMEB咨詢熱線 咨詢熱線

400-8888-794

微信掃碼咨詢

CRMEB開源商城下載 源碼下載 CRMEB幫助文檔 幫助文檔
返回頂部 返回頂部
CRMEB客服