Browse Source

Merge remote-tracking branch 'origin/master'

zhangdehua 1 year ago
parent
commit
87489d5eb7

+ 74 - 59
app/index/controller/Index.php

@@ -5,6 +5,7 @@ namespace app\index\controller;
 use app\index\model\Article as ArticleModel;
 use app\index\model\Comment as CommentModel;
 use app\index\model\Goods as GoodsModel;
+use think\facade\Cache;
 
 /**
  * 默认控制器
@@ -16,71 +17,85 @@ class Index extends Controller
     public function index()
     {
         //banner位
-
-        //商品区。new,video,bestseller
-        $model = new GoodsModel;
-        $newArrival = $model->getList(['listType' => 'on_sale'], 4)->toArray()['data'];
-        $bestseller = $model->getList(['sortType' => 'sales'], 4)->toArray()['data'];
-
-        $superDeals = $model->getList(['categoryId' => '10002',], 3)->toArray()['data'];
-        //dd($superDeals);
-        //return $this->renderSuccess(compact('bestseller'));
-
-        $newGoodsId = array_column($newArrival, 'goods_id');
-        $bestGoodsId = array_column($bestseller, 'goods_id');
-        $superDealsGoodsId = array_column($superDeals, 'goods_id');
-
-        //获取评价数量
-        $goodsIds = array_unique(array_merge($newGoodsId, $bestGoodsId, $superDealsGoodsId));
-        $commentModel = new CommentModel();
-        $rows = $commentModel->rowsTotalBatch($goodsIds)->toArray();
-        $rowsByGoodsId = array_column($rows, 'cnt', 'goods_id');
-
-        //获取评论分数
-        $commentScores = $commentModel->getTotalAll($goodsIds)->toArray();
-        $scoresByGoodsId = array_column($commentScores, 'score_total', 'goods_id');
-
-        //dd($rowsByGoodsId);
-
-        //可考虑缓存
-
-        foreach ($newArrival as &$item) {
-            $item['comment_cnt'] = $rowsByGoodsId[$item['goods_id']] ?? 0;
-            $temp = bcmul($item['comment_cnt'], 10, 0);
-            if ($temp){
-                $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']] ?? '0', $temp, 0);
-            }else{
-                $item['avg_score'] = 5;
+        $newArrivalCache = Cache::get('index_newArrival');
+        $bestsellerCache = Cache::get('index_bestseller');
+        $superDealsCache = Cache::get('index_superDeals');
+        $articleCache = Cache::get('index_article');
+        if ($newArrivalCache && $bestsellerCache && $superDealsCache && $articleCache) {
+            $newArrival = json_decode($newArrivalCache, true);
+            $bestseller = json_decode($bestsellerCache, true);
+            $superDeals = json_decode($superDealsCache, true);
+            $article = json_decode($articleCache, true);
+        } else {
+            //商品区。new,video,bestseller
+            $model = new GoodsModel;
+            $newArrival = $model->getList(['listType' => 'on_sale'], 4)->toArray()['data'];
+            $bestseller = $model->getList(['sortType' => 'sales'], 4)->toArray()['data'];
+
+            $superDeals = $model->getList(['categoryId' => '10002',], 3)->toArray()['data'];
+            //dd($superDeals);
+            //return $this->renderSuccess(compact('bestseller'));
+
+            $newGoodsId = array_column($newArrival, 'goods_id');
+            $bestGoodsId = array_column($bestseller, 'goods_id');
+            $superDealsGoodsId = array_column($superDeals, 'goods_id');
+
+            //获取评价数量
+            $goodsIds = array_unique(array_merge($newGoodsId, $bestGoodsId, $superDealsGoodsId));
+            $commentModel = new CommentModel();
+            $rows = $commentModel->rowsTotalBatch($goodsIds)->toArray();
+            $rowsByGoodsId = array_column($rows, 'cnt', 'goods_id');
+
+            //获取评论分数
+            $commentScores = $commentModel->getTotalAll($goodsIds)->toArray();
+            $scoresByGoodsId = array_column($commentScores, 'score_total', 'goods_id');
+
+            //dd($rowsByGoodsId);
+
+            //可考虑缓存
+
+            foreach ($newArrival as &$item) {
+                $item['comment_cnt'] = $rowsByGoodsId[$item['goods_id']] ?? 0;
+                $temp = bcmul($item['comment_cnt'], 10, 0);
+                if ($temp) {
+                    $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']] ?? '0', $temp, 0);
+                } else {
+                    $item['avg_score'] = 5;
+                }
             }
-        }
-
-        foreach ($bestseller as &$item) {
-            $item['comment_cnt'] = $rowsByGoodsId[$item['goods_id']] ?? 0;
-            if ($temp){
-                $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']] ?? '0', $temp, 0);
-            }else{
-                $item['avg_score'] = 5;
+            Cache::set('index_newArrival', json_encode($newArrival), 1200);
+
+            foreach ($bestseller as &$item) {
+                $item['comment_cnt'] = $rowsByGoodsId[$item['goods_id']] ?? 0;
+                if ($temp) {
+                    $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']] ?? '0', $temp, 0);
+                } else {
+                    $item['avg_score'] = 5;
+                }
             }
-        }
-
-        foreach ($superDeals as &$item) {
-            $item['comment_cnt'] = $rowsByGoodsId[$item['goods_id']] ?? 0;
-            if ($temp){
-                $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']] ?? '0', $temp, 0);
-            }else{
-                $item['avg_score'] = 5;
+            Cache::set('index_bestseller', json_encode($bestseller), 1200);
+
+            foreach ($superDeals as &$item) {
+                $item['comment_cnt'] = $rowsByGoodsId[$item['goods_id']] ?? 0;
+                if ($temp) {
+                    $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']] ?? '0', $temp, 0);
+                } else {
+                    $item['avg_score'] = 5;
+                }
             }
-        }
+            Cache::set('index_superDeals', json_encode($superDeals), 1200);
+
+            $model = new ArticleModel;
+            $article = $model->getList(0, 5)->toArray()['data'];
 
-        $model = new ArticleModel;
-        $article = $model->getList(0, 5)->toArray()['data'];
+            foreach ($article as &$datum) {
+                $datum['year'] = substr($datum['create_time'], 0, 4);
+                $datum['month_day'] = substr($datum['create_time'], 5, 5);
+                $datum['date'] = substr($datum['create_time'], 0, 10);
+            }
+            Cache::set('index_article', json_encode($article), 1200);
 
-        foreach ($article as &$datum) {
-            $datum['year'] = substr($datum['create_time'], 0, 4);
-            $datum['month_day'] = substr($datum['create_time'], 5, 5);
-            $datum['date'] = substr($datum['create_time'], 0, 10);
         }
-        //dd($article);
 
         return view('/index/index', [
             'newGoods' => $newArrival,

+ 6 - 6
app/index/view/cart/shoppingCart.html

@@ -39,10 +39,10 @@
                 <h2 class="headNavTitle">NEW VAPES</h2>
                 <p class="back"></p>
             </nav>
-            <nav class="headNavItem">
+<!--            <nav class="headNavItem">
                 <h2 class="headNavTitle">DISPOSABLES</h2>
                 <p class="back"></p>
-            </nav>
+            </nav>-->
         </div>
         <div class="headIconContainer">
             <!-- 购物车 -->
@@ -56,7 +56,7 @@
             <!--                <img src="/assets/index/asstes/icon/collect.png" alt="collect" tabindex="collect">-->
             <!--            </div>-->
             <!-- 个人中心 -->
-            <a href="/index/user/personal.html">
+            <a href="/index/user/order.html">
                 <div class="headIconItem userIcon">
                     <img src="/assets/index/asstes/icon/user.png" alt="user" tabindex="user">
                 </div>
@@ -85,15 +85,15 @@
         <!-- 移动端菜单 -->
         <section class="mobileMenuFixed">
             <div class="mobileMenuItem active">
-                <a href="#">
+                <a href="/index/index/index.html">
                     <h2 class="menuItemTitle">NEW VAPES</h2>
                 </a>
             </div>
-            <div class="mobileMenuItem">
+<!--            <div class="mobileMenuItem">
                 <a href="#">
                     <h2 class="menuItemTitle">DISPOSABLES</h2>
                 </a>
-            </div>
+            </div>-->
             <div class="mobileMenuItem">
                 <a href="/index/cart/shoppingCart.html">
                     <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>

+ 5 - 5
app/index/view/index/index.html

@@ -39,10 +39,10 @@
                 <h2 class="headNavTitle">NEW VAPES</h2>
                 <p class="back"></p>
             </nav>
-            <nav class="headNavItem">
+<!--            <nav class="headNavItem">
                 <h2 class="headNavTitle">DISPOSABLES</h2>
                 <p class="back"></p>
-            </nav>
+            </nav>-->
         </div>
         <div class="headIconContainer">
             <!-- 购物车 -->
@@ -85,15 +85,15 @@
         <!-- 移动端菜单 -->
         <section class="mobileMenuFixed">
             <div class="mobileMenuItem active">
-                <a href="#">
+                <a href="/index/index/index.html">
                     <h2 class="menuItemTitle">NEW VAPES</h2>
                 </a>
             </div>
-            <div class="mobileMenuItem">
+<!--            <div class="mobileMenuItem">
                 <a href="#">
                     <h2 class="menuItemTitle">DISPOSABLES</h2>
                 </a>
-            </div>
+            </div>-->
             <div class="mobileMenuItem">
                 <a href="/index/cart/shoppingCart.html">
                     <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>

+ 18 - 18
app/index/view/index/productDetails.html

@@ -39,10 +39,10 @@
                 <h2 class="headNavTitle">NEW VAPES</h2>
                 <p class="back"></p>
             </nav>
-            <nav class="headNavItem">
-                <h2 class="headNavTitle">DISPOSABLES</h2>
-                <p class="back"></p>
-            </nav>
+            <!--            <nav class="headNavItem">
+                            <h2 class="headNavTitle">DISPOSABLES</h2>
+                            <p class="back"></p>
+                        </nav>-->
         </div>
         <div class="headIconContainer">
             <a href="/index/cart/shoppingCart.html">
@@ -85,23 +85,25 @@
         <!-- 移动端菜单 -->
         <section class="mobileMenuFixed">
             <div class="mobileMenuItem active">
-                <a href="#">
+                <a href="/index/index/index.html">
                     <h2 class="menuItemTitle">NEW VAPES</h2>
                 </a>
             </div>
+            <!--            <div class="mobileMenuItem">
+                            <a href="#">
+                                <h2 class="menuItemTitle">DISPOSABLES</h2>
+                            </a>
+                        </div>-->
             <div class="mobileMenuItem">
-                <a href="#">
-                    <h2 class="menuItemTitle">DISPOSABLES</h2>
+                <a href="/index/cart/shoppingCart.html">
+                    <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>
                 </a>
             </div>
-            <a href="/index/cart/shoppingCart.html">
-                <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>
-            </a>
             <!--            <div class="mobileMenuItem">-->
             <!--                <h2 class="menuItemTitle collectIcon">Collect</h2>-->
             <!--            </div>-->
             <div class="mobileMenuItem">
-                <a href="/index/user/personal.html">
+                <a href="/index/user/order.html">
                     <h2 class="menuItemTitle userIcon">Personal</h2>
                 </a></div>
         </section>
@@ -528,20 +530,18 @@
                     container.html(html);
 
 
-
-
                     //数据长度大于0显示上下页按钮
                     //$('#reviewsButtonContainer').show();
-                    console.log(response.data.list.last_page , page,response.data.list.last_page > page)
-                    if (response.data.list.last_page > page){
+                    console.log(response.data.list.last_page, page, response.data.list.last_page > page)
+                    if (response.data.list.last_page > page) {
                         $("#nextPage").show()
-                    }else {
+                    } else {
                         $("#nextPage").hide()
                     }
 
-                    if (page > 1){
+                    if (page > 1) {
                         $("#prevPage").show()
-                    }else {
+                    } else {
                         $("#prevPage").hide()
                     }
 

+ 53 - 47
app/index/view/user/integral.html

@@ -75,19 +75,25 @@
         <!-- 移动端菜单 -->
         <section class="mobileMenuFixed">
             <div class="mobileMenuItem">
-                <h2 class="menuItemTitle">NEW VAPES</h2>
-            </div>
-            <div class="mobileMenuItem">
-                <h2 class="menuItemTitle">DISPOSABLES</h2>
-            </div>
-            <div class="mobileMenuItem">
-                <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>
+                <a href="/index/index/index.html">
+                    <h2 class="menuItemTitle">NEW VAPES</h2>
+                </a>
             </div>
+            <!--            <div class="mobileMenuItem">
+                            <h2 class="menuItemTitle">DISPOSABLES</h2>
+                        </div>-->
             <div class="mobileMenuItem">
-                <h2 class="menuItemTitle collectIcon">Collect</h2>
+                <a href="/index/cart/shoppingCart.html">
+                    <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>
+                </a>
             </div>
+            <!--            <div class="mobileMenuItem">
+                            <h2 class="menuItemTitle collectIcon">Collect</h2>
+                        </div>-->
             <div class="mobileMenuItem active">
-                <h2 class="menuItemTitle userIcon">Personal</h2>
+                <a href="/index/user/order.html">
+                    <h2 class="menuItemTitle userIcon">Personal</h2>
+                </a>
             </div>
         </section>
     </div>
@@ -246,44 +252,44 @@
             // 显示加载指示器
             $('#loadingIndicator').show();
             //调试后记得去除这段代码
-/*            setTimeout(() => {
-                // 在页面中添加数据
-                const container = $('#intContainer');
-                [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16].forEach(function (item) {
-                    container.append(`
-                    <div class="intItem">
-                            <div class="intValItem">
-                                <div class="valKey">
-                                    <p class="vTitle">变动数量</p>
-                                    <p class="symbol">:</p>
-                                </div>
-                                <p class="valVal">999</p>
-                            </div>
-                            <div class="intValItem">
-                                <div class="valKey">
-                                    <p class="vTitle">变动时间</p>
-                                    <p class="symbol">:</p>
-                                </div>
-                                <p class="valVal">2023:12:12 12-12-12</p>
-                            </div>
-                            <div class="intValItem">
-                                <div class="valKey">
-                                    <p class="vTitle">描述/说明</p>
-                                    <p class="symbol">:</p>
-                                </div>
-                                <p class="valVal">
-                                    --
-                                </p>
-                            </div>
-                        </div>`);
-                });
-                // 更新当前页数
-                page++;
-                // 隐藏加载指示器
-                $('#loadingIndicator').hide();
-                isLoading = false;
-            }, 1000)
-            return*/
+            /*            setTimeout(() => {
+                            // 在页面中添加数据
+                            const container = $('#intContainer');
+                            [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16].forEach(function (item) {
+                                container.append(`
+                                <div class="intItem">
+                                        <div class="intValItem">
+                                            <div class="valKey">
+                                                <p class="vTitle">变动数量</p>
+                                                <p class="symbol">:</p>
+                                            </div>
+                                            <p class="valVal">999</p>
+                                        </div>
+                                        <div class="intValItem">
+                                            <div class="valKey">
+                                                <p class="vTitle">变动时间</p>
+                                                <p class="symbol">:</p>
+                                            </div>
+                                            <p class="valVal">2023:12:12 12-12-12</p>
+                                        </div>
+                                        <div class="intValItem">
+                                            <div class="valKey">
+                                                <p class="vTitle">描述/说明</p>
+                                                <p class="symbol">:</p>
+                                            </div>
+                                            <p class="valVal">
+                                                --
+                                            </p>
+                                        </div>
+                                    </div>`);
+                            });
+                            // 更新当前页数
+                            page++;
+                            // 隐藏加载指示器
+                            $('#loadingIndicator').hide();
+                            isLoading = false;
+                        }, 1000)
+                        return*/
             $.ajax({
                 url: '/index/user/pointsLogs',
                 type: 'GET',

+ 20 - 12
app/index/view/user/order.html

@@ -42,9 +42,9 @@
                 </div>
             </a>
             <!-- 收藏 -->
-<!--            <div class="headIconItem collectIcon">-->
-<!--                <img src="/assets/index/asstes/icon/collect.png" alt="collect" tabindex="collect">-->
-<!--            </div>-->
+            <!--            <div class="headIconItem collectIcon">-->
+            <!--                <img src="/assets/index/asstes/icon/collect.png" alt="collect" tabindex="collect">-->
+            <!--            </div>-->
             <!-- 个人中心 -->
             <a href="/index/user/order.html">
                 <div class="headIconItem userIcon">
@@ -75,19 +75,27 @@
         <!-- 移动端菜单 -->
         <section class="mobileMenuFixed">
             <div class="mobileMenuItem">
-                <h2 class="menuItemTitle">NEW VAPES</h2>
-            </div>
-            <div class="mobileMenuItem">
-                <h2 class="menuItemTitle">DISPOSABLES</h2>
+                <a href="/index/index/index.html">
+                    <h2 class="menuItemTitle">NEW VAPES</h2>
+                </a>
+
             </div>
+            <!--            <div class="mobileMenuItem">
+                            <h2 class="menuItemTitle">DISPOSABLES</h2>
+                        </div>-->
             <div class="mobileMenuItem">
-                <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>
+                <a href="/index/cart/shoppingCart.html">
+                    <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>
+                </a>
+
             </div>
-<!--            <div class="mobileMenuItem">-->
-<!--                <h2 class="menuItemTitle collectIcon">Collect</h2>-->
-<!--            </div>-->
+            <!--            <div class="mobileMenuItem">-->
+            <!--                <h2 class="menuItemTitle collectIcon">Collect</h2>-->
+            <!--            </div>-->
             <div class="mobileMenuItem active">
-                <h2 class="menuItemTitle userIcon">Personal</h2>
+                <a href="/index/user/order.html">
+                    <h2 class="menuItemTitle userIcon">Personal</h2>
+                </a>
             </div>
         </section>
     </div>

+ 14 - 7
app/index/view/user/orderDetails.html

@@ -75,19 +75,25 @@
         <!-- 移动端菜单 -->
         <section class="mobileMenuFixed">
             <div class="mobileMenuItem">
-                <h2 class="menuItemTitle">NEW VAPES</h2>
-            </div>
-            <div class="mobileMenuItem">
-                <h2 class="menuItemTitle">DISPOSABLES</h2>
+                <a href="/index/cart/shoppingCart.html">
+                    <h2 class="menuItemTitle">NEW VAPES</h2>
+                </a>
             </div>
+            <!--            <div class="mobileMenuItem">
+                            <h2 class="menuItemTitle">DISPOSABLES</h2>
+                        </div>-->
             <div class="mobileMenuItem">
-                <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>
+                <a href="/index/cart/shoppingCart.html">
+                    <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>
+                </a>
             </div>
             <!--            <div class="mobileMenuItem">-->
             <!--                <h2 class="menuItemTitle collectIcon">Collect</h2>-->
             <!--            </div>-->
             <div class="mobileMenuItem active">
-                <h2 class="menuItemTitle userIcon">Personal</h2>
+                <a href="/index/user/order.html">
+                    <h2 class="menuItemTitle userIcon">Personal</h2>
+                </a>
             </div>
         </section>
     </div>
@@ -189,7 +195,8 @@
                             </p>
                             {foreach $order['goods'] as $goods}
 
-                            <div class="ogGoodsInfo" data-id="{$goods['goods_id']}" order-goods-id="{$goods['order_goods_id']}">
+                            <div class="ogGoodsInfo" data-id="{$goods['goods_id']}"
+                                 order-goods-id="{$goods['order_goods_id']}">
                                 <div class="ogImgBox">
                                     <img src="{$goods['goods_image']}"
                                          alt="">

File diff suppressed because it is too large
+ 56 - 3717
public/install/data/install_data.sql


+ 7 - 3
public/install/data/install_struct.sql

@@ -367,7 +367,8 @@ CREATE TABLE `yoshop_order` (
 DROP TABLE IF EXISTS `yoshop_order_address`;
 CREATE TABLE `yoshop_order_address` (
   `order_address_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '地址ID',
-  `name` varchar(30) NOT NULL DEFAULT '' COMMENT '收货人姓名',
+  `name` varchar(100) NOT NULL DEFAULT '' COMMENT '收货人姓名',
+  `last_name` varchar(100) NOT NULL DEFAULT '' COMMENT '收货人姓',
   `phone` varchar(20) NOT NULL DEFAULT '' COMMENT '联系电话',
   `province_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '省份ID',
   `city_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '城市ID',
@@ -758,7 +759,7 @@ CREATE TABLE `yoshop_upload_group` (
 DROP TABLE IF EXISTS `yoshop_user`;
 CREATE TABLE `yoshop_user` (
   `user_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID',
-  `mobile` varchar(20) NOT NULL DEFAULT '' COMMENT '用户手机号',
+  `mobile` varchar(100) NOT NULL DEFAULT '' COMMENT '用户邮箱',
   `nick_name` varchar(255) NOT NULL DEFAULT '' COMMENT '用户昵称',
   `avatar_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '头像文件ID',
   `gender` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '性别',
@@ -785,8 +786,11 @@ CREATE TABLE `yoshop_user` (
 DROP TABLE IF EXISTS `yoshop_user_address`;
 CREATE TABLE `yoshop_user_address` (
   `address_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
-  `name` varchar(30) NOT NULL DEFAULT '' COMMENT '收货人姓名',
+  `name` varchar(100) NOT NULL DEFAULT '' COMMENT '收货人姓名',
+  `last_name` varchar(100) NOT NULL DEFAULT '' COMMENT '收货人姓',
   `phone` varchar(20) NOT NULL DEFAULT '' COMMENT '联系电话',
+  `email` varchar(100) NOT NULL DEFAULT '' COMMENT '联系邮箱',
+  `zip_code` varchar(20) NOT NULL DEFAULT '' COMMENT '邮编',
   `province_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '省份ID',
   `city_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '城市ID',
   `region_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '区/县ID',