|
|
import { postFormId } from '../../libs/formIdCollectRequest';
|
|
|
|
|
|
|
|
|
Component({
|
|
|
options: {
|
|
|
multipleSlots: true // 在组件定义时的选项中启用多slot支持
|
|
|
},
|
|
|
/**
|
|
|
* 组件的属性列表
|
|
|
* 用于组件自定义设置
|
|
|
*/
|
|
|
properties: {
|
|
|
isShowIndicator: { //是否展示返回顶部按钮
|
|
|
type: Boolean,
|
|
|
value: false,
|
|
|
observer: "_indicatorChange"
|
|
|
},
|
|
|
|
|
|
isShowShopCart: { //是否展示购物车
|
|
|
type: Boolean,
|
|
|
value: true
|
|
|
},
|
|
|
|
|
|
marginBottom: { //底部边距
|
|
|
type: Number,
|
|
|
value: 100
|
|
|
},
|
|
|
|
|
|
isShowMenu: {
|
|
|
type: Boolean,
|
|
|
value: true
|
|
|
},
|
|
|
|
|
|
isShare: { // 是否显示分享
|
|
|
type: Boolean,
|
|
|
value: false
|
|
|
},
|
|
|
isUnionShare: {// 是否显示创建联盟分享按钮
|
|
|
type: Boolean,
|
|
|
value: false
|
|
|
},
|
|
|
isGoApp: { // 是否显示取app按钮
|
|
|
type: Boolean,
|
|
|
value: false
|
|
|
},
|
|
|
appParameter: {
|
|
|
type: String,
|
|
|
value: ''
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 私有数据,组件的初始数据
|
|
|
* 可用于模版渲染
|
|
|
*/
|
|
|
data: {
|
|
|
// 弹窗显示控制
|
|
|
isShow: true,
|
|
|
isExpand: false,
|
|
|
menuOpacity: 0,
|
|
|
funcItemAnimation: {},
|
|
|
indicatorAnimation: {},
|
|
|
isAnimation: false,
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 组件的方法列表
|
|
|
* 更新属性和数据的方法与更新页面数据的方法类似
|
|
|
*/
|
|
|
methods: {
|
|
|
//上报formid
|
|
|
formSubmit: function (e) {
|
|
|
let formId = e.detail.formId;
|
|
|
postFormId(formId)
|
|
|
},
|
|
|
|
|
|
/*
|
|
|
* 公有方法
|
|
|
*/
|
|
|
//隐藏
|
|
|
hide() {
|
|
|
this.setData({
|
|
|
isShow: !this.data.isShow
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//展示
|
|
|
show() {
|
|
|
this.setData({
|
|
|
isShow: !this.data.isShow
|
|
|
})
|
|
|
},
|
|
|
|
|
|
switchMenu() {
|
|
|
if(this.data.isAnimation){
|
|
|
return;
|
|
|
}
|
|
|
var time = 150;
|
|
|
if(this.data.isExpand){
|
|
|
this.takeback(time);
|
|
|
}else {
|
|
|
this.popout(time);
|
|
|
}
|
|
|
|
|
|
this.setData({
|
|
|
isAnimation: true
|
|
|
});
|
|
|
|
|
|
var delayTime = time;
|
|
|
setTimeout(function () {
|
|
|
this.setData({
|
|
|
isAnimation: false
|
|
|
})
|
|
|
}.bind(this), delayTime);
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
isExpand: !this.data.isExpand,
|
|
|
})
|
|
|
},
|
|
|
|
|
|
_indicatorChange: function(newVal, oldVal) {
|
|
|
var animtionIndicator = wx.createAnimation({
|
|
|
duration: 300,
|
|
|
timingFunction: 'linear',
|
|
|
});
|
|
|
|
|
|
if(newVal){
|
|
|
animtionIndicator.opacity(1).height(44).width(44).step();
|
|
|
}else {
|
|
|
animtionIndicator.opacity(0).height(0).width(0).step();
|
|
|
}
|
|
|
|
|
|
this.setData({
|
|
|
indicatorAnimation: animtionIndicator.export(),
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 动画
|
|
|
popout(time) {
|
|
|
var funcItemAnimation = wx.createAnimation({
|
|
|
duration: time,
|
|
|
timingFunction: 'ease-in-out'
|
|
|
});
|
|
|
|
|
|
funcItemAnimation.opacity(1).width(44).height(44).step({ duration: time });
|
|
|
this.setData({
|
|
|
funcItemAnimation: funcItemAnimation.export(),
|
|
|
});
|
|
|
},
|
|
|
|
|
|
takeback(time) {
|
|
|
var funcItemAnimation = wx.createAnimation({
|
|
|
duration: time,
|
|
|
timingFunction: 'ease-in-out'
|
|
|
});
|
|
|
|
|
|
funcItemAnimation.opacity(0).width(0).height(0).step({ duration: time });
|
|
|
this.setData({
|
|
|
funcItemAnimation: funcItemAnimation.export(),
|
|
|
});
|
|
|
},
|
|
|
|
|
|
jumpToHome() {
|
|
|
},
|
|
|
|
|
|
jumpToSearch() {
|
|
|
},
|
|
|
|
|
|
jumpToShopCart() {
|
|
|
},
|
|
|
|
|
|
backToTop() {
|
|
|
this.triggerEvent("backToTop");
|
|
|
},
|
|
|
|
|
|
unionShare() {
|
|
|
this.triggerEvent("unionShare");
|
|
|
},
|
|
|
|
|
|
goApp: function (e) {
|
|
|
|
|
|
var pages = getCurrentPages()
|
|
|
var currentPage = pages[pages.length - 1]
|
|
|
var url = currentPage.route
|
|
|
|
|
|
let params = {
|
|
|
PAGE_PATH: url,
|
|
|
};
|
|
|
},
|
|
|
|
|
|
launchAppError: function (e) {
|
|
|
wx.showToast({
|
|
|
title: '打开失败!您可能未安装Yoho!Buy官方APP,请下载后再尝试。',
|
|
|
icon: 'none',
|
|
|
duration: 3000
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
}) |