Commit c9c5c91d by liangjianmin

还原xk的自营

parent a88bdd5a
......@@ -9,20 +9,23 @@ const state = {
loading1:false,
ly1:false,//联营大陆得到数据防止切换多次请求
ly2:false,//联营香港得到数据防止切换多次请求
zy1:false,//自营得到数据防止切换多次请求
ly1Data:[],//大陆数据
ly2Data:[],//香港数据
zy1Data:[],//自营数据现货
zy2Data:[],//自营数据期货
ly1Length:0,
ly2Length:0,
zy1Length:0,//自营数据总长度
ly1LoseData:[],
ly2LoseData:[],
zy1LoseData:[],
priceInit:false,
totlaMState:false
}
const mutations = {
cartList(state, payload) {
state.ly1Length=payload.data.cn_count;
state.ly2Length=payload.data.hk_count;
if(payload.types_==1){
//大陆
var arr_=payload.data.list;
......@@ -47,53 +50,130 @@ const mutations = {
state.ly2Data.push(arr_[i])
}
}
}else{
//自营
var arr_=payload.data.list;
for(var i=0;i<arr_.length;i++){
arr_[i].editState=false;
if(arr_[i].status==-1){
state.zy1LoseData.push(arr_[i]);
}else{
if(arr_[i].sale_type==1){
//现货默认勾选
arr_[i].check=true;
state.zy1Data.push(arr_[i]);
}else{
//期货 //默认不勾选
arr_[i].check=false;
state.zy2Data.push(arr_[i])
}
}
}
}
},
cartDelete(state,payload){
var ids=payload.cart_id.split(",");
//联营
if(payload.act=='normal'){
//删除操作
var datalistp=payload.delivery==1?state.ly1Data:state.ly2Data;
for(var i=0;i<datalistp.length;i++){
for(var j=0;j<ids.length;j++){
if(datalistp[i].cart_id==ids[j]){
datalistp.splice(i,1);
if(payload.types==1){
//联营
if(payload.act=='normal'){
//删除操作
var datalistp=payload.delivery==1?state.ly1Data:state.ly2Data;
for(var i=0;i<datalistp.length;i++){
for(var j=0;j<ids.length;j++){
if(datalistp[i].cart_id==ids[j]){
datalistp.splice(i,1);
}
}
}
}
if(payload.delivery==1){
state.ly1Data=datalistp;
state.ly1Length=Number(state.ly1Length)-ids.length;
if(payload.delivery==1){
state.ly1Data=datalistp;
state.ly1Length=Number(state.ly1Length)-ids.length;
}else{
state.ly2Data=datalistp;
state.ly2Length=Number(state.ly2Length)-ids.length;
}
}else{
state.ly2Data=datalistp;
state.ly2Length=Number(state.ly2Length)-ids.length;
//清除过期数据
if(payload.delivery==1){
state.ly1LoseData=[];
}else{
state.ly2LoseData=[];
}
}
}else{
//清除过期数据
if(payload.delivery==1){
state.ly1LoseData=[];
//自营
if(payload.act=='normal'){
//删除
for(var i=0;i<state.zy1Data.length;i++){
for(var j=0;j<ids.length;j++){
if(state.zy1Data[i].cart_id==ids[j]){
state.zy1Data.splice(i,1);
}
}
}
for(var ii=0;ii<state.zy2Data.length;i++){
for(var jj=0;jj<ids.length;jj++){
if(state.zy2Data[ii].cart_id==ids[jj]){
state.zy2Data.splice(ii,1);
}
}
}
state.zy1Length=Number(state.zy1Length)-ids.length;
}else{
state.ly2LoseData=[];
//清除过期数据
state.zy1LoseData=[];
}
}
},
changenum(state,payload){
//大陆//香港
var list_=payload.delivery_place==1?state.ly1Data:state.ly2Data;
for(var i=0;i<list_.length;i++){
if(list_[i].cart_id==payload.cart_id){
list_[i].goods_number=payload.data.num;
list_[i].goods_amount=payload.data.goods_amount;
list_[i].goods_amount_format=payload.data.goods_amount_format;
list_[i].goods_price=payload.data.goods_price;
list_[i].goods_price_format=payload.data.goods_price_format;
}
}
if(payload.delivery_place==1||payload.delivery_place==2){
//大陆//香港
var list_=payload.delivery_place==1?state.ly1Data:state.ly2Data;
for(var i=0;i<list_.length;i++){
if(list_[i].cart_id==payload.cart_id){
list_[i].goods_number=payload.data.num;
list_[i].goods_amount=payload.data.goods_amount;
list_[i].goods_amount_format=payload.data.goods_amount_format;
list_[i].goods_price=payload.data.goods_price;
list_[i].goods_price_format=payload.data.goods_price_format;
}
}
}else{
//自营
var list_1=state.zy1Data,list_2=state.zy2Data;
for(var i=0;i<list_1.length;i++){
if(list_1[i].cart_id==payload.cart_id){
list_1[i].goods_number=payload.data.num;
list_1[i].goods_amount=payload.data.goods_amount;
list_1[i].goods_amount_format=payload.data.goods_amount_format;
list_1[i].goods_price=payload.data.goods_price;
list_1[i].goods_price_format=payload.data.goods_price_format;
if(payload.data.sale_type==2){
var arrj=list_1[i];
list_1.splice(i,1);
state.zy2Data.push(arrj)
}
}
}
for(var j=0;j<list_2.length;j++){
if(list_2[j].cart_id==payload.cart_id){
list_2[j].goods_number=payload.data.num;
list_2[j].goods_amount=payload.data.goods_amount;
list_2[j].goods_amount_format=payload.data.goods_amount_format;
list_2[j].goods_price=payload.data.goods_price;
if(payload.data.sale_type==1){
var arrj=list_2[j];
list_2.splice(j,1);
state.zy1Data.push(arrj)
}
}
}
}
state.totlaMState=true;
}
}
......@@ -122,6 +202,9 @@ const actions = {
}else if(types_==2){
//香港
state.ly2=true;
}else{
//自营
state.zy1=true;
}
if (data.err_code == 0) {
commit({
......@@ -140,7 +223,16 @@ const actions = {
state.loading1=false;
});
},
allcount({commit},payload){
Services.allcount().then((res) => {
let data = res.data;
if (data.err_code == 0) {
state.ly1Length=Number(data.data['1']['1']||0);
state.ly2Length=Number(data.data['1']['2']||0);
state.zy1Length=Number(data.data['2']['1']||0);
}
})
},
cartDelete({commit},payload){
state.loading=true;
var params = {
......
This diff could not be displayed because it is too large.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment