Commit 6cbd1d67 by 李嘉林

暂存

parent 22302091
......@@ -101,6 +101,19 @@ export default {
});
function pollCondition(data) {
if (Object.prototype.toString.call(data) === "[object Object]") {
if (data.visible && data.visible > 1 && data.visibleCopy == undefined) {
data.visibleCopy = data.visible;
console.log(data.visibleCopy,'--data.visibleCopy')
}
if ((data.visibleCopy == 2 && wx.getStorageSync('sessionid')) ||
(data.visibleCopy == 3 && !wx.getStorageSync('sessionid'))
) {
data.visible = 1;
} else if ((data.visibleCopy == 2 && !wx.getStorageSync('sessionid')) ||
(data.visibleCopy == 3 && wx.getStorageSync('sessionid'))
) {
data.visible = 0;
} else {
if (data.condition != "" && data.condition != undefined) {
data.visible = ids.some((item) => {
return item == data.condition;
......@@ -108,12 +121,25 @@ export default {
? 1
: 0;
}
}
for (const key in data) {
if (data.hasOwnProperty(key)) {
const element = data[key];
if (
Object.prototype.toString.call(element) === "[object Object]"
) {
if (element.visible && element.visible > 1 && element.visibleCopy == undefined) {
element.visibleCopy = element.visible;
}
if ((element.visibleCopy == 2 && wx.getStorageSync('sessionid')) ||
(element.visibleCopy == 3 && !wx.getStorageSync('sessionid'))
) {
element.visible = 1;
} else if ((element.visibleCopy == 2 && !wx.getStorageSync('sessionid')) ||
(element.visibleCopy == 3 && wx.getStorageSync('sessionid'))
) {
element.visible = 0;
} else {
if (element.condition != "" && element.condition != undefined) {
console.log("979797", element.condition);
element.visible = ids.some((item) => {
......@@ -122,6 +148,7 @@ export default {
? 1
: 0;
}
}
pollCondition(element);
} else if (
Object.prototype.toString.call(element) === "[object Array]" &&
......
......@@ -7,6 +7,8 @@
<div v-if="showSpokesManHome">
<get-index-homepage class="getIndexHomePage"></get-index-homepage>
</div>
<!-- <div style="font-size:40px;" @click="upImg">上传</div> -->
<!-- <mpvue-cropper v-if="chooseImg" :option="cropperOptions" @ready="cReady"></mpvue-cropper> -->
<ThemeDataPlant></ThemeDataPlant>
<div v-for="(item,index) in pageData" :key="index">
<div v-if="item.componentCode=='banner' && item.componentInfo.visible == 1">
......@@ -90,6 +92,9 @@
<div v-if="item.componentCode == 'spell-group' && item.componentInfo.visible == 1">
<spell-group :datas="item"></spell-group>
</div>
<div v-if="item.componentCode == 'wo-timeout' && item.componentInfo.visible == 1">
<wo-timeout :datas="item"></wo-timeout>
</div>
</div>
<bottomCont></bottomCont>
......@@ -129,6 +134,7 @@ import links from '@/components/basicTool/link/index.vue'
import interval from '@/components/basicTool/interval/index.vue'
import partition from '@/components/basicTool/partition/index.vue'
import shopPopup from '@/components/basicTool/shop-popup/index.vue'
import woTimeout from '@/components/basicTool/wo-timeout/index.vue'
import transverseLabel from '@/components/basicTool/transverse-label/index.vue'
import information from '@/components/content/information/index.vue'
import text from '@/components/content/text'
......@@ -141,9 +147,10 @@ import birth from '@/api/popup'
import couponPopup from '@/components/couponPopup.vue'
import NewUser from "../../components/newCustomer/newUser";
import NewPolite from "../../components/newCustomer/newPolite";
import { setTabBarActive, checkTabbarPage,themeColor } from "../../utils/mayi.js";
import { setTabBarActive, checkTabbarPage,themeColor, checkShowConditionIds } from "../../utils/mayi.js";
import indexApi from "@/api/index.js";
import { throttle, concatUrl } from "../../utils/index.js"
import mpvueCropper from '@/components/mpvue-cropper'
const app = getApp();
export default {
......@@ -173,7 +180,10 @@ export default {
timer: null,
isShowBirth: false, // 是否展示生日礼品
birthGifts: ""
birthGifts: "",
cropperOptions:{},
chooseImg:false,
imgSrc:'',
};
},
components:{
......@@ -193,7 +203,9 @@ export default {
couponPopup,
NewUser,
NewPolite,
birthPopup
birthPopup,
mpvueCropper,
woTimeout
},
onShareAppMessage(res) {
let {shopCode} = app.globalData.shopInfo;
......@@ -230,6 +242,26 @@ export default {
// };
},
onReady(){
console.log('--------on--------------ready')
const device = wx.getSystemInfoSync() // 获取设备信息
const width = device.windowWidth // 示例为一个与屏幕等宽的正方形裁剪框
const height = device.windowHeight
this.cropperOptions = {
src:"",
id:'canvasId',
targetId:'targetId',
pixelRatio:device.pixelRatio,
width, // 画布宽度
height, // 画布高度
scale: 2.5, // 最大缩放倍数
zoom: 8, // 缩放系数
cut: {
x: (width - 260) / 2, // 裁剪框x轴起点
y: (height - 220) / 2, // 裁剪框y轴期起点
width: 260, // 裁剪框宽度
height: 320 // 裁剪框高度
}
}
// 上报首页打开时间
if (wx.canIUse('reportPerformance')) {
const performance = wx.getPerformance()
......@@ -261,6 +293,7 @@ export default {
})
},
onLoad(options) {
console.log('--------on--------------load')
//进页面存储需要绑定的信息
if(options.userId||options.spokesmanRelId) {
wx.setStorage({
......@@ -358,6 +391,8 @@ export default {
this.newUserFun();
},
onShow() {
// 设置显示条件
console.log('--------on--------------show')
//分销隔流
if(this.toHomePage) {
let linkVal = '/personalCenter/spokesmanCenter/mine/spokesmanHomePage?from=_goodsInfo'
......@@ -377,13 +412,155 @@ export default {
};
},
methods: {
cReady(val){
console.log(val,'----------------404')
},
upImg(){
this.chooseImg1();
},
chooseImg1() {
const self = this;
wx.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success(res) {
const src = res.tempFilePaths[0]
if (src) {
// 将图片参数传递给插件
self.chooseImg = true;
self.cropperOptions.src = src;
};
wx.hideToast()
},
fail(res) {
wx.hideToast();
wx.navigateBack()
}
})
},
async setVisible(pageList, cb) {
// 首页显示条件
let pageInfo = pageList.filter((item) => item.pageCode == 1)[0];
let pageData = JSON.parse(pageInfo.pageData);
// 查询显示条件id
let showConditionIds = checkShowConditionIds(pageData);
// 查询可显示的条件
let { data: ids ,isAreaNavigation} = await this.checkCondition(showConditionIds);
// 没有定位组件
// if (!isAreaNavigation) {
// cb()
// return
// }
// 设置visible
pageInfo.pageData = this.updateCondition(pageData, ids);
console.log(showConditionIds, "--------------5454", ids, pageInfo);
cb(pageInfo)
},
checkCondition({ allCondition }) {
return new Promise((resolve, reject) => {
// 获取
let params = { showConditionIds:allCondition, region: "" };
shop
.checkShowCondition(params)
.then((res) => {
console.log(params, "check显示条件", res.data);
if (res.data.code == 200) {
resolve(res.data);
}
})
.catch((err) => {
console.log("check显示条件失败", err);
});
});
},
updateCondition(pageData, ids) {
pageData.forEach((item) => {
pollCondition(item);
});
function pollCondition(data) {
if (Object.prototype.toString.call(data) === "[object Object]") {
// 如果等于2(仅登录显示)且登录时显示 visible重新赋值1
// 如果等于2且未登录不展示 visible重新赋值0
// 如果等于3(仅登录隐藏)且登录时不展示 visible重新赋值1
// 如果等于3且未登录展示
if(data.visible>1){
console.log(data,wx.getStorageSync('sessionid'),'------491')
}
if (data.visible && data.visible > 1 && data.visibleCopy == undefined) {
data.visibleCopy = data.visible;
console.log(data.visibleCopy,'--data.visibleCopy')
}
if ((data.visibleCopy == 2 && wx.getStorageSync('sessionid')) ||
(data.visibleCopy == 3 && !wx.getStorageSync('sessionid'))
) {
data.visible = 1;
} else if ((data.visibleCopy == 2 && !wx.getStorageSync('sessionid')) ||
(data.visibleCopy == 3 && wx.getStorageSync('sessionid'))
) {
data.visible = 0;
} else {
if (data.condition != "" && data.condition != undefined) {
data.visible = ids.some((item) => {
return item == data.condition;
})
? 1
: 0;
}
}
for (const key in data) {
if (data.hasOwnProperty(key)) {
const element = data[key];
if (
Object.prototype.toString.call(element) === "[object Object]"
) {
if (element.visible && element.visible > 1 && element.visibleCopy == undefined) {
element.visibleCopy = element.visible;
}
if ((element.visibleCopy == 2 && wx.getStorageSync('sessionid')) ||
(element.visibleCopy == 3 && !wx.getStorageSync('sessionid'))
) {
element.visible = 1;
} else if ((element.visibleCopy == 2 && !wx.getStorageSync('sessionid')) ||
(element.visibleCopy == 3 && wx.getStorageSync('sessionid'))
) {
element.visible = 0;
} else {
if (element.condition != "" && element.condition != undefined) {
console.log("979797", element.condition);
element.visible = ids.some((item) => {
return item == element.condition;
})
? 1
: 0;
}
}
pollCondition(element);
} else if (
Object.prototype.toString.call(element) === "[object Array]" &&
element.length > 0
) {
element.forEach((item) => {
pollCondition(item);
});
}
}
}
}
}
return JSON.stringify(pageData);
},
init(pageList) {
this.getCartNum();
this.active=checkTabbarPage('/');
this.pageInfo = pageList.filter((item) => item.pageCode == 1)[0];
this.setVisible(this.mpApp.globalData.pageList,(res)=>{
this.pageInfo = res;
this.pageData = JSON.parse(this.pageInfo.pageData);
console.log("36", this.pageData,this.pageInfo.pageSettingData);
});
console.log("36----------------------559", this.pageData,this.pageInfo.pageSettingData);
console.log(app.globalData.shopInfo,'app')
wx.setNavigationBarTitle({title : app.globalData.shopInfo.shopName})
......
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