From 477d38740ea84af7abf3eb51a3cf98d6b1e9db40 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期四, 16 十月 2025 09:35:03 +0800
Subject: [PATCH] 用户行为分析
---
manager/src/views/Main.vue | 2
manager/src/utils/filters.js | 8
manager/src/views/userAction/userAction.vue | 519 +++++++++++++++++++++++++++
manager/src/views/userAction/userShareAction.vue | 569 +++++++++++++++++++++++++++++
manager/src/api/userAction.js | 21 +
manager/src/views/order/order/orderDetail.vue | 2
6 files changed, 1,119 insertions(+), 2 deletions(-)
diff --git a/manager/src/api/userAction.js b/manager/src/api/userAction.js
new file mode 100644
index 0000000..f1103bc
--- /dev/null
+++ b/manager/src/api/userAction.js
@@ -0,0 +1,21 @@
+import service from "../libs/axios";
+
+
+
+
+//鑾峰彇鐢ㄦ埛鍋滅暀鍒楄〃
+export const userStayList = (params) =>{
+ return service({
+ url: "/lmk/action-record/userStayList",
+ method: "GET",
+ params: params
+ })
+}
+//鑾峰彇鐢ㄦ埛鍒嗕韩椤甸潰
+export const userShareList = (params) =>{
+ return service({
+ url: "/lmk/action-record/userShare",
+ method: "GET",
+ params: params
+ })
+}
diff --git a/manager/src/utils/filters.js b/manager/src/utils/filters.js
index 5855744..bb53ace 100644
--- a/manager/src/utils/filters.js
+++ b/manager/src/utils/filters.js
@@ -214,6 +214,14 @@
return mobile.replace(/(\d{3})(\d{4})(\d{4})/, '$1****$3')
}
+/**
+ * 鏃ユ湡鏍煎紡鍖栬緟鍔╁嚱鏁�
+ * @param {string} str
+ * @returns
+ */
+function padLeftZero(str) {
+ return ('00' + str).substr(str.length);
+}
export function formatDate(date, fmt) {
if (/(y+)/.test(fmt)) {
diff --git a/manager/src/views/Main.vue b/manager/src/views/Main.vue
index baab908..0b9b428 100644
--- a/manager/src/views/Main.vue
+++ b/manager/src/views/Main.vue
@@ -75,7 +75,7 @@
<div class="single-page-con" :style="{ 'top': setting.isUseTabsRouter ? '100px' : '60px', height: setting.isUseTabsRouter ? 'calc(100% - 110px)' : 'calc(100% - 70px)' }">
<div class="single-page">
<!-- <keep-alive :include="cachePage">-->
- <keep-alive :include="['orderList','fictitiousOrderList','CarPack','after-sale-order','member']">
+ <keep-alive :include="['orderList','fictitiousOrderList','CarPack','after-sale-order','member','userAction','userShareAction']">
<router-view></router-view>
</keep-alive>
<!-- </keep-alive>-->
diff --git a/manager/src/views/order/order/orderDetail.vue b/manager/src/views/order/order/orderDetail.vue
index 5245977..7682cce 100644
--- a/manager/src/views/order/order/orderDetail.vue
+++ b/manager/src/views/order/order/orderDetail.vue
@@ -817,7 +817,7 @@
console.log("to:",to.fullPath)
console.log("form:",from.fullPath)
// 姝g‘鎵撳嵃璺敱瀵硅薄鐨勬柟娉�
- if((from.fullPath === "/orderList"|| from.fullPath === "/fictitiousOrderList" ||from.fullPath === "/orderStatistics"||from.fullPath.includes( "/member-detail")) && to.fullPath.includes("/order-detail")){
+ if((from.fullPath === "/orderList"|| from.fullPath === "/fictitiousOrderList" ||from.fullPath === "/orderStatistics"||from.fullPath === "/userAction"||from.fullPath.includes( "/member-detail")) && to.fullPath.includes("/order-detail")){
this.sn = this.$route.query.sn;
this.getDataList();
this.getOrderPackage();
diff --git a/manager/src/views/userAction/userAction.vue b/manager/src/views/userAction/userAction.vue
new file mode 100644
index 0000000..c37daa8
--- /dev/null
+++ b/manager/src/views/userAction/userAction.vue
@@ -0,0 +1,519 @@
+<template>
+ <div class="wrapper">
+ <Card class="user-action-card">
+ <Row @keydown.enter.native="handleSearch">
+ <Form ref="searchForm" :model="searchForm" inline :label-width="80" style="width: 100%" class="search-form">
+ <Form-item label="鐢ㄦ埛鏄电О" prop="userName">
+ <Input type="text" v-model="searchForm.userName" placeholder="璇疯緭鍏ョ敤鎴锋樀绉�" clearable style="width: 200px" />
+ </Form-item>
+ <Form-item label="椤甸潰绫诲瀷" prop="pageCode">
+ <Select
+ v-model="searchForm.pageCode"
+ clearable
+ filterable
+ style="width: 200px"
+ placeholder="璇烽�夋嫨椤甸潰绫诲瀷">
+ <Option
+ v-for="item in pageTypeOptions"
+ :key="item.value"
+ :value="item.value"
+ :label="item.label">
+ {{ item.label }}
+ </Option>
+ </Select>
+ </Form-item>
+ <Form-item label="寮�濮嬫椂闂�" prop="beginDate">
+ <DatePicker
+ v-model="searchForm.beginDate"
+ type="datetime"
+ placeholder="璇烽�夋嫨寮�濮嬫椂闂�"
+ style="width: 200px">
+ </DatePicker>
+ </Form-item>
+ <Form-item label="缁撴潫鏃堕棿" prop="endDate">
+ <DatePicker
+ v-model="searchForm.endDate"
+ type="datetime"
+ placeholder="璇烽�夋嫨缁撴潫鏃堕棿"
+ style="width: 200px">
+ </DatePicker>
+ </Form-item>
+ <Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn">鎼滅储</Button>
+ <Button @click="handleReset" type="default" class="search-btn">閲嶇疆</Button>
+ </Form>
+ </Row>
+ <div class="table-container">
+ <Table
+ :loading="loading"
+ border
+ :columns="columns"
+ :data="data"
+ ref="table">
+ </Table>
+ </div>
+ <Row type="flex" justify="end" class="mt_10">
+ <Page
+ :current="searchForm.pageNumber"
+ :total="total"
+ :page-size="searchForm.pageSize"
+ @on-change="changePage"
+ @on-page-size-change="changePageSize"
+ :page-size-opts="[10, 20, 50]"
+ size="small"
+ show-total
+ show-elevator
+ show-sizer>
+ </Page>
+ </Row>
+ </Card>
+ </div>
+</template>
+
+<script>
+import { userStayList } from "@/api/userAction";
+import { formatDate } from "@/utils/filters";
+
+export default {
+ name: "userAction",
+ data() {
+ // 璁剧疆榛樿鏃堕棿鏀逛负鏈�杩�7澶�
+ const now = new Date();
+ const endTime = new Date(now);
+ endTime.setHours(23, 59, 59, 999);
+
+ // 寮�濮嬫椂闂翠负7澶╁墠锛堝寘鍚粖澶╋紝鎬诲叡7澶╋級
+ const startTime = new Date(now);
+ startTime.setDate(startTime.getDate() - 6);
+ startTime.setHours(0, 0, 0, 0);
+
+ console.log("榛樿寮�濮嬫椂闂�(鏈�杩�7澶�):", startTime);
+ console.log("榛樿缁撴潫鏃堕棿:", endTime);
+ console.log("寮�濮嬫椂闂寸被鍨�:", typeof startTime);
+ console.log("缁撴潫鏃堕棿绫诲瀷:", typeof endTime);
+
+ // 楠岃瘉鏃ユ湡鏍煎紡鍖栨槸鍚︽甯稿伐浣�
+ try {
+ const formattedStart = formatDate(startTime, 'yyyy-MM-dd hh:mm:ss');
+ const formattedEnd = formatDate(endTime, 'yyyy-MM-dd hh:mm:ss');
+ console.log("榛樿寮�濮嬫椂闂存牸寮忓寲缁撴灉:", formattedStart);
+ console.log("榛樿缁撴潫鏃堕棿鏍煎紡鍖栫粨鏋�:", formattedEnd);
+ } catch (e) {
+ console.error("鍒濆鍖栨椂鏃ユ湡鏍煎紡鍖栧嚭閿�:", e);
+ }
+
+ return {
+ loading: false, // 榛樿涓嶅姞杞�
+ searchForm: {
+ pageNumber: 1,
+ pageSize: 10,
+ userName: "",
+ pageCode: "",
+ beginDate: startTime,
+ endDate: endTime
+ },
+ // 椤甸潰绫诲瀷閫夐」锛堢敤浜庝笅鎷夋锛�
+ pageTypeOptions: [
+ { value: "RECOMMEND_VIDEO", label: "棣栭〉鎺ㄨ崘瑙嗛" },
+ { value: "HEALTH_VIDEO", label: "澶у仴搴疯棰�" },
+ { value: "KITCHEN_VIDEO", label: "绁炲帹瑙嗛" },
+ { value: "RECOMMEND_VIDEO_GOODS", label: "瑙嗛鎺ㄨ崘鍟嗗搧椤甸潰" },
+ { value: "RECOMMEND_VIDEO_LEFT_GOODS", label: "宸︽粦鎺ㄨ崘鍟嗗搧" },
+ { value: "RECOMMEND_VIDEO_RIGHT_VIDEO", label: "鍙虫粦瑙嗛椤甸潰" },
+ { value: "FILL_ORDER", label: "濉啓璁㈠崟" },
+ { value: "PAY_ORDER", label: "鏀粯璁㈠崟" },
+ { value: "PAY_SUCCESS", label: "鏀粯鎴愬姛" },
+ { value: "ORDER_LIST", label: "璁㈠崟鍒楄〃" },
+ { value: "ORDER_DETAIL", label: "璁㈠崟璇︽儏" },
+ { value: "PRIZE_DETAIL", label: "鎶藉娲诲姩" },
+ { value: "CART_LIST", label: "璐墿杞�" },
+ { value: "TBA_BAR_MY", label: "鎴戠殑椤甸潰" },
+ { value: "SHOPPING_SQUARE", label: "鍟嗗搧骞垮満" },
+ { value: "ACTIVITY_LIST", label: "娲诲姩鍒楄〃" },
+ { value: "ACTIVITY_DETAIL", label: "娲诲姩璇︽儏" },
+ { value: "PUBLISH_VIDEO", label: "瑙嗛鍙戝竷" },
+ { value: "SWIPER_GOODS", label: "婊戝姩鍟嗗搧" },
+ { value: "COUPON_CENTER", label: "棰嗗嵎涓績" },
+ { value: "MY_COUPON", label: "鎴戠殑浼樻儬鍗�" },
+ { value: "AFTER_SALE", label: "鍞悗鍒楄〃" },
+ { value: "APPLY_SALE", label: "鐢宠鍞悗" },
+ { value: "REFUND_ORDER", label: "閫�娆�/閫�璐�" },
+ { value: "GOODS_DETAILS", label: "鍟嗗搧璇︽儏椤甸潰" }
+ ],
+ columns: [
+ {
+ title: "鐢ㄦ埛鍚嶇О",
+ key: "userId",
+ minWidth: 120
+ },
+ {
+ title: "鐢ㄦ埛鏄电О",
+ key: "nickName",
+ minWidth: 100
+ },
+ {
+ title: "浼氳瘽ID",
+ key: "sessionId",
+ minWidth: 150
+ },
+ {
+ title: "椤甸潰绫诲瀷",
+ key: "pageCode",
+ minWidth: 150,
+ render: (h, params) => {
+ const pageCodes = {
+ "RECOMMEND_VIDEO": "棣栭〉鎺ㄨ崘瑙嗛",
+ "HEALTH_VIDEO": "澶у仴搴疯棰�",
+ "KITCHEN_VIDEO": "绁炲帹瑙嗛",
+ "RECOMMEND_VIDEO_GOODS": "瑙嗛鎺ㄨ崘鍟嗗搧椤甸潰",
+ "RECOMMEND_VIDEO_LEFT_GOODS": "宸︽粦鎺ㄨ崘鍟嗗搧",
+ "RECOMMEND_VIDEO_RIGHT_VIDEO": "鍙虫粦瑙嗛椤甸潰",
+ "FILL_ORDER": "濉啓璁㈠崟",
+ "PAY_ORDER": "鏀粯璁㈠崟",
+ "PAY_SUCCESS": "鏀粯鎴愬姛",
+ "ORDER_LIST": "璁㈠崟鍒楄〃",
+ "ORDER_DETAIL": "璁㈠崟璇︽儏",
+ "PRIZE_DETAIL": "鎶藉娲诲姩",
+ "CART_LIST": "璐墿杞�",
+ "TBA_BAR_MY": "鎴戠殑椤甸潰",
+ "SHOPPING_SQUARE": "鍟嗗搧骞垮満",
+ "ACTIVITY_LIST": "娲诲姩鍒楄〃",
+ "ACTIVITY_DETAIL": "娲诲姩璇︽儏",
+ "PUBLISH_VIDEO": "瑙嗛鍙戝竷",
+ "SWIPER_GOODS": "婊戝姩鍟嗗搧",
+ "COUPON_CENTER": "棰嗗嵎涓績",
+ "MY_COUPON": "鎴戠殑浼樻儬鍗�",
+ "AFTER_SALE": "鍞悗鍒楄〃",
+ "APPLY_SALE": "鐢宠鍞悗",
+ "REFUND_ORDER": "閫�娆�/閫�璐�",
+ "GOODS_DETAILS": "鍟嗗搧璇︽儏椤甸潰"
+ };
+ return h('span', pageCodes[params.row.pageCode] || params.row.pageCode);
+ }
+ },
+ {
+ title: "椤甸潰鍚嶇О",
+ key: "pageNameCn",
+ minWidth: 150
+ },
+ {
+ title: "杩涘叆鏃堕棿",
+ key: "enterTime",
+ minWidth: 160
+ },
+ {
+ title: "绂诲紑鏃堕棿",
+ key: "leaveTime",
+ minWidth: 160
+ },
+ {
+ title: "鍋滅暀鏃堕暱(绉�)",
+ key: "staySeconds",
+ minWidth: 120
+ },
+ {
+ title: "鎿嶄綔",
+ key: "action",
+ width: 150,
+ align: "center",
+ render: (h, params) => {
+ // 鍙湁褰撻〉闈㈢被鍨嬫槸鍟嗗搧璇︽儏椤甸潰鏃舵墠鏄剧ず璺宠浆鎸夐挳
+ if (params.row.pageCode === "GOODS_DETAILS" && params.row.pageParams) {
+ return h('div', [
+ h('Button', {
+ props: {
+ type: 'primary',
+ size: 'small'
+ },
+ on: {
+ click: () => {
+ this.goToGoodsDetail(params.row.pageParams);
+ }
+ }
+ }, '鏌ョ湅鍟嗗搧璇︽儏')
+ ]);
+ }
+ // 褰撻〉闈㈢被鍨嬫槸璁㈠崟璇︽儏椤甸潰鏃舵樉绀鸿烦杞寜閽�
+ if (params.row.pageCode === "ORDER_DETAIL" && params.row.pageParams) {
+ return h('div', [
+ h('Button', {
+ props: {
+ type: 'primary',
+ size: 'small'
+ },
+ on: {
+ click: () => {
+ this.goToOrderDetail(params.row.pageParams);
+ }
+ }
+ }, '鏌ョ湅璁㈠崟璇︽儏')
+ ]);
+ }
+ return h('span', '-');
+ }
+ }
+ ],
+ data: [],
+ total: 0
+ };
+ },
+ methods: {
+ // 鍒濆鍖栨暟鎹�
+ init() {
+ console.log("鎵цinit鏂规硶锛屽噯澶囧姞杞芥暟鎹�");
+ // 椤甸潰鍒濆鍖栨椂鐩存帴璋冪敤锛屾鏌ユ椂闂村弬鏁�
+ this.$nextTick(() => {
+ console.log("init鏂规硶涓殑nextTick鍥炶皟锛岃皟鐢╣etDataListWithoutValidation");
+ this.getDataListWithoutValidation();
+ });
+ },
+ // 鑾峰彇鏈�杩�7澶╃殑寮�濮嬫椂闂达紙鍖呭惈浠婂ぉ锛屾�诲叡7澶╋級
+ getDefaultBeginDate() {
+ const now = new Date();
+ const startTime = new Date(now);
+ startTime.setDate(startTime.getDate() - 6); // 7澶╁墠锛屽寘鍚粖澶�
+ startTime.setHours(0, 0, 0, 0);
+ return startTime;
+ },
+ // 鑾峰彇褰撳ぉ缁撴潫鏃堕棿
+ getDefaultEndDate() {
+ const now = new Date();
+ now.setHours(23, 59, 59, 999);
+ return now;
+ },
+ // 涓嶈繘琛岃〃鍗曢獙璇佺殑鏁版嵁鑾峰彇
+ getDataListWithoutValidation() {
+ this.loading = true;
+ console.log("寮�濮嬭姹傛暟鎹�:", this.searchForm);
+ console.log("寮�濮嬫椂闂村��:", this.searchForm.beginDate);
+ console.log("缁撴潫鏃堕棿鍊�:", this.searchForm.endDate);
+ console.log("寮�濮嬫椂闂寸被鍨�:", typeof this.searchForm.beginDate);
+ console.log("缁撴潫鏃堕棿绫诲瀷:", typeof this.searchForm.endDate);
+
+ // 妫�鏌ユ椂闂村弬鏁版槸鍚︿负绌�
+ if (!this.searchForm.beginDate) {
+ console.log("寮�濮嬫椂闂翠负绌�");
+ }
+ if (!this.searchForm.endDate) {
+ console.log("缁撴潫鏃堕棿涓虹┖");
+ }
+
+ // 澶勭悊鏃堕棿鏍煎紡锛屼娇鐢ㄦ纭殑鍙傛暟鍚嶇ОbeginDate鍜宔ndDate
+ const params = { ...this.searchForm };
+ if (params.beginDate) {
+ params.beginDate = this.formatDate(params.beginDate);
+ console.log("鏍煎紡鍖栧悗鐨勫紑濮嬫椂闂�:", params.beginDate);
+ } else {
+ this.loading = false;
+ this.$Message.error("寮�濮嬫椂闂翠笉鑳戒负绌�");
+ return;
+ }
+ if (params.endDate) {
+ params.endDate = this.formatDate(params.endDate);
+ console.log("鏍煎紡鍖栧悗鐨勭粨鏉熸椂闂�:", params.endDate);
+ } else {
+ this.loading = false;
+ this.$Message.error("缁撴潫鏃堕棿涓嶈兘涓虹┖");
+ return;
+ }
+
+ console.log("鏈�缁堣姹傚弬鏁�:", params);
+
+ userStayList(params).then(res => {
+ console.log("璇锋眰鎴愬姛:", res);
+ if (res.code === 200) {
+ this.data = res.data.records || [];
+ this.total = res.data.total || 0;
+ console.log("鏁版嵁鍔犺浇瀹屾垚锛岃褰曟暟:", this.data.length);
+ } else {
+ this.$Message.error(res.msg || "鑾峰彇鏁版嵁澶辫触");
+ console.error("鑾峰彇鏁版嵁澶辫触:", res.msg || "鏈煡閿欒");
+ }
+ }).catch(err => {
+ console.error("璇锋眰澶辫触:", err);
+ this.$Message.error("璇锋眰寮傚父: " + (err.message || "鏈煡閿欒"));
+ }).finally(() => {
+ // 纭繚鍦ㄤ换浣曟儏鍐典笅閮藉叧闂璴oading鐘舵��
+ this.loading = false;
+ console.log("璇锋眰瀹屾垚锛宭oading鐘舵�佸凡鍏抽棴");
+ });
+ },
+ // 甯﹁〃鍗曢獙璇佺殑鏁版嵁鑾峰彇
+ getDataList() {
+ this.$refs.searchForm.validate((valid) => {
+ if (valid) {
+ this.getDataListWithoutValidation();
+ } else {
+ this.loading = false; // 楠岃瘉澶辫触鏃朵篃瑕佸叧闂璴oading
+ this.$Message.error("璇锋鏌ヨ〃鍗曡緭鍏ユ槸鍚︽纭�");
+ }
+ });
+ },
+ // 鏍煎紡鍖栨棩鏈熸椂闂�
+ formatDate(date) {
+ if (!date) {
+ console.warn("鏃ユ湡鏍煎紡鍖栨椂浼犲叆浜嗙┖鍊�");
+ return "";
+ }
+ try {
+ const formattedDate = formatDate(new Date(date), 'yyyy-MM-dd hh:mm:ss');
+ console.log("鏃ユ湡鏍煎紡鍖栫粨鏋�:", formattedDate);
+ return formattedDate;
+ } catch (error) {
+ console.error("鏃ユ湡鏍煎紡鍖栧嚭閿�:", error);
+ // 濡傛灉鏍煎紡鍖栧嚭閿欙紝灏濊瘯浣跨敤鍙︿竴绉嶆柟寮�
+ try {
+ const d = new Date(date);
+ const year = d.getFullYear();
+ const month = ('0' + (d.getMonth() + 1)).slice(-2);
+ const day = ('0' + d.getDate()).slice(-2);
+ const hours = ('0' + d.getHours()).slice(-2);
+ const minutes = ('0' + d.getMinutes()).slice(-2);
+ const seconds = ('0' + d.getSeconds()).slice(-2);
+ const formatted = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+ console.log("澶囩敤鏃ユ湡鏍煎紡鍖栫粨鏋�:", formatted);
+ return formatted;
+ } catch (backupError) {
+ console.error("澶囩敤鏃ユ湡鏍煎紡鍖栦篃鍑洪敊:", backupError);
+ return "";
+ }
+ }
+ },
+ // 鏀瑰彉椤垫暟
+ changePage(page) {
+ this.searchForm.pageNumber = page;
+ this.getDataListWithoutValidation();
+ },
+ // 鏀瑰彉椤电爜
+ changePageSize(pageSize) {
+ this.searchForm.pageNumber = 1;
+ this.searchForm.pageSize = pageSize;
+ this.getDataListWithoutValidation();
+ },
+ // 鎼滅储
+ handleSearch() {
+ console.log("鎼滅储鎸夐挳琚偣鍑�");
+ this.searchForm.pageNumber = 1;
+ // 鐩存帴妫�鏌ユ椂闂村弬鏁帮紝涓嶄娇鐢ㄨ〃鍗曢獙璇�
+ console.log("寮�濮嬫悳绱紝妫�鏌ユ椂闂村弬鏁�");
+ // 妫�鏌ユ椂闂村弬鏁版槸鍚︿负绌�
+ if (!this.searchForm.beginDate || !this.searchForm.endDate) {
+ this.$Message.error("寮�濮嬫椂闂村拰缁撴潫鏃堕棿涓嶈兘涓虹┖");
+ return;
+ }
+ this.getDataListWithoutValidation();
+ },
+ // 閲嶇疆
+ handleReset() {
+ this.searchForm.pageNumber = 1;
+ this.searchForm.pageSize = 10;
+ this.searchForm.userName = "";
+ this.searchForm.pageCode = "";
+ // 浣跨敤姝g‘鐨勫弬鏁板悕绉板拰鏂规硶
+ this.searchForm.beginDate = this.getDefaultBeginDate();
+ this.searchForm.endDate = this.getDefaultEndDate();
+ // 閲嶇疆鍚庨噸鏂板姞杞芥暟鎹�
+ this.$nextTick(() => {
+ this.getDataListWithoutValidation();
+ });
+ },
+ // 璺宠浆鍒板晢鍝佽鎯呴〉闈�
+ goToGoodsDetail(pageParams) {
+ try {
+ // 瑙f瀽pageParams JSON瀛楃涓�
+ const params = JSON.parse(pageParams);
+ console.log("瑙f瀽鍚庣殑鍙傛暟:", params);
+
+ // 妫�鏌ュ繀瑕佸弬鏁�
+ if (!params.id || !params.goodsId) {
+ this.$Message.error("鍟嗗搧鍙傛暟涓嶅畬鏁�");
+ return;
+ }
+
+ // 璺宠浆鍒板晢鍝佽鎯呴〉闈紝浼犻�掑弬鏁�
+ this.$router.push({
+ name: "goods-detail",
+ query: {
+ id: params.goodsId
+ }
+ });
+ } catch (error) {
+ console.error("瑙f瀽pageParams鍑洪敊:", error);
+ this.$Message.error("鍙傛暟瑙f瀽澶辫触");
+ }
+ },
+ // 璺宠浆鍒拌鍗曡鎯呴〉闈�
+ goToOrderDetail(pageParams) {
+ try {
+ // 瑙f瀽pageParams JSON瀛楃涓�
+ const params = JSON.parse(pageParams);
+ console.log("瑙f瀽鍚庣殑鍙傛暟:", params);
+
+ // 妫�鏌ュ繀瑕佸弬鏁�
+ if (!params.sn) {
+ this.$Message.error("璁㈠崟鍙傛暟涓嶅畬鏁�");
+ return;
+ }
+
+ // 璺宠浆鍒拌鍗曡鎯呴〉闈紝浼犻�掕鍗曞彿鍙傛暟
+ this.$router.push({
+ name: "order-detail",
+ query: {
+ sn: params.sn
+ }
+ });
+ } catch (error) {
+ console.error("瑙f瀽pageParams鍑洪敊:", error);
+ this.$Message.error("鍙傛暟瑙f瀽澶辫触");
+ }
+ }
+ },
+ mounted() {
+ console.log("缁勪欢宸叉寕杞斤紝寮�濮嬪垵濮嬪寲鏁版嵁");
+ this.$nextTick(() => {
+ console.log("nextTick鍥炶皟锛岃皟鐢╥nit鏂规硶");
+ this.init();
+ });
+ }
+};
+</script>
+
+<style scoped>
+.search-btn {
+ margin-right: 10px;
+}
+.mt_10 {
+ margin-top: 10px;
+}
+
+/* 鐢ㄦ埛琛屼负鍗$墖鏍峰紡 */
+.user-action-card {
+ height: calc(100vh - 100px);
+ display: flex;
+ flex-direction: column;
+}
+
+/* 琛ㄦ牸瀹瑰櫒鏍峰紡 */
+.table-container {
+ flex: 1;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+}
+
+/* 琛ㄦ牸鏍峰紡 */
+.table-container /deep/ .ivu-table-wrapper {
+ flex: 1;
+ overflow-y: auto;
+ height: 100%;
+}
+
+/* 鎼滅储琛ㄥ崟鏍峰紡 */
+.search-form {
+ padding: 16px 0;
+}
+
+/* 鍒嗛〉鏍峰紡 */
+.mt_10 {
+ padding: 10px 0;
+}
+</style>
diff --git a/manager/src/views/userAction/userShareAction.vue b/manager/src/views/userAction/userShareAction.vue
new file mode 100644
index 0000000..6620611
--- /dev/null
+++ b/manager/src/views/userAction/userShareAction.vue
@@ -0,0 +1,569 @@
+<template>
+ <div class="wrapper">
+ <Card class="user-action-card">
+ <Row @keydown.enter.native="handleSearch">
+ <Form ref="searchForm" :model="searchForm" inline :label-width="80" style="width: 100%" class="search-form">
+ <Form-item label="鐢ㄦ埛鏄电О" prop="userName">
+ <Input type="text" v-model="searchForm.userName" placeholder="璇疯緭鍏ョ敤鎴锋樀绉�" clearable style="width: 200px" />
+ </Form-item>
+ <Form-item label="椤甸潰绫诲瀷" prop="pageCode">
+ <Select
+ v-model="searchForm.pageCode"
+ clearable
+ filterable
+ style="width: 200px"
+ placeholder="璇烽�夋嫨椤甸潰绫诲瀷">
+ <Option
+ v-for="item in pageTypeOptions"
+ :key="item.value"
+ :value="item.value"
+ :label="item.label">
+ {{ item.label }}
+ </Option>
+ </Select>
+ </Form-item>
+ <Form-item label="寮�濮嬫椂闂�" prop="beginDate">
+ <DatePicker
+ v-model="searchForm.beginDate"
+ type="datetime"
+ placeholder="璇烽�夋嫨寮�濮嬫椂闂�"
+ style="width: 200px">
+ </DatePicker>
+ </Form-item>
+ <Form-item label="缁撴潫鏃堕棿" prop="endDate">
+ <DatePicker
+ v-model="searchForm.endDate"
+ type="datetime"
+ placeholder="璇烽�夋嫨缁撴潫鏃堕棿"
+ style="width: 200px">
+ </DatePicker>
+ </Form-item>
+ <Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn">鎼滅储</Button>
+ <Button @click="handleReset" type="default" class="search-btn">閲嶇疆</Button>
+ </Form>
+ </Row>
+ <div class="table-container">
+ <Table
+ :loading="loading"
+ border
+ :columns="columns"
+ :data="data"
+ ref="table">
+ </Table>
+ </div>
+ <Row type="flex" justify="end" class="mt_10">
+ <Page
+ :current="searchForm.pageNumber"
+ :total="total"
+ :page-size="searchForm.pageSize"
+ @on-change="changePage"
+ @on-page-size-change="changePageSize"
+ :page-size-opts="[10, 20, 50]"
+ size="small"
+ show-total
+ show-elevator
+ show-sizer>
+ </Page>
+ </Row>
+ </Card>
+
+ <!-- 瑙嗛璇︽儏寮圭獥 -->
+ <Modal
+ v-model="videoDetailShow"
+ :title="videoDetailTitle"
+ width="800"
+ :mask-closable="false"
+ @on-cancel="closeVideoDetail">
+ <div class="video-info" v-if="currentVideoDetail && !videoLoading">
+ <div class="video-basic-info">
+ <h3>{{ currentVideoDetail.title }}</h3>
+ </div>
+ <div style="margin: 15px 0; height: 1px; background-color: #e8eaec;"></div>
+ </div>
+ <div class="video-wrapper">
+ <video
+ v-if="videoDetailUrl"
+ :src="videoDetailUrl"
+ autoplay
+ controls
+ style="width: 100%; height: 450px"
+ />
+ <div v-else style="text-align: center; padding: 50px 0;">
+ <Spin v-if="videoLoading" fix />
+ <div v-else>鏆傛棤瑙嗛鍐呭</div>
+ </div>
+ </div>
+ <div slot="footer">
+ <Button type="text" @click="closeVideoDetail">鍏抽棴</Button>
+ </div>
+ </Modal>
+ </div>
+</template>
+
+<script>
+import { userShareList } from "@/api/userAction";
+import { formatDate } from "@/utils/filters";
+import { getVideoById } from "@/api/video";
+import { getFilePreview } from "@/api/file";
+
+export default {
+ name: "userShareAction",
+ data() {
+ // 璁剧疆榛樿鏃堕棿鏀逛负鏈�杩�7澶�
+ const now = new Date();
+ const endTime = new Date(now);
+ endTime.setHours(23, 59, 59, 999);
+
+ // 寮�濮嬫椂闂翠负7澶╁墠锛堝寘鍚粖澶╋紝鎬诲叡7澶╋級
+ const startTime = new Date(now);
+ startTime.setDate(startTime.getDate() - 6);
+ startTime.setHours(0, 0, 0, 0);
+
+ return {
+ loading: false, // 榛樿涓嶅姞杞�
+ searchForm: {
+ pageNumber: 1,
+ pageSize: 10,
+ userName: "",
+ pageCode: "",
+ beginDate: startTime,
+ endDate: endTime
+ },
+ // 椤甸潰绫诲瀷閫夐」锛堢敤浜庝笅鎷夋锛�
+ pageTypeOptions: [
+ { value: "RECOMMEND_VIDEO", label: "棣栭〉鎺ㄨ崘瑙嗛" },
+ { value: "SHOPPING_SQUARE", label: "鍟嗗搧骞垮満" },
+ { value: "GOODS_DETAILS", label: "鍟嗗搧璇︽儏椤甸潰" }
+ ],
+ // 瑙嗛璇︽儏寮圭獥鐩稿叧鏁版嵁
+ videoDetailShow: false,
+ videoDetailTitle: '',
+ videoDetailUrl: '',
+ videoLoading: false,
+ currentVideoDetail: null, // 褰撳墠瑙嗛璇︽儏鏁版嵁
+ columns: [
+ {
+ title: "鐢ㄦ埛鏄电О",
+ key: "nickName",
+ minWidth: 120
+ },
+ {
+ title: "椤甸潰绫诲瀷",
+ key: "pageCode",
+ minWidth: 150,
+ render: (h, params) => {
+ const pageCodes = {
+ "RECOMMEND_VIDEO": "棣栭〉鎺ㄨ崘瑙嗛",
+ "HEALTH_VIDEO": "澶у仴搴疯棰�",
+ "KITCHEN_VIDEO": "绁炲帹瑙嗛",
+ "RECOMMEND_VIDEO_GOODS": "瑙嗛鎺ㄨ崘鍟嗗搧椤甸潰",
+ "RECOMMEND_VIDEO_LEFT_GOODS": "宸︽粦鎺ㄨ崘鍟嗗搧",
+ "RECOMMEND_VIDEO_RIGHT_VIDEO": "鍙虫粦瑙嗛椤甸潰",
+ "FILL_ORDER": "濉啓璁㈠崟",
+ "PAY_ORDER": "鏀粯璁㈠崟",
+ "PAY_SUCCESS": "鏀粯鎴愬姛",
+ "ORDER_LIST": "璁㈠崟鍒楄〃",
+ "ORDER_DETAIL": "璁㈠崟璇︽儏",
+ "PRIZE_DETAIL": "鎶藉娲诲姩",
+ "CART_LIST": "璐墿杞�",
+ "TBA_BAR_MY": "鎴戠殑椤甸潰",
+ "SHOPPING_SQUARE": "鍟嗗搧骞垮満",
+ "ACTIVITY_LIST": "娲诲姩鍒楄〃",
+ "ACTIVITY_DETAIL": "娲诲姩璇︽儏",
+ "PUBLISH_VIDEO": "瑙嗛鍙戝竷",
+ "SWIPER_GOODS": "婊戝姩鍟嗗搧",
+ "COUPON_CENTER": "棰嗗嵎涓績",
+ "MY_COUPON": "鎴戠殑浼樻儬鍗�",
+ "AFTER_SALE": "鍞悗鍒楄〃",
+ "APPLY_SALE": "鐢宠鍞悗",
+ "REFUND_ORDER": "閫�娆�/閫�璐�",
+ "GOODS_DETAILS": "鍟嗗搧璇︽儏椤甸潰"
+ };
+ return h('span', pageCodes[params.row.pageCode] || params.row.pageCode);
+ }
+ },
+ {
+ title: "鍒嗕韩鏃堕棿",
+ key: "createTime",
+ minWidth: 160
+ },
+ {
+ title: "鎿嶄綔",
+ key: "action",
+ width: 150,
+ align: "center",
+ render: (h, params) => {
+ // 鍙湁褰撻〉闈㈢被鍨嬫槸鍟嗗搧璇︽儏椤甸潰鏃舵墠鏄剧ず璺宠浆鎸夐挳
+ if (params.row.pageCode === "GOODS_DETAILS") {
+ return h('div', [
+ h('Button', {
+ props: {
+ type: 'primary',
+ size: 'small'
+ },
+ on: {
+ click: () => {
+ this.goToGoodsDetail(params.row.shareOption);
+ }
+ }
+ }, '鏌ョ湅鍟嗗搧璇︽儏')
+ ]);
+ }
+ // 褰撻〉闈㈢被鍨嬫槸鎺ㄨ崘瑙嗛椤甸潰鏃舵樉绀鸿烦杞寜閽�
+ if (params.row.pageCode === "RECOMMEND_VIDEO") {
+ // 妫�鏌ュ弬鏁版槸鍚﹀畬鏁达紝濡傛灉瀹屾暣鎵嶆樉绀烘煡鐪嬫寜閽�
+ if (this.canViewVideoDetail(params.row.shareOption)) {
+ return h('div', [
+ h('Button', {
+ props: {
+ type: 'primary',
+ size: 'small'
+ },
+ on: {
+ click: () => {
+ // 鏌ョ湅瑙嗛璇︽儏
+ this.viewVideoDetail(params.row);
+ }
+ }
+ }, '鏌ョ湅瑙嗛璇︽儏')
+ ]);
+ }
+ }
+ return h('span', '-');
+ }
+ }
+ ],
+ data: [],
+ total: 0
+ };
+ },
+ methods: {
+ // 鍒濆鍖栨暟鎹�
+ init() {
+ this.$nextTick(() => {
+ this.getDataListWithoutValidation();
+ });
+ },
+ // 鑾峰彇鏈�杩�7澶╃殑寮�濮嬫椂闂达紙鍖呭惈浠婂ぉ锛屾�诲叡7澶╋級
+ getDefaultBeginDate() {
+ const now = new Date();
+ const startTime = new Date(now);
+ startTime.setDate(startTime.getDate() - 6); // 7澶╁墠锛屽寘鍚粖澶�
+ startTime.setHours(0, 0, 0, 0);
+ return startTime;
+ },
+ // 鑾峰彇褰撳ぉ缁撴潫鏃堕棿
+ getDefaultEndDate() {
+ const now = new Date();
+ now.setHours(23, 59, 59, 999);
+ return now;
+ },
+ // 涓嶈繘琛岃〃鍗曢獙璇佺殑鏁版嵁鑾峰彇
+ getDataListWithoutValidation() {
+ this.loading = true;
+
+ // 澶勭悊鏃堕棿鏍煎紡
+ const params = { ...this.searchForm };
+ if (params.beginDate) {
+ params.beginDate = this.formatDate(params.beginDate);
+ } else {
+ this.loading = false;
+ this.$Message.error("寮�濮嬫椂闂翠笉鑳戒负绌�");
+ return;
+ }
+ if (params.endDate) {
+ params.endDate = this.formatDate(params.endDate);
+ } else {
+ this.loading = false;
+ this.$Message.error("缁撴潫鏃堕棿涓嶈兘涓虹┖");
+ return;
+ }
+
+ userShareList(params).then(res => {
+ if (res.code === 200) {
+ this.data = res.data.records || [];
+ this.total = res.data.total || 0;
+ } else {
+ this.$Message.error(res.msg || "鑾峰彇鏁版嵁澶辫触");
+ }
+ }).catch(err => {
+ console.error("璇锋眰澶辫触:", err);
+ this.$Message.error("璇锋眰寮傚父: " + (err.message || "鏈煡閿欒"));
+ }).finally(() => {
+ this.loading = false;
+ });
+ },
+ // 甯﹁〃鍗曢獙璇佺殑鏁版嵁鑾峰彇
+ getDataList() {
+ this.$refs.searchForm.validate((valid) => {
+ if (valid) {
+ this.getDataListWithoutValidation();
+ } else {
+ this.loading = false;
+ this.$Message.error("璇锋鏌ヨ〃鍗曡緭鍏ユ槸鍚︽纭�");
+ }
+ });
+ },
+ // 鏍煎紡鍖栨棩鏈熸椂闂�
+ formatDate(date) {
+ if (!date) {
+ return "";
+ }
+ try {
+ const formattedDate = formatDate(new Date(date), 'yyyy-MM-dd hh:mm:ss');
+ return formattedDate;
+ } catch (error) {
+ // 濡傛灉鏍煎紡鍖栧嚭閿欙紝灏濊瘯浣跨敤鍙︿竴绉嶆柟寮�
+ try {
+ const d = new Date(date);
+ const year = d.getFullYear();
+ const month = ('0' + (d.getMonth() + 1)).slice(-2);
+ const day = ('0' + d.getDate()).slice(-2);
+ const hours = ('0' + d.getHours()).slice(-2);
+ const minutes = ('0' + d.getMinutes()).slice(-2);
+ const seconds = ('0' + d.getSeconds()).slice(-2);
+ const formatted = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+ return formatted;
+ } catch (backupError) {
+ return "";
+ }
+ }
+ },
+ // 鏀瑰彉椤垫暟
+ changePage(page) {
+ this.searchForm.pageNumber = page;
+ this.getDataListWithoutValidation();
+ },
+ // 鏀瑰彉椤电爜
+ changePageSize(pageSize) {
+ this.searchForm.pageNumber = 1;
+ this.searchForm.pageSize = pageSize;
+ this.getDataListWithoutValidation();
+ },
+ // 鎼滅储
+ handleSearch() {
+ this.searchForm.pageNumber = 1;
+ // 妫�鏌ユ椂闂村弬鏁版槸鍚︿负绌�
+ if (!this.searchForm.beginDate || !this.searchForm.endDate) {
+ this.$Message.error("寮�濮嬫椂闂村拰缁撴潫鏃堕棿涓嶈兘涓虹┖");
+ return;
+ }
+ this.getDataListWithoutValidation();
+ },
+ // 閲嶇疆
+ handleReset() {
+ this.searchForm.pageNumber = 1;
+ this.searchForm.pageSize = 10;
+ this.searchForm.userName = "";
+ this.searchForm.pageCode = "";
+ this.searchForm.beginDate = this.getDefaultBeginDate();
+ this.searchForm.endDate = this.getDefaultEndDate();
+ this.$nextTick(() => {
+ this.getDataListWithoutValidation();
+ });
+ },
+
+ // 妫�鏌ユ槸鍚﹀彲浠ユ煡鐪嬭棰戣鎯�
+ canViewVideoDetail(shareOption) {
+ try {
+ const params = JSON.parse(shareOption);
+ return params && params.videoId;
+ } catch (error) {
+ console.error("瑙f瀽瑙嗛鍙傛暟鍑洪敊:", error);
+ return false;
+ }
+ },
+
+ // 鏌ョ湅瑙嗛璇︽儏
+ viewVideoDetail(row) {
+ try {
+ // 瑙f瀽shareOption鑾峰彇瑙嗛ID
+ const params = JSON.parse(row.shareOption);
+ const videoId = params.videoId;
+
+ if (!videoId) {
+ this.$Message.error("瑙嗛鍙傛暟涓嶅畬鏁�");
+ return;
+ }
+
+ // 鏄剧ず寮圭獥骞惰缃姞杞界姸鎬�
+ this.videoDetailShow = true;
+ this.videoDetailTitle = "瑙嗛璇︽儏";
+ this.videoLoading = true;
+ this.videoDetailUrl = '';
+ this.currentVideoDetail = null;
+
+ // 鑾峰彇瑙嗛璇︽儏
+ getVideoById(videoId).then(res => {
+ if (res.code === 200 && res.data) {
+ const videoData = res.data;
+ // 淇濆瓨瑙嗛璇︽儏鏁版嵁
+ this.currentVideoDetail = videoData;
+
+ // 鑾峰彇瑙嗛棰勮鍦板潃
+ if (videoData.videoFileKey) {
+ getFilePreview(videoData.videoFileKey).then(previewRes => {
+ if (previewRes.code === 200) {
+ this.videoDetailUrl = previewRes.data;
+ } else {
+ this.$Message.error("鑾峰彇瑙嗛鍦板潃澶辫触");
+ }
+ }).catch(err => {
+ console.error("鑾峰彇瑙嗛棰勮鍦板潃澶辫触:", err);
+ this.$Message.error("鑾峰彇瑙嗛鍦板潃澶辫触");
+ }).finally(() => {
+ this.videoLoading = false;
+ });
+ } else {
+ this.videoLoading = false;
+ this.$Message.info("璇ヨ棰戞殏鏃犲唴瀹�");
+ }
+ } else {
+ this.videoLoading = false;
+ this.$Message.error("鑾峰彇瑙嗛璇︽儏澶辫触");
+ }
+ }).catch(err => {
+ console.error("鑾峰彇瑙嗛璇︽儏澶辫触:", err);
+ this.videoLoading = false;
+ this.$Message.error("鑾峰彇瑙嗛璇︽儏澶辫触");
+ });
+ } catch (error) {
+ console.error("瑙f瀽瑙嗛鍙傛暟鍑洪敊:", error);
+ this.videoLoading = false;
+ this.$Message.error("瑙嗛鍙傛暟瑙f瀽澶辫触");
+ }
+ },
+
+ // 鏍煎紡鍖栬棰戞椂闀�
+ formatVideoDuration(seconds) {
+ if (isNaN(seconds) || seconds < 0) return '0绉�';
+
+ const mins = Math.floor(seconds / 60);
+ const secs = seconds % 60;
+
+ if (mins === 0) return `${secs}绉抈;
+ if (secs === 0) return `${mins}鍒哷;
+
+ return `${mins}鍒�${secs}绉抈;
+ },
+
+ // 鍏抽棴瑙嗛璇︽儏寮圭獥
+ closeVideoDetail() {
+ this.videoDetailShow = false;
+ this.videoDetailTitle = '';
+ this.videoDetailUrl = '';
+ this.videoLoading = false;
+ this.currentVideoDetail = null;
+ },
+
+ // 璺宠浆鍒板晢鍝佽鎯呴〉闈�
+ goToGoodsDetail(shareOption) {
+ try {
+ // 瑙f瀽shareOption JSON瀛楃涓�
+ const params = JSON.parse(shareOption);
+
+ // 妫�鏌ュ繀瑕佸弬鏁�
+ if (!params.goodsId) {
+ this.$Message.error("鍟嗗搧鍙傛暟涓嶅畬鏁�");
+ return;
+ }
+
+ // 璺宠浆鍒板晢鍝佽鎯呴〉闈紝浼犻�掑弬鏁�
+ this.$router.push({
+ name: "goods-detail",
+ query: {
+ id: params.goodsId
+ }
+ });
+ } catch (error) {
+ console.error("瑙f瀽shareOption鍑洪敊:", error);
+ this.$Message.error("鍙傛暟瑙f瀽澶辫触");
+ }
+ }
+ },
+ mounted() {
+ this.$nextTick(() => {
+ this.init();
+ });
+ }
+};
+</script>
+
+<style scoped>
+.search-btn {
+ margin-right: 10px;
+}
+.mt_10 {
+ margin-top: 10px;
+}
+
+/* 鐢ㄦ埛琛屼负鍗$墖鏍峰紡 */
+.user-action-card {
+ height: calc(100vh - 100px);
+ display: flex;
+ flex-direction: column;
+}
+
+/* 琛ㄦ牸瀹瑰櫒鏍峰紡 */
+.table-container {
+ flex: 1;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+}
+
+/* 琛ㄦ牸鏍峰紡 */
+.table-container /deep/ .ivu-table-wrapper {
+ flex: 1;
+ overflow-y: auto;
+ height: 100%;
+}
+
+/* 鎼滅储琛ㄥ崟鏍峰紡 */
+.search-form {
+ padding: 16px 0;
+}
+
+/* 鍒嗛〉鏍峰紡 */
+.mt_10 {
+ padding: 10px 0;
+}
+
+/* 瑙嗛瀹瑰櫒鏍峰紡 */
+.video-wrapper {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ min-height: 450px;
+}
+
+/* 瑙嗛淇℃伅鏍峰紡 */
+.video-info {
+ padding: 10px 0;
+}
+
+.video-basic-info h3 {
+ margin-bottom: 15px;
+ color: #333;
+}
+
+.info-item {
+ margin-bottom: 8px;
+ display: flex;
+ align-items: center;
+}
+
+.label {
+ font-weight: bold;
+ color: #666;
+ min-width: 60px;
+}
+
+.value {
+ color: #333;
+}
+
+.ivu-tag {
+ margin-right: 5px;
+}
+</style>
--
Gitblit v1.8.0