using AllBase; using AllBase.Helper; using AllBase.Model.Result; using CefSharp; using CefSharp.WinForms; using NaiBa.CefHelper; using NaiBa.CefHelper.Handler; using NaiBa.Util.Extension; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Media; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using TemuKJD.BaseForms; using TemuKJD.Helper; using TemuKJD.ToolForms; using TemuKJD.WXForms.ShopForms; using TemuKJD.WXForms.TalkForms.TalkHelper; namespace TemuKJD.WXForms.TalkForms { public partial class WxTalkForm : BaseTalkForm { public Dictionary ShopChatCount = new Dictionary(); public delegate void SearchResultReceivedHandler(ShopLoginInfo shop); /// /// 查询结果事件通知 /// public event SearchResultReceivedHandler SearchResultReceived; public delegate void InfomationReceivedHandler(string infomation); /// /// 消息事件通知,比如:异常等通知 /// /// public event InfomationReceivedHandler InfomationReceived; public static ShopLoginInfo currentShop = null; ChromiumWebBrowser mainWebBrowser = null; /// /// 弹出框列表 /// public static List lstChatMessageForm = new List(); public static Dictionary dicRowColor = new Dictionary(); public int LocationXY = 0; public int LocationSize = 200; public WxTalkForm() { InitializeComponent(); ChatConfig.LoadChatSetting(); } private void WxTalkForm_FormClosed(object sender, FormClosedEventArgs e) { Process.GetCurrentProcess().Kill(); } private void WxTalkForm_Load(object sender, EventArgs e) { if (BaseClass.LogoImage != null) pbLogo.Image = BaseClass.LogoImage; if (BaseClass.Ico != null) this.Icon = BaseClass.Ico; else this.Icon = BaseClass.Ico = ImageBuild.ConvertToIcon(Properties.Resources.icon); //SetTitle(); //this.chkIsAutoReLogin.CheckedChanged -= chkIsAutoReLogin_CheckedChanged; //this.chkIsAutoReply.CheckedChanged -= chkIsAutoReply_CheckedChanged; //this.txtAutoReplyText.TextChanged -= txtAutoReplyText_TextChanged; //this.cmbMessage.SelectedIndexChanged -= cmbMessage_SelectedIndexChanged; if (this.cmbMessage.Items.Contains(ChatConfig.ChatSettingConfig.MessageSound)) this.cmbMessage.SelectedItem = ChatConfig.ChatSettingConfig.MessageSound; else this.cmbMessage.SelectedIndex = 0; this.chkIsAutoReply.Checked = ChatConfig.ChatSettingConfig.IsAutoReply; this.txtAutoReplyText.Text = ChatConfig.ChatSettingConfig.AutoReplayText; this.chkIsAutoReLogin.CheckedChanged += chkIsAutoReLogin_CheckedChanged; this.chkIsAutoReply.CheckedChanged += chkIsAutoReply_CheckedChanged; this.txtAutoReplyText.TextChanged += txtAutoReplyText_TextChanged; this.cmbMessage.SelectedIndexChanged += cmbMessage_SelectedIndexChanged; SearchResultReceived += Chat_SearchResultReceived; InfomationReceived += Collect_InfomationReceived; if (mainWebBrowser == null) { mainWebBrowser = CEFBrowser.CreateChromiumWebBrowser("about:blank", false); mainWebBrowser.KeyboardHandler = new KeyboardHandler(); mainWebBrowser.Dock = DockStyle.Fill; var lifeSpanHandler = new LifeSpanHandlerLocal(PopWindowType.NewTitleWindow); lifeSpanHandler.parent = mainWebBrowser; lifeSpanHandler.OnPop += MainLifeHandler_OnPop; mainWebBrowser.LifeSpanHandler = lifeSpanHandler; //mainWebBrowser.AddressChanged += mainWebBrowser_UrlChanged; mainWebBrowser.FrameLoadEnd += cefWebBrowser1_FrameLoadEnd; mainPanel.Controls.Add(mainWebBrowser); } Task.Run(() => { // 直到店铺加载完后再加载客服内容 while (!StartUp.IsShopInit) Thread.Sleep(100); SetMainBrowserUrl(GlobalConfig.ShopLoginList.FirstOrDefault()); LoadShop(); InitAutoExecute(); }); } private void cefWebBrowser1_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e) { //ChromiumWebBrowser cefWebBrowser1 = (ChromiumWebBrowser)sender; //string url = cefWebBrowser1.Address; //if (url.Contains("/mallcenter/info/basic") && cefWebBrowser3.IsBrowserInitialized) //{ // Thread.Sleep(5000); // var shop = GetShopLoginInfo.Shops.Find(s => s != null && s.ShopName == ShopName); // string code = "document.getElementsByClassName('new-part')[1].innerHTML=\"
" + shop.Name + "?

当前状态不支持修改店铺名,您可一键开新店铺

\""; // cefWebBrowser3.GetBrowser().MainFrame.ExecuteJavaScriptAsync(code); //} } [DllImport("winmm.dll")] public static extern uint mciSendString(string lpstrCommand, string lpstrReturnString, uint uReturnLength, uint hWndCallback); /// /// 播放提示音 /// public void playSound() { string musicname = "默认提示音"; if (!string.IsNullOrEmpty(ChatConfig.ChatSettingConfig.MessageSound)) musicname = ChatConfig.ChatSettingConfig.MessageSound; if (musicname == "无") return; if (musicname == "默认提示音") musicname = "9527.wav"; else musicname = musicname + ".mp3"; if (musicname.Contains("wav")) { try { SoundPlayer sound = new SoundPlayer("temp/" + musicname); sound.Play(); } catch { } } if (musicname.Contains("mp3")) { try { mciSendString(@"close ""temp/" + musicname + @"""", null, 0, 0); mciSendString(@"open ""temp/" + musicname + @"""", null, 0, 0); mciSendString(@"play ""temp/" + musicname + @"""", null, 0, 0); } catch { } } } public void ShowChat(ShopLoginInfo shop) { while (shop.Chat?.IsBrowserInitialized != true) { Thread.Sleep(50); } // 设置cef cookie if (shop.Chat != null && shop.Chat.IsBrowserInitialized) { var cookieManager = shop.Chat.RequestContext.GetCookieManager(null); var cookieLst = new List(); try { cookieLst = JsonHelper.DeserializeJsonToList(shop.Cookies.ParseToString().Replace("empty=true;", "[]")); } catch { } cookieManager.DeleteCookies("qq.com", null); foreach (var cook in cookieLst) { var t = CEFBrowser.SetCookieAsync(cook.Domain, cook.Name + "=" + cook.Value + ";", cookieManager); t.Wait(5000); } if (shop.LoginStatus == "登录成功") shop.Chat.Load("https://store.weixin.qq.com/shop/kf"); } } public void LoadShop(List shopList = null) { if (shopList == null) shopList = new List(); if (shopList.Count == 0) shopList.AddRange(GlobalConfig.ShopLoginList); for (int i = 0; i < shopList.Count; i++) { var shop = shopList[i]; ShopLoginInfo result = new ShopLoginInfo(); result.ShopId = shop.ShopId; result.ShopAccount = shop.ShopAccount; result.LoginStatus = shop.LoginStatus; var r = dgvShop.Rows.Cast().FirstOrDefault(x => x.Cells["colShopId"].Value.ToString() == shop.ShopId); this.Invoke(new Action(() => { int iGrid = 0; if (r == null) { iGrid = dgvShop.Rows.Add(); if (iGrid == 0) dgvShop.Rows[iGrid].Cells["colSelect"].Value = true; } else iGrid = r.Index; dgvShop.Rows[iGrid].Cells["colShopId"].Value = shop.ShopId; // 店铺ID dgvShop.Rows[iGrid].Cells["colShopName"].Value = shop.ShopAccount; // 店铺名称 dgvShop.Rows[iGrid].Cells["colLoginStatus"].Value = shop.LoginStatus == "登录成功" ? "在线" : "掉线"; // 登录状态 dicRowColor[dgvShop.Rows[iGrid]] = dgvShop.Rows[iGrid].DefaultCellStyle.BackColor; if (shop.Chat == null) { LocationXY += 5; shop.X = LocationXY % LocationSize; shop.Y = LocationXY / LocationSize; RequestContextSettings requestContextSettings = new RequestContextSettings(); requestContextSettings.PersistSessionCookies = false; //requestContextSettings.PersistUserPreferences = false; try { var cefWebBrowser = CEFBrowser.CreateChromiumWebBrowser("about:blank", false); //new ChromiumWebBrowser("https://store.weixin.qq.com/shop/kf); CustomResourceRequestHandler resourceRequestHandler = new CustomResourceRequestHandler(); Task.Run(() => { var handler = resourceRequestHandler; //Thread.Sleep(3000); handler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete; }); cefWebBrowser.RequestHandler = new CustomRequestHandler(resourceRequestHandler); cefWebBrowser.KeyboardHandler = new KeyboardHandler(); var lifeHandler = new LifeSpanHandlerLocal(PopWindowType.NewTitleWindow); lifeHandler.OnPop += LifeHandler_OnPop; lifeHandler.parent = cefWebBrowser; cefWebBrowser.LifeSpanHandler = lifeHandler; cefWebBrowser.RequestContext = new RequestContext(requestContextSettings); cefWebBrowser.Dock = DockStyle.Fill; //DockStyle.None; cefWebBrowser.Location = new Point(shop.X, shop.Y); shop.Chat = cefWebBrowser; pnlTalk.Controls.Add(shop.Chat); if (i == 0) currentShop = shop; Task.Run(() => { ShowChat(shop); while (shop.Chat.IsLoading) { Thread.Sleep(50); } //Thread.Sleep(3000); //var t = shop.Chat.GetMainFrame().EvaluateScriptAsync("document.getElementsByClassName('unread-badge bold').length;"); //t.Wait(2000); //if (t.Result?.Result?.ParseToInt() > 0) //{ // var row = dgvShop.Rows.Cast().FirstOrDefault(rw => rw.Cells["colShopId"].Value.ParseToString() == shop.ShopId); // if (row != null) // { // Invoke(new Action(() => // { // row.Cells["colMessage"].Value = "有历史未读消息"; // })); // // 进行闪烁 // Task.Run(() => { FlashDgvRow(row); }); // // 播放声音 // playSound(); // } //} }); } catch (Exception ex) { return; } } })); } } private void RequestHandler_ResourceLoadComplete(object sender, string url, string postData, string responseData) { //if (responseData.Contains("你好")) //{ //} if (url.Contains("action=get_nosession_summary") || url.Contains("action=get_open_session_summary") || url.Contains("action=get_session_summary") || url.Contains("action=get_sync_msg")) { Task.Run(() => { getResourceLoadMsg(sender as ChromiumWebBrowser, url, postData, responseData); }); } } private void getResourceLoadMsg(ChromiumWebBrowser cef, string url, string postData, string responseData) { if (cef == null) return; var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.Chat == cef); if (shop == null) return; Task.Run(() => { var row = dgvShop.Rows.Cast().FirstOrDefault(r => r.Cells["colShopId"].Value.ParseToString() == shop.ShopId); if (row == null) return; if (url.Contains("action=get_nosession_summary")) { //{"base_resp":{"err_msg":"ok","ret":0},"list":[{"session_status":1,"summary":{"accept_by_robot":2,"accept_by_robot_time":"0","complaint_info":{"complaint_expire_time":0,"complaint_id":"0"},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/Q3auHgzwzM6vehibAAib9ia4ejxH7ibula7RuH4rTO7H7equgOZPVZl5Ew\\/64\",\"nickname\":\"Vader\",\"list\":[],\"qa_info_list\":[]}","id":"1","is_delete":0,"lastest_msg_content":"","lastest_msg_id":"4348928114244206592","lastest_msg_kf_content":"{\"content\":\"你好\"}","lastest_user_msg_time":"1768807915","msg_type":1,"recv_open_account":"wxf4460bce24e5d58d","recv_openid":"","room_id":"4348927951587721218","scene":6,"send_open_account":"","send_openid":"o9cq802Ue5pCVRmzuzkFUcnoHjcM","send_scene":6,"unread_msg_num":"1","unreplied_msg_time":"1768807915","update_time":"1768807915"}}],"num":1} //{"base_resp":{"err_msg":"ok","ret":0},"list":[],"num":0} var jObj = JsonHelper.JObjectParse(responseData); //{"base_resp":{"err_msg":"ok","ret":0},"list":[{"session_status":1,"summary":{"accept_by_robot":2,"accept_by_robot_time":"0","complaint_info":{"complaint_expire_time":0,"complaint_id":"0"},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/PiajxSqBRaEIuS5Aa65qsCwzKFpmSiciazvMbicxfEyHvTmD8MpQibR85wg\\/64\",\"nickname\":\"jtt\",\"list\":[],\"qa_info_list\":[]}","id":"160","is_delete":0,"lastest_msg_content":"","lastest_msg_id":"4349035115016224786","lastest_msg_kf_content":"{\"type\":13,\"content\":\"{\\\"finder_live_id\\\":\\\"\\\",\\\"finder_username\\\":\\\"\\\",\\\"finder_object_id\\\":\\\"\\\",\\\"finder_nonce_id\\\":\\\"\\\",\\\"app_id\\\":\\\"wxca8d4b8e8feedc2a\\\",\\\"page_path\\\":\\\"main/pages/productDetail/productDetail.html?productId=10000405003763&realappid=wx2664a142d76831dd&cacheKey=3d585c9672aa92a088812cf9f8b30e0a&cacheType=backup&businessId=1&requestId=4349035091393462273&subScene=1208\\\",\\\"product_id\\\":\\\"10000405003763\\\",\\\"cover_url\\\":\\\"https://wst.wxapp.tc.qq.com/161/20304/snscosdownload/SH/reserved/695a36c7000ab9b70c029451f0d71715000000a100004f50?imageView2/1/w/400/h/400/q/50\\\",\\\"product_title\\\":\\\"运动套装女春秋2024新款时尚小熊卫衣连帽宽松跑步服休闲两件套潮\\\",\\\"market_price\\\":\\\"39530\\\",\\\"selling_price\\\":\\\"38730\\\",\\\"platform_head_img\\\":\\\"http://mmbiz.qpic.cn/mmbiz_jpg/cpXibyAIsexe8vObd8jWMktZk6sg1kKJgicdnzFiaxR1XvU0Kchlfdewsu7JETDF3lLp5cyULNNee94UPGeU1r9Rw/0?wx_fmt=jpeg/0\\\",\\\"platform_name\\\":\\\"夜笙供应链\\\",\\\"shop_window_id\\\":\\\"\\\",\\\"live_status\\\":\\\"\\\",\\\"flash_sale_price\\\":0,\\\"flash_sale_end_time\\\":0,\\\"ec_source\\\":\\\"\\\",\\\"selling_price_wording\\\":\\\"\\\",\\\"ext_conv\\\":{\\\"ext_conv_type\\\":1,\\\"ec_product_url\\\":\\\"https://channels.weixin.qq.com/shop?login_appid=wx2664a142d76831dd&redirect_url=%2Fgoods%2Fentry%3FproductId%3D10000405003763\\\",\\\"context\\\":\\\"\\\"}}\"}","lastest_user_msg_time":"1768814292","msg_type":11,"recv_open_account":"wx2664a142d76831dd","recv_openid":"","room_id":"4349034984388345858","scene":6,"send_open_account":"","send_openid":"o9cq800-I4XeS-NiBgsIae1y38Ac","send_scene":6,"unread_msg_num":"1","unreplied_msg_time":"1768814293","update_time":"1768814292"}}],"num":1} //if (jObj["num"].ParseToInt() <= 0) // return; return; } else if (url.Contains("action=get_open_session_summary")) { //{"base_resp":{"err_msg":"ok","ret":0},"pin_summary_list":[],"summary_cursor":"4349020771451830279","summary_list":[{"complaint_info":{"complaint_expire_time":0,"complaint_id":"","complaint_status":0},"ext_info":{},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/PiajxSqBRaEIuS5Aa65qsCwzKFpmSiciazvMbicxfEyHvTmD8MpQibR85wg\\/64\",\"nickname\":\"jtt\",\"list\":[],\"qa_info_list\":[]}","id":"5","is_delete":0,"is_expired":0,"is_pin":0,"is_pin_update_time":"0","kf_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","kf_reply_status":0,"lastest_msg_content":"","lastest_msg_id":"4349029975415865363","lastest_msg_kf_content":"{\"content\":\"你好\"}","lastest_user_msg_time":"1768813986","msg_type":1,"recv_open_account":"wxad4163db54e87b44","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","room_id":"4348999364009132044","room_session_status":0,"scene":6,"send_open_account":"","send_openid":"o9cq800-I4XeS-NiBgsIae1y38Ac","send_scene":6,"session_close_source":0,"star_label":0,"star_label_update_time":"0","sync_id":"78","unread_msg_num":"1","unreplied_msg_time":"1768813988","update_time":"1768813986","user_openid":"o9cq800-I4XeS-NiBgsIae1y38Ac"}]} //{"base_resp":{"err_msg":"ok","ret":0},"pin_summary_list":[],"summary_cursor":"4349035365970083850","summary_list":[{"complaint_info":{"complaint_expire_time":0,"complaint_id":"","complaint_status":0},"ext_info":{},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/PiajxSqBRaEIuS5Aa65qsCwzKFpmSiciazvMbicxfEyHvTmD8MpQibR85wg\\/64\",\"nickname\":\"jtt\",\"list\":[],\"qa_info_list\":[]}","id":"160","is_delete":0,"is_expired":0,"is_pin":0,"is_pin_update_time":"0","kf_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","kf_reply_status":1,"lastest_msg_content":"","lastest_msg_id":"4349035365970083850","lastest_msg_kf_content":"{\"content\":\"在的亲\"}","lastest_user_msg_time":"1768814292","msg_type":1,"recv_open_account":"wx2664a142d76831dd","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","room_id":"4349034984388345858","room_session_status":0,"scene":6,"send_open_account":"wx2664a142d76831dd","send_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","send_scene":6,"session_close_source":0,"star_label":0,"star_label_update_time":"0","sync_id":"3186","unread_msg_num":"0","unreplied_msg_time":"0","update_time":"1768814308","user_openid":"o9cq800-I4XeS-NiBgsIae1y38Ac"},{"complaint_info":{"complaint_expire_time":0,"complaint_id":"","complaint_status":0},"ext_info":{},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/sstLNDibp2U6zXibjfoE1tUiaHCOKX1olnJNZnFGehlibg4liacAAWmj2VQ\\/64\",\"nickname\":\"我是上帝的女儿李善容\",\"list\":[],\"qa_info_list\":[]}","id":"154","is_delete":0,"is_expired":0,"is_pin":0,"is_pin_update_time":"0","kf_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","kf_reply_status":0,"lastest_msg_content":"","lastest_msg_id":"4347360170765271042","lastest_msg_kf_content":"{\"type\":\"SessionTimeoutRedDot\",\"content\":\"你已超过10分钟未回复该会话,请及时处理。\",\"room_id\":\"4339855644638920709\",\"msg_id\":\"4347350053416747021\",\"is_anonymous_msg\":0,\"need_update_summary\":1}","lastest_user_msg_time":"1768713854","msg_type":24,"recv_open_account":"wx2664a142d76831dd","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","room_id":"4339855644638920709","room_session_status":0,"scene":6,"send_open_account":"","send_openid":"o9cq802n8yQWq6bwbx2w8rp_aygk","send_scene":6,"session_close_source":0,"star_label":0,"star_label_update_time":"0","sync_id":"3042","unread_msg_num":"0","unreplied_msg_time":"1768713857","update_time":"1768714458","user_openid":"o9cq802n8yQWq6bwbx2w8rp_aygk"},{"complaint_info":{"complaint_expire_time":0,"complaint_id":"","complaint_status":0},"ext_info":{},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/IbQhd2Y9oKdcIf3tbP1pciaic0icL271V7iaqWQqGvrrrMbq26tSHnFf9Q\\/64\",\"nickname\":\"素色🍃᭄年华\",\"list\":[],\"qa_info_list\":[]}","id":"155","is_delete":0,"is_expired":0,"is_pin":0,"is_pin_update_time":"0","kf_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","kf_reply_status":1,"lastest_msg_content":"","lastest_msg_id":"4347305586245287937","lastest_msg_kf_content":"{\"type\":\"SessionTimeoutRedDot\",\"content\":\"你已超过10分钟未回复该会话,请及时处理。\",\"room_id\":\"4340576309047115777\",\"msg_id\":\"4347295489464516617\",\"is_anonymous_msg\":0,\"need_update_summary\":1}","lastest_user_msg_time":"1768710602","msg_type":24,"recv_open_account":"wx2664a142d76831dd","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","room_id":"4340576309047115777","room_session_status":0,"scene":6,"send_open_account":"","send_openid":"o9cq80-t4oDOfQD6J6oJ8pp4yA7M","send_scene":6,"session_close_source":0,"star_label":0,"star_label_update_time":"0","sync_id":"3035","unread_msg_num":"0","unreplied_msg_time":"1768710604","update_time":"1768711205","user_openid":"o9cq80-t4oDOfQD6J6oJ8pp4yA7M"}]} var jObj = JsonHelper.JObjectParse(responseData); return; } else if (url.Contains("action=get_session_summary")) { //{"base_resp":{"err_msg":"ok","ret":0},"pin_summary_list":[],"summary_cursor":"4349042918267191303","summary_list":[{"complaint_info":{"complaint_expire_time":0,"complaint_id":"","complaint_status":0},"ext_info":{},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/PiajxSqBRaEIuS5Aa65qsCwzKFpmSiciazvMbicxfEyHvTmD8MpQibR85wg\\/64\",\"nickname\":\"jtt\",\"list\":[],\"qa_info_list\":[]}","id":"5","is_delete":0,"is_expired":0,"is_pin":0,"is_pin_update_time":"0","kf_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","kf_reply_status":1,"lastest_msg_content":"","lastest_msg_id":"4349042918267191303","lastest_msg_kf_content":"{\"content\":\"您好亲,有什么需要帮助的吗\"}","lastest_user_msg_time":"1768814710","msg_type":1,"recv_open_account":"wxad4163db54e87b44","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","room_id":"4348999364009132044","room_session_status":0,"scene":6,"send_open_account":"wxad4163db54e87b44","send_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","send_scene":6,"session_close_source":0,"star_label":0,"star_label_update_time":"0","sync_id":"87","unread_msg_num":"0","unreplied_msg_time":"0","update_time":"1768814758","user_openid":"o9cq800-I4XeS-NiBgsIae1y38Ac"},{"complaint_info":{"complaint_expire_time":0,"complaint_id":"","complaint_status":0},"ext_info":{},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/Q3auHgzwzM6vehibAAib9ia4ejxH7ibula7RuH4rTO7H7equgOZPVZl5Ew\\/64\",\"nickname\":\"Vader\",\"list\":[],\"qa_info_list\":[]}","id":"2","is_delete":0,"is_expired":1,"is_pin":0,"is_pin_update_time":"0","kf_reply_status":1,"lastest_msg_content":"","lastest_msg_id":"4348993861855264779","lastest_msg_kf_content":"{\"type\":\"EndRoom\",\"content\":\"用户超时未回,会话已结束,两天内仍可再次联系\",\"room_id\":\"4348684483414425612\",\"msg_id\":\"4348993861855264779\",\"is_anonymous_msg\":0,\"need_update_summary\":1}","lastest_user_msg_time":"1768811222","msg_type":5,"recv_open_account":"wxad4163db54e87b44","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","room_id":"4348684483414425612","scene":6,"send_open_account":"","send_openid":"o9cq802Ue5pCVRmzuzkFUcnoHjcM","send_scene":6,"star_label":0,"star_label_update_time":"0","sync_id":"59","unread_msg_num":"0","unreplied_msg_time":"0","update_time":"1768811834","user_openid":"o9cq802Ue5pCVRmzuzkFUcnoHjcM"},{"complaint_info":{"complaint_expire_time":0,"complaint_id":"","complaint_status":0},"ext_info":{},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/Q3auHgzwzM61GOTjShX4GX3aSpuNiavic5xxAickB0fxH1Bic8Az5d0LCA\\/64\",\"nickname\":\"春暖花开\",\"list\":[],\"qa_info_list\":[]}","id":"4","is_delete":0,"is_expired":1,"is_pin":0,"is_pin_update_time":"0","kf_reply_status":1,"lastest_msg_content":"","lastest_msg_id":"4348932333527973902","lastest_msg_kf_content":"{\"type\":\"EndRoom\",\"content\":\"用户超时未回,会话已结束,两天内仍可再次联系\",\"room_id\":\"4348906544732405760\",\"msg_id\":\"4348932333527973902\",\"is_anonymous_msg\":0,\"need_update_summary\":1}","lastest_user_msg_time":"1768807466","msg_type":5,"recv_open_account":"wxad4163db54e87b44","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","room_id":"4348906544732405760","scene":6,"send_open_account":"","send_openid":"o9cq807-mRKhlh-MPBpeYyar46HA","send_scene":6,"star_label":0,"star_label_update_time":"0","sync_id":"44","unread_msg_num":"0","unreplied_msg_time":"0","update_time":"1768808166","user_openid":"o9cq807-mRKhlh-MPBpeYyar46HA"},{"complaint_info":{"complaint_expire_time":0,"complaint_id":"","complaint_status":0},"ext_info":{},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/PdibpV1sFDHeGJDbIwia4cv3UUPxnHqjFQ4piaSFEeJlViaeDPicHuQITkw\\/64\",\"nickname\":\"春雨\",\"list\":[],\"qa_info_list\":[]}","id":"3","is_delete":0,"is_expired":1,"is_pin":0,"is_pin_update_time":"0","kf_reply_status":1,"lastest_msg_content":"","lastest_msg_id":"4348888492147638275","lastest_msg_kf_content":"{\"type\":\"EndRoom\",\"content\":\"用户超时未回,会话已结束,两天内仍可再次联系\",\"room_id\":\"4348715191491690506\",\"msg_id\":\"4348888492147638275\",\"is_anonymous_msg\":0,\"need_update_summary\":1}","lastest_user_msg_time":"1768795504","msg_type":5,"recv_open_account":"wxad4163db54e87b44","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","room_id":"4348715191491690506","scene":6,"send_open_account":"","send_openid":"o9cq805nSmIjHqNthn9QbNimVAsE","send_scene":6,"star_label":0,"star_label_update_time":"0","sync_id":"29","unread_msg_num":"0","unreplied_msg_time":"0","update_time":"1768805553","user_openid":"o9cq805nSmIjHqNthn9QbNimVAsE"},{"complaint_info":{"complaint_expire_time":0,"complaint_id":"","complaint_status":0},"ext_info":{},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/PiajxSqBRaEJLajvZG4pYqhDrljibs7sNChSx6Cib2mN6KicJgbRESR8Rg\\/64\",\"nickname\":\"喂累了额\",\"list\":[],\"qa_info_list\":[]}","id":"1","is_delete":0,"is_expired":1,"is_pin":0,"is_pin_update_time":"0","kf_reply_status":1,"lastest_msg_content":"","lastest_msg_id":"4348884857446612993","lastest_msg_kf_content":"{\"type\":\"EndRoom\",\"content\":\"用户超时未回,会话已结束,两天内仍可再次联系\",\"room_id\":\"4347660512343588869\",\"msg_id\":\"4348884857446612993\",\"is_anonymous_msg\":0,\"need_update_summary\":1}","lastest_user_msg_time":"1768732601","msg_type":5,"recv_open_account":"wxad4163db54e87b44","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","room_id":"4347660512343588869","scene":6,"send_open_account":"","send_openid":"o9cq8038HnVM43HL44F5yGx6S6P0","send_scene":6,"star_label":0,"star_label_update_time":"0","sync_id":"27","unread_msg_num":"0","unreplied_msg_time":"0","update_time":"1768805337","user_openid":"o9cq8038HnVM43HL44F5yGx6S6P0"}]} var jObj = JsonHelper.JObjectParse(responseData); if (jObj.IsNullOrEmpty() || jObj["summary_list"].IsNullOrEmpty()) { return; } bool needReply = false; foreach (var summaryObj in jObj["summary_list"]) { try { var summary = JsonHelper.SerializeObject(summaryObj); // 会话结束,返回 if (summary.Contains("会话已结束")) continue; if (summary.Contains("用户已结束会话") || summary.Contains("客服已结束会话")) continue; // 最后一条是自己回复的,返回 var send_open_account = summaryObj["send_open_account"].ParseToString(); if (send_open_account == shop.ShopId) continue; // 虽然没有回复,但是最后一条消息是七天以前收到的,返回 var lastUpTime = summaryObj["update_time"].ParseToLong(); if (lastUpTime < BaseClass.DateTimeToTimestampSeconds(DateTime.Now.AddDays(-7))) continue; // 其他情况,标记需要回复 needReply = true; } catch { continue; } } if (!needReply) return; else { Invoke(new Action(() => { row.Cells["colMessage"].Value = "有历史未读消息"; })); } } else if (url.Contains("action=get_sync_msg")) { //{"finder_live_id":"","finder_username":"","finder_object_id":"","finder_nonce_id":"","app_id":"wxca8d4b8e8feedc2a","page_path":"main/pages/productDetail/productDetail.html?productId=10000444468035&realappid=wx2664a142d76831dd&cacheKey=4f69a37c98838eb27e484b6def86d0ca&cacheType=backup&businessId=1&requestId=4348991209208823817&subScene=1208","product_id":"10000444468035","cover_url":"https://wst.wxapp.tc.qq.com/161/20304/snscosdownload/SH/reserved/69677007000d0f3329fc594d77ef1b15000000a000004f50?imageView2/1/w/400/h/400/q/50","product_title":"保暖加绒中老年妈妈装棉服","market_price":"6980","selling_price":"6180","platform_head_img":"http://mmbiz.qpic.cn/mmbiz_jpg/cpXibyAIsexe8vObd8jWMktZk6sg1kKJgicdnzFiaxR1XvU0Kchlfdewsu7JETDF3lLp5cyULNNee94UPGeU1r9Rw/0?wx_fmt=jpeg/0","platform_name":"夜笙供应链","shop_window_id":"","live_status":"","flash_sale_price":0,"flash_sale_end_time":0,"ec_source":"","selling_price_wording":"","ext_conv":{"ext_conv_type":1,"ec_product_url":"https://channels.weixin.qq.com/shop?login_appid=wx2664a142d76831dd&redirect_url=%2Fgoods%2Fentry%3FproductId%3D10000444468035","context":""}} try { if (responseData.Contains("更新房间游标")) return; var jObj = JsonHelper.JObjectParse(responseData); if (jObj["total_num"].ParseToInt() <= 0) return; // 自己发的消息或者客服自动回复消息不闪烁提示且将表格颜色还原 ----------------------------------------------------------------------------------------------- // 您好!人工客服目前无法及时回复,您可以留言详细问题,我们会尽快为您服务! //"send_open_account": "wxad4163db54e87b44", var send_open_account = jObj["list"].LastOrDefault()?["send_open_account"].ParseToString(); if (send_open_account == shop.ShopId) { row.DefaultCellStyle.BackColor = row.Tag is Color ? (Color)row.Tag : Color.White; row.Cells["colMessage"].Value = ""; return; } var msg_kf_content = jObj["list"].LastOrDefault()?["msg_kf_content"].ParseToString(); var contentObj = JsonHelper.JObjectParse(msg_kf_content); var content = contentObj["content"].ParseToString(); if (content.Contains("更新房间游标")) return; // 处理 msg_type=5 的情况 (应该是系统提示消息,有些提示比如关闭会话的无需闪烁) ------------------------------------------------------ // 以下 "msg_type":5 // 你已超过90秒未回复该会话,请及时处理。 // 你已超过3分钟未回复该会话,请及时处理。 // 你已超过10分钟未回复该会话,请及时处理。 // 超过48小时未回复用户,会话已结束 // {"base_resp":{"err_msg":"ok","ret":0},"kf_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","list":[{"accept_by_robot":0,"async_check_spam_stage":0,"client_ms":"1768806150100","create_time":"1768806150","create_time_ms":"1768806150100","encrypt_msg_kf_content":"","extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/Q3auHgzwzM6vehibAAib9ia4ejxH7ibula7RuH4rTO7H7equgOZPVZl5Ew\\/64\",\"nickname\":\"Vader\",\"list\":[],\"qa_info_list\":[]}","id":"31","imunion_msg_id":"mmec-commkf-v2-4348898496719831040","insert_create_time_ms":"1768806150148","is_anonymous_msg":0,"is_delete":0,"is_expired":0,"is_fail":0,"is_hit_spam":0,"is_revoked":0,"is_sys_msg":1,"msg_direction":3,"msg_id":"4348898496719831040","msg_kf_content":"{\"type\":\"EndRoom\",\"content\":\"用户超时未回,会话已结束,两天内仍可再次联系\",\"room_id\":\"4348684483414425612\",\"msg_id\":\"4348898496719831040\",\"is_anonymous_msg\":0,\"need_update_summary\":1}","msg_type":5,"properties":"0","recv_open_account":"wxad4163db54e87b44","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","reply_type":0,"room_id":"4348684483414425612","room_useruin":"0","scene":6,"send_open_account":"","send_openid":"o9cq802Ue5pCVRmzuzkFUcnoHjcM","send_scene":6,"session_id":"0","update_time":"1768806150"}],"total_num":1} if (content.Contains("用户超时未回,会话已结束,两天内仍可再次联系")) return; // {"base_resp":{"err_msg":"ok","ret":0},"kf_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","list":[{"accept_by_robot":0,"async_check_spam_stage":0,"client_ms":"1768808777632","create_time":"1768808777","create_time_ms":"1768808777632","encrypt_msg_kf_content":"","extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/Q3auHgzwzM6vehibAAib9ia4ejxH7ibula7RuH4rTO7H7equgOZPVZl5Ew\\/64\",\"nickname\":\"Vader\",\"list\":[],\"qa_info_list\":[]}","id":"46","imunion_msg_id":"mmec-commkf-v2-4348942579357122569","insert_create_time_ms":"1768808777711","is_anonymous_msg":1,"is_delete":0,"is_expired":0,"is_fail":0,"is_hit_spam":0,"is_revoked":0,"is_sys_msg":1,"msg_direction":3,"msg_id":"4348942579357122569","msg_kf_content":"{\"type\":\"AcceptRoom\",\"content\":\"用户已接入\",\"room_id\":\"4348684483414425612\",\"msg_id\":\"4348942569912549377\",\"is_anonymous_msg\":1,\"need_update_summary\":0,\"summary_content\":\"{\\\"id\\\":\\\"2\\\",\\\"room_id\\\":\\\"4348684483414425612\\\",\\\"scene\\\":6,\\\"account\\\":\\\"3641079964\\\",\\\"send_scene\\\":6,\\\"send_account\\\":\\\"user_acct_2044334303_6\\\",\\\"send_uin\\\":2044334303,\\\"lastest_msg_id\\\":\\\"4348942543756476432\\\",\\\"lastest_msg_content\\\":\\\"\\\",\\\"unread_msg_num\\\":\\\"1\\\",\\\"update_time\\\":\\\"1768808774\\\",\\\"kf_uin\\\":1525084715,\\\"extra_info\\\":\\\"{\\\\\\\"head_img\\\\\\\":\\\\\\\"http:\\\\\\\\\\\\\\/\\\\\\\\\\\\\\/wx.qlogo.cn\\\\\\\\\\\\\\/mmhead\\\\\\\\\\\\\\/Q3auHgzwzM6vehibAAib9ia4ejxH7ibula7RuH4rTO7H7equgOZPVZl5Ew\\\\\\\\\\\\\\/64\\\\\\\",\\\\\\\"nickname\\\\\\\":\\\\\\\"Vader\\\\\\\",\\\\\\\"list\\\\\\\":[],\\\\\\\"qa_info_list\\\\\\\":[]}\\\",\\\"lastest_msg_kf_content\\\":\\\"{\\\\\\\"content\\\\\\\":\\\\\\\"测试\\\\\\\"}\\\",\\\"lastest_user_msg_time\\\":\\\"1768808774\\\",\\\"msg_type\\\":1,\\\"send_open_account\\\":\\\"\\\",\\\"recv_open_account\\\":\\\"wxad4163db54e87b44\\\",\\\"send_openid\\\":\\\"o9cq802Ue5pCVRmzuzkFUcnoHjcM\\\",\\\"recv_openid\\\":\\\"o9cq801T0m1dIivQzMyUwBvW5Znk\\\",\\\"is_delete\\\":0,\\\"star_label\\\":0,\\\"star_label_update_time\\\":\\\"0\\\",\\\"unreplied_msg_time\\\":\\\"1768808777\\\",\\\"kf_reply_status\\\":0,\\\"sync_id\\\":\\\"45\\\",\\\"is_pin\\\":0,\\\"is_pin_update_time\\\":\\\"0\\\",\\\"ext_info\\\":{},\\\"complaint_info\\\":{\\\"complaint_expire_time\\\":0,\\\"complaint_id\\\":\\\"\\\",\\\"complaint_status\\\":0},\\\"user_uin\\\":2044334303,\\\"is_expired\\\":0}\"}","msg_type":5,"properties":"0","recv_open_account":"wxad4163db54e87b44","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","reply_type":0,"room_id":"4348684483414425612","room_useruin":"0","scene":6,"send_open_account":"","send_openid":"o9cq802Ue5pCVRmzuzkFUcnoHjcM","send_scene":6,"session_id":"0","update_time":"1768808777"}],"total_num":1} //if (content.Contains("用户已接入")) // return; //content {"finder_live_id":"","finder_username":"","finder_object_id":"","finder_nonce_id":"","app_id":"wxca8d4b8e8feedc2a","page_path":"main/pages/productDetail/productDetail.html?productId=10000458846351&realappid=wxad4163db54e87b44&cacheKey=5e17e5db9339a95043ba1f8a3d02454d&cacheType=backup&businessId=1&requestId=4349008357285756937&subScene=1208","product_id":"10000458846351","cover_url":"https://wst.wxapp.tc.qq.com/161/20304/snscosdownload/SH/reserved/695a8faa000d37b31b2e9b6f55e91715000000a100004f50?imageView2/1/w/400/h/400/q/50","product_title":"旗袍复古国风外套新款加绒中老年时尚中式盘扣妈妈唐装开衫上衣女","market_price":"0","selling_price":"15895","platform_head_img":"http://mmbiz.qpic.cn/mmbiz_jpg/v9IeicMmfib92I87ia9hWs58ozuHZ8CRk6jyf6qgLwzibNSjAPekLzdf7yxOdQqR6od63tLH9s2zTxJbuqVTs6E19w/0?wx_fmt=jpeg/0","platform_name":"曼月森工厂店","shop_window_id":"","live_status":"","flash_sale_price":0,"flash_sale_end_time":0,"ec_source":"","selling_price_wording":"","ext_conv":{"ext_conv_type":1,"ec_product_url":"https://channels.weixin.qq.com/shop?login_appid=wxad4163db54e87b44&redirect_url=%2Fgoods%2Fentry%3FproductId%3D10000458846351","context":""}} var product_title = BaseRegex.GetStringJson(ref content, "product_title"); if (!string.IsNullOrWhiteSpace(product_title)) content = "用户发送商品:" + product_title; // 在消息格子内显示消息 row.Cells["colMessage"].Value = content; } catch { return; } } else { return; } // 以上判断需要回复: // 弹框 if (!ChatConfig.ChatSettingConfig.IsNotShowMessageWindow) ShowMessageForm(shop); // 进行闪烁 FlashDgvRow(row); // 播放声音 playSound(); // 消息弹框,暂时废弃 if (!ChatConfig.ChatSettingConfig.IsNotShowMessageWindow) { } }); } void FlashDgvRow(DataGridViewRow row) { Task.Run(() => { if (row.Tag == null) row.Tag = row.DefaultCellStyle.BackColor; for (int j = 0; j < 6; j++) { Invoke(new Action(() => { row.DefaultCellStyle.BackColor = Color.White; })); Thread.Sleep(120); Invoke(new Action(() => { row.DefaultCellStyle.BackColor = Color.FromArgb(245, 95, 50); })); Thread.Sleep(120); Invoke(new Action(() => { row.DefaultCellStyle.BackColor = Color.FromArgb(245, 45, 10); })); Thread.Sleep(120); } }); } private void MainLifeHandler_OnPop(object sender, PopData e) { var targetUrl = e.Url; var lifeHandler = sender as LifeSpanHandlerLocal; Task.Run(() => { if (lifeHandler.parent != null) { var cookies = CEFBrowser.GetCookieList("", lifeHandler.parent.RequestContext.GetCookieManager(null)); Invoke(new Action(() => { CefForm cefForm = new CefForm(targetUrl, cookies); cefForm.Show(); })); } }); } private void LifeHandler_OnPop(object sender, PopData e) { var targetUrl = e.Url; var lifeHandler = sender as LifeSpanHandlerLocal; Task.Run(() => { //if (e.Url.StartsWith("https://haohuo.jinritemai.com/views/product/item")) //{ // var productId = BaseRegex.GetMatchRegexString(ref targetUrl, "&id=(\\d{5,30})"); // if (!string.IsNullOrEmpty(productId)) // { // long product_id = productId.ParseToLong(); // if (product_id > 0) // { // string urlx = BaseClass.LoginApiUrl + "?obj=upshopid/upid_dd&act=get"; // string datax = "&pid=" + product_id + "&table=" + (product_id % 1024); // string htmlx = GetHtml.PostUtf8(urlx, UserLogin.GetSignaturex("", "") + datax); // string id = BaseRegex.GetMatchRegexString(htmlx, @"([\d]+)"); // if (htmlx.StartsWith("tb")) // targetUrl = "https://item.taobao.com/item.htm?id=" + id; // if (htmlx.StartsWith("pd")) // targetUrl = "https://mobile.yangkeduo.com/goods.html?goods_id=" + id; // if (htmlx.StartsWith("al")) // targetUrl = "https://detail.1688.com/offer/" + id + ".html"; // if (htmlx.StartsWith("dy")) // targetUrl = "https://weidian.com/item.html?itemID=" + id; // } // } //} //if (lifeHandler.parent != null) //{ // var cookies = CEFBrowser.GetCookieList("", lifeHandler.parent.RequestContext.GetCookieManager(null)); // Invoke(new Action(() => // { // CefForm cefForm = new CefForm(targetUrl, cookies); // cefForm.Show(); // })); //} }); } /// /// 更新店铺后台首页 /// /// private void SetMainBrowserUrl(ShopLoginInfo shop) { if (shop == null) return; var cookieLst = new List(); try { cookieLst = JsonHelper.DeserializeJsonToList(shop.Cookies.ParseToString().Replace("empty=true;", "[]")); } catch { } var cookieManager = mainWebBrowser.RequestContext.GetCookieManager(null); cookieManager.DeleteCookiesAsync("qq.com", null).Wait(); foreach (var cook in cookieLst) { var t = CEFBrowser.SetCookieAsync(cook.Domain, cook.Name + "=" + cook.Value + ";", cookieManager); t.Wait(5000); } mainWebBrowser.Load("https://store.weixin.qq.com/shop/home"); } /// /// 自动回复等 /// public void InitAutoExecute() { //Task.Run(() => //{ // while (true) // { // foreach (var shop in GlobalConfig.DouShopLoginList) // { // try // { // Thread.Sleep(new Random(DateTime.Now.Millisecond).Next(300, 500)); // bool needReLogin = AutoCheckShopLoginStatus(shop); // if (ChatConfig.ChatSettingConfig.IsAutoReLogin && needReLogin) // AutoReLogin(shop); // if (shop.LoginStatus != "登录成功") // continue; // Thread.Sleep(new Random(DateTime.Now.Millisecond).Next(300, 500)); // AutoReConnect(shop); // Thread.Sleep(new Random(DateTime.Now.Millisecond).Next(300, 500)); // AutoCloseMaskWindow(shop); // Thread.Sleep(new Random(DateTime.Now.Millisecond).Next(300, 500)); // var isNewMessage = AutoGetNewMessage(shop); // while (isNewMessage && ChatConfig.ChatSettingConfig.IsAutoReply) // { // AutoReplyWithJs(shop); // Thread.Sleep(new Random(DateTime.Now.Millisecond).Next(300, 500)); // isNewMessage = AutoGetNewMessage(shop); // } // } // catch (Exception ex) // { // } // } // } //}); //Task.Run(() => //{ // var sleepTime = 1000; // while (true) // { // Thread.Sleep(sleepTime); // var jsStr = "function getVideo() {\r\n" + // " var videos = document.getElementsByTagName('video')\r\n" + // " if (videos && videos.length > 0) {\r\n" + // " var src = videos[0].src;\r\n" + // " videos[0].parentElement.parentElement.click();\r\n" + // " return src;\r\n" + // " //return '';\r\n" + // " }\r\n" + // " return '';\r\n" + // "}" + // "getVideo();\r\n"; // if (currentShop?.Chat != null && currentShop.Chat.IsBrowserInitialized) // { // var t = currentShop.Chat.GetMainFrame().EvaluateScriptAsync(jsStr); // t.Wait(); // if (!string.IsNullOrEmpty(t.Result?.Result?.ToString())) // { // Invoke(new Action(() => // { // AllBase.GetHtml.OpenUrl(t.Result.Result.ToString()); // })); // } // } // } //}); //Task.Run(() => //{ // var sleepTime = 2500; // while (true) // { // try // { // Thread.Sleep(sleepTime); // var jsStr1 = "function ClosePopWindow() {\r\n" + // " var result = 'no_pop'\r\n" + // " var item = document.getElementsByClassName('anticon-close-circle');\r\n" + // " for(i = 0; i < item.length; i++) {\r\n" + // " item[i].click();\r\n" + // " result = 'success'\r\n" + // " }\r\n" + // " return result;\r\n" + // "}\r\n" + // "ClosePopWindow();\r\n"; // var jsStr2 = "function clickPopWindow() {\r\n" // + "var child = document.body.firstElementChild;\r\n" // + "var element1 = null;\r\n" // + " while (child) {\r\n" // + " if (child.innerHTML.indexOf('知道了') >= 0) {\r\n" // + " element1 = child;\r\n" // + " if (child.firstElementChild) {\r\n" // + " child = child.firstElementChild; continue;\r\n" // + " } else break;\r\n" // + " }\r\n" // + " child = child.nextElementSibling;\r\n" // + " }\r\n" // + " if (element1) {\r\n" // + " element1.click(); return 'success';\r\n" // + " } else return 'no_pop';\r\n" // + "}\r\n" // + "clickPopWindow();\r\n"; // if (mainWebBrowser.IsBrowserInitialized) // { // var t1 = mainWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr1); // t1.Wait(); // var t2 = mainWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr2); // t2.Wait(); // if (t1.Result?.Result?.ToString() == "success" || t2.Result?.Result?.ToString() == "success") // sleepTime = Randomx.GetId(550, 650); // else // sleepTime = Randomx.GetId(2500, 3000); // } // } // catch (Exception ex) { } // } //}); } private void chkIsAutoReLogin_CheckedChanged(object sender, EventArgs e) { ChatConfig.ChatSettingConfig.IsAutoReLogin = chkIsAutoReLogin.Checked; ChatConfig.SaveChatSettingParam(); } private void chkIsAutoReply_CheckedChanged(object sender, EventArgs e) { ChatConfig.ChatSettingConfig.IsAutoReply = chkIsAutoReply.Checked; ChatConfig.SaveChatSettingParam(); } private void txtAutoReplyText_TextChanged(object sender, EventArgs e) { ChatConfig.ChatSettingConfig.AutoReplayText = txtAutoReplyText.Text; ChatConfig.SaveChatSettingParam(); } private void cmbMessage_SelectedIndexChanged(object sender, EventArgs e) { ChatConfig.ChatSettingConfig.MessageSound = this.cmbMessage.SelectedItem.ToString(); ChatConfig.SaveChatSettingParam(); } private void Chat_SearchResultReceived(ShopLoginInfo shop) { //var r = dgvShop.Rows.Cast().FirstOrDefault(x => x.Cells["columnShopId"].Value.ToString() == shop.ShopId); //if (r != null) //{ // for (int i = 0; i < dgvShop.Rows.Count; i++) // { // var row = dgvShop.Rows[i]; // if (row.Cells[0].Value.ToString() == shop.ShopId && shop != currentShop) // { // if (ShopChatCount.ContainsKey(shop.ShopId) && ShopChatCount[shop.ShopId] > 0) // { // Task.Run(() => // { // for (int j = 0; j < 4; j++) // { // Invoke(new Action(() => { row.DefaultCellStyle.BackColor = Color.White; })); // Thread.Sleep(100); // Invoke(new Action(() => { row.DefaultCellStyle.BackColor = Color.FromArgb(245, 95, 50); })); // Thread.Sleep(100); // Invoke(new Action(() => { row.DefaultCellStyle.BackColor = Color.FromArgb(245, 45, 10); })); // Thread.Sleep(100); // } // }); // } // else if (row.DefaultCellStyle.BackColor != Color.White) // { // row.DefaultCellStyle.BackColor = Color.White; // } // break; // } // } //} } private void Collect_InfomationReceived(string infomation) { //try //{ // this.Invoke(new Action(() => // { // lblMsg.Text = infomation; // var data = infomation.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries); // if (data.Length == 2) // { // if (data[1] == FastCarCollect.FASTCAR_QUOTA_FINISH) // { // var shop = gridShop.Rows.Cast().FirstOrDefault(x => x.Cells["columnShopName"].Value.ToString() == data[0]); // if (shop != null) // { // shop.Cells["columnMsg"].Value = data[1]; // } // } // } // if (infomation == "修改出价结束") // this.btnStart.Enabled = true; // if (infomation == "暂停推广结束") // this.btnStop.Enabled = true; // })); //} //catch { } } /// /// 显示右下角消息弹框 /// /// private void ShowMessageForm(ShopLoginInfo shop) { if (!lstChatMessageForm.Any(f => f.shop == shop)) { Invoke(new Action(() => { TalkMessageForm cmf = new TalkMessageForm(shop, this); cmf.Dragable = false; cmf.ShowMinimizedBox = false; lstChatMessageForm.Add(cmf); Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - cmf.Width, Screen.PrimaryScreen.WorkingArea.Height); cmf.PointToScreen(p); cmf.Location = p; cmf.Show(); })); } } private void dgvShop_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) return; string shopId = dgvShop.Rows[e.RowIndex].Cells["colShopId"].Value?.ToString(); if (string.IsNullOrEmpty(shopId)) return; var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId); if (shop == null) return; if (dgvShop.Columns[e.ColumnIndex].HeaderText == "状态" && dgvShop.Rows[e.RowIndex].Cells[e.ColumnIndex].Value?.ToString() == "掉线") { Task.Run(() => { // 如需登录,引导至登录窗口,禁止从聊天窗口登录。 Invoke(new Action(() => { // 登录小店 WXShopLoginForm lf = new WXShopLoginForm(shop); lf.ShowDialog(); })); WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false); LoadShop(new List() { shop }); if (shop.LoginStatus == "登录成功") { ShowChat(shop); while (shop.Chat.IsLoading) { Thread.Sleep(50); } } }); } } private void dgvShop_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) return; foreach (DataGridViewRow r in dgvShop.Rows) r.Cells["colSelect"].Value = false; var row = dgvShop.Rows[e.RowIndex]; row.Cells["colSelect"].Value = true; if (row.DefaultCellStyle.BackColor.R == 245 || row.DefaultCellStyle.BackColor == Color.Yellow) row.DefaultCellStyle.BackColor = Color.Yellow; //if (row.Tag != null) // row.DefaultCellStyle.BackColor = row.Tag is Color ? (Color)row.Tag : Color.White; string shopId = row.Cells["colShopId"].Value?.ToString(); if (string.IsNullOrEmpty(shopId)) return; var shop = GlobalConfig.ShopLoginList.Where(s => s.ShopId == shopId).FirstOrDefault(); if (shop == null) return; if (shop?.Chat != null) { currentShop = shop; shop.Chat.Dock = DockStyle.Fill; shop.Chat.BringToFront(); } Task.Run(() => { SetMainBrowserUrl(shop); }); } public void DgvShopClick(ShopLoginInfo shop) { var r = dgvShop.Rows.Cast().FirstOrDefault(x => x.Cells["colShopId"].Value.ToString() == shop.ShopId); if (r != null) { r.Cells[0].Selected = true; var sender = this.dgvShop; DataGridViewCellEventArgs e = new DataGridViewCellEventArgs(0, r.Index); dgvShop_CellClick(sender, e); } } private void pnlRefresh_Click(object sender, EventArgs e) { pbLoading.Visible = true; Task.Run(() => { WXShopListForm.UpdateShop(); LoadShop(); Invoke(new Action(() => { pbLoading.Visible = false; })); }); } } }