index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <Page styleReset="headerClass">
  3. <template v-slot:headerLeft>
  4. <div class="homeheaderleft">
  5. <img src="/src/assets/image/home_logo.png">
  6. <div class="text-white">客户管家</div>
  7. </div>
  8. </template>
  9. <template v-slot:body>
  10. <div class="home-theContent">
  11. <!-- 固定头部 -->
  12. <div class="home-theContent-title">
  13. <div class="item" v-for="(item, index) in addQuickList" :key="index">
  14. <div class="item-img" @click="jumpAdd(item)">
  15. <img :src="getRouterImg(item.path)" alt="">
  16. </div>
  17. <div class="item-text">建{{ item.name }}</div>
  18. </div>
  19. </div>
  20. <!-- 可以滚动 -->
  21. <div class="rollingLayout">
  22. <!-- 模块配置 -->
  23. <div class="layoutOfEachModule">
  24. <div class="item" v-for="(item, index) in addCommonlyUsedList" :key="index" @click="jumpList(item)">
  25. <div class="item-img"><img :src="getRouterImg(item.path)" alt=""></div>
  26. <div class="item-text">{{ item.name }}</div>
  27. </div>
  28. <div class="item" @click="showBottom = true">
  29. <div class="item-img">
  30. <img src="/src/assets/image/add.png"></img>
  31. </div>
  32. <div class="item-text">配置</div>
  33. </div>
  34. </div>
  35. <!-- 销售简报、数据汇总、商机阶段 -->
  36. <DataAnalysis></DataAnalysis>
  37. <!-- 常用联系人 -->
  38. <div class="mt-3">
  39. <div class="text-size-large text-[#000] pl16">常用联系人</div>
  40. <div class="p16 pt-0 pb-0">
  41. <template v-if="topContactsList && topContactsList.length > 0">
  42. <template v-for="item in topContactsList">
  43. <div class="flex flex-row items-center rounded-md p-4 bg-white mb-5" @click="toContactDetails(item)">
  44. <div class="contactImage">
  45. <img class="w-full h-full" src="/src/assets/image/topContacts.png">
  46. </div>
  47. <div class="flex-1">{{ item.name }}</div>
  48. <div class="rightArrow">
  49. <van-icon name="arrow" />
  50. </div>
  51. </div>
  52. </template>
  53. </template>
  54. <template v-else>
  55. <van-empty description="暂无常用联系人" />
  56. </template>
  57. </div>
  58. </div>
  59. </div>
  60. <!-- 弹出层 -->
  61. <van-popup v-model:show="showBottom" position="bottom">
  62. <div class="bg-[#eceeef]">
  63. <div class="w-full text-center bg-white leading-10" @click="quickListShow = true">快捷新建设置</div>
  64. <div class="w-full text-center bg-white leading-10 biankuang" @click="modulesListShow = true">常用功能设置</div>
  65. <div class="w-full text-center mt-2 text-[red] bg-white leading-10" @click="showBottom = false">取消</div>
  66. </div>
  67. </van-popup>
  68. <!-- 快捷入口设置 -->
  69. <van-popup v-model:show="quickListShow" position="bottom" :style="{ height: '100%' }" closeable>
  70. <QuickEntrance :allModulesList="allModulesList" :selectModule="addQuickList" @save-value="refreshData" />
  71. </van-popup>
  72. <!-- 常用功能设置 -->
  73. <van-popup v-model:show="modulesListShow" position="bottom" :style="{ height: '100%' }" closeable>
  74. <CommonFunctions :allModulesList="allModulesList" :selectModule="addCommonlyUsedList" @save-value="refreshData" />
  75. </van-popup>
  76. </div>
  77. </template>
  78. <template v-slot:footer>
  79. <Footer />
  80. </template>
  81. </Page>
  82. </template>
  83. <script setup>
  84. import { ref } from "vue";
  85. import { useLifecycle } from "@hooks/useCommon.js";
  86. import useInfoStore from "@store/useInfoStore"
  87. import Footer from "@components/page/footer.vue";
  88. import requests from "@common/requests"
  89. import { GET_FREQUENTLY_USED_CONTACTS, GET_FAST_ACCESS_LIST, GET_ALL_ROUTING_PARAMETERS, COMMON_FUNCTIONS } from "@hooks/useApi";
  90. import useToast from "@hooks/useToast"
  91. import { routingInfos, getRouterImg } from "@utility/generalVariables.js";
  92. import useRouterStore from "@store/useRouterStore.js";
  93. // 相关页面
  94. import DataAnalysis from './component/dataAnalysis.vue';
  95. import QuickEntrance from './component/quickEntrance.vue'
  96. import CommonFunctions from './component/commonFunctions.vue'
  97. const { toastText, toastSuccess, toastFail, toastLoading } = useToast()
  98. const router = useRouterStore()
  99. const useInfo = useInfoStore()
  100. const user = useInfo.userInfo
  101. const showBottom = ref(false)
  102. const quickListShow = ref(false)
  103. const modulesListShow = ref(false)
  104. const topContactsList = ref([])
  105. const allModulesList = [...useInfo.modularList.filter(item => item.path !== '/biReport'), { id: -1, path: '/visitor', name: '访客计划' }]
  106. const addQuickList = ref([])
  107. const addCommonlyUsedList = ref([])
  108. function getAllData() {
  109. getFrequentlyUsedContacts()
  110. getQuickList()
  111. getCommonUseList()
  112. }
  113. // 获取当前公司的常用功能列表
  114. function getCommonUseList() {
  115. requests.post(COMMON_FUNCTIONS, {}).then((res) => {
  116. addCommonlyUsedList.value = res.data.map(item => { return { ...item, path: item.router } })
  117. })
  118. }
  119. // 获取快捷新建列表
  120. function getQuickList() {
  121. requests.post(GET_FAST_ACCESS_LIST, {}).then((res) => {
  122. addQuickList.value = res.data.map(item => { return { ...item, path: item.router } })
  123. })
  124. }
  125. function getFrequentlyUsedContacts() {
  126. requests.post(GET_FREQUENTLY_USED_CONTACTS, {}).then((res) => {
  127. topContactsList.value = res.data
  128. })
  129. }
  130. function jumpAdd(rows) {
  131. if(rows.path == '/addEditorVisitor') {
  132. router.navigateTo({
  133. pathName: 'addEditorVisitor',
  134. success: () => {}
  135. })
  136. return
  137. }
  138. const jumpTo = routingInfos[rows.path.replace('/', '')]
  139. router.navigateTo({
  140. pathName: 'addEditor',
  141. success: () => {
  142. router.emit('addEditorParameter', {
  143. routerInfo: JSON.stringify(jumpTo)
  144. })
  145. }
  146. })
  147. }
  148. function jumpList(item) {
  149. if(item.path == '/visitor') {
  150. router.navigateTo({
  151. pathName: 'visitor',
  152. success: () => {}
  153. })
  154. return
  155. }
  156. const jumpTo = routingInfos[item.path.replace('/', '')]
  157. router.navigateTo({
  158. pathName: 'moduleList',
  159. success: () => {
  160. router.emit('moduleListDetailParameter', {
  161. row: JSON.stringify(jumpTo)
  162. })
  163. }
  164. })
  165. }
  166. function refreshData() {
  167. getQuickList()
  168. getCommonUseList()
  169. showBottom.value = false
  170. quickListShow.value = false
  171. modulesListShow.value = false
  172. }
  173. function obtainEnterpriseWeChatParameters(data = {}) {
  174. const token = data.id
  175. // const curUrl = window.location.href.split('home')[0]
  176. const curUrl = window.location.href
  177. requests.post('/wxcorp/getCorpWXConfig', { url: curUrl, token }).then((res) => {
  178. wx.config({
  179. beta: true,
  180. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  181. appId: res.data.appid, // 必填,公众号的唯一标识
  182. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  183. nonceStr: res.data.noncestr, // 必填,生成签名的随机串
  184. signature: res.data.sign, // 必填,签名,见附录1
  185. jsApiList: ['chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'previewFile', 'getLocation', 'agentConfig']
  186. })
  187. wx.ready(function () {
  188. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
  189. requests.post('/wxcorp/getCorpWXAgentConfig', { url: curUrl, token }).then((res) => {
  190. console.log(res, '<====== 返回的参数 /wxcorp/getCorpWXAgentConfig')
  191. wx.agentConfig({
  192. corpid: res.data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
  193. agentid: res.data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
  194. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  195. nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
  196. signature: res.data.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
  197. jsApiList: ['selectExternalContact', 'openThirdAppServiceChat', 'openAppManage'], //必填,传入需要使用的接口名称
  198. success: function (result) {
  199. // wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
  200. window.WWOpenData.bind(document.querySelector('ww-open-data'))
  201. },
  202. fail: function (res) {
  203. if (res.errMsg.indexOf('function not exist') > -1) {
  204. alert('版本过低请升级')
  205. }
  206. },
  207. })
  208. }).catch(err => {
  209. if (err.errMsg.indexOf('function not exist') > -1) {
  210. alert('版本过低请升级')
  211. }
  212. })
  213. })
  214. wx.error(function (res) {
  215. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  216. // alert('wxConfig发生异常:'+JSON.stringify(res));
  217. // 企业第一次授权安装进入后会报not in reliable domain的错误,刷新后正常
  218. // location.reload();
  219. });
  220. }).catch(err => {
  221. alert(err);
  222. })
  223. }
  224. useLifecycle({
  225. load: () => {
  226. getAllData()
  227. },
  228. init: () => {
  229. const currentEnvironment = navigator.userAgent.toLowerCase();
  230. const isCorpWX = currentEnvironment.indexOf("wxwork") > 0 ? true : false
  231. if (isCorpWX) {
  232. obtainEnterpriseWeChatParameters(userInfo.userInfo)
  233. }
  234. }
  235. });
  236. </script>
  237. <style lang="scss" scoped>
  238. :deep(.van-tabs__content) {
  239. flex: 1;
  240. overflow-y: auto;
  241. }
  242. :deep(.van-tabs__wrap) {
  243. background-color: $themeColor;
  244. }
  245. .homeheaderleft {
  246. font-size: 20px;
  247. font-weight: bold;
  248. display: flex;
  249. align-items: center;
  250. img {
  251. width: 30px;
  252. }
  253. div {
  254. margin-left: 10px;
  255. }
  256. }
  257. .home-theContent {
  258. display: flex;
  259. height: 100%;
  260. flex-direction: column;
  261. .home-theContent-title {
  262. padding: 25px;
  263. background-color: $themeColor;
  264. display: flex;
  265. .item {
  266. position: relative;
  267. display: flex;
  268. flex-direction: column;
  269. align-items: center;
  270. width: 25%;
  271. &::after {
  272. content: '';
  273. width: 1px;
  274. height: 30px;
  275. background-color: rgba($color: #fff, $alpha: 0.5);
  276. position: absolute;
  277. left: 0px;
  278. top: 0%;
  279. }
  280. &:first-child::after {
  281. width: 0;
  282. }
  283. .item-img {
  284. width: 24px;
  285. height: 24px;
  286. img {
  287. width: 100%;
  288. height: 100%;
  289. }
  290. }
  291. .item-text {
  292. color: #fff;
  293. font-size: 14px;
  294. margin-top: 8px;
  295. }
  296. }
  297. }
  298. .rollingLayout {
  299. flex: 1;
  300. overflow-y: auto;
  301. margin: 20px 0;
  302. padding: 0 20px;
  303. border-radius: 10px;
  304. .layoutOfEachModule {
  305. display: flex;
  306. flex-wrap: wrap;
  307. .item {
  308. width: 20%;
  309. display: flex;
  310. flex-direction: column;
  311. align-items: center;
  312. margin-bottom: 20px;
  313. .item-img {
  314. width: 36px;
  315. height: 36px;
  316. img {
  317. width: 100%;
  318. height: 100%;
  319. }
  320. }
  321. .item-text {
  322. color: #474A56;
  323. font-size: 14px;
  324. margin-top: 8px;
  325. }
  326. }
  327. }
  328. }
  329. }
  330. .biankuang {
  331. border-top: 1px solid #eceeef;
  332. }
  333. </style>