Bläddra i källkod

feat: 新增移动端标讯详情页接口调用相关逻辑

cuiyalong 1 år sedan
förälder
incheckning
27b5f4f890

+ 1 - 0
apps/mobile/package.json

@@ -14,6 +14,7 @@
   "dependencies": {
     "@jy/data-models": "workspace:^",
     "@jy/vue-anti": "workspace:^",
+    "@jy/util": "workspace:^",
     "@sentry/vue": "^7.64.0",
     "@tinymce/tinymce-vue": "^3.2.8",
     "dayjs": "^1.11.8",

+ 1 - 0
apps/mobile/src/api/index.js

@@ -1,5 +1,6 @@
 import service from './service'
 import './interceptors-anti'
 import './interceptors'
+import './interceptors-data-models'
 
 export default service

+ 4 - 0
apps/mobile/src/api/interceptors-data-models.js

@@ -0,0 +1,4 @@
+import service from './service'
+import { injectRequest } from '@jy/data-models'
+
+injectRequest(service)

+ 40 - 0
apps/mobile/src/api/modules/article.js

@@ -0,0 +1,40 @@
+import request from '@/api'
+import qs from 'qs'
+
+// 三级页前置接口
+export function getArticlePreAgentInfo(params) {
+  return request({
+    url: '/publicapply/detail/preAgent',
+    method: 'get',
+    params
+  })
+}
+
+// 三级页基本信息接口
+export function getArticleBaseInfo(data) {
+  data = qs.stringify(data)
+  return request({
+    url: '/publicapply/detail/baseInfo',
+    method: 'post',
+    data
+  })
+}
+
+// 三级页进阶信息
+export function getArticleAdvancedInfo(data) {
+  data = qs.stringify(data)
+  return request({
+    url: '/publicapply/detail/advancedInfo',
+    method: 'post',
+    data
+  })
+}
+
+// 三级页分享信息
+export function getArticleShareInfo(data) {
+  return request({
+    url: '/publicapply/detail/shareInfo',
+    method: 'post',
+    data
+  })
+}

+ 11 - 0
apps/mobile/src/api/modules/bigmember.js

@@ -97,6 +97,17 @@ export function bigmemberFollowAndClaim(data) {
   })
 }
 
+// 查询项目是否已经关注
+// 同时, 查询标讯是否关联有可关注的项目
+export function projectFollowCheck(data) {
+  data = qs.stringify(data)
+  return request({
+    url: '/bigmember/follow/project/check',
+    method: 'post',
+    data
+  })
+}
+
 // 获取项目详情
 export function projectDetailApi(data) {
   data = qs.stringify(data)

+ 14 - 0
apps/mobile/src/api/modules/public.js

@@ -268,6 +268,20 @@ export function getActivityConfig(data) {
   })
 }
 
+// 标讯收藏
+// data = {
+//   bids: 'id1,id2,id3', // 标讯id, 多个需要用逗号隔开
+//   label: 'info' // 如果收藏了, 查询并返回当前收藏的标签
+// }
+export function checkArticleIsCollect(data) {
+  data = qs.stringify(data)
+  return request({
+    url: '/publicapply/bidcoll/isColl',
+    method: 'post',
+    data
+  })
+}
+
 // nps
 export function getNpsData() {
   return request({

+ 2 - 0
apps/mobile/src/store/index.js

@@ -7,6 +7,7 @@ import createOrder from './modules/createOrder'
 import message from './modules/message'
 import ent from './modules/ent'
 import points from './modules/points'
+import article from './modules/article'
 
 if (import.meta.env.DEV) {
   Vue.use(Vuex)
@@ -45,6 +46,7 @@ export default new Vuex.Store({
     message,
     createOrder,
     ent,
+    article,
     points
   }
 })

+ 220 - 0
apps/mobile/src/store/modules/article.js

@@ -0,0 +1,220 @@
+import { appStorage } from '@/utils/storage'
+import { cloneDeep } from 'lodash'
+import useContentModel from '@jy/data-models/modules/article/model/content'
+import useExpandModel from '@jy/data-models/modules/article/model/expand'
+
+import {
+  getArticleAdvancedInfo,
+  getArticlePreAgentInfo,
+  getArticleBaseInfo
+} from '@/api/modules/article'
+
+const { model: mainModel, transformModel: contentTransform } = useContentModel()
+const { model: expandModel, transformModel: expandTransform } = useExpandModel()
+
+console.log(useContentModel(), expandModel)
+
+const CACHE_HISTORY_KEY = 'MOBILE_ARTICLE_CONTENT'
+const storageConf = {
+  login: true,
+  storage: sessionStorage
+}
+
+const defaultValueMap = {
+  preAgentInfo: {
+    token: ''
+  },
+  reqInfo: {
+    baseInfoReqToken: ''
+  },
+  otherModel: {
+    hasProject: false, // 当前标讯是否关联有项目,如果有,则可以点击查看项目信息
+    forecastShow: false, // 是否显示中标企业预测
+  },
+  mainModel,
+  expandModel
+  // mainModel: {
+  //   content: {
+  //     id: '', // ABCY1xFfylYGSY7I2Bhc3ISCzAoIyFmYXh1KSgwNi8NaGpzZg1UCbM%3D
+  //     isSelfSite: false,
+  //     projectCode: '', // HNEC-YGZB230061001H013
+  //     projectName: '', // 鹤壁煤电股份有限公司2023年设备采购第三批八矿水环真空泵
+  //     title: '',// '[公开招标]鹤壁煤电股份有限公司2023年设备采购第三批八矿水环真空泵中标结果公告'
+  //     keys: [], // ['发布', '信息']
+  //     tags: [
+  //       // {
+  //       //   label: '河南-鹤壁市-淇滨区',
+  //       //   link: 'javascript:volid(0);'
+  //       // },
+  //       // {
+  //       //   label: '成交',
+  //       //   link: '/list/stype/ZBJG.html'
+  //       // },
+  //       // {
+  //       //   label: '能源化工',
+  //       //   link: 'javascript:volid(0);'
+  //       // },
+  //       // {
+  //       //   label: '1159.8万元',
+  //       //   link: 'javascript:volid(0);'
+  //       // },
+  //       // {
+  //       //   label: '2023-06-06',
+  //       //   link: 'javascript:volid(0);'
+  //       // }
+  //     ],
+  //     tdk: {
+  //       description: '',
+  //       // '[公开招标]鹤壁煤电股份有限公司2023年设备采购第三批八矿水环真空泵中标结果公告,项目所属地区是河南鹤壁市,项目采购单位是鹤壁煤电股份有限公司,项目发布时间是2023年06月06日,查看该项目信息详情请访问剑鱼标讯官网。',
+  //       keywords: '',
+  //       // '鹤壁煤电股份有限公司,淄博水环真空泵厂有限公司,成交公告,河南招标,鹤壁市招标,剑鱼标讯',
+  //       title: '',
+  //       // '[公开招标]鹤壁煤电股份有限公司2023年设备采购第三批八矿水环真空泵中标结果公告'
+  //     }
+  //   },
+  //   summary: {
+  //     buyers: [],
+  //     list: [],
+  //     winners: []
+  //   }
+  // },
+  // expandModel: {
+  //   services: [],
+  //   projectProgress: {},
+  //   recommendBuyers: [],
+  //   recommendCustomers: [],
+  //   recommendWinners: [],
+  //   recommendProjects: []
+  // }
+}
+
+export default {
+  namespaced: true,
+  state() {
+    return appStorage.get(
+      CACHE_HISTORY_KEY,
+      cloneDeep(defaultValueMap),
+      storageConf
+    )
+  },
+  mutations: {
+    // 重置store数据
+    resetStore(state, resetKey) {
+      if (resetKey) {
+        state[resetKey] = cloneDeep(defaultValueMap[resetKey]) || {}
+      } else {
+        const keysArr = Object.keys(state)
+        keysArr.forEach((key) => {
+          state[key] = cloneDeep(defaultValueMap[key]) || {}
+        })
+      }
+    },
+    clearStorage() {
+      appStorage.rm(CACHE_HISTORY_KEY, storageConf)
+    },
+    saveToStorage(state) {
+      appStorage.set(CACHE_HISTORY_KEY, state, storageConf)
+    },
+    setPreAgentInfo(state, payload) {
+      state.preAgentInfo = payload
+    },
+    setBaseInfoReqToken(state, payload) {
+      state.reqInfo.baseInfoReqToken = payload
+    },
+    setMainContentModel(state, payload) {
+      state.mainModel = payload
+    },
+    setMainContentModelChild(state, { key, data }) {
+      if (state.mainModel.content) {
+        state.mainModel.content[key] = data
+      }
+    },
+    setMainSummaryModelChild(state, { key, data }) {
+      if (state.mainModel.summary) {
+        state.mainModel.summary[key] = data
+      }
+    },
+    setExpandModel(state, payload) {
+      state.expandModel = payload
+    },
+    setExpandModelChild(state, { key, data }) {
+      if (state.expandModel) {
+        state.expandModel[key] = data
+      }
+    },
+    setOtherModelChild(state, { key, data }) {
+      state.otherModel[key] = data
+    }
+  },
+  actions: {
+    resetThisStore({ commit }) {
+      commit('clearStorage')
+      commit('resetStore')
+    },
+    removeStoreAsync({ commit }, key) {
+      commit('clearStorage')
+      commit('resetStore', key)
+      commit('saveToStorage')
+    },
+    async getPreAgentInfo({ commit }) {
+      try {
+        const {
+          error_code: code,
+          error_msg: msg,
+          data
+        } = await getArticlePreAgentInfo()
+        if (code === 0 && data) {
+          commit('setPreAgentInfo', data)
+        } else {
+          console.log(msg)
+        }
+      } catch (error) {
+        console.log(error)
+      }
+    },
+    async getBaseInfo({ commit, state }) {
+      const { preAgentInfo } = state
+      try {
+        const {
+          error_code: code,
+          error_msg: msg,
+          data
+        } = await getArticleBaseInfo({ token: preAgentInfo.token })
+        if (code === 0 && data) {
+          const r = contentTransform(data)
+          commit('setMainContentModel', r)
+          commit('setBaseInfoReqToken', data.token)
+        } else {
+          console.log(msg)
+        }
+      } catch (error) {
+        console.log(error)
+      }
+    },
+    async getAdvancedInfo({ commit, state }) {
+      const { reqInfo } = state
+      const token = reqInfo.baseInfoReqToken
+      if (!token) return
+      try {
+        const {
+          error_code: code,
+          error_msg: msg,
+          data
+        } = await getArticleAdvancedInfo({ token })
+        if (code === 0 && data) {
+          const r = expandTransform(data)
+          commit('setExpandModel', r)
+        } else {
+          console.log(msg)
+        }
+      } catch (error) {
+        console.log(error)
+      }
+    }
+  },
+  getters: {
+    biddingSearchHistory(state) {
+      return state.searchHistory.bidding
+    }
+  }
+}

+ 1 - 0
apps/mobile/src/store/modules/user.js

@@ -303,6 +303,7 @@ export default {
     isHasFreeKey(state) {
       return state.power?.freeHasKey || false
     },
+    // 是否新商机管理用户
     isNewBusiness(state) {
       return state.power?.entIsNew || false
     },

+ 1 - 1
apps/mobile/src/views/article/components/NpsCard.vue

@@ -91,7 +91,7 @@ export default {
     },
     // emoji表情转为字符
     utf16toEntities(str) {
-      const patt = /[\ud800-\udbff][\udc00-\udfff]/g; // 检测utf16字符正则
+      const patt = /[\ud800-\udbff][\udc00-\udfff]/g // 检测utf16字符正则
       str = str.replace(patt, function (char) {
         let H, L, code
         if (char.length === 2) {

+ 0 - 2
data/data-models/modules/article/transform/summary2.js

@@ -175,8 +175,6 @@ class SummaryModel extends BaseModel {
     result.list = list
     result.originMap = summary
 
-    console.log(result)
-
     return result
   }