friendCouponDetail.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <!-- 好友优惠券 - 详情页面 -->
  3. <div class="table-box" style="width: 100%; min-height: 100%; background-color: white">
  4. <div class="header">
  5. <el-button @click="goBack"> 返回 </el-button>
  6. <h2 class="title">好友优惠券详情</h2>
  7. </div>
  8. <div class="content">
  9. <!-- 左侧内容区域 -->
  10. <div class="contentLeft">
  11. <!-- 基础信息模块 -->
  12. <div class="model">
  13. <h3 style="font-weight: bold">基础信息:</h3>
  14. <!-- 店铺名称 -->
  15. <div class="detail-item">
  16. <div class="detail-label">店铺名称</div>
  17. <div class="detail-value">
  18. {{ couponModel.name || "--" }}
  19. </div>
  20. </div>
  21. <!-- 优惠券名称 -->
  22. <div class="detail-item">
  23. <div class="detail-label">优惠券名称</div>
  24. <div class="detail-value">
  25. {{ couponModel.name || "--" }}
  26. </div>
  27. </div>
  28. <!-- 面值 -->
  29. <div class="detail-item">
  30. <div class="detail-label">面值(元)</div>
  31. <div class="detail-value">
  32. {{ formatCurrency(couponModel.nominalValue, 2, "¥") }}
  33. </div>
  34. </div>
  35. <!-- 有效期至 -->
  36. <div class="detail-item">
  37. <div class="detail-label">有效期至</div>
  38. <div class="detail-value">
  39. {{ couponModel.endGetDate }}
  40. </div>
  41. </div>
  42. <!-- 优惠券数量 -->
  43. <div class="detail-item">
  44. <div class="detail-label">优惠券数量</div>
  45. <div class="detail-value">
  46. {{ couponModel.singleQty || "--" }}
  47. </div>
  48. </div>
  49. <!-- 最低消费金额 -->
  50. <div class="detail-item">
  51. <div class="detail-label">最低消费金额</div>
  52. <div class="detail-value">
  53. {{ formatCurrency(couponModel.minimumSpendingAmount, 2, "¥") }}
  54. </div>
  55. </div>
  56. </div>
  57. <!-- 好友信息模块 -->
  58. <div class="model">
  59. <h3 style="font-weight: bold">好友信息:</h3>
  60. <!-- 好友名称 -->
  61. <div class="detail-item">
  62. <div class="detail-label">
  63. {{ type === "friendMessage" ? "赠送人" : "接收人" }}
  64. </div>
  65. <div class="detail-value">
  66. {{ couponModel.acName || "--" }}
  67. </div>
  68. </div>
  69. <!-- 状态 -->
  70. <div class="detail-item" v-if="type === 'myGift' && couponModel.status !== undefined">
  71. <div class="detail-label">状态</div>
  72. <div class="detail-value">
  73. {{ getStatusText() }}
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <!-- 右侧内容区域 -->
  79. <div class="contentRight">
  80. <!-- 优惠券详细列表 -->
  81. <div
  82. class="model"
  83. v-if="couponModel.lifeDiscountCouponFriendRuleDetailVos && couponModel.lifeDiscountCouponFriendRuleDetailVos.length > 0"
  84. >
  85. <h3 style="font-weight: bold">优惠券详细列表:</h3>
  86. <div v-for="(detail, index) in couponModel.lifeDiscountCouponFriendRuleDetailVos" :key="index" class="detail-card">
  87. <div class="detail-item">
  88. <div class="detail-label">店铺名称</div>
  89. <div class="detail-value">
  90. {{ detail.storeName || "--" }}
  91. </div>
  92. </div>
  93. <div class="detail-item">
  94. <div class="detail-label">优惠券名称</div>
  95. <div class="detail-value">
  96. {{ detail.couponName || "--" }}
  97. </div>
  98. </div>
  99. <div class="detail-item">
  100. <div class="detail-label">优惠券数量</div>
  101. <div class="detail-value">
  102. {{ detail.couponNum || "--" }}
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. </template>
  111. <script setup lang="tsx" name="friendCouponDetail">
  112. /**
  113. * 好友优惠券 - 详情页面
  114. * 功能:显示好友优惠券的详细信息
  115. */
  116. import { ref, onMounted } from "vue";
  117. import { useRouter, useRoute } from "vue-router";
  118. import { ElMessage } from "element-plus";
  119. import { getFriendCouponDetail } from "@/api/modules/newLoginApi";
  120. import { formatCurrency } from "@/utils/formatCurrency";
  121. import { localGet } from "@/utils";
  122. // ==================== 响应式数据定义 ====================
  123. // 路由相关
  124. const router = useRouter();
  125. const route = useRoute();
  126. // 页面ID参数
  127. const id = ref<string>("");
  128. // 优惠券类型(好友赠我 friendMessage / 我赠好友 myGift)
  129. const type = ref<string>("");
  130. // ==================== 优惠券信息数据模型 ====================
  131. const couponModel = ref<any>({
  132. // 账户名称(赠送人/接收人)
  133. acName: "",
  134. // 优惠券名称
  135. couponName: "",
  136. // 优惠券数量
  137. couponNum: 0,
  138. // 删除标志
  139. deleteFlag: 0,
  140. // 结束日期
  141. endDate: "",
  142. // ID
  143. id: 0,
  144. // 图片URL
  145. imgUrl: "",
  146. // 详细列表
  147. lifeDiscountCouponFriendRuleDetailVos: [],
  148. // 最低消费金额
  149. minimumSpendingAmount: 0,
  150. // 金额上限
  151. moneyHigh: 0,
  152. // 金额下限
  153. moneyLow: 0,
  154. // 面值
  155. nominalValue: 0,
  156. // 状态
  157. status: "",
  158. // 店铺ID
  159. storeId: 0,
  160. // 店铺名称
  161. storeName: ""
  162. });
  163. // ==================== 生命周期钩子 ====================
  164. /**
  165. * 组件挂载时初始化
  166. * 从路由参数中获取couponId并加载详情数据
  167. */
  168. onMounted(async () => {
  169. id.value = (route.query.couponId as string) || "";
  170. type.value = (route.query.type as string) || "";
  171. if (id.value) {
  172. await loadDetailData();
  173. } else {
  174. ElMessage.warning("缺少优惠券ID参数");
  175. }
  176. });
  177. // ==================== 事件处理函数 ====================
  178. /**
  179. * 返回上一页
  180. */
  181. const goBack = () => {
  182. router.go(-1);
  183. };
  184. // ==================== 数据加载函数 ====================
  185. /**
  186. * 加载详情数据
  187. */
  188. const loadDetailData = async () => {
  189. try {
  190. // 使用 couponId 获取详情数据
  191. const res: any = await getFriendCouponDetail({
  192. counponId: id.value
  193. });
  194. if (res.code === 200) {
  195. couponModel.value = res.data;
  196. } else {
  197. ElMessage.error(res.msg);
  198. }
  199. } catch (error) {
  200. ElMessage.error("加载详情数据出错");
  201. }
  202. };
  203. /**
  204. * 获取状态文本
  205. */
  206. const getStatusText = () => {
  207. const statusMap: Record<string, string> = {
  208. "0": "未使用",
  209. "1": "已使用",
  210. "2": "已过期"
  211. };
  212. return statusMap[couponModel.value.status] || "--";
  213. };
  214. </script>
  215. <style scoped lang="scss">
  216. /* 页面容器 */
  217. .table-box {
  218. display: flex;
  219. flex-direction: column;
  220. height: auto !important;
  221. min-height: 100%;
  222. }
  223. /* 头部区域 */
  224. .header {
  225. display: flex;
  226. align-items: center;
  227. padding: 20px 24px;
  228. background-color: #ffffff;
  229. border-bottom: 1px solid #e4e7ed;
  230. box-shadow: 0 2px 4px rgb(0 0 0 / 2%);
  231. }
  232. .title {
  233. flex: 1;
  234. margin: 0;
  235. font-size: 18px;
  236. font-weight: 600;
  237. color: #303133;
  238. text-align: center;
  239. }
  240. /* 内容区域布局 */
  241. .content {
  242. display: flex;
  243. flex: 1;
  244. column-gap: 24px;
  245. width: 98%;
  246. padding: 0 12px;
  247. margin: 24px auto;
  248. /* 左侧内容区域 */
  249. .contentLeft {
  250. width: 50%;
  251. padding-right: 12px;
  252. }
  253. /* 右侧内容区域 */
  254. .contentRight {
  255. width: 50%;
  256. padding-left: 12px;
  257. }
  258. }
  259. /* 模块容器 */
  260. .model {
  261. margin-bottom: 50px;
  262. h3 {
  263. padding-bottom: 12px;
  264. margin: 0 0 20px;
  265. font-size: 16px;
  266. color: #303133;
  267. }
  268. }
  269. /* 详情项样式 */
  270. .detail-item {
  271. display: flex;
  272. align-items: flex-start;
  273. min-height: 32px;
  274. margin-bottom: 24px;
  275. }
  276. .detail-label {
  277. flex-shrink: 0;
  278. min-width: 200px;
  279. font-size: 14px;
  280. font-weight: 500;
  281. line-height: 32px;
  282. color: #606266;
  283. }
  284. .detail-value {
  285. flex: 1;
  286. font-size: 14px;
  287. line-height: 32px;
  288. color: #303133;
  289. word-break: break-word;
  290. }
  291. .empty-text {
  292. color: #909399;
  293. }
  294. /* 详情卡片样式 */
  295. .detail-card {
  296. padding: 16px;
  297. margin-bottom: 16px;
  298. background-color: #f5f7fa;
  299. border: 1px solid #e4e7ed;
  300. border-radius: 4px;
  301. }
  302. </style>