echart-contact.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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>{{ 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. totalNum:{
  76. type:Number,
  77. default:0
  78. }
  79. },
  80. data() {
  81. return {
  82. isEmpty:false,
  83. current: 0,
  84. remarksTotal:0,
  85. contactChartData:null,
  86. contactData:{
  87. startTime: '',
  88. endTime: '',
  89. remarksScopeNum:0
  90. },
  91. params:{
  92. clubId:0,// 机构id
  93. dateType:3,// 日期类别 0日 1月 2半年 3全年
  94. startTime:'',// 开始时间
  95. endTime:'',// 结束时间
  96. type:0 // 统计类别 0订单 1搜索关键词 2咨询记录 3访问记录 4初始状态
  97. },
  98. opts: {
  99. legend: {
  100. show: false
  101. },
  102. color: ['#81ecec'],
  103. dataLabel: true,
  104. padding: [15, 30, 0, 5],
  105. enableScroll: false,
  106. xAxis: {
  107. disableGrid: true,
  108. min: 0,
  109. axisLine: false,
  110. max: 40,
  111. rotateLabel: true,
  112. format: 'xAxisDemo3'
  113. },
  114. yAxis: {
  115. fontSize: 12,
  116. fontColor: '#CCCCCC',
  117. axisLineColor: '#DCDCDC',
  118. gridColor: '#DCDCDC',
  119. boundaryGap: 'justify',
  120. disabled: true,
  121. axisLine: false,
  122. min: 0,
  123. max: 40
  124. },
  125. extra: {
  126. column: {
  127. type: 'group',
  128. width: 20,
  129. meterBorde: 1,
  130. meterFillColor: '#FFFFFF',
  131. activeBgColor: '#000000',
  132. activeBgOpacity: 0.08,
  133. seriesGap: 2,
  134. categoryGap: 3,
  135. barBorderCircle: false,
  136. linearType: 'custom',
  137. linearOpacity: 1,
  138. customColor: ['#00cec9', '#81ecec'],
  139. colorStop: 0
  140. }
  141. }
  142. }
  143. }
  144. },
  145. created() {
  146. this.params.clubId = this.clubId
  147. this.remarksTotal = this.totalNum
  148. this.userClubPortrait(2)
  149. },
  150. methods: {
  151. handleTimeClick(dateType,index,type) {
  152. //年月日点击
  153. console.log('dateType', dateType)
  154. this.current = index
  155. this.params.dateType = dateType
  156. this.params.startTime = ''
  157. this.params.endTime = ''
  158. this.userClubPortrait(type)
  159. },
  160. async userClubPortrait(type){
  161. this.params.type = type
  162. this.contactData.startTime = this.params.startTime
  163. this.contactData.endTime = this.params.endTime
  164. try {
  165. const res = await this.UserService.userClubPortrait(this.params)
  166. const data = res.data
  167. this.contactData.remarksScopeNum = data.portrait.remarksScopeNum
  168. this.contactData.startTime = this.params.startTime = data.portrait.startTime
  169. this.contactData.endTime = this.params.endTime = data.portrait.endTime
  170. if(data.remarks){
  171. this.isEmpty = false
  172. this.getSetContactData(data.remarks)
  173. }else{
  174. this.isEmpty = true
  175. }
  176. console.log('contactData',this.contactData)
  177. } catch (error) {
  178. this.$util.msg(error.msg, 2000)
  179. }
  180. },
  181. getSetContactData(data) {
  182. setTimeout(() => {
  183. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  184. let res = {
  185. categories:data.name,
  186. series: [
  187. {
  188. name: '',
  189. data: data.value
  190. }
  191. ]
  192. }
  193. this.contactChartData = JSON.parse(JSON.stringify(res))
  194. }, 500)
  195. }
  196. },
  197. onShow() {}
  198. }
  199. </script>
  200. <style lang="scss"></style>