index.vue 12 KB

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