echart-order.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view class="echart-content">
  3. <view class="echart-title">
  4. <view class="e-icon e2"><text class="iconfont icon-dingdan"></text></view> <view class="e-name">订单</view>
  5. </view>
  6. <view class="echart-search">
  7. <view class="echart-search-text">
  8. <view class="search-text">所有:<text>¥{{ orderData.orderTotalAmount }}({{ orderData.orderTotal }}个)</text></view>
  9. <view class="search-text">当前范围:<text>¥{{ orderData.orderScopeTotalFee }}({{ orderData.orderScopeNum }}个)</text></view>
  10. </view>
  11. <view class="echart-search-date">
  12. <view class="echart-search-date-input">
  13. <picker
  14. mode="date"
  15. :value="date"
  16. :start="startDate"
  17. :end="endDate"
  18. @change="bindStartDateChange($event, 0)"
  19. >
  20. <text class="input-text">{{ orderData.startTime }}</text>
  21. </picker>
  22. <text class="iconfont icon-riqi"></text>
  23. </view>
  24. <view class="line">-</view>
  25. <view class="echart-search-date-input">
  26. <picker
  27. mode="date"
  28. :value="date"
  29. :start="startDate"
  30. :end="endDate"
  31. @change="bindEndDateChange($event, 0)"
  32. >
  33. <text class="input-text">{{ orderData.endTime }}</text>
  34. </picker>
  35. <text class="iconfont icon-riqi"></text>
  36. </view>
  37. </view>
  38. <view class="echart-search-time">
  39. <view
  40. class="time-tab"
  41. v-for="(time, index) in timeList"
  42. :class="{ current: current === index }"
  43. :key="index"
  44. @click="handleTimeClick(time.current, index, 0)"
  45. >{{ time.label }}</view
  46. >
  47. </view>
  48. </view>
  49. <view class="echart-mains">
  50. <view class="echart-mains-none" v-if="isEmpty">
  51. <image
  52. class="none-image"
  53. src="https://static.caimei365.com/app/img/bg/icon_echart_none@2x.png"
  54. mode=""
  55. ></image>
  56. <view class="none-text">暂无数据</view>
  57. </view>
  58. <view class="echart-mains-data" v-else>
  59. <qiun-data-charts type="pie" :opts="opts" :chartData="orderChartData" :errorShow="false" />
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import { mapState, mapMutations } from 'vuex'
  66. import chartMixin from './mixins/chart.mixin.js'
  67. export default {
  68. mixins: [chartMixin],
  69. props:{
  70. clubId:{
  71. type:Number,
  72. default:0
  73. }
  74. },
  75. data() {
  76. return {
  77. isEmpty:false,
  78. current: 0,
  79. orderChartData:null,
  80. orderData:{
  81. startTime: '',
  82. endTime: '',
  83. orderTotal:0,
  84. orderScopeNum:0,
  85. orderTotalAmount:0,
  86. orderScopeTotalFee:0
  87. },
  88. params:{
  89. clubId:0,// 机构id
  90. dateType:3,// 日期类别 0日 1月 2半年 3全年
  91. startTime:'',// 开始时间
  92. endTime:'',// 结束时间
  93. type:0 // 统计类别 0订单 1搜索关键词 2咨询记录 3访问记录 4初始状态
  94. },
  95. opts: {
  96. timing: 'easeOut',
  97. duration: 1000,
  98. rotate: false,
  99. rotateLock: false,
  100. color: [
  101. '#1890FF',
  102. '#91CB74',
  103. '#FAC858',
  104. '#EE6666',
  105. '#73C0DE',
  106. '#3CA272',
  107. '#FC8452',
  108. '#9A60B4',
  109. '#ea7ccc'
  110. ],
  111. padding: [5, 5, 5, 5],
  112. fontSize: 13,
  113. fontColor: '#666666',
  114. dataLabel: true,
  115. dataPointShape: true,
  116. dataPointShapeType: 'solid',
  117. touchMoveLimit: 60,
  118. enableScroll: false,
  119. enableMarkLine: false,
  120. legend: {
  121. show: false,
  122. position: 'bottom',
  123. lineHeight: 25,
  124. float: 'bottom',
  125. padding: 5,
  126. margin: 5,
  127. backgroundColor: 'rgba(0,0,0,0)',
  128. borderColor: 'rgba(0,0,0,0)',
  129. borderWidth: 0,
  130. fontSize: 13,
  131. fontColor: '#666666',
  132. hiddenColor: '#CECECE',
  133. itemGap: 10
  134. },
  135. title: {
  136. name: '订单总量',
  137. fontSize: 15,
  138. color: '#666666',
  139. offsetX: 0,
  140. offsetY: 0
  141. },
  142. subtitle: {
  143. name: '70%',
  144. fontSize: 25,
  145. color: '#7cb5ec',
  146. offsetX: 0,
  147. offsetY: 0
  148. },
  149. extra: {
  150. ring: {
  151. ringWidth: 30,
  152. activeOpacity: 0.5,
  153. activeRadius: 10,
  154. offsetAngle: 0,
  155. labelWidth: 15,
  156. border: true,
  157. borderWidth: 3,
  158. borderColor: '#FFFFFF',
  159. centerColor: '#FFFFFF',
  160. customRadius: 0,
  161. linearType: 'none'
  162. },
  163. tooltip: {
  164. showBox: true,
  165. showArrow: true,
  166. showCategory: false,
  167. borderWidth: 0,
  168. borderRadius: 0,
  169. borderColor: '#000000',
  170. borderOpacity: 0.7,
  171. bgColor: '#000000',
  172. bgOpacity: 0.7,
  173. gridType: 'solid',
  174. dashLength: 4,
  175. gridColor: '#CCCCCC',
  176. boxPadding: 3,
  177. fontSize: 13,
  178. lineHeight: 20,
  179. fontColor: '#FFFFFF',
  180. legendShow: true,
  181. legendShape: 'auto',
  182. splitLine: true,
  183. horizentalLine: false,
  184. xAxisLabel: false,
  185. yAxisLabel: false,
  186. labelBgColor: '#FFFFFF',
  187. labelBgOpacity: 0.7,
  188. labelFontColor: '#666666'
  189. }
  190. }
  191. }
  192. }
  193. },
  194. created() {
  195. this.params.clubId = this.clubId
  196. this.userClubPortrait(0)
  197. },
  198. methods: {
  199. handleTimeClick(dateType,index,type) {
  200. //年月日点击
  201. console.log('dateType', dateType)
  202. this.current = index
  203. this.params.dateType = dateType
  204. this.params.startTime = ''
  205. this.params.endTime = ''
  206. this.userClubPortrait(type)
  207. },
  208. async userClubPortrait(type){
  209. this.params.type = type
  210. try {
  211. const res = await this.UserService.userClubPortrait(this.params)
  212. const data = res.data
  213. this.orderData.orderTotal = data.portrait.orderTotal
  214. this.orderData.orderScopeNum = data.portrait.orderScopeNum
  215. this.orderData.orderTotalAmount = data.portrait.orderTotalAmount
  216. this.orderData.orderScopeTotalFee = data.portrait.orderScopeTotalFee
  217. this.orderData.startTime = this.params.startTime = data.portrait.startTime
  218. this.orderData.endTime = this.params.endTime = data.portrait.endTime
  219. if(data.order){
  220. this.isEmpty = false
  221. this.getSetOrderData(data.order)
  222. }else{
  223. this.isEmpty = true
  224. }
  225. } catch (error) {
  226. this.$util.msg(error.msg, 2000)
  227. }
  228. },
  229. getSetOrderData(data) {
  230. //模拟从服务器获取数据时的延时
  231. setTimeout(() => {
  232. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  233. let res = {
  234. series: [
  235. {
  236. format: 'pieDemo1',
  237. data: data.orderList
  238. }
  239. ]
  240. }
  241. this.orderChartData = JSON.parse(JSON.stringify(res))
  242. }, 500)
  243. }
  244. },
  245. onShow() {}
  246. }
  247. </script>
  248. <style lang="scss"></style>