From f02261aa3739f92ee7b1f9ae1cbdaeb178f88f7e Mon Sep 17 00:00:00 2001 From: devil Date: Mon, 6 Jan 2020 18:53:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E6=95=B0=E9=87=8Fnav?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Cart.php | 1 + application/api/controller/Index.php | 2 ++ application/api/controller/User.php | 3 +- application/index/controller/User.php | 2 +- application/service/BuyService.php | 6 +++- application/service/MessageService.php | 4 ++- application/service/NavigationService.php | 4 +-- public/appmini/old/alipay/app.js | 18 ++++++++-- public/appmini/old/alipay/app.json | 2 +- .../appmini/old/alipay/pages/index/index.js | 1 + public/appmini/old/alipay/pages/user/user.js | 1 + public/appmini/old/weixin/app.js | 34 +++++++++++++++++++ public/appmini/old/weixin/app.json | 4 +-- public/appmini/old/weixin/pages/cart/cart.js | 16 +++++++++ .../appmini/old/weixin/pages/index/index.js | 9 +++++ .../appmini/old/weixin/pages/index/index.json | 2 ++ .../pages/user-membervip/user-membervip.js | 10 ++++-- .../pages/user-membervip/user-membervip.wxml | 25 ++++++++++++-- .../pages/user-membervip/user-membervip.wxss | 28 +++++++++++++-- public/appmini/old/weixin/pages/user/user.js | 8 +++++ 20 files changed, 161 insertions(+), 19 deletions(-) diff --git a/application/api/controller/Cart.php b/application/api/controller/Cart.php index 4229cf68a..5584135a9 100755 --- a/application/api/controller/Cart.php +++ b/application/api/controller/Cart.php @@ -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; diff --git a/application/api/controller/Index.php b/application/api/controller/Index.php index 01455e5fa..876ebf330 100755 --- a/application/api/controller/Index.php +++ b/application/api/controller/Index.php @@ -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]), ]; // 支付宝小程序在线客服 diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 803d68384..1cd41b438 100755 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -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]), ); // 支付宝小程序在线客服 diff --git a/application/index/controller/User.php b/application/index/controller/User.php index 82adb0b7c..824f05db9 100755 --- a/application/index/controller/User.php +++ b/application/index/controller/User.php @@ -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); diff --git a/application/service/BuyService.php b/application/service/BuyService.php index 4e3d7c91c..6607a5ba1 100755 --- a/application/service/BuyService.php +++ b/application/service/BuyService.php @@ -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; } /** diff --git a/application/service/MessageService.php b/application/service/MessageService.php index 5fc9c9a29..52d30fbf8 100755 --- a/application/service/MessageService.php +++ b/application/service/MessageService.php @@ -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; } /** diff --git a/application/service/NavigationService.php b/application/service/NavigationService.php index bd02ef77b..a9dc411a4 100755 --- a/application/service/NavigationService.php +++ b/application/service/NavigationService.php @@ -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; } // 列表 diff --git a/public/appmini/old/alipay/app.js b/public/appmini/old/alipay/app.js index bd33e3d31..01642cd52 100644 --- a/public/appmini/old/alipay/app.js +++ b/public/appmini/old/alipay/app.js @@ -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', + }); + }, + }); diff --git a/public/appmini/old/alipay/app.json b/public/appmini/old/alipay/app.json index 3e50c92c4..6ae2b52fe 100644 --- a/public/appmini/old/alipay/app.json +++ b/public/appmini/old/alipay/app.json @@ -31,7 +31,7 @@ "pages/extraction-address/extraction-address" ], "window": { - "defaultTitle": "{{application_title}}", + "defaultTitle": "shopxo", "titleBarColor": "#d2364c" }, "tabBar": { diff --git a/public/appmini/old/alipay/pages/index/index.js b/public/appmini/old/alipay/pages/index/index.js index b76994d33..a3b84ce79 100644 --- a/public/appmini/old/alipay/pages/index/index.js +++ b/public/appmini/old/alipay/pages/index/index.js @@ -27,6 +27,7 @@ Page({ }, onShow() { + app.set_nav_bg_color_main(); this.init(); }, diff --git a/public/appmini/old/alipay/pages/user/user.js b/public/appmini/old/alipay/pages/user/user.js index a1fd99aa2..9f552dca2 100644 --- a/public/appmini/old/alipay/pages/user/user.js +++ b/public/appmini/old/alipay/pages/user/user.js @@ -35,6 +35,7 @@ Page({ onShow() { my.setNavigationBar({title: app.data.common_pages_title.user}); + app.set_nav_bg_color_main(); this.init(); }, diff --git a/public/appmini/old/weixin/app.js b/public/appmini/old/weixin/app.js index 8f7e6da7f..7a194b4c0 100755 --- a/public/appmini/old/weixin/app.js +++ b/public/appmini/old/weixin/app.js @@ -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() }); + } + } + }, + }); \ No newline at end of file diff --git a/public/appmini/old/weixin/app.json b/public/appmini/old/weixin/app.json index cb59c6222..12fe28d56 100755 --- a/public/appmini/old/weixin/app.json +++ b/public/appmini/old/weixin/app.json @@ -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", diff --git a/public/appmini/old/weixin/pages/cart/cart.js b/public/appmini/old/weixin/pages/cart/cart.js index 076107e88..ebd0579f5 100755 --- a/public/appmini/old/weixin/pages/cart/cart.js +++ b/public/appmini/old/weixin/pages/cart/cart.js @@ -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)) { diff --git a/public/appmini/old/weixin/pages/index/index.js b/public/appmini/old/weixin/pages/index/index.js index 26c814f82..c742be861 100755 --- a/public/appmini/old/weixin/pages/index/index.js +++ b/public/appmini/old/weixin/pages/index/index.js @@ -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) { diff --git a/public/appmini/old/weixin/pages/index/index.json b/public/appmini/old/weixin/pages/index/index.json index b3298e1be..d98684c7d 100755 --- a/public/appmini/old/weixin/pages/index/index.json +++ b/public/appmini/old/weixin/pages/index/index.json @@ -1,5 +1,7 @@ { "enablePullDownRefresh": true, + "navigationBarBackgroundColor": "#d2364c", + "backgroundColor": "#d2364c", "usingComponents": { "component-icon-nav": "/components/icon-nav/icon-nav", "component-banner": "/components/slider/slider" diff --git a/public/appmini/old/weixin/pages/user-membervip/user-membervip.js b/public/appmini/old/weixin/pages/user-membervip/user-membervip.js index bb1e8bcc4..6972e4185 100644 --- a/public/appmini/old/weixin/pages/user-membervip/user-membervip.js +++ b/public/appmini/old/weixin/pages/user-membervip/user-membervip.js @@ -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: "数据统计", } ], }, diff --git a/public/appmini/old/weixin/pages/user-membervip/user-membervip.wxml b/public/appmini/old/weixin/pages/user-membervip/user-membervip.wxml index c7ea8372a..f00b085a4 100644 --- a/public/appmini/old/weixin/pages/user-membervip/user-membervip.wxml +++ b/public/appmini/old/weixin/pages/user-membervip/user-membervip.wxml @@ -41,11 +41,32 @@ - + - + {{item.title}} + + + + + + + + + {{item}} + + + + + + + + + {{item}} + + + \ No newline at end of file diff --git a/public/appmini/old/weixin/pages/user-membervip/user-membervip.wxss b/public/appmini/old/weixin/pages/user-membervip/user-membervip.wxss index cdfcc3170..dbb4d9989 100644 --- a/public/appmini/old/weixin/pages/user-membervip/user-membervip.wxss +++ b/public/appmini/old/weixin/pages/user-membervip/user-membervip.wxss @@ -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; } \ No newline at end of file diff --git a/public/appmini/old/weixin/pages/user/user.js b/public/appmini/old/weixin/pages/user/user.js index 9d99324a7..bc243f2ca 100755 --- a/public/appmini/old/weixin/pages/user/user.js +++ b/public/appmini/old/weixin/pages/user/user.js @@ -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')) {