聚星移动端

index.vue 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="pageCon">
  3. <view class="flex">
  4. <uni-data-select v-model="timeVal" :localdata="timeList" @change="timeChange" :clear="false" :isrealConsumePage="true" style="margin-right: 30rpx"></uni-data-select>
  5. <uni-data-select v-model="cusVal" :localdata="cusList" @change="cusChange" :clear="false" :isrealConsumePage="true" :selfPullWidth="220"></uni-data-select>
  6. <view class="updateCss" @click.stop="updateEvent">更新<view class="iconfont icon-gengxin"></view></view>
  7. </view>
  8. <view class="updateTime">数据更新时间: {{updateTime || '-'}}</view>
  9. <view class="realTimeConsume">
  10. <view class="f28">实时消耗</view>
  11. <view class="tMar5"><text class="f40">¥ </text> <text class="f68 fWeight600">{{$NumberHandle(realConsume)}}</text></view>
  12. </view>
  13. <view class="dataBox">
  14. <view v-for="(item,index) in dataList" :key="item.key" class="itemBox">
  15. <view class="num">{{$NumberHandle(item.val)}} <text v-if="item.hasPercent">%</text></view>
  16. <view class="name">{{item.name || '-'}}</view>
  17. </view>
  18. </view>
  19. <view class="previewBtn" @click="goDetial">查看详情</view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data () {
  25. return {
  26. timeVal: 1,
  27. cusVal: 1,
  28. timeList: [
  29. { value: 1, text: "今天" },
  30. { value: 7, text: "近7天" },
  31. { value: 30, text: "近30天" },
  32. ],
  33. cusList:[],
  34. updateTime:'',
  35. realConsume:'',
  36. dataList:[
  37. {name:'播放数',val:'',key:'play'},
  38. {name:'行为数',val:'',key:'action'},
  39. {name:'激活数',val:'',key:'conversion'},
  40. {name:'表单提交数',val:'',key:'submissions_number'},
  41. {name:'表单提交数成本',val:'',key:'sub_cpa'},
  42. {name:'评论数',val:'',key:'comment'},
  43. {name:'点赞数',val:'',key:'admire'},
  44. {name:'3s播放数',val:'',key:'played3s_cnt'},
  45. {name:'3s播放率',val:'',key:'played3s_percent',hasPercent:true},
  46. {name:'行为率',val:'',key:'ctr',hasPercent:true},
  47. {name:'千次观看成本',val:'',key:'cpm'},
  48. {name:'行为成本',val:'',key:'cpc'},
  49. {name:'激活成本',val:'',key:'cpa'},
  50. ]
  51. }
  52. },
  53. components:{},
  54. onLoad (option) {
  55. // await this.$onLaunched;
  56. this.init_cusList(option.cusVal ? option.cusVal : '')
  57. this.timeVal = 1
  58. },
  59. onPullDownRefresh(){
  60. },
  61. onShow() {
  62. this.timeVal = 1
  63. this.cusVal = uni.getStorageSync('cusVal') ? JSON.parse(JSON.stringify(uni.getStorageSync('cusVal'))) : 1
  64. uni.removeStorageSync('cusVal')
  65. this.init()
  66. },
  67. onHide(){
  68. },
  69. onUnload(){
  70. },
  71. methods: {
  72. //时间改变
  73. timeChange(e) {
  74. if(e == '7'){
  75. uni.navigateTo({
  76. url: './multiDay?timeVal=7&cusVal='+this.cusVal
  77. })
  78. }else if(e == '30'){
  79. uni.navigateTo({
  80. url: './multiDay?timeVal=30&cusVal='+this.cusVal
  81. })
  82. }
  83. },
  84. //客户改变
  85. cusChange(e) {
  86. this.cusVal = e
  87. this.init()
  88. },
  89. //更新
  90. updateEvent(){
  91. this.$show_init_loading()
  92. let paramsModel = {
  93. cust_id:this.cusVal,
  94. }
  95. this.$req(this.$api.Traffic_dailyList_update, 'post', paramsModel,(res)=>{
  96. if (res && res.code == 0) {
  97. let resNew = res.data
  98. this.init()
  99. } else {
  100. uni.showToast({
  101. title: res.msg,
  102. icon: 'none',
  103. duration: 2000
  104. })
  105. }
  106. })
  107. },
  108. //客户列表
  109. init_cusList(optionVal){
  110. let paramsModel = {
  111. page:1,
  112. pageSize:500,
  113. }
  114. this.$req(this.$api.customerAuth_list, 'get', paramsModel,(res)=>{
  115. if (res && res.code == 0) {
  116. let resNew = res.data
  117. this.cusList = []
  118. resNew.data.forEach(item=>{
  119. this.cusList.push({value:item.id,text:item.name})
  120. })
  121. this.cusVal = optionVal ? Number(optionVal) : this.cusList[0].value
  122. this.init()
  123. } else {
  124. uni.showToast({
  125. title: res.msg,
  126. icon: 'none',
  127. duration: 2000
  128. })
  129. }
  130. })
  131. },
  132. //数据列表
  133. init(){
  134. this.$show_init_loading()
  135. let paramsModel = {
  136. page:1,
  137. pageSize:1,
  138. cust_id:this.cusVal,
  139. st_date:this.$getDay(0, false),
  140. en_date:this.$getDay(0, false),
  141. }
  142. this.$req(this.$api.Traffic_dailyList, 'get', paramsModel,(res)=>{
  143. this.$hide_init_loading()
  144. this.updateTime = this.$getDay(0, true)['now']
  145. if (res && res.code == 0) {
  146. let resNew = res.data
  147. //清空值
  148. this.realConsume = ''
  149. this.dataList.forEach(item=>{
  150. item.val = ''
  151. })
  152. //赋值
  153. if(resNew.data&&resNew.data.length>0){
  154. this.dataList.forEach(item=>{
  155. item.val = resNew.data[0][item.key]
  156. })
  157. this.realConsume = resNew.data[0].consume_amount
  158. }
  159. } else {
  160. uni.showToast({
  161. title: res.msg,
  162. icon: 'none',
  163. duration: 2000
  164. })
  165. }
  166. })
  167. },
  168. //去详情
  169. goDetial(){
  170. let cusName = this.cusList.filter(n => { return n.value == this.cusVal })[0].text
  171. uni.navigateTo({
  172. url: './detialIndex?cust_id=' + this.cusVal + '&date=' + this.$getDay(0, false) + '&cusName=' + cusName
  173. })
  174. },
  175. }
  176. }
  177. </script>
  178. <style>
  179. </style>
  180. <style lang="scss" scoped>
  181. .pageCon{
  182. background: #0D1546;
  183. padding: 40rpx;
  184. height: calc(100%);
  185. overflow-y: auto;
  186. .updateCss{
  187. display: flex;
  188. align-items: center;
  189. justify-content: space-between;
  190. font-size: 28rpx;
  191. color: #0275FF;
  192. margin-left: auto;
  193. .iconfont{
  194. color: #0275FF;
  195. font-size: 28rpx;
  196. margin-left: 4rpx;
  197. }
  198. }
  199. .updateTime{
  200. font-size: 24rpx;
  201. color: #666FA7;
  202. margin: 32rpx 0 24rpx;
  203. }
  204. .realTimeConsume{
  205. width: 100%;
  206. height: 188rpx;
  207. background: #FFFFFF;
  208. border-radius: 12rpx;
  209. color: #0D1546;
  210. display: flex;
  211. flex-direction: column;
  212. justify-content: center;
  213. align-items: center;
  214. }
  215. .dataBox{
  216. background: #FFFFFF;
  217. border-radius: 12rpx;
  218. margin-top: 20rpx;
  219. display: flex;
  220. flex-wrap: wrap;
  221. padding: 0;
  222. padding-bottom: 64rpx;
  223. .itemBox{
  224. text-align: center;
  225. margin-top: 64rpx;
  226. width: 33.3%;
  227. .num{
  228. font-size: 40rpx;
  229. font-weight: 600;
  230. color: #0D1546;
  231. }
  232. .name{
  233. font-size: 28rpx;
  234. margin-top: 5rpx;
  235. color: rgba(13, 21, 70, .5);
  236. }
  237. }
  238. .rMar0{
  239. margin-right: 0;
  240. }
  241. }
  242. .previewBtn{
  243. width: 100%;
  244. height: 108rpx;
  245. line-height: 108rpx;
  246. background: #0275FF;
  247. border-radius: 12rpx;
  248. color: #fff;
  249. font-size: 36rpx;
  250. margin-top: 40rpx;
  251. text-align: center;
  252. }
  253. }
  254. </style>