echart-keyword.vue 5.0 KB

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