Browse Source

加入竞品更新接口

master
feng 2 years ago
parent
commit
9d369525e4
  1. 6
      src/Coldairarrow.Api/Controllers/HuiYan/teamitemsController.cs
  2. 24
      src/Coldairarrow.Business/HuiYan/teamitemsBusiness.cs
  3. 2
      src/Coldairarrow.IBusiness/HuiYan/IteamitemsBusiness.cs
  4. 22
      客户端/齐越慧眼/齐越慧眼/ApiHelper.cs
  5. 2
      客户端/齐越慧眼/齐越慧眼/Models/CompetingModel.cs
  6. 32
      客户端/齐越慧眼/齐越慧眼/UserControls/BrowerControl.xaml.cs
  7. 6
      客户端/齐越慧眼/齐越慧眼/ViewModels/CompetingWindowViewModel.cs
  8. 45
      客户端/齐越慧眼/齐越慧眼/Windows/CompetingWindow.xaml
  9. 39
      客户端/齐越慧眼/齐越慧眼/Windows/CompetingWindow.xaml.cs
  10. 34
      客户端/齐越慧眼/齐越慧眼/Windows/ItemDetailWindow.xaml.cs
  11. 6
      客户端/齐越慧眼/齐越慧眼/vuepage/client/src/router/index.js
  12. 9
      客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/competing/Index.vue
  13. 97
      客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/competing/List.vue
  14. 2
      客户端/齐越慧眼/齐越慧眼/vuepage/dist/js/app.js
  15. 2
      客户端/齐越慧眼/齐越慧眼/vuepage/dist/js/app.js.map

6
src/Coldairarrow.Api/Controllers/HuiYan/teamitemsController.cs

@ -98,6 +98,12 @@ namespace Coldairarrow.Api.Controllers.HuiYan
return _teamitemsBus.SetItem(model);
}
[HttpPost]
public AjaxResult UpdateItemCompeting([FromBody] List<TeamCompetingItem> competingItems, [FromQuery]string id)
{
return _teamitemsBus.UpdateItemCompeting(competingItems,id);
}
/// <summary>
/// 设置商品状态
/// </summary>

24
src/Coldairarrow.Business/HuiYan/teamitemsBusiness.cs

@ -303,11 +303,6 @@ namespace Coldairarrow.Business.HuiYan
{
int row = Db.Update<teamitems>(c => c.Id == model.Id, (item) =>
{
if (model.CompetingItems!=null)
{
item.CompetingItemJson = Newtonsoft.Json.JsonConvert.SerializeObject(model.CompetingItems);
}
item.ExtensionJson = Newtonsoft.Json.JsonConvert.SerializeObject(model.Extensions);
item.RivalGoodsId = model.RivalGoodsId;
item.RivalPLCount = model.RivalPLCount;
@ -326,6 +321,25 @@ namespace Coldairarrow.Business.HuiYan
}
}
public AjaxResult UpdateItemCompeting(List<TeamCompetingItem> competingItems,string id)
{
try
{
int row = Db.Update<teamitems>(c => c.Id == id, (item) =>
{
item.CompetingItemJson = Newtonsoft.Json.JsonConvert.SerializeObject(competingItems);
});
if (row > 0)
return Success();
return Error("操作失败!");
}
catch (Exception ex)
{
return Error("操作失败,缺少必填数据!");
}
}
public bool UpdateTaskSuccess(List<pricetasklog> logs)
{
var ids= logs.Select(c => c.TeamItemId).ToList();

2
src/Coldairarrow.IBusiness/HuiYan/IteamitemsBusiness.cs

@ -30,5 +30,7 @@ namespace Coldairarrow.Business.HuiYan
bool UpdateTaskSuccess(List<pricetasklog> logs);
Task<List<TeamitemDto>> GetListByState(int state,List<string> ids);
AjaxResult UpdateItemCompeting(List<TeamCompetingItem> competingItems, string itemId);
}
}

22
客户端/齐越慧眼/齐越慧眼/ApiHelper.cs

@ -7,14 +7,15 @@ using System.Windows;
using Utils;
using System.Diagnostics;
using .Models;
using Microsoft.DotNet.PlatformAbstractions;
namespace
{
public class ApiHelper
{
#if LOCATION
//public static string ApiBase { get; set; } = "http://localhost:5000";
public static string ApiBase { get; set; } = "http://hyapi.qiyue666.com";
public static string ApiBase { get; set; } = "http://localhost:5000";
//public static string ApiBase { get; set; } = "http://hyapi.qiyue666.com";
#else
public static string ApiBase { get; set; } = "http://hyapi.qiyue666.com";
@ -413,9 +414,24 @@ namespace 齐越慧眼
return "";
}
/// <summary>
/// 设置竞品信息
/// </summary>
/// <param name="items"></param>
/// <param name="teamitemId"></param>
/// <returns></returns>
public static bool UpdateItemCompeting(List<TeamCompetingItem> items,string teamitemId)
{
var result = Http($"/HuiYan/teamitems/UpdateItemCompeting?id={teamitemId}", Newtonsoft.Json.JsonConvert.SerializeObject(items));
var data = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(result);
bool isSuccess = data.Success;
return isSuccess;
}
}

2
客户端/齐越慧眼/齐越慧眼/Models/CompetingModel.cs

@ -174,7 +174,7 @@ namespace 齐越慧眼.Models
get
{
if(string.IsNullOrEmpty(_Sku))
_Sku= Regex.Match(ImgUrl, @"item\.jd\.com/(.*?)\.html").Groups[1].Value;
_Sku= Regex.Match(ItemUrl, @"item\.jd\.com/(.*?)\.html").Groups[1].Value;
return _Sku;
}
set {

32
客户端/齐越慧眼/齐越慧眼/UserControls/BrowerControl.xaml.cs

@ -212,22 +212,22 @@ namespace 齐越慧眼.UserControls
private void Web_StartNewWindow(object sender, NewWindowEventArgs e)
{
var match= Regex.Match(e.Url, @"item\.jd\.com/(.*?)\.html");
if (match.Success)
{
Thread t = new Thread(() => {
//判断是否添加成功
if (Windows.ItemDetailWindow.Show(e.Url) == true)
{
WpfNoticeMsg.NoticeMessage.Show("添加成功!");
}
});
t.IsBackground = true;
t.Start();
return;
}
//var match= Regex.Match(e.Url, @"item\.jd\.com/(.*?)\.html");
// if (match.Success)
// {
// Thread t = new Thread(() => {
// //判断是否添加成功
// if (Windows.ItemDetailWindow.Show(e.Url) == true)
// {
// WpfNoticeMsg.NoticeMessage.Show("添加成功!");
// }
// });
// t.IsBackground = true;
// t.Start();
// return;
// }
//
//WpfNoticeMsg.NoticeMessage.Show(e.Url);
BrowerHelper.OpenUrl(e.Url);

6
客户端/齐越慧眼/齐越慧眼/ViewModels/CompetingWindowViewModel.cs

@ -12,7 +12,7 @@ namespace 齐越慧眼.ViewModels
/// <summary>
/// 当前操作对象
/// </summary>
TeamItem Item { get; set; }
public TeamItem Item { get;private set; }
public CompetingWindowViewModel(TeamItem item)
{
@ -22,7 +22,9 @@ namespace 齐越慧眼.ViewModels
}
private System.Collections.ObjectModel.ObservableCollection<TeamCompetingItem> _ItemList;
/// <summary>
/// 当前选中竞品列表
/// </summary>
public System.Collections.ObjectModel.ObservableCollection<TeamCompetingItem> ItemList
{
get { return _ItemList; }

45
客户端/齐越慧眼/齐越慧眼/Windows/CompetingWindow.xaml

@ -8,7 +8,7 @@
Title="CompetingWindow" Height="768" Width="1280">
<DockPanel Margin="0 10 0 0">
<DockPanel DockPanel.Dock="Top" >
<DockPanel DockPanel.Dock="Top" x:Name="topPanel">
<Button Content="返回" Margin="0 0 10 0" Name="back" Click="back_Click"></Button>
<TextBox x:Name="txtUrl" Keyboard.KeyUp="txtUrl_KeyUp"></TextBox>
</DockPanel>
@ -22,25 +22,36 @@
</DropShadowEffect>
</Border.Effect>
<Grid Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Background="White" Name="firstGrid" >
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10 0 0 0">
<TextBlock Text="已选" FontSize="18" Foreground="#333333"></TextBlock>
<TextBlock Text="{Binding ItemList.Count}" Margin="5 0 0 0" FontSize="18" Foreground="#333333"></TextBlock>
<TextBlock Text="/20" Margin="5 0 0 0" FontSize="18" Foreground="#333333"></TextBlock>
<TextBlock Text="个竞品" Margin="5 0 0 0" FontSize="18" Foreground="#333333"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10 0 0 0">
<TextBlock Text="已选" FontSize="18" Foreground="#333333"></TextBlock>
<TextBlock Text="{Binding ItemList.Count}" Margin="5 0 0 0" FontSize="18" Foreground="#333333"></TextBlock>
<TextBlock Text="/20" Margin="5 0 0 0" FontSize="18" Foreground="#333333"></TextBlock>
<TextBlock Text="个竞品" Margin="5 0 0 0" FontSize="18" Foreground="#333333"></TextBlock>
</StackPanel>
<Button Grid.Column="1" Style="{StaticResource ButtonPrimary}" Content="下一步" Height="61" Width="119" HorizontalAlignment="Right" Cursor="Hand" Background="#8080ff" FontSize="13" Foreground="White">
<Button.Effect>
<DropShadowEffect ShadowDepth="-4" BlurRadius="5" Color="LightGray" />
</Button.Effect>
</Button>
</Grid>
<Button x:Name="btn_next" Click="btn_next_Click" Grid.Column="1" Style="{StaticResource ButtonPrimary}" Content="下一步" Height="61" Width="119" HorizontalAlignment="Right" Cursor="Hand" Background="#8080ff" FontSize="13" Foreground="White">
<Button.Effect>
<DropShadowEffect ShadowDepth="-4" BlurRadius="5" Color="LightGray" />
</Button.Effect>
</Button>
</Grid>
<Grid x:Name="nextGrid" Visibility="Collapsed">
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button x:Name="btn_canel" Content="上一步" Click="btn_canel_Click" Style="{StaticResource ButtonCustom}" Padding="40 5" Cursor="Hand" FontSize="13" Foreground="#555555"></Button>
<Button x:Name="btn_save" Click="btn_save_Click" Content="保存" Style="{StaticResource ButtonPrimary}" Margin="20 0 0 0" Height="60" Cursor="Hand" Padding="40 0" Background="#8080ff" FontSize="13" Foreground="White"></Button>
</StackPanel>
</Grid>
</Grid>
</Border>
<Grid x:Name="grid" DockPanel.Dock="Bottom" Margin="0 10 0 0">
</Grid>

39
客户端/齐越慧眼/齐越慧眼/Windows/CompetingWindow.xaml.cs

@ -123,6 +123,7 @@ namespace 齐越慧眼.Windows
//判断是否添加成功
if (Windows.ItemDetailWindow.Show(e.Url) == true)
{
StartPage();
WpfNoticeMsg.NoticeMessage.Show("添加成功!");
}
});
@ -567,10 +568,48 @@ namespace 齐越慧眼.Windows
lastUrl = string.Empty;
this.web.Back();
}
private void btn_next_Click(object sender, RoutedEventArgs e)
{
web.LoadUrlAsync("nacollector://home/competingList");
firstGrid.Visibility = Visibility.Collapsed;
nextGrid.Visibility = Visibility.Visible;
topPanel.Visibility = Visibility.Collapsed;
}
private void btn_canel_Click(object sender, RoutedEventArgs e)
{
if(web.CanGoBack)
web.Back();
firstGrid.Visibility = Visibility.Visible;
nextGrid.Visibility = Visibility.Collapsed;
topPanel.Visibility = Visibility.Visible;
}
private void btn_save_Click(object sender, RoutedEventArgs e)
{
if (ApiHelper.UpdateItemCompeting(CompetingWindowViewModel.Instance.ItemList.ToList(), CompetingWindowViewModel.Instance.Item.Id))
{
WpfNoticeMsg.NoticeMessage.Show("保存成功!");
}
else
{
WpfNoticeMsg.NoticeMessage.Show("保存失败!");
}
}
}
public class CompetingAsyncJS
{
public CompetingWindow Brower { get; set; }
public List<TeamCompetingItem> getData()
{
return CompetingWindowViewModel.Instance.ItemList.ToList();
}
public bool saveData()
{
return ApiHelper.UpdateItemCompeting(CompetingWindowViewModel.Instance.ItemList.ToList(), CompetingWindowViewModel.Instance.Item.Id);
}
}
}

34
客户端/齐越慧眼/齐越慧眼/Windows/ItemDetailWindow.xaml.cs

@ -2,6 +2,7 @@
using CefSharp.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Text.RegularExpressions;
@ -125,16 +126,31 @@ namespace 齐越慧眼.Windows
string url = web.Address;
string spu = EvalScript("return $(document.head).html().match(/mainSkuId:'(.*?)',/)==undefined?\"\":$(document.head).html().match(/mainSkuId:'(.*?)',/)[1]");
var model = new Models.TeamCompetingItem()
{
CommentCount = comment,
ImgUrl = imgUrl,
ItemUrl = url,
Platform = 0,
Price = price,
Spu = spu,
Title = title,
};
model.Sku= Regex.Match(model.ItemUrl, @"item\.jd\.com/(.*?)\.html").Groups[1].Value;
ViewModels.CompetingWindowViewModel.Instance.ItemList.Add(new Models.TeamCompetingItem() {
CommentCount=comment,
ImgUrl=imgUrl,
ItemUrl=url,
Platform=0,
Price=price,
Spu=spu,
Title=title,
});
if (string.IsNullOrEmpty(model.Price) || string.IsNullOrEmpty(model.Sku) || string.IsNullOrEmpty(model.CommentCount))
{
WpfNoticeMsg.NoticeMessage.Show("请等待页面加载完成!");
return;
}
if (ViewModels.CompetingWindowViewModel.Instance.ItemList.Any(c => c.Spu == model.Spu))
{
WpfNoticeMsg.NoticeMessage.Show("当前已有相同Spu竞品存在!");
return;
}
ViewModels.CompetingWindowViewModel.Instance.ItemList.Add(model);
this.DialogResult = true;
}

6
客户端/齐越慧眼/齐越慧眼/vuepage/client/src/router/index.js

@ -5,6 +5,7 @@ import Items from '../views/items/Index.vue'
import PriceTask from '../views/pricetask/Index.vue'
import Info from '../views/info/Index.vue'
import Competing from '../views/competing/Index.vue'
import CompetingList from '../views/competing/List.vue'
Vue.use(VueRouter)
@ -33,6 +34,11 @@ const routes = [
path: '/competing',
name: 'competing',
component: Competing
},
{
path: '/competingList',
name: 'competingList',
component: CompetingList
}
]

9
客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/competing/Index.vue

@ -200,8 +200,13 @@ export default {
this.getDatas(0);
},
onShowWindow(item,type){
if( hyCoreModel.onShowWindow(JSON.stringify(item),type))
this.reloaddata()
hyCoreModel.onShowWindow(JSON.stringify(item),type).then(res=>{
if(res)
{
this.reloaddata()
}
})
},
getTop1Data(items){
if(items&&items.length>0)

97
客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/competing/List.vue

@ -0,0 +1,97 @@
<template>
<div>
<a-table :dataSource="datas" :columns="columns" >
<span slot="action" slot-scope="text, record">
<template>
<a @click="handleEdit(record)">修改</a>
<a-divider type="vertical" />
<a @click="handleDelete(record)">删除</a>
</template>
</span>
<span slot="platform" slot-scope="text">
{{text=="0"?"京东":"京东" }}
</span>
<div slot="ImgUrl" slot-scope="text">
<img :src="text" style="width: 50px;height: 50px;">
</div>
</a-table>
</div>
</template>
<script>
export default {
data() {
return {
datas: [],
columns:[{
title: '图片',
dataIndex: 'ImgUrl',
width:'50px',
scopedSlots: { customRender: 'ImgUrl' }
},
{
title: 'SKU名称',
dataIndex: 'Title',
width:'280px'
},
{
title: '价格',
dataIndex: 'Price',
width:'88px'
},
{
title: '评价数',
dataIndex: 'CommentCount',
width:'88px'
},
{
title: '竞品链接',
dataIndex: 'ItemUrl',
width:'535px'
},
{
title: '平台',
dataIndex: 'Platform',
scopedSlots: { customRender: 'platform' },
width:'88px'
},
{
title: '操作',
dataIndex: 'action',
scopedSlots: { customRender: 'action' },
width:'209px'
},]
};
},
mounted() {
this.getDatas();
},
methods: {
getDatas() {
hyCoreModel.getData().then((res) => {
console.log(res, "当前竞品对象");
this.datas = res;
});
},
handleEdit(item){
},
handleDelete(item){
},
saveData() {
hyCoreModel.saveData().then((isOk) => {
if (isOk) {
this.$message.success("成功!");
} else {
this.$message.error("失败!");
}
});
},
},
};
</script>

2
客户端/齐越慧眼/齐越慧眼/vuepage/dist/js/app.js

File diff suppressed because one or more lines are too long

2
客户端/齐越慧眼/齐越慧眼/vuepage/dist/js/app.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save