index.vue 4.4 KB

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