Commit a77b6048 by luyt

feat:看产品

1 parent 0d321a00
// pages/tab/index/components/indexProduct/indexProduct.js // pages/tab/index/components/indexProduct/indexProduct.js
import { IMG_URL } from '~/utils/constantData.js' import { IMG_URL } from "~/utils/constantData.js";
// 导入方法
import { behavior as computedBehavior } from '~/utils/lib/miniprogram-computed'
const videoBaseUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/' const videoBaseUrl =
"https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/";
Component({ Component({
// 混入
behaviors: [computedBehavior],
/** /**
* 组件的属性列表 * 组件的属性列表
*/ */
properties: { properties: {
actNum:Number, actNum: Number,
img_version:null, img_version: null,
senceData:Array, senceData: Array,
headerHeight:Number headerHeight: Number,
},
// 默认已深度监听
watch: {
'tabActive': function (a, b) {
// console.log('变化',a)
this.setData({
mainActiveIndex:0
})
this.setProType()
}
}, },
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
refresherFlag:true, refresherFlag: true,
IMG_URL, IMG_URL,
// 头部tab // 头部tab
tabActive:0, tabActive: 0,
items:[ items: [
{
text: '全部',
type: 'all'
},
{ {
text: '全部', text: "全部",
type: 'all' type: "all",
}, },
], ],
mainActiveIndex: 0, mainActiveIndex: 0,
contentHeight:0, contentHeight: 0,
// 视频海报 // 视频海报
videoActive:1 videoActive: 1,
overlayShow: false,
},
lifetimes: {
attached() {
this.setProType()
}, },
lifetimes:{ ready() {
ready(){
// console.log('lifetimes',this) // console.log('lifetimes',this)
let contentTop let contentTop;
let that = this; let that = this;
const query = this.createSelectorQuery() const query = this.createSelectorQuery();
query.select('#pro-cont').boundingClientRect(function(res){ query.select("#pro-cont").boundingClientRect(function (res) {
// console.log('top',res.top) // console.log('top',res.top)
contentTop = res.top contentTop = res.top;
//屏幕 //屏幕
const windowHeight = wx.getSystemInfoSync().windowHeight const windowHeight = wx.getSystemInfoSync().windowHeight;
// console.log('windowHeight: ', windowHeight, contentTop); // console.log('windowHeight: ', windowHeight, contentTop);
const contentHeight = windowHeight - contentTop const contentHeight = windowHeight - contentTop;
// console.log('contentHeight: ', contentHeight); // console.log('contentHeight: ', contentHeight);
that.setData({ that.setData({
contentHeight contentHeight,
}) });
}) });
query.exec() query.exec();
},
}
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
setProType(){
let { tabActive } = this.data;
let typeItems = this.getAllTypePro(tabActive, "productList");
typeItems.unshift({
text: "全部",
type: "all",
});
this.setData({
items: typeItems,
});
},
//获取当前场景下的全部 产品分类
// getAllTypePro(3,'productList')
getAllTypePro(index, type) {
// console.log('senceData[index]',senceData[index])
let {senceData} = this.data
//获取所有分类
let res = []; //[ { text: '美容类',type:xxx }, { text: '轻改类',type:xxx } ]
let list = senceData[index][type];
function someFn(element) {
return element.text == this.category;
}
if (list) {
list.forEach((item) => {
if (!res.some(someFn, item)) {
res.push({
text: item.category,
type: item.type,
});
}
});
}
// console.log('res',res)
return res;
},
// 开通
openPro() {},
openBus() {
wx.$router.go('/packagesList/apply/pages/apply')
},
onClickHide() {
this.setData({ overlayShow: false });
},
//视频 海报切换 //视频 海报切换
onclickVideoTab(event){ onclickVideoTab(event) {
// console.log('event: ', event); // console.log('event: ', event);
let videoActive = +event.currentTarget.dataset.num let videoActive = +event.currentTarget.dataset.num;
console.log('videoActive: ', videoActive); console.log("videoActive: ", videoActive);
this.setData({ this.setData({
videoActive videoActive,
}) });
}, },
onClickNav({ detail = {} }) { onClickNav({ detail = {} }) {
...@@ -82,24 +139,27 @@ Component({ ...@@ -82,24 +139,27 @@ Component({
}); });
}, },
// 头部tab回调 // 头部tab回调
onTabChange(event){ onTabChange(event) {
console.log('event: ', event); // console.log("event: ", event);
let index = event.detail.index
this.setData({
tabActive:index
})
}, },
// 选车场景切换 // 选车场景切换
selectCar(e) { selectCar(e) {
// console.log('e: ', e) // console.log('e: ', e)
let { num } = e.currentTarget.dataset let { num } = e.currentTarget.dataset;
this.triggerEvent('selectCar',num) this.triggerEvent("selectCar", num);
}, },
refresherrefreshFn(){ refresherrefreshFn() {
this.triggerEvent('refresherrefresh') this.triggerEvent("refresherrefresh");
setTimeout(()=>{ setTimeout(() => {
this.setData({ this.setData({
refresherFlag:false refresherFlag: false,
}) });
},1000) }, 1000);
},
} },
} });
})
...@@ -143,6 +143,7 @@ ...@@ -143,6 +143,7 @@
height: 44rpx; height: 44rpx;
} }
.pro-cont { .pro-cont {
position: relative;
.van-tree-select__nav { .van-tree-select__nav {
width: 116rpx; width: 116rpx;
flex: 0; flex: 0;
...@@ -236,5 +237,61 @@ ...@@ -236,5 +237,61 @@
} }
} }
} }
.expand-business{
position: absolute;
// top: calc(88rpx * 2);
left: 0;
.bus-pro{
width: 116rpx;
height: 88rpx;
line-height: 88rpx;
font-size: 22rpx;
color: #8A8C90;
text-align: center;
}
}
}
}
//图片预览
.overlay-wrap{
position: absolute;
top: 52%;
left: 50%;
transform: translate(-50%, -50%);
width: 558rpx;
height: 944rpx;
background: #FFFFFF;
border-radius: 16rpx 16rpx 0 0;
.overlay-img{
display: block;
margin: 32rpx;
width: 494rpx;
height: 880rpx;
}
.overlay-msg{
display:flex;
justify-content:center;
align-items: center;
height: 90rpx;
background: #F7F8FA;
border-radius: 0 0 12rpx 12rpx;
.hand{
margin-right: 12rpx;
width: 40rpx;
height: 40rpx;
}
.forward{
font-weight: 500;
font-size: 32rpx;
color: #3666FE;
}
}
.img-close{
position: absolute;
top: -92rpx;
right: 0;
width: 56rpx;
height: 56rpx;
} }
} }
...@@ -45,9 +45,27 @@ ...@@ -45,9 +45,27 @@
</view> </view>
</view> </view>
</van-tree-select> </van-tree-select>
<!-- +产品 +业务 -->
<view class="expand-business" style="top:{{88 * items.length}}rpx" >
<view class="bus-pro" bindtap="openBus">
+业务
</view>
<view class="bus-pro" bindtap="openPro">
+产品
</view>
</view>
</view> </view>
</view> </view>
<!-- 图片预览弹窗 --> <!-- 图片预览弹窗 -->
<van-overlay show="{{ true }}"> <van-overlay show="{{ overlayShow }}" z-index="100">
<view class="wrapper">123</view> <view class="overlay-wrap">
<image class="overlay-img" show-menu-by-longpress src="{{IMG_URL}}index/poster/poster0-0.png?v={{img_version}}" />
<view class="overlay-msg">
<image class="hand" src="{{IMG_URL}}index/hand.png?v={{img_version}}"/>
<view class="forward">长按图片转发</view>
</view>
<image class="img-close" bindtap="onClickHide" src="{{IMG_URL}}index/img-close.png?v={{img_version}}"/>
</view>
</van-overlay> </van-overlay>
...@@ -282,30 +282,6 @@ var senceData = [ ...@@ -282,30 +282,6 @@ var senceData = [
// }, // },
] ]
//获取当前场景下的全部 产品分类
const getAllTypePro= (index,type) => {
//获取所有分类
let res = []; //[ { text: '美容类' }, { text: '轻改类' } ]
let list = senceData[index][type]
function someFn(element) {
return element.text == this.category;
}
if(list){
list.forEach(item=>{
if(!res.some(someFn,item)){
res.push({
text:item.category,
type:item.type
})
}
})
}
// console.log('res',res)
return res;
}
// getAllTypePro(3,'productList')
module.exports = { module.exports = {
senceData senceData
} }
\ No newline at end of file \ No newline at end of file
...@@ -297,6 +297,7 @@ Page({ ...@@ -297,6 +297,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
// console.log('options: ', options); // console.log('options: ', options);
let { sessionId } = wx.$storage.get() let { sessionId } = wx.$storage.get()
// console.log("sessionId: ", sessionId); // console.log("sessionId: ", sessionId);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!