Commit 967cf83b by 严立

LL - 购物流程问题修复

parent 9823cf03
......@@ -61,8 +61,7 @@ App({
// console.log("返回:", res);
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) {
obj.success(res.data)
}
......@@ -72,6 +71,10 @@ App({
this.wxRequest(obj)
}
})
} else if (500 === code) {
if (obj.success) {
obj.success(res)
}
} else {
if (obj.fail) {
let err = {
......
......@@ -73,8 +73,8 @@ Page({
'id': funcResponse[i].id, // 商品标识
'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面
'typeId': funcResponse[i].classifyId, // 商品分类标识
'shopType': funcResponse[i].genre,
'sideBarId': funcResponse[i].classifyId, // 商品所属标签
}
funcList.push(funcItem)
}
......@@ -100,8 +100,8 @@ Page({
'id': funcResponse[i].id, // 商品标识
'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面
'typeId': funcResponse[i].classifyId, // 商品分类标识
'shopType': funcResponse[i].genre,
'sideBarId': funcResponse[i].classifyId, // 商品所属标签
}
funcList.push(funcItem)
}
......@@ -127,8 +127,8 @@ Page({
'id': funcResponse[i].id, // 商品标识
'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面
'typeId': funcResponse[i].classifyId, // 商品分类标识
'shopType': funcResponse[i].genre,
'sideBarId': funcResponse[i].classifyId, // 商品所属标签
}
funcList.push(funcItem)
}
......@@ -154,8 +154,8 @@ Page({
'id': funcResponse[i].id, // 商品标识
'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面
'typeId': funcResponse[i].classifyId, // 商品分类标识
'shopType': funcResponse[i].genre,
'sideBarId': funcResponse[i].classifyId, // 商品所属标签
}
funcList.push(funcItem)
}
......@@ -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
* @param {object} - event
......
......@@ -23,7 +23,7 @@
</view>
<view class="shop-menu">
<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>
<text>{{item.name}}</text>
</view>
......@@ -39,7 +39,7 @@
</view>
<view class="shop-menu">
<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>
<text>{{item.name}}</text>
</view>
......@@ -59,12 +59,15 @@
<image src="{{resourcesBase + 'commodity/home/services-title.png'}}"></image>
</view>
<view class="services-list col align-c">
<!-- 精灵鸟理想国 -->
<view class="services-list-item col align-c" data-id="{{3}}" bindtap="onBuyMembership">
<image src="{{resourcesBase + 'commodity/home/services-1.png'}}"></image>
</view>
<!-- 故宫海洋世界 -->
<view class="services-list-item col align-c" data-id="{{1}}" bindtap="onBuyPassCheck">
<image src="{{resourcesBase + 'commodity/home/services-2.png'}}"></image>
</view>
<!-- 元养水韵 -->
<view class="services-list-item col align-c" data-id="{{7}}" bindtap="onBuyService">
<image src="{{resourcesBase + 'commodity/home/services-3.png'}}"></image>
</view>
......@@ -110,7 +113,7 @@
</view>
<view class="shop-menu">
<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>
<text>{{item.name}}</text>
</view>
......@@ -126,7 +129,7 @@
</view>
<view class="shop-menu">
<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>
<text>{{item.name}}</text>
</view>
......
......@@ -5,8 +5,11 @@ Page({
imageBase: App.globalData.appImageBase,
resourcesBase: App.globalData.appResourcesBase,
option: {},
animationData: {},
animationPointHeight: 0,
animationPointOrigin: 0,
winAnimationPoint: false,
......@@ -29,16 +32,22 @@ Page({
winCommodityDetail: false,
},
onLoad: function () {
onLoad: function (option) {
this.setData({
option: option
})
this.resetShoppingCart()
this.setCartAnimation()
this.setShopInfo()
this.querySideBar()
},
onUnload: function () {
// 离开页面清空商品数据
wx.setStorageSync('shoppingCartBuffer', [])
onShow: function () {
if (wx.getStorageSync('shoppingCartBuffer').length === 0) {
this.resetShoppingCart()
}
},
/**
......@@ -53,6 +62,15 @@ Page({
duration: 500,
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({
winAnimationPoint: true,
})
let funcTimer = setTimeout(() => {
this.animation.translate(0, 0).step()
this.animation.translate(0, this.data.animationPointOrigin).step()
this.setData({
animationData: this.animation.export(),
// winAnimationPoint: false,
......@@ -88,7 +106,14 @@ Page({
this.setData({
shopInfo: funcShopInfo
})
console.log(this.data.shopInfo)
},
resetShoppingCart: function () {
this.setData({
shoppingCart: [],
shoppingCartTotal: 0,
})
wx.setStorageSync('shoppingCartBuffer', [])
},
/**
......@@ -115,6 +140,18 @@ Page({
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({
sideBar: funcSideBar,
menuTitle: funcSideBar[0].tab
......@@ -165,10 +202,13 @@ Page({
'notificationId': funcResponse[i].notificationId, // 下单须知
'quantityMin': 1,
'quantityMax': funcResponse[i].number,
'quantityMax': funcResponse[i].number < 20 ? funcResponse[i].number : 20, // 最大上限 20 件
'isActive': true,
}
// 没有库存了
if (funcItem.quantityMax === 0) funcItem.isStockMax = true
let funcUserType = wx.getStorageSync('userInfo').userType
// 根据后台判断价格显示类型
// 活动价优先级最高,如果存在活动价,则只显示活动价和普通价
......@@ -189,6 +229,23 @@ Page({
winLoading: false,
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({
let funcShoppingCart = this.data.shoppingCart
let funcWinToastNothing = false
// 详情加入购物车按钮商品数据不会存在于 event 对象中,所以要区分
let funcWinToast = false
let funcWinToast = true
let funcItem = event.currentTarget.dataset.item
if (!funcItem) {
funcWinToast = true
funcItem = this.data.commodityDetail
}
console.log(funcItem)
// 判断购物车中是否存在同类商品
// 修改相应的商品数量
if (funcShoppingCart.length !== 0) {
for (let i = 0, l = funcShoppingCart.length; i < l; i++) {
if (funcItem.id === funcShoppingCart[i].id) {
if (funcShoppingCart[i].quantity < funcShoppingCart[i].quantityMax) {
funcShoppingCart[i].quantity = funcShoppingCart[i].quantity + 1
} else {
funcWinToastNothing = true
funcWinToast = false
}
break
}
// 当前添加商品不在购物车里的场景
if (i === funcShoppingCart.length - 1) {
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1
funcShoppingCart.push(funcItem)
}
}
}
} else {
// 库存要大于零才能添加
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1
funcShoppingCart.push(funcItem)
}
}
// 重新计算购物车总数
let funcShoppingCartTotal = 0
......@@ -303,8 +374,11 @@ Page({
shoppingCart: funcShoppingCart,
shoppingCartTotal: funcShoppingCartTotal,
winToast: funcWinToast,
winToastNothing: funcWinToastNothing,
winCommodityDetail: false,
})
console.log(funcShoppingCart)
},
/**
......
......@@ -2,11 +2,13 @@
l-image-class="toast-image"
l-class="toast-bg"
show="{{winToast}}"
mask="{{true}}"
image="/image/success.png"
title="添加购物车成功"
duration="400"
></l-toast>
<l-toast show="{{winToastNothing}}" icon="error" title="没有更多商品了" duration="400"></l-toast>
<l-toast
show="{{winLoading}}"
icon="loading"
......@@ -31,8 +33,8 @@
<view class="menu-list">
<view class="right-content-title">{{menuTitle}}</view>
<block wx:for="{{commodityList}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="commodity-item row">
<view class="item-img" data-item="{{item}}" bindtap="onCommodityDetail">
<view class="commodity-item row" data-item="{{item}}" bind:tap="onCommodityDetail">
<view class="item-img">
<image src="{{item.cover}}" mode="widthFix"></image>
</view>
<view class="item-info">
......@@ -79,7 +81,7 @@
</view>
<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>
</button>
</view>
......@@ -89,9 +91,9 @@
</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-img-wrap">
......
......@@ -13,7 +13,7 @@ page {
.side-bar {
width: 160rpx;
height: 100vh;
margin-top: 140rpx;
padding-top: 126rpx;
overflow-y: scroll;
background: #f2f3f5;
}
......@@ -58,7 +58,7 @@ page {
color: #959da9;
}
.cart-btn {
.cart {
position: fixed;
right: 48rpx;
bottom: 160rpx;
......@@ -188,6 +188,13 @@ page {
height: 24rpx;
}
.item-operation-add-disable button {
width: 44rpx;
height: 44rpx;
border-radius: 50%;
background: #999999;
}
.goods-add-btn-wrap {
flex: 1;
}
......@@ -378,9 +385,10 @@ image {
/* 购物车样式 */
.cart-animation {
position: fixed;
top: 0;
right: 48rpx;
width: 26rpx;
height: 26rpx;
border-radius: 50%;
background: red;
background: #86c5e1;
}
\ No newline at end of file
......@@ -5,6 +5,8 @@ Page({
imageBase: App.globalData.appImageBase,
resourcesBase: App.globalData.appResourcesBase,
option: {},
animationData: {},
animationPointHeight: 0,
animationPointOrigin: 0,
......@@ -30,7 +32,11 @@ Page({
winCommodityDetail: false,
},
onLoad: function () {
onLoad: function (option) {
this.setData({
option: option
})
this.resetShoppingCart()
this.setCartAnimation()
......@@ -41,6 +47,11 @@ Page({
onShow: function () {
if (wx.getStorageSync('shoppingCartBuffer').length === 0) {
this.resetShoppingCart()
} else {
this.setData({
shoppingCart: wx.getStorageSync('shoppingCartBuffer')
})
this.selectionTotal()
}
},
......@@ -61,7 +72,6 @@ Page({
const funcQuery = wx.createSelectorQuery()
funcQuery.select('#cart').boundingClientRect()
funcQuery.exec((result) => {
console.log(result)
this.setData({
animationPointOrigin: result[0].top + 4
})
......@@ -101,7 +111,6 @@ Page({
this.setData({
shopInfo: funcShopInfo
})
console.log(this.data.shopInfo)
},
resetShoppingCart: function () {
......@@ -136,6 +145,18 @@ Page({
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({
sideBar: funcSideBar,
menuTitle: funcSideBar[0].tab
......@@ -190,6 +211,9 @@ Page({
'isActive': true,
}
// 没有库存了
if (funcItem.quantityMax === 0) funcItem.isStockMax = true
let funcUserType = wx.getStorageSync('userInfo').userType
// 根据后台判断价格显示类型
// 活动价优先级最高,如果存在活动价,则只显示活动价和普通价
......@@ -211,8 +235,22 @@ Page({
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({
* @returns
*/
onCommodityDetail: function (event) {
console.log('onCommodityDetail', event)
let funcItem = event.currentTarget.dataset.item
App.wxRequest({
......@@ -291,44 +328,68 @@ Page({
let funcShoppingCart = this.data.shoppingCart
let funcWinToastNothing = false
// 详情加入购物车按钮商品数据不会存在于 event 对象中,所以要区分
let funcWinToast = false
let funcWinToast = true
let funcItem = event.currentTarget.dataset.item
if (!funcItem) {
funcWinToast = true
funcItem = this.data.commodityDetail
}
console.log(funcItem)
// 判断购物车中是否存在同类商品
// 修改相应的商品数量
if (funcShoppingCart.length !== 0) {
for (let i = 0, l = funcShoppingCart.length; i < l; i++) {
if (funcItem.id === funcShoppingCart[i].id) {
if (funcShoppingCart[i].quantity < funcShoppingCart[i].quantityMax) {
funcShoppingCart[i].quantity = funcShoppingCart[i].quantity + 1
} else {
funcWinToastNothing = true
funcWinToast = false
}
break
}
// 当前添加商品不在购物车里的场景
if (i === funcShoppingCart.length - 1) {
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1
funcShoppingCart.push(funcItem)
}
}
}
} else {
// 库存要大于零才能添加
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1
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
for (let i = 0, l = funcShoppingCart.length; i < l; i++) {
funcShoppingCartTotal = funcShoppingCartTotal + funcShoppingCart[i].quantity
}
this.setData({
shoppingCart: funcShoppingCart,
shoppingCartTotal: funcShoppingCartTotal,
winToast: funcWinToast,
winCommodityDetail: false,
})
},
......
......@@ -2,11 +2,13 @@
l-image-class="toast-image"
l-class="toast-bg"
show="{{winToast}}"
mask="{{true}}"
image="/image/success.png"
title="添加购物车成功"
duration="400"
></l-toast>
<l-toast show="{{winToastNothing}}" icon="error" title="没有更多商品了" duration="400"></l-toast>
<l-toast
show="{{winLoading}}"
icon="loading"
......@@ -91,7 +93,7 @@
<!-- 购物车按钮 -->
<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-img-wrap">
......
......@@ -13,7 +13,7 @@ page {
.side-bar {
width: 160rpx;
height: 100vh;
margin-top: 140rpx;
padding-top: 126rpx;
overflow-y: scroll;
background: #f2f3f5;
}
......@@ -188,6 +188,13 @@ page {
height: 24rpx;
}
.item-operation-add-disable button {
width: 44rpx;
height: 44rpx;
border-radius: 50%;
background: #999999;
}
.goods-add-btn-wrap {
flex: 1;
}
......
......@@ -5,8 +5,11 @@ Page({
imageBase: App.globalData.appImageBase,
resourcesBase: App.globalData.appResourcesBase,
option: {},
animationData: {},
animationPointHeight: 0,
animationPointOrigin: 0,
winAnimationPoint: false,
......@@ -29,16 +32,22 @@ Page({
winCommodityDetail: false,
},
onLoad: function () {
onLoad: function (option) {
this.setData({
option: option
})
this.resetShoppingCart()
this.setCartAnimation()
this.setShopInfo()
this.querySideBar()
},
onUnload: function () {
// 离开页面清空商品数据
wx.setStorageSync('shoppingCartBuffer', [])
onShow: function () {
if (wx.getStorageSync('shoppingCartBuffer').length === 0) {
this.resetShoppingCart()
}
},
/**
......@@ -53,6 +62,15 @@ Page({
duration: 500,
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({
winAnimationPoint: true,
})
let funcTimer = setTimeout(() => {
this.animation.translate(0, 0).step()
this.animation.translate(0, this.data.animationPointOrigin).step()
this.setData({
animationData: this.animation.export(),
// winAnimationPoint: false,
......@@ -88,7 +106,14 @@ Page({
this.setData({
shopInfo: funcShopInfo
})
console.log(this.data.shopInfo)
},
resetShoppingCart: function () {
this.setData({
shoppingCart: [],
shoppingCartTotal: 0,
})
wx.setStorageSync('shoppingCartBuffer', [])
},
/**
......@@ -115,6 +140,18 @@ Page({
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({
sideBar: funcSideBar,
menuTitle: funcSideBar[0].tab
......@@ -165,10 +202,13 @@ Page({
'notificationId': funcResponse[i].notificationId, // 下单须知
'quantityMin': 1,
'quantityMax': funcResponse[i].number,
'quantityMax': funcResponse[i].number < 20 ? funcResponse[i].number : 20, // 最大上限 20 件
'isActive': true,
}
// 没有库存了
if (funcItem.quantityMax === 0) funcItem.isStockMax = true
let funcUserType = wx.getStorageSync('userInfo').userType
// 根据后台判断价格显示类型
// 活动价优先级最高,如果存在活动价,则只显示活动价和普通价
......@@ -189,6 +229,23 @@ Page({
winLoading: false,
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({
let funcShoppingCart = this.data.shoppingCart
let funcWinToastNothing = false
// 详情加入购物车按钮商品数据不会存在于 event 对象中,所以要区分
let funcWinToast = false
let funcWinToast = true
let funcItem = event.currentTarget.dataset.item
if (!funcItem) {
funcWinToast = true
funcItem = this.data.commodityDetail
}
console.log(funcItem)
// 判断购物车中是否存在同类商品
// 修改相应的商品数量
if (funcShoppingCart.length !== 0) {
for (let i = 0, l = funcShoppingCart.length; i < l; i++) {
if (funcItem.id === funcShoppingCart[i].id) {
if (funcShoppingCart[i].quantity < funcShoppingCart[i].quantityMax) {
funcShoppingCart[i].quantity = funcShoppingCart[i].quantity + 1
} else {
funcWinToastNothing = true
funcWinToast = false
}
break
}
// 当前添加商品不在购物车里的场景
if (i === funcShoppingCart.length - 1) {
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1
funcShoppingCart.push(funcItem)
}
}
}
} else {
// 库存要大于零才能添加
if (funcItem.quantityMax > 0) {
funcItem.quantity = 1
funcShoppingCart.push(funcItem)
}
}
// 重新计算购物车总数
let funcShoppingCartTotal = 0
......@@ -303,8 +374,11 @@ Page({
shoppingCart: funcShoppingCart,
shoppingCartTotal: funcShoppingCartTotal,
winToast: funcWinToast,
winToastNothing: funcWinToastNothing,
winCommodityDetail: false,
})
console.log(funcShoppingCart)
},
/**
......
......@@ -2,11 +2,13 @@
l-image-class="toast-image"
l-class="toast-bg"
show="{{winToast}}"
mask="{{true}}"
image="/image/success.png"
title="添加购物车成功"
duration="400"
></l-toast>
<l-toast show="{{winToastNothing}}" icon="error" title="没有更多商品了" duration="400"></l-toast>
<l-toast
show="{{winLoading}}"
icon="loading"
......@@ -31,8 +33,8 @@
<view class="menu-list">
<view class="right-content-title">{{menuTitle}}</view>
<block wx:for="{{commodityList}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="commodity-item row">
<view class="item-img" data-item="{{item}}" bindtap="onCommodityDetail">
<view class="commodity-item row" data-item="{{item}}" bind:tap="onCommodityDetail">
<view class="item-img">
<image src="{{item.cover}}" mode="widthFix"></image>
</view>
<view class="item-info">
......@@ -79,7 +81,7 @@
</view>
<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>
</button>
</view>
......@@ -89,9 +91,9 @@
</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-img-wrap">
......
......@@ -13,7 +13,7 @@ page {
.side-bar {
width: 160rpx;
height: 100vh;
margin-top: 140rpx;
padding-top: 126rpx;
overflow-y: scroll;
background: #f2f3f5;
}
......@@ -58,7 +58,7 @@ page {
color: #959da9;
}
.cart-btn {
.cart {
position: fixed;
right: 48rpx;
bottom: 160rpx;
......@@ -188,6 +188,13 @@ page {
height: 24rpx;
}
.item-operation-add-disable button {
width: 44rpx;
height: 44rpx;
border-radius: 50%;
background: #999999;
}
.goods-add-btn-wrap {
flex: 1;
}
......@@ -378,9 +385,10 @@ image {
/* 购物车样式 */
.cart-animation {
position: fixed;
top: 0;
right: 48rpx;
width: 26rpx;
height: 26rpx;
border-radius: 50%;
background: red;
background: #86c5e1;
}
\ No newline at end of file
......@@ -122,7 +122,7 @@ Page({
for (let i = 0, l = funcResponse.length; i < l; i++) {
let funcItem = {
'id': funcResponse[i].id, // 商品标识
'typeId': funcResponse[i].classifyId, // 商品分类标识
'typeId': funcResponse[i].genre, // 商品分类标识
'inventoriesId': funcResponse[i].inventoriesId, // 仓库标识
'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面
......
......@@ -161,7 +161,7 @@ Page({
let funcShoppingCart = this.data.shoppingCart
if (funcShoppingCart[funcIndex].quantityMax <= funcShoppingCart[funcIndex].quantity) return
funcShoppingCart[funcIndex].quantity = funcShoppingCart[funcIndex].quantity + 10
funcShoppingCart[funcIndex].quantity = funcShoppingCart[funcIndex].quantity + 1
this.setData({
shoppingCart: funcShoppingCart
})
......
<l-toast show="{{winToast}}" icon="error" title="{{toastContent}}"></l-toast>
<!-- 购买须知详情 -->
<view class="notice-detail" wx:if="{{winNoticeDetail}}" bindtap="onNoticeClose">
<view class="notice-item" animation="{{animation}}">
......@@ -171,11 +169,13 @@
</view>
<view class="quantity-input row con-b align-c">
<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>
<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">
<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>
</view>
<view class="quantity-other row con-b align-c">
......@@ -190,7 +190,7 @@
</view>
<!-- winContact -->
<view class="contact" wx:if="{{winContact && !winNoticeDetail}}">
<view class="contact" wx:if="{{winContact && !winNoticeDetail && !winStockTip}}">
<view class="contact-title col">
<text>{{contactTitle}}</text>
<text>仅用于接收订单确认短信</text>
......@@ -202,13 +202,13 @@
</view>
<view class="contact-input col">
<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>
</view>
</view>
<!-- winRegister -->
<view class="register" wx:if="{{winRegister && !winNoticeDetail}}">
<view class="register" wx:if="{{winRegister && !winNoticeDetail && !winStockTip}}">
<view class="register-title col">
<text>填写贵宾信息</text>
</view>
......@@ -228,7 +228,7 @@
</view>
<view class="contact-input col">
<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>
</view>
<view class="contact-input col">
......@@ -241,7 +241,7 @@
</view>
<!-- 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-image src="{{imageBase + 'fail-icon-4.png'}}"></cover-image>
<cover-view class="pay-tip-text row con-c align-c">付款后一经确认不得退款</cover-view>
......@@ -256,3 +256,23 @@
<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>
<!-- 库存不足提示 -->
<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 @@
font-size: 26rpx;
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()
let logicData = {
pageScrollLock: false,
pageScrollTimer: 0,
}
Page({
data: {
bannerImg: App.globalData.appResourcesBase + 'play/home/type.png',
......@@ -12,6 +7,10 @@ Page({
navigationLogoTop: 0,
navigationLogoMarginTop: 0,
movieList: [],
recentList: [
{
id: 0,
......@@ -61,7 +60,8 @@ Page({
},
onShow: function () {
this.getActivityList(1)
this.queryActivity()
this.queryMovie()
},
/**
......@@ -82,42 +82,22 @@ Page({
},
/**
* 设置标题高度
* 查询主题活动
* @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
})
},
//主题活动列表 type 1 近期 0 往期
getActivityList(type) {
queryActivity: function () {
var that = this
App.wxRequest({
url: '/api/v1/activity/getList',
data: {
listType: type,
listType: 1,
pageSize: 10,
pageNo: 1,
tagId: '101',
},
success: function (res) {
success: (res) => {
var tmpArr = [];
res.data.list.forEach(item => {
var tmpItem = {
......@@ -131,24 +111,84 @@ Page({
tmpArr.push(tmpItem)
})
// 活动开始时间倒序排序
// 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({
this.setData({
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 () {
wx.navigateTo({
......@@ -195,8 +235,11 @@ Page({
})
},
onAllActivity: function () {
wx.navigateTo({
url: '/pages/play/activity/activity'
})
},
onAllRecent: function () {
wx.navigateTo({
......
......@@ -17,12 +17,12 @@
<view class="title row con-b align-c">
<image src="./image/title-activity.png">近期活动</image>
<text bindtap="onAllRecent">查看全部</text>
<text bindtap="onAllRecent" bindtap="onAllActivity">查看全部</text>
</view>
<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">
<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>
</block>
</swiper>
......@@ -36,13 +36,13 @@
<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-cover">
<image src="{{item.img}}"></image>
<image src="{{item.cover}}"></image>
</view>
<view class="movie-info-wrapper">
<view class="movie-name row">
<text>{{item.name}}</text>
<text>{{item.movieName}}</text>
<view class="movie-dimensional">
<text>{{item.dimensional}}</text>
<text>{{item.movieType}}</text>
</view>
</view>
<view class="movie-info row">
......@@ -50,7 +50,7 @@
<text>类型</text>
</view>
<view class="movie-info-right">
<text>{{item.type}}</text>
<text>{{item.movieType}}</text>
</view>
</view>
<view class="movie-info row">
......@@ -58,7 +58,7 @@
<text>导演</text>
</view>
<view class="movie-info-right">
<text>{{item.director}}</text>
<text>{{item.movieDirector}}</text>
</view>
</view>
<view class="movie-btn">
......
......@@ -190,11 +190,8 @@
}
.movie-info-right {
display: -webkit-box;
margin-left: 8rpx;
color: #656e7b;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
}
......
......@@ -10,6 +10,7 @@ Page({
data: {
imageBase: App.globalData.appImageBase,
option: {},
// 导航栏相关属性
navigationStyle: {
......@@ -69,8 +70,9 @@ Page({
},
onLoad: function (options) {
options.id = 1
logicData.option = options
this.setData({
option: options
})
this.queryDetail(Number(options.id))
},
......@@ -80,12 +82,12 @@ Page({
* @param {string} - funcToken
* @returns
*/
queryDetail: function (funcIndex) {
funcIndex = funcIndex - 1
queryDetail: function (funcAppId) {
let funcIndex = 0
// 预设数据
let funcDetail = [
{
id: 1,
appId: 1,
banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-1-1-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-1-1-2.png',
......@@ -144,7 +146,7 @@ Page({
],
contact: '13316748039'
}, {
id: 2,
appId: 5,
banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-1-2-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-1-2-2.png',
......@@ -158,7 +160,7 @@ Page({
],
contact: '13316748039'
}, {
id: 3,
appId: 7,
banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-2-1-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-2-1-2.png',
......@@ -175,7 +177,7 @@ Page({
],
contact: '13316748039'
}, {
id: 4,
appId: 6,
banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-3-1-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-3-1-2.png',
......@@ -195,7 +197,7 @@ Page({
],
contact: '13316748039'
}, {
id: 5,
appId: 4,
banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-3-2-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-3-2-2.png',
......@@ -209,7 +211,7 @@ Page({
],
contact: '13316748039'
}, {
id: 6,
appId: 2,
banner: [
App.globalData.appResourcesBase + 'shop/banner/banner-4-1-1.png',
App.globalData.appResourcesBase + 'shop/banner/banner-4-1-2.png',
......@@ -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({
banner: funcDetail[funcIndex].banner,
......@@ -252,9 +277,17 @@ Page({
}
},
queryDetailActivity: function () {
},
queryDetailCommodity: function () {
},
onLocation: function () {
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