Commit d18b7cad by 程智春

Merge branch 'nativehome_tst' of http://code.mayi888.com/chengmo/mayi-mp-shop into nativehome_tst

parents 8d919715 40c48936
......@@ -2,6 +2,17 @@ const app = getApp()
console.log(app, 'apppppppppp')
Component({
pageLifetimes: {
show() {
console.log('哈哈哈哈')
if (typeof this.getTabBar === 'function' &&
this.getTabBar()) {
this.getTabBar().setData({
selected: 1
})
}
}
},
data: {
selected: 0,
color: "#7A7E83",
......@@ -65,7 +76,9 @@ Component({
}
// ----------webview 变化
console.log('启动1111')
console.log('启动1111',this.getTabBar())
app.webviewCallBack = function (state,params) {
console.log('webview变化',state,params)
}
......@@ -75,27 +88,22 @@ Component({
},
switchTab(e) {
// mpApp.$themeToLink //
const {
index
} = e.currentTarget.dataset
console.log('755555555', this.data.list[index].link)
// if (index == this.data.selected) return
app.globalData.tabBarPageLink=this.data.list[index].link.link
app.$themeToLink(this.data.list[index]['link'],1)
console.log(app,'aaaa')
this.toPage(this.data.list[index].link,index)
// return
// app.$themeToLink(this.data.list[index].link)
// this.setData({
// selected: index
// })
// this.toPage(this.data.list[index].link,index)
// this.setData({
// selected: index
// })
},
toPage(data,index){
console.log('index98',index)
console.log('index98',index,this)
// index=index==0?index+1:index
// 跳转
if (data.link=='/') {
wx.switchTab({
......
<!--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-border"></cover-view>
<cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.link}}" data-index="{{index}}"
bindtap="switchTab">
......
......@@ -53,6 +53,8 @@ export default {
let defaultComponentModel = res.data.data.shopThemeData;
this.mpApp.globalData.shopThemeData = res.data.data.shopThemeData;
this.mpApp.globalData.shopInfo=res.data.data;
// 获取底部栏数据
let val = JSON.parse(defaultComponentModel);
if (val && val.defaultComponentModel) {
......
import { requestPOST, requestGET } from "@/utils/request.js";
export default {
getSingleItemActivityV2(data) {
return requestPOST(`${process.env.OLSHOP_URL}/promotion/v2/query_single_item_activity_detail`, data);
},
// 根据列表查询活动
query_single_item_activity_list_by_ids(data) {
return requestPOST(`${process.env.OLSHOP_URL}/promotion/query_single_item_activity_list_by_ids`, data);
},
};
\ No newline at end of file
......@@ -4,6 +4,7 @@ import Store from './store/index'
import "../static/nicon/iconfont.css"
import goodsApi from "./api/goods"
import orderApi from "./api/order"
import promoteApi from "./api/promote";
import { DFSImg } from "@/utils/index";
import { $themeToLink } from "@/utils/mayi"
......@@ -45,4 +46,5 @@ mpApp.$themeToLink = $themeToLink
// api
mpApp.goodsApi = goodsApi;
mpApp.orderApi = orderApi;
mpApp.promoteApi = promoteApi;
mpApp.DFSImg = DFSImg;
<template>
<div class="domain">
<view class="ant-daipinglun">1</view>
<!-- <goods-list id="goodsList"></goods-list> -->
<div v-for="(item,index) in pageData" :key="index">
<div v-if="item.componentCode=='banner'">
<banner :datas="item"></banner>
<scroll-view @scroll="scrolls" @scrolltolower="scrolltolower" style="height:100vh;" scroll-y="true">
<div v-for="(item,index) in pageData" :key="index">
<div v-if="item.componentCode=='banner'">
<banner :datas="item"></banner>
</div>
<div v-else-if="item.componentCode=='goods-list'" style="height:100%;">
<goods-list class="goodsListItem" :datas="item"></goods-list>
</div>
<div v-else-if="item.componentCode == 'area-navigation'">
<area-navigation :datas="item"></area-navigation>
</div>
<div v-else-if="item.componentCode == 'cube-nav'">
<cube-nav :datas="item"></cube-nav>
</div>
<div v-else-if="item.componentCode == 'time-limited-discount'">
<time-limited-discount :datas="item"></time-limited-discount>
</div>
<div v-if="item.componentCode == 'links'">
<links :datas="item"></links>
</div>
<div v-if="item.componentCode == 'interval'">
<interval :datas="item"></interval>
</div>
<div v-if="item.componentCode == 'partition'">
<partition :datas="item"></partition>
</div>
<div v-if="item.componentCode == 'shop-popup'">
<shop-popup :datas="item"></shop-popup>
</div>
<div v-if="item.componentCode == 'float-button'">
<float-button :datas="item"></float-button>
</div>
</div>
<div v-else-if="item.componentCode=='goods-list'">
<goods-list :datas="item"></goods-list>
</div>
<div v-if="item.componentCode == 'area-navigation'">
<area-navigation :datas="item"></area-navigation>
</div>
<div v-if="item.componentCode == 'cube-nav'">
<cube-nav :datas="item"></cube-nav>
</div>
<div v-if="item.componentCode == 'links'">
<links :datas="item"></links>
</div>
<div v-if="item.componentCode == 'interval'">
<interval :datas="item"></interval>
</div>
<div v-if="item.componentCode == 'partition'">
<partition :datas="item"></partition>
</div>
<div v-if="item.componentCode == 'shop-popup'">
<shop-popup :datas="item"></shop-popup>
</div>
<div v-if="item.componentCode == 'float-button'">
<float-button :datas="item"></float-button>
</div>
</div>
</scroll-view>
<!-- <image
src="http://cdn.mayi888.com/public/jpg/33ff0efc-96b5-4044-a65a-07799dfe98e1.jpg?x-oss-process=image/resize,limit_1,w_750"
></image>
<van-button type="primary">按钮</van-button>
<view class="ant-bofang">1</view> -->
-->
<!-- ----瀑布流开始---- -->
<!-- <waterfall-flow id="waterfallFlow"></waterfall-flow> -->
<!-- ----瀑布流结束---- -->
......@@ -51,6 +57,8 @@ import links from '@/components/basicTool/link/index.vue'
import interval from '@/components/basicTool/interval/index.vue'
import partition from '@/components/basicTool/partition/index.vue'
import shopPopup from '@/components/basicTool/shop-popup/index.vue'
import { setTabBarActive, checkTabbarPage } from "../../utils/mayi.js";
export default {
data() {
return {
......@@ -74,19 +82,31 @@ export default {
};
}
},
onShow() {
setTabBarActive.bind(this)(checkTabbarPage('/'));
},
methods: {
init(pageList) {
setTabBarActive.bind(this)(checkTabbarPage('/'));
this.pageInfo = pageList.filter((item) => item.pageCode == 1)[0];
this.pageData = JSON.parse(this.pageInfo.pageData);
console.log('36',this.pageData)
console.log("36", this.pageData);
},
scrolls(el){
console.log('scroll')
this.$mp.page.selectComponent(".goodsListItem").getScroll(el);
},
scrolltolower(){
console.log("scrolltolower")
}
},
};
</script>
<style>
.domain {
text-align: center;
/* text-align: center; */
/* padding-top: 50%; */
}
</style>
\ No newline at end of file
......@@ -2,6 +2,7 @@
"usingComponents": {
"banner": "/static/nativeComponents/Banner/index",
"goods-list": "/static/nativeComponents/GoodsList/index",
"time-limited-discount": "/static/nativeComponents/TimeLimitedDiscount/index",
"waterfall-flow": "/static/nativeComponents/module/WaterfallFlow/index",
"van-button": "/static/vant/button/index",
"area-navigation":"/static/nativeComponents/AreaNavigation/index",
......
......@@ -79,15 +79,6 @@ export default {
this.options = options;
Object.assign(this.$data, this.$options.data());
console.log(
wx.getStorageSync("sessionid"),
options,
"index------",
this.shopId,
"-----",
wx.getStorageSync("openid"),
this.shopId
);
//获取openId
wx.login({
success: res => {
......@@ -109,21 +100,7 @@ export default {
//检测登录态
this.checkLogin();
console.log(this.params,6666666)
this.options = options;
console.log('-------1',options.scene)
console.log(this.options)
console.log('-------link',this.mpApp.globalData.tabBarPageLink)
// tabbar 跳转
// if (this.mpApp.globalData.tabBarPageLink) {
// this.page = this.mpApp.globalData.tabBarPageLink;
// this.mpApp.globalData.tabBarPageLink=''
// }
// if (options.from && options.from == "tabbar") {
// this.page = decodeURIComponent(options.backpath);
// }
// ---------
if (options.share) {
//来自分享
this.link = decodeURIComponent(options.share);
......@@ -153,6 +130,9 @@ export default {
} else if (options.from && (options.from == "home" || options.from == "livedToIndex")) {
//来自直播详情
this.page = decodeURIComponent(options.backpath);
if(this.page.includes("?")){
this.params="&mixid=" + this.shopId;
}
options.params && (this.params += "&" + serialize(options.params));
} else if (options.from && options.from == "livedBackShop") {
//直播页back到商城
......@@ -327,6 +307,19 @@ export default {
}
this.init();
},
onShow(){
let ss=wx.getStorageSync("sessionid");
if (ss && !this.params.includes("sessionid")) {
this.params +=`&sessionid=${ss}`
}
console.log(this.getTabBar,'312')
if (typeof this.getTabBar === 'function' &&
this.getTabBar()) {
this.getTabBar().setData({
selected: this.index
})
}
},
methods: {
init() {
// 获取小程序开启的订阅消息配置
......
......@@ -27,12 +27,14 @@
<script>
import { serialize } from "@/utils/index";
import { checkTabbarPage } from "@/utils/mayi";
import { wx_decode } from "@/utils/wxIndex.js";
import login from "@/api/login";
import shop from "@/api/shop";
import indexApi from "@/api/index.js";
var WXBizDataCrypt = require("@/utils/WXBizDataCrypt");
export default {
name:'login',
components: {
// card
},
......@@ -315,11 +317,24 @@ export default {
delta: 1
});
}else{
wx.reLaunch({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${encodeURIComponent(this.backParams)}`
});
let parseLink=decodeURIComponent(this.backPath);
let isTabbarIndex =checkTabbarPage(parseLink)
console.log('32111',isTabbarIndex,parseLink)
wx.navigateBack()
return
if(isTabbarIndex>-1){
wx.navigateBack()
// wx.switchTab({
// url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`,
// })
}else{
wx.redirectTo({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${encodeURIComponent(this.backParams)}`
});
}
}
},
getPhoneNumber(e) {
......
......@@ -3,28 +3,39 @@
-->
<template>
<div>
{{ pageUrl }}
<web-view :src="pageUrl" @error="handleError"></web-view>
</div>
</template>
<script>
import { getUrlofLink } from "../../utils/mayi.js";
import {
getUrlofLink,
setTabBarActive,
checkTabbarPage,
} from "../../utils/mayi.js";
export default {
data() {
return {
link: process.env.BASE_URL,
page: "/",
params: "?mixid=" + this.$store.state.mixid,
index:1
index: 1,
ss: "",
};
},
computed: {
pageUrl() {
return this.link + this.page + this.params;
return this.link + this.page + this.params + this.ss;
},
},
onLoad(options) {
let ss = wx.getStorageSync("sessionid");
this.ss = ss ? `&sessionid=${ss}` : "";
// tabbar 跳转
let homeIndex = checkTabbarPage("/");
homeIndex != 0 && homeIndex==this.index && (this.index = 0);
if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
......@@ -32,20 +43,13 @@ export default {
this.mpApp.globalData.tabBarPageLink = "";
}
},
onShow(){
console.log('show')
if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
);
this.mpApp.globalData.tabBarPageLink = "";
onShow() {
let ss = wx.getStorageSync("sessionid");
if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`;
}
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
setTabBarActive.bind(this)(this.index);
},
methods: {
handleError(data) {
......
......@@ -3,28 +3,39 @@
-->
<template>
<div>
{{ pageUrl }}
<web-view :src="pageUrl" @error="handleError"></web-view>
</div>
</template>
<script>
import { getUrlofLink } from "../../utils/mayi.js";
import {
getUrlofLink,
setTabBarActive,
checkTabbarPage,
} from "../../utils/mayi.js";
export default {
data() {
return {
link: process.env.BASE_URL,
page: "/",
params: "?mixid=" + this.$store.state.mixid,
index:2
index: 2,
ss: "",
};
},
computed: {
pageUrl() {
return this.link + this.page + this.params;
return this.link + this.page + this.params + this.ss;
},
},
onLoad(options) {
let ss = wx.getStorageSync("sessionid");
this.ss = ss ? `&sessionid=${ss}` : "";
// tabbar 跳转
let homeIndex = checkTabbarPage("/");
homeIndex != 0 && homeIndex==this.index && (this.index = 0);
if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
......@@ -32,14 +43,14 @@ export default {
this.mpApp.globalData.tabBarPageLink = "";
}
},
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
onShow() {
let ss = wx.getStorageSync("sessionid");
if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`;
}
setTabBarActive.bind(this)(this.index);
},
methods: {
handleError(data) {
wx.showLoading({
......
......@@ -3,43 +3,60 @@
-->
<template>
<div>
{{ pageUrl }}
<web-view :src="pageUrl" @error="handleError"></web-view>
</div>
</template>
<script>
import { getUrlofLink } from "../../utils/mayi.js";
import {
getUrlofLink,
setTabBarActive,
checkTabbarPage,
} from "../../utils/mayi.js";
export default {
data() {
return {
link: process.env.BASE_URL,
page: "/",
params: "?mixid=" + this.$store.state.mixid,
index:3
index: 3,
ss: "",
};
},
computed: {
pageUrl() {
return this.link + this.page + this.params;
return this.link + this.page + this.params + this.ss;
},
},
onLoad(options) {
let ss = wx.getStorageSync("sessionid");
this.ss = ss ? `&sessionid=${ss}` : "";
// tabbar 跳转
let homeIndex = checkTabbarPage("/");
homeIndex != 0 && homeIndex==this.index && (this.index = 0);
if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
);
let p= getUrlofLink(this.mpApp.globalData.footerVal.componentData.list[this.index].link);
let pl=p.split('?')
if (pl[1]) {
this.page=pl[0]
this.params+='&'+pl[1]
}else{
this.page = p
}
this.mpApp.globalData.tabBarPageLink = "";
}
},
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
onShow() {
let ss = wx.getStorageSync("sessionid");
if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`;
}
setTabBarActive.bind(this)(this.index);
},
methods: {
handleError(data) {
wx.showLoading({
......
......@@ -3,43 +3,60 @@
-->
<template>
<div>
{{ pageUrl }}
<web-view :src="pageUrl" @error="handleError"></web-view>
</div>
</template>
<script>
import { getUrlofLink } from "../../utils/mayi.js";
import {
getUrlofLink,
setTabBarActive,
checkTabbarPage,
} from "../../utils/mayi.js";
export default {
data() {
return {
link: process.env.BASE_URL,
page: "/",
params: "?mixid=" + this.$store.state.mixid,
index:4
index: 4,
ss: "",
};
},
computed: {
pageUrl() {
return this.link + this.page + this.params;
return this.link + this.page + this.params + this.ss;
},
},
onLoad(options) {
let ss = wx.getStorageSync("sessionid");
this.ss = ss ? `&sessionid=${ss}` : "";
// tabbar 跳转
let homeIndex = checkTabbarPage("/");
homeIndex != 0 && homeIndex==this.index && (this.index = 0);
if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
);
let p= getUrlofLink(this.mpApp.globalData.footerVal.componentData.list[this.index].link);
let pl=p.split('?')
if (pl[1]) {
this.page=pl[0]
this.params+='&'+pl[1]
}else{
this.page = p
}
this.mpApp.globalData.tabBarPageLink = "";
}
},
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
onShow() {
let ss = wx.getStorageSync("sessionid");
if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`;
}
setTabBarActive.bind(this)(this.index);
},
methods: {
handleError(data) {
wx.showLoading({
......
......@@ -3,13 +3,24 @@ export function getUrlofLink(data) {
return data.link
}
// 全局跳转
export function $themeToLink(data) {
let app = getApp()
let footerVal = app.globalData.footerVal.componentData.list;
console.log('393939', footerVal)
// 全局跳转 data:link数据 option:是否为底部栏触发
export function $themeToLink(data, option) {
let type = data.type;
// 点击底部栏
if (option) {
let parseLink = getUrlofLink(data);
let isTabbarIndex = checkTabbarPage(parseLink);
// 替换首页位置
isTabbarIndex = isTabbarIndex == 0 ? checkTabbarPage('/') : isTabbarIndex
wx.switchTab({
url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`,
})
console.log(option, data)
return
}
// 历史数据
if (type == undefined || type == 'undefined') {
if (data.length > 0) {
......@@ -17,17 +28,16 @@ export function $themeToLink(data) {
}
return
}
// 底部导航跳转
let parseLink = getUrlofLink(data)
let isFooter = footerVal.findIndex(item => {
return item.link.link == parseLink
})
if (isFooter > -1) {
wx.switchTab({
url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isFooter}/main`,
})
return
}
// let parseLink=getUrlofLink(data)
// let isTabbarIndex =checkTabbarPage(parseLink )
// if (isTabbarIndex>-1) {
// wx.switchTab({
// url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`,
// })
// return
// }
// -----------------
......@@ -77,10 +87,32 @@ export function $themeToLink(data) {
}
}
function toPage(backPath, backParams) {
function toPage(backPath, backParams = "") {
wx.navigateTo({
url: `../index/main?from=home&backpath=${backPath}&params=${encodeURIComponent(backParams)}`
url: `../index/main?from=home&backpath=${encodeURIComponent(backPath)}&params=${encodeURIComponent(backParams)}`
});
}
// check url是否为底部栏配置项
\ No newline at end of file
// check 链接是否为底部导航栏页面 返回索引
export function checkTabbarPage(link) {
let app = getApp()
if (!app.globalData.footerVal) return -1
let footerVal = app.globalData.footerVal.componentData.list;
let isFooter = footerVal.findIndex(item => {
return item.link.link == link
})
return isFooter
}
// 当前底部栏选中项
export function setTabBarActive(data) {
console.log(this, 'this', data)
if (data < 0 || !this.$mp.page) return
if (typeof this.$mp.page.getTabBar === 'function' &&
this.$mp.page.getTabBar()) {
this.$mp.page.getTabBar().setData({
selected: data
})
}
}
const app = getApp();
const { goodsApi, DFSImg, $themeToLink } = app;
const componentOptions = {
// 组件选项
options: {
......@@ -18,7 +20,7 @@ const componentOptions = {
// 组件数据
data: {
isPageHidden: false, // 页面是否处于隐藏状态
timeData: {},
timeData: {}
},
// 数据监听器
observers: {},
......@@ -54,7 +56,49 @@ const componentOptions = {
},
onChange(e) {
this.setData({ timeData: e.detail });
}
},
onclickProduct() {
let { goodsType } = this.data.datas.componentData;
let {
productId,
terminalProductId,
terminalGoodsMixId
} = this.data.items;
let linkVal = "";
if (goodsType == 0) {
linkVal = `/goods/${productId}?terminalProductId=${terminalProductId}`;
} else if (goodsType == 1) {
linkVal = `/pointShop/goodsDetail?productId${productId}&terminalProductId=${terminalProductId}&terminalGoodsMixId=${terminalGoodsMixId}`;
}
$themeToLink({
type: 1,
link: linkVal
});
},
onclickBuynow() {
let { btnType } = this.data.datas.componentData;
let {
minProductGoodsMixid,
minProductGoodsId,
minGoodsId
} = this.data.items;
let linkVal = "";
if (btnType < 6) {
// 加入购物车
console.log("加入购物车");
// this.$themeAddToCard(item);
} else {
// 进入确认订单
linkVal = `/order/orderConfirm?productGoodsMixId=${minProductGoodsMixid}&productGoodsId=${minProductGoodsId}&goodsId=${minGoodsId}&qty=1&goodsString=null&source=3`;
}
console.log(linkVal, "-------90");
$themeToLink({ type: 1, link: linkVal });
},
toMerchants() {
let { orgId } = this.data.items;
$themeToLink({ type: 1, link: `/merchantsDetail/${orgId}` });
},
},
// 组件生命周期
lifetimes: {
......
<!-- 商品列表item -->
<view class="goodsItem {{datas.componentData.style==='rowList'?'goodsRowList':''}} {{datas.componentData.style==='heap'?'goodsRowList goodsHeapItem':''}}" style="--proGap2:{{datas.componentData.proGap*2}}rpx;">
<view
class="goodsItem {{datas.componentData.style==='rowList'?'goodsRowList':''}} {{datas.componentData.style==='heap'?'goodsRowList goodsHeapItem':''}}"
style="--proGap2:{{datas.componentData.proGap*2}}rpx;"
bindtap="onclickProduct"
>
<view class="goods-item-child {{datas.componentData['borderColorShow']?'goods-item-child-bd':''}}" style="border-radius:{{datas.componentData.borderRadius}}em;--border_color:{{datas.componentData['borderColor']}};box-shadow:{{datas.componentData['cardShadow']?'0rpx 0rpx 10rpx '+datas.componentData['cardShadowSize']*2+'rpx #ccc':''}};">
<!-- 商户入口-顶部 -->
<view class="merchantsEntrance flex" wx:if="{{datas.componentData['merchantsEntrance'] && datas.componentData['merchantsEntranceType'] == 0 && datas.componentData.style!='heap'}}">
<view
class="merchantsEntrance flex"
bindtoMerchants="toMerchants"
wx:if="{{datas.componentData['merchantsEntrance'] && datas.componentData['merchantsEntranceType'] == 0 && datas.componentData.style!='heap'}}"
>
<view class="left flex" wx:if="{{items != null}}">
<view class="logo">
<image mode='widthFix' src="{{items.shopLogoUrl}}" />
......@@ -71,7 +79,11 @@
<!-- 商品详情 -->
<view class="info" style="text-align:{{datas.componentData['initcharAlign']}};">
<view class="info-top flex">
<view class="name" wx:if="{{datas.componentData['nameShow']}}">
<view
class="name"
wx:if="{{datas.componentData['nameShow']}}"
style="color:{{datas.componentData['nameColor']}};font-weight:{{datas.componentData['nameFontWeight']}};font-size:{{datas.componentData['nameFontSize']}}em;height:2.8em;"
>
{{items!=null?items['productName']:'名称'}}
</view>
<view
......@@ -148,7 +160,7 @@
>
已售罄
</view>
<view wx:if="{{(items&&items.totalQty-0>0||items&&items.oversoldFlag==1)&& datas.componentData['paynow']}}">
<view wx:if="{{(items&&items.totalQty-0>0||items&&items.oversoldFlag==1)&& datas.componentData['paynow']}}" catchtap="onclickBuynow">
<text wx:if="{{datas.componentData.btnType<6}}" style="color:{{datas.componentData.btnColor}}" class="buy-now-icon iconfont-common {{datas.componentData.btnIcon}}"></text>
<view
wx:else
......@@ -187,7 +199,11 @@
</block>
</view>
<!-- 商户入口二 -->
<view class="merchantsEntrance flex" wx:if="{{datas.componentData.merchantsEntrance&&datas.componentData.merchantsEntranceType==1 && datas.componentData.style!='heap'}}">
<view
class="merchantsEntrance flex"
bindtoMerchants="toMerchants"
wx:if="{{datas.componentData.merchantsEntrance&&datas.componentData.merchantsEntranceType==1 && datas.componentData.style!='heap'}}"
>
<view class="left flex" wx:if="{{items!=null}}">
<view class="logo">
<image mode='widthFix' src="http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/ppefWK8BS6.png?x-oss-process=image/resize,limit_1,w_150,h_150" />
......
......@@ -3,7 +3,7 @@
display: flex;
}
.goods-item-child-bd{
border: 1px solid var(--border-color);
border: 1px solid var(--border_color);
}
image{
width: 100%;
......
......@@ -5,11 +5,10 @@
wx:key="index"
data-index="{{index}}"
class="{{'card-swiper-item curdistance' + (swiperCurIndex + index) + (!!item.slideClass? item.slideClass: '')}}"
bindtap="next"
catchtouchstart="touchCard.start"
catchtouchmove="touchCard.move"
catchtouchend="touchCard.end"
catchtouchcancel="touchCard.cancel"
bindtouchstart="touchCard.start"
bindtouchmove="touchCard.move"
bindtouchend="touchCard.end"
bindtouchcancel="touchCard.cancel"
>
<goods-item
style="width:100%"
......
const app = getApp();
const { goodsApi,DFSImg } = app;
const { goodsApi, DFSImg, $themeToLink } = app;
const componentOptions = {
// 组件选项
options: {
......@@ -16,7 +16,10 @@ const componentOptions = {
isPageHidden: false, // 页面是否处于隐藏状态
titleIcon: "",
classificationLoadPage: 1,
classificationLoadNum: 10
classificationLoadNum: 10,
queryProductInfoLoading: false,
loading: false,
finished: false
},
// 数据监听器
observers: {},
......@@ -65,7 +68,9 @@ const componentOptions = {
titleIcon
} = this.data.datas.componentData;
angleSignImg = DFSImg(angleSignImg);
titleIcon = DFSImg(titleIcon);
if (titleIcon) {
titleIcon = DFSImg(titleIcon);
}
this.setData({
"data.datas.componentData.angleSignImg": angleSignImg,
titleIcon
......@@ -91,39 +96,63 @@ const componentOptions = {
},
getProductList(code, type) {
let { goodsList, goodsSort } = this.data.datas.componentData;
let {
classificationLoadPage,
loading,
finished,
queryProductInfoLoading
} = this.data;
if (queryProductInfoLoading == true) {
return;
}
this.setData({ queryProductInfoLoading: true });
// type 1初始化 2滚动加载
//分类查
if (code == 1) {
if (type == 1) {
classificationLoadPage = 1;
} else {
classificationLoadPage++;
loading = true;
}
this.setData({ classificationLoadPage, loading });
let query = {
categoryId: this.data.datas.componentData.categoryId,
page: this.showRowNum()
? 1
: this.data.datas.componentData.classificationLoadPage, // 当前页
page: this.showRowNum() ? classificationLoadPage : 1,
rows: this.showRowNum()
? this.getItemNum()
: this.classificationLoadNum, // 一页多少条
sortColumn: this.data.datas.componentData.goodsSort,
sortType: this.data.datas.componentData.goodsSort != 2 ? 1 : 0,
? this.data.classificationLoadNum
: this.getItemNum(),
sortColumn: goodsSort,
sortType: goodsSort != 2 ? 1 : 0,
whetherShowSoldOutGoods: this.data.datas.componentData
.whetherShowSoldOutGoods, //查询销售数量
whetherQueryCollectCount: true, //查询收藏数
whetherUseVirtualSalesQty: true, //是否使用虚拟销售数量
whetherUseVirtualCollectCount: true, //是否使用虚拟收藏人数
.whetherShowSoldOutGoods,
whetherQueryCollectCount: true,
whetherUseVirtualSalesQty: true,
whetherUseVirtualCollectCount: true,
whetherFindDistributionCommission: this
.whetherFindDistributionCommission, //是否查询商品佣金(0:不查询,1:展示,为空不查佣金)
.whetherFindDistributionCommission,
whetherFindRecommendedCardFlag: this.data.datas.componentData.vipPrice
? 1
: 0, //是否查询会员价 1是 0否
: 0,
whetherShowGoodsDefaultTagFlag: this.data.datas.componentData
.marketingTag
? 1
: 0, //是否展示营销标签 1是 0否
whetherFindMultiShopFlag: 1 //是否查询多商户 //商城使用
};
: 0,
whetherFindMultiShopFlag: 1
}; // 当前页 // 一页多少条 //查询销售数量 //查询收藏数 //是否使用虚拟销售数量 //是否使用虚拟收藏人数 //是否查询商品佣金(0:不查询,1:展示,为空不查佣金) //是否查询会员价 1是 0否 //是否展示营销标签 1是 0否 //是否查询多商户 //商城使用
goodsApi.queryProductInfo(query).then(res => {
this.setData({ loading: false, queryProductInfoLoading: false });
if (res.data.code == 200) {
let goodsList = res.data.data.list;
this.goodsListVal(goodsList);
let goodsLists = res.data.data.list;
if (type == 1) {
goodsList = goodsLists;
} else {
goodsList = [...goodsList, ...goodsLists];
}
if (goodsLists && goodsLists.length < 10) {
this.setData({ finished: true });
}
this.goodsListVal(goodsList, type);
}
});
} else {
......@@ -177,13 +206,13 @@ const componentOptions = {
goodsApi.queryMoreProductInfo(moreQuery).then(res => {
if (res.data.code == 200) {
goodsList = res.data.data;
this.goodsListVal(goodsList);
this.goodsListVal(goodsList, 1);
}
});
},
goodsListVal(goodsList) {
console.log(goodsList,"------------goodsListVal")
goodsList.forEach((item,index) => {
goodsListVal(goodsList, type) {
console.log(goodsList, "------------goodsListVal");
goodsList.forEach((item, index) => {
item.marketingTag = item.defaultTags
? this.filtermark(
item.defaultTags,
......@@ -191,21 +220,21 @@ const componentOptions = {
)
: [];
item.shopLogoUrl = DFSImg(item.shopLogoUrl);
item.coverImage = DFSImg(item.coverImage);
item.productImgUrl = DFSImg(item.productImgUrl);
item.coverImage = DFSImg(item.coverImage, 100, 100, 0);
item.productImgUrl = DFSImg(item.productImgUrl, 100, 100, 0);
item.minPrice = Number(item.minPrice).toFixed(2);
item.qty = Number(item.qty);
item.saleQty = Number(item.saleQty);
item.totalCollectionCount = Number(item.totalCollectionCount) || 0;
item.minPriceAfterRecommendedCardPriceTable = item.minPriceAfterRecommendedCardPriceTable?
Number(item.minPriceAfterRecommendedCardPriceTable):"";
item.minProductGoodsCommission = item.minProductGoodsCommission?
Number(item.minProductGoodsCommission).toFixed(2) : 0;
item.minGoodsSuggestedRetailPrice = item
.minGoodsSuggestedRetailPrice?Number(
item.minGoodsSuggestedRetailPrice
)
.toFixed(2) : "";
item.minPriceAfterRecommendedCardPriceTable = item.minPriceAfterRecommendedCardPriceTable
? Number(item.minPriceAfterRecommendedCardPriceTable)
: "";
item.minProductGoodsCommission = item.minProductGoodsCommission
? Number(item.minProductGoodsCommission).toFixed(2)
: 0;
item.minGoodsSuggestedRetailPrice = item.minGoodsSuggestedRetailPrice
? Number(item.minGoodsSuggestedRetailPrice).toFixed(2)
: "";
item.showVipPrice = this.showVipPrice(item, index);
item.showVipTag = this.showVipTag(item, index);
if (item.saleTime) {
......@@ -217,8 +246,16 @@ const componentOptions = {
this.setData({
"datas.componentData.goodsList": goodsList
});
if (this.selectComponent("#waterfallFlow")) {
this.selectComponent("#waterfallFlow").initList();
if (type == 1) {
// 初始化
if (this.selectComponent("#waterfallFlow")) {
this.selectComponent("#waterfallFlow").initList();
}
} else {
// 滚动加载
if (this.selectComponent("#waterfallFlow")) {
this.selectComponent("#waterfallFlow").reLoadPro();
}
}
}, 0);
},
......@@ -249,9 +286,9 @@ const componentOptions = {
}
},
showRowNum() {
return !(
return (
this.data.datas.componentData.moreShow == false &&
this.data.datas.componentData.getStyle == "waterfall" &&
this.data.datas.componentData.style == "waterfall" &&
this.data.datas.componentData.goodsSource == "classify"
);
},
......@@ -278,21 +315,50 @@ const componentOptions = {
}
return showFlag;
},
showVipTag(item,index) {
showVipTag(item, index) {
// 索引 0 显示价格 1显示名称
let showFlag = false;
let vipPrice = item["minPriceAfterRecommendedCardPriceTable"];
let showTag = item["recommendedCardMinPricePriceTableName"];
if (
vipPrice &&
showTag &&
Number(vipPrice) <= Number(item["minPrice"])
) {
if (vipPrice && showTag && Number(vipPrice) <= Number(item["minPrice"])) {
showFlag = true;
}
return showFlag;
},
getScroll(el) {
// 是指定分类且不显示查看更多的瀑布流组件滚动加载
let { goodsSource, moreShow, style } = this.data.datas.componentData;
if (
goodsSource == "classify" &&
moreShow == false &&
style == "waterfall"
) {
this.selectComponent("#waterfallFlow").getScroll(el);
}
},
// 分页加载
onLoad() {
console.log("---触发分页加载");
this.getProductList(1, 2);
},
viewMore() {
let { goodsType,style, categoryName, categoryId } = this.data.datas.componentData;
let linkVal = "";
if (goodsType != 1) {
if (style == "list") {
linkVal = `/goods/commodityMenu?categoryName=${categoryName}&categoryId=${categoryId}`;
} else {
linkVal = `/goods/commodityMenu`;
}
} else {
linkVal = `/pointShop/productList?categoryName=${categoryName}&categoryId=${categoryId}`;
}
$themeToLink({
type: 1,
link:linkVal,
});
}
},
}
};
Component(componentOptions);
......@@ -9,7 +9,11 @@
</view>
<view class="title">{{datas.componentData['titles']}}</view>
</view>
<view class="moreTop" wx:if="{{datas.componentData['moreShow'] && datas.componentData.moreButtonSite=='top' && datas.componentData['goodsSource']!='assign'}}">
<view
class="moreTop"
bindtap="viewMore"
wx:if="{{datas.componentData['moreShow'] && datas.componentData.moreButtonSite=='top' && datas.componentData['goodsSource']!='assign'}}"
>
查看更多
<text class="jt"></text>
</view>
......@@ -63,6 +67,9 @@
datas="{{datas}}"
padding="{{datas.componentData.proGap}}"
wx:if="{{datas.componentData.goodsList}}"
bindonLoad="onLoad"
loading="{{loading}}"
finished="{{finished}}"
></waterfall-flow>
</view>
<!-- 横向列表 -->
......@@ -88,7 +95,14 @@
<view class="goods-heap-Item" wx:if="{{datas.componentData.style==='heap'}}">
<heap-item datas="{{datas}}"></heap-item>
</view>
<view
class="moreBottom"
bindtap="viewMore"
wx:if="{{datas.componentData['moreShow'] && datas.componentData.moreButtonSite=='bottom' && datas.componentData['goodsSource']!='assign'}}"
>
查看更多
<text class="jt"></text>
</view>
</view>
</view>
......@@ -40,7 +40,7 @@ image{
font-size: 13px;
color: #6b6b6b;
}
.moreTop .jt {
.moreTop .jt,.moreBottom .jt{
display: inline-block;
border-top: 1px solid;
border-right: 1px solid;
......@@ -50,6 +50,12 @@ image{
transform: rotate(405deg);
margin-left: 0px;
}
.moreBottom {
font-size: 13px;
text-align: center;
padding-top: 0.54em;
color: #6b6b6b;
}
.goodsItem-list{
flex-wrap: wrap;
}
......
const app = getApp();
const { $themeToLink } = app;
const componentOptions = {
// 组件选项
options: {
multipleSlots: true
},
behaviors: [],
properties: {
datas: {
type: Object
},
countDownShow: {
type: Boolean
},
num: {
type: Number
}
},
// 组件数据
data: {
isPageHidden: false, // 页面是否处于隐藏状态
hideItem: false,
timeData: {}
},
// 数据监听器
observers: {},
// 组件方法
methods: {
init() {},
onChange(e) {
let { isStart, startTime } = this.data.datas;
isStart =
new Date(startTime.replace(/-/g, "/")).getTime() > new Date().getTime()
? true
: false;
this.setData({ timeData: e.detail, "datas.isStart": isStart });
},
toActivity() {
$themeToLink({ type: 1, link: `/brandTopics/${this.data.datas.id}` });
}
},
// 组件生命周期
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-count-down": "/static/vant/count-down/index"
}
}
<!-- 活动列表item -->
<view
class="activityListItem"
wx:if="{{!hideItem||!datas.isEnd}}"
bindtap="toActivity"
>
<view class="title">
{{datas.singleItemActivityName}}
</view>
<view class="cover">
<image mode="center" src="{{datas.singleItemActivityCoverImage}}"></image>
</view>
<view class="countDown flex" wx:if="{{countDownShow}}">
<van-count-down
use-slot
time="{{datas.isStart?datas.startTimeTimeStamp:datas.endTimeTimeStamp}}"
class="countDown"
bind:change="onChange"
>
<view class="time">
<text class="colon">距{{datas.isStart?'开始':'结束'}}</text>
<text class="block">{{ timeData.days }}</text>
<text class="colon">天</text>
<text class="block">{{ timeData.hours }}</text>
<text class="colon">时</text>
<text class="block">{{ timeData.minutes }}</text>
<text class="colon">分</text>
<text class="block">{{ timeData.seconds }}</text>
<text class="colon">秒</text>
</view>
</van-count-down>
</view>
</view>
.activityListItem {
margin-bottom: 20rpx;
padding: 20rpx 0;
background: #fff;
border-radius: 8rpx;
-webkit-border-radius: 8rpx;
-moz-border-radius: 8rpx;
-ms-border-radius: 8rpx;
-o-border-radius: 8rpx;
}
.title {
padding: 8rpx 20rpx;
font-size: 34rpx;
color: #333;
font-weight: bold;
text-align: left;
}
.cover {
margin: 8rpx 0;
width: 100%;
height: 300rpx;
overflow: hidden;
}
.cover image {
width: 100%;
}
.countDown {
padding: 4rpx 10rpx;
justify-content: flex-end;
font-size: 24rpx;
color: #666;
}
.countDown .block {
display: inline-block;
width: 40rpx;
height: 40rpx;
text-align: center;
line-height: 40rpx;
border-radius: 4rpx;
background: #333;
color: #fff;
-webkit-border-radius: 4rpx;
-moz-border-radius: 4rpx;
-ms-border-radius: 4rpx;
-o-border-radius: 4rpx;
}
.time{
display: flex;
align-items: center;
justify-content: flex-end;
margin-right: 10rpx;
}
.colon{
font-size: 30rpx;
}
.block{
margin: 0 10rpx;
color: #fff;
}
\ No newline at end of file
let d = null;
const app = getApp();
const { promoteApi, DFSImg, $themeToLink } = app;
// 倒计时方法
if (typeof xcsoft == "undefined") var xcsoft = new function() {}();
xcsoft.countdown = function(a, b, c) {
d = new Object();
var e = 0;
if (typeof a == "object") {
var f = parseInt(new Date().getTime() / 1000);
var g = a.startTime ? parseInt(a.startTime) : 0;
g = g == 0 ? f : g;
var h = a.endTime;
var x = g - f;
d.decimal = parseInt(a.msec ? a.msec : 0);
} else {
var f = 0;
var x = 0;
d.decimal = 0;
var h = a;
var i = h.toString();
if (i.indexOf(".") > 0) {
d.decimal = i.split(".")[1];
if (d.decimal > 3) {
d.decimal = 3;
}
}
}
d.time = h;
d.finish = false;
if (isNaN(h)) {
var j = h.substring(0, 19);
j = j.replace(/-/g, "/");
d.time = new Date(j).getTime() / 1000;
}
var k = d.decimal == 0 ? 100 : 100;
d.day = 0;
d.hour = 0;
d.minute = 0;
d.second = 0;
d.t = setInterval(function() {
e = new Date().getTime();
f = parseInt(e / 1000 + x);
var l = d.time - f;
if (l <= 0) {
e = 0;
l = 0;
}
if (l >= 0) {
d = xcsoft.getTimeObject(d, l);
}
if (d.decimal == 1) {
d.msecZero = d.msec = parseInt(10 - (e % 1000) / 100);
if (d.msec == 10 || l == 0) {
d.msecZero = d.msec = 0;
}
} else if (d.decimal == 2) {
d.msecZero = d.msec = parseInt(100 - (e % 1000) / 10);
if (d.msec < 10) {
d.msecZero = "0" + d.msec;
} else if (d.msec == 100 || l == 0) {
d.msec = 0;
d.msecZero = "0" + d.msec;
}
} else {
d.msecZero = d.msec = parseInt(1000 - e % 1000);
if (d.msec < 10) {
d.msecZero = "00" + d.msec;
} else if (d.msec < 100) {
d.msecZero = "0" + d.msec;
} else if (d.msec == 1000 || l == 0) {
d.msec = 0;
d.msecZero = "00" + d.msec;
}
}
if (b) {
b(d);
}
if (l <= 0 || d.stop == true) {
clearInterval(d.t);
d.finish = true;
if (c) c(d);
}
}, k);
};
xcsoft.getTimeObject = function(a, l) {
var b = 60;
var c = b * b;
var d = 24 * c;
a.days = Math.floor(l / d);
a.year = Math.floor(a.days / 365);
a.day = Math.floor(a.days % 365);
a.hour = Math.floor((l % d) / c);
a.minute = Math.floor((l - (a.days * d + a.hour * c)) / b);
a.second = Math.floor(l % b);
a.dayZero = a.day < 10 ? "0" + a.day : a.day;
a.daysZero = a.days < 10 ? "0" + a.days : a.days;
a.hourZero = a.hour < 10 ? "0" + a.hour : a.hour;
a.minuteZero = a.minute < 10 ? "0" + a.minute : a.minute;
a.secondZero = a.second < 10 ? "0" + a.second : a.second;
return a;
};
const componentOptions = {
// 组件选项
options: {
multipleSlots: true
},
behaviors: [],
properties: {
datas: {
type: Object
}
},
// 组件数据
data: {
isPageHidden: false, // 页面是否处于隐藏状态
timeData: {},
isLoading: true,
deleteFlag: false, //活动未禁用
newTime: new Date().getTime(),
timer: null,
hideAll: false,
days: 0,
hours: 0,
minute: 0,
second: 0
},
// 数据监听器
observers: {},
// 组件方法
methods: {
init() {
let { goodsList, activityCode, selectActivityValue, dimension } = this.data.datas.componentData;
let { deleteFlag, endTimeData } = this.data;
if (activityCode == "") {
return;
}
let query = {
singleItemActivityId: activityCode,
whetherShowSoldOutGoods: 1
};
promoteApi.getSingleItemActivityV2(query).then(res => {
if (res.data.code == 200) {
let copyData = res.data.data;
deleteFlag = copyData.activityStatus != 2 ? true : false;
if (dimension == 0 && copyData.goodsItems.length == 0) {
deleteFlag = true;
}
endTimeData = new Date(copyData.endTime.replace(/-/g, "/")).getTime() - new Date().getTime();
console.log(endTimeData, "----------------------150");
this.setData({ endTime: endTimeData });
let _this = this;
this.setData({ deleteFlag });
console.log("------------155")
// setTimeout(() => {
// xcsoft.countdown(_this.data.datas.componentData.endTime, function (time) {
// console.log("--------------157")
// let { days, hours, minute, second } = _this.data;
// days = time.dayZero;
// hours = time.hourZero;
// minute = time.minuteZero;
// second = time.secondZero;
// // _this.setData({ days, hours, minute, second });
// }, function(time) {
// //倒计时结束后的操作
// });
// setTimeout(() => {
// this.setData({ isLoading: true });
// }, 100);
// }, 100);
copyData.goodsItems.forEach((item, index) => {
item.productImgUrl = DFSImg(item.imgUrl);
item.minPrice = parseFloat(item.discountPrice);
item.maxPrice = parseFloat(item.salePrice);
});
this.setData({
goodsList: copyData.goodsItems,
selectActivityValue: copyData.singleItemActivityName
});
}
});
},
initArticityList() {
let ids = [];
let { actList } = this.data.datas.componentData;
let { isLoading } = this.data;
if (actList.length > 0) {
ids = actList.map(item => {
return item.id;
});
}
if (ids.length == 0) {
this.setData({ isLoading:true });
return;
}
promoteApi.query_single_item_activity_list_by_ids(ids).then(res => {
if (res.data.code == 200) {
let list = res.data.data ||[];
if (list.length > 0) {
let hideNum = 0;
list.forEach((item, index) => {
if (new Date(item.endTime.replace(/-/g, "/")).getTime() - new Date().getTime() <= 0) {
item.isEnd = true;
hideNum += 1;
} else {
item.isEnd = false;
}
item.startTimeTimeStamp = new Date(item.startTime.replace(/-/g, "/")).getTime() - new Date().getTime();
item.endTimeTimeStamp = new Date(item.endTime.replace(/-/g, "/")).getTime() - new Date().getTime();
item.singleItemActivityCoverImage = DFSImg(item.singleItemActivityCoverImage);
item.isStart = new Date(item.startTime.replace(/-/g, "/")).getTime() > new Date().getTime() ? true : false;
})
this.setData({ "datas.componentData.actList": list });
if (hideNum == actList.length) {
this.setData({ hideAll:true });
}
}
}
});
},
onChange(e) {
this.setData({ timeData: e.detail });
},
onclickProduct(e) {
console.log(e.currentTarget.dataset.items,'-------------------------226');
let { terminalProductId, terminalGoodsMixId, productId } = e.currentTarget.dataset.items;
$themeToLink({ type: 1, link: `/goods/${productId}?limitedLime=true&endTime=${this.data.datas.componentData.endTime}&terminalProductId="${terminalProductId}&terminalGoodsMixId=${terminalGoodsMixId}` });
},
onclickOrder(e) {
let { terminalGoodsMixId, terminalGoodsId, goodsId } = e.currentTarget.dataset.items;
$themeToLink({
type: 1,
link: `/order/orderConfirm?productGoodsMixId=${terminalGoodsMixId}&productGoodsId=${terminalGoodsId}&goodsId=${goodsId}&qty=1&goodsString=null`
});
},
getData() {
let { dimension } = this.data.datas.componentData;
if (dimension == 0) {
this.init();
} else if (dimension == 1) {
this.initArticityList();
}
}
},
// 组件生命周期
lifetimes: {
created() {},
attached() {
this.getData();
},
ready() {},
moved() {},
detached() {}
},
definitionFilter() {},
// 页面生命周期
pageLifetimes: {
// 页面被展示
show() {
const { isPageHidden } = this.data;
// show事件发生前,页面不是处于隐藏状态时
if (!isPageHidden) {
return;
}
this.getData();
// 重新执行定时器等操作
},
// 页面被隐藏
hide() {
this.setData({
isPageHidden: true
});
// 清除定时器等操作
},
// 页面尺寸变化时
resize() {}
}
};
Component(componentOptions)
{
"component": true,
"usingComponents": {
"activity-list-item":"./activityListItem/index",
"van-count-down": "/static/vant/count-down/index"
}
}
<!-- 限时活动 -->
<view class="time-limited-discount" style="padding-top:{{datas.componentData.paddingList[0].value*2}}rpx;padding-bottom:{{datas.componentData.paddingList[1].value*2}}rpx;padding-left:{{datas.componentData.paddingList[2].value*2}}rpx;padding-right:{{datas.componentData.paddingList[3].value*2}}rpx;--backgroundColor:{{datas.componentData.backgroundColor}}">
<!-- 标题 -->
<view class="tops {{datas.componentData['countDownShow']?'hideCountDown':''}}">
<view class="topInfo">
<view class="title">
{{datas.componentData.dimension ==0?datas.componentData.selectActivityValue:datas.componentData.actTitle}}
</view>
<view class="subheading" wx:if="{{datas.componentData['countDownShow']&&datas.componentData.dimension==0}}">
<view wx:if="{{datas.componentData['endTime']&&endTime>0}}">
<van-count-down
use-slot
time="{{endTime}}"
class="countDown"
bind:change="onChange"
>
<text class="endTime days">{{ timeData.days }}</text>
<text class="endTimedot">天</text>
<text class="endTime hours">{{ timeData.hours }}</text>
<text class="endTimedot">:</text>
<text class="endTime minute">{{ timeData.minutes }}</text>
<text class="endTimedot">:</text>
<text class="endTime second">{{ timeData.seconds }}</text>
</van-count-down>
</view>
<view class="countDown" wx:elif="{{isLoading}}">
活动已结束
</view>
</view>
</view>
</view>
<!-- 内容 -->
<!-- 网格模式 -->
<view class="goods" wx:if="{{datas.componentData.style==='list'}}">
<view class="goodsList">
<view
class="goodsItem {{datas.componentData.columnNum==2?'style2':'style3'}}"
wx:for="{{datas.componentData.goodsList}}"
wx:key="index"
style="width:{{100/datas.componentData.columnNum}}%"
>
<view class="goods-item-child {{datas.componentData.columnNum==1?'goods-item-child-flex':''}}">
<view class="imgBox slidebox1">
<view
class="goodsPicture"
bindtap="onclickProduct"
data-items="{{datas.componentData.goodsList[index]}}"
style="padding:{{datas.componentData.imgSize}}"
>
<image mode="widthFix" src="{{datas.componentData.goodsList[index]['productImgUrl']}}"></image>
<view class="whiteBg" wx:if="{{datas.componentData.goodsList[index].oversoldFlag==0&&datas.componentData.goodsList[index].saleQty-0<=0}}">
<view class="cover">
<text>商品</text>
<text>售罄</text>
</view>
</view>
</view>
</view>
<view class="info">
<view class="name">
{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['productName']:'名称'}}
</view>
<view class="allPrice">
<view>
<!-- <text class="price" wx:if="{{((hours-0)+(minute-0)+(second-0))!=0}}">¥{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['minPrice']:0}}</text>
<text class="price" wx:else>¥{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['minPrice']:0}}</text>
<text class="delPrice" wx:if="{{((hours-0)+(minute-0)+(second-0))!=0}}">¥{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['maxPrice']:0}}</text> -->
<view class="price">¥{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['minPrice']:0}}</view>
<view class="delPrice">¥{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['maxPrice']:0}}</view>
</view>
<view
class="btn"
style="background:#333;"
data-items="{{datas.componentData.goodsList[index]}}"
catchtap="onclickOrder"
>
立即抢购
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 横向滑动 -->
<view class="goods1" wx:elif="{{datas.componentData.style==='across'}}">
<view
class="goods-item"
wx:for="{{datas.componentData.goodsList}}"
wx:key="index"
>
<view class="items">
<view class="imgBox slidebox2">
<view
class="goodsPicture"
wx:if="{{datas.componentData.goodsList[index]!=null}}"
style="padding:{{datas.componentData.imgSize}}"
data-items="{{datas.componentData.goodsList[index]}}"
bindtap="onclickProduct"
>
<image mode="widthFix" src="{{datas.componentData.goodsList[index]['productImgUrl']}}"></image>
<view class="whiteBg" wx:if="{{datas.componentData.goodsList[index].oversoldFlag==0&&datas.componentData.goodsList[index].saleQty-0<=0}}">
<view class="cover">
<text>商品</text>
<text>售罄</text>
</view>
</view>
</view>
</view>
<view class="info">
<!-- <text class="price" wx:if="{{((hours-0)+(minute-0)+(second-0))!=0}}">¥{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['minPrice']:0}}</text>
<text class="price" wx:else>¥{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['minPrice']:0}}</text>
<text class="delPrice" wx:if="{{((hours-0)+(minute-0)+(second-0))!=0}}">¥{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['maxPrice']:0}}</text> -->
<view class="price">¥{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['minPrice']:0}}</view>
<view class="delPrice">¥{{datas.componentData.goodsList[index]!=null?datas.componentData.goodsList[index]['maxPrice']:0}}</view>
</view>
</view>
</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>
</view>
.time-limited-discount {
background: var(--backgroundColor);
font-size: 32rpx;
}
.tops {
padding: 8rpx 0;
}
.hideCountDown {
display: flex;
justify-content: space-between;
align-items: center;
}
.topInfo {
width: 100%;
display: flex;
justify-content: space-between;
align-content: center;
}
.topInfo .title {
font-size: 38rpx;
color: #333;
font-weight: bold;
text-align: left;
}
.topInfo .subheading {
position: relative;
display: flex;
align-items: center;
}
.subheading.countDown {
display: flex;
justify-content: space-around;
align-items: center;
}
.endTime {
padding: 4rpx 10rpx;
border-radius: 6rpx;
background: #6a6b6b;
color: #fff;
font-weight: bold;
-webkit-border-radius: 6rpx;
-moz-border-radius: 6rpx;
-ms-border-radius: 6rpx;
-o-border-radius: 6rpx;
}
.endTimedot {
padding: 0 10rpx;
}
.goods {
width: 100%;
}
.goodsList {
display: flex;
align-items: flex-start;
}
.goodsItem {
box-sizing: border-box;
}
.goods-item-child {
border-radius: 5px;
overflow: hidden;
background: #fff;
margin: 0 10rpx;
}
.goods-item-child .info {
padding: 10rpx 20rpx 12rpx;
}
.goods-item-child .info .name {
text-align: left;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
line-height: 44rpx;
font-size: 32rpx;
height: 92rpx;
}
.goods-item-child .info .allPrice {
display: flex;
justify-content: space-between;
align-items: center;
}
.price {
font-weight: 600;
margin-top: 10rpx;
color: #ff3434;
font-size: 32rpx;
}
.delPrice {
text-decoration: line-through;
margin-top: 10rpx;
color: #999;
}
.goods-item-child .info .allPrice .btn {
font-size: 24rpx;
background: #333;
padding: 8rpx;
color: #fff;
border-radius: 10rpx;
-webkit-border-radius: 10rpx;
-moz-border-radius: 10rpx;
-ms-border-radius: 10rpx;
-o-border-radius: 10rpx;
}
.goods-item-child-flex {
display: flex;
justify-content: space-between;
align-items: center;
}
.imgBox {
position: relative;
overflow: hidden;
width: 100%;
height: 40vw;
display: flex;
align-items: center;
justify-content: center;
}
.imgBox .goodsPicture{
width: 100%;
}
.goods-item-child-flex .imgBox {
width: 30%;
padding-bottom: 30%;
}
.goods-item-child-flex .info {
width: 70%;
}
.goodsPicture .whiteBg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(#fff, 0.7);
}
.goodsPicture .whiteBg .cover {
position: absolute;
top: 40rpx;
left: 40rpx;
right: 40rpx;
bottom: 40rpx;
display: flex;
background: rgba(#333, 0.6);
flex-direction: column;
justify-content: center;
align-items: center;
border-radius: 50%;
}
.goodsPicture .whiteBg .cover text {
color: #fff;
font-weight: bold;
letter-spacing: 6rpx;
text-align: center;
}
.goods1 {
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
-webkit-overflow-scrolling: touch; /* ios5+ */
}
.goods1 .goods-item {
display: inline-block;
vertical-align: top;
white-space: initial;
margin-right: 20rpx;
width: 40%;
}
.goods1 .goods-item .items {
border-radius: 5px;
overflow: hidden;
background: #ffffff;
}
.goods1 .goods-item .info {
text-align: center;
}
.goods1 .goods-item .slidebox2 {
box-sizing: border-box;
-moz-box-sizing: border-box; /* Firefox */
-webkit-box-sizing: border-box; /* Safari */
}
......@@ -13,8 +13,17 @@ Component({
},
padding: {
type: Number
},
loading: {
type: Boolean
},
finished: {
type: Boolean
}
},
onPageScroll(e) {
console.log(e);
},
lifetimes: {
created() {
console.log("进入组件created");
......@@ -26,7 +35,14 @@ Component({
},
ready() {
console.log("进入组件ready");
// this.reLoadPro();
let _this = this;
let { clientHeight } = this.data;
wx.getSystemInfo({
success: function(res) {
let clientHeight = parseInt(res.windowHeight);
_this.setData({ clientHeight });
}
});
}
},
observers: {},
......@@ -36,50 +52,71 @@ Component({
//列高度数组
waterfallDeviationHeight: [0, 0],
contentList: [],
inj: 0
inj: 0,
clientHeight: 0, //窗口高度
goodsNum:0,
},
methods: {
// 初始化数组
initList() {
// 初始化容器
let contentList = this.data.contentList;
let { contentList, waterfallDeviationHeight } = this.data;
contentList[0] = [];
contentList[1] = [];
this.setData({ contentList });
waterfallDeviationHeight = [0,0];
this.setData({ contentList, waterfallDeviationHeight });
console.log(this.data.note, "-------------------185");
this.reLoadPro();
},
async reLoadPro() {
let _this = this;
// this.setHeight(0);
this.setHeight(this.data.goodsNum);
this.setData({ goodsNum:this.data.note.length>0?this.data.note.length+1:0 });
},
setHeight(i) {
let _this = this;
let item = this.data.note[i];
console.log(i, "---------------i");
console.log(
this.data.waterfallDeviationHeight,
"-------waterfallDeviationHeight"
);
// console.log(i, "---------------i");
// console.log(
// this.data.waterfallDeviationHeight,
// "-------waterfallDeviationHeight"
// );
let minIndex = this.filterMin();
console.log(minIndex, "---------------126");
// console.log(minIndex, "---------------126");
let contentList = this.data.contentList;
contentList[minIndex].push(item);
this.setData({ contentList });
const queryDom = wx.createSelectorQuery().in(this);
queryDom.select(`.item${minIndex}`).boundingClientRect();
queryDom.exec(res => {
res[0].height;
console.log(res[0], "--------------res");
let waterfallDeviationHeight = _this.data.waterfallDeviationHeight;
waterfallDeviationHeight[minIndex] = res[0].height;
_this.setData({ waterfallDeviationHeight });
if (i >= _this.data.note.length - 1) {
return;
}
i++;
_this.setHeight(i);
});
_this
.createSelectorQuery()
.select(`.item${minIndex}`)
.boundingClientRect(function(res) {
if (res) {
res.height;
console.log(res, "--------------res");
let waterfallDeviationHeight = _this.data.waterfallDeviationHeight;
waterfallDeviationHeight[minIndex] = res.height;
_this.setData({ waterfallDeviationHeight });
if (i >= _this.data.note.length - 1) {
return;
}
i++;
_this.setHeight(i);
}
})
.exec();
// const queryDom = wx.createSelectorQuery().in(this);
// queryDom.select(`.item${minIndex}`).boundingClientRect();
// queryDom.exec(res => {
// res[0].height;
// console.log(res[0], "--------------res");
// let waterfallDeviationHeight = _this.data.waterfallDeviationHeight;
// waterfallDeviationHeight[minIndex] = res[0].height;
// _this.setData({ waterfallDeviationHeight });
// if (i >= _this.data.note.length - 1) {
// return;
// }
// i++;
// _this.setHeight(i);
// });
},
filterMin() {
let val = Math.min.apply(null, this.data.waterfallDeviationHeight);
......@@ -101,6 +138,26 @@ Component({
ev.target.dataset.id,
"-----------------------219"
);
},
getScroll(el) {
let { finished } = this.properties;
let _this = this;
_this
.createSelectorQuery()
.select("#waterfallFlow")
.boundingClientRect(function(res) {
if (res) {
console.log(el, "-------------118");
console.log(res, "---------------35");
let scrollTop = parseInt(el.target.scrollTop);
let domHeight = parseInt(res.height);
// 窗口高度+滚动高度等于 = 元素整体高度 -(预留一段距离加载) 触发父组件查询接口
if (scrollTop + _this.data.clientHeight >= domHeight - 150 && finished == false) {
_this.triggerEvent("onLoad");
}
}
})
.exec();
}
}
});
<!--瀑布流组件-->
<view class="waterfallFlow" style="--proGap:{{padding}}rpx">
<view
class="waterfallFlow"
id="waterfallFlow"
style="--proGap:{{padding}}rpx"
>
<view class="container flex">
<view
wx:for="{{contentList}}"
......@@ -21,5 +25,10 @@
</view>
</view>
</view>
<!-- 上拉加载底部展示 -->
<view class="loadBottom" wx:if="{{datas.componentData.goodsSource == 'classify' && datas.componentData.moreShow == false &&datas.componentData.style == 'waterfall'}}">
<text wx:if="{{loading}}">加载中~</text>
<text wx:if="{{ finished}}">暂无更多</text>
</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