payList.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="payList">
  3. <view class="timeSeletParent" v-if="list.length>0">
  4. <picker
  5. mode="date"
  6. fields="month"
  7. :value="date"
  8. :start="startDate"
  9. :end="endDate"
  10. @change="bindDateChange"
  11. >
  12. <view class="timeSeletBox">{{date}}</view>
  13. </picker>
  14. <view
  15. v-if="isToggle"
  16. class="seeAll"
  17. @click="seeAll"
  18. >
  19. 查看全部
  20. </view>
  21. </view>
  22. <!-- top="xxx"下拉布局往下偏移,防止被悬浮菜单遮住 -->
  23. <mescroll-uni
  24. top="100"
  25. @down="downCallback"
  26. :up="upOption"
  27. @up="upCallback"
  28. @init="mescrollInit"
  29. >
  30. <!-- 数据列表 -->
  31. <view class="payItem" v-for="item in list" :key="item.id" v-if="list.length>0">
  32. <view class="payInfoBox">
  33. <image class="fixedIcon" src="/static/pay_icon.png"></image>
  34. <view class="payMain">
  35. <view>
  36. <text class="payTitle">缴纳月份: {{item.month}}\n</text>
  37. <text class="payTime">{{item.pays_at}}</text>
  38. </view>
  39. <view>
  40. <text class="payPrice">{{item.fee}}\n</text>
  41. <text class="payStatus">交易成功</text>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </mescroll-uni>
  47. </view>
  48. </template>
  49. <script>
  50. import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue";
  51. import { payList } from "../../api/index.js"
  52. export default{
  53. components: {
  54. MescrollUni
  55. },
  56. data(){
  57. const currentDate = this.getDate({
  58. format: true
  59. })
  60. return {
  61. mescroll: null, //mescroll实例对象
  62. upOption:{
  63. page: {
  64. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  65. size: 10 // 每页数据的数量
  66. },
  67. noMoreSize: 10,
  68. empty:{
  69. tip: '~ 搜索无数据 ~', // 提示
  70. btnText: '去看看'
  71. }
  72. },
  73. list:[],
  74. date:currentDate,
  75. isToggle:false,
  76. hideHeader:false,
  77. loading:true
  78. }
  79. },
  80. computed: {
  81. startDate() {
  82. return this.getDate('start');
  83. },
  84. endDate() {
  85. return this.getDate('end');
  86. }
  87. },
  88. methods:{
  89. mescrollInit(mescroll) {
  90. this.mescroll = mescroll;
  91. },
  92. /*下拉刷新的回调 */
  93. downCallback(mescroll) {
  94. // 这里加载你想下拉刷新的数据, 比如刷新轮播数据
  95. // loadSwiper();
  96. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 mescroll.num=1, 再触发upCallback方法 )
  97. mescroll.resetUpScroll()
  98. },
  99. /*上拉加载的回调: mescroll携带page的参数, 其中num:当前页 从1开始, size:每页数据条数,默认10 */
  100. upCallback(mescroll) {
  101. //联网加载数据
  102. this.getListDataFromNet(mescroll.num, mescroll.size, (curPageData)=>{
  103. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  104. mescroll.endSuccess(curPageData.length);
  105. //设置列表数据
  106. if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  107. this.list=this.list.concat(curPageData); //追加新数据
  108. }, () => {
  109. //联网失败的回调,隐藏下拉刷新的状态
  110. mescroll.endErr();
  111. })
  112. },
  113. getListDataFromNet(pageNum,pageSize,successCallback,errorCallback) {
  114. const month=this.isToggle ? this.date : ''
  115. payList({
  116. page_index:pageNum,
  117. page_size:pageSize,
  118. month
  119. }).then(res=>{
  120. successCallback && successCallback(res.data);
  121. }).catch(e=>{
  122. errorCallback && errorCallback();
  123. })
  124. },
  125. seeAll(){
  126. this.isToggle=false
  127. this.date=this.getDate({
  128. format: true
  129. })
  130. this.getListDataFromNet(1,10,(data)=>{
  131. this.mescroll.resetUpScroll()
  132. this.mescroll.endSuccess(data.length);
  133. this.list=data
  134. },()=>{
  135. })
  136. },
  137. bindDateChange(e) {
  138. this.isToggle=true
  139. this.date = e.target.value
  140. this.getListDataFromNet(1,10,(data)=>{
  141. this.mescroll.endSuccess(data.length);
  142. this.list=data
  143. },()=>{
  144. })
  145. },
  146. getDate(type) {
  147. const date = new Date();
  148. let year = date.getFullYear();
  149. let month = date.getMonth() + 1;
  150. if (type === 'start') {
  151. year = year - 1;
  152. } else if (type === 'end') {
  153. year = year+1;
  154. }
  155. month = month > 9 ? month : '0' + month;;
  156. return `${year}-${month}`;
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="scss">
  162. page{
  163. width: 100%;
  164. height: 100%;
  165. background: $uni-bg-color-normal;
  166. }
  167. .timeSeletParent{
  168. position: fixed;
  169. top: 0;
  170. left: 0;
  171. right: 0;
  172. height: 100rpx;
  173. display: flex;
  174. align-items: center;
  175. justify-content: space-between;
  176. background: $uni-bg-color-normal;
  177. padding: 0 30rpx;
  178. .seeAll{
  179. font-size: 24rpx;
  180. color: #2E8BFC;
  181. }
  182. }
  183. .timeSeletBox{
  184. width: 150rpx;
  185. padding: 0 35rpx;
  186. height: 60rpx;
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. font-size: 28rpx;
  191. color: #323332;
  192. border-radius: 28rpx;
  193. background: $uni-bg-color;
  194. }
  195. .timeSeletBox::after{
  196. content: "";
  197. display: block;
  198. width: 28rpx;
  199. height: 16rpx;
  200. background: url(../../static/arrow_all_down.png);
  201. background-size: 100% 100%;
  202. }
  203. .payInfoBox{
  204. width: calc(100% - 97rpx);
  205. height: 156rpx;
  206. background: $uni-bg-color;
  207. display: flex;
  208. align-items: center;
  209. justify-content: space-between;
  210. padding-left:67rpx;
  211. padding-right: 30rpx;
  212. }
  213. .payItem{
  214. border-bottom: 1px solid #e1e1e1;
  215. &:nth-last-of-type(2){
  216. border-bottom: none;
  217. }
  218. }
  219. .fixedIcon{
  220. display: block;
  221. width: 48rpx;
  222. height: 48rpx;
  223. }
  224. .payMain{
  225. width: calc(100% - 101rpx);
  226. display: flex;
  227. justify-content: space-between;
  228. align-items: center;
  229. }
  230. .payTitle{
  231. font-size: 28rpx;
  232. color: #323332;
  233. }
  234. .payTime,.payStatus{
  235. font-size: 24rpx;
  236. color: #999999;
  237. }
  238. .payPrice{
  239. font-size: 32rpx;
  240. color: #323332;
  241. }
  242. .noList{
  243. text-align: center;
  244. padding: 10px 0;
  245. font-size: 28rpx;
  246. }
  247. .loading{
  248. font-size: 24rpx;
  249. text-align: center;
  250. padding: 10px 0;
  251. }
  252. .scrollView{
  253. position: absolute;
  254. top: 100rpx;
  255. left: 0;
  256. right: 0;
  257. bottom: 0;
  258. overflow: hidden;
  259. }
  260. .hideHeader{
  261. font-size: 24rpx;
  262. padding: 100rpx;
  263. text-align: center;
  264. }
  265. </style>