Commit f73ac406 by 李嘉林

分享组件

parent d18b7cad
const app = getApp() const app = getApp();
console.log(app, 'apppppppppp') console.log(app, "apppppppppp");
Component({ Component({
pageLifetimes: { pageLifetimes: {
show() { show() {
console.log('哈哈哈哈') console.log("哈哈哈哈");
if (typeof this.getTabBar === 'function' && if (typeof this.getTabBar === "function" && this.getTabBar()) {
this.getTabBar()) {
this.getTabBar().setData({ this.getTabBar().setData({
selected: 1 selected: 1
}) });
} }
} }
}, },
...@@ -17,106 +16,108 @@ Component({ ...@@ -17,106 +16,108 @@ Component({
selected: 0, selected: 0,
color: "#7A7E83", color: "#7A7E83",
selectedColor: "#3cc51f", selectedColor: "#3cc51f",
list: [{ list: [
pagePath: "/pages/home/main", {
iconPath: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png", pagePath: "/pages/home/main",
selectedIconPath: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png", iconPath:
text: "组件", "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: "", condition: "",
icon: "ant-daishouhuo", icon: "ant-daishouhuo",
iconType: 1, //0 iconfont 1 image iconType: 1, //0 iconfont 1 image
imgUrl: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png", imgUrl:
selectImgUrl: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png", "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
link: { selectImgUrl:
key: "1.1.1.7", "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
link: "/personalCenter/spokesmanCenter?distributionModel=1", link: {
name: "分销商中心", key: "1.1.1.7",
type: 1 link: "/personalCenter/spokesmanCenter?distributionModel=1",
name: "分销商中心",
type: 1
},
show: true,
title: "分类页",
version: "1.0.0",
visible: 1
}, },
show: true, {
title: "分类页", pagePath: "/pages/index/main",
version: "1.0.0", iconPath: "/static/images/bofang.png",
visible: 1 selectedIconPath: "/static/images/bofang.png",
}, { text: "接口",
pagePath: "/pages/index/main",
iconPath: "/static/images/bofang.png",
selectedIconPath: "/static/images/bofang.png",
text: "接口",
//--多主题 //--多主题
condition: "", condition: "",
icon: "ant-daishouhuo", icon: "ant-daishouhuo",
iconType: 0, //0 iconfont 1 image iconType: 0, //0 iconfont 1 image
imgUrl: "", imgUrl: "",
selectImgUrl: "", selectImgUrl: "",
link: {}, link: {},
show: true, show: true,
title: "分类页", title: "分类页",
version: "1.0.0", version: "1.0.0",
visible: 1 visible: 1
}], }
componentData: {} ],
componentData: {},
show: true
}, },
attached() { attached() {
let that = this let that = this;
if (app.globalData.footerVal) { if (app.globalData.footerVal) {
that.setData({ that.setData({
componentData: app.globalData.footerVal.componentData, componentData: app.globalData.footerVal.componentData,
list: app.globalData.footerVal.componentData.list list: app.globalData.footerVal.componentData.list
}) });
} else { } else {
app.footerCallBack = function (params) { app.footerCallBack = function(params) {
that.setData({ that.setData({
componentData: params.componentData, componentData: params.componentData,
list: params.componentData.list list: params.componentData.list
}) });
} };
} }
// ----------webview 变化 // ----------webview 变化
console.log('启动1111',this.getTabBar()) console.log("启动1111", this.getTabBar());
app.webviewCallBack = function (state,params) { app.webviewCallBack = function(state, params) {
console.log('webview变化',state,params) console.log("webview变化", state, params);
} };
}, },
methods: { methods: {
init() { init() {},
},
switchTab(e) { switchTab(e) {
const { const { index } = e.currentTarget.dataset;
index console.log("755555555", this.data.list[index].link);
} = 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.toPage(this.data.list[index].link,index)
// this.setData({ // this.setData({
// selected: index // selected: index
// }) // })
}, },
toPage(data,index){ toPage(data, index) {
console.log('index98',index,this) console.log("index98", index, this);
// index=index==0?index+1:index // index=index==0?index+1:index
// 跳转 // 跳转
if (data.link=='/') { if (data.link == "/") {
wx.switchTab({ wx.switchTab({
url: '/pages/home/main', url: "/pages/home/main"
}) });
}else{ } else {
wx.switchTab({ wx.switchTab({
url: `/pages/tabBar${index}/main`, url: `/pages/tabBar${index}/main`
}) });
// ?from=tabbar&backpath=${ // ?from=tabbar&backpath=${
// data.link // data.link
// } // }
} }
} }
} }
}) });
<!--miniprogram/custom-tab-bar/index.wxml--> <!--miniprogram/custom-tab-bar/index.wxml-->
<cover-view class="tab-bar"> <cover-view class="tab-bar" wx:if="{{show}}">
<cover-view class="antt ant-daipinglun"></cover-view> <cover-view class="antt ant-daipinglun"></cover-view>
<cover-view class="iconfont icon-fenzhi">3</cover-view> <cover-view class="iconfont icon-fenzhi">3</cover-view>
<cover-view class="tab-bar-border"></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}}" <cover-view
bindtap="switchTab"> 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 wx:if="{{item.iconType==0||!item.iconType}}">
<cover-view class="antt {{item.icon}}"></cover-view> <cover-view class="antt {{item.icon}}"></cover-view>
</cover-view> </cover-view>
<cover-view wx:elif="{{item.iconType==1}}" <cover-view
class="img-view" wx:elif="{{item.iconType==1}}"
style="width:{{(index==selected?componentData.selectionIconSize*2:componentData.defaultIconSize*2)+'rpx'}};height:{{(index==selected?componentData.selectionIconSize*2:componentData.defaultIconSize*2)+'rpx'}}"> 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-image src="{{selected === index ? item.selectImgUrl : item.imgUrl}}"></cover-image>
</cover-view> </cover-view>
<!-- 名称 --> <!-- 名称 -->
<cover-view <cover-view style="color: {{selected === index ? componentData.selectTextColor : componentData.defaultTextColor}};font-size:{{selected === index ? componentData.selectionTextNum*2 : componentData.defaultTextNum*2}}rpx">
style="color: {{selected === index ? componentData.selectTextColor : componentData.defaultTextColor}};font-size:{{selected === index ? componentData.selectionTextNum*2 : componentData.defaultTextNum*2}}rpx">
{{item.title}}</cover-view> {{item.title}}</cover-view>
</cover-view> </cover-view>
</cover-view> </cover-view>
\ No newline at end of file
...@@ -38,6 +38,7 @@ mpApp.pageCallBack = function () { } ...@@ -38,6 +38,7 @@ mpApp.pageCallBack = function () { }
mpApp.footerCallBack = function () { } mpApp.footerCallBack = function () { }
// webview变化 // webview变化
mpApp.webviewCallBack = function () { } mpApp.webviewCallBack = function () { }
mpApp.shareInit = function () {};
console.log('3555555', wx) console.log('3555555', wx)
// 全局跳转 data为link对象 // 全局跳转 data为link对象
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
<van-button type="primary">按钮</van-button> --> <van-button type="primary">按钮</van-button> -->
<!-- </div> --> <!-- </div> -->
<share-popup></share-popup>
</div> </div>
</template> </template>
...@@ -72,6 +73,19 @@ export default { ...@@ -72,6 +73,19 @@ export default {
partition, partition,
shopPopup, 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() { onLoad() {
let that = this; let that = this;
if (this.mpApp.globalData.pageList) { if (this.mpApp.globalData.pageList) {
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
"van-button": "/static/vant/button/index", "van-button": "/static/vant/button/index",
"area-navigation":"/static/nativeComponents/AreaNavigation/index", "area-navigation":"/static/nativeComponents/AreaNavigation/index",
"cube-nav":"/static/nativeComponents/CubeNav/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 "enablePullDownRefresh":true
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ export function getUrlofLink(data) { ...@@ -5,6 +5,7 @@ export function getUrlofLink(data) {
// 全局跳转 data:link数据 option:是否为底部栏触发 // 全局跳转 data:link数据 option:是否为底部栏触发
export function $themeToLink(data, option) { export function $themeToLink(data, option) {
let app = getApp();
let type = data.type; let type = data.type;
// 点击底部栏 // 点击底部栏
...@@ -72,6 +73,7 @@ export function $themeToLink(data, option) { ...@@ -72,6 +73,7 @@ export function $themeToLink(data, option) {
// this.$themeCouponClick(data.feature.value.couponCode, data.feature.value); // this.$themeCouponClick(data.feature.value.couponCode, data.feature.value);
} else if (featureType == 1) {//分享 } else if (featureType == 1) {//分享
console.log('是分享了。。。。'); console.log('是分享了。。。。');
app.shareInit({ itemList: data.feature.value });
} else if (featureType == "themeMemberCardClick" || featureType == 2) { //会员卡 } else if (featureType == "themeMemberCardClick" || featureType == 2) { //会员卡
// this.$themeMemberCardClick(data.feature.value); // 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 = { ...@@ -20,7 +20,7 @@ const componentOptions = {
// 组件数据 // 组件数据
data: { data: {
isPageHidden: false, // 页面是否处于隐藏状态 isPageHidden: false, // 页面是否处于隐藏状态
hideItem: false, // hideItem: false,
timeData: {} timeData: {}
}, },
// 数据监听器 // 数据监听器
......
<!-- 活动列表item --> <!-- 活动列表item -->
<view <view
class="activityListItem" class="activityListItem"
wx:if="{{!hideItem||!datas.isEnd}}" wx:if="{{!datas.isEnd}}"
bindtap="toActivity" bindtap="toActivity"
> >
<view class="title"> <view class="title">
......
...@@ -191,7 +191,7 @@ const componentOptions = { ...@@ -191,7 +191,7 @@ const componentOptions = {
}); });
} }
if (ids.length == 0) { if (ids.length == 0) {
this.setData({ isLoading:true }); this.setData({ isLoading:false });
return; return;
} }
promoteApi.query_single_item_activity_list_by_ids(ids).then(res => { promoteApi.query_single_item_activity_list_by_ids(ids).then(res => {
...@@ -246,10 +246,9 @@ const componentOptions = { ...@@ -246,10 +246,9 @@ const componentOptions = {
// 组件生命周期 // 组件生命周期
lifetimes: { lifetimes: {
created() {}, created() {},
attached() { ready() {
this.getData(); this.getData();
}, },
ready() {},
moved() {}, moved() {},
detached() {} detached() {}
}, },
...@@ -258,12 +257,12 @@ const componentOptions = { ...@@ -258,12 +257,12 @@ const componentOptions = {
pageLifetimes: { pageLifetimes: {
// 页面被展示 // 页面被展示
show() { show() {
this.getData();
const { isPageHidden } = this.data; const { isPageHidden } = this.data;
// show事件发生前,页面不是处于隐藏状态时 // show事件发生前,页面不是处于隐藏状态时
if (!isPageHidden) { if (!isPageHidden) {
return; return;
} }
this.getData();
// 重新执行定时器等操作 // 重新执行定时器等操作
}, },
......
...@@ -118,14 +118,13 @@ ...@@ -118,14 +118,13 @@
</view> </view>
</view> </view>
<!-- 活动列表 --> <!-- 活动列表 -->
<block wx:if="{{datas.componentData.dimension == 1 && isLoading}}"> <activity-list-item
<activity-list-item wx:if="{{datas.componentData.dimension == 1}}"
wx:for="{{datas.componentData.actList}}" wx:for="{{datas.componentData.actList}}"
wx:key="index" wx:key="index"
datas="{{item}}" datas="{{item}}"
num="{{index}}" num="{{index}}"
countDownShow="{{datas.componentData['countDownShow']}}" countDownShow="{{datas.componentData['countDownShow']}}"
></activity-list-item> ></activity-list-item>
</block>
</view> </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