添加项目文件。

This commit is contained in:
杨皓
2020-04-03 11:55:02 +08:00
parent f8a6829e30
commit d4e7a559f2
178 changed files with 20595 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="XXCpzs.Views.AboutPage"
xmlns:vm="clr-namespace:XXCpzs.ViewModels"
Title="{Binding Title}">
<ContentPage.BindingContext>
<vm:AboutViewModel />
</ContentPage.BindingContext>
<ContentPage.Resources>
<ResourceDictionary>
<Color x:Key="Primary">#2196F3</Color>
<Color x:Key="Accent">#96d1ff</Color>
<Color x:Key="LightTextColor">#999999</Color>
</ResourceDictionary>
</ContentPage.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackLayout BackgroundColor="{StaticResource Accent}" VerticalOptions="FillAndExpand" HorizontalOptions="Fill">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Center">
<ContentView Padding="0,40,0,40" VerticalOptions="FillAndExpand">
<Image Source="xamarin_logo.png" VerticalOptions="Center" HeightRequest="64" />
</ContentView>
</StackLayout>
</StackLayout>
<ScrollView Grid.Row="1">
<StackLayout Orientation="Vertical" Padding="16,40,16,40" Spacing="10">
<Label FontSize="22">
<Label.FormattedText>
<FormattedString>
<FormattedString.Spans>
<Span Text="AppName" FontAttributes="Bold" FontSize="22" />
<Span Text=" " />
<Span Text="1.0" ForegroundColor="{StaticResource LightTextColor}" />
</FormattedString.Spans>
</FormattedString>
</Label.FormattedText>
</Label>
<Label>
<Label.FormattedText>
<FormattedString>
<FormattedString.Spans>
<Span Text="This app is written in C# and native APIs using the" />
<Span Text=" " />
<Span Text="Xamarin Platform" FontAttributes="Bold" />
<Span Text="." />
</FormattedString.Spans>
</FormattedString>
</Label.FormattedText>
</Label>
<Label>
<Label.FormattedText>
<FormattedString>
<FormattedString.Spans>
<Span Text="It shares code with its" />
<Span Text=" " />
<Span Text="iOS, Android, and Windows" FontAttributes="Bold" />
<Span Text=" " />
<Span Text="versions." />
</FormattedString.Spans>
</FormattedString>
</Label.FormattedText>
</Label>
<Button Margin="0,10,0,0" Text="Learn more"
Command="{Binding OpenWebCommand}"
BackgroundColor="{StaticResource Primary}"
TextColor="White" />
</StackLayout>
</ScrollView>
</Grid>
</ContentPage>

View File

@@ -0,0 +1,18 @@
using System;
using System.ComponentModel;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace XXCpzs.Views
{
// Learn more about making custom code visible in the Xamarin.Forms previewer
// by visiting https://aka.ms/xamarinforms-previewer
[DesignTimeVisible(false)]
public partial class AboutPage : ContentPage
{
public AboutPage()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:views="clr-namespace:XXCpzs.Views"
x:Class="XXCpzs.Views.MainPage">
<MasterDetailPage.Master>
<views:MenuPage />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<NavigationPage.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS" Value="tab_feed.png"/>
</OnPlatform>
</NavigationPage.Icon>
<x:Arguments>
<views:PageMain />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>

View File

@@ -0,0 +1,98 @@
using RestSharp;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Xml;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.Models;
using XXCpzs.Services;
namespace XXCpzs.Views
{
[DesignTimeVisible(false)]
public partial class MainPage : MasterDetailPage
{
Dictionary<int, NavigationPage> MenuPages = new Dictionary<int, NavigationPage>();
public MainPage()
{
InitializeComponent();
MasterBehavior = MasterBehavior.Popover;
MenuPages.Add((int)MenuItemType.Browse, (NavigationPage)Detail);
}
public ServerVersion GetServerVer()
{
string version = "1.00";
string upAddresss = null;
string upContent = null;
string upTime = null;
var client = new RestClient{
BaseUrl = new Uri("http://cpzs.xixingwl.cn/cpzs.php/index/update/t/Droid.html"),
Timeout = 60000
};
var request = new RestRequest{
Timeout = 30000,
Method = Method.POST
};
request.AddHeader("Content-Type", "text/html,application/xhtml+xml,application/xml;q=0.9");
request.AddHeader("Authorization", "Bearer123456");
IRestResponse response2 = client.Execute(request);
if (response2.IsSuccessful){
XmlDocument sync = new XmlDocument();
sync.LoadXml(response2.Content.Trim());
XmlNode think = sync.SelectSingleNode("think");
version = think.SelectSingleNode("Version").InnerText;
upAddresss = think.SelectSingleNode(" UpAddresss").InnerText;
upContent = think.SelectSingleNode(" UpContent").InnerText;
upTime = think.SelectSingleNode(" UpTime").InnerText;
}
return new ServerVersion() { Version = version, UpAddresss = upAddresss ,UpContent = upContent, UpTime = upTime };
}
public async Task NavigateFromMenu(int id)
{
if (!MenuPages.ContainsKey(id))
{
switch (id)
{
case (int)MenuItemType.Browse:
MenuPages.Add(id, new NavigationPage(new PageMain()));
break;
case (int)MenuItemType.About:
MenuPages.Add(id, new NavigationPage(new AboutPage()));
break;
case (int)MenuItemType.Upgrade:
// var ServerVer = GetServerVer();
//string LocaVer = DependencyService.Get<ICommonService>().GetVersion();
//if (int.Parse(ServerVer.Version) > int.Parse(LocaVer))
//{
// bool answer = await DisplayAlert("检测到新的版本", "是否立即更新?" + ServerVer.Version, "Yes", "No");
// if (answer)
// {
// DependencyService.Get<ICommonService>().UpdateApp(ServerVer.UpAddresss);
// }
//}
break;
case (int)MenuItemType.CloseApp:
DependencyService.Get<ICommonService>().CloseApp();
break;
}
}
var newPage = MenuPages[id];
if (newPage != null && Detail != newPage)
{
Detail = newPage;
if (Device.RuntimePlatform == Device.Android)
await Task.Delay(100);
IsPresented = false;
}
}
}
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="XXCpzs.Views.MenuPage"
Title="Menu">
<StackLayout VerticalOptions="FillAndExpand">
<ListView x:Name="ListViewMenu"
HasUnevenRows="True">
<d:ListView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Item 1</x:String>
<x:String>Item 2</x:String>
</x:Array>
</d:ListView.ItemsSource>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="10">
<Label Text="{Binding Title}" d:Text="{Binding .}" FontSize="20"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>

View File

@@ -0,0 +1,42 @@
using XXCpzs.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace XXCpzs.Views
{
// Learn more about making custom code visible in the Xamarin.Forms previewer
// by visiting https://aka.ms/xamarinforms-previewer
[DesignTimeVisible(false)]
public partial class MenuPage : ContentPage
{
MainPage RootPage { get => Application.Current.MainPage as MainPage; }
List<HomeMenuItem> menuItems;
public MenuPage()
{
InitializeComponent();
menuItems = new List<HomeMenuItem>
{
new HomeMenuItem {Id = MenuItemType.Browse, Title="主页" },
new HomeMenuItem {Id = MenuItemType.About, Title="关于" },
new HomeMenuItem {Id = MenuItemType.Upgrade, Title="升级检测" } ,
new HomeMenuItem {Id = MenuItemType.CloseApp, Title="退出APP" }
};
ListViewMenu.ItemsSource = menuItems;
ListViewMenu.SelectedItem = menuItems[0];
ListViewMenu.ItemSelected += async (sender, e) =>
{
if (e.SelectedItem == null)
return;
var id = (int)((HomeMenuItem)e.SelectedItem).Id;
await RootPage.NavigateFromMenu(id);
};
}
}
}

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageAddCustomer">
<ContentPage.Content>
<StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text=" 公司:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="Company" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="联系人:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="Contacts" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="电话:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="Phone" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="邮件:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="Email" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="地址:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="Address" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="备注:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="Note" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<Button Text="立即添加" VerticalOptions="EndAndExpand" Clicked="Button_Clicked"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.Models;
using XXCpzs.ViewModels;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageAddCustomer : ContentPage
{
//id uid companyId departmentId diviceId contacts phone email address company note create_time update_time
private AddCustomerModel ViewModel;
private UserInfo userInfo;
private int DeviceId = 1;
public PageAddCustomer(UserInfo userInfo)
{
InitializeComponent();
this.userInfo = userInfo;
this.BindingContext = ViewModel = new AddCustomerModel(userInfo.uid);
}
private async void Button_Clicked(object sender, EventArgs e)
{
if (Company.Text == null)
{
await DisplayAlert("提示:", "客户企业名不能为空!", "确定");
return;
}
if (Contacts.Text == null)
{
await DisplayAlert("提示:", "客户联系人不能为空!", "确定");
return;
}
if (Phone.Text == null)
{
await DisplayAlert("提示:", "客户电话不能为空!", "确定");
return;
}
bool response = await DisplayAlert("提示:", "确认添加?", "Yes", "No");
if (response)
{
var request = HttpHelper.Refresh<Customer>("addcustomer",
new Dictionary<string, string>{
{"Uid", userInfo.uid.ToString()},
{"Company", Company.Text.Trim()},
{"Contacts",Contacts.Text.Trim()},
{"Phone", Phone.Text.Trim()},
{"Email", Email.Text},
{"Address", Address.Text},
{"Note", Note.Text},
{"deviceId", this.DeviceId.ToString()}
});
if (request.Code != 0)
{
MessagingCenter.Send(this, "AddCustomer", request.Data as Customer);
await Navigation.PopModalAsync();
}
}
}
}
}

View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageChaXun">
<ContentPage.Content>
<ScrollView>
<StackLayout Spacing="0" Padding="0" BackgroundColor="GreenYellow">
<StackLayout Orientation="Horizontal" HeightRequest="50" BackgroundColor="White" Padding="5">
<StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="Start">
<BoxView BackgroundColor="Black" WidthRequest="40" HeightRequest="40" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
<Label FontSize="14" TextColor="Black" Text="Accent Color" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
</StackLayout>
<StackLayout Spacing="0" BackgroundColor="White" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
<BoxView BackgroundColor="Maroon" WidthRequest="40" HeightRequest="40" HorizontalOptions="Start" VerticalOptions="Center" />
<Label FontSize="14" TextColor="Black" Text="Primary Color" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
</StackLayout>
</StackLayout>
<StackLayout Orientation="Vertical" BackgroundColor="Silver" Padding="5">
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="S N 码:" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
<Entry HorizontalOptions="FillAndExpand" Text="35" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="供应商家:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin.Forms"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="产品名称:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100"/>
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin, C#, .NET, Mono..."/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="保修时长:" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
<Entry HorizontalOptions="FillAndExpand" Text="35" />
</StackLayout>
</StackLayout>
<StackLayout Orientation="Vertical" BackgroundColor="White" Padding="5">
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="入库时间:" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin.Forms"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="入库人员:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100"/>
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin, C#, .NET, Mono..."/>
</StackLayout>
</StackLayout>
<StackLayout Orientation="Vertical" BackgroundColor="Silver" Padding="5">
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="入仓时间:" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
<Entry HorizontalOptions="FillAndExpand" Text="35" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="入仓人员:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin.Forms"/>
</StackLayout>
</StackLayout>
<StackLayout Orientation="Vertical" BackgroundColor="White" Padding="5">
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="出仓日期:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100"/>
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin, C#, .NET, Mono..."/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="出仓人员:" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
<Entry HorizontalOptions="FillAndExpand" Text="35" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="出仓目标:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin.Forms"/>
</StackLayout>
</StackLayout>
<StackLayout Orientation="Vertical" BackgroundColor="Silver" Padding="5">
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="销售日期:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100"/>
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin, C#, .NET, Mono..."/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="销售人员:" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
<Entry HorizontalOptions="FillAndExpand" Text="35" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="购买客户:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin.Forms"/>
</StackLayout>
</StackLayout>
<StackLayout Orientation="Vertical" BackgroundColor="White" Padding="5">
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="返修日期:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100"/>
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin, C#, .NET, Mono..."/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="返修人员:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100"/>
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin, C#, .NET, Mono..."/>
</StackLayout>
</StackLayout>
<StackLayout Orientation="Vertical" BackgroundColor="Silver" Padding="5">
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="换货日期:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100"/>
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin, C#, .NET, Mono..."/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontSize="14" Text="换货人员:"
HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100"/>
<Entry HorizontalOptions="FillAndExpand" Text="Xamarin, C#, .NET, Mono..."/>
</StackLayout>
</StackLayout>
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,21 @@

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.Models;
using XXCpzs.ViewModels;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageChaXun : ContentPage
{
private ChaXunViewModel ViewModel;
private PageMain pageMain;
public PageChaXun(UserInfo userInfo )
{
InitializeComponent();
this.BindingContext = ViewModel = new ChaXunViewModel();
}
}
}

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageChuCang">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text=" 序 列 号:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="SerialNumber" HorizontalOptions="FillAndExpand" />
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray">
<Label Text="发货目标:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25"/>
<Picker x:Name="BrandPicker"
ItemsSource="{Binding CangKuItems}"
FontSize="20"
ItemDisplayBinding="{Binding title}"
Title="请选择发货目标"
HorizontalOptions="FillAndExpand"
SelectedIndexChanged="OnBumenPickerSelectedIndexChangedAsync"
TitleColor="Red">
</Picker>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray">
<Label Text="备注:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="NewSerialNumber" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" BackgroundColor="SlateGray">
<ListView BackgroundColor="GreenYellow"
ItemsSource="{Binding Items , Mode=OneWay}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
CachingStrategy="RecycleElement" >
<ListView.Header>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="ID" HorizontalOptions="Start"
LineBreakMode="NoWrap"
FontSize="16" />
<Label Text="序列号" HorizontalOptions="CenterAndExpand"
LineBreakMode="NoWrap"
FontSize="13" />
<Label Text="提交结果" HorizontalOptions="EndAndExpand"
LineBreakMode="NoWrap"
FontSize="13" />
</StackLayout>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="{Binding Code}" HorizontalOptions="Start"
LineBreakMode="NoWrap" d:Text="ID"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Data}" HorizontalOptions="CenterAndExpand"
d:Text="序列号"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<Label Text="{Binding Msg}" HorizontalOptions="EndAndExpand"
d:Text="提交结果"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End" BackgroundColor="Gray">
<Button Text="提 交" HorizontalOptions="FillAndExpand" Clicked="Button_ClickedAsync"/>
<Button Text="扫码提交" HorizontalOptions="FillAndExpand" Clicked="OnScan"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,90 @@
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.Models;
using XXCpzs.ViewModels;
using ZXing.Mobile;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageChuCang : ContentPage
{
ChuCangViewModel ViewModel;
private int Uid = 0;
private int MubiaoId = 0;
private int deviceId = 1;
private UserInfo userInfo;
public PageChuCang(UserInfo userInfo)
{
InitializeComponent();
this.Uid = userInfo.uid;
this.userInfo = userInfo;
this.BindingContext = ViewModel = new ChuCangViewModel(userInfo);
}
void OnBumenPickerSelectedIndexChangedAsync(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
MubiaoId = ViewModel.CangKuItems[selectedIndex].id;
}
}
private async void Button_ClickedAsync(object sender, EventArgs e)
{
if (this.MubiaoId == 0)
{
await DisplayAlert("注意", "请选择产品要发往的目的地", "OK"); return;
}
if (Uid != 0 && SerialNumber.Text != string.Empty)
{
Dictionary<string, string> _body = new Dictionary<string, string>{
{"Sn", SerialNumber.Text},
{"Uid", this.Uid.ToString()},
{"MubiaoId", this.MubiaoId.ToString()},
{"deviceId", this.deviceId.ToString()}
};
var request = await HttpHelper.RequestPost(12, _body);
if (request.Code == 200){
ViewModel.Items.Add(new ResultModel() { Code = request.Code, Data = request.Data, Msg = request.Msg });
}
else{
await DisplayAlert("访问出错", request.Msg, "OK");
}
}
}
private async void OnScan(object sender, EventArgs e)
{
if (await CheckPerssion())
{
var scanner = new MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
{
SerialNumber.Text = result.Text;
}
}
}
private async Task<bool> CheckPerssion()
{
var current = CrossPermissions.Current;
//检查权限
var status = await current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
var result = await current.RequestPermissionsAsync(Permission.Camera);
status = result[Permission.Camera];
}
return status == PermissionStatus.Granted;
}
}
}

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageCustomer">
<ContentPage.Content>
<StackLayout>
<ListView x:Name="ContextDemoList" VerticalOptions="FillAndExpand" BackgroundColor="SeaGreen">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Clicked="OnMore" CommandParameter="{Binding .}" Text="More" />
<MenuItem Clicked="OnDelete" CommandParameter="{Binding .}" Text="Delete" IsDestructive="True" />
</ViewCell.ContextActions>
<StackLayout Padding="15,0">
<Label Text="{Binding title}" />
<Label Text="{Binding title}" />
<Label Text="{Binding title}" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,35 @@
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.Models;
using XXCpzs.ViewModels;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageCustomer : ContentPage
{
private CustomerViewModel ViewModel;
public PageCustomer(UserInfo userInfo)
{
InitializeComponent();
this.BindingContext = ViewModel = new CustomerViewModel();
}
public void OnMore(object sender, EventArgs e)
{
var mi = ((MenuItem)sender);
DisplayAlert("More Context Action", mi.CommandParameter + " more context action", "OK");
}
public void OnDelete(object sender, EventArgs e)
{
var mi = ((MenuItem)sender);
DisplayAlert("Delete Context Action", mi.CommandParameter + " delete context action", "OK");
}
}
}

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageCustomerSelect">
<ContentPage.Content>
<StackLayout>
<SearchBar x:Name="searchBar"
HorizontalOptions="Fill"
VerticalOptions="CenterAndExpand"
Placeholder="Search fruits..."
CancelButtonColor="Orange"
HorizontalTextAlignment="Start"
TextChanged="OnTextChanged"/>
<ListView x:Name="searchResults"
HorizontalOptions="Fill"
VerticalOptions="CenterAndExpand"
ItemSelected="searchResults_ItemSelectedAsync">
<ListView.Header>
<StackLayout Orientation="Horizontal">
<Label Text="企业名" HorizontalOptions="Start" />
<Label Text="联系人" HorizontalOptions="CenterAndExpand"/>
<Label Text="电话" HorizontalOptions="CenterAndExpand"/>
</StackLayout>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="{Binding company}" HorizontalOptions="Start"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding contacts}" HorizontalOptions="CenterAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<Label Text="{Binding phone}" HorizontalOptions="End"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Text="添加" Clicked="Button_Clicked" VerticalOptions="EndAndExpand"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.Models;
using XXCpzs.Services;
using XXCpzs.ViewModels;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageCustomerSelect : ContentPage
{
SearchViewModel ViewModel;
private UserInfo userInfo;
public PageCustomerSelect(UserInfo userInfo)
{
InitializeComponent();
this.userInfo = userInfo;
this.BindingContext = ViewModel = new SearchViewModel(userInfo.uid, this);
searchResults.ItemsSource = CustomerDataService.GetSearchResults(searchBar.Text);
}
void OnTextChanged(object sender, TextChangedEventArgs e)
{
searchResults.ItemsSource = CustomerDataService.GetSearchResults(e.NewTextValue);
}
private async void searchResults_ItemSelectedAsync(object sender, SelectedItemChangedEventArgs e)
{
if (e.SelectedItem != null)
{
Customer customer = e.SelectedItem as Customer;
bool response = await DisplayAlert("Item Selected", customer.company, "Yes", "No");
if (response)
{
MessagingCenter.Send(this, "SelectCustomer", customer);
await Navigation.PopModalAsync();
}
}
}
private async void Button_Clicked(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new NavigationPage(new PageAddCustomer(userInfo)));
}
public void Refresh()
{
searchResults.ItemsSource = CustomerDataService.GetSearchResults(searchBar.Text);
}
}
}

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageDaBao">
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="Auto" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Text="产品名:" VerticalTextAlignment="Center" FontSize="25" Grid.Column="0" Grid.Row="0" />
<Picker x:Name="TypePicker"
ItemsSource="{Binding dabaoTypes}"
ItemDisplayBinding="{Binding name}"
Title="请选择产品名称"
SelectedIndexChanged="TypePicker_SelectedIndexChanged"
FontSize="20"
TitleColor="Red"
Grid.Column="1" Grid.Row="0">
</Picker>
<Label Text="供应商:" VerticalTextAlignment="Center" FontSize="25" Grid.Column="0" Grid.Row="1"/>
<Picker x:Name="BrandPicker" Grid.Column="1" Grid.Row="1"
ItemsSource="{Binding dabaoBrands}"
FontSize="20"
ItemDisplayBinding="{Binding company}"
Title="请选择供应商"
SelectedIndexChanged="BrandPicker_SelectedIndexChanged"
TitleColor="Red">
</Picker>
<Label Text="序列号:" VerticalTextAlignment="Center" FontSize="25" Grid.Column="0" Grid.Row="2" />
<Editor Grid.Column="1" x:Name="SerialNumber" FontSize="25" Grid.Row="2"/>
<ListView Grid.Column="0" Grid.Row="3" Grid.RowSpan="2" Grid.ColumnSpan="2"
BackgroundColor="GreenYellow"
ItemsSource="{Binding Items , Mode=OneWay}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="{Binding Code}" HorizontalOptions="Start"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Data}" HorizontalOptions="CenterAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<Label Text="{Binding Msg}" HorizontalOptions="EndAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Text="提交" Grid.Column="0" Grid.Row="5" Clicked="Button_Clicked"/>
<Button Text="扫描二维码" Grid.Column="1" Grid.Row="5" Clicked="OnScan"/>
</Grid>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,115 @@
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.Models;
using XXCpzs.ViewModels;
using ZXing.Mobile;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageDaBao : ContentPage
{
DabaoViewModel ViewModel;
private int BrandId = 0;
private int TypeId = 0;
private int Uid = 0;
private int deviceId = 1;
private UserInfo userInfo;
public PageDaBao(UserInfo userInfo)
{
InitializeComponent();
this.Uid = userInfo.uid;
this.userInfo = userInfo;
this.BindingContext = ViewModel = new DabaoViewModel(Uid);
}
private void TypePicker_SelectedIndexChanged(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
TypeId = ViewModel.dabaoTypes[selectedIndex].id;
}
}
private void BrandPicker_SelectedIndexChanged(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
BrandId = ViewModel.dabaoBrands[selectedIndex].id;
}
}
private async void Button_Clicked(object sender, EventArgs e)
{
if (BrandId != 0 && TypeId != 0 && Uid != 0 && SerialNumber.Text != string.Empty)
{
Dictionary<string, string> _body = new Dictionary<string, string>{
{"Sn", SerialNumber.Text},
{"typeId",this.TypeId.ToString() },
{"brandId", this.BrandId.ToString() },
{"Uid", this.Uid.ToString()},
{"deviceId", this.deviceId.ToString()}
};
var request = await HttpHelper.RequestPost(09, _body);
if (request.Code == 200)
{
ViewModel.Items.Add(new ResultModel() { Code = request.Code, Data = request.Data, Msg = request.Msg });
}
else
{
await DisplayAlert("访问出错", request.Msg, "OK");
//Button_ClickedAsync(sender, e);
}
}
}
private async void OnScan(object sender, EventArgs e)
{
if (this.BrandId == 0 )
{
await DisplayAlert("注意","请选择产品供应商", "OK"); return;
}
if ( this.TypeId == 0)
{
await DisplayAlert("访问出错", "请选择产品名称", "OK"); return;
}
if (await CheckPerssion())
{
var scanner = new MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
{
SerialNumber.Text = result.Text;
Button_Clicked(sender, e);
}
}
}
private async Task<bool> CheckPerssion()
{
var current = CrossPermissions.Current;
//检查权限
var status = await current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
var result = await current.RequestPermissionsAsync(Permission.Camera);
status = result[Permission.Camera];
}
return status == PermissionStatus.Granted;
}
}
}

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageFanXiu">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="序列号:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="SerialNumber" HorizontalOptions="FillAndExpand" />
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray">
<Label Text="再销原因:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" Grid.Column="0" Grid.Row="1"/>
<Picker x:Name="BrandPicker" FontSize="20"
ItemsSource="{Binding CauseItems}"
ItemDisplayBinding="{Binding title}"
SelectedIndexChanged="OnCauseSelectedIndexChangedAsync"
Title="默认原因"
HorizontalOptions="FillAndExpand"
TitleColor="Red">
</Picker>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="备注:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="Note" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" BackgroundColor="Gray">
<ListView ItemsSource="{Binding Items , Mode=OneWay}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="{Binding Code}" HorizontalOptions="Start"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Data}" HorizontalOptions="CenterAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<Label Text="{Binding Msg}" HorizontalOptions="EndAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End" BackgroundColor="SlateGray">
<Button Text="提交" HorizontalOptions="FillAndExpand" Clicked="Button_ClickedAsync"/>
<Button Text="扫码提交" HorizontalOptions="FillAndExpand" Clicked="OnScan"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,93 @@
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.Models;
using XXCpzs.ViewModels;
using ZXing.Mobile;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageFanXiu : ContentPage
{
private FanXiuViewModel ViewModel;
private int CauseId = 1;
private UserInfo userInfo;
private int DeviceId = 1;
public PageFanXiu(UserInfo userInfo)
{
InitializeComponent();
this.userInfo = userInfo;
this.BindingContext = ViewModel = new FanXiuViewModel(userInfo.uid);
}
void OnCauseSelectedIndexChangedAsync(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
CauseId = ViewModel.CauseItems[selectedIndex].id;
}
}
private async void Button_ClickedAsync(object sender, EventArgs e)
{
if (this.CauseId == 0)
{
await DisplayAlert("注意", "请选择产品 返修的原因 ", "OK"); return;
}
if (userInfo != null && SerialNumber.Text != null)
{
var request = await HttpHelper.RequestPost(19,
new Dictionary<string, string>{
{"Sn", SerialNumber.Text},
{"Uid", userInfo.uid.ToString()},
{"CauseId", CauseId.ToString()},
{"deviceId", this.DeviceId.ToString()}
});
if (request.Code == 200)
{
ViewModel.Items.Add(new ResultModel() { Code = request.Code, Data = request.Data, Msg = request.Msg });
}
else
{
await DisplayAlert("访问出错", request.Msg, "OK");
}
}
}
private async void OnScan(object sender, EventArgs e)
{
if (await CheckPerssion())
{
var scanner = new MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
{
SerialNumber.Text = result.Text;
Button_ClickedAsync(sender, e);
}
}
}
private async Task<bool> CheckPerssion()
{
var current = CrossPermissions.Current;
//检查权限
var status = await current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
var result = await current.RequestPermissionsAsync(Permission.Camera);
status = result[Permission.Camera];
}
return status == PermissionStatus.Granted;
}
}
}

View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="XXCpzs.Views.PageHuanHuo">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="序列号:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="SerialNumber" HorizontalOptions="FillAndExpand" />
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="新序列号:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="NewSerialNumber" HorizontalOptions="FillAndExpand" />
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray">
<Label Text="再销原因:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" Grid.Column="0" Grid.Row="1"/>
<Picker x:Name="BrandPicker" FontSize="20"
ItemsSource="{Binding CauseItems}"
ItemDisplayBinding="{Binding title}"
SelectedIndexChanged="OnCauseSelectedIndexChangedAsync"
Title="默认原因"
HorizontalOptions="FillAndExpand"
TitleColor="Red">
</Picker>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="备注:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="Note" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" BackgroundColor="Gray">
<ListView ItemsSource="{Binding Items , Mode=OneWay}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="{Binding Code}" HorizontalOptions="Start"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Data}" HorizontalOptions="CenterAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<Label Text="{Binding Msg}" HorizontalOptions="EndAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End" BackgroundColor="SlateGray">
<Button Text="提交" HorizontalOptions="FillAndExpand" Clicked="Button_ClickedAsync"/>
<Button Text="扫码提交" HorizontalOptions="FillAndExpand" Clicked="OnScan"/>
<Button Text="扫码提交" HorizontalOptions="FillAndExpand" Clicked="OnScan1"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,103 @@
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.Models;
using XXCpzs.ViewModels;
using ZXing.Mobile;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageHuanHuo : ContentPage
{
private HuanHuoViewModel ViewModel;
private int CauseId = 1;
private UserInfo userInfo;
private int DeviceId = 1;
public PageHuanHuo(UserInfo userInfo)
{
InitializeComponent();
this.userInfo = userInfo;
this.BindingContext = ViewModel = new HuanHuoViewModel(userInfo.uid);
}
private void OnCauseSelectedIndexChangedAsync(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
CauseId = ViewModel.CauseItems[selectedIndex].id;
}
}
private async void Button_ClickedAsync(object sender, EventArgs e)
{
if (this.CauseId == 0)
{
await DisplayAlert("注意", "请选择产品 换货 的原因", "OK"); return;
}
if (userInfo == null && userInfo.uid != 0 && SerialNumber.Text != string.Empty && NewSerialNumber.Text != string.Empty)
{
var request = await HttpHelper.RequestPost(20,
new Dictionary<string, string>{
{"Sn", SerialNumber.Text},
{"NewSn", NewSerialNumber.Text},
{"Uid", userInfo.uid.ToString()},
{"CauseId", CauseId.ToString()},
{"deviceId", this.DeviceId.ToString()}
});
if (request.Code == 200)
{
ViewModel.Items.Add(new ResultModel() { Code = request.Code, Data = request.Data, Msg = request.Msg });
}
else
{
await DisplayAlert("访问出错", request.Msg, "OK");
}
}
}
private async void OnScan(object sender, EventArgs e)
{
if (await CheckPerssion())
{
var scanner = new MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
{
SerialNumber.Text = result.Text;
}
}
}
private async void OnScan1(object sender, EventArgs e)
{
if (await CheckPerssion())
{
var scanner = new MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
{
NewSerialNumber.Text = result.Text;
}
}
}
private async Task<bool> CheckPerssion()
{
var current = CrossPermissions.Current;
//检查权限
var status = await current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
var result = await current.RequestPermissionsAsync(Permission.Camera);
status = result[Permission.Camera];
}
return status == PermissionStatus.Granted;
}
}
}

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="XXCpzs.Views.PageLogin">
<pages:PopupPage.Resources>
<ResourceDictionary>
<Color x:Key="Primary">#2196F3</Color>
</ResourceDictionary>
</pages:PopupPage.Resources>
<pages:PopupPage.Animation>
<animations:ScaleAnimation DurationIn="400"
DurationOut="300"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True"
PositionIn="Center"
PositionOut="Center"
ScaleIn="1.2"
ScaleOut="0.8" />
</pages:PopupPage.Animation>
<Frame CornerRadius="20" BackgroundColor="White" VerticalOptions="Center" Margin="40,20" HeightRequest="400">
<StackLayout >
<Label Text="部门:" VerticalOptions="CenterAndExpand" />
<Picker x:Name="BumenPicker"
ItemDisplayBinding="{Binding title}"
ItemsSource="{Binding BuMenItems}"
Title="Select a monkey"
SelectedIndexChanged="OnBumenPickerSelectedIndexChangedAsync"
TitleColor="Red" />
<Label Text="用户名:" VerticalOptions="CenterAndExpand" />
<Picker x:Name="UserPicker"
ItemDisplayBinding="{Binding realname}"
ItemsSource="{Binding UserItems}"
Title="Select a User Name"
TitleColor="Red"
SelectedIndexChanged="UserPicker_SelectedIndexChanged"/>
<Label Text="密码:" IsEnabled="False" VerticalOptions="CenterAndExpand" />
<Entry x:Name="UserPass" Placeholder="" IsPassword="True" />
<StackLayout Orientation="Horizontal">
<Label Text="记住密码?" HorizontalOptions ="StartAndExpand" />
<Switch IsToggled="false" HorizontalOptions="EndAndExpand" />
</StackLayout>
<Label Text="{Binding ValidateMsg}" TextColor="Red" HorizontalOptions="Center"/>
<Button Margin="0,10,0,0"
Text="登录"
BackgroundColor="{StaticResource Primary}"
TextColor="White"
HeightRequest="50"
VerticalOptions="Start"
Clicked="Button_ClickedAsync"/>
<Label Text="没有账号?请联系管理员。" HorizontalOptions="Center" FontSize="12"/>
</StackLayout>
</Frame>
</pages:PopupPage>

View File

@@ -0,0 +1,88 @@
using Acr.UserDialogs;
using Rg.Plugins.Popup.Pages;
using Rg.Plugins.Popup.Services;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.Models;
using XXCpzs.ViewModels;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageLogin : PopupPage
{
LoginViewModel ViewModel;
private int Uid;
private PageMain pageMain;
public PageLogin(PageMain pageMain)
{
InitializeComponent();
this.pageMain = pageMain;
this.BindingContext = ViewModel = new LoginViewModel(pageMain.companyId);
}
void OnBumenPickerSelectedIndexChangedAsync(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
DepartmentItem buMen = ViewModel.BuMenItems[selectedIndex] as DepartmentItem;
Dictionary<string, string> _body = new Dictionary<string, string>{
{ "companyId", pageMain.companyId.ToString() },{"departmentId", buMen.id.ToString() }
};
List<UserItem> buMens = HttpHelper.RefreshData<UserItem>(04, RestSharp.Method.POST, _body);
ViewModel.UserItems = new ObservableCollection<UserItem>();
foreach (var item in buMens)
{
ViewModel.UserItems.Add(item);
}
UserPicker.ItemsSource = ViewModel.UserItems;
}
}
private void UserPicker_SelectedIndexChanged(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
this.Uid = ViewModel.UserItems[selectedIndex].uid;
}
}
async void Button_ClickedAsync(object sender, EventArgs e)
{
UserDialogs.Instance.ShowLoading("正在登录,请稍后!");
new Thread(new ThreadStart(async () =>
{
Dictionary<string, string> _body = new Dictionary<string, string>{
{ "Uid", this.Uid.ToString() },{"Password", UserPass.Text.Trim() }
};
var Result = HttpHelper.Refresh<UserInfo>("login", _body);
if (Result.Code == 200)
{
Device.BeginInvokeOnMainThread(() =>{
UserInfo LoginResult = Result.Data;
pageMain.Loginback(LoginResult);
UserDialogs.Instance.HideLoading();
});
await PopupNavigation.Instance.PopAsync();
}
else
{
await DisplayAlert("访问出错", Result.Msg, "OK");
//Button_ClickedAsync(sender, e);
}
})).Start();
}
}
}

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageMain">
<ContentPage.Content>
<StackLayout>
<StackLayout Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Orientation="Vertical">
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<Entry x:Name="LabelCompany" IsEnabled="False" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" HorizontalOptions="FillAndExpand" Text="{Binding CompanyName}" />
</StackLayout>
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<Entry x:Name="LabelDepartment" IsEnabled="False" HorizontalOptions="FillAndExpand" Text="{Binding Department}"/>
<Entry x:Name="LabelUserName" IsEnabled="False" HorizontalOptions="FillAndExpand" Text="{Binding UserName}"/>
</StackLayout>
</StackLayout>
<!--定义网格行间隙为2列间隙为2-->
<Grid x:Name="Grid121" VerticalOptions="FillAndExpand" RowSpacing="5" ColumnSpacing="5" BackgroundColor="#A8A8A8">
<!--定义一个5行4列的表格-->
<Grid.RowDefinitions>
<!--设置行高为100-->
<!--减去行高100后按照1/10高度此网格定义了10计算-->
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<!--按照1/5宽度此网格定义了5计算-->
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<!--按照2/5宽度此网格定义了5计算-->
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--设置元素在网格的第0行0列-->
<ImageButton x:Name="ImageButtonLogin" IsEnabled="False"
Grid.Row="1" Grid.Column="1"
Aspect="AspectFit"
Source="ico_login.png"
Clicked="ImageButtonLogin_Clicked"/>
<ImageButton x:Name="ImageButtonRegister"
Grid.Row="2" Grid.Column="1"
Aspect="AspectFit" IsEnabled="False"
Clicked="ImageButtonRegister_Clicked"
Source="ico_Register.png"/>
<!--<ImageButton Grid.Row="3" Grid.Column="1"
Aspect="AspectFit"
Clicked="ImageButtonQuit_Clicked"
Source="ico_Quit.png"/>-->
</Grid>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,252 @@

using Acr.UserDialogs;
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using Rg.Plugins.Popup.Services;
using System;
using System.Collections.Generic;
using System.Threading;
using Xamarin.Essentials;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.IOInterface;
using XXCpzs.Models;
using XXCpzs.Services;
using XXCpzs.ViewModels;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageMain : ContentPage, InterfaceLogin
{
MainViewModel ViewModel;
public int companyId;
private UserInfo userInfo;
private async System.Threading.Tasks.Task<bool> CheckPerssion()
{
var current = CrossPermissions.Current;
//检查权限
var status = await current.CheckPermissionStatusAsync(Permission .Camera );
if (status != PermissionStatus.Granted)
{
var result = await current.RequestPermissionsAsync(Permission.Camera);
status = result[Permission.Camera];
}
return status == PermissionStatus.Granted;
}
public PageMain()
{
InitializeComponent();
this.BindingContext = ViewModel = new MainViewModel();
if ( CheckPerssion().Result)
{
// var networkConnection = DependencyService.Get<INetworkConnection>();
// networkConnection.CheckNetworkConnection();
// var networkStatus = networkConnection.IsConnected ? "链接" : "未连接";
var current = Connectivity.NetworkAccess;
if (current == NetworkAccess.Internet){
// IsConnected = true;
//DisplayAlert("Alert", "网络连接成功", "OK");
DependencyService.Get<ICommonService>().SendNotity("通知", "网络连接成功");
}
else{
DisplayAlert("Alert", "网络连接失败", "OK");
}
}
Button refresh = new Button
{
Text = "点击刷新",
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
};
refresh.Clicked += (sender, e) =>
{
try
{
if (DependencyService.Get<INetworkConnection>().IsConnected)
{
Navigation.PushAsync(new MainPage());
}
else
{
}
}
catch (Exception ex)
{
}
};
}
protected override void OnAppearing() {
base.OnAppearing();
UserDialogs.Instance.ShowLoading("加载中");
new Thread(new ThreadStart(() =>
{
var Result = HttpHelper.Refresh<AuthorizeItem>("noun", new Dictionary<string, string>{
{ "appid", "98573393804132392" },
{ "appkey", "9010137b2c292b39757f94ee434e9d5a" },
{ "device", "Droid" }
});
if (Result.Code == 200)
{
Device.BeginInvokeOnMainThread(async () =>
{
ViewModel.Authorize = Result.Data;
ViewModel.CompanyName = ViewModel.Authorize.companyName;
companyId = ViewModel.Authorize.companyId;
ImageButtonLogin.IsEnabled = true;
ImageButtonRegister.IsEnabled = true;
string LocaVer = DependencyService.Get<ICommonService>().GetVersion();
if (Convert.ToDecimal(ViewModel.Authorize.ServerVer.Version) > Convert.ToDecimal(LocaVer))
{
bool answer = await DisplayAlert("检测到新的版本", "是否立即更新?" + ViewModel.Authorize.ServerVer.UpContent, "Yes", "No");
if (answer)
{
DependencyService.Get<ICommonService>().UpdateApp(ViewModel.Authorize.ServerVer.UpAddresss);
}
}
ITextToSpeechService service = DependencyService.Get<ITextToSpeechService>(DependencyFetchTarget.NewInstance);
using (service as IDisposable) {
service.SpeakAsync("Welcome to use");
}
UserDialogs.Instance.HideLoading();
});
}
})).Start();
}
//获取权限
int r = 0;
int c = 0;
public void Loginback(UserInfo userInfo)
{
if (userInfo == null)
return;
r = 0;
c = 0;
MessagingCenter.Unsubscribe<PageRegister, string>(this, "RegisteResult");
Grid121.Children.Clear();
this.userInfo = userInfo;
ViewModel.Department = this.userInfo.departmentName;
ViewModel.UserName = this.userInfo.realname;
CpzsPowers cpzsPowers = this.userInfo.CpzsPowers;
//{"uid":1,"cx":1,"db":1,"rc":1,"cc":1,"xs":1,"fx":1,"hh":1,"th":1,"rs":1,"
if (cpzsPowers.cx == 1)
AddImageButton("cx");
if (cpzsPowers.kh == 1)
AddImageButton("kh");
if (cpzsPowers.dd == 1)
AddImageButton("dd");
if (cpzsPowers.db == 1)
AddImageButton("db");
if (cpzsPowers.rc == 1)
AddImageButton("rc");
if (cpzsPowers.cc == 1)
AddImageButton("cc");
if (cpzsPowers.xs == 1)
AddImageButton("xs");
if (cpzsPowers.rs == 1)
AddImageButton("rs");
if (cpzsPowers.fx == 1)
AddImageButton("fx");
if (cpzsPowers.hh == 1)
AddImageButton("hh");
if (cpzsPowers.th == 1)
AddImageButton("th");
ImageButton imageButton = new ImageButton
{
Aspect = Aspect.AspectFit,
};
Grid121.Children.Add(imageButton);
Grid.SetRow(imageButton, 3);
Grid.SetColumn(imageButton, 2);
}
private void AddImageButton(string fun)
{
ImageButton imageButton = new ImageButton
{
Aspect = Aspect.AspectFit,
};
switch (fun)
{
case "dd":
imageButton.Source = "ico_order.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageOrder(userInfo)); };
break;
case "kh":
imageButton.Source = "ico_customer.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageCustomer(userInfo)); };
break;
case "cx":
imageButton.Source = "ico_search.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageChaXun(userInfo)); };
break;
case "db":
imageButton.Source = "ico_pack.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageDaBao(userInfo)); };
break;
case "rc":
imageButton.Source = "ico_cangku.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageRuCang(userInfo)); };
break;
case "cc":
imageButton.Source = "ico_chucang.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageChuCang(userInfo)); };
break;
case "xs":
imageButton.Source = "ico_sale.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageSale(userInfo)); };
break;
case "rs":
imageButton.Source = "ico_resale.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageResale(userInfo)); };
break;
case "fx":
imageButton.Source = "ico_weixiu.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageFanXiu(userInfo)); };
break;
case "hh":
imageButton.Source = "ico_hh.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageHuanHuo(userInfo)); };
break;
case "th":
imageButton.Source = "ico_th.png";
imageButton.Clicked += async (s, args) => { await Navigation.PushAsync(new PageTuiHuo(userInfo)); };
break;
default:
break;
}
Grid121.Children.Add(imageButton);
Grid.SetRow(imageButton, r);
Grid.SetColumn(imageButton, c);
if (c < 2) { c++; }
else { c = 0; r++; }
}
public async void ImageButtonLogin_Clicked(object sender, EventArgs e)
{
await PopupNavigation.Instance.PushAsync(new PageLogin(this));
}
private async void ImageButtonRegister_Clicked(object sender, EventArgs e)
{
await PopupNavigation.Instance.PushAsync(new PageRegister(this));
}
}
public delegate void ChangeLoadingClosd();
}

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageOrder">
<ContentPage.Content>
<StackLayout>
<ListView x:Name="ContextDemoList" VerticalOptions="FillAndExpand" BackgroundColor="SeaGreen">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Clicked="OnMore" CommandParameter="{Binding .}" Text="More" />
<MenuItem Clicked="OnDelete" CommandParameter="{Binding .}" Text="Delete" IsDestructive="True" />
</ViewCell.ContextActions>
<StackLayout Padding="15,0">
<Label Text="{Binding title}" />
<Label Text="{Binding title}" />
<Label Text="{Binding title}" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,35 @@
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.Models;
using XXCpzs.ViewModels;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageOrder : ContentPage
{
private OrderViewModel ViewModel;
public PageOrder(UserInfo userInfo)
{
InitializeComponent();
this.BindingContext = ViewModel = new OrderViewModel();
}
public void OnMore(object sender, EventArgs e)
{
var mi = ((MenuItem)sender);
DisplayAlert("More Context Action", mi.CommandParameter + " more context action", "OK");
}
public void OnDelete(object sender, EventArgs e)
{
var mi = ((MenuItem)sender);
DisplayAlert("Delete Context Action", mi.CommandParameter + " delete context action", "OK");
}
}
}

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageRegister">
<pages:PopupPage.Animation>
<animations:ScaleAnimation DurationIn="400"
DurationOut="300"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True"
PositionIn="Center"
PositionOut="Center"
ScaleIn="1.2"
ScaleOut="0.8" />
</pages:PopupPage.Animation>
<Frame CornerRadius="20" BackgroundColor="White" VerticalOptions="Center" Margin="40,10" HeightRequest="400">
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" BackgroundColor="Gray" VerticalOptions="Center">
<Label Text="部门:" VerticalTextAlignment="Center" FontSize="25" HorizontalOptions="Start"/>
<Picker x:Name="Picker_Section"
ItemsSource="{Binding BuMenItems}"
FontSize="20"
ItemDisplayBinding="{Binding title}"
Title=" 选择部门"
HorizontalOptions="FillAndExpand"
SelectedIndexChanged="PickerSection_SelectedIndexChanged"
TitleColor="Red">
</Picker>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray" VerticalOptions="Center" >
<Label Text="姓名:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor Placeholder="真实姓名" x:Name="EditorRealname" HorizontalOptions="FillAndExpand" FontSize="20"/>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray" VerticalOptions="Center">
<Label Text="手机:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="EditorMobile" HorizontalOptions="FillAndExpand" FontSize="20"/>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray" VerticalOptions="Center">
<Label Text="密码:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="EditorPassword" HorizontalOptions="FillAndExpand" FontSize="20"/>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray" VerticalOptions="Center">
<Label Text="确认:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="EditorConfirmPass" HorizontalOptions="FillAndExpand" FontSize="20"/>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray" VerticalOptions="Center">
<Button Text="提 交" HorizontalOptions="FillAndExpand" Clicked="Button_Clicked"/>
</StackLayout>
</StackLayout>
</Frame>
</pages:PopupPage>

View File

@@ -0,0 +1,73 @@
using Acr.UserDialogs;
using NPinyin;
using Rg.Plugins.Popup.Pages;
using Rg.Plugins.Popup.Services;
using System;
using System.Collections.Generic;
using System.Threading;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.ViewModels;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageRegister : PopupPage
{
RegisterViewModel ViewModel;
private int DepartmentId;
private PageMain pageMain;
public PageRegister(PageMain pageMain)
{
InitializeComponent();
this.pageMain = pageMain;
this.BindingContext = ViewModel = new RegisterViewModel(pageMain.companyId);
}
private async void Button_Clicked(object sender, EventArgs e)
{
UserDialogs.Instance.ShowLoading("正在注册,请稍后!");
new Thread(new ThreadStart(async () =>
{
Random rd = new Random();
int rdi = rd.Next(1000, 9999);
Dictionary<string, string> _body = new Dictionary<string, string>{
{"companyId", this.pageMain.companyId.ToString() }
,{"departmentId", this.DepartmentId.ToString() }
,{"deviceId", "0" }
,{"username", Pinyin.GetPinyin(EditorRealname.Text).Trim().Replace(" ","")+ rdi.ToString() }
,{"realname", EditorRealname.Text }
,{"mobile", EditorMobile.Text.Trim() }
,{"email", EditorMobile.Text.Trim() + "@163.com" }
,{"password", EditorPassword.Text.Trim() }
};
var Result = HttpHelper.RequestPost(02, _body).Result;
if (Result.Code == 200)
{
Device.BeginInvokeOnMainThread(async () =>
{
UserDialogs.Instance.HideLoading();
await PopupNavigation.Instance.PopAsync();
pageMain.ImageButtonLogin_Clicked(sender, e);
});
}
else
{
await DisplayAlert("访问出错", Result.Msg, "OK");
}
})).Start();
}
private void PickerSection_SelectedIndexChanged(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
DepartmentId = ViewModel.BuMenItems[selectedIndex].id;
}
}
}
}

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageResale">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="序列号:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="SerialNumber" HorizontalOptions="FillAndExpand" />
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray">
<Label Text="再销原因:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" Grid.Column="0" Grid.Row="1"/>
<Picker x:Name="BrandPicker" FontSize="20"
ItemsSource="{Binding CauseItems}"
ItemDisplayBinding="{Binding title}"
SelectedIndexChanged="OnCauseSelectedIndexChangedAsync"
Title="默认原因"
HorizontalOptions="FillAndExpand"
TitleColor="Red">
</Picker>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="备注:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="Note" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" BackgroundColor="Gray">
<ListView ItemsSource="{Binding Items , Mode=OneWay}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="{Binding Code}" HorizontalOptions="Start"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Data}" HorizontalOptions="CenterAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<Label Text="{Binding Msg}" HorizontalOptions="EndAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End" BackgroundColor="SlateGray">
<Button Text="提交" HorizontalOptions="FillAndExpand" Clicked="Button_ClickedAsync"/>
<Button Text="扫码提交" HorizontalOptions="FillAndExpand" Clicked="OnScan"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,91 @@
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.Models;
using XXCpzs.ViewModels;
using ZXing.Mobile;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageResale : ContentPage
{
private ResaleViewModel ViewModel;
private UserInfo userInfo;
private int CauseId = 1;
private int DeviceId = 1;
public PageResale(UserInfo userInfo)
{
InitializeComponent();
this.userInfo = userInfo;
this.BindingContext = ViewModel = new ResaleViewModel(userInfo.uid);
}
void OnCauseSelectedIndexChangedAsync(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
CauseId = ViewModel.CauseItems[selectedIndex].id;
}
}
private async void Button_ClickedAsync(object sender, EventArgs e)
{
if (this.CauseId == 0)
{
await DisplayAlert("注意", "请选择产品再销售的原因", "OK"); return;
}
if (userInfo != null && SerialNumber.Text != null)
{
Dictionary<string, string> _body = new Dictionary<string, string>{
{"Sn", SerialNumber.Text},
{"Uid", userInfo.uid.ToString()},
{"CauseId", CauseId.ToString()},
{"deviceId", this.DeviceId.ToString()}
};
var request = await HttpHelper.RequestPost(18, _body);
if (request.Code == 200)
{
ViewModel.Items.Add(new ResultModel() { Code = request.Code, Data = request.Data, Msg = request.Msg });
}
else
{
await DisplayAlert("访问出错", request.Msg, "OK");
}
}
}
private async void OnScan(object sender, EventArgs e)
{
if (await CheckPerssion())
{
var scanner = new MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
{
SerialNumber.Text = result.Text;
Button_ClickedAsync(sender, e);
}
}
}
private async Task<bool> CheckPerssion()
{
var current = CrossPermissions.Current;
//检查权限
var status = await current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
var result = await current.RequestPermissionsAsync(Permission.Camera);
status = result[Permission.Camera];
}
return status == PermissionStatus.Granted;
}
}
}

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageRuCang">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="序列号:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="SerialNumber" HorizontalOptions="FillAndExpand" />
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray">
<Label Text="目标仓库:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25"/>
<Picker x:Name="BrandPicker"
ItemsSource="{Binding CangKuItems}"
FontSize="20"
ItemDisplayBinding="{Binding title}"
Title="请目标仓库"
HorizontalOptions="FillAndExpand"
SelectedIndexChanged="OnBumenPickerSelectedIndexChangedAsync"
TitleColor="Red">
</Picker>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray">
<Label Text="备注:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="NewSerialNumber" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" BackgroundColor="SlateGray">
<ListView BackgroundColor="GreenYellow"
ItemsSource="{Binding Items , Mode=OneWay}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
CachingStrategy="RecycleElement" >
<ListView.Header>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="ID" HorizontalOptions="Start"
LineBreakMode="NoWrap"
FontSize="16" />
<Label Text="序列号" HorizontalOptions="CenterAndExpand"
LineBreakMode="NoWrap"
FontSize="13" />
<Label Text="提交结果" HorizontalOptions="EndAndExpand"
LineBreakMode="NoWrap"
FontSize="13" />
</StackLayout>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="{Binding Code}" HorizontalOptions="Start"
LineBreakMode="NoWrap" d:Text="ID"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Data}" HorizontalOptions="CenterAndExpand"
d:Text="序列号"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<Label Text="{Binding Msg}" HorizontalOptions="EndAndExpand"
d:Text="提交结果"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End" BackgroundColor="Gray">
<Button Text="提 交" HorizontalOptions="FillAndExpand" Clicked="Button_ClickedAsync"/>
<Button Text="扫码提交" HorizontalOptions="FillAndExpand" Clicked="OnScan"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,93 @@
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.Models;
using XXCpzs.ViewModels;
using ZXing.Mobile;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageRuCang : ContentPage
{
RuCangViewModel ViewModel;
private int Uid = 0;
private int deviceId = 1;
private UserInfo userInfo;
public PageRuCang(UserInfo userInfo)
{
InitializeComponent();
this.Uid = userInfo.uid;
this.userInfo = userInfo;
this.BindingContext = ViewModel = new RuCangViewModel(userInfo);
}
private int CangkuId = 0;
void OnBumenPickerSelectedIndexChangedAsync(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
CangkuId = ViewModel.CangKuItems[selectedIndex].id;
}
}
private async void Button_ClickedAsync(object sender, EventArgs e)
{
if (this.CangkuId == 0)
{
await DisplayAlert("注意", "请选择产品要存放的仓库", "OK"); return;
}
if (Uid != 0 && SerialNumber.Text != string.Empty)
{
Dictionary<string, string> _body = new Dictionary<string, string>{
{"Sn", SerialNumber.Text},
{"Uid", this.Uid.ToString()},
{"CangkuId", this.CangkuId.ToString()},
{"deviceId", this.deviceId.ToString()}
};
var request = await HttpHelper.RequestPost(10, _body);
if (request.Code == 200){
ViewModel.Items.Add(new ResultModel() { Code = request.Code, Data = request.Data, Msg = request.Msg });
}
else{
await DisplayAlert("访问出错", request.Msg, "OK");
}
}
}
private async void OnScan(object sender, EventArgs e)
{
if (await CheckPerssion())
{
var scanner = new MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
{
SerialNumber.Text = result.Text;
Button_ClickedAsync(sender, e);
}
}
}
private async Task<bool> CheckPerssion()
{
var current = CrossPermissions.Current;
//检查权限
var status = await current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
var result = await current.RequestPermissionsAsync(Permission.Camera);
status = result[Permission.Camera];
}
return status == PermissionStatus.Granted;
}
}
}

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageSale">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="序列号:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="SerialNumber" HorizontalOptions="FillAndExpand"/>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray">
<Button Text="{Binding CompanyName}" HorizontalOptions="FillAndExpand" x:Name="CustomerName" />
<Button Text="选择" HorizontalOptions="EndAndExpand" x:Name="ButtonCustomerSelect" Clicked="ButtonCustomerSelect_Clicked"/>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" BackgroundColor="SlateGray">
<ListView ItemsSource="{Binding Items}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="{Binding Code}" HorizontalOptions="Start"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Data}" HorizontalOptions="CenterAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<Label Text="{Binding Msg}" HorizontalOptions="EndAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End" BackgroundColor="Gray">
<Button Text="提交" HorizontalOptions="FillAndExpand" Clicked="Button_ClickedAsync"/>
<Button Text="扫码提交" HorizontalOptions="FillAndExpand" Clicked="OnScan"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,85 @@
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.Models;
using XXCpzs.ViewModels;
using ZXing.Mobile;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageSale : ContentPage
{
private SaleViewModel ViewModel;
private int deviceId = 1;
private UserInfo userInfo;
public PageSale(UserInfo userInfo)
{
InitializeComponent();
this.userInfo = userInfo;
this.BindingContext = ViewModel = new SaleViewModel();
}
private async void ButtonCustomerSelect_Clicked(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new NavigationPage(new PageCustomerSelect(userInfo)));
}
private async void Button_ClickedAsync(object sender, EventArgs e)
{
if (userInfo != null && ViewModel.CustomerId != 0 && SerialNumber.Text != null)
{
Dictionary<string, string> _body = new Dictionary<string, string>{
{"Sn", SerialNumber.Text},
{"Uid", userInfo.uid.ToString()},
{"CustomerId", ViewModel.CustomerId.ToString()},
{"deviceId", this.deviceId.ToString()}
};
var request = await HttpHelper.RequestPost(16, _body);
if (request.Code == 200){
ViewModel.Items.Add(new ResultModel() { Code = request.Code, Data = request.Data, Msg = request.Msg });
}
else{
await DisplayAlert("访问出错", request.Msg, "OK");
}
}
}
private async void OnScan(object sender, EventArgs e)
{
if (this.ViewModel.CustomerId == 0)
{
await DisplayAlert("注意", "请选择产品 购买的客户", "OK"); return;
}
if (await CheckPerssion())
{
var scanner = new MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
{
SerialNumber.Text = result.Text;
Button_ClickedAsync(sender, e);
}
}
}
private async Task<bool> CheckPerssion()
{
var current = CrossPermissions.Current;
//检查权限
var status = await current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
var result = await current.RequestPermissionsAsync(Permission.Camera);
status = result[Permission.Camera];
}
return status == PermissionStatus.Granted;
}
}
}

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="{Binding Title}"
x:Class="XXCpzs.Views.PageTuiHuo">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="序列号:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="SerialNumber" HorizontalOptions="FillAndExpand" />
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="Gray">
<Label Text="再销原因:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" Grid.Column="0" Grid.Row="1"/>
<Picker x:Name="BrandPicker" FontSize="20"
ItemsSource="{Binding CauseItems}"
ItemDisplayBinding="{Binding title}"
SelectedIndexChanged="OnCauseSelectedIndexChangedAsync"
Title="默认原因"
HorizontalOptions="FillAndExpand"
TitleColor="Red">
</Picker>
</StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="SlateGray">
<Label Text="备注:" VerticalTextAlignment="Center" HorizontalOptions="Start" FontSize="25" />
<Editor x:Name="Note" HorizontalOptions="FillAndExpand" FontSize="25"/>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" BackgroundColor="Gray">
<ListView ItemsSource="{Binding Items , Mode=OneWay}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" Orientation="Horizontal">
<Label Text="{Binding Code}" HorizontalOptions="Start"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Data}" HorizontalOptions="CenterAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<Label Text="{Binding Msg}" HorizontalOptions="EndAndExpand"
d:Text="Item descripton"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End" BackgroundColor="SlateGray">
<Button Text="提交" HorizontalOptions="FillAndExpand" Clicked="Button_ClickedAsync"/>
<Button Text="扫码提交" HorizontalOptions="FillAndExpand" Clicked="OnScan"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,93 @@
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XXCpzs.helper;
using XXCpzs.Models;
using XXCpzs.ViewModels;
using ZXing.Mobile;
namespace XXCpzs.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageTuiHuo : ContentPage
{
private TuiHuoViewModel ViewModel;
private UserInfo userInfo;
private int CauseId = 1;
private int DeviceId = 1;
public PageTuiHuo(UserInfo userInfo)
{
InitializeComponent();
this.userInfo = userInfo;
this.BindingContext = ViewModel = new TuiHuoViewModel(userInfo.uid);
}
void OnCauseSelectedIndexChangedAsync(object sender, EventArgs e)
{
var picker = (Picker)sender;
int selectedIndex = picker.SelectedIndex;
if (selectedIndex != -1)
{
CauseId = ViewModel.CauseItems[selectedIndex].id;
}
}
private async void Button_ClickedAsync(object sender, EventArgs e)
{
if (this.CauseId == 0)
{
await DisplayAlert("注意", "请选择产品 退货 的原因", "OK"); return;
}
if (userInfo != null && CauseId != 0 && SerialNumber.Text != null)
{
Dictionary<string, string> _body = new Dictionary<string, string>{
{"Sn", SerialNumber.Text},
{"Uid", userInfo.uid.ToString()},
{"CauseId", CauseId.ToString()},
{"deviceId", this.DeviceId.ToString()}
};
var request = await HttpHelper.RequestPost(21, _body);
if (request.Code == 200)
{
ViewModel.Items.Add(new ResultModel() { Code = request.Code, Data = request.Data, Msg = request.Msg });
}
else
{
await DisplayAlert("访问出错", request.Msg, "OK");
}
}
}
private async void OnScan(object sender, EventArgs e)
{
if (await CheckPerssion())
{
var scanner = new MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
{
SerialNumber.Text = result.Text;
Button_ClickedAsync(sender, e);
}
}
}
private async Task<bool> CheckPerssion()
{
var current = CrossPermissions.Current;
//检查权限
var status = await current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
var result = await current.RequestPermissionsAsync(Permission.Camera);
status = result[Permission.Camera];
}
return status == PermissionStatus.Granted;
}
}
}