projectsDemoDetail.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. const { createApp, ref ,onMounted,createVNode, render} = Vue
  2. createApp({
  3. setup() {
  4. onMounted(()=>{
  5. productList()
  6. newsDetails()
  7. })
  8. const baseURL = ref('http://61.164.207.46:8002/yos/rest/index')
  9. const data = ref([])
  10. const productData = ref([])
  11. const axt_class = ref({})
  12. const productList = async ()=>{
  13. const res = await instance.post('',{
  14. "id": "20240801134003",
  15. "content": {
  16. "siteid":"HY",
  17. "sat_sharematerialid":getQueryParam('id'),
  18. "where":{
  19. "condition":""
  20. }
  21. }
  22. })
  23. productData.value = res.data.data
  24. }
  25. const detailData = ref({})
  26. const newsDetails = async ()=>{
  27. const res = await instance.post('',{
  28. "id":20240801134203,
  29. "content": {
  30. 'siteid':'HY',
  31. "sat_sharematerialid":getQueryParam('id')
  32. }
  33. })
  34. if (res.data.code == 1) {
  35. detailData.value = res.data.data
  36. tool.modulesClick('工程案例',detailData.value.title)
  37. }
  38. }
  39. const getQueryParam = (name)=> {
  40. // 获取当前页面的URL
  41. var url = window.location.search;
  42. // 去除URL中的"?"
  43. var search = url.substring(1);
  44. // 将查询字符串分割成键值对数组
  45. var params = search.split("&");
  46. // 遍历键值对数组
  47. for (var i = 0; i < params.length; i++) {
  48. // 将每个键值对分割成键和值
  49. var pair = params[i].split("=");
  50. // 如果键匹配,则返回对应的值
  51. if (decodeURIComponent(pair[0]) === name) {
  52. return decodeURIComponent(pair[1] || '');
  53. }
  54. }
  55. // 如果没有找到匹配的参数,则返回null或undefined
  56. return null;
  57. }
  58. const linkOf = (url)=> {
  59. window.location.href = url
  60. }
  61. const queryFaid = async (item)=>{
  62. const res = await instance.post('',{
  63. "id": "2024100815094203",
  64. "content": {
  65. "siteid":"HY",
  66. "itemid":item.itemid
  67. }
  68. })
  69. if (res.data.data.length == 0) {
  70. // alert('该产品未收录在产品名录中')
  71. tool.alert('该产品未收录在产品名录中')
  72. } else {
  73. linkOf(`./productDetail.html?id=` + res.data.data[0].sa_fadid)
  74. }
  75. }
  76. return {
  77. data,
  78. productList,
  79. productData,
  80. axt_class,
  81. getQueryParam,
  82. newsDetails,
  83. detailData,
  84. linkOf,
  85. queryFaid
  86. }
  87. }
  88. }).mount('#app')