club-board.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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-content">
  12. <!-- 机构活跃统计 -->
  13. <view class="charts-box charts-box0" id="charts-box0">
  14. <echart-active
  15. ref="echart-active"
  16. :clubId="clubInfo.clubId"
  17. :totalAmount="totalData.orderTotalAmount"
  18. :totalNum="totalData.orderTotal"
  19. v-if="isRequest"
  20. />
  21. </view>
  22. <!-- 机构填写咨询记录统计 -->
  23. <view class="charts-box charts-box1" id="charts-box1">
  24. <echart-consult
  25. ref="echart-consult"
  26. :clubId="clubInfo.clubId"
  27. :totalAmount="totalData.orderTotalAmount"
  28. :totalNum="totalData.orderTotal"
  29. v-if="isRequest"
  30. />
  31. </view>
  32. </view>
  33. </template>
  34. </view>
  35. </template>
  36. <script>
  37. import { mapState, mapMutations } from 'vuex'
  38. import { debounce } from '@/common/config/common.js'
  39. import echartActive from './components/echart-active'
  40. import echartConsult from './components/echart-consult'
  41. import chartMixin from './components/mixins/chart.mixin.js'
  42. const observers = {}
  43. export default {
  44. mixins: [chartMixin],
  45. components: {
  46. echartActive,
  47. echartConsult,
  48. },
  49. data() {
  50. return {
  51. skeletonShow: true,
  52. isRequest: false,
  53. clubInfo: {},
  54. clubUserInfo: {},
  55. tabCurrentIndex: 0,
  56. anchorList: [], // 锚点元素节点信息
  57. anchorStatus: [0, 0, 0, 0, 0], // 分别代表5个锚点区域的开关 0:关 1:开
  58. totalData: {
  59. orderTotalAmount: 0, // 订单总金额
  60. orderTotal: 0, // 订单总量
  61. remarksTotal: 0, // 所有咨询记录条数
  62. totalKeywords: 0 // 所有关键词条数
  63. }
  64. }
  65. },
  66. onLoad(option) {
  67. this.getClubInfo(option.userId)
  68. },
  69. onReady() {
  70. console.log('onReady')
  71. setTimeout(() => {
  72. this.getAnchorSection()
  73. }, 2000)
  74. },
  75. methods: {
  76. async getClubInfo(userId) {
  77. //获取机构信息
  78. try {
  79. const clubRes = await this.UserService.OrganizationUpdateModifyInfo({ userId: 666747 })
  80. this.clubInfo = clubRes.data.club
  81. this.clubUserInfo = clubRes.data.user
  82. const tialRes = await this.UserService.userClubInitial({ clubId: this.clubInfo.clubId })
  83. this.totalData.orderTotal = tialRes.data.orderTotal
  84. this.totalData.orderTotalAmount = tialRes.data.orderTotalAmount
  85. this.totalData.remarksTotal = tialRes.data.remarksTotal
  86. this.totalData.totalKeywords = tialRes.data.totalKeywords
  87. setTimeout(() => {
  88. this.skeletonShow = false
  89. this.isRequest = true
  90. }, 1000)
  91. } catch (error) {
  92. console.log(error)
  93. }
  94. },
  95. tabChange(index) {
  96. this.tabCurrentIndex = index
  97. this.scrollToAnchor()
  98. },
  99. // 获取锚点元素信息
  100. getAnchorSection() {
  101. const query = uni.createSelectorQuery().in(this)
  102. query
  103. .selectAll('.charts-box')
  104. .boundingClientRect(data => {
  105. if (data.length > 0) {
  106. this.anchorList = data
  107. this.anchorList.forEach((dom, index) => {
  108. uni.createSelectorQuery()
  109. .select('.charts-content')
  110. .boundingClientRect(data => {
  111. //目标节点、也可以是最外层的父级节点
  112. uni.createSelectorQuery()
  113. .select(`#${dom.id}`)
  114. .boundingClientRect(res => {
  115. //dom
  116. dom.top = res.top - data.top + 8
  117. })
  118. .exec()
  119. })
  120. .exec()
  121. })
  122. console.log(this.anchorList)
  123. this.observerAnchor(data)
  124. }
  125. })
  126. .exec()
  127. },
  128. // 滚动到锚点
  129. scrollToAnchor() {
  130. let scrollTop = 0
  131. const query = uni.createSelectorQuery().in(this)
  132. if (this.tabCurrentIndex > 0) {
  133. scrollTop = this.anchorList[this.tabCurrentIndex].top
  134. }
  135. uni.pageScrollTo({
  136. scrollTop: scrollTop
  137. })
  138. },
  139. // 为需要观测的区域创建观测者
  140. observerAnchor(selectorList = []) {
  141. const height = uni.getSystemInfoSync().windowHeight - 70
  142. selectorList.forEach((selector, index) => {
  143. observers[selector.id] = uni.createIntersectionObserver(this)
  144. observers[selector.id].relativeToViewport({ bottom: -height }).observe(`#${selector.id}`, res => {
  145. if (res.intersectionRatio > 0) {
  146. this.anchorStatus[index] = 1
  147. // console.log(index, `当前区域为${selector.id}标签选择器的区域...`)
  148. } else {
  149. this.anchorStatus[index] = 0
  150. // console.log(index, `离开区域为${selector.id}标签选择器的区域...`)
  151. }
  152. })
  153. })
  154. }
  155. },
  156. onPageScroll(e) {
  157. this.scrollTop = e.scrollTop
  158. },
  159. onShow() {}
  160. }
  161. </script>
  162. <style lang="scss">
  163. page {
  164. background-color: #f5f5f5 !important;
  165. }
  166. .container {
  167. width: 100%;
  168. height: auto;
  169. box-sizing: border-box;
  170. padding: 24rpx;
  171. }
  172. .charts-navbar {
  173. width: 100%;
  174. height: 90rpx;
  175. background-color: #ffffff;
  176. box-sizing: border-box;
  177. padding: 20rpx 0;
  178. display: flex;
  179. position: fixed;
  180. top: 0;
  181. left: 0;
  182. z-index: 9999999;
  183. .nav-item {
  184. display: flex;
  185. flex: 1;
  186. justify-content: center;
  187. align-items: center;
  188. height: 50rpx;
  189. font-size: $font-size-28;
  190. color: $text-color;
  191. position: relative;
  192. float: left;
  193. position: relative;
  194. .line {
  195. width: 60rpx;
  196. height: 2px;
  197. border-radius: 1px;
  198. background: #ffffff;
  199. position: absolute;
  200. bottom: 0;
  201. left: 50%;
  202. margin-left: -30rpx;
  203. }
  204. &.current {
  205. color: $color-system;
  206. .line {
  207. background: $color-system;
  208. }
  209. }
  210. }
  211. }
  212. .charts-content {
  213. width: 100%;
  214. height: auto;
  215. }
  216. .charts-box {
  217. width: 100%;
  218. min-height: 350rpx;
  219. box-sizing: border-box;
  220. padding: 34rpx 24rpx;
  221. background-color: #fff;
  222. margin-bottom: 32rpx;
  223. border-radius: 16rpx;
  224. float: left;
  225. .echart-content {
  226. width: 100%;
  227. .echart-title {
  228. width: 100%;
  229. height: 96rpx;
  230. float: left;
  231. box-sizing: border-box;
  232. .e-name {
  233. float: left;
  234. line-height: 56rpx;
  235. font-size: 30rpx;
  236. color: #333;
  237. }
  238. .e-more {
  239. float: right;
  240. line-height: 56rpx;
  241. font-size: 28rpx;
  242. color: #999999;
  243. }
  244. }
  245. .echart-main {
  246. width: 100%;
  247. min-height: 200rpx;
  248. box-sizing: border-box;
  249. padding: 32rpx 40rpx;
  250. position: relative;
  251. float: left;
  252. background-color: #f7f7f7;
  253. .echart-text {
  254. width: 100%;
  255. line-height: 40rpx;
  256. margin-bottom: 20rpx;
  257. font-size: 28rpx;
  258. color: #333;
  259. float: left;
  260. .label {
  261. color: #999;
  262. text-align-last: justify;
  263. }
  264. }
  265. .echart-next {
  266. width: 100rpx;
  267. height: 100%;
  268. position: absolute;
  269. right: 10rpx;
  270. top: 50%;
  271. font-size: 28rpx;
  272. color: #1890f9;
  273. }
  274. }
  275. .echart-mains {
  276. width: 100%;
  277. min-height: 350rpx;
  278. float: left;
  279. &.demand{
  280. min-height: 200rpx;
  281. }
  282. .echart-mains-none {
  283. width: 100%;
  284. height: 100%;
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. flex-direction: column;
  289. .none-image {
  290. width: 220rpx;
  291. height: 220rpx;
  292. margin-bottom: 20rpx;
  293. }
  294. .none-text {
  295. font-size: $font-size-28;
  296. color: #999999;
  297. line-height: 44rpx;
  298. }
  299. }
  300. }
  301. }
  302. }
  303. </style>