totlePrice.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="content">
  3. <view style="width: 100%;display: flex;align-items: center;">
  4. <view class="content">
  5. <view @click="echarts.onClick" :prop="option" :change:prop="echarts.updateEcharts" ref="chartId" :id="chartId" class="echarts"></view>
  6. </view>
  7. <view>
  8. <text style="font-size: 28rpx;font-family: Verdana, Verdana-Regular;font-weight: 400;text-align: left;color: #5f636f;">意向总价</text>
  9. <view style="display: flex;justify-content: space-between;margin-top: 10rpx;">
  10. <text style="font-size: 28rpx;font-family: Verdana, Verdana-Regular;font-weight: 400;text-align: left;" :style="{'color':fuzhuColor}" v-if="dataList.length > 0">约{{dataList[0]}}万</text>
  11. <text style="font-size: 28rpx;font-family: Verdana, Verdana-Regular;font-weight: 400;text-align: left; margin-left: 82rpx;" v-if="dataList.length > 1">约{{dataList[1]}}万</text>
  12. <text style="font-size: 28rpx;font-family: Verdana, Verdana-Regular;font-weight: 400;text-align: left; margin-left: 82rpx;" v-if="dataList.length > 2">约{{dataList[2]}}万</text>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import echarts from '../../static/echarts.js'
  20. var colorList = ['#73DDFF', '#73ACFF', '#FDD56A'];
  21. export default {
  22. props: {
  23. chartId: String,
  24. title: {
  25. type: String,
  26. default: '面积'
  27. },
  28. dataList: {
  29. type: Array,
  30. default:() => {
  31. return []
  32. }
  33. }
  34. },
  35. data() {
  36. return {
  37. themeColor: "",
  38. fuzhuColor: "",
  39. themeColor25: "",
  40. option: {
  41. title: {
  42. text: '总价',
  43. x: 'center',
  44. y: 'center',
  45. textStyle: {
  46. fontSize: 10
  47. }
  48. },
  49. color: colorList,
  50. series: [{
  51. name: '访问来源',
  52. type: 'pie',
  53. radius: ['50%', '70%'],
  54. avoidLabelOverlap: false,
  55. hoverAnimation: false,
  56. label: {
  57. show: false,
  58. position: 'center'
  59. },
  60. itemStyle: {
  61. normal: {
  62. // color: function(params) {
  63. // return colorList[params.dataIndex]
  64. // }
  65. }
  66. },
  67. emphasis: {
  68. label: {
  69. show: false,
  70. fontSize: '30',
  71. fontWeight: 'bold'
  72. }
  73. },
  74. labelLine: {
  75. show: false
  76. },
  77. data: []
  78. // data: [{
  79. // value: 335,
  80. // name: '直接访问'
  81. // },
  82. // {
  83. // value: 310,
  84. // name: '邮件营销'
  85. // },
  86. // {
  87. // value: 234,
  88. // name: '联盟广告'
  89. // }
  90. // ]
  91. }]
  92. }
  93. }
  94. },
  95. methods: {
  96. getDataAction() {
  97. // this.dataList = []
  98. // this.data1 = []
  99. // for (var i = 0; i < 3; i++) {
  100. // var num1 = Math.ceil(Math.random() * 50)
  101. // this.data1.push(num1)
  102. // this.dataList.push(num1)
  103. // }
  104. this.option.series[0].data = this.dataList
  105. // this.option.xAxis.data = this.dataList
  106. // console.log('总价数据刷新', this.option)
  107. },
  108. onViewClick(options) {
  109. // console.log(options)
  110. }
  111. },
  112. watch: {
  113. chartId: {
  114. handler(e) {
  115. // console.log('走没走!!!!', e)
  116. // this.getDataAction()
  117. },
  118. immediate: true
  119. },
  120. dataList: {
  121. handler(e) {
  122. this.getDataAction()
  123. },
  124. immediate: true,
  125. deep: true
  126. }
  127. },
  128. mounted() {
  129. let app = getApp()
  130. let globalData = app.globalData;
  131. this.themeColor = globalData.themeColor
  132. this.fuzhuColor = globalData.fuzhuColor
  133. this.themeColor25 = globalData.themeColor25
  134. let that = this;
  135. }
  136. }
  137. </script>
  138. <script module="echarts" lang="renderjs">
  139. let myChart
  140. export default {
  141. mounted() {
  142. this.initAction()
  143. },
  144. methods: {
  145. initAction() {
  146. if (typeof window.echarts === 'function') {
  147. this.initEcharts()
  148. } else {
  149. // 动态引入较大类库避免影响页面展示
  150. const script = document.createElement('script')
  151. // view 层的页面运行在 www 根目录,其相对路径相对于 www 计算
  152. script.src = 'static/echarts.js'
  153. script.onload = this.initEcharts.bind(this)
  154. document.head.appendChild(script)
  155. }
  156. },
  157. initEcharts() {
  158. // console.log("initEcharts -> this.$refs", this.$refs.chartId.$el.id)
  159. myChart = echarts.init(document.getElementById(this.$refs.chartId.$el.id))
  160. // 观测更新的数据在 view 层可以直接访问到
  161. myChart.setOption(this.option)
  162. },
  163. updateEcharts(newValue, oldValue, ownerInstance, instance) {
  164. // 监听 service 层数据变更
  165. myChart.setOption(newValue)
  166. },
  167. onClick(event, ownerInstance) {
  168. // 调用 service 层的方法
  169. ownerInstance.callMethod('onViewClick', {
  170. test: 'test'
  171. })
  172. }
  173. }
  174. }
  175. </script>
  176. <style scoped lang="scss">
  177. .content {
  178. .top-Section {
  179. padding: 0 20rpx;
  180. display: flex;
  181. flex-direction: row;
  182. justify-content: space-between;
  183. font-family: Verdana;
  184. .title {
  185. font-size: 32rpx;
  186. font-weight: bold;
  187. color: #383838;
  188. }
  189. .rightBtn {
  190. font-size: 24rpx;
  191. color: #546074;
  192. margin-top: 5rpx;
  193. }
  194. }
  195. .echarts {
  196. width: 214rpx;
  197. margin-top: 0;
  198. height: 200rpx;
  199. }
  200. }
  201. </style>