transactionRecord.vue 6.5 KB

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