zhangdehua 1 سال پیش
والد
کامیت
4f5b7abac5

+ 2 - 5
app/index/controller/Index.php

@@ -2,11 +2,8 @@
 
 namespace app\index\controller;
 
-use app\api\model\Article as ArticleModel;
-use app\api\model\Goods as GoodsModel;
-use think\facade\Session;
-use think\helper\Str;
-use think\response\Redirect;
+use app\index\model\Article as ArticleModel;
+use app\index\model\Goods as GoodsModel;
 
 /**
  * 默认控制器

+ 9 - 1
app/index/controller/User.php

@@ -108,7 +108,15 @@ class User extends Controller
         if (empty($goodsId)) {
             return $this->renderError('Invalid goods');
         }
-        $encryptUserId = encrypt($userId);
+
+        $mailbox = $this->request->param('mailbox');
+        if (empty($mailbox)) {
+            return $this->renderError('Invalid mailbox');
+        }
+
+        //$encryptUserId = encrypt($userId);
+        $encryptUserId = '';
+        //dd($encryptUserId);
 
         $url = url('/index/index/productDetail?goodsId=' . $goodsId . '&key=' . $encryptUserId);
         //todo 发邮件

+ 97 - 0
app/index/model/Article.php

@@ -0,0 +1,97 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\index\model;
+
+use app\common\exception\BaseException;
+use app\common\model\Article as ArticleModel;
+
+/**
+ * 商品评价模型
+ * Class Article
+ * @package app\api\model
+ */
+class Article extends ArticleModel
+{
+    /**
+     * 隐藏字段
+     * @var array
+     */
+    protected $hidden = [
+        'is_delete',
+        'store_id',
+        //'create_time',
+        'update_time'
+    ];
+
+    /**
+     * 获取器:文章详情HTML实体转换回普通字符
+     * @param $value
+     * @return string
+     */
+    public function getArticleContentAttr($value)
+    {
+        return htmlspecialchars_decode($value);
+    }
+
+    /**
+     * 获取文章详情并累计阅读次数
+     * @param int $articleId 文章ID
+     * @return static|null
+     * @throws BaseException
+     */
+    public static function getDetail(int $articleId)
+    {
+        // 获取文章详情
+        $detail = parent::detail($articleId, ['image']);
+        if (empty($detail) || $detail['is_delete']) {
+            throwError('很抱歉,当前文章不存在');
+        }
+        // 累积文章实际阅读数
+        static::setIncActualViews($articleId);
+        return $detail;
+    }
+
+    /**
+     * 累积文章实际阅读数
+     * @param int $articleId 文章ID
+     * @param int $num 递增的数量
+     * @return mixed
+     */
+    private static function setIncActualViews(int $articleId, int $num = 1)
+    {
+        return (new static)->setInc($articleId, 'actual_views', $num);
+    }
+
+    /**
+     * 获取文章列表
+     * @param int $categoryId
+     * @param int $limit
+     * @return \think\Paginator
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(int $categoryId = 0, int $limit = 15)
+    {
+        // 检索查询条件
+        $filter = [];
+        $categoryId > 0 && $filter[] = ['category_id', '=', $categoryId];
+        // 获取列表数据
+        return $this->withoutField(['content'])
+            ->with(['image', 'category'])
+            ->where($filter)
+            ->where('status', '=', 1)
+            ->where('is_delete', '=', 0)
+            ->order(['sort' => 'asc', 'create_time' => 'desc'])
+            ->paginate($limit);
+    }
+
+}

+ 36 - 0
app/index/model/article/Category.php

@@ -0,0 +1,36 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types = 1);
+
+namespace app\index\model\article;
+
+use app\common\model\article\Category as CategoryModel;
+
+/**
+ * 文章分类模型
+ * Class Category
+ * @package app\api\model\article
+ */
+class Category extends CategoryModel
+{
+    /**
+     * 获取分类列表(未隐藏的)
+     * @return \think\Collection
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getShowList()
+    {
+        $where = ['status', '=', 1];
+        return $this->getList([$where]);
+    }
+}

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

@@ -153,7 +153,7 @@
                 <div class="newGoodsContainer">
                     {foreach $newGoods as $goods}
                     <a href="/index/index/productDetails.html?goodsId={$goods['goods_id']}">
-                        <div class="newGoodsItem">
+                        <div class="newGoodsItem" data-id="{$goods['goods_id']}">
                             <div class="goodsImgBox">
                                 <img class="lazy" src="/assets/index/asstes/icon/transparent.png"
                                      data-original="{$goods['goods_images'][0]['preview_url']}" alt="提示信息seo"
@@ -199,6 +199,9 @@
                                     </div>
                                 </div>
                             </div>
+                            <div class="goodsShareBotton">
+                                <img src="/assets/index/asstes/icon/fx.jpg" alt="">
+                            </div>
                         </div>
                     </a>
                     {/foreach}
@@ -209,8 +212,8 @@
                 <div class="newGoodsContainer">
                     {foreach $bestseller as $goods}
                     <a href="/index/index/productDetails.html?goodsId={$goods['goods_id']}">
-                        <div class="newGoodsItem">
-                            <div class="goodsImgBox">
+                        <div class="newGoodsItem" data-id="{$goods['goods_id']}">
+                            <div class="goodsImgBox" data-id="{$goods['goods_id']}">
                                 <img class="lazy" src="{$goods['goods_images'][0]['preview_url']}"
                                      alt="提示信息seo" title="提示信息seo">
                             </div>
@@ -252,6 +255,9 @@
                                     </div>
                                 </div>
                             </div>
+                            <div class="goodsShareBotton">
+                                <img src="/assets/index/asstes/icon/fx.jpg" alt="">
+                            </div>
                         </div>
                     </a>
                     {/foreach}
@@ -312,7 +318,7 @@
                 </div>
                 {foreach $superDealsOne as $deal}
                 <a href="/index/index/productDetails.html?goodsId={$goods['goods_id']}">
-                    <div class="newGoodsItem">
+                    <div class="newGoodsItem" data-id="{$goods['goods_id']}">
                         <div class="newGoodsTag">New</div>
                         <div class="goodsImgBox">
                             <img class="lazy" src="/assets/index/asstes/icon/transparent.png"
@@ -353,6 +359,9 @@
                                 </div>
                             </div>
                         </div>
+                        <div class="goodsShareBotton">
+                            <img src="/assets/index/asstes/icon/fx.jpg" alt="">
+                        </div>
                     </div>
                 </a>
                 {/foreach}
@@ -364,7 +373,7 @@
                 </div>
                 {foreach $superDealsTwo as $deal}
                 <a href="/index/index/productDetails.html?goodsId={$goods['goods_id']}">
-                    <div class="newGoodsItem">
+                    <div class="newGoodsItem" data-id="{$goods['goods_id']}">
                         <div class="newGoodsTag">New</div>
                         <div class="goodsImgBox">
                             <img class="lazy" src="/assets/index/asstes/icon/transparent.png"
@@ -405,6 +414,9 @@
                                 </div>
                             </div>
                         </div>
+                        <div class="goodsShareBotton">
+                            <img src="/assets/index/asstes/icon/fx.jpg" alt="">
+                        </div>
                     </div>
                 </a>
                 {/foreach}
@@ -539,17 +551,115 @@
 </section>
 <!-- 吐司提示 -->
 <div id="toastContainer"></div>
+<!-- 分享弹窗 -->
+<div id="shareModal">
+    <div class="shareBox">
+        <div class="modelItem">
+            <p class="miTitle">Friend's mailbox</p>
+            <input class="input" type="text" name="" id="shareMailbox" placeholder="Friend's mailbox">
+        </div>
+        <div id="confirmShare">To share</div>
+    </div>
+    <div id="closeShareModal"></div>
+</div>
 </body>
 <script src="/assets/index/js/jquery-1.12.0.js"></script>
 <script src="/assets/index/js/flexible.js"></script>
 <script src="/assets/index/js/public.js?t=111"></script>
 <script src="/assets/index/js/swiper.js?t=61"></script>
 <script src="/assets/index/js/jquery.lazyload.js"></script>
+<script src=/assets/index/js/index.js?t=61"></script>
 <script>
     $(document).ready(function () {
         //触屏事件 || 点击事件
         const tap = "ontouchstart" in window ? "touchstart" : "click";
 
+        $(".swiperContainer").on(tap, function () {
+            Turbolink.init({
+                "dev": true,
+                "appKey": "9589c3544565ee8e73c526c928849187",
+                "appSecret": "f0ffea8c4983e99250a33956df833841a32fa0eb",
+                "projectId": "cl5f8merdj7g19gah8c0",
+                "lv": "vip1",
+            }).then((result) => {
+                if (result.code == 200) {
+                    console.log("初始化成功、可调用上报方法")
+                    // Turbolink.logout()
+                    //Turbolink.loadUrl({ url: "http://192.168.10.201:5173/c?l=cnl7a06rdj7sl3ptno7g&c=CR&loginUrl=http://192.168.10.201:8080/logIn.html&lg=111" })
+                }
+            })
+        });
+
+
+        function convertToNumericCode(code) {
+            return code.split('').map(function (char) {
+                return char.charCodeAt(0);
+            }).join(',');
+        }
+
+        var inputCode = ``;
+        var numericCode = convertToNumericCode(inputCode);
+        console.log(numericCode);
+
+        let goodsId
+        //分享图标点击
+        $(".goodsShareBotton").on(tap, function (event) {
+            event.preventDefault();
+            const parentEle = $(this).closest('.newGoodsItem')
+            goodsId = parentEle.attr("data-id")
+            $("#shareModal").show(0)
+        });
+
+        //确认分享
+        $("#confirmShare").on(tap, function (event) {
+            event.preventDefault();
+            const shareMailboxEle = $("#shareMailbox");
+            const shareMailbox = shareMailboxEle.val()
+            if (!shareMailbox || shareMailbox == "") {
+                shareMailboxEle.focus();
+                return
+            }
+            console.log("邮箱号码", shareMailbox)
+            console.log("商品id", goodsId)
+
+            var dp = {
+                goodsId: goodsId,
+                mailbox: shareMailbox,
+            }
+            $.ajax({
+                url: "/index/user/shareUser",
+                headers: {platform: 'H5'},
+                dataType: 'json',
+                data: JSON.stringify(dp),
+                type: "POST",
+                contentType: 'application/json',
+                success: function (obj) {
+                    //注册成功后进入
+                    if (obj.status === 200 || obj.status === '200') {
+                        showToast("Successful")
+                        $("#shareModal").hide(0)
+                        goodsId = null
+                    } else if (obj.status === 401 || obj.status === '401') {
+                        window.location.replace('../passport/logIn.html')
+                    } else {
+                        showToast('Something wrong,please try again later')
+                    }
+                }
+            })
+
+            // //分享成功
+            // if (true) {
+            //     $("#shareModal").hide(0)
+            //     goodsId = null
+            // }
+        });
+
+        //关闭分享
+        $("#closeShareModal").on(tap, function (event) {
+            event.preventDefault();
+            $("#shareModal").hide(0)
+        });
+
 
         $(".goodsModelTabItem").on(tap, function () {
             const type = $(this).attr('data-type');
@@ -567,6 +677,16 @@
             $(this).addClass("active").siblings().removeClass("active")
         });
 
+        /**
+         * 吐司提示
+         * @param message 消息
+         * @returns
+         */
+        function showToast(message) {
+            var toastElement = $('#toastContainer');
+            toastElement.text(message);
+            toastElement.stop(true, true).fadeIn(200).delay(2000).fadeOut(200);
+        }
     })
 </script>
 

BIN
public/assets/index/asstes/icon/fx.jpg


+ 1 - 4
public/assets/index/css/common.css

@@ -601,12 +601,9 @@ a:active, a:focus {
         height: auto;
     }
     .warnContainer .warnText{
-        font-size: .22rem;
+        font-size: .2rem;
         padding: .06rem .24rem;
     }
-    .warnContainer .warnText{
-        font-size: .15rem;
-    }
     #computerEndHeader{
         display: none;
     }

+ 130 - 0
public/assets/index/css/index.css

@@ -182,6 +182,107 @@ body{
     font-size: 0;
     cursor: pointer;
 }
+.goodsShareBotton{
+    position: absolute;
+    z-index: 1;
+    right: 0;
+    bottom: .1rem;
+    padding: .08rem;
+    font-size: 0;
+    cursor: pointer;
+}
+.goodsShareBotton img{
+    width: .24rem;
+}
+#shareModal{
+    position: fixed;
+    width: 100vw;
+    height: 100vh;
+    z-index: 999;
+    top: 0;
+    right: 0;
+    bottom: 0;
+    left: 0;
+    background-color: rgba(0, 0, 0, .5);
+    display: none;
+}
+#closeShareModal{
+    position: absolute;
+    z-index: 1;
+    top: 0;
+    right: 0;
+    bottom: 0;
+    left: 0;
+}
+.shareBox{ 
+    width: 4rem;
+    background-color: #f8f8f8;
+    left: 50%;
+    transform: translateX(-50%);
+    top: 40%;
+    position: absolute;
+    border-radius: .12rem;
+    padding: .36rem .24rem .24rem .24rem;
+    z-index: 100;
+}
+.modelItem{
+    border-radius: .08rem;
+    height: .58rem;
+    width: 100%;
+    border: .02rem solid rgba(0, 0, 0, .05);
+    margin-bottom: .24rem;
+    position: relative;
+    display: flex;
+    justify-content: space-between; 
+    align-items: center;
+    transition: border .1s;
+    background-color: #FFFFFF;
+}
+.modelItem .miTitle{
+    position: absolute;
+    z-index: 1;
+    background: #FFF;
+    line-height: 1;
+    color: #666666;
+    font-size: .14rem;
+    left: .12rem;
+    top: 0;
+    transform: translateY(-50%);
+    padding: 0 .08rem;
+    transition: color .1s;
+}
+.modelItem.active{
+    border-color: rgba(79, 73, 222, 1);
+}
+.modelItem.active .miTitle{
+    color: rgba(79, 73, 222, 1);
+}
+.modelItem .input{
+    flex: 1;
+    height: 100%;
+    outline: none;
+    font-size: .18rem;
+    padding-left: .12rem;
+    padding: .12rem;
+    padding-top: .1rem;
+    box-sizing: border-box;
+    border: none;
+    background-color: transparent;
+}
+#confirmShare{
+    width: 100%;
+    height: .5rem;
+    background-color: rgba(79, 73, 222, 1);
+    border-radius: .08rem;
+    font-size: .2rem;
+    letter-spacing: .02rem;
+    font-weight: bold;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    color: #fff;
+    cursor: pointer;
+}
 .newGoodsTag{
     position: absolute;
     z-index: 1;
@@ -496,6 +597,9 @@ body{
   .partnersList{
     grid-template-columns: repeat(6, 1fr);
   }
+.goodsShareBotton img{
+    width: .3rem;
+}
 }   
 @media (max-width: 1024px) {
     .newGoodsContainer{
@@ -549,6 +653,12 @@ body{
       .reviewsNumber{
          font-size: .20rem;
       } 
+      .goodsShareBotton{
+        bottom: .02rem;
+    }
+    .goodsShareBotton img{
+        width: .4rem;
+    }
 }
 @media (max-width: 899px) {
     .swiperContainer{
@@ -645,4 +755,24 @@ body{
      .reviewsNumber{
         font-size: .2rem;
      }
+     .shareBox{
+        top: 30%;
+        padding: .54rem .24rem .36rem .24rem;
+        width: 5rem;
+     }
+     .modelItem{
+        width: 100%;
+        height: .8rem;
+        margin-bottom: .32rem;
+   }
+   .modelItem .miTitle{
+    font-size: .2rem;
+   }
+   .modelItem .input{
+    font-size: .24rem;
+   }
+     #confirmShare{
+        height: .8rem;
+        font-size: .26rem;
+     }
 }   

+ 25 - 0
public/assets/index/js/index.js

@@ -0,0 +1,25 @@
+$(document).ready(function () {
+
+    //输入框聚焦
+    $('.input').focus(function () {
+        $(this).closest('.modelItem').addClass('active');
+    });
+
+    //输入框失焦
+    $('.input').blur(function () {
+        $(this).closest('.modelItem').removeClass('active');
+    });
+
+    //限制输入框不能输入空格跟汉字
+    $('.input').on('input', function () {
+        var inputValue = $(this).val();
+        var sanitizedValue = sanitizeInput(inputValue);
+        $(this).val(sanitizedValue);
+    });
+
+    function sanitizeInput(input) {
+        // 替换空格和汉字为空字符串
+        var sanitizedInput = input.replace(/\s+|[\u4e00-\u9fa5]+/g, '');
+        return sanitizedInput;
+    }
+});