echart-contact.vue 5.0 KB

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