transactionRecord.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="container">
  3. <!-- 头部 -->
  4. <view class="header">
  5. <text :class="tabType==1?'active':''" @tap="changeTab(1)">消费</text>
  6. <text :class="tabType==0?'active':''" @tap="changeTab(0)">充值</text>
  7. </view>
  8. <!-- 主体内容 -->
  9. <view class="scroll-content" >
  10. <scroll-view scroll-y style="height: 100%;width:100%;overflow: auto;" @scrolltolower="onreachBottom">
  11. <view class="month-list">
  12. <!-- 3月记录 -->
  13. <view class="month-card" v-for="item in list" :key="item.tradeMonth">
  14. <view class="month-header">
  15. <text class="month-title">{{item.tradeMonth}}</text>
  16. <view>
  17. <text class="month-total">总计:{{item.totalAmount}}</text>
  18. <text style="font-size: 10px;margin-left:5px;"> 元</text>
  19. </view>
  20. </view>
  21. <view class="record-list">
  22. <view
  23. class="record-item"
  24. v-for="(sitem, index) in item.list"
  25. :key="sitem.id"
  26. >
  27. <view class="item-left">
  28. <text class="amount-label">{{tabType==0?'充值':'消费'}}</text>
  29. <text class="time" v-if="tabType==0">充值人:{{sitem.operatorName}}</text>
  30. <text class="time" v-if="tabType==0">{{sitem.bizType=='ZERO'?'清零时间':'充值时间'}}:{{sitem.tradeDate}}</text>
  31. <text class="time" v-if="tabType==1&&sitem.bizType=='SALES'">{{sitem.finishFlag==1?'支付时间':'采购时间'}}:{{sitem.tradeDate}}</text>
  32. <text class="time" v-if="tabType==1&&sitem.bizType=='REFUND'">退款时间:{{sitem.tradeDate}}</text>
  33. </view>
  34. <view class="amount">
  35. <text :class="sitem.bizType=='ZERO'?'red':''" v-if="tabType==0">{{sitem.bizType=='ZERO'?'':'+'}}{{sitem.tradeAmount}}</text>
  36. <text :class="sitem.bizType=='SALES'?'red':''" v-if="tabType==1">{{sitem.bizType=='SALES'?'':'+'}}{{sitem.tradeAmount}}</text>
  37. <text style="font-size: 10px;margin-left:5px;"> 元</text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view style="padding:0 30upx 30upx;">
  43. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  44. <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
  45. </view>
  46. </view>
  47. </scroll-view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import {xprhStoreAccountFlowPage} from '@/api/recharge.js'
  53. import {
  54. mapState,
  55. mapMutations,
  56. } from 'vuex'
  57. export default {
  58. data() {
  59. return {
  60. status: 'loading',
  61. noDataText: '暂无数据',
  62. // 查询条件
  63. pageNo: 1,
  64. pageSize: 10,
  65. list: [],
  66. total: 0,
  67. tabType:0,
  68. lastMoth:''
  69. }
  70. },
  71. onLoad(opts){
  72. this.tabType = opts.type
  73. uni.setNavigationBarTitle({
  74. title: opts.type==0?'充值交易记录':'消费交易记录'
  75. })
  76. },
  77. onShow() {
  78. this.getRow(1)
  79. },
  80. computed: {
  81. ...mapState(['hasLogin']),
  82. // 登录用户信息
  83. userInfo(){
  84. return this.$store.state.vuex_userInfo
  85. },
  86. // 货架经销商信息
  87. shelfInfo(){
  88. return this.$store.state.vuex_storeShelf
  89. },
  90. maxNums(){
  91. let nums = 0
  92. this.list.forEach(item => {
  93. nums += item.list.length
  94. })
  95. return nums
  96. }
  97. },
  98. methods: {
  99. changeTab(type){
  100. this.tabType = type
  101. uni.setNavigationBarTitle({
  102. title: this.tabType==0?'充值交易记录':'消费交易记录'
  103. })
  104. this.list = []
  105. this.lastMoth = ''
  106. this.getRow(1)
  107. },
  108. // 查询列表
  109. getRow (pageNo) {
  110. let _this = this
  111. this.status = "loading"
  112. // 0 充值,1 消费
  113. const params = {
  114. storeSn:this.shelfInfo.storeSn,
  115. bizTypeList:this.tabType==0 ? ['RECHARGE'] : ['SALES', 'REFUND'],
  116. accountType: ['RECHARGE','GIVE'][this.tabType]
  117. }
  118. xprhStoreAccountFlowPage({pageNo:this.pageNo,pageSize: this.pageSize,...params}).then(res => {
  119. if (res.status == 200) {
  120. const list = res.data&&res.data.list || []
  121. if(_this.pageNo>1){
  122. const fm = list[0] && list[0].tradeMonth
  123. // 如果相等,将数据拼接到上页去
  124. if(fm == _this.lastMoth){
  125. let preList = _this.list[_this.list.length-1].list
  126. preList = preList.concat(list[0].list)
  127. _this.list[_this.list.length-1].list = preList
  128. // 删除第一项
  129. list[0].list = []
  130. }
  131. console.log(list)
  132. _this.list = _this.list.concat(list.length?list.filter(item=>item.list.length):list)
  133. }else{
  134. _this.list = list
  135. }
  136. // 最后一条的月份
  137. _this.lastMoth = _this.list.length>0 ? _this.list[_this.list.length-1].tradeMonth : ''
  138. _this.total = res.data.count || 0
  139. } else {
  140. _this.list = []
  141. _this.total = 0
  142. _this.noDataText = res.message
  143. }
  144. _this.status = _this.total>=_this.maxNums ? "nomore" : 'loadmore'
  145. })
  146. },
  147. // scroll-view到底部加载更多
  148. onreachBottom() {
  149. if(this.maxNums < this.total){
  150. this.pageNo += 1
  151. this.getRow()
  152. }else{
  153. this.status = "nomore"
  154. }
  155. },
  156. }
  157. }
  158. </script>
  159. <style lang="less">
  160. .container {
  161. height: 100vh;
  162. display: flex;
  163. flex-direction: column;
  164. background-color: #f5f5f5;
  165. }
  166. .header {
  167. padding: 30px 10px 20px;
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. > text {
  172. font-size: 16px;
  173. font-weight: bold;
  174. color: #333;
  175. margin: 0 10px;
  176. }
  177. .active{
  178. color: #ff0000;
  179. }
  180. }
  181. .scroll-content {
  182. height: calc(100vh - 90px);
  183. .month-list{
  184. padding: 0 15px;
  185. }
  186. }
  187. .month-card {
  188. margin-bottom: 15px;
  189. overflow: hidden;
  190. }
  191. .month-header {
  192. padding: 12px 0;
  193. display: flex;
  194. justify-content: space-between;
  195. .month-title {
  196. font-size: 16px;
  197. color: #333;
  198. font-weight: 500;
  199. }
  200. .month-total {
  201. font-size: 14px;
  202. color: #666;
  203. }
  204. }
  205. .record-list {
  206. padding: 0 15px;
  207. background-color: #fff;
  208. border-radius: 8px;
  209. .red{
  210. color: #ff0000
  211. }
  212. }
  213. .record-item {
  214. padding: 12px 0;
  215. display: flex;
  216. justify-content: space-between;
  217. align-items: center;
  218. border-bottom: 1px solid #f0f0f0;
  219. &:last-child {
  220. border-bottom: none;
  221. }
  222. .item-left {
  223. display: flex;
  224. flex-direction: column;
  225. }
  226. .amount-label {
  227. font-size: 14px;
  228. color: #333;
  229. font-weight: bold;
  230. }
  231. .amount {
  232. font-size: 14px;
  233. color: #333;
  234. font-weight: 500;
  235. }
  236. .time {
  237. font-size: 12px;
  238. color: #999;
  239. margin-top: 5px;
  240. }
  241. }
  242. </style>