echart-keyword.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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>{{ keyWordData.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. },
  80. data() {
  81. return {
  82. isEmpty:false,
  83. current: 0,
  84. keyWordChartData: null,
  85. keyWordData: {
  86. startTime: '',
  87. endTime: '',
  88. totalKeywords: 0,
  89. keyWordsScopeNum: 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: ['#9370DB'],
  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: ['#7B68EE', '#9370DB'],
  139. colorStop: 0
  140. }
  141. }
  142. }
  143. }
  144. },
  145. created() {
  146. this.params.clubId = this.clubId
  147. this.userClubPortrait(1)
  148. },
  149. methods: {
  150. handleTimeClick(dateType, index,type) {
  151. //年月日点击
  152. console.log('dateType', dateType)
  153. this.current = index
  154. this.params.dateType = dateType
  155. this.params.startTime = ''
  156. this.params.endTime = ''
  157. this.userClubPortrait(type)
  158. },
  159. async userClubPortrait(type){
  160. this.params.type = type
  161. this.keyWordData.startTime = this.params.startTime
  162. this.keyWordData.endTime = this.params.endTime
  163. try {
  164. const res = await this.UserService.userClubPortrait(this.params)
  165. const data = res.data
  166. console.log('data',data)
  167. this.keyWordData.totalKeywords = data.portrait.totalKeywords
  168. this.keyWordData.keyWordsScopeNum = data.portrait.keyWordsScopeNum
  169. this.keyWordData.startTime = this.params.startTime = data.portrait.startTime
  170. this.keyWordData.endTime = this.params.endTime = data.portrait.endTime
  171. if (data.behavior) {
  172. this.isEmpty = false
  173. this.getSetKeywordData(data.behavior)
  174. }else{
  175. this.isEmpty = true
  176. }
  177. console.log('keyWordData', this.keyWordData)
  178. } catch (error) {
  179. this.$util.msg(error.msg, 2000)
  180. }
  181. },
  182. getSetKeywordData(data) {
  183. setTimeout(() => {
  184. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  185. let res = {
  186. categories: data.name,
  187. series: [
  188. {
  189. name: '',
  190. data: data.value
  191. }
  192. ]
  193. }
  194. this.keyWordChartData = JSON.parse(JSON.stringify(res))
  195. }, 500)
  196. }
  197. },
  198. onShow() {}
  199. }
  200. </script>
  201. <style lang="scss"></style>