Commit 4bb50609 by 严立

LL - 服务首页

parent 538f3685
const App = getApp()
Page({
data: {
imageBase: App.globalData.appImageBase,
resourcesBase: App.globalData.appResourcesBase,
option: {},
userInfo: {},
greetingName: '', // 问候姓名
greetingMessage: '', // 问候消息
phone: '13316748039',
hotline: false, //客服热线
......@@ -17,9 +21,12 @@ Page({
onLoad: function (option) {
this.setData({
option: option
option: option,
userInfo: wx.getStorageSync('userInfo')
})
this.setGreetingMessage()
// formPage=order&shopAppId=1&commodityType=5
},
......@@ -28,6 +35,54 @@ Page({
},
/**
* 问候消息
* @function
* @param {object} - funcEvent
* @returns
*/
setGreetingMessage: function () {
let funcHour = Number(App.modular.miment().format('hh'))
let funcMinute = Number(App.modular.miment().format('mm'))
let funcTime = [{
'min': 0,
'max': 12,
'message': '上午好!'
}, {
'min': 12,
'max': 18,
'message': '下午好!'
}, {
'min': 18,
'max': 24,
'message': '晚上好!'
}]
let funcIndex = 0
for (let i = 0, l = funcTime.length; i < l; i ++) {
// 判断小时区间
if (funcTime[i].min < funcHour && funcHour <= funcTime[i].max) {
// 如果小时区间等于该区间最大数值,那么分钟不为零时递增一个区间
if (funcHour === funcTime[i].max && 0 < funcMinute) {
funcIndex = i + 1
} else {
funcIndex = i
}
break
}
}
let funcGreetingName = this.data.userInfo.name
if (funcGreetingName.length > 5) funcGreetingName = funcGreetingName.substring(0, 5) + '...'
if (funcGreetingName === '') funcGreetingName = 'Hello,'
this.setData({
greetingName: funcGreetingName,
greetingMessage: funcTime[funcIndex].message
})
},
/**
* 查询推荐商品
* @function
* @param {object} - funcEvent
......@@ -190,6 +245,7 @@ Page({
'logo': funcShopId[i].logo,
'cover': funcShopId[i].cover,
'shopType': funcShopType,
'commodityLogo': funcShopId[i].commodityLogo
}
wx.setStorageSync('shopInfoBuffer', funcShopInfo)
break
......
<navigation class="navigation"></navigation>
<view class="container">
<view class="title">
<image src="{{resourcesBase + 'commodity/home/title.png'}}" class="title_img"></image>
<!-- 问候订制 -->
<view class="greeting">
<text>{{greetingName + greetingMessage}}</text>
</view>
<!-- 商店 -->
......
......@@ -11,12 +11,6 @@
text-align: left;
}
.title_img {
width: 214rpx;
height: 50rpx;
margin-top: 128rpx;
}
.greetings_body {
width: 750rpx;
height: height;
......@@ -182,14 +176,17 @@
font-weight: 500;
}
.title {
.greeting {
width: 750rpx;
height: 280rpx;
padding: 140rpx 46rpx 130rpx 46rpx;
}
.title image {
width: 750rpx;
height: 80rpx;
.greeting text {
height: 82rpx;
font-size: 58rpx;
font-weight: 500;
line-height: 82rpx;
color: #15191F;
}
/* 商店样式 */
......
......@@ -38,16 +38,18 @@ Page({
option: option
})
console.log(this.data.option)
this.setSideBarStyle()
},
onShow: function () {
this.resetShoppingCart()
this.setCartAnimation()
this.setShopInfo()
this.querySideBar()
},
onShow: function () {
if (wx.getStorageSync('shoppingCartBuffer').length === 0) {
this.resetShoppingCart()
} else {
......@@ -346,8 +348,6 @@ Page({
funcItem = this.data.commodityDetail
}
console.log(funcItem)
// 判断购物车中是否存在同类商品
// 修改相应的商品数量
if (funcShoppingCart.length !== 0) {
......
......@@ -94,6 +94,7 @@ Page({
'priceType': 1,
'describe': funcResponse[i].synopsis,
'tags': funcResponse[i].tags,
'notificationId': funcResponse[i].notificationId, // 下单须知
}
let funcUserType = wx.getStorageSync('userInfo').userType
......@@ -135,6 +136,7 @@ Page({
'priceType': 1,
'describe': funcResponse[i].synopsis,
'tags': funcResponse[i].tags,
'notificationId': funcResponse[i].notificationId, // 下单须知
}
let funcUserType = wx.getStorageSync('userInfo').userType
......
......@@ -2,92 +2,59 @@ let App = getApp()
Page({
data: {
shopInfo: {},
commodityTypeId: '',
commodityList: [],
imageBase: App.globalData.appImageBase,
resourcesBase: App.globalData.appResourcesBase,
winLoading: false,
projectType: 1, // 1 儿童营地,2 - SPA,3 - 文创, 5 - 餐品, 6 - 活动, 7 - 观影
banner: [],
bannerIndex: 0,
banner: [
{
id: 0,
img: ''
},
{
id: 1,
img: ''
},
shopAppId: [
{
id: 2,
img: ''
'appId': 1,
'commodityType': 3,
}, {
'appId': 7,
'commodityType': 2,
}, {
'appId': 3,
'commodityType': 1,
}
],
projectAll: {
projectArt: {
projectType: 3,
btn: '购买门票',
titleImg: '',
list: []
},
projectSpa: {
projectType: 2,
btn: '查看服务',
list: []
},
projectChild: {
projectType: 1,
btn: '购买门票',
list: []
}
}
},
onLoad: function (options) {
this.setData({
shopInfo: wx.getStorageSync('shopInfoBuffer')
})
this.queryCommodityTab()
shopCommodityData: [],
},
queryCommodityTab: function () {
App.wxRequest({
url: '/api/v1/commodity/getClassifys',
data: {
'officeId': this.data.shopInfo.id,
'genre': this.data.shopInfo.shopType,
},
success: (response) => {
let funcResponse = response.data
this.setData({
commodityTypeId: funcResponse[0].id
})
this.queryCommodity()
onLoad: function (options) {
for (let i = 0, l = this.data.shopAppId.length; i < l; i++) {
this.queryPassCheck(this.data.shopAppId[i].appId, this.data.shopAppId[i].commodityType, i)
}
})
},
queryCommodity: function () {
this.setData({
shopInfo: wx.getStorageSync('shopInfoBuffer')
})
queryPassCheck: function (funcShopAppId, funcCommodityType, funcIndex) {
let funcShopId = ''
for (let i = 0, l = App.globalData.shopId.length; i < l; i++) {
if (funcShopAppId === App.globalData.shopId[i].appId) {
funcShopId = App.globalData.shopId[i].id
break
}
}
App.wxRequest({
url: '/api/v1/commodity/getCommoditys',
data: {
'officeId': this.data.shopInfo.id,
'classifyId': this.data.commodityTypeId,
'genre': this.data.shopInfo.shopType,
'officeId': funcShopId,
'genre': funcCommodityType,
},
success: (response) => {
let funcCommodityList = []
let funcResponse = response.data
switch (funcCommodityType) {
// 年卡月卡
case 1:
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].inventorie[0].inventoriesId, // 仓库标识
'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面
......@@ -97,9 +64,10 @@ Page({
'priceSpecialText': App.modular.utils.formatAmount(funcResponse[i].inventorie[0].ownerPrice), // 业主价文本格式
'priceDiscount': funcResponse[i].inventorie[0].price, // 活动价
'priceDiscountText': App.modular.utils.formatAmount(funcResponse[i].inventorie[0].price), // 活动价文本格式
'priceType': '',
'priceType': 1,
'describe': funcResponse[i].synopsis,
'tags': funcResponse[i].tags,
'notificationId': funcResponse[i].notificationId, // 下单须知
}
let funcUserType = wx.getStorageSync('userInfo').userType
......@@ -115,24 +83,73 @@ Page({
funcItem.priceType = 3
}
}
funcCommodityList.push(funcItem)
}
break
// 普通商品
case 2:
// 门票商品
case 3:
default:
for (let i = 0, l = funcResponse.length; i < l; i++) {
let funcItem = {
'id': funcResponse[i].id, // 商品标识
'typeId': funcResponse[i].genre, // 商品分类标识
'inventoriesId': funcResponse[i].inventoriesId, // 仓库标识
'name': funcResponse[i].name,
'cover': funcResponse[i].coverImg, // 商品封面
'price': funcResponse[i].sightseerPrice, // 普通价
'priceText': App.modular.utils.formatAmount(funcResponse[i].sightseerPrice), // 普通价文本格式
'priceSpecial': funcResponse[i].ownerPrice, // 业主价
'priceSpecialText': App.modular.utils.formatAmount(funcResponse[i].ownerPrice), // 业主价文本格式
'priceDiscount': funcResponse[i].price, // 活动价
'priceDiscountText': App.modular.utils.formatAmount(funcResponse[i].price), // 活动价文本格式
'priceType': 1,
'describe': funcResponse[i].synopsis,
'tags': funcResponse[i].tags,
'notificationId': funcResponse[i].notificationId, // 下单须知
}
let funcUserType = wx.getStorageSync('userInfo').userType
// 根据后台判断价格显示类型
// 活动价优先级最高,如果存在活动价,则只显示活动价和普通价
if (funcItem.priceDiscount) {
funcItem.priceType = 1
} else {
// 活动价不存在,进一步判断普通价与业主价是否一致,如果不一致,则显示两者
if (funcItem.price !== funcItem.priceSpecial && funcUserType) {
funcItem.priceType = 2
} else {
funcItem.priceType = 3
}
}
funcCommodityList.push(funcItem)
}
break
}
let funcShopCommodityData = this.data.shopCommodityData
funcShopCommodityData[funcIndex] = funcCommodityList
this.setData({
winLoading: false,
commodityList: funcCommodityList,
shopCommodityData: funcShopCommodityData,
})
},
})
},
onBuy: function () {
console.log(JSON.stringify(this.data.shopCommodityData) )
},
/**
* banner 切换图片同步自定义标识组件
* @function
* @param {object} - funcEvent
* @returns
*/
onSwiperChange: function (funcEvent) {
eventSwiperChange: function (funcEvent) {
this.setData({
bannerIndex: funcEvent.detail.current
})
......
......@@ -26,110 +26,132 @@
left: 0;
}
.project-wrapper {
/* 门店样式 */
.shop-list {
background: #F3F4F6;
}
.shop-item {
width: 670rpx;
margin-top: 48rpx;
padding: 36rpx 32rpx 14rpx;
background-color: #fff;
margin: 48rpx 40rpx 0 40rpx;
padding: 32rpx;
border-radius: 4px;
background: #FFFFFF;
}
.project-title {
height: 88rpx;
background-color: #ccc;
.shop-name {
width: 606rpx;
height: 70rpx;
}
.project-item {
margin-top: 48rpx;
padding-bottom: 50rpx;
border-bottom: 1px solid #E2E7EF;
.shop-name image {
margin-right: 20rpx;
}
/* 商品信息样式 */
.commodity-item {
height: 214rpx;
margin-top: 50rpx;
border-bottom: 1px #E2E7EF solid;
}
.project-item:last-child {
.commodity-item:last-child {
border-bottom: none;
}
.project-cover {
.commodity-cover image {
width: 128rpx;
height: 128rpx;
background-color: #ccc;
margin-right: 24rpx;
background: #999999;
}
.project-content {
margin-left: 24rpx;
flex: 1;
.commodity-describe {
position: relative;
flex-grow: 1;
}
.project-info {
}
.project-name {
height: 46rpx;
color: #15191F;
.commodity-describe text:nth-child(1) {
height: 42rpx;
font-size: 30rpx;
font-weight: 600;
font-weight: 500;
line-height: 42rpx;
color: #15191F;
overflow: hidden;
text-overflow: ellipsis;
}
.project-msg text {
margin-top: 8rpx;
color: #959DA9;
.commodity-describe text:nth-child(2) {
position: absolute;
top: 54rpx;
left: 0;
max-width: 320rpx;
max-height: 120rpx;
border: 1px red solid;
background: #FFFFFF;
overflow: hidden;
font-size: 22rpx;
}
.project-price-wrapper {
flex: 1;
height: 100%;
width: 100%;
}
.project-price-special {
}
.price-wrap {
color: #EF4E4E;
letter-spacing: 2rpx;
display: table-cell;
vertical-align: bottom;
font-weight: 400;
line-height: 40rpx;
word-wrap: break-word;
color: #959DA9;
}
.price-symbol {
.commodity-price-symbol {
height: 32rpx;
font-size: 24rpx;
font-weight: 500;
line-height: 32rpx;
color: #EF4E4E;
}
.price-special {
font-size: 34rpx;
.commodity-price-value {
height: 32rpx;
font-size: 32rpx;
font-weight: 500;
line-height: 32rpx;
color: #EF4E4E;
}
.price-special-msg {
.commodity-price-special {
display: inline-block;
width: 78rpx;
height: 32rpx;
color: #E8D0AF;
font-size: 18rpx;
margin: 0 0 0 8rpx;
border-radius: 4px;
background: linear-gradient(180deg, #3F4357 0%, #252532 100%);
text-align: center;
font-size: 18rpx;
font-weight: 500;
line-height: 32rpx;
background: linear-gradient(180deg, #3F4357 0%, #252532 100%);
border-radius: 4rpx;
color: #E8D0AF;
}
.commodity-price-through {
margin-top: 12rpx;
}
.project-price-old {
.commodity-price-through text {
height: 32rpx;
color: #959DA9;
font-size: 22rpx;
font-weight: 400;
line-height: 32rpx;
text-decoration: line-through;
color: #959DA9;
}
.price-old {
font-size: 22rpx;
}
.price-symbol-old {
font-size: 20rpx;
}
.project-buy-wrapper {
flex: 1;
}
.project-buy-btn {
.commodity-price-operation button {
width: 120rpx;
height: 56rpx;
margin-top: 24rpx;
color: #fff;
font-size: 22rpx;
line-height: 56rpx;
text-align: center;
background-color: #86C5E1;
border-radius: 4rpx;
}
border-radius: 4px;
background: #86C5E1;
image {
width: 100%;
height: 100%;
font-size: 22rpx;
font-weight: 500;
line-height: 32rpx;
color: #FFFFFF;
}
\ No newline at end of file
......@@ -7,7 +7,6 @@ Page({
shopId: '',
shopName: '',
shopLogo: '',
shoppingCart: [], // 购物车列表
shoppingCartSelection: 0, // 购物车选择数量
......@@ -101,8 +100,7 @@ Page({
let funcShopInfo = wx.getStorageSync('shopInfoBuffer')
this.setData({
shopId: funcShopInfo.id,
shopName: funcShopInfo.name,
shopLogo: funcShopInfo.logo
shopLogo: funcShopInfo.commodityLogo
})
console.log(this.data.shopLogo)
......@@ -161,7 +159,7 @@ Page({
let funcShoppingCart = this.data.shoppingCart
if (funcShoppingCart[funcIndex].quantityMax <= funcShoppingCart[funcIndex].quantity) return
funcShoppingCart[funcIndex].quantity = funcShoppingCart[funcIndex].quantity + 1
funcShoppingCart[funcIndex].quantity = funcShoppingCart[funcIndex].quantity + 100
this.setData({
shoppingCart: funcShoppingCart
})
......
......@@ -3,9 +3,8 @@
<l-toast show="{{winToast}}" icon="error" title="请选购商品后结算"></l-toast>
<view class="container" wx:if="{{shoppingCart.length > 0}}">
<view class="shop-info row align-c">
<image wx:if="{{shopLogo}}" src="{{resourcesBase + shopLogo}}" mode="left"></image>
<text>{{shopName}}</text>
<view class="shop-info row con-b align-c">
<image wx:if="{{shopLogo}}" src="{{resourcesBase + shopLogo}}" mode="widthFix"></image>
<text bindtap="onClearn">清空</text>
</view>
......
......@@ -12,33 +12,23 @@
.shop-info {
width: 750rpx;
height: 116rpx;
padding: 16rpx 40rpx;
height: 110rpx;
padding: 0 30rpx 0 40rpx;
font-size: 30rpx;
}
.shop-info > image {
max-width: 120rpx;
height: 100%;
width: 380rpx;
height: 110rpx;
}
.shop-info > text:nth-child(2) {
flex-grow: 1;
.shop-info > text {
height: 42rpx;
font-size: 30rpx;
font-weight: 500;
line-height: 42rpx;
color: #586A46;
}
.shop-info > text:nth-child(3) {
flex-grow: 1;
height: 100rpx;
text-align: right;
line-height: 100rpx;
color: #656e7b;
}
.l-content {
color: #959da9 !important;
}
......@@ -134,6 +124,8 @@
font-weight: 400;
line-height: 32rpx;
color: #959DA9;
text-decoration: line-through;
}
.list-item-quantity {
......
......@@ -15,13 +15,15 @@ Page({
address: '',
},
onLoad: function (options) {
let funcUserInfo = wx.getStorageSync('userInfo')
let mobile = wx.getStorageSync('mobile')
let nickName = wx.getStorageSync('nickName')
let avatarUrl = wx.getStorageSync('avatarUrl')
let sex = wx.getStorageSync('sex')
let birthday = wx.getStorageSync('birthday')
let address = wx.getStorageSync('address')
let mobile = funcUserInfo.phone
let nickName = funcUserInfo.name
let avatarUrl = funcUserInfo.avatar
let sex = funcUserInfo.sex
let birthday = funcUserInfo.birthday
let address = birthday.address
this.setData({
mobile: this.toHide(mobile),
nickName: nickName,
......
......@@ -4,6 +4,9 @@ Page({
data: {
imageBase: App.globalData.appImageBase,
resourcesBase: App.globalData.appResourcesBase,
option: {},
orderTypeTitle: '全部分类',
orderTypeHeight: 0,
orderType: [],
......@@ -34,6 +37,7 @@ Page({
isFinished: false
},
onLoad: function (options) {
this.setData({ option: options })
this.setOrderType()
},
......@@ -219,9 +223,15 @@ Page({
},
onNavigationBack: function () {
if (this.data.option.fromPage) {
wx.switchTab({
url: '/pages/mine/home/home',
})
} else {
wx.navigateBack({
'delta': 1
})
}
},
/**
......@@ -451,14 +461,12 @@ Page({
* @returns
*/
onOrderAgain: function (event) {
let item = event.currentTarget.dataset.item
let commodityType = item.goodType
let shopAppId = wx.getStorageSync('shopInfoBuffer') ? wx.getStorageSync('shopInfoBuffer').appId : ""
wx.navigateTo({
url: `/pages/commodity/menu-food/menu-food?formPage=order&shopAppId=${shopAppId}&commodityType=${commodityType}`,
})
},
/**
......@@ -468,7 +476,6 @@ Page({
* @returns
*/
onReachBottom: function () {
this.setData({
orderPages: this.data.orderPages + 1
})
......
......@@ -308,6 +308,7 @@ Page({
setShoppingCartData: function () {
// 读取上级页面的购物车数据,默认选中所有。
let funcShoppingCart = wx.getStorageSync('shoppingCartBuffer')
console.log(JSON.stringify(funcShoppingCart))
// 设置商品的最终提交价格
let funcPayAmount = 0
......@@ -378,9 +379,6 @@ Page({
* @returns
*/
setStock: function () {
console.log('funcCommodity')
console.log(this.data.shoppingCartList)
let funcItem = this.data.shoppingCartList[0]
App.wxRequest({
......@@ -453,6 +451,8 @@ Page({
clearTimeout(funcTimer)
}, 100)
console.log(this.data.shoppingCartList)
App.wxRequest({
url: '/api/v1/commodity/getNotification',
data: {
......@@ -592,12 +592,14 @@ Page({
// 定位到当前问题位置
if (funcErrorIndex !== null) {
const funcQuery = wx.createSelectorQuery()
funcQuery.selectAll('.register-item-title').boundingClientRect()
funcQuery.selectAll('.contact-input-mark').boundingClientRect()
funcQuery.exec((response) => {
console.log(response)
let funcScrollTop = response[0][funcErrorIndex].top
if (funcScrollTop !== 0) {
wx.pageScrollTo({
scrollTop: response[0][funcErrorIndex].top
})
}
})
}
return funcPass
......@@ -663,7 +665,30 @@ Page({
'smPersonalDetails': funcUserInfo
},
success: (response) => {
console.log(response)
if (/价格不一致/.test(response.data.msg)) {
wx.lin.showToast({
title: '价格已变更,请重新下单。',
icon: 'error',
success: () => {
wx.navigateBack({
delta: 2
})
}
})
return
}
if (/订单未支付/.test(response.data.msg)) {
wx.lin.showToast({
title: response.data.msg,
icon: 'error',
})
this.setData({
isPaySubmit: false,
})
return
}
if (/库存不足/.test(response.data.msg)) {
let funcList = []
for (let i = 0, l = response.data.data.list.length; i < l; i++) {
......@@ -763,7 +788,7 @@ Page({
} else {
// 取消支付直接进入订单
wx.reLaunch({
url: '/pages/pay/order/order'
url: '/pages/mine/order/order?fromPage=pay'
})
}
},
......
<!-- 购买须知详情 -->
<view class="notice-detail" wx:if="{{winNoticeDetail}}" bindtap="onNoticeClose">
<view class="notice-item" animation="{{animation}}">
<view class="notice-title">
<text>{{noticeText}}</text>
</view>
<view class="notice-rich">
<rich-text nodes="{{noticeDetail}}"></rich-text>
</view>
</view>
</view>
<l-toast></l-toast>
<view class="container">
<!-- winBuyContent -->
......@@ -201,7 +191,7 @@
<text>仅用于接收订单确认短信</text>
</view>
<view class="contact-input col">
<text>姓名</text>
<text class="contact-input-mark">姓名</text>
<input placeholder="请输入姓名" data-type="name" data-index="{{0}}" bindblur="onInputBlur"></input>
<text>{{registerInfo[0].errorName}}</text>
</view>
......@@ -227,7 +217,7 @@
<text>{{registerTitle + (index + 1)}}</text>
</view>
<view class="contact-input col">
<text>姓名</text>
<text class="contact-input-mark">姓名</text>
<input placeholder="请输入姓名" data-type="name" data-index="{{index}}" bindblur="onInputBlur"></input>
<text>{{item.errorName}}</text>
</view>
......@@ -262,6 +252,21 @@
<cover-view class="appointment-confirm row con-c align-c">确认预约</cover-view>
</cover-view>
<!-- 购买须知详情 -->
<view class="notice-detail" wx:if="{{winNoticeDetail}}" bindtap="onNoticeClose">
<view class="notice-item" animation="{{animation}}">
<view class="notice-title">
<text>{{noticeText}}</text>
</view>
<view class="notice-rich">
<rich-text nodes="{{noticeDetail}}"></rich-text>
</view>
</view>
</view>
<!-- 未支付订单超额提示 -->
<!-- 库存不足提示 -->
<view class="stock-mask row con-c align-c" wx:if="{{winStockTip}}">
<view class="stock col con-c align-c">
......
......@@ -915,6 +915,8 @@
.stock-info {
width: 526rpx;
max-height: 480rpx;
overflow-y: scroll;
}
.stock-close {
......
......@@ -26,7 +26,6 @@ let output = {
*/
formatAmount: function (funcAmountValue) {
if (!funcAmountValue && funcAmountValue !== 0) return
console.log(funcAmountValue, funcAmountValue.toString().length)
switch (funcAmountValue.toString().length) {
case 1:
funcAmountValue = '00' + funcAmountValue
......
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