You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

920 lines
28 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
6 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <script setup>
  2. import { onMounted, reactive, ref, watch } from "vue";
  3. import { ElIcon, ElMessage } from "element-plus";
  4. import moment from "moment";
  5. import request from "@/util/http.js"
  6. import Cookies from 'js-cookie';
  7. import { useAdminStore } from "@/store/index.js";
  8. import { storeToRefs } from "pinia";
  9. import { WarnTriangleFilled } from "@element-plus/icons-vue";
  10. import dayjs from "dayjs";
  11. // 国际化
  12. import { useI18n } from 'vue-i18n'
  13. const { t } = useI18n()
  14. const adminStore = useAdminStore();
  15. const { adminData, menuTree } = storeToRefs(adminStore);
  16. // 精网号去空格
  17. const trimJwCode = () => {
  18. if (addConsume.value.jwcode) {
  19. // 去除所有空格,并尝试转换为整数
  20. const trimmed = addConsume.value.jwcode.toString().replace(/\s/g, '')
  21. const numeric = Number(trimmed)
  22. // 如果转换为数字成功,保存为数字,否则提示错误
  23. if (!isNaN(numeric)) {
  24. addConsume.value.jwcode = numeric
  25. } else {
  26. ElMessage.error(t('elmessage.limitDigitJwcode'))
  27. }
  28. }
  29. }
  30. //提交禁止重复点击
  31. const addDisabled = ref(false)
  32. // 通过精网号查询用户(客户)信息 表单
  33. const user = ref({
  34. jwcode: null,
  35. name: "",
  36. market: "",
  37. red: null,
  38. historySumGold: null,
  39. historyPermanentGold: null,
  40. historyFreeGold: null,
  41. historyTaskGold: null,
  42. rechargeNum: null,
  43. consumeNum: null,
  44. firstRecharge: "",
  45. nowPermanentGold: null,
  46. nowFreeJune: null,
  47. nowTaskGold: null,
  48. nowFreeDecember: null,
  49. nowFreeGold: null,
  50. nowSumGold: null
  51. })
  52. // 这是添加消费信息的表单(金币)
  53. const addConsume = ref({
  54. // jwcode 是数字
  55. jwcode: null, //精网号
  56. goodsName: "",// 商品名称
  57. price: null, // 原价
  58. sumGold: null, // 消费金币总数
  59. freeGold: null, // 免费金币
  60. permanentGold: null, // 永久金币
  61. taskGold: null, // 任务金币
  62. remark: "",//备注
  63. adminId: null,// 当前管理员id
  64. adminName: adminData.value.adminName
  65. })
  66. const Ref = ref(null)
  67. const rules = reactive({
  68. jwcode: [
  69. { required: true, message: t('elmessage.checkJwcode'), trigger: "blur" },
  70. ],
  71. goodsName: [{ required: true, message: t('elmessage.checkGoodsName'), trigger: "change" }],
  72. sumGold: [
  73. { required: true, message: t('elmessage.noEmptySumGold'), trigger: "blur" },
  74. {
  75. validator: (rule, value, callback) => {
  76. // 允许0开头的小数(如0.1)但不允许单独的0
  77. const isValid = /^(0\.\d{1,2})|([1-9]\d*(\.\d{1,2})?)$/.test(value);
  78. if (!isValid) {
  79. callback(new Error(t('elmessage.limitPositiveNumber')));
  80. } else {
  81. callback();
  82. }
  83. },
  84. trigger: "blur"
  85. }
  86. ]
  87. });
  88. // 查询商品的表单
  89. const goods = ref([])
  90. // 输入验证函数
  91. function validateInput() {
  92. const sumGold = parseFloat(addConsume.value.sumGold);
  93. trimJwCode();
  94. if (user.value.jwcode == null) {
  95. ElMessage.warning(t('elmessage.checkUserInfo'));
  96. addConsume.value.sumGold = null;
  97. user.value = {};
  98. return false;
  99. }
  100. /*
  101. // 验证金币数值
  102. if (user.value.jwcode && (isNaN(sumGold) || sumGold <= 0)) {
  103. ElMessage.warning("消费金币总数必须是大于0的数字");
  104. // 将sumGold设置为null
  105. addConsume.value.sumGold = null;
  106. return false;
  107. }
  108. */
  109. // sumGold 补充0(比如.1 为0.1)
  110. if (addConsume.value.sumGold && addConsume.value.sumGold.toString().startsWith('.')) {
  111. addConsume.value.sumGold = '0' + addConsume.value.sumGold;
  112. // ElMessage.info('已自动补充前导0');
  113. }
  114. // 验证金币不能为负数
  115. if (sumGold < 0) {
  116. ElMessage.warning(t('elmessage.limitNegativeNumber'));
  117. addConsume.value.sumGold = null;
  118. return false;
  119. }
  120. // 小数位数限制 2位,整数位数限制 6位
  121. if (addConsume.value.sumGold) {
  122. const sumGoldStr = addConsume.value.sumGold.toString();
  123. // 检查整数部分长度
  124. if (sumGoldStr.includes('.')) {
  125. const integerPart = sumGoldStr.split('.')[0];
  126. if (integerPart.length > 6) {
  127. // 截断整数部分到6位并提示
  128. const truncatedInteger = integerPart.slice(0, 6);
  129. addConsume.value.sumGold = parseFloat(truncatedInteger);
  130. ElMessage.info(t('elmessage.limitSix'));
  131. return; // 直接返回,不再处理小数部分
  132. }
  133. } else {
  134. // 纯整数情况
  135. if (sumGoldStr.length > 6) {
  136. addConsume.value.sumGold = parseFloat(sumGoldStr.slice(0, 6));
  137. ElMessage.info(t('elmessage.limitSix'));
  138. return;
  139. }
  140. }
  141. // 处理小数部分
  142. if (sumGoldStr.includes('.')) {
  143. const decimalPart = sumGoldStr.split('.')[1];
  144. if (decimalPart.length > 2) {
  145. // 截断到两位小数并提示
  146. const truncatedValue = parseFloat(sumGoldStr.slice(0, sumGoldStr.indexOf('.') + 3));
  147. addConsume.value.sumGold = truncatedValue;
  148. ElMessage.info(t('elmessage.limitTwoDecimal'));
  149. }
  150. }
  151. }
  152. // 验证金币总和
  153. const totalAvailableGold = (user.value.nowSumGold)
  154. if (user.value.jwcode && sumGold > totalAvailableGold) {
  155. ElMessage.error(t('elmessage.limitExceeded'));
  156. // 将sumGold设置为null
  157. addConsume.value.sumGold = null;
  158. return false;
  159. }
  160. return true;
  161. }
  162. // 仅在鼠标离开(blur)时校验:消耗金币数 + 红包抵扣金额 ≥ 原价
  163. function validateRedLimit() {
  164. const sumGold = parseFloat(addConsume.value.sumGold);
  165. const price = Number(addConsume.value.price || 0);
  166. const redMax = Number(user.value.red || 0);
  167. if (!isNaN(price) && price > 0) {
  168. if (isNaN(sumGold) || sumGold <= 0) {
  169. ElMessage.error(t('elmessage.noEmptySumGold'));
  170. return false;
  171. }
  172. if (sumGold + redMax < price) {
  173. ElMessage.error(t('elmessage.limitRedAmount'));
  174. return false;
  175. }
  176. }
  177. return true;
  178. }
  179. // 消耗金币计算函数
  180. function calculateCoins(sumGold) {
  181. console.log("消耗金币计算函数:计算金币", sumGold);
  182. const parsedSumGold = parseFloat(sumGold);
  183. if (isNaN(parsedSumGold) || parsedSumGold <= 0 || !user.value.jwcode) {
  184. return { free: 0, permanent: 0, task: 0 };
  185. }
  186. const { nowFreeGold, nowPermanentGold, nowTaskGold } = user.value;
  187. let remaining = parsedSumGold;
  188. let freeUsed = 0, permanentUsed = 0, taskUsed = 0;
  189. // 优先消耗免费金币
  190. if (nowFreeGold > 0) {
  191. freeUsed = Math.min(parseFloat(nowFreeGold.toFixed(4)), remaining);
  192. remaining = parseFloat((remaining - freeUsed).toFixed(4));
  193. }
  194. // 其次消耗永久金币
  195. if (remaining > 0 && nowPermanentGold > 0) {
  196. permanentUsed = Math.min(parseFloat(nowPermanentGold.toFixed(4)), remaining);
  197. remaining = parseFloat((remaining - permanentUsed).toFixed(4));
  198. }
  199. // 最后消耗任务金币
  200. if (remaining > 0 && nowTaskGold > 0) {
  201. taskUsed = parseFloat(remaining.toFixed(4));
  202. }
  203. // 更新金币值
  204. addConsume.value.freeGold = freeUsed;
  205. addConsume.value.permanentGold = permanentUsed;
  206. addConsume.value.taskGold = taskUsed;
  207. return { free: freeUsed, permanent: permanentUsed, task: taskUsed };
  208. }
  209. // 用来写的 cookie 的 key
  210. const WriteCookies = ref(null)
  211. // 用来写的 cookie 的 value
  212. const WriteCookiesTime = ref(null)
  213. // 用来读的 cookie 的 key
  214. const ReadCookies = ref(null)
  215. // 用来读的 cookie 的 value
  216. const ReadCookiesTime = ref(null)
  217. // 这是添加消费信息的接口
  218. const add = async function () {
  219. try {
  220. // 验证输入数据 再验证一次
  221. if (!validateInput()) {
  222. return;
  223. }
  224. // 计算金币使用情况
  225. calculateCoins(addConsume.value.sumGold);
  226. console.log("addConsume.value", addConsume.value)
  227. addDisabled.value = true
  228. // 发送POST请求
  229. const result = await request({
  230. url: "/consume/add",
  231. data: {
  232. jwcode: addConsume.value.jwcode,
  233. adminId: adminData.value.id,
  234. price: Number(addConsume.value.price || 0) * 100,
  235. sumGold: addConsume.value.sumGold * 100,
  236. freeGold: addConsume.value.freeGold * 100,
  237. taskGold: addConsume.value.taskGold * 100,
  238. permanentGold: addConsume.value.permanentGold * 100,
  239. goodsName: addConsume.value.goodsName.value,
  240. remark: addConsume.value.remark,
  241. adminName: adminData.value.adminName
  242. }
  243. })
  244. addDisabled.value = false
  245. console.log("add请求", result);
  246. // 处理响应
  247. handleResponse(result);
  248. // 重置表单
  249. resetForm();
  250. } catch (error) {
  251. console.error("请求失败", error);
  252. ElMessage.error(t('elmessage.addFailed'));
  253. }
  254. };
  255. // 响应处理函数
  256. function handleResponse(result) {
  257. console.log("响应结果", result)
  258. if (result.code === 200) {
  259. //存一下 用户的jwcode
  260. // 拼接 jwcode:permanentGold:freeGold
  261. WriteCookies.value = `coinConsume:${addConsume.value.jwcode}:${addConsume.value.goodsName.value}`
  262. //value 为当前消耗时间
  263. WriteCookiesTime.value = dayjs().format("YYYY-MM-DD HH:mm:ss");
  264. // 设置cookies,用户jwcode为key,value也是jwcode,过期时间为1天
  265. Cookies.set(WriteCookies.value, WriteCookiesTime.value, {
  266. expires:
  267. 1, path: '/'
  268. });
  269. ElMessage.success(t('elmessage.addSuccess'));
  270. console.log("请求成功", result);
  271. } else {
  272. ElMessage.error(result.msg || t('elmessage.addFailedUnknown'));
  273. }
  274. }
  275. // 重置表单函数
  276. function resetForm() {
  277. // 清空表单数据
  278. Ref.value.resetFields();
  279. addConsume.value = {
  280. jwcode: null,
  281. goodsName: "",
  282. sumGold: null,
  283. freeGold: null,
  284. permanentGold: null,
  285. taskGold: null,
  286. remark: "",
  287. adminId: adminData.value.id,
  288. adminName: adminData.value.adminName,
  289. }
  290. console.log("重置表单")
  291. user.value = {
  292. jwcode: null,
  293. name: "",
  294. market: "",
  295. historySumGold: null,
  296. historyPermanentGold: null,
  297. historyFreeGold: null,
  298. historyTaskGold: null,
  299. rechargeNum: null,
  300. consumeNum: null,
  301. firstRecharge: "",
  302. nowPermanentGold: null,
  303. nowFreeJune: null,
  304. nowTaskGold: null,
  305. nowFreeDecember: null,
  306. nowFreeGold: null,
  307. nowSumGold: null
  308. }
  309. }
  310. // 充值对话框显示状态
  311. const ConsumeDialogVisible = ref(false);
  312. // 关闭对话框
  313. const ConsumeDialogVisiblehandleClose = () => {
  314. ConsumeDialogVisible.value = false;
  315. // 重置表单数据
  316. resetForm()
  317. user.value = {}
  318. };
  319. ``
  320. // 确认使用cookie继续充值
  321. const ConsumeDialogVisibleContinue = () => {
  322. ConsumeDialogVisible.value = false;
  323. add();
  324. };
  325. const ConsumeDialogVisibleCancel = () => {
  326. ConsumeDialogVisible.value = false
  327. resetForm()
  328. user.value = {}
  329. };
  330. // 第一次弹窗
  331. // 充值对话框显示状态
  332. const FirstConsumeDialogVisible = ref(false);
  333. // 关闭对话框
  334. const FirstConsumeDialogVisiblehandleClose = () => {
  335. FirstConsumeDialogVisible.value = false;
  336. // 重置表单数据
  337. resetForm()
  338. user.value = {}
  339. };
  340. // 第一次消耗
  341. const FirstConsumeDialogVisibleContinue = () => {
  342. FirstConsumeDialogVisible.value = false;
  343. add();
  344. };
  345. const FirstConsumeDialogVisibleCancel = () => {
  346. FirstConsumeDialogVisible.value = false
  347. resetForm()
  348. user.value = {}
  349. };
  350. // 实际执行充值操作
  351. // const proceedWithConsume = () => {
  352. // ElMessageBox.confirm('确认购买?')
  353. // .then(() => {
  354. // add();
  355. // console.log('添加成功');
  356. // })
  357. // .catch(() => {
  358. // console.log('取消添加');
  359. // });
  360. // };
  361. // 添加前验证
  362. const addBefore = () => {
  363. Ref.value.validate(async (valid) => {
  364. // 验证cookie
  365. if (!valid) {
  366. ElMessage({
  367. type: 'error',
  368. message: t('elmessage.checkInputContent')
  369. });
  370. return;
  371. }
  372. if (!validateInput() || !validateRedLimit()) {
  373. return;
  374. }
  375. ReadCookies.value = `coinConsume:${addConsume.value.jwcode}:${addConsume.value.goodsName.value}`
  376. // 获取cookie
  377. const cookie = Cookies.get(ReadCookies.value)
  378. console.log("time", WriteCookiesTime.value)
  379. // 格式化时间
  380. ReadCookiesTime.value = moment(cookie).format('YYYY-MM-DD HH:mm:ss')
  381. console.log("cookie========", cookie)
  382. if (cookie) {
  383. ConsumeDialogVisible.value = true;
  384. } else {
  385. FirstConsumeDialogVisible.value = true;
  386. }
  387. });
  388. };
  389. // 查询客户信息(通过精网号)
  390. const getUser = async function (jwcode) {
  391. try {
  392. // 验证精网号
  393. if (!jwcode) {
  394. ElMessage.warning(t('elmessage.noEmptyJwcode'));
  395. return;
  396. }
  397. // 验证精网号是否为数字
  398. if (!/^\d{1,9}$/.test(jwcode)) {
  399. ElMessage.warning(t('elmessage.limitJwcodeNine'));
  400. resetForm()
  401. return;
  402. }
  403. // 发送POST请求
  404. const result = await request({
  405. url: "/user/selectUser",
  406. data: { jwcode }
  407. });
  408. console.log("请求成功", result);
  409. if (result.code === 200 && result.data) {
  410. // 处理用户数据
  411. user.value = {
  412. ...result.data,
  413. // 统一处理所有黄金数值,除以100
  414. nowPermanentGold: result.data.nowPermanentGold,
  415. nowFreeGold: result.data.nowFreeGold,
  416. nowSumGold: result.data.nowSumGold,
  417. nowTaskGold: result.data.nowTaskGold,
  418. nowFreeJune: result.data.nowFreeJune,
  419. nowFreeDecember: result.data.nowFreeDecember,
  420. historySumGold: result.data.historySumGold,
  421. historyPermanentGold: result.data.historyPermanentGold,
  422. historyFreeGold: result.data.historyFreeGold,
  423. historyTaskGold: result.data.historyTaskGold
  424. };
  425. ElMessage.success(t('elmessage.searchSuccess'));
  426. // 检查sumGold是否有值,如果有则重新计算金币分配
  427. if (addConsume.value.sumGold) {
  428. const parsedSumGold = parseFloat(addConsume.value.sumGold);
  429. if (!isNaN(parsedSumGold) && parsedSumGold > 0) {
  430. const { free, permanent, task } = calculateCoins(parsedSumGold);
  431. addConsume.value.freeGold = free;
  432. addConsume.value.permanentGold = permanent;
  433. addConsume.value.taskGold = task;
  434. }
  435. }
  436. // 验证输入
  437. validateInput()
  438. } else if (!result.data) {
  439. ElMessage.warning(t('elmessage.noUser'));
  440. user.value.jwcode = null
  441. addConsume.value.jwcode = null
  442. // resetForm(); // 重置表单
  443. } else {
  444. ElMessage.warning(result.msg || t('elmessage.checkQueryParams'));
  445. }
  446. } catch (error) {
  447. console.error("请求失败", error);
  448. ElMessage.error(t('elmessage.queryFailed'));
  449. resetForm(); // 重置表单
  450. }
  451. };
  452. // 获取商品信息(三楼接口)
  453. const getGoods = async function () {
  454. try {
  455. // 发送POST请求
  456. const result = await request({
  457. // url: "/product", //
  458. // url: "http://39.101.133.168:8828/live_mall/api/product/all",
  459. url: "https://api.homilychart.com/live_mall/api/product/all",
  460. });
  461. // 将响应结果存储到响应式数据中
  462. console.log("请求成功", result);
  463. goods.value = result.data.map(item => ({
  464. id: item.id,
  465. label: item.name,
  466. value: item.name,
  467. price: item.price
  468. }));
  469. } catch (error) {
  470. console.log("请求失败", error);
  471. // 在这里可以处理错误逻辑,比如显示错误提示等
  472. }
  473. };
  474. /*
  475. ====================监听=================================
  476. */
  477. // 监听消费总金额变化,自动计算三类金币
  478. watch(
  479. () => addConsume.value.sumGold,
  480. (newValue) => {
  481. const parsedNewValue = parseFloat(newValue);
  482. if (!isNaN(parsedNewValue) && parsedNewValue > 0) {
  483. const { free, permanent, task } = calculateCoins(parsedNewValue);
  484. addConsume.value.freeGold = free;
  485. addConsume.value.permanentGold = permanent;
  486. addConsume.value.taskGold = task;
  487. } else {
  488. addConsume.value.freeGold = null;
  489. addConsume.value.permanentGold = null;
  490. addConsume.value.taskGold = null;
  491. }
  492. }
  493. );
  494. // 监听商品选择,自动展示原价
  495. watch(
  496. () => addConsume.value.goodsName,
  497. (newGoods) => {
  498. if (newGoods && typeof newGoods === 'object') {
  499. addConsume.value.price = Number(newGoods.price || 0) || null;
  500. } else {
  501. addConsume.value.price = null;
  502. }
  503. }
  504. );
  505. /*
  506. ====================挂载=================================
  507. */
  508. // 挂载
  509. onMounted(async function () {
  510. await getGoods()
  511. console.log('adminData', adminData.value)
  512. })
  513. </script>
  514. <template>
  515. <div class="father1">
  516. <div class="left">
  517. <el-form :model="addConsume" ref="Ref" :rules="rules" style="min-width: 600px;" class="add-form"
  518. label-width="auto" label-position="right">
  519. <el-form-item prop="jwcode" :label="t('common_add.jwcode')" style="margin-top: 50px">
  520. <el-input v-model="addConsume.jwcode" style="width: 200px;" />
  521. <el-button type="primary" @click="getUser(addConsume.jwcode)" style="margin-left: 20px">
  522. {{ t('common.search') }}
  523. </el-button>
  524. </el-form-item>
  525. <el-form-item prop="goodsName" :label="t('common_add.goodsName')">
  526. <el-select v-model="addConsume.goodsName" :placeholder="t('common_add.goodsNamePlaceholder')"
  527. style="width: 200px" clearable filterable>
  528. <el-option v-for="(item, index) in goods" :key="index" :label="item.label" :value="item" />
  529. </el-select>
  530. </el-form-item>
  531. <el-form-item prop="price" :label="t('common_add.price')">
  532. <el-input v-model="addConsume.price" style="width: 120px" disabled />
  533. </el-form-item>
  534. <el-form-item prop="sumGold" :label="t('common_add.consumeTotalGold')">
  535. <el-input v-model="addConsume.sumGold" style="width: 120px"
  536. @blur="validateRedLimit()" />
  537. </el-form-item>
  538. <!-- 三类金币自动计算禁用状态不可编辑 -->
  539. <el-form-item prop="permanentGold" :label="t('common_add.permanentGold')">
  540. <el-input v-model="addConsume.permanentGold" disabled style="width: 120px">
  541. <template #default="scope">{{ scope.row.permanentGold }}</template>
  542. </el-input>
  543. <p style="margin-right: 0px">&nbsp;&nbsp;{{ $t('common.个') }}</p>
  544. </el-form-item>
  545. <el-form-item prop="freeCoin" :label="t('common_add.freeGold')">
  546. <el-input disabled v-model="addConsume.freeGold" style="width: 120px" />
  547. <p style="margin-right: 0px">&nbsp;&nbsp;{{ $t('common.个') }}</p>
  548. </el-form-item>
  549. <el-form-item prop="taskGold" :label="t('common_add.taskGold')">
  550. <el-input disabled v-model="addConsume.taskGold" style="width: 120px" />
  551. <p style="margin-right: 20px">&nbsp;&nbsp;{{ $t('common.个') }}</p>
  552. </el-form-item>
  553. <el-form-item prop="remark" :label="t('common_add.remark')">
  554. <el-input v-model="addConsume.remark" style="width: 250px" :rows="4" maxlength="100" show-word-limit
  555. type="textarea" />
  556. </el-form-item>
  557. <el-button type="success" @click="resetForm()" style="margin-left: 200px;margin-top:10px">{{ t('common.reset')
  558. }}</el-button>
  559. <el-button type="primary" :disabled="addDisabled" @click="addBefore" style="margin-top:10px">{{
  560. t('common.submit')
  561. }}</el-button>
  562. </el-form>
  563. </div>
  564. <div class="right">
  565. <!-- 客户信息栏 -->
  566. <el-card v-if="user.jwcode" style="width: 800px; float: right" class="customer-info">
  567. <el-form :model="user" label-width="auto" style="max-width: 1000px" label-position="left">
  568. <el-text size="large" style="margin-left: 20px">{{ $t('common_add_user.customerInfo') }}</el-text>
  569. <!-- 第一行姓名 + 历史金币 -->
  570. <el-row style="margin-top: 20px">
  571. <el-col :span="9">
  572. <el-form-item :label="$t('common_add_user.name')">
  573. <p>{{ user.name }}</p>
  574. </el-form-item>
  575. </el-col>
  576. <el-col :span="14">
  577. <el-form-item :label="$t('common_add_user.currentGoldCoinTotal')" style="width: 500px">
  578. <span style="color: #2fa1ff; margin-right: 5px" v-if="user.nowSumGold !== undefined">{{
  579. user.nowSumGold
  580. }}</span>
  581. </el-form-item>
  582. <!-- 金币详情独立显示 -->
  583. <el-form-item style="margin-top: -23px"> <!-- 负边距减少间距 -->
  584. <span style="color: #b1b1b1; margin-left: 0px" v-if="user.nowPermanentGold !== undefined">({{
  585. $t('common_add_user.permanentGold') }}:{{
  586. user.nowPermanentGold
  587. }};
  588. {{ $t('common_add_user.freeGold') }}:{{ user.nowFreeGold }};
  589. {{ $t('common_add_user.taskGold') }}:{{ user.nowTaskGold }})</span>
  590. </el-form-item>
  591. </el-col>
  592. </el-row>
  593. <!-- 第二行精网号 + 当前金币独立行 -->
  594. <el-row>
  595. <el-col :span="9">
  596. <el-form-item :label="$t('common_add_user.jwcode')">
  597. <p>{{ user.jwcode }}</p>
  598. </el-form-item>
  599. </el-col>
  600. <el-col :span="14">
  601. <el-form-item :label="$t('common_add_user.consumptionTimes')">
  602. <p style="color: #2fa1ff">{{ user.consumeNum }} </p>
  603. </el-form-item>
  604. <el-form-item style="margin-top: -23px"> <!-- 负边距减少间距 -->
  605. <p style="font-size: small; color: #b1b1b1">({{ $t('common_add_user.onlyStatisticsDataAfter20250101')
  606. }})
  607. </p>
  608. </el-form-item>
  609. </el-col>
  610. </el-row>
  611. <!-- 第三行首次充值日期 + 充值次数 -->
  612. <!-- <el-row >
  613. <el-col :span="9">
  614. <el-form-item label="首次充值日期">
  615. <p v-if="user.firstRecharge">
  616. {{ moment(user.firstRecharge).format('YYYY-MM-DD HH:mm:ss') }}
  617. </p>
  618. </el-form-item>
  619. </el-col>
  620. </el-row> -->
  621. <!-- 第四行消费次数 + 所属门店 -->
  622. <el-row>
  623. <el-col :span="9">
  624. <el-form-item :label="$t('common_add_user.store')">
  625. <p>{{ user.market }}</p>
  626. </el-form-item>
  627. </el-col>
  628. <el-col :span="14">
  629. <el-form-item :label="$t('common_add_user.maxReductionAmount')">
  630. <p style="color: #2fa1ff">{{ user.red }} </p>
  631. </el-form-item>
  632. </el-col>
  633. </el-row>
  634. </el-form>
  635. </el-card>
  636. <el-dialog v-model="FirstConsumeDialogVisible" :title="$t('common_add.operationConfirm')"
  637. :before-close="FirstConsumeDialogVisiblehandleClose" :close-on-click-modal="false" width="480px">
  638. <!-- 内容整体居中且收窄 -->
  639. <div class="confirm-body">
  640. <!-- 用户信息 -->
  641. <div>
  642. <div class="field-label">{{ $t('common_add.userInfo') }}</div>
  643. <el-input :model-value="user.jwcode + (user.name ? '' + user.name + '' : '')" disabled />
  644. </div>
  645. <!-- 商品名称 -->
  646. <div class="field">
  647. <div class="field-label">{{ $t('common_add.goodsName') }}</div>
  648. <el-input v-model="addConsume.goodsName.value" disabled />
  649. </div>
  650. <!--金币总数 -->
  651. <div class="field">
  652. <div class="field-label">{{ $t('common_add.totalGold') }}</div>
  653. <el-input v-model="addConsume.sumGold" disabled />
  654. </div>
  655. <!-- 金币详细信息同一行左右排列 -->
  656. <el-row :gutter="20" class="coins-row">
  657. <el-col :span="8">
  658. <div class="field">
  659. <div class="field-label">{{ $t('common_add.permanentGold') }}</div>
  660. <el-input v-model="addConsume.permanentGold" disabled />
  661. </div>
  662. </el-col>
  663. <el-col :span="8">
  664. <div class="field">
  665. <div class="field-label">{{ $t('common_add.freeGold') }}</div>
  666. <el-input v-model="addConsume.freeGold" disabled />
  667. </div>
  668. </el-col>
  669. <el-col :span="8">
  670. <div class="field">
  671. <div class="field-label">{{ $t('common_add.taskGold') }}</div>
  672. <el-input v-model="addConsume.taskGold" disabled />
  673. </div>
  674. </el-col>
  675. </el-row>
  676. <div class="field">
  677. <div class="field-label">{{ $t('common_add.remark') }}</div>
  678. <el-input v-model="addConsume.remark" disabled />
  679. </div>
  680. </div>
  681. <!-- 底部按钮居中 -->
  682. <template #footer>
  683. <div class="dialog-footer-center">
  684. <el-button @click="FirstConsumeDialogVisibleCancel">{{ $t('common.cancel') }}</el-button>
  685. <el-button type="primary" @click="FirstConsumeDialogVisibleContinue">{{ $t('common.confirm') }}</el-button>
  686. </div>
  687. </template>
  688. </el-dialog>
  689. <el-dialog v-model="ConsumeDialogVisible" :title="$t('common_add.operationConfirm')" :before-close="ConsumeDialogVisiblehandleClose"
  690. :close-on-click-modal="false" width="480px">
  691. <!-- 内容整体居中且收窄 -->
  692. <div class="confirm-body">
  693. <!-- 用户信息 -->
  694. <div>
  695. <div class="field-label">{{ $t('common_add.userInfo') }}</div>
  696. <el-input :model-value="user.jwcode + (user.name ? '' + user.name + '' : '')" disabled />
  697. </div>
  698. <!-- 商品名称 -->
  699. <div class="field">
  700. <div class="field-label">{{ $t('common_add.goodsName') }}</div>
  701. <el-input v-model="addConsume.goodsName.value" disabled />
  702. </div>
  703. <!--金币总数 -->
  704. <div class="field">
  705. <div class="field-label">{{ $t('common_add.totalGold') }}</div>
  706. <el-input v-model="addConsume.sumGold" disabled />
  707. </div>
  708. <!-- 金币详细信息同一行左右排列 -->
  709. <el-row :gutter="20" class="coins-row">
  710. <el-col :span="8">
  711. <div class="field">
  712. <div class="field-label">{{ $t('common_add.permanentGold') }}</div>
  713. <el-input v-model="addConsume.permanentGold" disabled />
  714. </div>
  715. </el-col>
  716. <el-col :span="8">
  717. <div class="field">
  718. <div class="field-label">{{ $t('common_add.freeGold') }}</div>
  719. <el-input v-model="addConsume.freeGold" disabled />
  720. </div>
  721. </el-col>
  722. <el-col :span="8">
  723. <div class="field">
  724. <div class="field-label">{{ $t('common_add.taskGold') }}</div>
  725. <el-input v-model="addConsume.taskGold" disabled />
  726. </div>
  727. </el-col>
  728. </el-row>
  729. <!-- 风险提示 -->
  730. <div style="display: flex; align-items: center; margin-top: 20px;">
  731. <el-icon :size="24" color="#FFD700">
  732. <WarnTriangleFilled />
  733. </el-icon>
  734. <p>{{ $t('common_add.prompt') }}</p>
  735. </div>
  736. <!-- 记录 + 虚线分隔 -->
  737. <div>
  738. <el-divider border-style="dashed" />
  739. <p>{{ $t('common_add.similarRechargeRecords') }}</p>
  740. · {{ ReadCookiesTime }} {{ $t('common_add.buy') }} {{ addConsume.goodsName.value }}({{ $t('common_add.operator') }}: {{ adminData.adminName }})
  741. </div>
  742. <div style="margin-top: 10px">
  743. <p>{{ $t('common_add.continueOperation') }}</p>
  744. </div>
  745. </div>
  746. <!-- 底部按钮居中 -->
  747. <template #footer>
  748. <div class="dialog-footer-center">
  749. <el-button @click="ConsumeDialogVisibleCancel">{{ $t('common.cancel') }}</el-button>
  750. <el-button type="primary" @click="ConsumeDialogVisibleContinue">{{ $t('common.confirm') }}</el-button>
  751. </div>
  752. </template>
  753. </el-dialog>
  754. </div>
  755. </div>
  756. </template>
  757. <style scoped lang="scss">
  758. p {
  759. margin: 0px;
  760. }
  761. /* 上传图片的格式 */
  762. .avatar-uploader .avatar {
  763. width: 50px;
  764. height: 50px;
  765. display: block;
  766. }
  767. .add-form {
  768. width: 400px;
  769. float: left;
  770. }
  771. /* 标题居中 */
  772. .el-dialog__header {
  773. text-align: center;
  774. }
  775. .confirm-body {
  776. width: 350px;
  777. margin: 0 auto;
  778. }
  779. /* 字段块与标签样式 */
  780. .field {
  781. margin-bottom: 14px;
  782. }
  783. .field-label {
  784. font-size: 14px;
  785. color: #606266;
  786. margin-bottom: 6px;
  787. }
  788. /* 金币行紧凑 */
  789. .coins-row .field {
  790. margin-bottom: 0;
  791. }
  792. /* 底部按钮居中 */
  793. .dialog-footer-center {
  794. display: flex;
  795. justify-content: center;
  796. gap: 12px;
  797. }
  798. .father1 {
  799. width: 82vw;
  800. height: 80vh;
  801. display: flex;
  802. .left {
  803. width: 500px;
  804. float: left;
  805. display: flex;
  806. }
  807. .right {
  808. flex: 1;
  809. height: 50vh;
  810. display: flex;
  811. align-items: center;
  812. .customer-info {
  813. width: 300px;
  814. margin-left: 20px;
  815. display: flex;
  816. justify-content: center;
  817. align-items: center;
  818. }
  819. }
  820. }
  821. </style>