index.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div class="content">
  3. <lucency-header :lang="lang" page-key="product" />
  4. <item-banner :title="productTypeText" :sub-title="productTypeSubText"></item-banner>
  5. <div class="conBox big-title">
  6. <span >
  7. {{product.name}}
  8. </span>
  9. <div class="hr"></div>
  10. </div>
  11. <div class="product-view">
  12. <div class="left">
  13. <div class="imgView">
  14. <img :src="product.image"/>
  15. </div>
  16. <div class="concatUs">
  17. <!-- 联系销售 -->
  18. </div>
  19. </div>
  20. <div class="right">
  21. </div>
  22. </div>
  23. <!-- 产品展示页面 -->
  24. <!-- 页脚 -->
  25. <default-footer :lang="lang"/>
  26. </div>
  27. </template>
  28. <script>
  29. import langMap from "~/map/langMap";
  30. import { getTypeText,getTypeSubText, pTypes} from "~/map/productMap";
  31. export default {
  32. name: "itemIndex",
  33. props:['uLang','pType'],
  34. data(){
  35. return {
  36. langType: langMap.lang,
  37. lang: this.uLang?this.uLang:langMap.lang.cn,
  38. productId: null,
  39. types: pTypes,
  40. type: '',
  41. productTypeText: getTypeText(this.pType),
  42. productTypeSubText: getTypeSubText(this.pType),
  43. productDetail: {},
  44. }
  45. },
  46. beforeMount() {
  47. const queryString = window.location.search;
  48. const params = new URLSearchParams(queryString);
  49. if(params&&params.get('id')){
  50. this.productId = params.get('id');
  51. }else{
  52. window.location.href = '/product'
  53. }
  54. this.loadProductDetail();
  55. },
  56. mounted() {
  57. console.log(this.pType);
  58. console.log(this.type);
  59. this.type = this.pType;
  60. },
  61. methods:{
  62. getLangText(str) {
  63. return langMap.getText(this.lang, str);
  64. },
  65. getAbbrText(str) {
  66. return langMap.getAbbrText(this.lang, str);
  67. },
  68. async loadProductDetail(){
  69. let err,res;
  70. let url = `/api/getProduct?id=${this.productId}`
  71. [err,res] = await handle(this.$axios.$get(url));
  72. if(err){
  73. console.error(err);
  74. return alert(err.message);
  75. }
  76. let result = res.data;
  77. if(result.rcode === 1){
  78. this.productDetail = result.data;
  79. }else{
  80. console.log('not match result');
  81. console.log(result);
  82. return alert('加载产品失败!!!');
  83. }
  84. }
  85. }
  86. }
  87. </script>
  88. <style scoped>
  89. .big-title {
  90. margin: 5px auto;
  91. justify-content: left;
  92. }
  93. </style>