transactionRecord.vue 6.4 KB

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