Commit 1e6fd284 by lixiaomin

轮播图

parent ef1f4477
import request from "@/utils/request";
// 查询列表
export function getBannerList(pageNum,pageSize,data) {
return request({
url: "/system/banner/list?pageNum=" + pageNum+ "&pageSize="+pageSize,
method: "post",
data: data,
});
}
// 新增轮播图
export function addBanner(data) {
return request({
url: "/system/banner/create",
method: "post",
data: data,
});
}
// 修改轮播图
export function updateBanner(data) {
return request({
url: "/system/banner/update",
method: "post",
data: data,
});
}
// 删除轮播图
export function delBanner(id) {
return request({
url: "/system/banner/delete?bannerId="+id,
method: "get"
});
}
// 修改上下线状态轮播图
export function upStateBanner(id,state) {
return request({
url: "/system/banner/state/update?bannerId="+id+"&state="+state,
method: "get"
});
}
/** 组装省市区门店数据,供回显使用 */
function buildPS(pdata){
let province= pdata.province;
let ps_ary = new Array();
if(province && province[0]==0){
ps_ary.push(["0"]);
}else{
//如果 shopIds有值,其实不管哪个省市区商店有值 都用统一的方法处理 找到对应节点-找到所有最底节点-逐级找到父节点
let t_shopIds = pdata.shopIds;
let t_area = pdata.area;
let t_city = pdata.city;
let t_province = pdata.province;
let child_ary = new Array();
//找到对应的节点
if(t_shopIds ){
getChildNodeData(t_shopIds,child_ary);
}
if(t_area ){
getChildNodeData(t_area,child_ary);
}
if(t_city ){
getChildNodeData(t_city,child_ary);
}
if(t_province ){
getChildNodeData(t_province,child_ary);
}
//循环所有最底层子节点找到parent,生成数组;
for(let i=0;i<child_ary.length;i++){
let cdata_ary = new Array();
cdata_ary.push(child_ary[i].value);
getNodeData(child_ary[i],cdata_ary);
cdata_ary.unshift("1");
ps_ary.push(cdata_ary)
}
}
return ps_ary;
}
let list=[];
function getChildNodeData(pval,child_ary){
for(let i=0;i<pval.length;i++){
//找到指定值对应的节点
let tobj = cascadTreeData(list[1],pval[i]);
//找到所有的最底层子节点
getNodeList(tobj,child_ary);
}
}
//填充所有父节点的值
function getNodeData(child,pary){
if(child.parentObj){
pary.unshift(child.parentObj.value);
getNodeData(child.parentObj,pary);
}
}
//找到当前的值对应的节点,
function cascadTreeData(tdata,pval){
if(!pval || pval==null ) return null;
if(tdata && tdata.value && tdata.value==pval){
return tdata;
}else{
let tchild = tdata.children;
if(tchild){
for(let i=0;i<tchild.length;i++){
let titem = tchild[i];
if(titem.value==pval){
return titem;
}else{
let tobj = cascadTreeData(titem,pval);
if(tobj) return tobj;
}
}
}
}
}
//找到指定节点所有的子节点
function getNodeList(pnode,pary){
if(pnode==null) return ;
if(pnode.children){
for(let i=0;i<pnode.children.length;i++){
let titem = pnode.children[i];
if(titem.children){
getNodeList(titem,pary);
}else{
pary.push(titem);
}
}
}else{
pary.push(pnode);
}
}
function getList(dataList){
list=dataList
}
export default{
buildPS,
getList
}
\ No newline at end of file
......@@ -213,6 +213,7 @@ import {listClass} from "@/api/system/category";
import {listSpu} from "@/api/system/goods";
import {listShop,getShopAreaTree} from "@/api/system/shop";
import piovince from '@/utils/piovince'
import area from '@/utils/area'
export default {
components: { GiveCoupon},
data() {
......@@ -582,109 +583,111 @@ export default {
this.shopRange=sh_ary;
}
//省市区门店
let ps_ary = this.buildPS(response.data);
area.getList(this.shopAreaTreeList);
let ps_ary=area.buildPS(response.data);
//let ps_ary = this.buildPS(response.data);
this.storesRange = ps_ary;
}
});
}
}).catch(() => {});
},
/** 组装省市区门店数据,供回显使用 */
buildPS(pdata){
//this.storesRange=[[1,"110000","110000","110105","48"]];
//0,1
//province: "110000"
//city: "110000"
// area
//shopIds
let province= pdata.province;
let ps_ary = new Array();
if(province && province[0]==0){
ps_ary.push(["0"]);
}else{
//如果 shopIds有值,其实不管哪个省市区商店有值 都用统一的方法处理 找到对应节点-找到所有最底节点-逐级找到父节点
let t_shopIds = pdata.shopIds;
let t_area = pdata.area;
let t_city = pdata.city;
let t_province = pdata.province;
// /** 组装省市区门店数据,供回显使用 */
// buildPS(pdata){
// //this.storesRange=[[1,"110000","110000","110105","48"]];
// //0,1
// //province: "110000"
// //city: "110000"
// // area
// //shopIds
// let province= pdata.province;
// let ps_ary = new Array();
// if(province && province[0]==0){
// ps_ary.push(["0"]);
// }else{
// //如果 shopIds有值,其实不管哪个省市区商店有值 都用统一的方法处理 找到对应节点-找到所有最底节点-逐级找到父节点
// let t_shopIds = pdata.shopIds;
// let t_area = pdata.area;
// let t_city = pdata.city;
// let t_province = pdata.province;
let child_ary = new Array();
//找到对应的节点
if(t_shopIds ){
this.getChildNodeData(t_shopIds,child_ary);
}
if(t_area ){
this.getChildNodeData(t_area,child_ary);
}
if(t_city ){
this.getChildNodeData(t_city,child_ary);
}
if(t_province ){
this.getChildNodeData(t_province,child_ary);
}
//循环所有最底层子节点找到parent,生成数组;
for(let i=0;i<child_ary.length;i++){
let cdata_ary = new Array();
cdata_ary.push(child_ary[i].value);
this.getNodeData(child_ary[i],cdata_ary);
cdata_ary.unshift("1");
ps_ary.push(cdata_ary)
}
}
return ps_ary;
},
getChildNodeData(pval,child_ary){
for(let i=0;i<pval.length;i++){
//找到指定值对应的节点
let tobj = this.cascadTreeData(this.shopAreaTreeList[1],pval[i]);
console.log("tobj ",tobj);
//找到所有的最底层子节点
this.getNodeList(tobj,child_ary);
}
},
//填充所有父节点的值
getNodeData(child,pary){
if(child.parentObj){
pary.unshift(child.parentObj.value);
this.getNodeData(child.parentObj,pary);
}
},
//找到当前的值对应的节点,
cascadTreeData(tdata,pval){
if(!pval || pval==null ) return null;
if(tdata && tdata.value && tdata.value==pval){
return tdata;
}else{
let tchild = tdata.children;
if(tchild){
for(let i=0;i<tchild.length;i++){
let titem = tchild[i];
if(titem.value==pval){
return titem;
}else{
let tobj = this.cascadTreeData(titem,pval);
if(tobj) return tobj;
}
}
}
}
},
//找到指定节点所有的子节点
getNodeList(pnode,pary){
if(pnode==null) return ;
if(pnode.children){
for(let i=0;i<pnode.children.length;i++){
let titem = pnode.children[i];
if(titem.children){
this.getNodeList(titem,pary);
}else{
pary.push(titem);
}
}
}else{
pary.push(pnode);
}
},
// let child_ary = new Array();
// //找到对应的节点
// if(t_shopIds ){
// this.getChildNodeData(t_shopIds,child_ary);
// }
// if(t_area ){
// this.getChildNodeData(t_area,child_ary);
// }
// if(t_city ){
// this.getChildNodeData(t_city,child_ary);
// }
// if(t_province ){
// this.getChildNodeData(t_province,child_ary);
// }
// //循环所有最底层子节点找到parent,生成数组;
// for(let i=0;i<child_ary.length;i++){
// let cdata_ary = new Array();
// cdata_ary.push(child_ary[i].value);
// this.getNodeData(child_ary[i],cdata_ary);
// cdata_ary.unshift("1");
// ps_ary.push(cdata_ary)
// }
// }
// return ps_ary;
// },
// getChildNodeData(pval,child_ary){
// for(let i=0;i<pval.length;i++){
// //找到指定值对应的节点
// let tobj = this.cascadTreeData(this.shopAreaTreeList[1],pval[i]);
// console.log("tobj ",tobj);
// //找到所有的最底层子节点
// this.getNodeList(tobj,child_ary);
// }
// },
// //填充所有父节点的值
// getNodeData(child,pary){
// if(child.parentObj){
// pary.unshift(child.parentObj.value);
// this.getNodeData(child.parentObj,pary);
// }
// },
// //找到当前的值对应的节点,
// cascadTreeData(tdata,pval){
// if(!pval || pval==null ) return null;
// if(tdata && tdata.value && tdata.value==pval){
// return tdata;
// }else{
// let tchild = tdata.children;
// if(tchild){
// for(let i=0;i<tchild.length;i++){
// let titem = tchild[i];
// if(titem.value==pval){
// return titem;
// }else{
// let tobj = this.cascadTreeData(titem,pval);
// if(tobj) return tobj;
// }
// }
// }
// }
// },
// //找到指定节点所有的子节点
// getNodeList(pnode,pary){
// if(pnode==null) return ;
// if(pnode.children){
// for(let i=0;i<pnode.children.length;i++){
// let titem = pnode.children[i];
// if(titem.children){
// this.getNodeList(titem,pary);
// }else{
// pary.push(titem);
// }
// }
// }else{
// pary.push(pnode);
// }
// },
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
......
......@@ -132,9 +132,7 @@ export default {
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
state: null
pageSize: 10
},
// 表单参数
form: {},
......
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 to comment