Commit f73ac406 by 李嘉林

分享组件

parent d18b7cad
const app = getApp()
const app = getApp();
console.log(app, 'apppppppppp')
console.log(app, "apppppppppp");
Component({
pageLifetimes: {
show() {
console.log('哈哈哈哈')
if (typeof this.getTabBar === 'function' &&
this.getTabBar()) {
console.log("哈哈哈哈");
if (typeof this.getTabBar === "function" && this.getTabBar()) {
this.getTabBar().setData({
selected: 1
})
});
}
}
},
......@@ -17,106 +16,108 @@ Component({
selected: 0,
color: "#7A7E83",
selectedColor: "#3cc51f",
list: [{
pagePath: "/pages/home/main",
iconPath: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
selectedIconPath: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
text: "组件",
list: [
{
pagePath: "/pages/home/main",
iconPath:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
selectedIconPath:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
text: "组件",
//--多主题
condition: "",
icon: "ant-daishouhuo",
iconType: 1, //0 iconfont 1 image
imgUrl: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
selectImgUrl: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
link: {
key: "1.1.1.7",
link: "/personalCenter/spokesmanCenter?distributionModel=1",
name: "分销商中心",
type: 1
//--多主题
condition: "",
icon: "ant-daishouhuo",
iconType: 1, //0 iconfont 1 image
imgUrl:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
selectImgUrl:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
link: {
key: "1.1.1.7",
link: "/personalCenter/spokesmanCenter?distributionModel=1",
name: "分销商中心",
type: 1
},
show: true,
title: "分类页",
version: "1.0.0",
visible: 1
},
show: true,
title: "分类页",
version: "1.0.0",
visible: 1
}, {
pagePath: "/pages/index/main",
iconPath: "/static/images/bofang.png",
selectedIconPath: "/static/images/bofang.png",
text: "接口",
{
pagePath: "/pages/index/main",
iconPath: "/static/images/bofang.png",
selectedIconPath: "/static/images/bofang.png",
text: "接口",
//--多主题
condition: "",
icon: "ant-daishouhuo",
iconType: 0, //0 iconfont 1 image
imgUrl: "",
selectImgUrl: "",
link: {},
show: true,
title: "分类页",
version: "1.0.0",
visible: 1
}],
componentData: {}
//--多主题
condition: "",
icon: "ant-daishouhuo",
iconType: 0, //0 iconfont 1 image
imgUrl: "",
selectImgUrl: "",
link: {},
show: true,
title: "分类页",
version: "1.0.0",
visible: 1
}
],
componentData: {},
show: true
},
attached() {
let that = this
let that = this;
if (app.globalData.footerVal) {
that.setData({
componentData: app.globalData.footerVal.componentData,
list: app.globalData.footerVal.componentData.list
})
});
} else {
app.footerCallBack = function (params) {
app.footerCallBack = function(params) {
that.setData({
componentData: params.componentData,
list: params.componentData.list
})
}
});
};
}
// ----------webview 变化
console.log('启动1111',this.getTabBar())
console.log("启动1111", this.getTabBar());
app.webviewCallBack = function (state,params) {
console.log('webview变化',state,params)
}
app.webviewCallBack = function(state, params) {
console.log("webview变化", state, params);
};
},
methods: {
init() {
},
init() {},
switchTab(e) {
const {
index
} = e.currentTarget.dataset
console.log('755555555', this.data.list[index].link)
const { index } = e.currentTarget.dataset;
console.log("755555555", this.data.list[index].link);
app.$themeToLink(this.data.list[index]['link'],1)
app.$themeToLink(this.data.list[index]["link"], 1);
// this.toPage(this.data.list[index].link,index)
// this.setData({
// selected: index
// })
// this.setData({
// selected: index
// })
},
toPage(data,index){
console.log('index98',index,this)
toPage(data, index) {
console.log("index98", index, this);
// index=index==0?index+1:index
// 跳转
if (data.link=='/') {
wx.switchTab({
url: '/pages/home/main',
})
}else{
wx.switchTab({
url: `/pages/tabBar${index}/main`,
})
// ?from=tabbar&backpath=${
// data.link
// }
}
// 跳转
if (data.link == "/") {
wx.switchTab({
url: "/pages/home/main"
});
} else {
wx.switchTab({
url: `/pages/tabBar${index}/main`
});
// ?from=tabbar&backpath=${
// data.link
// }
}
}
}
})
});
<!--miniprogram/custom-tab-bar/index.wxml-->
<cover-view class="tab-bar">
<cover-view class="antt ant-daipinglun"></cover-view>
<cover-view class="iconfont icon-fenzhi">3</cover-view>
<cover-view class="tab-bar" wx:if="{{show}}">
<cover-view class="antt ant-daipinglun"></cover-view>
<cover-view class="iconfont icon-fenzhi">3</cover-view>
<cover-view class="tab-bar-border"></cover-view>
<cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.link}}" data-index="{{index}}"
bindtap="switchTab">
<cover-view
wx:for="{{list}}"
wx:key="index"
class="tab-bar-item"
data-path="{{item.link}}"
data-index="{{index}}"
bindtap="switchTab"
>
<cover-view wx:if="{{item.iconType==0||!item.iconType}}">
<cover-view class="antt {{item.icon}}"></cover-view>
</cover-view>
<cover-view wx:elif="{{item.iconType==1}}"
class="img-view"
style="width:{{(index==selected?componentData.selectionIconSize*2:componentData.defaultIconSize*2)+'rpx'}};height:{{(index==selected?componentData.selectionIconSize*2:componentData.defaultIconSize*2)+'rpx'}}">
<cover-view
wx:elif="{{item.iconType==1}}"
class="img-view"
style="width:{{(index==selected?componentData.selectionIconSize*2:componentData.defaultIconSize*2)+'rpx'}};height:{{(index==selected?componentData.selectionIconSize*2:componentData.defaultIconSize*2)+'rpx'}}"
>
<cover-image src="{{selected === index ? item.selectImgUrl : item.imgUrl}}"></cover-image>
</cover-view>
<!-- 名称 -->
<cover-view
style="color: {{selected === index ? componentData.selectTextColor : componentData.defaultTextColor}};font-size:{{selected === index ? componentData.selectionTextNum*2 : componentData.defaultTextNum*2}}rpx">
<cover-view style="color: {{selected === index ? componentData.selectTextColor : componentData.defaultTextColor}};font-size:{{selected === index ? componentData.selectionTextNum*2 : componentData.defaultTextNum*2}}rpx">
{{item.title}}</cover-view>
</cover-view>
</cover-view>
\ No newline at end of file
</cover-view>
......@@ -38,6 +38,7 @@ mpApp.pageCallBack = function () { }
mpApp.footerCallBack = function () { }
// webview变化
mpApp.webviewCallBack = function () { }
mpApp.shareInit = function () {};
console.log('3555555', wx)
// 全局跳转 data为link对象
......
......@@ -49,6 +49,7 @@
<van-button type="primary">按钮</van-button> -->
<!-- </div> -->
<share-popup></share-popup>
</div>
</template>
......@@ -72,6 +73,19 @@ export default {
partition,
shopPopup,
},
onShareAppMessage: function(res) {
if (res.from === "button") {
console.log(res.target,'-----------78');
}
return {
title: "分享1",
path: "",
imageUrl:"http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/18d0044d-9634-4c89-8321-3e8ff8e94cce.png",
success: function(res) {
console.log("成功", res);
}
};
},
onLoad() {
let that = this;
if (this.mpApp.globalData.pageList) {
......
......@@ -7,7 +7,8 @@
"van-button": "/static/vant/button/index",
"area-navigation":"/static/nativeComponents/AreaNavigation/index",
"cube-nav":"/static/nativeComponents/CubeNav/index",
"float-button":"/static/nativeComponents/FloatButton/index"
"float-button":"/static/nativeComponents/FloatButton/index",
"share-popup":"/static/nativeComponents/SharePopup/index"
},
"enablePullDownRefresh":true
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ export function getUrlofLink(data) {
// 全局跳转 data:link数据 option:是否为底部栏触发
export function $themeToLink(data, option) {
let app = getApp();
let type = data.type;
// 点击底部栏
......@@ -72,6 +73,7 @@ export function $themeToLink(data, option) {
// this.$themeCouponClick(data.feature.value.couponCode, data.feature.value);
} else if (featureType == 1) {//分享
console.log('是分享了。。。。');
app.shareInit({ itemList: data.feature.value });
} else if (featureType == "themeMemberCardClick" || featureType == 2) { //会员卡
// this.$themeMemberCardClick(data.feature.value);
}
......
const app = getApp();
const { $themeToLink } = app;
const componentOptions = {
// 组件选项
options: {
multipleSlots: true
},
behaviors: [],
properties: {},
// 组件数据
data: {
isPageHidden: false, // 页面是否处于隐藏状态
showPop: false,
custom: {
textShow: 1,
itemList: [1, 1, 1],
itemListInfo: [],
href: "",
toPage: "", //跳转的页面
callback: "", //回调函数
extends: {} //额外参数
},
distributorVal: "",
type: 0,
phone: "",
href: "",
posterId: -1,
spokesmanGroupId: "",
spokesmanShopId: "",
spokesmanRelId: "",
hasInvitationStatus: 0,
nickname: "",
shareGoodsInfo: {},
giftIsSend: false,
miniProgram: 0,
flag: false,
productId: "",
copyLink: "32132132"
},
// 数据监听器
observers: {},
// 组件方法
methods: {
init() {
let _this = this;
let { custom } =this.data;
app.shareInit = function(list) {
for (const key in list) {
if (list.hasOwnProperty(key)) {
if (custom[key] !== "undefined" && custom[key] !== undefined && list[key] !== "undefined" && list[key] !== undefined) {
custom[key] = list[key];
}
}
}
_this.setData({ custom });
_this.showPopup();
};
},
showPopup() {
this.setData({ showPop: true });
this.getTabBar().setData({ show: false });
},
onClose() {
this.setData({ showPop: false });
this.getTabBar().setData({ show: true });
},
cancel() {
this.onClose();
},
copyText(e) {
let { text } = e.currentTarget.dataset;
let pagePath = getCurrentPages()[0].route;
let copyVal = pagePath + text;
wx.setClipboardData({
data: copyVal,
success: function(res) {
wx.getClipboardData({
success: function(res) {
wx.showToast({ title: "复制成功" });
}
});
}
});
},
toPosters() {
let linkVal = `/goods/posters`;
$themeToLink({ type: 1, link: linkVal });
},
},
// 组件生命周期
lifetimes: {
created() {},
attached() {
this.init();
},
ready() {},
moved() {},
detached() {}
},
definitionFilter() {},
// 页面生命周期
pageLifetimes: {
// 页面被展示
show() {
const { isPageHidden } = this.data;
// show事件发生前,页面不是处于隐藏状态时
if (!isPageHidden) {
return;
}
// 重新执行定时器等操作
},
// 页面被隐藏
hide() {
this.setData({
isPageHidden: true
});
// 清除定时器等操作
},
// 页面尺寸变化时
resize() {}
}
};
Component(componentOptions);
{
"component": true,
"usingComponents": {
"van-popup": "/static/vant/popup/index"
}
}
<!-- 分享弹窗 -->
<view class="SharePopup" id="SharePopup">
<van-popup
show="{{ showPop }}"
position="bottom"
bind:close="onClose"
>
<!-- <view class="share-tip">
<text style="color:#333;font-size:28rpx;">朋友通过你分享的页面成功购买后,你可获得奖励金</text>
<text style="color:#333;font-size:24rpx;">可在【我的】 - 【distributorVal】查看奖励金</text>
</view>
<view class="share-tip">
<text style="color:#333;font-size:28rpx;">朋友通过你分享的页面成功登录后,将成为你的客户</text>
<text style="color:#333;font-size:24rpx;">可在【我的】 - 【distributorVal】-【我的客户】查看</text>
</view> -->
<view class="share-main">
<view class="share-item" wx:if="{{custom.itemList[0]==1}}">
<button
type="text"
open-type="share"
class="shareButton"
>
<image src="http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/015d5cd2-183a-44aa-9b66-5f7c2e627089.png"></image>
<text class="item-text">微信分享</text>
</button>
</view>
<view
class="share-item"
bindtap="copyText"
data-text="{{copyLink}}"
wx:if="{{custom.itemList[1]==1}}"
>
<image src="http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/0320a722-25d2-4a30-900f-790c2a541f2f.png"></image>
<text class="item-text">复制链接</text>
</view>
<view
class="share-item"
bindtap="toPosters"
wx:if="{{custom.itemList[2]==1}}"
>
<image src="http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/18d0044d-9634-4c89-8321-3e8ff8e94cce.png"></image>
<text class="item-text">生成海报</text>
</view>
</view>
<view class="share-cancel" bindtap="cancel">取消</view>
</van-popup>
</view>
.share-tip {
padding: 24rpx 0 0 32rpx;
text-align: center;
}
.share-tip text {
line-height: 48rpx;
}
.share-main {
width: 100%;
height: 254rpx;
display: flex;
justify-content: space-around;
align-items: center;
border-bottom: 20rpx solid #eeeeed;
}
.shareButton {
background-color: transparent;
padding-left: 0;
padding-right: 0;
line-height: inherit;
border-radius:0;
font-size: 28rpx;
}
.shareButton::after {
border: none;
}
.share-main .share-item {
text-align: center;
color: #333;
font-size: 28rpx;
}
.share-main .share-item image {
width: 112rpx;
height: 112rpx;
margin-bottom: 10rpx;
}
.share-cancel {
width: 100%;
height: 100rpx;
text-align: center;
line-height: 100rpx;
font-size: 34rpx;
color: #f82f2e;
}
......@@ -20,7 +20,7 @@ const componentOptions = {
// 组件数据
data: {
isPageHidden: false, // 页面是否处于隐藏状态
hideItem: false,
// hideItem: false,
timeData: {}
},
// 数据监听器
......
<!-- 活动列表item -->
<view
class="activityListItem"
wx:if="{{!hideItem||!datas.isEnd}}"
wx:if="{{!datas.isEnd}}"
bindtap="toActivity"
>
<view class="title">
......
......@@ -191,7 +191,7 @@ const componentOptions = {
});
}
if (ids.length == 0) {
this.setData({ isLoading:true });
this.setData({ isLoading:false });
return;
}
promoteApi.query_single_item_activity_list_by_ids(ids).then(res => {
......@@ -246,10 +246,9 @@ const componentOptions = {
// 组件生命周期
lifetimes: {
created() {},
attached() {
ready() {
this.getData();
},
ready() {},
moved() {},
detached() {}
},
......@@ -258,12 +257,12 @@ const componentOptions = {
pageLifetimes: {
// 页面被展示
show() {
this.getData();
const { isPageHidden } = this.data;
// show事件发生前,页面不是处于隐藏状态时
if (!isPageHidden) {
return;
}
this.getData();
// 重新执行定时器等操作
},
......
......@@ -118,14 +118,13 @@
</view>
</view>
<!-- 活动列表 -->
<block wx:if="{{datas.componentData.dimension == 1 && isLoading}}">
<activity-list-item
wx:for="{{datas.componentData.actList}}"
wx:key="index"
datas="{{item}}"
num="{{index}}"
countDownShow="{{datas.componentData['countDownShow']}}"
></activity-list-item>
</block>
<activity-list-item
wx:if="{{datas.componentData.dimension == 1}}"
wx:for="{{datas.componentData.actList}}"
wx:key="index"
datas="{{item}}"
num="{{index}}"
countDownShow="{{datas.componentData['countDownShow']}}"
></activity-list-item>
</view>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment