Commit a77b6048 by luyt

feat:看产品

1 parent 0d321a00
// 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({
// 混入
behaviors: [computedBehavior],
/**
* 组件的属性列表
*/
properties: {
actNum:Number,
img_version:null,
senceData:Array,
headerHeight:Number
actNum: Number,
img_version: null,
senceData: Array,
headerHeight: Number,
},
// 默认已深度监听
watch: {
'tabActive': function (a, b) {
// console.log('变化',a)
this.setData({
mainActiveIndex:0
})
this.setProType()
}
},
/**
* 组件的初始数据
*/
data: {
refresherFlag:true,
refresherFlag: true,
IMG_URL,
// 头部tab
tabActive:0,
items:[
tabActive: 0,
items: [
{
text: '全部',
type: 'all'
},
{
text: '全部',
type: 'all'
text: "全部",
type: "all",
},
],
mainActiveIndex: 0,
contentHeight:0,
contentHeight: 0,
// 视频海报
videoActive:1
videoActive: 1,
overlayShow: false,
},
lifetimes:{
ready(){
lifetimes: {
attached() {
this.setProType()
},
ready() {
// console.log('lifetimes',this)
let contentTop
let contentTop;
let that = this;
const query = this.createSelectorQuery()
query.select('#pro-cont').boundingClientRect(function(res){
const query = this.createSelectorQuery();
query.select("#pro-cont").boundingClientRect(function (res) {
// console.log('top',res.top)
contentTop = res.top
contentTop = res.top;
//屏幕
const windowHeight = wx.getSystemInfoSync().windowHeight
// console.log('windowHeight: ', windowHeight, contentTop);
const contentHeight = windowHeight - contentTop
// console.log('contentHeight: ', contentHeight);
that.setData({
contentHeight
})
})
query.exec()
}
//屏幕
const windowHeight = wx.getSystemInfoSync().windowHeight;
// console.log('windowHeight: ', windowHeight, contentTop);
const contentHeight = windowHeight - contentTop;
// console.log('contentHeight: ', contentHeight);
that.setData({
contentHeight,
});
});
query.exec();
},
},
/**
* 组件的方法列表
*/
methods: {
//视频 海报切换
onclickVideoTab(event){
// console.log('event: ', event);
let videoActive = +event.currentTarget.dataset.num
console.log('videoActive: ', videoActive);
this.setData({
videoActive
})
},
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;
},
onClickNav({ detail = {} }) {
this.setData({
mainActiveIndex: detail.index || 0,
});
},
// 头部tab回调
onTabChange(event){
console.log('event: ', event);
},
// 开通
openPro() {},
openBus() {
wx.$router.go('/packagesList/apply/pages/apply')
},
onClickHide() {
this.setData({ overlayShow: false });
},
// 选车场景切换
selectCar(e) {
// console.log('e: ', e)
let { num } = e.currentTarget.dataset
this.triggerEvent('selectCar',num)
},
refresherrefreshFn(){
this.triggerEvent('refresherrefresh')
setTimeout(()=>{
//视频 海报切换
onclickVideoTab(event) {
// console.log('event: ', event);
let videoActive = +event.currentTarget.dataset.num;
console.log("videoActive: ", videoActive);
this.setData({
refresherFlag:false
videoActive,
});
},
onClickNav({ detail = {} }) {
this.setData({
mainActiveIndex: detail.index || 0,
});
},
// 头部tab回调
onTabChange(event) {
// console.log("event: ", event);
let index = event.detail.index
this.setData({
tabActive:index
})
},1000)
}
}
})
},
// 选车场景切换
selectCar(e) {
// console.log('e: ', e)
let { num } = e.currentTarget.dataset;
this.triggerEvent("selectCar", num);
},
refresherrefreshFn() {
this.triggerEvent("refresherrefresh");
setTimeout(() => {
this.setData({
refresherFlag: false,
});
}, 1000);
},
},
});
......@@ -143,6 +143,7 @@
height: 44rpx;
}
.pro-cont {
position: relative;
.van-tree-select__nav {
width: 116rpx;
flex: 0;
......@@ -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 @@
</view>
</view>
</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>
<!-- 图片预览弹窗 -->
<van-overlay show="{{ true }}">
<view class="wrapper">123</view>
</van-overlay>
\ No newline at end of file
<van-overlay show="{{ overlayShow }}" z-index="100">
<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>
......@@ -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 = {
senceData
}
\ No newline at end of file
......@@ -297,6 +297,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log('options: ', options);
let { sessionId } = wx.$storage.get()
// 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!