index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. {{productDetail.name}}
  8. </span>
  9. <div class="hr"></div>
  10. </div>
  11. <div class="conBox product-view">
  12. <div class="left">
  13. <div class="imgView">
  14. <img :src="'/public/'+productDetail.image" alt=""/>
  15. </div>
  16. <div class="concatUs">
  17. <!-- 联系销售 -->
  18. <span class="chunk">联系购买</span>
  19. <div class="imgView">
  20. <img src="/public/files/basic/2021-03-22/605842910c2ae.jpg" alt="">
  21. </div>
  22. </div>
  23. </div>
  24. <div class="right">
  25. <div class="remark">
  26. {{productDetail.remark}}
  27. </div>
  28. <div class="detail" v-html="productDetail.detail">
  29. </div>
  30. </div>
  31. </div>
  32. <!-- 更多数据页面 -->
  33. <div class="conBox product-detail">
  34. <q-tab></q-tab>
  35. </div>
  36. <!-- 页脚 -->
  37. <default-footer :lang="lang"/>
  38. </div>
  39. </template>
  40. <script>
  41. import langMap from "~/map/langMap";
  42. import { getTypeText,getTypeSubText, pTypes} from "~/map/productMap";
  43. import handle from "~/until/handle";
  44. import {unescape} from "~/until/unescapeHtml";
  45. import qTab from "../../../components/qTab";
  46. import DefaultFooter from "../../../components/footer/defaultFooter";
  47. import LucencyHeader from "../../../components/header/lucencyHeader";
  48. import ItemBanner from "../../../components/banner/itemBanner";
  49. export default {
  50. name: "itemIndex",
  51. components: {ItemBanner, LucencyHeader, DefaultFooter, qTab},
  52. props:['uLang','pType'],
  53. data(){
  54. return {
  55. langType: langMap.lang,
  56. lang: this.uLang?this.uLang:langMap.lang.cn,
  57. productId: null,
  58. types: pTypes,
  59. type: '',
  60. productTypeText: getTypeText(this.pType),
  61. productTypeSubText: getTypeSubText(this.pType),
  62. productDetail: {},
  63. }
  64. },
  65. beforeMount() {
  66. const queryString = window.location.search;
  67. const params = new URLSearchParams(queryString);
  68. if(params&&params.get('id')){
  69. this.productId = params.get('id');
  70. }else{
  71. window.location.href = '/product'
  72. }
  73. this.loadProductDetail();
  74. },
  75. mounted() {
  76. console.log(this.pType);
  77. console.log(this.type);
  78. this.type = this.pType;
  79. },
  80. methods:{
  81. getLangText(str) {
  82. return langMap.getText(this.lang, str);
  83. },
  84. getAbbrText(str) {
  85. return langMap.getAbbrText(this.lang, str);
  86. },
  87. async loadProductDetail(){
  88. let err,res;
  89. let url = `/api/getProduct.php?id=${this.productId}`;
  90. [err,res] = await handle(this.$axios.get(url));
  91. if(err){
  92. console.error(err);
  93. return alert(err.message);
  94. }
  95. let result = res.data;
  96. if(result.rcode === 1){
  97. this.productDetail = result.data;
  98. console.log(this.productDetail.detail)
  99. this.productDetail.detail = unescape(this.productDetail.detail);
  100. console.log(this.productDetail.detail)
  101. }else{
  102. console.log('not match result');
  103. console.log(result);
  104. return alert('加载产品失败!!!');
  105. }
  106. },
  107. }
  108. }
  109. </script>
  110. <style scoped>
  111. .big-title {
  112. margin: 5px auto;
  113. justify-content: left;
  114. }
  115. .product-view{
  116. height: auto;
  117. min-height: 680px;
  118. /*width: 100%;*/
  119. border-top: 1px solid #dedede;
  120. display: flex;
  121. }
  122. .product-view .left{
  123. width: 320px;
  124. height: auto;
  125. }
  126. .product-view .left .imgView{
  127. width: 300px;
  128. height: 300px;
  129. margin: 10px;
  130. position: relative;
  131. }
  132. .product-view .left .imgView img{
  133. display: block;
  134. width: 100%;
  135. height: 100%;
  136. }
  137. .product-view .right{
  138. width: calc(100% - 320px);
  139. height: auto;
  140. }
  141. .product-view .right .remark{
  142. padding: 10px 5px;
  143. border-left: 1px solid #b6b6b6;
  144. margin-top: 5px;
  145. box-sizing: border-box;
  146. }
  147. .product-view .left .concatUs{
  148. width: 100%;
  149. height: auto;
  150. border-top: 1px solid gray;
  151. }
  152. .product-view .left .concatUs .chunk{
  153. width: 90%;
  154. margin: 5px auto;
  155. display: flex;
  156. padding: 5px 15px;
  157. justify-content: center;
  158. font-size: 1.4rem;
  159. border-radius: 3px;
  160. box-shadow: 0 0 5px gainsboro;
  161. cursor: pointer;
  162. }
  163. .product-view .left .concatUs .chunk:hover{
  164. background-color: skyblue;
  165. color: white;
  166. }
  167. .product-detail{
  168. margin-top: 20px;
  169. border-top: 1px solid gainsboro;
  170. }
  171. .tab-header{
  172. display: flex;
  173. }
  174. .tab-header .header-title{
  175. }
  176. </style>