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

全部
常見(jiàn)問(wèn)題
產(chǎn)品動(dòng)態(tài)
精選推薦

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

管理 管理 編輯 刪除

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

邏輯如下

本身客服系統(tǒng)自帶游客功能,對(duì)代碼進(jìn)行了適當(dāng)?shù)男薷?,讓游客信息能順利入?kù)

不可忽視的問(wèn)題

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

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

php代碼修改

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

修改從第46行開(kāi)始,將 ??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();
            }
        }
        // 只有用戶(hù)模式下才能使用游客模式
        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/目錄下的四個(gè)文件,依次修改

找到 ???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? ,將整行代碼移動(dòng)到下方 授權(quán)不通過(guò),不會(huì)拋出異常繼續(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

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


最后使用HBuilder重新打包前端

請(qǐng)登錄后查看

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

快捷回復(fù)
回復(fù)
回復(fù)
回復(fù)({{post_count}}) {{!is_user ? '我的回復(fù)' :'全部回復(fù)'}}
排序 默認(rèn)正序 回復(fù)倒序 點(diǎn)贊倒序

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

作者 管理員 企業(yè)

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

{{itemf.name}}

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

{{itemc.user_info.nickname}}

{{itemc.user_name}}

回復(fù) {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

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

相關(guān)推薦

快速安全登錄

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

微信登錄/注冊(cè)

切換手機(jī)號(hào)登錄

{{ bind_phone ? '綁定手機(jī)' : '手機(jī)登錄'}}

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

CRMEB咨詢(xún)熱線(xiàn) 咨詢(xún)熱線(xiàn)

400-8888-794

微信掃碼咨詢(xún)

CRMEB開(kāi)源商城下載 源碼下載 CRMEB幫助文檔 幫助文檔
返回頂部 返回頂部
CRMEB客服