Commit 33775768 by luyt

feat:分享视频

1 parent 33e23bc5
......@@ -181,11 +181,13 @@ Component({
},
checkProd(e){
let {tabActive} = this.data
let userInfo = wx.$storage.get('userInfo')
// let item = e.currentTarget.dataset.item
let index = e.currentTarget.dataset.index
let obj = {
actNum:tabActive, //选中的场景
activeNavIdx:index //选中的产品
activeNavIdx:index, //选中的产品
phone: userInfo.phone
}
wx.$router.go("/pages/viewProd/index",obj)
......
......@@ -23,16 +23,24 @@ Page({
// 是否授权昵称
hasUserInfo: false,
phone: '', //授权手机号
prodItemVideo:'' //选中的场景下的video的第一个
},
// 计算属性
computed: {
showLeftFlag(data) {
return data.showLeft
// 1.分享出去
// 2.点击可以改变状态
return data.isShare && !data.showLeft
},
// // 授权昵称弹框显示
// authNcknameShow(){
// }
prodItemVideo(data){
let {senceData,actNum,activeNavIdx} = data
// return senceData[actNum]?.productList[activeNavIdx]
return senceData[actNum]?.videoList[0]
},
// 授权昵称弹框显示
authNcknameShow(data){
return data.isShare && !data.hasUserInfo
}
},
/**
......@@ -41,17 +49,25 @@ Page({
*/
onLoad(options) {
if (!options || utils.isEmptyObj(options)) return
let { actNum, activeNavIdx, isShare } = options
let { actNum, activeNavIdx, isShare,phone } = options
this.setData({
actNum,
activeNavIdx,
isShare
isShare,
phone
});
//分享数据
let senceItem = senceData[actNum]
let item = senceData[actNum]?.productList[activeNavIdx]
this.shareQuery = `sceneCode=${senceItem?.sceneCode}&productCode=${item?.productCode}&isShare=${true}&productDesc=${item?.productName}&category=${item?.category}&actNum=${actNum}&activeNavIdx=${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,
......@@ -66,26 +82,34 @@ Page({
//接受跳转的路由参数(小程序页面跳转)
onRoute(options) {
if (!options || utils.isEmptyObj(options)) return
let { actNum = 0, activeNavIdx = 0 } = options;
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},戳我参与~`;
wx.setNavigationBarTitle({
title: "查看产品",
});
//分享数据
let item = senceData[actNum]?.productList[activeNavIdx]
this.shareQuery = `sceneCode=${senceData[actNum].sceneCode}&productCode=${item?.productCode}&isShare=${true}&productDesc=${item?.productName}&category=${item?.category}&actNum=${actNum}&activeNavIdx=${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,
......@@ -233,6 +257,7 @@ Page({
},
// 获取用户昵称(昵称头像)
getUserProfile(e) {
//关闭授权框
this.setData({
hasUserInfo: true
})
......@@ -261,6 +286,11 @@ Page({
}
})
},
// 1.3查看活动详情按钮
checkActive(){
// 跳转
console.log('跳转')
},
/**
* 生命周期函数--监听页面显示
*/
......
<view class="view-prod">
<video class="frame" src=""></video>
<video class="frame" src="{{prodItemVideo.videoUrl}}"></video>
<view class="title-wrap">
<view class="title">单品AR导航-新增产值20w+</view>
<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">3256</view>
<view class="num">{{prodItemVideo.view}}</view>
</view>
<view class="tab-wrap">
<van-tabs sticky bind:click="onClickTab" active="{{tabAct}}">
......@@ -24,31 +24,30 @@
<glsx-image webp src="index/phone.png" class="icon"></glsx-image>
请联系我
<view style="color:#3666fe">
<!-- {{phone}} -->
132456413
{{phone}}
</view>
</view>
</block>
<!-- 查看活动那个详情 1.3才有 -->
<block wx:if="{{ index == 1 && actNum == 3}}">
<button class="check-act" type="default" plain="true">查看活动详情</button>
<button class="check-act" type="default" plain="true" bindtap="checkActive">查看活动详情</button>
</block>
<!-- 获取更多详情 -->
<block wx:if="{{ index == 2 && !showLeftFlag}}">
<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 wx:if="{{ index >= 3 && !showLeftFlag}}" webp class="img-item img-item{{actNum}}{{index}}" src="{{item}}?v={{img_version}}">
</image>
</block>
<view class="occupancy">
<view class="occupancy" wx:if="{{!isShare}}">
<!-- padding底部 占位元素 -->
</view>
</view>
</view>
<!-- 申请按钮 -->
<apply-button downShow="{{false}}"></apply-button>
<!-- 申请按钮 不是分享出去的显示按钮 -->
<apply-button wx:if="{{!isShare}}" downShow="{{false}}"></apply-button>
<!-- 授权昵称 -->
<view wx:if="{{!hasUserInfo}}" class="user-profile" bindtap="getUserProfile"></view>
\ No newline at end of file
<view wx:if="{{authNcknameShow}}" class="user-profile" bindtap="getUserProfile"></view>
\ No newline at end of file
......@@ -3,8 +3,10 @@ import { IMG_URL } from "~/utils/constantData.js";
import { senceData } from "~/pages/tab/index/constant/data";
// 导入方法
import { behavior as computedBehavior } from "~/utils/lib/miniprogram-computed";
import utils from '~/utils/util.js'
Page({
noPageAuth: true,
// 混入
behaviors: [computedBehavior],
/**
......@@ -12,6 +14,7 @@ Page({
*/
data: {
IMG_URL,
isShare:false,//是否是被分享出去
videoSrc: "",
senceData,
tabActive: 0, //场景值
......@@ -32,29 +35,68 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {},
onLoad(options) {
let {isShare} = options;
this.setData({
isShare:isShare, //
})
this.shareDataFn(options)
},
//接受跳转的路由参数(小程序页面跳转)
onRoute(options) {
console.log("options: ", options);
this.shareDataFn(options)
},
// 分享数据函数
shareDataFn(options){
if (!options || utils.isEmptyObj(options)) return
let {tabActive,videoIndex} = options
// console.log("options: ", options, !!options);
console.log('tabActive,videoIndex: ', tabActive,videoIndex);
this.setData({
tabActive: options.tabActive,
videoIndex: options.videoIndex,
});
wx.setNavigationBarTitle({
title: "当前页面当前页面当前页面当前页面当前页面",
tabActive: tabActive,
videoIndex: videoIndex,
});
//
//分享的数据
this.changeShareData()
},
changeShareData(){
let {senceData,tabActive,videoIndex,videoitem} = this.data
// // 设置转发标题
// let userInfoObj = wx.$storage.get("userInfo");
// // #服务商账号#取该分享者商户的联系人字段,无则取商户简称,无则取商户全称
// let name = userInfoObj.merchantName;
this.shareTitle = `给您分享一个${videoitem.name } 视频`;
//分享的数据
let senceItem = senceData[tabActive]
this.shareQuery = `sceneCode=${senceItem?.sceneCode}&isShare=${true}&tabActive=${tabActive}&videoIndex=${videoIndex}`
},
changeVideo(e) {
let { index } = e.currentTarget.dataset;
this.setData({
videoIndex: index,
});
this.setpagesTitle()
this.changeShareData()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
onReady() {
this.setpagesTitle()
},
//设置标题
setpagesTitle(){
//设置标题
let {videoitem} = this.data
wx.setNavigationBarTitle({
title: videoitem.name,
});
},
/**
* 生命周期函数--监听页面显示
......
......@@ -28,4 +28,4 @@
</view>
<!-- 申请按钮 -->
<apply-button ></apply-button>
<apply-button wx:if="{{!isShare}}" ></apply-button>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!