edit.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <script >
  2. import langMap from "@/map/langMap";
  3. import {apiMap} from "@/map/apiMap";
  4. import {handle} from "@/until/handle";
  5. import {rCode} from "@/map/rcodeMap_esm";
  6. import {unescapeHtml} from "@/until/unescapeHtml";
  7. import {timestampToTime} from "@/until/time";
  8. import RoundedTitle from "@/components/public/roundedTitle.vue";
  9. import productAdd from "@/pages/manger/product/add.vue"
  10. export default {
  11. name: "productInfoView",
  12. components: {RoundedTitle, productAdd},
  13. data() {
  14. return {
  15. loading: false,
  16. productInfo: {},
  17. // 英文的产品信息
  18. productId: '',
  19. lang: langMap.lang.zh,
  20. showImage: ''
  21. }
  22. },
  23. beforeMount() {
  24. this.productId = this.$route.query.id;
  25. this.loadProductInfo();
  26. },
  27. computed: {
  28. },
  29. methods: {
  30. async loadProductInfo() {
  31. let productId = this.productId;
  32. if (!productId) {
  33. this.$message.error('未获取到产品id');
  34. return;
  35. }
  36. this.loading = true;
  37. let url = apiMap.productInfo.path;
  38. url += `/${productId}?lang=${this.lang}`
  39. let [err, res] = await handle(this.$axios.get(url));
  40. this.loading = false;
  41. if (err) {
  42. this.$message.error('获取产品信息失败');
  43. return console.log(err);
  44. }
  45. let result = res.data;
  46. if (result.code !== rCode.OK) {
  47. this.$message.error(`获取产品信息失败,${result.msg}`)
  48. return
  49. }
  50. console.log(result)
  51. let data = result.data;
  52. data.showImage = data.image;
  53. this.productInfo = data;
  54. },
  55. getLangText(str) {
  56. return langMap.getText(this.lang, str);
  57. },
  58. }
  59. }
  60. </script>
  61. <template>
  62. <product-add :product="productInfo" :lang="lang" />
  63. </template>
  64. <style scoped>
  65. .page{
  66. width: 100%;
  67. height: calc(100% - 60px);
  68. }
  69. .product-show{
  70. margin-top: 20px;
  71. width: 100%;
  72. height: calc(100% - 50px);
  73. overflow: auto;
  74. background-color: #fff;
  75. border-radius: 10px;
  76. }
  77. .edit-btn{
  78. font-size: 14px;
  79. }
  80. </style>