private async void postView_OnNavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args) { var url = args.Uri.ToString(); if (url.Contains("story")) { ProductEntities.Where(c => c.Id == currentPid).First().ProValue = 100; if (_productList.Count > 0) { args.Cancel = true; var itemd = _productList.Dequeue(); var firstpro = itemd.ProductUrl; var urls = firstpro.TrimEnd('/').Split('/'); var rid = urls[urls.Length - 1]; currentPid = itemd.Id; await Task.Delay(1000); var postView = WebEnginner.CreateInstance("postReq"); postView.NavigationStarting -= postView_OnNavigationStarting; postView.LoadCompleted -= postView_OnLoadCompleted; postView.NavigationStarting += postView_OnNavigationStarting; postView.LoadCompleted += postView_OnLoadCompleted; postView.Navigate(new Uri(string.Format("https://m.facebook.com/sharer.php?fs=0&sid={0}&pid={1}", rid, currentPid))); } } }
private async void postView_OnLoadCompleted(object sender, NavigationEventArgs e) { if (e.Uri.ToString().Contains("sharer")) { string script = @"function run(){document.getElementById('share_submit').click(); setTimeout(run,500);} run();"; await WebEnginner.GetWebView("postReq").InvokeScriptAsync("eval", new string[] { script }); ProductEntities.Where(c => c.Id == currentPid).First().ProValue = 70; } }
private async void next() { if (_groupList.Count <= 0 && _productList.Count <= 0) { return; } await Task.Delay(5000); PostProValue++; if (_productList.Count > 0) { var itemd = _productList.Dequeue(); var firstpro = itemd.ProductUrl; var urls = firstpro.TrimEnd('/').Split('/'); var rid = urls[urls.Length - 1]; currentPid = itemd.Id; itemd.ProValue = 10; CurrentPostInfo = string.Format("当前推送小组为:{0},商品为:{1}", currentGroupItem.Name, itemd.ProductName); var postView = WebEnginner.CreateInstance("postReqg"); postView.NavigationStarting -= postView_OnNavigationStarting; postView.LoadCompleted -= postView_OnLoadCompleted; postView.NavigationStarting += postView_OnNavigationStarting; postView.LoadCompleted += postView_OnLoadCompleted; postView.Navigate(new Uri(string.Format("https://m.facebook.com/sharer.php?m=group&group_target=0&u&id&ids&sid={0}&usedialogwithselector=1&_rdr", rid))); } else { currentGroupItem = _groupList.Dequeue(); ProductEntities.ToList().ForEach(item => _productList.Enqueue(item)); var itemd = _productList.Dequeue(); var firstpro = itemd.ProductUrl; var urls = firstpro.TrimEnd('/').Split('/'); var rid = urls[urls.Length - 1]; currentPid = itemd.Id; itemd.ProValue = 10; CurrentPostInfo = string.Format("当前推送小组为:{0},商品为:{1}", currentGroupItem.Name, itemd.ProductName); var postView = WebEnginner.CreateInstance("postReqg"); postView.NavigationStarting -= postView_OnNavigationStarting; postView.LoadCompleted -= postView_OnLoadCompleted; postView.NavigationStarting += postView_OnNavigationStarting; postView.LoadCompleted += postView_OnLoadCompleted; postView.Navigate(new Uri(string.Format("https://m.facebook.com/sharer.php?m=group&group_target=0&u&id&ids&sid={0}&usedialogwithselector=1&_rdr", rid))); } }