echart-demand.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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-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, 2)"
  16. >
  17. <text class="input-text">{{ contactData.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, 2)"
  29. >
  30. <text class="input-text">{{ contactData.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, 2)"
  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="contactChartData" :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. totalNum:{
  72. type:Number,
  73. default:0
  74. }
  75. },
  76. data() {
  77. return {
  78. isEmpty:false,
  79. current: 0,
  80. remarksTotal:0,
  81. contactChartData:null,
  82. contactData:{
  83. startTime: '',
  84. endTime: '',
  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.remarksTotal = this.totalNum
  144. this.userClubPortrait(2)
  145. },
  146. methods: {
  147. handleTimeClick(dateType,index,type) {
  148. //年月日点击
  149. console.log('dateType', dateType)
  150. this.current = index
  151. this.params.dateType = dateType
  152. this.params.startTime = ''
  153. this.params.endTime = ''
  154. this.userClubPortrait(type)
  155. },
  156. async userClubPortrait(type){
  157. this.params.type = type
  158. this.contactData.startTime = this.params.startTime
  159. this.contactData.endTime = this.params.endTime
  160. try {
  161. const res = await this.UserService.userClubPortrait(this.params)
  162. const data = res.data
  163. this.contactData.remarksScopeNum = data.portrait.remarksScopeNum
  164. this.contactData.startTime = this.params.startTime = data.portrait.startTime
  165. this.contactData.endTime = this.params.endTime = data.portrait.endTime
  166. if(data.remarks){
  167. this.isEmpty = false
  168. this.getSetContactData(data.remarks)
  169. }else{
  170. this.isEmpty = true
  171. }
  172. console.log('contactData',this.contactData)
  173. } catch (error) {
  174. this.$util.msg(error.msg, 2000)
  175. }
  176. },
  177. getSetContactData(data) {
  178. setTimeout(() => {
  179. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  180. let res = {
  181. categories:data.name,
  182. series: [
  183. {
  184. name: '',
  185. data: data.value
  186. }
  187. ]
  188. }
  189. this.contactChartData = JSON.parse(JSON.stringify(res))
  190. }, 500)
  191. }
  192. },
  193. onShow() {}
  194. }
  195. </script>
  196. <style lang="scss"></style>