Commit 41593d90 by luyt

feat:新增banner详情页

1 parent b7d6a7ab
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"login/accountItems/accountItems", "login/accountItems/accountItems",
"pages/viewVideo/index", "pages/viewVideo/index",
"pages/viewProd/index", "pages/viewProd/index",
"pages/viewProdBanner/index",
"pages/measure/measure/measure", "pages/measure/measure/measure",
"pages/measure/measureResult/measureResult" "pages/measure/measureResult/measureResult"
], ],
......
...@@ -192,7 +192,7 @@ Component({ ...@@ -192,7 +192,7 @@ Component({
activeNavIdx: 0, //选中的产品 activeNavIdx: 0, //选中的产品
phone: userInfo.phone, phone: userInfo.phone,
}; };
wx.$router.go("/pages/viewProd/index", obj); wx.$router.go("/pages/viewProdBanner/index", obj);
}, },
checkProd(e) { checkProd(e) {
let { tabActive } = this.data; let { tabActive } = this.data;
......
// pages/viewProd/index.js
import { behavior as computedBehavior } from '~/utils/lib/miniprogram-computed'
import { IMG_URL } from "~/utils/constantData.js";
import { senceData } from "~/pages/tab/index/constant/data";
import USERAPI from '~/api/usersApi/index'
import utils from '~/utils/util.js'
Page({
/**
* 页面的初始数据
*/
noPageAuth: true,
behaviors: [computedBehavior],
data: {
IMG_URL,
senceData,
isShare:false, //是否是分享出去的
actNum: 0,
tabAct: 0,
showLeft:false, //更多按钮显示的内容
scrollTop:0,
img_version: '0.1.0',
// 是否授权昵称
hasUserInfo: false,
phone: '', //授权手机号
prodItemVideo:'' //选中的场景下的video的第一个
},
// 计算属性
computed: {
showLeftFlag(data) {
// 1.分享出去
// 2.点击可以改变状态
return data.isShare && !data.showLeft
},
prodItemVideo(data){
let {senceData,actNum,activeNavIdx} = data
// return senceData[actNum]?.productList[activeNavIdx]
return senceData[actNum]?.videoList[0]
},
// 授权昵称弹框显示
authNcknameShow(data){
return data.isShare && !data.hasUserInfo
}
},
/**
* 生命周期函数--监听页面加载
* 分享出去,或扫码进来
*/
onLoad(options) {
if (!options || utils.isEmptyObj(options)) return
let { actNum, activeNavIdx, isShare,phone } = options
this.setData({
actNum,
activeNavIdx,
isShare,
phone
});
//分享数据
let senceItem = senceData[actNum]
let item = senceData[actNum]?.productList[activeNavIdx]
console.log('title',item.productName)
setTimeout(() => {
wx.setNavigationBarTitle({
title: item.productName,
});
},100)
this.shareQuery = `sceneCode=${senceItem?.sceneCode}&productCode=${item?.productCode}&isShare=${true}&productDesc=${item?.productName}&category=${item?.category}&actNum=${actNum}&activeNavIdx=${activeNavIdx}&phone=${phone}`
this.shareTrackData = {
sceneCode: senceItem?.sceneCode,
productCode: item?.productCode,
productName: item?.productName,
category: item?.category,
productDesc: item?.productName
// actNum,
// activeNavIdx,
}
},
//接受跳转的路由参数(小程序页面跳转)
onRoute(options) {
if (!options || utils.isEmptyObj(options)) return
let { actNum = 0, activeNavIdx = 0,phone=123 } = options;
this.setData({
actNum, //选中的场景下标
activeNavIdx, //选中的产品
phone //联系电话
});
// 设置转发标题
let userInfoObj = wx.$storage.get("userInfo");
// #服务商账号#取该分享者商户的联系人字段,无则取商户简称,无则取商户全称
let name = userInfoObj.merchantName;
this.shareTitle = `${name}给你分享一个活动${senceData[actNum]?.productList[activeNavIdx].proName},戳我参与~`;
//分享数据
let item = senceData[actNum]?.productList[activeNavIdx]
console.log('title2',item.productName)
setTimeout(() => {
wx.setNavigationBarTitle({
title: item.productName,
});
},100)
this.shareQuery = `sceneCode=${senceData[actNum].sceneCode}&productCode=${item?.productCode}&isShare=${true}&productDesc=${item?.productName}&category=${item?.category}&actNum=${actNum}&activeNavIdx=${activeNavIdx}&phone=${phone}`
this.shareTrackData = {
sceneCode: senceData[actNum]?.sceneCode,
productCode: item?.productCode,
productName: item?.productName,
category: item?.category,
productDesc: item?.productName
// actNum,
// activeNavIdx,
// apiData,
}
},
onClickTab(event) {
// console.log('event: ', event);s
let { index } = event.detail;
// console.log('index: ', index);
this.setData({
tabAct: index,
});
let { imgTopArr } = this.data;
wx.pageScrollTo({
scrollTop: imgTopArr[index],
});
},
onPageScroll: (function () {
let timer = null;
return function (e) {
// console.log("在滚动");
// 监听页面的滚动开始和结束
clearTimeout(timer);
timer = setTimeout(() => {
let { imgTopArr } = this.data;
// console.log("滚动结束",imgTopArr,e.scrollTop);
// wx.$eventbus.emit('evt_page_scroll', { scrollTop: e.scrollTop })
wx.nextTick(() => {
let idx = imgTopArr.findIndex((item) => item >e.scrollTop) - 1;
// console.log('idx: ', idx);
if (idx > -1) {
this.setData({
tabAct: idx,
scrollTop:e.scrollTop
});
} else {
this.setData({
tabAct: 0,
scrollTop:e.scrollTop
});
}
});
}, 100);
};
})(),
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
this.init()
this.getImgHeight();
},
getImgHeight() {
let query = wx.createSelectorQuery().in(this);
let heightArr = [];
let imgTopArr = [];
let s = 0;
let top;
let {scrollTop} = this.data
let _this = this;
query
.selectAll(".img-item")
.boundingClientRect((react) => {
react.forEach((item, index) => {
//44 tab的高度
// console.log('item',item)
s = item.top - 44 + scrollTop;
imgTopArr.push(s);
});
_this.setData({
imgTopArr,
});
})
.exec();
// setTimeout(() => {
// console.log('imgTopArr',this.data.imgTopArr)
// },500)
},
phoneCall(e) {
let { phone } = e.currentTarget.dataset;
wx.$api.phoneCall(phone);
},
async init() {
try {
const { data, code, message } = await USERAPI.wxCodeLogin()
if (code == '0') {
this.loginToken = data
} else this.reLogin(message)
wx.hideLoading()
} catch ({ errMsg }) {
console.error(errMsg)
this.reLogin()
}
},
/**获取loginToken */
reLogin(message) {
wx.showModal({
content: message || '获取loginToken失败',
confirmText: '重试',
confirmColor: '#3666FE'
}).then(({ confirm }) => {
if (confirm) this.init()
})
},
// 获取用户信息(手机号)
getUserInfo({ detail }) {
// console.log(detail);
if (!detail.code) return;
// this.setBtnLoading()
USERAPI.getUserProfile(this.loginToken, detail)
.then((result) => {
// console.log(result)
let userInfo = wx.$storage.get("wx_user_info");
// console.log('userInfo: ', userInfo);
let { phone } = result;
// console.log('phone: ', phone);
wx.$storage.set("wx_user_info", {
...userInfo,
phone,
});
// 显示后面的内容
setTimeout(() => {
this.getImgHeight()
},300)
this.setData({
showLeft: true
})
})
.catch(({ errMsg }) => {
wx.$api.showToast(errMsg || "系统异常");
// this.setBtnLoading(false)
});
},
// 获取用户昵称(昵称头像)
getUserProfile(e) {
//关闭授权框
this.setData({
hasUserInfo: true
})
let _this = this
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '用于完善资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: res => {
// console.log('res: ', res.userInfo.nickName);
// userInfo.nickName
this.setData({
userInfo: res.userInfo
})
let wx_user_info = wx.$storage.get('wx_user_info')
// console.log('wx_user_info: ', wx_user_info);
let obj = {
...wx_user_info,
nickName: res.userInfo.nickName,
avatarUrl: res.userInfo.avatarUrl
}
// console.log('obj',obj)
wx.$storage.set('wx_user_info', obj)
_this.onLoad(null)
}
})
},
// 1.3查看活动详情按钮
checkActive(){
// 跳转
console.log('跳转')
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});
{
"usingComponents": {
"video-item":"../tab/index/components/video-item",
"apply-button":"../viewVideo/components/apply-button/index",
"van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index"
}
}
\ No newline at end of file \ No newline at end of file
/* pages/viewVideo/index.wxss */
page {
background-color: #fff;
}
.view-prod {
.frame {
margin: 32rpx;
width: calc(100% - 64rpx);
height: 422rpx;
border-radius: 16rpx;
box-sizing: border-box;
}
.title-wrap {
margin-bottom: 32rpx;
margin-left: 32rpx;
margin-right: 32rpx;
display: flex;
align-items: center;
.title {
width: 564rpx;
height: 48rpx;
font-weight: 500;
font-size: 32rpx;
color: #323436;
// line-height: 48rpx;
}
.check {
margin-left: 30rpx;
margin-right: 6rpx;
width: 28rpx;
height: 28rpx;
}
.num {
font-size: 24rpx;
color: #5a6066;
}
}
.tab-wrap {
position: sticky;
top: 0;
margin-bottom: 20rpx;
z-index: 1;
.van-tab {
font-size: 28rpx;
color: #5a6066;
}
.van-tab--active {
font-weight: 600;
font-size: 28rpx;
color: #3666fe;
}
.van-tabs__line {
width: 112rpx !important;
height: 4rpx !important;
}
}
.prod-detail {
.occupancy{
height: 120rpx;
}
.img-item{
position: relative;
}
.phone {
position: absolute;
top: 60rpx;
right: 32rpx;
font-weight: 400;
font-size: 24rpx;
color: #6C6C6C;
display: flex;
align-items: center;
.icon {
width: 40rpx;
height: 40rpx;
margin-right: 6rpx;
}
}
.check-act{
position: absolute;
top: 20px;
right: 60rpx;
}
.more-btn {
position: absolute;
left: 50%;
bottom: 50px;
transform: translateX(-50%);
width: 622rpx;
height: 96rpx;
background-image: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/btn.png");
background-size: 100% 100%;
font-weight: 500;
font-size: 16px;
color: #ffffff;
text-align: center;
line-height: 96rpx;
}
// 流程图一
.img-item00 {
width: 100%;
height: 1110rpx;
}
.img-item01 {
width: 100%;
height: 1290rpx;
}
.img-item02 {
width: 100%;
height: 596rpx;
}
.img-item03 {
width: 100%;
height: 744rpx;
}
// 流程图二
.img-item10 {
width: 100%;
height: 2168rpx;
}
.img-item11 {
width: 100%;
height: 1290rpx;
}
.img-item12 {
width: 100%;
height: 596rpx;
}
.img-item13 {
width: 100%;
height: 830rpx;
}
// 流程图三
.img-item20 {
width: 100%;
height: 1110rpx;
}
.img-item21 {
width: 100%;
height: 1290rpx;
}
.img-item22 {
width: 100%;
height: 596rpx;
}
.img-item23 {
width: 100%;
height: 984rpx;
}
// 流程图四
.img-item30 {
width: 100%;
height: 678rpx;
}
.img-item31 {
width: 100%;
height: 1266rpx;
}
.img-item32 {
width: 100%;
height: 1398rpx;
}
.img-item33 {
width: 100%;
height: 830rpx;
}
}
}
/* 用户授权 */
.user-profile {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 3;
background-color: transparent;
}
<view class="view-prod">
<video class="frame" src="{{prodItemVideo.videoUrl}}"></video>
<view class="title-wrap">
<view class="title">{{prodItemVideo.name}}</view>
<!-- <glsx-image class="check" src="index/poster/check.png" /> -->
<image class="check" src="{{IMG_URL}}index/poster/check.png?v={{img_version}}" />
<view class="num">{{prodItemVideo.view}}</view>
</view>
<view class="tab-wrap">
<van-tabs sticky bind:click="onClickTab" active="{{tabAct}}">
<van-tab title="项目亮点"></van-tab>
<van-tab title="合作案例"></van-tab>
<van-tab title="合作方式"></van-tab>
<van-tab title="适配产品"></van-tab>
</van-tabs>
</view>
<view class="prod-detail">
<block wx:for="{{senceData[actNum].sceneImgs}}" wx:key="index">
<image wx:if="{{ index < 3}}" webp class="img-item img-item{{actNum}}{{index}}" src="{{item}}?v={{img_version}}">
<block wx:if="{{ index == 0}}">
<!-- && phone -->
<view class="phone" bindtap="phoneCall" data-phone="{{phone}}">
<!-- <image src="{{IMGURL}}share-phone.png?v={{img_version}}" class="icon"></image> -->
<glsx-image webp src="index/phone.png" class="icon"></glsx-image>
请联系我
<view style="color:#3666fe">
{{phone}}
</view>
</view>
</block>
<!-- 查看活动那个详情 1.3才有 -->
<block wx:if="{{ index == 1 && actNum == 3}}">
<button class="check-act" type="default" plain="true" bindtap="checkActive">查看活动详情</button>
</block>
<!-- 获取更多详情 -->
<block wx:if="{{ index == 2 && showLeftFlag}}">
<button class="more-btn" data-index="{{index}}" bindgetphonenumber="getUserInfo" open-type="getPhoneNumber">
点击查看更多详情
</button>
</block>
</image>
<image wx:if="{{ index >= 3 && !showLeftFlag}}" webp class="img-item img-item{{actNum}}{{index}}" src="{{item}}?v={{img_version}}">
</image>
</block>
<view class="occupancy" wx:if="{{!isShare}}">
<!-- padding底部 占位元素 -->
</view>
</view>
</view>
<!-- 申请按钮 不是分享出去的显示按钮 -->
<apply-button wx:if="{{!isShare}}" downShow="{{false}}"></apply-button>
<!-- 授权昵称 -->
<view wx:if="{{authNcknameShow}}" class="user-profile" bindtap="getUserProfile"></view>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!