private async void postView_OnLoadCompleted(object sender, NavigationEventArgs e)
        {
            if (e.Uri.ToString().Contains("sharer"))
            {
                var    wv     = sender as WebView;
                var    id     = currentGroupItem.GroupId;
                string script = "try{ document.getElementsByName('group_target')[0].setAttribute('value','" + id + "');}catch(err){}";
                await wv.InvokeScriptAsync("eval", new string[] { script });

                await Task.Delay(200);

                script = "try{ document.getElementById('u_0_6').setAttribute('value','C'); }catch(err){}";
                await wv.InvokeScriptAsync("eval", new string[] { script });

                await Task.Delay(200);

                script = "try{ document.getElementsByName('privacyx')[0].setAttribute('value','291667064279714'); }catch(err){}";
                await wv.InvokeScriptAsync("eval", new string[] { script });

                await Task.Delay(500);

                script = @"function run(){ try{ document.getElementById('share_submit').click(); }catch(err){}  setTimeout(run,500);} run();";
                await wv.InvokeScriptAsync("eval", new string[] { script });

                ProductEntities.Where(c => c.Id == currentPid).First().ProValue = 70;
            }
        }
        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;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 加载产品
        /// </summary>
        protected virtual void LoadProducts()
        {
            if (string.IsNullOrEmpty(Request.QueryString["Id"]))
            {
                return;
            }
            var query = new QueryInfo();

            query.Query <ProductEntity>().Where(it => it.Goods.Id == Request.QueryString["Id"].Convert <long>())
            .OrderBy(it => it.Id);
            ProductEntities = Ioc.Resolve <IApplicationService, ProductEntity>().GetEntities <ProductEntity>(query);
            var builder = new StringBuilder();

            builder.Append("[");
            var tempEntities = ProductEntities == null ? null : ProductEntities.Where(it => it.Sku != "").ToList();

            if (tempEntities != null && tempEntities.Count > 0)
            {
                foreach (var info in tempEntities)
                {
                    builder.Append("{");
                    builder.AppendFormat("Id:'{0}',Price:{1},Cost:{2},Count:{3},OrderMinCount:{4},OrderStepCount:{5},DataId:'{6}',DepositRate:{7},IsCustom:{8},IsReturn:{9},IsSales:'{10}',Sku:'{11}',OrderLimitCount:{12}",
                                         info.Id, info.Price, info.Cost, info.Count, info.OrderMinCount, info.OrderStepCount, info.DataId, info.DepositRate,
                                         info.IsCustom.ToString().ToLower(), info.IsReturn.ToString().ToLower(), info.IsSales.ToString().ToLower(),
                                         string.IsNullOrEmpty(info.Sku) ? "" : info.Sku.Replace("\"", "\\\""), info.Promotion == null?0:info.Promotion.OrderLimitCount);
                    builder.Append("},");
                }
                builder.Remove(builder.Length - 1, 1);
            }
            builder.Append("]");
            Products = builder.ToString();
            var defaultEntity = ProductEntities == null ? null : ProductEntities.FirstOrDefault(it => it.Sku == "");

            if (defaultEntity != null)
            {
                hfProductId.Value = defaultEntity.Id.ToString();
            }
        }