club-portrait.vue 10 KB

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