echart-service.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="echart-content">
  3. <view class="echart-title">
  4. <view class="e-icon e5"><text class="iconfont icon-fangwenjilu"></text></view>
  5. <view class="e-name">访问记录</view>
  6. </view>
  7. <view class="echart-search">
  8. <view class="echart-search-date">
  9. <view class="echart-search-date-input">
  10. <picker
  11. mode="date"
  12. :value="date"
  13. :start="startDate"
  14. :end="endDate"
  15. @change="bindStartDateChange($event, 3)"
  16. >
  17. <text class="input-text">{{ serviceData.startTime }}</text>
  18. </picker>
  19. <text class="iconfont icon-riqi"></text>
  20. </view>
  21. <view class="line">-</view>
  22. <view class="echart-search-date-input">
  23. <picker
  24. mode="date"
  25. :value="date"
  26. :start="startDate"
  27. :end="endDate"
  28. @change="bindEndDateChange($event, 3)"
  29. >
  30. <text class="input-text">{{ serviceData.endTime }}</text>
  31. </picker>
  32. <text class="iconfont icon-riqi"></text>
  33. </view>
  34. </view>
  35. <view class="echart-search-time">
  36. <view
  37. class="time-tab"
  38. v-for="(time, index) in timeList"
  39. :class="{ current: current === index }"
  40. :key="index"
  41. @click="handleTimeClick(time.current, index, 3)"
  42. >{{ time.label }}</view
  43. >
  44. </view>
  45. </view>
  46. <view class="echart-mains">
  47. <view class="echart-mains-none" v-if="isEmpty">
  48. <image
  49. class="none-image"
  50. src="https://static.caimei365.com/app/img/bg/icon_echart_none@2x.png"
  51. mode=""
  52. ></image>
  53. <view class="none-text">暂无数据</view>
  54. </view>
  55. <view class="echart-mains-data" v-else>
  56. <qiun-data-charts type="column" :opts="opts" :chartData="serviceChartData" :animation="false" />
  57. </view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import { mapState, mapMutations } from 'vuex'
  63. import chartMixin from './mixins/chart.mixin.js'
  64. export default {
  65. mixins: [chartMixin],
  66. props:{
  67. clubId:{
  68. type:Number,
  69. default:0
  70. }
  71. },
  72. data() {
  73. return {
  74. isEmpty:false,
  75. current: 0,
  76. serviceChartData:null,
  77. serviceData:{
  78. startTime: '',
  79. endTime: ''
  80. },
  81. params:{
  82. clubId:0,// 机构id
  83. dateType:3,// 日期类别 0日 1月 2半年 3全年
  84. startTime:'',// 开始时间
  85. endTime:'',// 结束时间
  86. type:0 // 统计类别 0订单 1搜索关键词 2咨询记录 3访问记录 4初始状态
  87. },
  88. opts: {
  89. legend: {
  90. show: false
  91. },
  92. color: ['#74b9ff'],
  93. dataLabel: true,
  94. padding: [15, 30, 0, 5],
  95. enableScroll: false,
  96. xAxis: {
  97. disableGrid: true,
  98. min: 0,
  99. axisLine: false,
  100. max: 40,
  101. rotateLabel: true,
  102. format: 'xAxisDemo3'
  103. },
  104. yAxis: {
  105. fontSize: 12,
  106. fontColor: '#CCCCCC',
  107. axisLineColor: '#DCDCDC',
  108. gridColor: '#DCDCDC',
  109. boundaryGap: 'justify',
  110. disabled: true,
  111. axisLine: false,
  112. min: 0,
  113. max: 40
  114. },
  115. extra: {
  116. column: {
  117. type: 'group',
  118. width: 20,
  119. meterBorde: 1,
  120. meterFillColor: '#FFFFFF',
  121. activeBgColor: '#000000',
  122. activeBgOpacity: 0.08,
  123. seriesGap: 2,
  124. categoryGap: 3,
  125. barBorderCircle: false,
  126. linearType: 'custom',
  127. linearOpacity: 1,
  128. customColor: ['#0984e3', '#74b9ff'],
  129. colorStop: 0
  130. }
  131. }
  132. }
  133. }
  134. },
  135. created() {
  136. this.params.clubId = this.clubId
  137. this.userClubPortrait(3)
  138. },
  139. methods: {
  140. handleTimeClick(dateType,index,type) {
  141. //年月日点击
  142. console.log('dateType', dateType)
  143. this.current = index
  144. this.params.dateType = dateType
  145. this.params.startTime = ''
  146. this.params.endTime = ''
  147. this.userClubPortrait(type)
  148. },
  149. async userClubPortrait(type){
  150. this.params.type = type
  151. this.serviceData.startTime = this.params.startTime
  152. this.serviceData.endTime = this.params.endTime
  153. try {
  154. const res = await this.UserService.userClubPortrait(this.params)
  155. const data = res.data
  156. this.serviceData.startTime = this.params.startTime = data.portrait.startTime
  157. this.serviceData.endTime = this.params.endTime = data.portrait.endTime
  158. if(data.pageType){
  159. this.isEmpty = false
  160. this.getSetServiceData(data.pageType)
  161. }else{
  162. this.isEmpty = true
  163. }
  164. console.log('serviceData',this.serviceData)
  165. } catch (error) {
  166. this.$util.msg(error.msg, 2000)
  167. }
  168. },
  169. getSetServiceData(data) {
  170. setTimeout(() => {
  171. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  172. let res = {
  173. categories: data.name,
  174. series: [
  175. {
  176. name: '',
  177. data: data.value
  178. }
  179. ]
  180. }
  181. this.serviceChartData = JSON.parse(JSON.stringify(res))
  182. }, 500)
  183. }
  184. },
  185. onShow() {}
  186. }
  187. </script>
  188. <style lang="scss"></style>