Commit 967cf83b by 严立

LL - 购物流程问题修复

parent 9823cf03
...@@ -61,8 +61,7 @@ App({ ...@@ -61,8 +61,7 @@ App({
// console.log("返回:", res); // console.log("返回:", res);
let code = res.data.code * 1; let code = res.data.code * 1;
if (200 == code) { if (200 == code && true == res.data.success) {
// if (200 == code && true == res.data.success) {
if (obj.success) { if (obj.success) {
obj.success(res.data) obj.success(res.data)
} }
...@@ -72,6 +71,10 @@ App({ ...@@ -72,6 +71,10 @@ App({
this.wxRequest(obj) this.wxRequest(obj)
} }
}) })
} else if (500 === code) {
if (obj.success) {
obj.success(res)
}
} else { } else {
if (obj.fail) { if (obj.fail) {
let err = { let err = {
......
...@@ -73,8 +73,8 @@ Page({ ...@@ -73,8 +73,8 @@ Page({
'id': funcResponse[i].id, // 商品标识 'id': funcResponse[i].id, // 商品标识
'name': funcResponse[i].name, 'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面 'cover': funcResponse[i].coverImg, // 商品封面
'typeId': funcResponse[i].classifyId, // 商品分类标识
'shopType': funcResponse[i].genre, 'shopType': funcResponse[i].genre,
'sideBarId': funcResponse[i].classifyId, // 商品所属标签
} }
funcList.push(funcItem) funcList.push(funcItem)
} }
...@@ -100,8 +100,8 @@ Page({ ...@@ -100,8 +100,8 @@ Page({
'id': funcResponse[i].id, // 商品标识 'id': funcResponse[i].id, // 商品标识
'name': funcResponse[i].name, 'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面 'cover': funcResponse[i].coverImg, // 商品封面
'typeId': funcResponse[i].classifyId, // 商品分类标识
'shopType': funcResponse[i].genre, 'shopType': funcResponse[i].genre,
'sideBarId': funcResponse[i].classifyId, // 商品所属标签
} }
funcList.push(funcItem) funcList.push(funcItem)
} }
...@@ -127,8 +127,8 @@ Page({ ...@@ -127,8 +127,8 @@ Page({
'id': funcResponse[i].id, // 商品标识 'id': funcResponse[i].id, // 商品标识
'name': funcResponse[i].name, 'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面 'cover': funcResponse[i].coverImg, // 商品封面
'typeId': funcResponse[i].classifyId, // 商品分类标识
'shopType': funcResponse[i].genre, 'shopType': funcResponse[i].genre,
'sideBarId': funcResponse[i].classifyId, // 商品所属标签
} }
funcList.push(funcItem) funcList.push(funcItem)
} }
...@@ -154,8 +154,8 @@ Page({ ...@@ -154,8 +154,8 @@ Page({
'id': funcResponse[i].id, // 商品标识 'id': funcResponse[i].id, // 商品标识
'name': funcResponse[i].name, 'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面 'cover': funcResponse[i].coverImg, // 商品封面
'typeId': funcResponse[i].classifyId, // 商品分类标识
'shopType': funcResponse[i].genre, 'shopType': funcResponse[i].genre,
'sideBarId': funcResponse[i].classifyId, // 商品所属标签
} }
funcList.push(funcItem) funcList.push(funcItem)
} }
...@@ -209,6 +209,25 @@ Page({ ...@@ -209,6 +209,25 @@ Page({
}, },
/** /**
* 点击推荐餐品
* @function
* @param {object} - event
* @returns
*/
onBuyRecommendFood: function (event) {
// funcShopType 使用函数区分商品类型,所以每个函数里的数值是固定的
let funcShopType = 5
let funcShopAppId = event.currentTarget.dataset.id
let funcCommodityItem = event.currentTarget.dataset.item
console.log(funcCommodityItem)
this.setShopInfo(funcShopAppId, funcShopType)
wx.navigateTo({
url: '/pages/commodity/menu-food/menu-food?commodityId=' + funcCommodityItem.id + '&sideBarId=' + funcCommodityItem.sideBarId
})
},
/**
* 所有 * 所有
* @function * @function
* @param {object} - event * @param {object} - event
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</view> </view>
<view class="shop-menu"> <view class="shop-menu">
<block wx:for="{{shopRecommendA}}" wx:for-index="index" wx:for-item="item" wx:key="index"> <block wx:for="{{shopRecommendA}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="shop-menu-item col con-c align-c"> <view class="shop-menu-item col con-c align-c" data-id="{{6}}" data-item="{{item}}" bindtap="onBuyRecommendFood">
<image src="{{item.cover}}"></image> <image src="{{item.cover}}"></image>
<text>{{item.name}}</text> <text>{{item.name}}</text>
</view> </view>
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</view> </view>
<view class="shop-menu"> <view class="shop-menu">
<block wx:for="{{shopRecommendB}}" wx:for-index="index" wx:for-item="item" wx:key="index"> <block wx:for="{{shopRecommendB}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="shop-menu-item col con-c align-c"> <view class="shop-menu-item col con-c align-c" data-id="{{4}}" data-item="{{item}}" bindtap="onBuyRecommendFood">
<image src="{{item.cover}}"></image> <image src="{{item.cover}}"></image>
<text>{{item.name}}</text> <text>{{item.name}}</text>
</view> </view>
...@@ -59,12 +59,15 @@ ...@@ -59,12 +59,15 @@
<image src="{{resourcesBase + 'commodity/home/services-title.png'}}"></image> <image src="{{resourcesBase + 'commodity/home/services-title.png'}}"></image>
</view> </view>
<view class="services-list col align-c"> <view class="services-list col align-c">
<!-- 精灵鸟理想国 -->
<view class="services-list-item col align-c" data-id="{{3}}" bindtap="onBuyMembership"> <view class="services-list-item col align-c" data-id="{{3}}" bindtap="onBuyMembership">
<image src="{{resourcesBase + 'commodity/home/services-1.png'}}"></image> <image src="{{resourcesBase + 'commodity/home/services-1.png'}}"></image>
</view> </view>
<!-- 故宫海洋世界 -->
<view class="services-list-item col align-c" data-id="{{1}}" bindtap="onBuyPassCheck"> <view class="services-list-item col align-c" data-id="{{1}}" bindtap="onBuyPassCheck">
<image src="{{resourcesBase + 'commodity/home/services-2.png'}}"></image> <image src="{{resourcesBase + 'commodity/home/services-2.png'}}"></image>
</view> </view>
<!-- 元养水韵 -->
<view class="services-list-item col align-c" data-id="{{7}}" bindtap="onBuyService"> <view class="services-list-item col align-c" data-id="{{7}}" bindtap="onBuyService">
<image src="{{resourcesBase + 'commodity/home/services-3.png'}}"></image> <image src="{{resourcesBase + 'commodity/home/services-3.png'}}"></image>
</view> </view>
...@@ -110,7 +113,7 @@ ...@@ -110,7 +113,7 @@
</view> </view>
<view class="shop-menu"> <view class="shop-menu">
<block wx:for="{{shopRecommendC}}" wx:for-index="index" wx:for-item="item" wx:key="index"> <block wx:for="{{shopRecommendC}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="shop-menu-item col con-c align-c"> <view class="shop-menu-item col con-c align-c" data-id="{{1}}" data-item="{{item}}" bindtap="onBuyRecommendFood">
<image src="{{item.cover}}"></image> <image src="{{item.cover}}"></image>
<text>{{item.name}}</text> <text>{{item.name}}</text>
</view> </view>
...@@ -126,7 +129,7 @@ ...@@ -126,7 +129,7 @@
</view> </view>
<view class="shop-menu"> <view class="shop-menu">
<block wx:for="{{shopRecommendD}}" wx:for-index="index" wx:for-item="item" wx:key="index"> <block wx:for="{{shopRecommendD}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="shop-menu-item col con-c align-c"> <view class="shop-menu-item col con-c align-c" data-id="{{3}}" data-item="{{item}}" bindtap="onBuyRecommendFood">
<image src="{{item.cover}}"></image> <image src="{{item.cover}}"></image>
<text>{{item.name}}</text> <text>{{item.name}}</text>
</view> </view>
......
...@@ -5,8 +5,11 @@ Page({ ...@@ -5,8 +5,11 @@ Page({
imageBase: App.globalData.appImageBase, imageBase: App.globalData.appImageBase,
resourcesBase: App.globalData.appResourcesBase, resourcesBase: App.globalData.appResourcesBase,
option: {},
animationData: {}, animationData: {},
animationPointHeight: 0, animationPointHeight: 0,
animationPointOrigin: 0,
winAnimationPoint: false, winAnimationPoint: false,
...@@ -29,16 +32,22 @@ Page({ ...@@ -29,16 +32,22 @@ Page({
winCommodityDetail: false, winCommodityDetail: false,
}, },
onLoad: function () { onLoad: function (option) {
this.setData({
option: option
})
this.resetShoppingCart()
this.setCartAnimation() this.setCartAnimation()
this.setShopInfo() this.setShopInfo()
this.querySideBar() this.querySideBar()
}, },
onUnload: function () { onShow: function () {
// 离开页面清空商品数据 if (wx.getStorageSync('shoppingCartBuffer').length === 0) {
wx.setStorageSync('shoppingCartBuffer', []) this.resetShoppingCart()
}
}, },
/** /**
...@@ -53,6 +62,15 @@ Page({ ...@@ -53,6 +62,15 @@ Page({
duration: 500, duration: 500,
timingFunction: 'ease' timingFunction: 'ease'
}) })
// 获取购物车高度
const funcQuery = wx.createSelectorQuery()
funcQuery.select('#cart').boundingClientRect()
funcQuery.exec((result) => {
this.setData({
animationPointOrigin: result[0].top + 4
})
})
}, },
/** /**
...@@ -74,7 +92,7 @@ Page({ ...@@ -74,7 +92,7 @@ Page({
winAnimationPoint: true, winAnimationPoint: true,
}) })
let funcTimer = setTimeout(() => { let funcTimer = setTimeout(() => {
this.animation.translate(0, 0).step() this.animation.translate(0, this.data.animationPointOrigin).step()
this.setData({ this.setData({
animationData: this.animation.export(), animationData: this.animation.export(),
// winAnimationPoint: false, // winAnimationPoint: false,
...@@ -88,7 +106,14 @@ Page({ ...@@ -88,7 +106,14 @@ Page({
this.setData({ this.setData({
shopInfo: funcShopInfo shopInfo: funcShopInfo
}) })
console.log(this.data.shopInfo) },
resetShoppingCart: function () {
this.setData({
shoppingCart: [],
shoppingCartTotal: 0,
})
wx.setStorageSync('shoppingCartBuffer', [])
}, },
/** /**
...@@ -115,6 +140,18 @@ Page({ ...@@ -115,6 +140,18 @@ Page({
funcSideBar.push(funcItem) funcSideBar.push(funcItem)
} }
// 判断是否从推荐菜单进入
if (this.data.option.sideBarId) {
for (let i = 0, l = funcSideBar.length; i < l; i++) {
if (funcSideBar[i].id === this.data.option.sideBarId) {
this.setData({
currentIndex: i
})
break
}
}
}
this.setData({ this.setData({
sideBar: funcSideBar, sideBar: funcSideBar,
menuTitle: funcSideBar[0].tab menuTitle: funcSideBar[0].tab
...@@ -165,10 +202,13 @@ Page({ ...@@ -165,10 +202,13 @@ Page({
'notificationId': funcResponse[i].notificationId, // 下单须知 'notificationId': funcResponse[i].notificationId, // 下单须知
'quantityMin': 1, 'quantityMin': 1,
'quantityMax': funcResponse[i].number, 'quantityMax': funcResponse[i].number < 20 ? funcResponse[i].number : 20, // 最大上限 20 件
'isActive': true, 'isActive': true,
} }
// 没有库存了
if (funcItem.quantityMax === 0) funcItem.isStockMax = true
let funcUserType = wx.getStorageSync('userInfo').userType let funcUserType = wx.getStorageSync('userInfo').userType
// 根据后台判断价格显示类型 // 根据后台判断价格显示类型
// 活动价优先级最高,如果存在活动价,则只显示活动价和普通价 // 活动价优先级最高,如果存在活动价,则只显示活动价和普通价
...@@ -189,6 +229,23 @@ Page({ ...@@ -189,6 +229,23 @@ Page({
winLoading: false, winLoading: false,
commodityList: funcCommodityList, commodityList: funcCommodityList,
}) })
// 判断是否从推荐菜单进入,主动查询商品详情
if (this.data.option.commodityId) {
for (let i = 0, l = funcCommodityList.length; i < l; i++) {
if (funcCommodityList[i].id === this.data.option.commodityId) {
let funcEvent = {
currentTarget: {
dataset: {
item: funcCommodityList[i]
}
}
}
this.onCommodityDetail(funcEvent)
break
}
}
}
}, },
}) })
}, },
...@@ -266,32 +323,46 @@ Page({ ...@@ -266,32 +323,46 @@ Page({
let funcShoppingCart = this.data.shoppingCart let funcShoppingCart = this.data.shoppingCart
let funcWinToastNothing = false
// 详情加入购物车按钮商品数据不会存在于 event 对象中,所以要区分 // 详情加入购物车按钮商品数据不会存在于 event 对象中,所以要区分
let funcWinToast = false let funcWinToast = true
let funcItem = event.currentTarget.dataset.item let funcItem = event.currentTarget.dataset.item
if (!funcItem) { if (!funcItem) {
funcWinToast = true funcWinToast = true
funcItem = this.data.commodityDetail funcItem = this.data.commodityDetail
} }
console.log(funcItem)
// 判断购物车中是否存在同类商品 // 判断购物车中是否存在同类商品
// 修改相应的商品数量 // 修改相应的商品数量
if (funcShoppingCart.length !== 0) { if (funcShoppingCart.length !== 0) {
for (let i = 0, l = funcShoppingCart.length; i < l; i++) { for (let i = 0, l = funcShoppingCart.length; i < l; i++) {
if (funcItem.id === funcShoppingCart[i].id) { if (funcItem.id === funcShoppingCart[i].id) {
if (funcShoppingCart[i].quantity < funcShoppingCart[i].quantityMax) {
funcShoppingCart[i].quantity = funcShoppingCart[i].quantity + 1 funcShoppingCart[i].quantity = funcShoppingCart[i].quantity + 1
} else {
funcWinToastNothing = true
funcWinToast = false
}
break break
} }
// 当前添加商品不在购物车里的场景
if (i === funcShoppingCart.length - 1) { if (i === funcShoppingCart.length - 1) {
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1 funcItem.quantity = 1
funcShoppingCart.push(funcItem) funcShoppingCart.push(funcItem)
} }
} }
}
} else { } else {
// 库存要大于零才能添加
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1 funcItem.quantity = 1
funcShoppingCart.push(funcItem) funcShoppingCart.push(funcItem)
} }
}
// 重新计算购物车总数 // 重新计算购物车总数
let funcShoppingCartTotal = 0 let funcShoppingCartTotal = 0
...@@ -303,8 +374,11 @@ Page({ ...@@ -303,8 +374,11 @@ Page({
shoppingCart: funcShoppingCart, shoppingCart: funcShoppingCart,
shoppingCartTotal: funcShoppingCartTotal, shoppingCartTotal: funcShoppingCartTotal,
winToast: funcWinToast, winToast: funcWinToast,
winToastNothing: funcWinToastNothing,
winCommodityDetail: false, winCommodityDetail: false,
}) })
console.log(funcShoppingCart)
}, },
/** /**
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
l-image-class="toast-image" l-image-class="toast-image"
l-class="toast-bg" l-class="toast-bg"
show="{{winToast}}" show="{{winToast}}"
mask="{{true}}"
image="/image/success.png" image="/image/success.png"
title="添加购物车成功" title="添加购物车成功"
duration="400"
></l-toast> ></l-toast>
<l-toast show="{{winToastNothing}}" icon="error" title="没有更多商品了" duration="400"></l-toast>
<l-toast <l-toast
show="{{winLoading}}" show="{{winLoading}}"
icon="loading" icon="loading"
...@@ -31,8 +33,8 @@ ...@@ -31,8 +33,8 @@
<view class="menu-list"> <view class="menu-list">
<view class="right-content-title">{{menuTitle}}</view> <view class="right-content-title">{{menuTitle}}</view>
<block wx:for="{{commodityList}}" wx:for-index="index" wx:for-item="item" wx:key="index"> <block wx:for="{{commodityList}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="commodity-item row"> <view class="commodity-item row" data-item="{{item}}" bind:tap="onCommodityDetail">
<view class="item-img" data-item="{{item}}" bindtap="onCommodityDetail"> <view class="item-img">
<image src="{{item.cover}}" mode="widthFix"></image> <image src="{{item.cover}}" mode="widthFix"></image>
</view> </view>
<view class="item-info"> <view class="item-info">
...@@ -79,7 +81,7 @@ ...@@ -79,7 +81,7 @@
</view> </view>
<view class="item-operation-add"> <view class="item-operation-add">
<button class="row con-c align-c" data-item="{{item}}" bindtap="onCommodityAdd"> <button class="row con-c align-c" data-item="{{item}}" catchtap="onCommodityAdd">
<image mode="widthFix" src="{{imageBase + 'icon/cart-3.png'}}"></image> <image mode="widthFix" src="{{imageBase + 'icon/cart-3.png'}}"></image>
</button> </button>
</view> </view>
...@@ -89,9 +91,9 @@ ...@@ -89,9 +91,9 @@
</block> </block>
<!-- 购物车按钮 --> <!-- 购物车按钮 -->
<view class="cart-btn row con-c align-c" bindtap="onShoppingCart"> <view id="cart" class="cart row con-c align-c" bindtap="onShoppingCart">
<!-- 添加动画圆点 --> <!-- 添加动画圆点 -->
<view class="cart-animation" wx:if="{{winAnimationPoint}}" animation="{{animationData}}"></view> <!-- <view class="cart-animation" wx:if="{{winAnimationPoint}}" animation="{{animationData}}"></view> -->
<view class="cart-num row con-c align-c">{{shoppingCartTotal}}</view> <view class="cart-num row con-c align-c">{{shoppingCartTotal}}</view>
<view class="cart-img-wrap"> <view class="cart-img-wrap">
......
...@@ -13,7 +13,7 @@ page { ...@@ -13,7 +13,7 @@ page {
.side-bar { .side-bar {
width: 160rpx; width: 160rpx;
height: 100vh; height: 100vh;
margin-top: 140rpx; padding-top: 126rpx;
overflow-y: scroll; overflow-y: scroll;
background: #f2f3f5; background: #f2f3f5;
} }
...@@ -58,7 +58,7 @@ page { ...@@ -58,7 +58,7 @@ page {
color: #959da9; color: #959da9;
} }
.cart-btn { .cart {
position: fixed; position: fixed;
right: 48rpx; right: 48rpx;
bottom: 160rpx; bottom: 160rpx;
...@@ -188,6 +188,13 @@ page { ...@@ -188,6 +188,13 @@ page {
height: 24rpx; height: 24rpx;
} }
.item-operation-add-disable button {
width: 44rpx;
height: 44rpx;
border-radius: 50%;
background: #999999;
}
.goods-add-btn-wrap { .goods-add-btn-wrap {
flex: 1; flex: 1;
} }
...@@ -378,9 +385,10 @@ image { ...@@ -378,9 +385,10 @@ image {
/* 购物车样式 */ /* 购物车样式 */
.cart-animation { .cart-animation {
position: fixed; position: fixed;
top: 0;
right: 48rpx; right: 48rpx;
width: 26rpx; width: 26rpx;
height: 26rpx; height: 26rpx;
border-radius: 50%; border-radius: 50%;
background: red; background: #86c5e1;
} }
\ No newline at end of file
...@@ -5,6 +5,8 @@ Page({ ...@@ -5,6 +5,8 @@ Page({
imageBase: App.globalData.appImageBase, imageBase: App.globalData.appImageBase,
resourcesBase: App.globalData.appResourcesBase, resourcesBase: App.globalData.appResourcesBase,
option: {},
animationData: {}, animationData: {},
animationPointHeight: 0, animationPointHeight: 0,
animationPointOrigin: 0, animationPointOrigin: 0,
...@@ -30,7 +32,11 @@ Page({ ...@@ -30,7 +32,11 @@ Page({
winCommodityDetail: false, winCommodityDetail: false,
}, },
onLoad: function () { onLoad: function (option) {
this.setData({
option: option
})
this.resetShoppingCart() this.resetShoppingCart()
this.setCartAnimation() this.setCartAnimation()
...@@ -41,6 +47,11 @@ Page({ ...@@ -41,6 +47,11 @@ Page({
onShow: function () { onShow: function () {
if (wx.getStorageSync('shoppingCartBuffer').length === 0) { if (wx.getStorageSync('shoppingCartBuffer').length === 0) {
this.resetShoppingCart() this.resetShoppingCart()
} else {
this.setData({
shoppingCart: wx.getStorageSync('shoppingCartBuffer')
})
this.selectionTotal()
} }
}, },
...@@ -61,7 +72,6 @@ Page({ ...@@ -61,7 +72,6 @@ Page({
const funcQuery = wx.createSelectorQuery() const funcQuery = wx.createSelectorQuery()
funcQuery.select('#cart').boundingClientRect() funcQuery.select('#cart').boundingClientRect()
funcQuery.exec((result) => { funcQuery.exec((result) => {
console.log(result)
this.setData({ this.setData({
animationPointOrigin: result[0].top + 4 animationPointOrigin: result[0].top + 4
}) })
...@@ -101,7 +111,6 @@ Page({ ...@@ -101,7 +111,6 @@ Page({
this.setData({ this.setData({
shopInfo: funcShopInfo shopInfo: funcShopInfo
}) })
console.log(this.data.shopInfo)
}, },
resetShoppingCart: function () { resetShoppingCart: function () {
...@@ -136,6 +145,18 @@ Page({ ...@@ -136,6 +145,18 @@ Page({
funcSideBar.push(funcItem) funcSideBar.push(funcItem)
} }
// 判断是否从推荐菜单进入
if (this.data.option.sideBarId) {
for (let i = 0, l = funcSideBar.length; i < l; i++) {
if (funcSideBar[i].id === this.data.option.sideBarId) {
this.setData({
currentIndex: i
})
break
}
}
}
this.setData({ this.setData({
sideBar: funcSideBar, sideBar: funcSideBar,
menuTitle: funcSideBar[0].tab menuTitle: funcSideBar[0].tab
...@@ -190,6 +211,9 @@ Page({ ...@@ -190,6 +211,9 @@ Page({
'isActive': true, 'isActive': true,
} }
// 没有库存了
if (funcItem.quantityMax === 0) funcItem.isStockMax = true
let funcUserType = wx.getStorageSync('userInfo').userType let funcUserType = wx.getStorageSync('userInfo').userType
// 根据后台判断价格显示类型 // 根据后台判断价格显示类型
// 活动价优先级最高,如果存在活动价,则只显示活动价和普通价 // 活动价优先级最高,如果存在活动价,则只显示活动价和普通价
...@@ -211,8 +235,22 @@ Page({ ...@@ -211,8 +235,22 @@ Page({
commodityList: funcCommodityList, commodityList: funcCommodityList,
}) })
console.log('commodityList') // 判断是否从推荐菜单进入,主动查询商品详情
console.log(JSON.stringify(this.data.commodityList)) if (this.data.option.commodityId) {
for (let i = 0, l = funcCommodityList.length; i < l; i++) {
if (funcCommodityList[i].id === this.data.option.commodityId) {
let funcEvent = {
currentTarget: {
dataset: {
item: funcCommodityList[i]
}
}
}
this.onCommodityDetail(funcEvent)
break
}
}
}
}, },
}) })
}, },
...@@ -242,7 +280,6 @@ Page({ ...@@ -242,7 +280,6 @@ Page({
* @returns * @returns
*/ */
onCommodityDetail: function (event) { onCommodityDetail: function (event) {
console.log('onCommodityDetail', event)
let funcItem = event.currentTarget.dataset.item let funcItem = event.currentTarget.dataset.item
App.wxRequest({ App.wxRequest({
...@@ -291,44 +328,68 @@ Page({ ...@@ -291,44 +328,68 @@ Page({
let funcShoppingCart = this.data.shoppingCart let funcShoppingCart = this.data.shoppingCart
let funcWinToastNothing = false
// 详情加入购物车按钮商品数据不会存在于 event 对象中,所以要区分 // 详情加入购物车按钮商品数据不会存在于 event 对象中,所以要区分
let funcWinToast = false let funcWinToast = true
let funcItem = event.currentTarget.dataset.item let funcItem = event.currentTarget.dataset.item
if (!funcItem) { if (!funcItem) {
funcWinToast = true funcWinToast = true
funcItem = this.data.commodityDetail funcItem = this.data.commodityDetail
} }
console.log(funcItem)
// 判断购物车中是否存在同类商品 // 判断购物车中是否存在同类商品
// 修改相应的商品数量 // 修改相应的商品数量
if (funcShoppingCart.length !== 0) { if (funcShoppingCart.length !== 0) {
for (let i = 0, l = funcShoppingCart.length; i < l; i++) { for (let i = 0, l = funcShoppingCart.length; i < l; i++) {
if (funcItem.id === funcShoppingCart[i].id) { if (funcItem.id === funcShoppingCart[i].id) {
if (funcShoppingCart[i].quantity < funcShoppingCart[i].quantityMax) {
funcShoppingCart[i].quantity = funcShoppingCart[i].quantity + 1 funcShoppingCart[i].quantity = funcShoppingCart[i].quantity + 1
} else {
funcWinToastNothing = true
funcWinToast = false
}
break break
} }
// 当前添加商品不在购物车里的场景
if (i === funcShoppingCart.length - 1) { if (i === funcShoppingCart.length - 1) {
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1 funcItem.quantity = 1
funcShoppingCart.push(funcItem) funcShoppingCart.push(funcItem)
} }
} }
}
} else { } else {
// 库存要大于零才能添加
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1 funcItem.quantity = 1
funcShoppingCart.push(funcItem) funcShoppingCart.push(funcItem)
} }
}
this.setData({
shoppingCart: funcShoppingCart,
winToast: funcWinToast,
winToastNothing: funcWinToastNothing,
winCommodityDetail: false,
})
// 重新计算购物车数量
this.selectionTotal()
},
selectionTotal: function () {
// 重新计算购物车总数 // 重新计算购物车总数
let funcShoppingCart = this.data.shoppingCart
let funcShoppingCartTotal = 0 let funcShoppingCartTotal = 0
for (let i = 0, l = funcShoppingCart.length; i < l; i++) { for (let i = 0, l = funcShoppingCart.length; i < l; i++) {
funcShoppingCartTotal = funcShoppingCartTotal + funcShoppingCart[i].quantity funcShoppingCartTotal = funcShoppingCartTotal + funcShoppingCart[i].quantity
} }
this.setData({ this.setData({
shoppingCart: funcShoppingCart,
shoppingCartTotal: funcShoppingCartTotal, shoppingCartTotal: funcShoppingCartTotal,
winToast: funcWinToast,
winCommodityDetail: false,
}) })
}, },
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
l-image-class="toast-image" l-image-class="toast-image"
l-class="toast-bg" l-class="toast-bg"
show="{{winToast}}" show="{{winToast}}"
mask="{{true}}"
image="/image/success.png" image="/image/success.png"
title="添加购物车成功" title="添加购物车成功"
duration="400"
></l-toast> ></l-toast>
<l-toast show="{{winToastNothing}}" icon="error" title="没有更多商品了" duration="400"></l-toast>
<l-toast <l-toast
show="{{winLoading}}" show="{{winLoading}}"
icon="loading" icon="loading"
...@@ -91,7 +93,7 @@ ...@@ -91,7 +93,7 @@
<!-- 购物车按钮 --> <!-- 购物车按钮 -->
<view id="cart" class="cart row con-c align-c" bindtap="onShoppingCart"> <view id="cart" class="cart row con-c align-c" bindtap="onShoppingCart">
<!-- 添加动画圆点 --> <!-- 添加动画圆点 -->
<view class="cart-animation" wx:if="{{winAnimationPoint}}" animation="{{animationData}}"></view> <!-- <view class="cart-animation" wx:if="{{winAnimationPoint}}" animation="{{animationData}}"></view> -->
<view class="cart-num row con-c align-c">{{shoppingCartTotal}}</view> <view class="cart-num row con-c align-c">{{shoppingCartTotal}}</view>
<view class="cart-img-wrap"> <view class="cart-img-wrap">
......
...@@ -13,7 +13,7 @@ page { ...@@ -13,7 +13,7 @@ page {
.side-bar { .side-bar {
width: 160rpx; width: 160rpx;
height: 100vh; height: 100vh;
margin-top: 140rpx; padding-top: 126rpx;
overflow-y: scroll; overflow-y: scroll;
background: #f2f3f5; background: #f2f3f5;
} }
...@@ -188,6 +188,13 @@ page { ...@@ -188,6 +188,13 @@ page {
height: 24rpx; height: 24rpx;
} }
.item-operation-add-disable button {
width: 44rpx;
height: 44rpx;
border-radius: 50%;
background: #999999;
}
.goods-add-btn-wrap { .goods-add-btn-wrap {
flex: 1; flex: 1;
} }
......
...@@ -5,8 +5,11 @@ Page({ ...@@ -5,8 +5,11 @@ Page({
imageBase: App.globalData.appImageBase, imageBase: App.globalData.appImageBase,
resourcesBase: App.globalData.appResourcesBase, resourcesBase: App.globalData.appResourcesBase,
option: {},
animationData: {}, animationData: {},
animationPointHeight: 0, animationPointHeight: 0,
animationPointOrigin: 0,
winAnimationPoint: false, winAnimationPoint: false,
...@@ -29,16 +32,22 @@ Page({ ...@@ -29,16 +32,22 @@ Page({
winCommodityDetail: false, winCommodityDetail: false,
}, },
onLoad: function () { onLoad: function (option) {
this.setData({
option: option
})
this.resetShoppingCart()
this.setCartAnimation() this.setCartAnimation()
this.setShopInfo() this.setShopInfo()
this.querySideBar() this.querySideBar()
}, },
onUnload: function () { onShow: function () {
// 离开页面清空商品数据 if (wx.getStorageSync('shoppingCartBuffer').length === 0) {
wx.setStorageSync('shoppingCartBuffer', []) this.resetShoppingCart()
}
}, },
/** /**
...@@ -53,6 +62,15 @@ Page({ ...@@ -53,6 +62,15 @@ Page({
duration: 500, duration: 500,
timingFunction: 'ease' timingFunction: 'ease'
}) })
// 获取购物车高度
const funcQuery = wx.createSelectorQuery()
funcQuery.select('#cart').boundingClientRect()
funcQuery.exec((result) => {
this.setData({
animationPointOrigin: result[0].top + 4
})
})
}, },
/** /**
...@@ -74,7 +92,7 @@ Page({ ...@@ -74,7 +92,7 @@ Page({
winAnimationPoint: true, winAnimationPoint: true,
}) })
let funcTimer = setTimeout(() => { let funcTimer = setTimeout(() => {
this.animation.translate(0, 0).step() this.animation.translate(0, this.data.animationPointOrigin).step()
this.setData({ this.setData({
animationData: this.animation.export(), animationData: this.animation.export(),
// winAnimationPoint: false, // winAnimationPoint: false,
...@@ -88,7 +106,14 @@ Page({ ...@@ -88,7 +106,14 @@ Page({
this.setData({ this.setData({
shopInfo: funcShopInfo shopInfo: funcShopInfo
}) })
console.log(this.data.shopInfo) },
resetShoppingCart: function () {
this.setData({
shoppingCart: [],
shoppingCartTotal: 0,
})
wx.setStorageSync('shoppingCartBuffer', [])
}, },
/** /**
...@@ -115,6 +140,18 @@ Page({ ...@@ -115,6 +140,18 @@ Page({
funcSideBar.push(funcItem) funcSideBar.push(funcItem)
} }
// 判断是否从推荐菜单进入
if (this.data.option.sideBarId) {
for (let i = 0, l = funcSideBar.length; i < l; i++) {
if (funcSideBar[i].id === this.data.option.sideBarId) {
this.setData({
currentIndex: i
})
break
}
}
}
this.setData({ this.setData({
sideBar: funcSideBar, sideBar: funcSideBar,
menuTitle: funcSideBar[0].tab menuTitle: funcSideBar[0].tab
...@@ -165,10 +202,13 @@ Page({ ...@@ -165,10 +202,13 @@ Page({
'notificationId': funcResponse[i].notificationId, // 下单须知 'notificationId': funcResponse[i].notificationId, // 下单须知
'quantityMin': 1, 'quantityMin': 1,
'quantityMax': funcResponse[i].number, 'quantityMax': funcResponse[i].number < 20 ? funcResponse[i].number : 20, // 最大上限 20 件
'isActive': true, 'isActive': true,
} }
// 没有库存了
if (funcItem.quantityMax === 0) funcItem.isStockMax = true
let funcUserType = wx.getStorageSync('userInfo').userType let funcUserType = wx.getStorageSync('userInfo').userType
// 根据后台判断价格显示类型 // 根据后台判断价格显示类型
// 活动价优先级最高,如果存在活动价,则只显示活动价和普通价 // 活动价优先级最高,如果存在活动价,则只显示活动价和普通价
...@@ -189,6 +229,23 @@ Page({ ...@@ -189,6 +229,23 @@ Page({
winLoading: false, winLoading: false,
commodityList: funcCommodityList, commodityList: funcCommodityList,
}) })
// 判断是否从推荐菜单进入,主动查询商品详情
if (this.data.option.commodityId) {
for (let i = 0, l = funcCommodityList.length; i < l; i++) {
if (funcCommodityList[i].id === this.data.option.commodityId) {
let funcEvent = {
currentTarget: {
dataset: {
item: funcCommodityList[i]
}
}
}
this.onCommodityDetail(funcEvent)
break
}
}
}
}, },
}) })
}, },
...@@ -266,32 +323,46 @@ Page({ ...@@ -266,32 +323,46 @@ Page({
let funcShoppingCart = this.data.shoppingCart let funcShoppingCart = this.data.shoppingCart
let funcWinToastNothing = false
// 详情加入购物车按钮商品数据不会存在于 event 对象中,所以要区分 // 详情加入购物车按钮商品数据不会存在于 event 对象中,所以要区分
let funcWinToast = false let funcWinToast = true
let funcItem = event.currentTarget.dataset.item let funcItem = event.currentTarget.dataset.item
if (!funcItem) { if (!funcItem) {
funcWinToast = true funcWinToast = true
funcItem = this.data.commodityDetail funcItem = this.data.commodityDetail
} }
console.log(funcItem)
// 判断购物车中是否存在同类商品 // 判断购物车中是否存在同类商品
// 修改相应的商品数量 // 修改相应的商品数量
if (funcShoppingCart.length !== 0) { if (funcShoppingCart.length !== 0) {
for (let i = 0, l = funcShoppingCart.length; i < l; i++) { for (let i = 0, l = funcShoppingCart.length; i < l; i++) {
if (funcItem.id === funcShoppingCart[i].id) { if (funcItem.id === funcShoppingCart[i].id) {
if (funcShoppingCart[i].quantity < funcShoppingCart[i].quantityMax) {
funcShoppingCart[i].quantity = funcShoppingCart[i].quantity + 1 funcShoppingCart[i].quantity = funcShoppingCart[i].quantity + 1
} else {
funcWinToastNothing = true
funcWinToast = false
}
break break
} }
// 当前添加商品不在购物车里的场景
if (i === funcShoppingCart.length - 1) { if (i === funcShoppingCart.length - 1) {
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1 funcItem.quantity = 1
funcShoppingCart.push(funcItem) funcShoppingCart.push(funcItem)
} }
} }
}
} else { } else {
// 库存要大于零才能添加
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1 funcItem.quantity = 1
funcShoppingCart.push(funcItem) funcShoppingCart.push(funcItem)
} }
}
// 重新计算购物车总数 // 重新计算购物车总数
let funcShoppingCartTotal = 0 let funcShoppingCartTotal = 0
...@@ -303,8 +374,11 @@ Page({ ...@@ -303,8 +374,11 @@ Page({
shoppingCart: funcShoppingCart, shoppingCart: funcShoppingCart,
shoppingCartTotal: funcShoppingCartTotal, shoppingCartTotal: funcShoppingCartTotal,
winToast: funcWinToast, winToast: funcWinToast,
winToastNothing: funcWinToastNothing,
winCommodityDetail: false, winCommodityDetail: false,
}) })
console.log(funcShoppingCart)
}, },
/** /**
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
l-image-class="toast-image" l-image-class="toast-image"
l-class="toast-bg" l-class="toast-bg"
show="{{winToast}}" show="{{winToast}}"
mask="{{true}}"
image="/image/success.png" image="/image/success.png"
title="添加购物车成功" title="添加购物车成功"
duration="400"
></l-toast> ></l-toast>
<l-toast show="{{winToastNothing}}" icon="error" title="没有更多商品了" duration="400"></l-toast>
<l-toast <l-toast
show="{{winLoading}}" show="{{winLoading}}"
icon="loading" icon="loading"
...@@ -31,8 +33,8 @@ ...@@ -31,8 +33,8 @@
<view class="menu-list"> <view class="menu-list">
<view class="right-content-title">{{menuTitle}}</view> <view class="right-content-title">{{menuTitle}}</view>
<block wx:for="{{commodityList}}" wx:for-index="index" wx:for-item="item" wx:key="index"> <block wx:for="{{commodityList}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="commodity-item row"> <view class="commodity-item row" data-item="{{item}}" bind:tap="onCommodityDetail">
<view class="item-img" data-item="{{item}}" bindtap="onCommodityDetail"> <view class="item-img">
<image src="{{item.cover}}" mode="widthFix"></image> <image src="{{item.cover}}" mode="widthFix"></image>
</view> </view>
<view class="item-info"> <view class="item-info">
...@@ -79,7 +81,7 @@ ...@@ -79,7 +81,7 @@
</view> </view>
<view class="item-operation-add"> <view class="item-operation-add">
<button class="row con-c align-c" data-item="{{item}}" bindtap="onCommodityAdd"> <button class="row con-c align-c" data-item="{{item}}" catchtap="onCommodityAdd">
<image mode="widthFix" src="{{imageBase + 'icon/cart-3.png'}}"></image> <image mode="widthFix" src="{{imageBase + 'icon/cart-3.png'}}"></image>
</button> </button>
</view> </view>
...@@ -89,9 +91,9 @@ ...@@ -89,9 +91,9 @@
</block> </block>
<!-- 购物车按钮 --> <!-- 购物车按钮 -->
<view class="cart-btn row con-c align-c" bindtap="onShoppingCart"> <view id="cart" class="cart row con-c align-c" bindtap="onShoppingCart">
<!-- 添加动画圆点 --> <!-- 添加动画圆点 -->
<view class="cart-animation" wx:if="{{winAnimationPoint}}" animation="{{animationData}}"></view> <!-- <view class="cart-animation" wx:if="{{winAnimationPoint}}" animation="{{animationData}}"></view> -->
<view class="cart-num row con-c align-c">{{shoppingCartTotal}}</view> <view class="cart-num row con-c align-c">{{shoppingCartTotal}}</view>
<view class="cart-img-wrap"> <view class="cart-img-wrap">
......
...@@ -13,7 +13,7 @@ page { ...@@ -13,7 +13,7 @@ page {
.side-bar { .side-bar {
width: 160rpx; width: 160rpx;
height: 100vh; height: 100vh;
margin-top: 140rpx; padding-top: 126rpx;
overflow-y: scroll; overflow-y: scroll;
background: #f2f3f5; background: #f2f3f5;
} }
...@@ -58,7 +58,7 @@ page { ...@@ -58,7 +58,7 @@ page {
color: #959da9; color: #959da9;
} }
.cart-btn { .cart {
position: fixed; position: fixed;
right: 48rpx; right: 48rpx;
bottom: 160rpx; bottom: 160rpx;
...@@ -188,6 +188,13 @@ page { ...@@ -188,6 +188,13 @@ page {
height: 24rpx; height: 24rpx;
} }
.item-operation-add-disable button {
width: 44rpx;
height: 44rpx;
border-radius: 50%;
background: #999999;
}
.goods-add-btn-wrap { .goods-add-btn-wrap {
flex: 1; flex: 1;
} }
...@@ -378,9 +385,10 @@ image { ...@@ -378,9 +385,10 @@ image {
/* 购物车样式 */ /* 购物车样式 */
.cart-animation { .cart-animation {
position: fixed; position: fixed;
top: 0;
right: 48rpx; right: 48rpx;
width: 26rpx; width: 26rpx;
height: 26rpx; height: 26rpx;
border-radius: 50%; border-radius: 50%;
background: red; background: #86c5e1;
} }
\ No newline at end of file
...@@ -122,7 +122,7 @@ Page({ ...@@ -122,7 +122,7 @@ Page({
for (let i = 0, l = funcResponse.length; i < l; i++) { for (let i = 0, l = funcResponse.length; i < l; i++) {
let funcItem = { let funcItem = {
'id': funcResponse[i].id, // 商品标识 'id': funcResponse[i].id, // 商品标识
'typeId': funcResponse[i].classifyId, // 商品分类标识 'typeId': funcResponse[i].genre, // 商品分类标识
'inventoriesId': funcResponse[i].inventoriesId, // 仓库标识 'inventoriesId': funcResponse[i].inventoriesId, // 仓库标识
'name': funcResponse[i].name, 'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面 'cover': funcResponse[i].coverImg, // 商品封面
......
...@@ -161,7 +161,7 @@ Page({ ...@@ -161,7 +161,7 @@ Page({
let funcShoppingCart = this.data.shoppingCart let funcShoppingCart = this.data.shoppingCart
if (funcShoppingCart[funcIndex].quantityMax <= funcShoppingCart[funcIndex].quantity) return if (funcShoppingCart[funcIndex].quantityMax <= funcShoppingCart[funcIndex].quantity) return
funcShoppingCart[funcIndex].quantity = funcShoppingCart[funcIndex].quantity + 10 funcShoppingCart[funcIndex].quantity = funcShoppingCart[funcIndex].quantity + 1
this.setData({ this.setData({
shoppingCart: funcShoppingCart shoppingCart: funcShoppingCart
}) })
......
<l-toast show="{{winToast}}" icon="error" title="{{toastContent}}"></l-toast>
<!-- 购买须知详情 --> <!-- 购买须知详情 -->
<view class="notice-detail" wx:if="{{winNoticeDetail}}" bindtap="onNoticeClose"> <view class="notice-detail" wx:if="{{winNoticeDetail}}" bindtap="onNoticeClose">
<view class="notice-item" animation="{{animation}}"> <view class="notice-item" animation="{{animation}}">
...@@ -171,11 +169,13 @@ ...@@ -171,11 +169,13 @@
</view> </view>
<view class="quantity-input row con-b align-c"> <view class="quantity-input row con-b align-c">
<l-button l-class="input-button input-cut" special="{{true}}" bind:lintap="onQuantityCut"> <l-button l-class="input-button input-cut" special="{{true}}" bind:lintap="onQuantityCut">
<image class="input-icon" src="{{imageBase + 'cut.png'}}"></image> <image wx:if="{{1 < quantity}}" class="input-icon" src="{{imageBase + 'icon/cut-1.png'}}"></image>
<image wx:if="{{1 === quantity}}" class="input-icon" src="{{imageBase + 'icon/cut-2.png'}}"></image>
</l-button> </l-button>
<text class="text" style="{{formQuantity === 0 ? 'color: #C2C7CF' : 'color: #15191F'}}">{{quantity}}</text> <text class="text" style="{{formQuantity === 0 ? 'color: #C2C7CF' : 'color: #15191F'}}">{{quantity}}</text>
<l-button l-class="input-button input-add" special="{{true}}" bind:lintap="onQuantityAdd"> <l-button l-class="input-button input-add" special="{{true}}" bind:lintap="onQuantityAdd">
<image class="input-icon" src="{{imageBase + 'add.png'}}"></image> <image wx:if="{{quantity < quantityMax}}" class="input-icon" src="{{imageBase + 'icon/add-1.png'}}"></image>
<image wx:if="{{quantity === quantityMax}}" class="input-icon" src="{{imageBase + 'icon/add-2.png'}}"></image>
</l-button> </l-button>
</view> </view>
<view class="quantity-other row con-b align-c"> <view class="quantity-other row con-b align-c">
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
</view> </view>
<!-- winContact --> <!-- winContact -->
<view class="contact" wx:if="{{winContact && !winNoticeDetail}}"> <view class="contact" wx:if="{{winContact && !winNoticeDetail && !winStockTip}}">
<view class="contact-title col"> <view class="contact-title col">
<text>{{contactTitle}}</text> <text>{{contactTitle}}</text>
<text>仅用于接收订单确认短信</text> <text>仅用于接收订单确认短信</text>
...@@ -202,13 +202,13 @@ ...@@ -202,13 +202,13 @@
</view> </view>
<view class="contact-input col"> <view class="contact-input col">
<text>手机号</text> <text>手机号</text>
<input placeholder="请输入手机号" maxlength="11" data-type="phone" data-index="{{0}}" bindblur="onInputBlur"></input> <input placeholder="请输入手机号" maxlength="11" type="number" data-type="phone" data-index="{{0}}" bindblur="onInputBlur"></input>
<text>{{registerInfo[0].errorPhone}}</text> <text>{{registerInfo[0].errorPhone}}</text>
</view> </view>
</view> </view>
<!-- winRegister --> <!-- winRegister -->
<view class="register" wx:if="{{winRegister && !winNoticeDetail}}"> <view class="register" wx:if="{{winRegister && !winNoticeDetail && !winStockTip}}">
<view class="register-title col"> <view class="register-title col">
<text>填写贵宾信息</text> <text>填写贵宾信息</text>
</view> </view>
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</view> </view>
<view class="contact-input col"> <view class="contact-input col">
<text>手机号</text> <text>手机号</text>
<input placeholder="请输入手机号" maxlength="11" data-type="phone" data-index="{{index}}" bindblur="onInputBlur"></input> <input placeholder="请输入手机号" maxlength="11" type="number" data-type="phone" data-index="{{index}}" bindblur="onInputBlur"></input>
<text>{{item.errorPhone}}</text> <text>{{item.errorPhone}}</text>
</view> </view>
<view class="contact-input col"> <view class="contact-input col">
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
</view> </view>
<!-- winButtonPay --> <!-- winButtonPay -->
<cover-view class="pay" wx:if="{{winButtonPay && !winNoticeDetail}}"> <cover-view class="pay" wx:if="{{winButtonPay && !winNoticeDetail && !winStockTip}}">
<cover-view class="pay-tip row align-c"> <cover-view class="pay-tip row align-c">
<cover-image src="{{imageBase + 'fail-icon-4.png'}}"></cover-image> <cover-image src="{{imageBase + 'fail-icon-4.png'}}"></cover-image>
<cover-view class="pay-tip-text row con-c align-c">付款后一经确认不得退款</cover-view> <cover-view class="pay-tip-text row con-c align-c">付款后一经确认不得退款</cover-view>
...@@ -256,3 +256,23 @@ ...@@ -256,3 +256,23 @@
<cover-view class="appointment row con-c align-c" wx:if="{{winButtonAppointment && !winNoticeDetail}}"> <cover-view class="appointment row con-c align-c" wx:if="{{winButtonAppointment && !winNoticeDetail}}">
<cover-view class="appointment-confirm row con-c align-c">确认预约</cover-view> <cover-view class="appointment-confirm row con-c align-c">确认预约</cover-view>
</cover-view> </cover-view>
<!-- 库存不足提示 -->
<view class="stock-mask row con-c align-c" wx:if="{{winStockTip}}">
<view class="stock col con-c align-c">
<view class="stock-tip row con-c align-c">
<text>{{'抱歉,您本单商品有' + stockList.length + '件库存不足'}}</text>
</view>
<view class="stock-info col con-c align-c">
<block wx:for="{{stockList}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="stock-item row align-c">
<image src="{{item.cover}}"></image>
<text>{{item.name}}</text>
</view>
</block>
</view>
<view class="stock-close row con-c align-c" bindtap="onStockTipClose">
<button class="row con-c align-c">返回购物车</button>
</view>
</view>
</view>
\ No newline at end of file
...@@ -866,3 +866,72 @@ ...@@ -866,3 +866,72 @@
font-size: 26rpx; font-size: 26rpx;
line-height: 44rpx; line-height: 44rpx;
} }
/* 库存不足 */
.stock-mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, .6);
}
.stock {
width: 606rpx;
padding: 56rpx 40rpx 40rpx 40rpx;
background: #FFFFFF;
}
.stock-tip {
width: 526rpx;
padding-bottom: 58rpx;
border-bottom: 1px #E2E7EF solid;
}
.stock-tip text {
height: 48rpx;
font-size: 34rpx;
font-weight: 500;
line-height: 48rpx;
color: #15191F;
}
.stock-info {
width: 526rpx;
}
.stock-close {
margin-top: 96rpx;
}
.stock-close > button {
width: 526rpx;
height: 80rpx;
border-radius: 4px;
background: #86C5E1;
font-size: 30rpx;
font-weight: 500;
line-height: 42rpx;
color: #FFFFFF;
}
.stock-item {
width: 526rpx;
height: 96rpx;
margin-top: 64rpx;
}
.stock-item image {
width: 96rpx;
height: 96rpx;
margin-right: 32rpx;
}
.stock-item text {
font-size: 30rpx;
font-weight: 400;
line-height: 42rpx;
color: #15191F;
}
\ No newline at end of file
const App = getApp() const App = getApp()
let logicData = {
pageScrollLock: false,
pageScrollTimer: 0,
}
Page({ Page({
data: { data: {
bannerImg: App.globalData.appResourcesBase + 'play/home/type.png', bannerImg: App.globalData.appResourcesBase + 'play/home/type.png',
...@@ -12,6 +7,10 @@ Page({ ...@@ -12,6 +7,10 @@ Page({
navigationLogoTop: 0, navigationLogoTop: 0,
navigationLogoMarginTop: 0, navigationLogoMarginTop: 0,
movieList: [],
recentList: [ recentList: [
{ {
id: 0, id: 0,
...@@ -61,7 +60,8 @@ Page({ ...@@ -61,7 +60,8 @@ Page({
}, },
onShow: function () { onShow: function () {
this.getActivityList(1) this.queryActivity()
this.queryMovie()
}, },
/** /**
...@@ -82,42 +82,22 @@ Page({ ...@@ -82,42 +82,22 @@ Page({
}, },
/** /**
* 设置标题高度 * 查询主题活动
* @function * @function
* @param * @param
* @returns * @returns
*/ */
onActivity: function () { queryActivity: function () {
wx.navigateTo({
url: '/pages/play/activity/activity'
})
},
onActivityDetail: function (funcItem) {
// console.log(funcItem)
wx.navigateTo({
url: '/pages/activity-detail/activity-detail?id=' + funcItem.currentTarget.dataset.id
})
},
onShopDetail: function (funcItem) {
wx.navigateTo({
url: '/pages/play/service-detail/service-detail?id=' + funcItem.currentTarget.dataset.id
})
},
//主题活动列表 type 1 近期 0 往期
getActivityList(type) {
var that = this var that = this
App.wxRequest({ App.wxRequest({
url: '/api/v1/activity/getList', url: '/api/v1/activity/getList',
data: { data: {
listType: type, listType: 1,
pageSize: 10, pageSize: 10,
pageNo: 1, pageNo: 1,
tagId: '101', tagId: '101',
}, },
success: function (res) { success: (res) => {
var tmpArr = []; var tmpArr = [];
res.data.list.forEach(item => { res.data.list.forEach(item => {
var tmpItem = { var tmpItem = {
...@@ -131,24 +111,84 @@ Page({ ...@@ -131,24 +111,84 @@ Page({
tmpArr.push(tmpItem) tmpArr.push(tmpItem)
}) })
// 活动开始时间倒序排序 this.setData({
// tmpArr.sort(function(a,b) {
// return new Date(b.beginDate.replace(/月/g,"\/").replace(/日/g,"\/")) - new Date(a.beginDate.replace(/月/g,"\/").replace(/日/g,"\/"))
// })
if (type == 1) {
that.setData({
banner: tmpArr banner: tmpArr
}) })
} else { }
that.setData({
other: tmpArr
}) })
},
/**
* 查询热映电影
* @function
* @param
* @returns
*/
queryMovie: function () {
App.wxRequest({
url: '/api/v1/film/getAllFilm',
data: {
'weekType': 0,
'pageSize': 10,
'pageNo': 1,
},
success: (response) => {
let funcResponse = response.data.list
let funcList = []
for (let i = 0, l = funcResponse.length; i < l; i++) {
let funcItem = {
'name': funcResponse[i].activityId,
'dateBegin': funcResponse[i].beginDate,
'dateEnd': funcResponse[i].endDate,
'cover': funcResponse[i].cover,
'movieDirector': funcResponse[i].filmDirector,
'movieLeader': funcResponse[i].filmLead,
'movieName': funcResponse[i].filmName,
'movieType': funcResponse[i].filmType,
'movieKeyWord': funcResponse[i].keyword,
'movieLeader': funcResponse[i].filmLead,
'price': funcResponse[i].visitorPrice, // 普通价
'priceText': App.modular.utils.formatAmount(funcResponse[i].visitorPrice), // 普通价文本格式
'priceSpecial': funcResponse[i].ownerPrice, // 业主价
'priceSpecialText': App.modular.utils.formatAmount(funcResponse[i].ownerPrice), // 业主价文本格式
'priceType': 1,
'tagsId': funcResponse[i].tagIds,
'tags': funcResponse[i].tags,
} }
funcList.push(funcItem)
}
this.setData({
movieList: funcList
})
} }
}) })
}, },
/**
* 设置标题高度
* @function
* @param
* @returns
*/
onActivity: function () {
wx.navigateTo({
url: '/pages/play/activity/activity'
})
},
onActivityDetail: function (funcItem) {
// console.log(funcItem)
wx.navigateTo({
url: '/pages/activity-detail/activity-detail?id=' + funcItem.currentTarget.dataset.id
})
},
onShopDetail: function (funcItem) {
wx.navigateTo({
url: '/pages/play/service-detail/service-detail?id=' + funcItem.currentTarget.dataset.id
})
},
//跳转到艺文 //跳转到艺文
onToArt: function () { onToArt: function () {
wx.navigateTo({ wx.navigateTo({
...@@ -195,8 +235,11 @@ Page({ ...@@ -195,8 +235,11 @@ Page({
}) })
}, },
onAllActivity: function () {
wx.navigateTo({
url: '/pages/play/activity/activity'
})
},
onAllRecent: function () { onAllRecent: function () {
wx.navigateTo({ wx.navigateTo({
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
<view class="title row con-b align-c"> <view class="title row con-b align-c">
<image src="./image/title-activity.png">近期活动</image> <image src="./image/title-activity.png">近期活动</image>
<text bindtap="onAllRecent">查看全部</text> <text bindtap="onAllRecent" bindtap="onAllActivity">查看全部</text>
</view> </view>
<swiper class="recent-swiper" next-margin="38rpx" bindchange="swiperRecentChange"> <swiper class="recent-swiper" next-margin="38rpx" bindchange="swiperRecentChange">
<block wx:for="{{recentList}}" wx:key="id"> <block wx:for="{{banner}}" wx:key="id">
<swiper-item class="recent-item"> <swiper-item class="recent-item">
<image class="{{swiperRecentCurrent === index ? 'recent-item-left' : '' }} {{swiperRecentCurrent === recentList.length - 1 ? 'recent-item-center' : ''}}" src="{{item.img}}"></image> <image class="{{swiperRecentCurrent === index ? 'recent-item-left' : '' }} {{swiperRecentCurrent === banner.length - 1 ? 'recent-item-center' : ''}}" src="{{item.cover}}"></image>
</swiper-item> </swiper-item>
</block> </block>
</swiper> </swiper>
...@@ -36,13 +36,13 @@ ...@@ -36,13 +36,13 @@
<swiper-item class="movie-item col con-e"> <swiper-item class="movie-item col con-e">
<view class="movie-wrapper {{swiperMovieCurrent === index ? 'movie-item-left' : '' }} {{swiperMovieCurrent === movieList.length - 1 ? 'movie-item-center' : ''}}"> <view class="movie-wrapper {{swiperMovieCurrent === index ? 'movie-item-left' : '' }} {{swiperMovieCurrent === movieList.length - 1 ? 'movie-item-center' : ''}}">
<view class="movie-cover"> <view class="movie-cover">
<image src="{{item.img}}"></image> <image src="{{item.cover}}"></image>
</view> </view>
<view class="movie-info-wrapper"> <view class="movie-info-wrapper">
<view class="movie-name row"> <view class="movie-name row">
<text>{{item.name}}</text> <text>{{item.movieName}}</text>
<view class="movie-dimensional"> <view class="movie-dimensional">
<text>{{item.dimensional}}</text> <text>{{item.movieType}}</text>
</view> </view>
</view> </view>
<view class="movie-info row"> <view class="movie-info row">
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<text>类型</text> <text>类型</text>
</view> </view>
<view class="movie-info-right"> <view class="movie-info-right">
<text>{{item.type}}</text> <text>{{item.movieType}}</text>
</view> </view>
</view> </view>
<view class="movie-info row"> <view class="movie-info row">
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<text>导演</text> <text>导演</text>
</view> </view>
<view class="movie-info-right"> <view class="movie-info-right">
<text>{{item.director}}</text> <text>{{item.movieDirector}}</text>
</view> </view>
</view> </view>
<view class="movie-btn"> <view class="movie-btn">
......
...@@ -190,11 +190,8 @@ ...@@ -190,11 +190,8 @@
} }
.movie-info-right { .movie-info-right {
display: -webkit-box;
margin-left: 8rpx; margin-left: 8rpx;
color: #656e7b; color: #656e7b;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden; overflow: hidden;
} }
......
...@@ -10,6 +10,7 @@ Page({ ...@@ -10,6 +10,7 @@ Page({
data: { data: {
imageBase: App.globalData.appImageBase, imageBase: App.globalData.appImageBase,
option: {},
// 导航栏相关属性 // 导航栏相关属性
navigationStyle: { navigationStyle: {
...@@ -69,8 +70,9 @@ Page({ ...@@ -69,8 +70,9 @@ Page({
}, },
onLoad: function (options) { onLoad: function (options) {
options.id = 1 this.setData({
logicData.option = options option: options
})
this.queryDetail(Number(options.id)) this.queryDetail(Number(options.id))
}, },
...@@ -80,12 +82,12 @@ Page({ ...@@ -80,12 +82,12 @@ Page({
* @param {string} - funcToken * @param {string} - funcToken
* @returns * @returns
*/ */
queryDetail: function (funcIndex) { queryDetail: function (funcAppId) {
funcIndex = funcIndex - 1 let funcIndex = 0
// 预设数据 // 预设数据
let funcDetail = [ let funcDetail = [
{ {
id: 1, appId: 1,
banner: [ banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-1-1-1.png', App.globalData.appResourcesBase + 'shop/banner/banner-1-1-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-1-1-2.png', App.globalData.appResourcesBase + 'shop/banner/banner-1-1-2.png',
...@@ -144,7 +146,7 @@ Page({ ...@@ -144,7 +146,7 @@ Page({
], ],
contact: '13316748039' contact: '13316748039'
}, { }, {
id: 2, appId: 5,
banner: [ banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-1-2-1.png', App.globalData.appResourcesBase + 'shop/banner/banner-1-2-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-1-2-2.png', App.globalData.appResourcesBase + 'shop/banner/banner-1-2-2.png',
...@@ -158,7 +160,7 @@ Page({ ...@@ -158,7 +160,7 @@ Page({
], ],
contact: '13316748039' contact: '13316748039'
}, { }, {
id: 3, appId: 7,
banner: [ banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-2-1-1.png', App.globalData.appResourcesBase + 'shop/banner/banner-2-1-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-2-1-2.png', App.globalData.appResourcesBase + 'shop/banner/banner-2-1-2.png',
...@@ -175,7 +177,7 @@ Page({ ...@@ -175,7 +177,7 @@ Page({
], ],
contact: '13316748039' contact: '13316748039'
}, { }, {
id: 4, appId: 6,
banner: [ banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-3-1-1.png', App.globalData.appResourcesBase + 'shop/banner/banner-3-1-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-3-1-2.png', App.globalData.appResourcesBase + 'shop/banner/banner-3-1-2.png',
...@@ -195,7 +197,7 @@ Page({ ...@@ -195,7 +197,7 @@ Page({
], ],
contact: '13316748039' contact: '13316748039'
}, { }, {
id: 5, appId: 4,
banner: [ banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-3-2-1.png', App.globalData.appResourcesBase + 'shop/banner/banner-3-2-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-3-2-2.png', App.globalData.appResourcesBase + 'shop/banner/banner-3-2-2.png',
...@@ -209,7 +211,7 @@ Page({ ...@@ -209,7 +211,7 @@ Page({
], ],
contact: '13316748039' contact: '13316748039'
}, { }, {
id: 6, appId: 2,
banner: [ banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-4-1-1.png', App.globalData.appResourcesBase + 'shop/banner/banner-4-1-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-4-1-2.png', App.globalData.appResourcesBase + 'shop/banner/banner-4-1-2.png',
...@@ -228,7 +230,30 @@ Page({ ...@@ -228,7 +230,30 @@ Page({
} }
] ]
// 读取预设信息,banner 图片等等
for (let i = 0, l = funcDetail.length; i < l; i++) {
if (funcAppId === funcDetail[i].appId) {
funcIndex = i
break
}
}
console.log(funcIndex)
// 缓存当前商店信息
for (let i = 0, l = App.globalData.shopId.length; i < l; i++) {
if (funcAppId === App.globalData.shopId[i].appId) {
let funcItem = {
'id': 'd9436d7018de43809824b6ec221ea01f',
'appId': 6,
'name': '原味舒食',
'logo': 'shop/logo-6.png',
'cover': 'shop/cover-6.png',
'shopType': ''
}
wx.setStorageSync('shopInfoBuffer', funcItem)
break
}
}
this.setData({ this.setData({
banner: funcDetail[funcIndex].banner, banner: funcDetail[funcIndex].banner,
...@@ -252,9 +277,17 @@ Page({ ...@@ -252,9 +277,17 @@ Page({
} }
}, },
queryDetailActivity: function () {
},
queryDetailCommodity: function () {
},
onLocation: function () { onLocation: function () {
wx.navigateTo({ wx.navigateTo({
url: '/pages/home/guide/guide?id=' + Number(logicData.option.id) url: '/pages/home/guide/guide?id=' + Number(this.data.option.id)
}) })
}, },
......
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 sign in to comment