聚星移动端

multiDay.vue 7.2KB

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