Пример #1
0
        public virtual async Task RenderListAsync(AccountRecord page, int pageIndex = 1)
        {
            try
            {
                var rows     = 20;
                var gteTime  = Convert.ToDateTime(page.DpStartTime.Text);
                var lteTime  = Convert.ToDateTime(page.DpEndTime.Text);
                var type     = (EnumAccountRecordType)Convert.ToInt32(((ComboBoxItem)page.CmbType.SelectedValue).Tag.ToString());
                var response = await _onMainHostRequestPlugins.QueryAccountRecorrdAsync(new AccountRecordRequest()
                {
                    Page        = pageIndex,
                    Rows        = rows,
                    Type        = (int)type,
                    GteTime     = gteTime,
                    LteTime     = lteTime,
                    AccessToken = AccountCache.Persist.AccessToken
                });

                if (response != null && response.Code == Application.Enums.ApiCodeEnums.ERROR_NOLOGIN)
                {
                    _onTipRender.ExecuteTip(page.BodyPanel, "登陆失效,请退出重新登陆");
                    _onRedirectRender.RedirectLogin();
                    return;
                }

                var resp = response.Data;
                #region 数据绑定

                _onControlRender.ThreadExecuteUI(() =>
                {
                    _onControlRender.BindFrameworkElement(page.DataGridOrderList, resp?.Data?.ToList() ?? null);

                    if ((resp?.Data?.Count() ?? 0) <= 0)
                    {
                        page.SpPager.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        page.SpPager.Visibility = Visibility.Visible;
                    }

                    var sump                    = Convert.ToInt32(resp.TotalCount) % rows;
                    var totalPage               = Convert.ToInt32(resp?.TotalCount ?? 0) / rows + (sump > 0 ? 1 : 0);
                    page.labTotalPage.Content   = $"/{totalPage}";
                    page.labCurrentPage.Content = $"{pageIndex}";

                    page.labPrePage.Tag        = $"{pageIndex - 1}";
                    page.labPrePage.IsEnabled  = pageIndex > 1;
                    page.labNextPage.Tag       = $"{pageIndex + 1}";
                    page.labNextPage.IsEnabled = (pageIndex + 1) <= totalPage;
                    page.txbJumb.Tag           = totalPage;
                });
                #endregion
            }
            catch (Exception ex)
            {
                TextHelper.Error("RenderList 异常", ex);
                _onTipRender.ExecuteTip(page.BodyPanel, "查询异常[0001]");
            }
        }
Пример #2
0
        public virtual async Task Start(Main main)
        {
            var browser = AutofacManage.GetService <Browser>();

            if (!AccountCache.Persist.IsMember)
            {
                _onTipRender.ExecuteTip(main.BodyPanel, "您还不是会员,请成为会员后开启挣钱之旅");
                return;
            }
            browser.Show();
            browser.StartService();
            main.Hide();
        }
Пример #3
0
        public virtual async Task RenderListAsync(Product page)
        {
            try
            {
                var listResponse = await _onMainHostRequestPlugins.GetProductListAsync(AccountCache.Persist.AccessToken);

                if (listResponse.Code == Application.Enums.ApiCodeEnums.ERROR_NOLOGIN)
                {
                    _onTipRender.ExecuteTip(page.BodyPanel, "登陆失效,请退出重新登陆");
                    _onRedirectRender.RedirectLogin();
                    return;
                }
                var data = listResponse.Data;
                _onControlRender.ThreadExecuteUI(() =>
                {
                    for (var i = 0; i < data.Count; i++)
                    {
                        if (i == 0)
                        {
                            data[i].Color = "#818184";
                        }
                        if (i == 1)
                        {
                            data[i].Color = "#708e9e";
                        }
                        if (i == 2)
                        {
                            data[i].Color = "#a9a98d";
                        }
                        if (i == 3)
                        {
                            data[i].Color = "#8aa48d";
                        }
                        if (i == 4)
                        {
                            data[i].Color = "#7f698c";
                        }
                    }
                    page.DataGridProductList.ItemsSource = listResponse.Data;
                });
            }
            catch (Exception ex)
            {
                TextHelper.Error("RenderListAsync 异常", ex);
                _onTipRender.ExecuteTip(page.BodyPanel, "查询异常[0001]");
            }
        }
Пример #4
0
        public virtual async Task RenderAccountAsync(Account account)
        {
            try
            {
                var acccountResponse = await _onMainHostRequestPlugins.QueryAccountAsync(AccountCache.Persist.AccessToken);

                if (acccountResponse.Code == Application.Enums.ApiCodeEnums.ERROR_NOLOGIN)
                {
                    _onTipRender.ExecuteTip(account.BodyPanel, "登陆失效,请退出重新登陆");
                    _onRedirectRender.RedirectLogin();
                    return;
                }
                var data = acccountResponse?.Data ?? null;
                _onControlRender.ThreadExecuteUI(() =>
                {
                    if (!string.IsNullOrWhiteSpace(data.AlipayAccount))
                    {
                        account.tbAlipayAccount.IsReadOnly = true;
                    }
                    if (!string.IsNullOrWhiteSpace(data.RealName))
                    {
                        account.tbAlipayName.IsReadOnly = true;
                    }
                    var handleFee = $"提现手续费{AccountCache.Persist.SystemSettings.HandleFee * 100}%";
                    if (AccountCache.Persist.SystemSettings.HandleFee >= 1)
                    {
                        handleFee = $"提现手续费{AccountCache.Persist.SystemSettings.HandleFee}元";
                    }
                    account.lbHandler.Content     = handleFee;
                    account.BodyPanel.DataContext = data;
                });
            }
            catch (Exception ex)
            {
                TextHelper.Error($"RenderAccountAsync 异常 message:{ex.Message}", ex);
            }
        }
Пример #5
0
        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="login"></param>
        /// <returns></returns>
        public async Task RenderLoginAsync(Login login)
        {
            try
            {
                var userName = login.UserName.Text.Trim();
                var passWord = login.Password.Password.Trim();
                //var isRemember = login.cbRememberPassword.IsChecked ?? false;
                //var isAutoLogin = login.cbAutoLogin.IsChecked ?? false;
                if (!Verify(login))
                {
                    return;
                }

                var loginResponse = await _onMainHostRequestPlugins.AuthAsync(new AuthRequest()
                {
                    Mobile   = userName,
                    Password = passWord
                });

                if (!(loginResponse?.Success ?? false))
                {
                    _onTipRender.ExecuteTip(login.BodyPanel, loginResponse?.Msg ?? "登陆失败001");
                    return;
                }
                if (string.IsNullOrWhiteSpace(loginResponse?.Data?.AccessToken ?? ""))
                {
                    _onTipRender.ExecuteTip(login.BodyPanel, loginResponse?.Msg ?? "登陆失败002");
                    return;
                }

                var accessToken  = loginResponse.Data.AccessToken;
                var refreshToken = loginResponse.Data.RefreshToken;
                //ServiceIniCacheHelper.WriteAccessToken(loginResponse.DataaccessToken);
                //ServiceIniCacheHelper.WriteRefreshToken(refreshToken);

                #region 设置登录信息
                var systemRespnose = await _onMainHostRequestPlugins.QuerySettingsAsync(accessToken);

                AccountCache.SetLogin(new AccountCache()
                {
                    UserName       = userName,
                    Password       = passWord,
                    AccessToken    = accessToken,
                    RefreshToken   = refreshToken,
                    SystemSettings = systemRespnose?.Data ?? new SystemSettingsResponse()
                });
                #endregion

                #region 登陆成功
                var main = AutofacManage.GetService <Main>();
                main.ShowAmount();
                var suspensionMain = AutofacManage.GetService <SuspensionMain>();
                main.Show();
                suspensionMain.Show();
                login.Hide();
                #endregion
            }
            catch (Exception ex)
            {
                TextHelper.Error($"RenderLoginAsync 登陆失败 errror:{ex.Message}", ex);
                _onTipRender.ExecuteTip(login.BodyPanel, ex.Message ?? "登陆失败003");
            }
        }
Пример #6
0
        /// <summary>
        /// 查询渲染订单列表
        /// </summary>
        /// <param name="orderDataRequest"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public async Task RenderListAsync(CardOrder page, int pageIndex = 1)
        {
            try
            {
                #region 组装数据
                var cardNo           = page.txbCardNo.Text.Equals("请输入会员手机号或卡号") ? "" : page.txbCardNo.Text;
                var orderDataRequest = new Model.CardOrderRequest()
                {
                    CashId        = AccountCache.Persist.CashId,
                    OrderNo       = page.txbOrderNo.Text.Trim(),
                    Type          = Convert.ToInt32(((ComboBoxItem)page.CmbOrderType.SelectedValue).Tag.ToString()),
                    PageIndex     = pageIndex,
                    StartTime     = Convert.ToDateTime(page.DpStartTime.Text),
                    EndTime       = Convert.ToDateTime(page.DpEndTime.Text),
                    Rows          = 8,
                    StoresId      = AccountCache.Persist.StoreId,
                    PhoneOrCardNo = cardNo,
                };
                #endregion

                #region 信息验证
                if ((orderDataRequest?.CashId ?? 0) <= 0)
                {
                    _onControlRender.ThreadExecuteUI(() =>
                    {
                        _onTipRender.ExecuteTip(page.BodyPanel, "参数错误");
                        page.DataGridOrderList.DataContext = new List <CardOrderItemResponse>();
                    });
                    return;
                }
                #endregion

                #region 查询订单
                var resp = await _onOrderRequest.ExecuteQueryAsync(orderDataRequest);

                if (!(resp?.IsSuccess ?? false))
                {
                    _onControlRender.ThreadExecuteUI(() =>
                    {
                        _onTipRender.ExecuteTip(page.BodyPanel, resp?.Msg ?? "查询异常");
                        page.DataGridOrderList.DataContext = new List <CardOrderItemResponse>();
                    });
                    return;
                }
                #endregion

                #region 数据绑定

                _onControlRender.ThreadExecuteUI(() =>
                {
                    page.btnExport.IsEnabled  = (resp.Data?.Items?.Count ?? 0) > 0;
                    page.btnPrinter.IsEnabled = (resp.Data?.Items?.Count ?? 0) > 0;
                    page.btnRefund.IsEnabled  = (resp.Data?.Items?.Count ?? 0) > 0;
                    //if ((resp.Data?.Items?.Count ?? 0) > 0)
                    //{
                    _onControlRender.BindFrameworkElement(page.DataGridOrderList, resp.Data?.Items ?? null);
                    //}

                    if ((resp.Data?.Items?.Count ?? 0) <= 0)
                    {
                        page.SpPager.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        page.SpPager.Visibility = Visibility.Visible;
                    }

                    var sump                    = Convert.ToInt32(resp.Data?.Total ?? 0) % orderDataRequest.Rows;
                    var totalPage               = Convert.ToInt32(resp.Data?.Total ?? 0) / orderDataRequest.Rows + (sump > 0 ? 1 : 0);
                    page.labTotalPage.Content   = $"/{totalPage}";
                    page.labCurrentPage.Content = $"{orderDataRequest.PageIndex}";

                    page.labPrePage.Tag        = $"{orderDataRequest.PageIndex - 1}";
                    page.labPrePage.IsEnabled  = orderDataRequest.PageIndex > 1;
                    page.labNextPage.Tag       = $"{orderDataRequest.PageIndex + 1}";
                    page.labNextPage.IsEnabled = (orderDataRequest.PageIndex + 1) <= totalPage;
                    page.txbJumb.Tag           = totalPage;
                });
                #endregion
            }
            catch (Exception ex)
            {
                TextHelper.Error("RenderList 异常", ex);
                _onTipRender.ExecuteTip(page.BodyPanel, "查询异常[0001]");
            }
        }