Commit ac073f6e by luyt

feat:添加分享弹框

1 parent 4871f402
...@@ -159,5 +159,8 @@ Component({ ...@@ -159,5 +159,8 @@ Component({
tab, tab,
}); });
}, },
onShareFn(){
this.triggerEvent('sharehandle')
}
}, },
}); });
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
<view class="prod-info"> <view class="prod-info">
<text class="title">360全景导航</text> <text class="title">360全景导航</text>
<text class="sale">新车销量 <text class="sale-num">{{senceData[actNum]['productList'][activeNavIdx].changeSale || senceData[actNum]['productList'][activeNavIdx].sale}}</text> <text class="sale">新车销量 <text class="sale-num">{{senceData[actNum]['productList'][activeNavIdx].sale}}</text>
</text> </text>
<text class="earnings">预估收益 <text class="earnings-num">{{senceData[actNum]['productList'][activeNavIdx].profit}}</text> <text class="earnings">预估收益 <text class="earnings-num">{{senceData[actNum]['productList'][activeNavIdx].profit}}</text>
</text> </text>
</view> </view>
<view class="share-btn"> <view class="share-btn" bindtap="onShareFn">
<image class="icon" src="{{IMGURL}}share.png" /> <image class="icon" src="{{IMGURL}}share.png" />
<text>分享</text> <text>分享</text>
</view> </view>
......
// pages/tab/index/components/shareModel/shareModel.js
import { IMG_URL } from "~/utils/constantData.js";
Component({
/**
* 组件的属性列表
*/
properties: {
actNum: Number, //场景选择
isShow: Boolean,
// //分享方法
// onShareAppMessage:Function,
// onShareTimeline:Function,
},
/**
* 组件的初始数据
*/
data: {
IMG_URL: `${IMG_URL}index`,
btnList: [
{
src: `${IMG_URL}index/wechat.png`,
name: "微信转发",
},
{
src: `${IMG_URL}index/moments.png`,
name: "朋友圈分享",
},
{
src: `${IMG_URL}index/down.png`,
name: "下载为海报",
},
],
// imgList
// imgList:[
// {
// src:`${IMG_URL}index/scene${actNum}1.png`,
// },
// ]
},
// observers:{
// // actNum:function(actNum) {
// // let imgList = [
// // `${IMG_URL}index/scene${actNum +1}1.png`,
// // `${IMG_URL}index/scene${actNum +1}2.png`,
// // `${IMG_URL}index/scene${actNum +1}3.png`,
// // `${IMG_URL}index/scene${actNum +1}4.png`,
// // `${IMG_URL}index/scene${actNum +1}5.png`,
// // ]
// // if(actNum != 2){
// // imgList.push(`${IMG_URL}index/scene${actNum +1}6.png`)
// // }
// // this.setData({
// // imgList
// // })
// // }
// },
/**
* 组件的方法列表
*/
methods: {
// 分享按钮
handleClick(e) {
let { index } = e.currentTarget.dataset;
switch (index) {
case 0:
this.wechatFn();
break;
case 1:
this.wechatFn();
break;
case 2:
this.download();
break;
}
},
// 微信转发
wechatFn() {
// this.data.onShareAppMessage()
this.modelClose();
},
// 朋友圈转发
momentsFn() {
// this.data.onShareTimeline()
this.modelClose();
},
// 下载海报
download() {
this.modelClose();
},
//模态框关闭
modelClose() {
this.triggerEvent("modelclose", false);
},
// 图片加载事件
onloadFn(event){
// console.log('event.detail',event.detail)
this.setData({
imgHeight: ((event.detail.height)*0.2).toFixed(0)
})
}
},
});
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/tab/index/components/shareModel/shareModel.wxss */
.share-wrap {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 1;
.img-wrap {
position: absolute;
top: 20%;
left: 50%;
transform: translateX(-50%);
width: 225px;
height: 311px;
// background-color: red;
overflow: auto;
.img {
width: 100%;
height: auto;
}
}
.btns {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 154px;
background: #ffffff;
border-radius: 8px 8px 0 0;
.top {
display: flex;
justify-content: space-around;
.btn {
padding-top: 16px;
}
.img {
display: block;
margin: 0 auto 8px;
width: 40px;
height: 40px;
}
.name {
font-size: 12px;
color: #323436;
text-align: center;
}
}
.btom {
margin: 18px auto 0;
width: 343px;
height: 44px;
line-height: 44px;
border: 1px solid #eeeeee;
border-radius: 4px;
text-align: center;
}
}
}
<!-- pages/tab/index/components/shareModel/shareModel.wxml -->
<view class="share-wrap" wx:if="{{isShow}}">
<view class="img-wrap">
<image class="img" style="height:{{imgHeight}}px" src="{{IMG_URL}}/longpic{{actNum+1}}.png" bindload="onloadFn" />
</view>
<view class="btns">
<view class="top">
<view class="btn" wx:for="{{btnList}}" wx:key="name" bindtap="handleClick" data-index="{{index}}">
<image class="img" src="{{item.src}}" />
<view class="name">{{item.name}}</view>
</view>
</view>
<view class="btom" bindtap="modelClose">取消</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
...@@ -40,7 +40,7 @@ Page({ ...@@ -40,7 +40,7 @@ Page({
msg: "1.3 存量用户众筹", msg: "1.3 存量用户众筹",
}, },
], ],
actNum: 0, actNum: 0, //car 场景选择
tabIndx: 1, tabIndx: 1,
navList: ["看线索", "看产品"], navList: ["看线索", "看产品"],
typeList: ["联系电话", "意向客户", "线索来源", "重置"], typeList: ["联系电话", "意向客户", "线索来源", "重置"],
...@@ -161,7 +161,7 @@ Page({ ...@@ -161,7 +161,7 @@ Page({
// tabList: pageData.tabList, // tabList: pageData.tabList,
// 定义数据 // 定义数据
senceData: pageData.senceData, senceData: pageData.senceData,
changeSale: 0, //每次改变的销量 isShow:false,
}, },
//引导图 //引导图
...@@ -293,16 +293,13 @@ Page({ ...@@ -293,16 +293,13 @@ Page({
this.data.senceData.forEach((item, index) => { this.data.senceData.forEach((item, index) => {
item.productList.forEach((i, lastIndex) => { item.productList.forEach((i, lastIndex) => {
if (i.profit) { if (i.profit) {
// let name = `senceData[${index}].productList[${lastIndex}].profit`;
let sale = `senceData[${index}].productList[${lastIndex}].sale`; let sale = `senceData[${index}].productList[${lastIndex}].sale`;
let name = `senceData[${index}].productList[${lastIndex}].profit`; let name = `senceData[${index}].productList[${lastIndex}].profit`;
// let changeSale = `senceData[${index}].productList[${lastIndex}].changeSale`;
let profit = _this.formula(i.productType, sales, flow); let profit = _this.formula(i.productType, sales, flow);
console.log(name, profit); console.log(name, profit);
this.setData({ this.setData({
[name]: profit, [name]: profit,
[sale]:sales [sale]:sales
// [changeSale]: sales,
}); });
} }
}); });
...@@ -384,7 +381,7 @@ Page({ ...@@ -384,7 +381,7 @@ Page({
} }
console.log(profit.length); console.log(profit.length);
console.log(productType, sales, flow, profit); console.log(productType, sales, flow, profit);
if (profit.length > 6) { if (profit.length > 8) {
return (profit / 10000).toFixed(0) + "万"; return (profit / 10000).toFixed(0) + "万";
} else { } else {
return profit; return profit;
...@@ -405,6 +402,7 @@ Page({ ...@@ -405,6 +402,7 @@ Page({
}); });
return false; return false;
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
...@@ -492,6 +490,18 @@ Page({ ...@@ -492,6 +490,18 @@ Page({
let { phone } = e.currentTarget.dataset; let { phone } = e.currentTarget.dataset;
wx.$api.setCopyData(phone); wx.$api.setCopyData(phone);
}, },
// 分项弹框关闭
modelcloseFn(e){
this.setData({
isShow: e.detail
})
},
// 分享按钮
sharehandle(){
this.setData(({
isShow: true
}))
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
...@@ -524,4 +534,5 @@ Page({ ...@@ -524,4 +534,5 @@ Page({
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function () {}, onShareAppMessage: function () {},
onShareTimeline:function () {},
}); });
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
"usingComponents": { "usingComponents": {
"product": "./components/product/product", "product": "./components/product/product",
"vas-toast": "./components/likeToast/likeToast", "vas-toast": "./components/likeToast/likeToast",
"chat":"./components/chat/chat" "chat": "./components/chat/chat",
"shareModel": "./components/shareModel/shareModel"
}, },
"navigationStyle": "custom" "navigationStyle": "custom"
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!