Pārlūkot izejas kodu

浏览历史完成

赵启卫 2 gadi atpakaļ
vecāks
revīzija
dd8ee87871

+ 1 - 1
application/config.php

xqd
@@ -20,7 +20,7 @@ return [
     // 应用调试模式
     'app_debug' => true,
     // 应用Trace
-    'app_trace' => false,
+    'app_trace' => true,
     // 应用模式状态
     'app_status' => '',
     // 是否支持多模块

+ 27 - 0
application/wap/controller/My.php

xqd xqd
@@ -13,6 +13,8 @@ namespace app\wap\controller;
 
 use Api\Express;
 use app\wap\model\special\SpecialRecord;
+use app\wap\model\special\SpecialLog;
+use app\wap\model\special\SpecialSource;
 use app\wap\model\special\SpecialRelation;
 use app\wap\model\user\SmsCode;
 use app\wap\model\store\StoreOrderCartInfo;
@@ -466,4 +468,29 @@ class My extends AuthController
     {
         return $this->fetch();
     }
+
+    /**
+     * 课程浏览历史
+     */
+    
+    public function special_log($page = 1, $limit = 20, $op = '') {
+        if ($op == 'list') {
+            $model = SpecialLog::alias('sl')->where('sl.mid', $this->uid)->page((int)$page, (int)$limit);
+            $model = $model->join('Special s', 's.id = sl.sid');
+            $model = $model->join('specialSubject ss', 's.subject_id = ss.id');
+            $orderList = $model->order('sl.add_time DESC')->field('s.*, sl.add_time as log_time, ss.name as subject_name')->select();
+            $orderList = count($orderList) > 0 ? $orderList->toArray() : [];
+            foreach ($orderList as &$item) {
+                if (!isset($item['money'])) $item['money'] = 0;
+                $item['money'] = (float)$item['money'];
+                $item['image'] = get_oss_process($item['image'], 0);
+                $item['count'] = 0;
+                $specialSourceId = SpecialSource::getSpecialSource($item['id']);
+                if ($specialSourceId) $item['count'] = count($specialSourceId);
+                else $item['count'] = 0;
+            }
+            return JsonService::successful($orderList);
+        }
+        return $this->fetch();
+    }
 }

+ 14 - 0
application/wap/controller/Special.php

xqd xqd
@@ -32,6 +32,7 @@ use app\wap\model\special\SpecialWatch;
 use app\wap\model\special\SpecialReply;
 use app\wap\model\special\SpecialExchange;
 use app\wap\model\special\SpecialBatch;
+use app\wap\model\special\SpecialLog;
 use app\wap\model\store\StoreCart;
 use app\wap\model\store\StoreOrder;
 use app\wap\model\store\StorePink;
@@ -163,6 +164,19 @@ class Special extends AuthController
     public function details($id = 0, $pinkId = 0, $gift_uid = 0, $gift_order_id = null, $link_pay_uid = 0, $partake = 0, $gift = 0, $link_pay = 0)
     {
         if (!$id) $this->failed('缺少参数,无法访问', Url::build('index/index'));
+        //leozhao add  课程记录
+        if ($this->uid) {
+            $log = SpecialLog::where(['sid' => $id, 'mid' => $this->uid])->find();
+            if ($log) {
+                $log->add_time = time();
+                $log->save();
+            } else {
+                $specialLog = new SpecialLog(); 
+                $data = ['sid' => $id, 'mid' => $this->uid, 'add_time' => time()];
+                $specialLog->data($data)->save();
+            }
+        }
+        //leozhao add  课程记录
         if ($gift_uid && $gift_order_id) {
             if ($gift_uid == $this->uid) $this->failed('您不能领取自己的礼物', Url::build('special/grade_list'));
             if (!User::get($gift_uid)) $this->failed('赠送礼物的用户不存在', Url::build('my/my_gift'));

+ 23 - 0
application/wap/model/special/SpecialLog.php

xqd
@@ -0,0 +1,23 @@
+<?php
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+
+namespace app\wap\model\special;
+
+use basic\ModelBasic;
+use traits\ModelTrait;
+
+/**访问日志
+ * Class SpecialLog
+ * @package app\wap\model\special
+ */
+class SpecialLog extends ModelBasic{
+    use ModelTrait;
+}

+ 130 - 0
application/wap/view/first/my/special_log.html

xqd
@@ -0,0 +1,130 @@
+<!-- +---------------------------------------------------------------------- -->
+<!-- | CRMEB [ CRMEB赋能开发者,助力企业发展 ] -->
+<!-- +---------------------------------------------------------------------- -->
+<!-- | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. -->
+<!-- +---------------------------------------------------------------------- -->
+<!-- | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 -->
+<!-- +---------------------------------------------------------------------- -->
+<!-- | Author: CRMEB Team <admin@crmeb.com> -->
+<!-- +---------------------------------------------------------------------- -->
+{extend name="public/container"}
+{block name="title"}浏览记录{/block}
+{block name="head"}
+<style>
+    body {
+        background: #F5F5F5;
+    }
+    .price-wrap {
+        display: flex;
+        align-items: center;
+        font-size: .24rem;
+        line-height: .33rem;
+        color: #DC9845;
+    }
+    .price-wrap .price {
+        flex: 1;
+        font-weight: bold;
+        font-size: .24rem;
+        line-height: .45rem;
+        color: #DC9845;
+    }
+    .price-wrap .price span {
+        font-size: .32rem;
+    }
+    .activity-list li > div > div > div:last-child {
+        font-weight: normal;
+    }
+    .activity-list .tab div{text-align: left; padding-left: 10px;}
+</style>
+{/block}
+{block name="content"}
+<div class="activity-list" v-cloak id="app">
+    <div class="tab">
+        <div>浏览过的课程</div>
+    </div>
+    <div class="content">
+        <ul v-if="activityList.length">
+            <li v-for="(item, index) in activityList" :key="index" @click="activityDetails(item.order_id)">
+                <div>
+                    <div>
+                        <img :src="item.image" alt="">
+                    </div>
+                    <div>
+                        <div>{{ item.title }}</div>
+                        <div>{{ item.subject_name }}</div>
+                        <div class="price-wrap">
+                            <div class="price">¥<span>{{ item.money }}</span></div>
+                            <div>共{{ item.count }}节</div>
+                        </div>
+                    </div>
+                </div>
+            </li>
+        </ul>
+        <div v-if="!activityList.length && loadend" class="empty">
+            <img src="{__WAP_PATH}zsff/images/empty.png" alt="暂无数据">
+            <div>暂无数据</div>
+        </div>
+    </div>
+    <quick-menu></quick-menu>
+</div>
+{/block}
+{block name="foot"}
+<script>
+    require(['vue', 'store', 'helper', '{__WAP_PATH}zsff/js/quick.js'], function (Vue, store, $h) {
+        var app = new Vue({
+            el: '#app',
+            data: {
+                navs: ['全部', '待核销', '已核销'],
+                navActive: 0,
+                activityList: [],
+                loading: false,
+                loadend: false,
+                page: 1,
+                limit: 20,
+                loadTitle:''
+            },
+            mounted: function () {
+                this.geLogList();
+                this.$nextTick(function () {
+                    this.init();
+                });
+            },
+            methods: {
+                init: function () {
+                    var that = this;
+                    window.addEventListener('scroll', function () {
+                        var clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
+                            scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight,
+                            scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
+                        if (clientHeight + scrollTop >= scrollHeight) {
+                            that.geLogList();
+                        }
+                    });
+                },
+                activityDetails: function (order_id) {
+                    return window.location.href=$h.U({ c: 'my', a: 'sign_my_order', q: {order_id: order_id } });
+                },
+                // 获取历史列表
+                geLogList: function () {
+                    var that = this;
+                    if (that.loading) return;
+                    if (that.loadend) return;
+                    that.loading = true;
+                    store.baseGet($h.U({ c: 'my', a: 'special_log', p: { page: that.page, limit: that.limit, op:'list' } }), function (res) {
+                        var list = res.data.data;
+                        that.activityList.push.apply(that.activityList, list);
+                        that.loadend = list.length < that.limit;
+                        that.loadTitle = that.loadend ? '已全部加载完' : '上拉加载更多';
+                        that.page = that.page + 1;
+                        that.loading = false;
+                        that.$set(this, 'activityList', that.activityList);
+                    }, function (res) {
+                        that.loadTitle = '上拉加载更多';
+                        that.loading = false;
+                    });
+                }
+            }
+        });
+    });
+</script>
+{/block}

BIN
public/public/qrcode/su47495088.png