club-portrait.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <view class="container clearfix">
  3. <tui-skeleton
  4. v-if="skeletonShow"
  5. backgroundColor="#fafafa"
  6. borderRadius="10rpx"
  7. :isLoading="true"
  8. :loadingType="5"
  9. />
  10. <template v-else>
  11. <!-- <view class="charts-navbar" id="topBar">
  12. <view
  13. class="nav-item tui-skeleton-fillet"
  14. v-for="(nav, index) in navBarList"
  15. :key="index"
  16. :class="{ current: tabCurrentIndex === nav.index }"
  17. @click="tabChange(nav.index)"
  18. >
  19. <text>{{ nav.name }}</text> <text class="line"></text>
  20. </view>
  21. </view> -->
  22. <view class="charts-content">
  23. <!-- 重点资料 -->
  24. <view class="charts-box charts-box0" id="charts-box0">
  25. <echartInfo
  26. ref="echart-info"
  27. :clubInfo="clubInfo"
  28. :clubId="clubInfo.clubId"
  29. :clubUserInfo="clubUserInfo"
  30. v-if="isRequest" />
  31. </view>
  32. <!-- 用户需求 -->
  33. <view class="charts-box charts-box0" id="charts-box0">
  34. <echartDemand
  35. ref="echartDemand"
  36. :clubId="clubInfo.clubId"
  37. :totalAmount="totalData.orderTotalAmount"
  38. :totalNum="totalData.orderTotal"
  39. v-if="isRequest"
  40. />
  41. </view>
  42. <!-- 订单 -->
  43. <view class="charts-box charts-box1" id="charts-box1">
  44. <echartOrder
  45. ref="echartOrder"
  46. :clubId="clubInfo.clubId"
  47. :totalAmount="totalData.orderTotalAmount"
  48. :totalNum="totalData.orderTotal"
  49. v-if="isRequest"
  50. />
  51. </view>
  52. <!-- 关键词 -->
  53. <view class="charts-box charts-box2" id="charts-box2">
  54. <echartKeyword
  55. ref="echartKeyword"
  56. :clubId="clubInfo.clubId"
  57. :totalNum="totalData.totalKeywords"
  58. v-if="isRequest"
  59. />
  60. </view>
  61. <!-- 咨询记录 -->
  62. <view class="charts-box charts-box3" id="charts-box3">
  63. <echartContact
  64. ref="echartContact"
  65. :clubId="clubInfo.clubId"
  66. :totalNum="totalData.remarksTotal"
  67. v-if="isRequest"
  68. />
  69. </view>
  70. <!-- 访问记录 -->
  71. <view class="charts-box charts-box4" id="charts-box4">
  72. <echartService ref="echartService" :clubId="clubInfo.clubId" v-if="isRequest" />
  73. </view>
  74. </view>
  75. </template>
  76. </view>
  77. </template>
  78. <script>
  79. import { mapState, mapMutations } from 'vuex'
  80. import { debounce } from '@/common/config/common.js'
  81. import echartInfo from './components/echart-info'
  82. import echartDemand from './components/echart-demand'
  83. import echartOrder from './components/echart-order'
  84. import echartKeyword from './components/echart-keyword'
  85. import echartContact from './components/echart-contact'
  86. import echartService from './components/echart-service'
  87. import chartMixin from './components/mixins/chart.mixin.js'
  88. const observers = {}
  89. export default {
  90. mixins: [chartMixin],
  91. components: {
  92. echartInfo,
  93. echartDemand,
  94. echartOrder,
  95. echartKeyword,
  96. echartContact,
  97. echartService
  98. },
  99. data() {
  100. return {
  101. skeletonShow: true,
  102. isRequest: false,
  103. clubInfo: {},
  104. clubUserInfo: {},
  105. navBarList: [
  106. { name: '重点资料', index: 0 },
  107. { name: '订单数据', index: 1 },
  108. { name: '搜索关键词', index: 2 },
  109. { name: '咨询记录', index: 3 },
  110. { name: '访问记录', index: 4 }
  111. ],
  112. tabCurrentIndex: 0,
  113. anchorList: [], // 锚点元素节点信息
  114. anchorStatus: [0, 0, 0, 0, 0], // 分别代表5个锚点区域的开关 0:关 1:开
  115. totalData: {
  116. orderTotalAmount: 0, // 订单总金额
  117. orderTotal: 0, // 订单总量
  118. remarksTotal: 0, // 所有咨询记录条数
  119. totalKeywords: 0 // 所有关键词条数
  120. }
  121. }
  122. },
  123. onLoad(option) {
  124. this.getClubInfo(option.userId)
  125. },
  126. onReady() {
  127. console.log('onReady')
  128. setTimeout(() => {
  129. this.getAnchorSection()
  130. }, 2000)
  131. },
  132. methods: {
  133. async getClubInfo(userId) {
  134. //获取机构信息
  135. try {
  136. const clubRes = await this.UserService.OrganizationUpdateModifyInfo({ userId: userId })
  137. this.clubInfo = clubRes.data.club
  138. this.clubUserInfo = clubRes.data.user
  139. const tialRes = await this.UserService.userClubInitial({ clubId: this.clubInfo.clubId })
  140. this.totalData.orderTotal = tialRes.data.orderTotal
  141. this.totalData.orderTotalAmount = tialRes.data.orderTotalAmount
  142. this.totalData.remarksTotal = tialRes.data.remarksTotal
  143. this.totalData.totalKeywords = tialRes.data.totalKeywords
  144. setTimeout(() => {
  145. this.skeletonShow = false
  146. this.isRequest = true
  147. }, 1000)
  148. } catch (error) {
  149. console.log(error)
  150. }
  151. },
  152. tabChange(index) {
  153. this.tabCurrentIndex = index
  154. this.scrollToAnchor()
  155. },
  156. // 获取锚点元素信息
  157. getAnchorSection() {
  158. const query = uni.createSelectorQuery().in(this)
  159. query
  160. .selectAll('.charts-box')
  161. .boundingClientRect(data => {
  162. if (data.length > 0) {
  163. this.anchorList = data
  164. this.anchorList.forEach((dom, index) => {
  165. uni.createSelectorQuery()
  166. .select('.charts-content')
  167. .boundingClientRect(data => {
  168. //目标节点、也可以是最外层的父级节点
  169. uni.createSelectorQuery()
  170. .select(`#${dom.id}`)
  171. .boundingClientRect(res => {
  172. //dom
  173. dom.top = res.top - data.top + 8
  174. })
  175. .exec()
  176. })
  177. .exec()
  178. })
  179. console.log(this.anchorList)
  180. this.observerAnchor(data)
  181. }
  182. })
  183. .exec()
  184. },
  185. // 滚动到锚点
  186. scrollToAnchor() {
  187. let scrollTop = 0
  188. const query = uni.createSelectorQuery().in(this)
  189. if (this.tabCurrentIndex > 0) {
  190. scrollTop = this.anchorList[this.tabCurrentIndex].top
  191. }
  192. uni.pageScrollTo({
  193. scrollTop: scrollTop
  194. })
  195. },
  196. // 为需要观测的区域创建观测者
  197. observerAnchor(selectorList = []) {
  198. const height = uni.getSystemInfoSync().windowHeight - 70
  199. selectorList.forEach((selector, index) => {
  200. observers[selector.id] = uni.createIntersectionObserver(this)
  201. observers[selector.id].relativeToViewport({ bottom: -height }).observe(`#${selector.id}`, res => {
  202. if (res.intersectionRatio > 0) {
  203. this.anchorStatus[index] = 1
  204. // console.log(index, `当前区域为${selector.id}标签选择器的区域...`)
  205. } else {
  206. this.anchorStatus[index] = 0
  207. // console.log(index, `离开区域为${selector.id}标签选择器的区域...`)
  208. }
  209. })
  210. })
  211. }
  212. },
  213. onPageScroll(e) {
  214. this.scrollTop = e.scrollTop
  215. },
  216. onShow() {}
  217. }
  218. </script>
  219. <style lang="scss">
  220. page {
  221. background-color: #f5f5f5 !important;
  222. }
  223. .container {
  224. width: 100%;
  225. height: auto;
  226. box-sizing: border-box;
  227. padding: 24rpx;
  228. }
  229. .charts-navbar {
  230. width: 100%;
  231. height: 90rpx;
  232. background-color: #ffffff;
  233. box-sizing: border-box;
  234. padding: 20rpx 0;
  235. display: flex;
  236. position: fixed;
  237. top: 0;
  238. left: 0;
  239. z-index: 9999999;
  240. .nav-item {
  241. display: flex;
  242. flex: 1;
  243. justify-content: center;
  244. align-items: center;
  245. height: 50rpx;
  246. font-size: $font-size-28;
  247. color: $text-color;
  248. position: relative;
  249. float: left;
  250. position: relative;
  251. .line {
  252. width: 60rpx;
  253. height: 2px;
  254. border-radius: 1px;
  255. background: #ffffff;
  256. position: absolute;
  257. bottom: 0;
  258. left: 50%;
  259. margin-left: -30rpx;
  260. }
  261. &.current {
  262. color: $color-system;
  263. .line {
  264. background: $color-system;
  265. }
  266. }
  267. }
  268. }
  269. .charts-content {
  270. width: 100%;
  271. height: auto;
  272. }
  273. .charts-box {
  274. width: 100%;
  275. min-height: 350rpx;
  276. box-sizing: border-box;
  277. padding: 34rpx 24rpx;
  278. background-color: #fff;
  279. margin-bottom: 32rpx;
  280. border-radius: 16rpx;
  281. float: left;
  282. .echart-content {
  283. width: 100%;
  284. .echart-title {
  285. width: 100%;
  286. height: 96rpx;
  287. float: left;
  288. box-sizing: border-box;
  289. padding: 16rpx 0 24rpx 0;
  290. .e-icon {
  291. width: 56rpx;
  292. height: 56rpx;
  293. float: left;
  294. text-align: center;
  295. line-height: 56rpx;
  296. border-radius: 50%;
  297. &.e1 {
  298. background-color: #1890f9;
  299. }
  300. &.e2 {
  301. background-color: #FF5B00;
  302. }
  303. &.e3 {
  304. background-color: #f2637b;
  305. }
  306. &.e4 {
  307. background-color: #f99e0a;
  308. }
  309. &.e5 {
  310. background-color: #36cbcb;
  311. }
  312. .iconfont {
  313. font-size: 30rpx;
  314. color: #fff;
  315. }
  316. }
  317. .e-name {
  318. float: left;
  319. line-height: 56rpx;
  320. font-size: 30rpx;
  321. margin-left: 24rpx;
  322. color: #333;
  323. }
  324. .e-start {
  325. float: right;
  326. line-height: 56rpx;
  327. font-size: 28rpx;
  328. color: #34cc8c;
  329. }
  330. }
  331. .echart-main {
  332. width: 100%;
  333. min-height: 200rpx;
  334. box-sizing: border-box;
  335. padding: 32rpx 40rpx;
  336. position: relative;
  337. float: left;
  338. background-color: #f7f7f7;
  339. .echart-text {
  340. width: 100%;
  341. line-height: 40rpx;
  342. margin-bottom: 20rpx;
  343. font-size: 28rpx;
  344. color: #333;
  345. float: left;
  346. .label {
  347. color: #999;
  348. text-align-last: justify;
  349. }
  350. }
  351. .echart-next {
  352. width: 100rpx;
  353. height: 100%;
  354. position: absolute;
  355. right: 10rpx;
  356. top: 50%;
  357. font-size: 28rpx;
  358. color: #1890f9;
  359. }
  360. }
  361. .echart-search {
  362. width: 100%;
  363. height: auto;
  364. float: left;
  365. margin-bottom: 58rpx;
  366. .echart-search-text {
  367. width: 100%;
  368. height: 34rpx;
  369. margin-bottom: 20rpx;
  370. .search-text {
  371. float: left;
  372. line-height: 34rpx;
  373. font-size: 24rpx;
  374. color: #333;
  375. margin-right: 20rpx;
  376. text {
  377. color: #FF5B00;
  378. }
  379. }
  380. }
  381. .echart-search-date {
  382. width: 100%;
  383. height: 56rpx;
  384. box-sizing: border-box;
  385. .line {
  386. color: #999999;
  387. float: left;
  388. line-height: 56rpx;
  389. margin: 0 20rpx;
  390. }
  391. .echart-search-date-input {
  392. width: 228rpx;
  393. height: 56rpx;
  394. border: 1px solid #e2e2e2;
  395. border-radius: 8rpx;
  396. box-sizing: border-box;
  397. padding: 0 20rpx;
  398. line-height: 56rpx;
  399. float: left;
  400. position: relative;
  401. .input-text {
  402. display: block;
  403. height: 56rpx;
  404. font-size: 24rpx;
  405. color: #666666;
  406. }
  407. .icon-riqi {
  408. color: #999;
  409. display: block;
  410. width: 40rpx;
  411. height: 56rpx;
  412. position: absolute;
  413. right: 10rpx;
  414. top: 0;
  415. line-height: 56rpx;
  416. }
  417. }
  418. }
  419. .echart-search-time {
  420. width: 100%;
  421. height: 40rpx;
  422. margin-top: 24rpx;
  423. .time-tab {
  424. width: 80rpx;
  425. height: 40rpx;
  426. float: left;
  427. border-radius: 20rpx;
  428. margin-right: 24rpx;
  429. box-sizing: border-box;
  430. border: 1px solid #b2b2b2;
  431. line-height: 38rpx;
  432. font-size: 24rpx;
  433. text-align: center;
  434. color: #999;
  435. &.current {
  436. background-color: #fef6f3;
  437. border-color: #FF5B00;
  438. color: #FF5B00;
  439. }
  440. }
  441. }
  442. }
  443. .echart-mains {
  444. width: 100%;
  445. min-height: 300rpx;
  446. float: left;
  447. &.demand{
  448. min-height: 200rpx;
  449. }
  450. .echart-mains-none {
  451. width: 100%;
  452. height: 100%;
  453. display: flex;
  454. align-items: center;
  455. justify-content: center;
  456. flex-direction: column;
  457. .none-image {
  458. width: 220rpx;
  459. height: 220rpx;
  460. margin-bottom: 20rpx;
  461. }
  462. .none-text {
  463. font-size: $font-size-28;
  464. color: #999999;
  465. line-height: 44rpx;
  466. }
  467. }
  468. }
  469. }
  470. }
  471. </style>