mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-11-30 10:59:47 +08:00
小程序购物车数量nav
This commit is contained in:
parent
f9d8b5f910
commit
f02261aa37
@ -52,6 +52,7 @@ class Cart extends Common
|
||||
'customer_service_tel' => MyC('common_app_customer_service_tel', null, true),
|
||||
'common_is_exhibition_mode_btn_text'=> MyC('common_is_exhibition_mode_btn_text', '立即咨询', true),
|
||||
'common_site_type' => (int) MyC('common_site_type', 0, true),
|
||||
'common_cart_total' => BuyService::UserCartTotal(['user'=>$this->user]),
|
||||
];
|
||||
|
||||
return $ret;
|
||||
|
@ -14,6 +14,7 @@ use app\service\GoodsService;
|
||||
use app\service\BannerService;
|
||||
use app\service\AppHomeNavService;
|
||||
use app\service\PluginsService;
|
||||
use app\service\BuyService;
|
||||
|
||||
/**
|
||||
* 首页
|
||||
@ -57,6 +58,7 @@ class Index extends Common
|
||||
'common_app_is_header_nav_fixed' => (int) MyC('common_app_is_header_nav_fixed', 0),
|
||||
'common_app_is_online_service' => (int) MyC('common_app_is_online_service', 0),
|
||||
'common_app_is_limitedtimediscount' => (int) MyC('common_app_is_limitedtimediscount'),
|
||||
'common_cart_total' => BuyService::UserCartTotal(['user'=>$this->user]),
|
||||
];
|
||||
|
||||
// 支付宝小程序在线客服
|
||||
|
@ -15,6 +15,7 @@ use app\service\OrderService;
|
||||
use app\service\GoodsService;
|
||||
use app\service\MessageService;
|
||||
use app\service\AppCenterNavService;
|
||||
use app\service\BuyService;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
@ -504,7 +505,6 @@ class User extends Common
|
||||
// 未读消息总数
|
||||
$params = ['user'=>$this->user, 'is_more'=>1, 'is_read'=>0];
|
||||
$common_message_total = MessageService::UserMessageTotal($params);
|
||||
$common_message_total = ($common_message_total > 99) ? '99+' : $common_message_total;
|
||||
|
||||
// 用户订单状态
|
||||
$user_order_status = OrderService::OrderStatusStepTotal(['user_type'=>'user', 'user'=>$this->user, 'is_comments'=>1, 'is_aftersale'=>1]);
|
||||
@ -525,6 +525,7 @@ class User extends Common
|
||||
'navigation' => AppCenterNavService::AppCenterNav(),
|
||||
'common_app_is_online_service' => (int) MyC('common_app_is_online_service', 0),
|
||||
'common_app_is_head_vice_nav' => (int) MyC('common_app_is_head_vice_nav', 0),
|
||||
'common_cart_total' => BuyService::UserCartTotal(['user'=>$this->user]),
|
||||
);
|
||||
|
||||
// 支付宝小程序在线客服
|
||||
|
@ -97,7 +97,7 @@ class User extends Common
|
||||
// 未读消息总数
|
||||
$params = ['user'=>$this->user, 'is_more'=>1, 'is_read'=>0, 'user_type'=>'user'];
|
||||
$common_message_total = MessageService::UserMessageTotal($params);
|
||||
$this->assign('common_message_total', ($common_message_total > 99) ? '99+' : $common_message_total);
|
||||
$this->assign('common_message_total', $common_message_total);
|
||||
|
||||
// 获取进行中的订单列表
|
||||
$params = array_merge($_POST, $_GET);
|
||||
|
@ -1281,6 +1281,7 @@ class BuyService
|
||||
* @date 2018-09-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
* @return [int|string] [超过99则返回 99+]
|
||||
*/
|
||||
public static function UserCartTotal($params = [])
|
||||
{
|
||||
@ -1297,7 +1298,10 @@ class BuyService
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return self::CartTotal(['user_id'=>$params['user']['id']]);
|
||||
|
||||
// 获取购物车总数
|
||||
$total = self::CartTotal(['user_id'=>$params['user']['id']]);
|
||||
return ($total > 99) ? '99+' : $total;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,6 +137,7 @@ class MessageService
|
||||
* @date 2018-09-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
* @return [int|string] [超过99则返回 99+]
|
||||
*/
|
||||
public static function UserMessageTotal($params = [])
|
||||
{
|
||||
@ -153,7 +154,8 @@ class MessageService
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return self::MessageTotal(self::MessageListWhere($params));
|
||||
$total = self::MessageTotal(self::MessageListWhere($params));
|
||||
return ($total > 99) ? '99+' : $total;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -496,12 +496,11 @@ class NavigationService
|
||||
{
|
||||
// 购物车商品总数
|
||||
$common_cart_total = BuyService::UserCartTotal(['user'=>$params['user']]);
|
||||
$common_cart_total = ($common_cart_total > 99) ? '99+' : $common_cart_total;
|
||||
|
||||
// 未读消息总数
|
||||
$message_params = ['user'=>$params['user'], 'is_more'=>1, 'is_read'=>0, 'user_type'=>'user'];
|
||||
$common_message_total = MessageService::UserMessageTotal($message_params);
|
||||
$common_message_total = ($common_message_total > 99) ? '99+' : (($common_message_total <= 0) ? -1 : $common_message_total);
|
||||
$common_message_total = ($common_message_total <= 0) ? -1 : $common_message_total;
|
||||
}
|
||||
|
||||
// 列表
|
||||
@ -846,7 +845,6 @@ class NavigationService
|
||||
{
|
||||
// 购物车商品总数
|
||||
$common_cart_total = BuyService::UserCartTotal(['user'=>$params['user']]);
|
||||
$common_cart_total = ($common_cart_total > 99) ? '99+' : $common_cart_total;
|
||||
}
|
||||
|
||||
// 列表
|
||||
|
@ -67,8 +67,8 @@ App({
|
||||
|
||||
// 请求地址
|
||||
request_url: "{{request_url}}",
|
||||
// request_url: 'http://tp5-dev.com/',
|
||||
// request_url: 'http://dev.shopxo.net/',
|
||||
request_url: 'http://shopxo.com/',
|
||||
request_url: 'http://dev.shopxo.net/',
|
||||
|
||||
// 基础信息
|
||||
application_title: "{{application_title}}",
|
||||
@ -683,4 +683,18 @@ App({
|
||||
return (user == false) ? null : user.alipay_openid || null;
|
||||
},
|
||||
|
||||
// 窗口背景色设置
|
||||
set_nav_bg_color_main() {
|
||||
// 窗口和下拉顶部背景色
|
||||
my.setBackgroundColor({
|
||||
backgroundColor: '#d2364c',
|
||||
backgroundColorTop: '#d2364c',
|
||||
});
|
||||
|
||||
// 下拉文字颜色
|
||||
my.setBackgroundTextStyle({
|
||||
textStyle: 'light',
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
@ -31,7 +31,7 @@
|
||||
"pages/extraction-address/extraction-address"
|
||||
],
|
||||
"window": {
|
||||
"defaultTitle": "{{application_title}}",
|
||||
"defaultTitle": "shopxo",
|
||||
"titleBarColor": "#d2364c"
|
||||
},
|
||||
"tabBar": {
|
||||
|
@ -27,6 +27,7 @@ Page({
|
||||
},
|
||||
|
||||
onShow() {
|
||||
app.set_nav_bg_color_main();
|
||||
this.init();
|
||||
},
|
||||
|
||||
|
@ -35,6 +35,7 @@ Page({
|
||||
|
||||
onShow() {
|
||||
my.setNavigationBar({title: app.data.common_pages_title.user});
|
||||
app.set_nav_bg_color_main();
|
||||
this.init();
|
||||
},
|
||||
|
||||
|
@ -619,4 +619,38 @@ App({
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置导航reddot
|
||||
* index tabBar 的哪一项,从左边算起(0开始)
|
||||
* type 0 移出, 1 添加 (默认 0 移出)
|
||||
*/
|
||||
set_tab_bar_reddot(index, type) {
|
||||
if (index !== undefined && index !== null)
|
||||
{
|
||||
if ((type || 0) == 0)
|
||||
{
|
||||
wx.hideTabBarRedDot({ index: Number(index) });
|
||||
} else {
|
||||
wx.showTabBarRedDot({ index: Number(index) });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置导航车badge
|
||||
* index tabBar 的哪一项,从左边算起(0开始)
|
||||
* type 0 移出, 1 添加 (默认 0 移出)
|
||||
* value 显示的文本,超过 4 个字符则显示成 ...(type参数为1的情况下有效)
|
||||
*/
|
||||
set_tab_bar_badge(index, type, value) {
|
||||
if (index !== undefined && index !== null)
|
||||
{
|
||||
if ((type || 0) == 0) {
|
||||
wx.removeTabBarBadge({ index: Number(index) });
|
||||
} else {
|
||||
wx.setTabBarBadge({ "index": Number(index), "text": value.toString() });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages": ["pages/index/index",
|
||||
"pages/user-membervip/user-membervip",
|
||||
"pages/index/index",
|
||||
|
||||
"pages/goods-category/goods-category",
|
||||
"pages/cart/cart",
|
||||
"pages/user/user",
|
||||
|
@ -89,6 +89,14 @@ Page({
|
||||
common_is_exhibition_mode_btn_text: data.common_is_exhibition_mode_btn_text || '立即咨询',
|
||||
customer_service_tel: data.customer_service_tel || null,
|
||||
});
|
||||
|
||||
// 导航购物车处理
|
||||
var cart_total = data.common_cart_total || 0;
|
||||
if (cart_total <= 0) {
|
||||
app.set_tab_bar_badge(2, 0);
|
||||
} else {
|
||||
app.set_tab_bar_badge(2, 1, cart_total);
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 2,
|
||||
@ -261,6 +269,14 @@ Page({
|
||||
data_list_loding_status: temp_data_list.length == 0 ? 0 : this.data.data_list_loding_status,
|
||||
});
|
||||
|
||||
// 导航购物车处理
|
||||
var cart_total = res.data.data || 0;
|
||||
if (cart_total <= 0) {
|
||||
app.set_tab_bar_badge(2, 0);
|
||||
} else {
|
||||
app.set_tab_bar_badge(2, 1, cart_total);
|
||||
}
|
||||
|
||||
app.showToast(((type == 'delete') ? '删除成功' : '收藏成功'), 'success');
|
||||
} else {
|
||||
if (app.is_login_check(res.data)) {
|
||||
|
@ -61,6 +61,15 @@ Page({
|
||||
plugins_limitedtimediscount_data: data.plugins_limitedtimediscount_data || null,
|
||||
});
|
||||
|
||||
// 导航购物车处理
|
||||
var cart_total = data.common_cart_total || 0;
|
||||
if (cart_total <= 0)
|
||||
{
|
||||
app.set_tab_bar_badge(2, 0);
|
||||
} else {
|
||||
app.set_tab_bar_badge(2, 1, cart_total);
|
||||
}
|
||||
|
||||
// 限时秒杀倒计时
|
||||
if (this.data.common_app_is_limitedtimediscount == 1 && this.data.plugins_limitedtimediscount_data != null)
|
||||
{
|
||||
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"enablePullDownRefresh": true,
|
||||
"navigationBarBackgroundColor": "#d2364c",
|
||||
"backgroundColor": "#d2364c",
|
||||
"usingComponents": {
|
||||
"component-icon-nav": "/components/icon-nav/icon-nav",
|
||||
"component-banner": "/components/slider/slider"
|
||||
|
@ -12,13 +12,19 @@ Page({
|
||||
nav_list: [
|
||||
{
|
||||
icon: "/images/share-weixin-icon.png",
|
||||
cs: "br-t br-b br-r",
|
||||
title: "开通订单",
|
||||
},
|
||||
{
|
||||
icon: "/images/share-weixin-icon.png",
|
||||
title: "推广返利",
|
||||
},
|
||||
{
|
||||
icon: "/images/share-weixin-icon.png",
|
||||
cs: "br-t br-b",
|
||||
title: "收益明细",
|
||||
},
|
||||
{
|
||||
icon: "/images/share-weixin-icon.png",
|
||||
title: "数据统计",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -41,11 +41,32 @@
|
||||
</view>
|
||||
|
||||
<!-- 导航 -->
|
||||
<view class="nav">
|
||||
<view class="nav spacing-mt oh bg-white">
|
||||
<block wx:for="{{nav_list}}" wx:key="key">
|
||||
<view class="item fl tc {{item.cs}}">
|
||||
<view class="item fl tc">
|
||||
<image src="{{item.icon}}" mode="scaleToFill" class="dis-block" />
|
||||
<view class="title">{{item.title}}</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 通知 -->
|
||||
<view class="tips-container spacing-mb">
|
||||
<!-- 未开通会员介绍 -->
|
||||
<view wx:if="{{(user_vip || null) == null && (data_base.not_opening_vip_desc || null) != null && data_base.not_opening_vip_desc.length > 0}}" class="tips-item spacing-mt">
|
||||
<view class="not-opening-vip-desc">
|
||||
<view wx:for="{{data_base.not_opening_vip_desc}}" wx:key="key" class="item">
|
||||
{{item}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 会员中心通知 -->
|
||||
<view wx:if="{{(data_base.user_vip_center_notice || null) != null && data_base.user_vip_center_notice.length > 0}}" class="tips-item spacing-mt">
|
||||
<view class="tips">
|
||||
<view wx:for="{{data_base.user_vip_center_notice}}" wx:key="key" class="item">
|
||||
{{item}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
@ -66,11 +66,15 @@
|
||||
* 导航
|
||||
*/
|
||||
.nav {
|
||||
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
.nav .item {
|
||||
padding: 20rpx;
|
||||
width: calc(50% - 30px);
|
||||
padding: 30rpx 0;
|
||||
width: calc(50% - 1px);
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.nav .item:nth-child(odd) {
|
||||
border-right: 1px solid #eee;
|
||||
}
|
||||
.nav .item image {
|
||||
width: 100rpx;
|
||||
@ -79,4 +83,22 @@
|
||||
}
|
||||
.nav .item .title {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
/*
|
||||
* 提示信息
|
||||
*/
|
||||
.tips-container .tips-item {
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
.tips-container .tips-item .tips .item {
|
||||
line-height: 38rpx;
|
||||
}
|
||||
.tips-container .not-opening-vip-desc {
|
||||
background: #def2fd;
|
||||
border: 1px solid #cfeeff;
|
||||
color: #1490d2;
|
||||
padding: 10rpx;
|
||||
font-size: 26rpx;
|
||||
border-radius: 2px;
|
||||
}
|
@ -107,6 +107,14 @@ Page({
|
||||
common_app_is_online_service: data.common_app_is_online_service || 0,
|
||||
common_app_is_head_vice_nav: data.common_app_is_head_vice_nav || 0,
|
||||
});
|
||||
|
||||
// 导航购物车处理
|
||||
var cart_total = data.common_cart_total || 0;
|
||||
if (cart_total <= 0) {
|
||||
app.set_tab_bar_badge(2, 0);
|
||||
} else {
|
||||
app.set_tab_bar_badge(2, 1, cart_total);
|
||||
}
|
||||
} else {
|
||||
if(app.is_login_check(res.data, this, 'get_data'))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user