summary.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <app-layout>
  3. <view class="header">
  4. <view class="date-group">
  5. <view class="date">
  6. <picker mode="date" :value="startDate" @change="startDateChange">
  7. <view>{{startDate}}</view>
  8. </picker>
  9. </view>
  10. <text>至</text>
  11. <view class="date">
  12. <picker mode="date" :value="endDate" @change="endDateChange">
  13. <view>{{endDate}}</view>
  14. </picker>
  15. </view>
  16. </view>
  17. <view class="summary-btn" @click="search">统计</view>
  18. </view>
  19. <view class="tabs">
  20. <view class="tab" :class="tabIndex==index?'active':''" v-for="(item,index) in tabs" :key="index" @click="changeTab(index)">
  21. {{item.name}}
  22. </view>
  23. </view>
  24. <view class="content">
  25. <view class="list-item" v-for="(item,index) in tabs[tabIndex]['listItem']" :key="index">
  26. <text>{{item.name}}</text>
  27. <text>{{item.value}}</text>
  28. </view>
  29. </view>
  30. <view class="desc" @click="showDesc = !showDesc">
  31. <text>{{tabs[tabIndex].name}}说明</text>
  32. <image src="../../../static/image/icon/arrow-right.png"></image>
  33. </view>
  34. <view v-if="showDesc" class="show-desc">
  35. <view class="main">
  36. <image class="close" src="../../../static/image/icon/close.png" @click="showDesc = !showDesc"></image>
  37. <view class="title">{{tabs[tabIndex].name}}说明</view>
  38. <view class="desc-con">{{tabs[tabIndex].desc}}</view>
  39. </view>
  40. </view>
  41. </app-layout>
  42. </template>
  43. <script>
  44. export default {
  45. data(){
  46. return {
  47. showDesc:'',
  48. tabIndex: 0,
  49. date: this.getDate({
  50. format: true
  51. }),
  52. startDate:this.getDate('start'),
  53. endDate:this.getDate('end'),
  54. tabs:[
  55. {
  56. name: '人数',
  57. value: 1,
  58. desc:'人数说明',
  59. listItem:[
  60. {
  61. key: 'newCustomer',
  62. name: '新增顾客',
  63. value: 0,
  64. },
  65. {
  66. key: 'newShare',
  67. name: '新增代理',
  68. value: 0,
  69. },
  70. {
  71. key: 'myTeam',
  72. name: '团队人数',
  73. value: 0,
  74. }
  75. ],
  76. },
  77. {
  78. name: '业绩',
  79. value: 2,
  80. desc:'业绩说明',
  81. listItem:[
  82. {
  83. key: 'selfPerformance',
  84. name: '个人业绩',
  85. value: 0,
  86. },
  87. {
  88. key: 'teamPerformance',
  89. name: '团队业绩',
  90. value: 0,
  91. },
  92. {
  93. key: 'totalPerformance',
  94. name: '总共业绩',
  95. value: 0,
  96. }
  97. ],
  98. },
  99. {
  100. name: '销量',
  101. value: 3,
  102. desc:'销量说明',
  103. listItem:[
  104. {
  105. key: 'selfSale',
  106. name: '个人销量',
  107. value: 0,
  108. },
  109. {
  110. key: 'teamSale',
  111. name: '团队销量',
  112. value: 0,
  113. },
  114. {
  115. key: 'totalSale',
  116. name: '总共销量',
  117. value: 0,
  118. }
  119. ],
  120. },
  121. {
  122. name: '返利',
  123. value: 4,
  124. desc: '返利说明',
  125. listItem:[
  126. {
  127. key: 'selfCash',
  128. name: '个人返利',
  129. value: 0,
  130. },
  131. {
  132. key: 'teamCash',
  133. name: '团队返利',
  134. value: 0,
  135. },
  136. {
  137. key: 'totalCash',
  138. name: '总共返利',
  139. value: 0,
  140. }
  141. ],
  142. }
  143. ]
  144. }
  145. },
  146. methods:{
  147. changeTab(index){
  148. this.tabIndex = index
  149. },
  150. search(){
  151. this.$showLoading();
  152. this.$request({
  153. url: this.$api.share.summary,
  154. data: {
  155. startDate: this.startDate,
  156. endDate: this.endDate
  157. }
  158. }).then(response => {
  159. uni.hideLoading();
  160. this.$hideLoading();
  161. if(response.code == 1){
  162. const data = response.data
  163. this.tabs.map(item => {
  164. for (const index in item['listItem']) {
  165. item['listItem'][index]['value'] = data[item['listItem'][index]['key']].toString()
  166. }
  167. })
  168. }
  169. }).catch(() => {
  170. uni.hideLoading();
  171. this.$hideLoading();
  172. })
  173. },
  174. startDateChange(e){
  175. this.startDate = e.detail.value;
  176. },
  177. endDateChange(e){
  178. this.endDate = e.detail.value;
  179. },
  180. getDate(type) {
  181. const date = new Date();
  182. let year = date.getFullYear();
  183. let month = date.getMonth() + 1;
  184. let day = date.getDate();
  185. if (type === 'start') {
  186. const startDate = new Date(date.getTime() - 30 * 24 * 60 * 60 * 1000);
  187. year = startDate.getFullYear();
  188. month = startDate.getMonth() + 1;
  189. day = startDate.getDate();
  190. } else if (type === 'end') {
  191. //return `${year}-${month}-${day}`;
  192. }
  193. month = month > 9 ? month : '0' + month;
  194. day = day > 9 ? day : '0' + day;
  195. return `${year}-${month}-${day}`;
  196. }
  197. },
  198. onLoad(){
  199. this.search()
  200. }
  201. }
  202. </script>
  203. <style scoped lang="scss">
  204. $defaultSpace:30rpx;
  205. $borderColor:#ccc;
  206. $defaultColor:#FF3A30;
  207. .header{
  208. display: flex;
  209. align-items: center;
  210. background: white;
  211. padding: $defaultSpace/3 $defaultSpace;
  212. .date-group{
  213. display: flex;
  214. flex: 1;
  215. border-radius: 10rpx;
  216. border: 1rpx solid $borderColor;
  217. height: 80rpx;
  218. align-items: center;
  219. .date{
  220. display: flex;
  221. flex: 1;
  222. align-items: center;
  223. justify-content: center;
  224. }
  225. text{
  226. padding: 0 20rpx;
  227. }
  228. }
  229. .summary-btn{
  230. padding: 0 $defaultSpace;
  231. background: $defaultColor;
  232. color: #ffffff;
  233. border-radius: 10rpx;
  234. height: 80rpx;
  235. margin-left: 20rpx;
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. }
  240. }
  241. .tabs{
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. margin: $defaultSpace $defaultSpace;
  246. border-radius: 20rpx;
  247. overflow: hidden;
  248. background: white;
  249. .tab{
  250. background: $defaultColor;
  251. color: #333333;
  252. border-left: 1rpx solid $borderColor;
  253. display: flex;
  254. flex: 1;
  255. align-items: center;
  256. justify-content: center;
  257. padding: $defaultSpace 0;
  258. &.active{
  259. color: #ffffff;
  260. }
  261. }
  262. }
  263. .content{
  264. background: white;
  265. margin-top: $defaultSpace;
  266. .list-item{
  267. display: flex;
  268. align-items: center;
  269. justify-content: space-between;
  270. padding: $defaultSpace;
  271. border-bottom: 1px solid $borderColor;
  272. color: #666666;
  273. }
  274. }
  275. .desc{
  276. padding: $defaultSpace;
  277. display: flex;
  278. align-items: center;
  279. justify-content: space-between;
  280. background: white;
  281. margin-top: $defaultSpace;
  282. color: #666666;
  283. image{
  284. width: 20rpx;
  285. height: 30rpx;
  286. }
  287. }
  288. .show-desc{
  289. position: fixed;
  290. background: rgba(0,0,0,.3);
  291. top: 0;
  292. left: 0;
  293. width: 100%;
  294. height: 100%;
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. .main{
  299. width: 90%;
  300. height: 80%;
  301. border-radius: $defaultSpace;
  302. background: white;
  303. position: relative;
  304. .close{
  305. position: absolute;
  306. right: $defaultSpace;
  307. top: $defaultSpace;
  308. border-radius: 50%;
  309. border: 2px solid $borderColor;
  310. width: 40rpx;
  311. height: 40rpx;
  312. }
  313. .title{
  314. color: #666666;
  315. padding: $defaultSpace 20rpx;
  316. }
  317. .desc-con{
  318. padding: $defaultSpace 20rpx;
  319. }
  320. }
  321. }
  322. </style>