balance-bills.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <mescroll :down="downOption" :up="upOption" @up="upCallback" :fixed="false" @down="downCallback"
  3. @init="mescrollInit">
  4. <view class="head_box u-flex u-row-center u-col-center">
  5. <view class="card-box">
  6. <view class="card-head u-flex u-col-center">
  7. <view class="card-title u-m-r-10">可提现金额(元)</view>
  8. <view class="u-iconfont uicon-eye" style="color: #fff;font-size: 50rpx;"></view>
  9. </view>
  10. <view class="money-num u-p-t-50">{{dataInfo.availableNum}}</view>
  11. <view class="padding-top-40 text-white text-df">
  12. <text class="price">总收益:{{dataInfo.totalNum}}</text>
  13. <text class="margin-left-30 price">今日收益:{{dataInfo.todayNum}}</text>
  14. </view>
  15. <button @click="jump" class="u-reset-button withdraw-btn">结算</button>
  16. </view>
  17. </view>
  18. <view @click.stop="showTime = true" class="flex justify-between"
  19. style="font-size: 24rpx;color: #666666;background-color: #f6f6f6;">
  20. <view class="flex">
  21. <view class="bg-white cu-btn round margin-30 sm">
  22. <text>{{defaultTime}}</text>
  23. <text class="cuIcon-triangledownfill text-gray" style="font-size: 50rpx;"></text>
  24. </view>
  25. <!-- <view class="total-box">收入¥0.00 支出¥0.00</view> -->
  26. </view>
  27. <!-- <view class="center margin-right-30">
  28. 统计
  29. <text class="cuIcon-right"></text>
  30. </view> -->
  31. </view>
  32. <scroll-view scroll-x class="bg-white nav">
  33. <view class="flex text-center">
  34. <view class="cu-item flex-sub" :class="index==stateCurrent?'text-base cur text-xl text-bold ':'text-lg'"
  35. v-for="(item,index) in statusList" :key="index" @tap="onTab(index)">
  36. {{item.name}}
  37. </view>
  38. </view>
  39. </scroll-view>
  40. <u-sticky v-if="stateCurrent==0" offset-top="0" :enable="true">
  41. <view class="flex bg-white u-border-top " style="padding: 30rpx">
  42. <view style="width: 51%;margin-left: 60rpx;">
  43. 来源
  44. </view>
  45. <view class="text-center" style="width: 25%;">
  46. 折扣
  47. </view>
  48. <view class="text-right" style="width: 24%;margin-right: 20rpx;">
  49. 金额
  50. </view>
  51. </view>
  52. </u-sticky>
  53. <view v-show="stateCurrent==0" class="bg-white safe-area-inset-bottom tabsClass" style="height: 100%;">
  54. <navigator :url="'/pages/my-bills/bills-detail?id='+item.id+'&type=all'" class="u-border-bottom flex"
  55. v-for="(item,index) in list" :key="index">
  56. <view class="area1">
  57. <image v-if="$isNotEmpty(item.avatar)" :src="item.avatar"></image>
  58. <block v-else>
  59. <image v-if="item.payWay=='WECHAT'" src="@/static/icon/wx.png"></image>
  60. <image v-else-if="item.payWay=='ALIPAY'" src="@/static/icon/ALIPAY.png"></image>
  61. <image v-else-if="item.payWay=='UNIONPAY'" src="@/static/icon/UNIONPAY.png"></image>
  62. <image v-else-if="item.payWay=='APPLEPAY'" src="@/static/icon/apple.png"></image>
  63. <image v-else src="@/static/icon/avatar.png"></image>
  64. </block>
  65. <view>
  66. <text v-if="$isNotEmpty(item.nickName)">{{item.nickName}}</text>
  67. <block v-else>
  68. <text v-if="item.payWay=='WECHAT'">微信用户</text>
  69. <text v-else-if="item.payWay=='ALIPAY'">支付宝用户</text>
  70. <text v-else-if="item.payWay=='UNIONPAY'">银联用户</text>
  71. <text v-else-if="item.payWay=='APPLEPAY'">苹果用户</text>
  72. <text v-else>用户昵称</text>
  73. </block>
  74. <text>{{item.createTime}}</text>
  75. </view>
  76. </view>
  77. <view class="area2">
  78. <text>{{discount(item.discount)}}</text>
  79. </view>
  80. <view class="area3">
  81. <text class="text-base price plus">{{item.receiveNumYp || 0}}</text>
  82. </view>
  83. </navigator>
  84. </view>
  85. <view v-show="stateCurrent==1" class="bg-white safe-area-inset-bottom tabsClass" style="height: 100%;">
  86. <navigator :url="'/pages/withdraw/detail?id='+item.id" class="card u-border-bottom"
  87. v-for="(item,index) in list" :key="index">
  88. <view class="left">
  89. <view class="margin-bottom-20 flex">
  90. <text class="text-bold" style="font-size: 32rpx;">余额结算</text>
  91. </view>
  92. <text class="desc">{{item.createTime}}</text>
  93. </view>
  94. <view class="right center text-base">
  95. <view v-if="item.withdrawStatus == 'DONE'" class="value" style="margin-bottom: 10rpx;">
  96. <text>-</text>
  97. <text class="" style="margin: 0 4rpx;">{{item.price}}</text>
  98. <text class="text-sm">元</text>
  99. </view>
  100. <view v-else class="text-sm">
  101. <text v-if="item.withdrawStatus == 'WAITING'" class="text-warn"
  102. style="font-size: 26rpx;margin-left: 10rpx;">处理中</text>
  103. <text v-if="item.withdrawStatus == 'FAIL'" class="text-error"
  104. style="font-size: 26rpx;margin-left: 10rpx;">结算失败</text>
  105. <text v-if="item.withdrawStatus == 'FAIL'" @click.stop="toast(item.failReason)"
  106. class="cuIcon-question text-error u-m-l-4"></text>
  107. </view>
  108. </view>
  109. </navigator>
  110. </view>
  111. <toast ref="toast"></toast>
  112. <u-picker confirm-color="#EF9944" v-model="showTime" mode="time" :params="params" @confirm="confirmTime">
  113. </u-picker>
  114. </mescroll>
  115. </template>
  116. <script>
  117. import mescroll from '@/components/mescroll-body/mescroll-uni.vue'
  118. export default {
  119. components: {
  120. mescroll
  121. },
  122. props: {
  123. type: Number,
  124. },
  125. data() {
  126. return {
  127. dataInfo: {},
  128. stateCurrent: 0, //默认
  129. statusList: [{
  130. name: '收入',
  131. value: 0
  132. },
  133. {
  134. name: '支出',
  135. value: 1
  136. }
  137. ],
  138. //时间
  139. showTime: false,
  140. params: {
  141. year: true,
  142. month: true,
  143. },
  144. defaultTime: '',
  145. //数据
  146. list: [],
  147. mescroll: null,
  148. upOption: {
  149. noMoreSize: 5,
  150. auto: false,
  151. },
  152. // 下拉配置参数
  153. downOption: {
  154. use: false,
  155. auto: false
  156. },
  157. };
  158. },
  159. watch: {
  160. type() {
  161. if (!this.isInit && this.type === 1) {
  162. this.mescroll.resetUpScroll()
  163. }
  164. }
  165. },
  166. mounted() {
  167. if (!this.isInit && this.type === 1) {
  168. this.mescroll.resetUpScroll()
  169. }
  170. },
  171. created() {
  172. this.defaultTime = this.$dateTime.format(new Date(), 'YYYY-mm')
  173. this.queryBalance()
  174. },
  175. methods: {
  176. toast(msg) {
  177. console.log(msg);
  178. this.$refs.toast.toast(msg)
  179. },
  180. jump() {
  181. let params = {
  182. type: 'BALANCE_WITHDRAW',
  183. canWithDraw: this.dataInfo.availableNum,
  184. }
  185. uni.navigateTo({
  186. url: "/pages/withdraw/withdraw" + this.$u.queryParams(params)
  187. })
  188. },
  189. queryBalance() {
  190. this.$api.shopTrade.balanceQuery({
  191. shopId: this.vuex_shopId
  192. }).then(res => {
  193. this.dataInfo = res.data
  194. })
  195. },
  196. mescrollInit(mescroll) {
  197. this.mescroll = mescroll
  198. },
  199. onTab(index) {
  200. this.stateCurrent = index
  201. this.mescroll.resetUpScroll();
  202. },
  203. confirmTime(e) {
  204. this.defaultTime = e.year + '-' + e.month
  205. this.mescroll.resetUpScroll();
  206. },
  207. fetchOutcome(mescroll) {
  208. let params = {
  209. current: mescroll.num,
  210. size: mescroll.size,
  211. ownerype: '商户',
  212. ownerId: this.vuex_shopId,
  213. type: 'BALANCE_WITHDRAW'
  214. }
  215. try {
  216. this.$api.withdraw.list(params).then(res => {
  217. let data = res.data.records
  218. let total = res.data.total
  219. mescroll.endBySize(data.length, total);
  220. if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  221. this.list = this.list.concat(data); //追加新数据
  222. })
  223. } catch (e) {
  224. this.mescroll.endErr()
  225. }
  226. },
  227. fetchIncome(mescroll) {
  228. console.log("balance");
  229. let params = {
  230. receiveId: this.vuex_shopId,
  231. current: mescroll.num,
  232. size: mescroll.size,
  233. payStatus: this.$global.PAY_STATUS.SUCCESS,
  234. billType: 'price'
  235. }
  236. if (this.defaultTime) {
  237. params.createTime = this.$dateTime.format(new Date(this.defaultTime))
  238. } else {
  239. params.createTime = this.$dateTime.format(new Date())
  240. }
  241. try {
  242. this.$api.bills.list(params).then(res => {
  243. let data = res.data.records
  244. let total = res.data.total
  245. mescroll.endBySize(data.length, total);
  246. if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  247. this.list = this.list.concat(data); //追加新数据
  248. })
  249. } catch (e) {
  250. this.mescroll.endErr()
  251. }
  252. },
  253. upCallback(mescroll) {
  254. if (this.stateCurrent == 0) {
  255. this.fetchIncome(mescroll)
  256. } else {
  257. this.fetchOutcome(mescroll)
  258. }
  259. },
  260. downCallback() {
  261. setTimeout(() => {
  262. this.mescroll.resetUpScroll();
  263. }, 500)
  264. },
  265. }
  266. };
  267. </script>
  268. <style>
  269. page {
  270. background-color: #FFFFFF;
  271. }
  272. </style>
  273. <style lang="scss" scoped>
  274. .area1 {
  275. $img-width: 70rpx;
  276. width: 54%;
  277. display: flex;
  278. height: 120rpx;
  279. padding-left: 30rpx;
  280. justify-content: center;
  281. align-items: center;
  282. image {
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. width: $img-width;
  287. height: $img-width;
  288. border-radius: 50%;
  289. }
  290. view {
  291. width: 80%;
  292. display: flex;
  293. flex-direction: column;
  294. justify-content: space-between;
  295. margin-left: 10rpx;
  296. }
  297. text:first-child {
  298. margin-bottom: 8rpx;
  299. }
  300. text:last-child {
  301. margin-top: 8rpx;
  302. color: #999;
  303. }
  304. }
  305. .area2 {
  306. display: flex;
  307. justify-content: center;
  308. align-items: center;
  309. text-align: center;
  310. width: 22%;
  311. margin-top: 10rpx;
  312. font-weight: 300;
  313. color: #666;
  314. }
  315. .area3 {
  316. display: flex;
  317. justify-content: center;
  318. align-items: center;
  319. width: 24%;
  320. font-size: 32rpx;
  321. margin-top: 10rpx;
  322. }
  323. .head_box {
  324. font-weight: 300;
  325. background-color: #fff;
  326. padding: 30rpx 0;
  327. .card-box {
  328. width: 700rpx;
  329. min-height: 300rpx;
  330. padding: 40rpx 40rpx 0rpx;
  331. background-color: #ff9201;
  332. box-shadow: 1rpx 5rpx 16rpx 0 rgba(255, 148, 71, .6);
  333. border-radius: 30rpx;
  334. overflow: hidden;
  335. position: relative;
  336. .card-head {
  337. color: #fff;
  338. font-size: 30rpx;
  339. }
  340. .money-num {
  341. font-size: 70rpx;
  342. line-height: 70rpx;
  343. font-weight: 500;
  344. color: #ffffff;
  345. }
  346. .reduce-num {
  347. font-size: 26rpx;
  348. font-weight: 400;
  349. color: #ffffff;
  350. }
  351. .withdraw-btn {
  352. width: 120rpx;
  353. height: 60rpx;
  354. line-height: 60rpx;
  355. background: #ffffff;
  356. border-radius: 30px;
  357. font-size: 24rpx;
  358. font-weight: 500;
  359. color: #ff9201;
  360. position: absolute;
  361. right: 30rpx;
  362. top: 40rpx;
  363. }
  364. }
  365. }
  366. .total-box {
  367. display: flex;
  368. justify-content: center;
  369. align-items: center;
  370. margin-right: 40rpx;
  371. font-size: 24rpx;
  372. font-weight: 500;
  373. color: #999999;
  374. }
  375. .card {
  376. display: flex;
  377. justify-content: space-between;
  378. background-color: #FFFFFF;
  379. padding: 30rpx 50rpx;
  380. .desc {
  381. color: #b2b2b2;
  382. font-size: 24rpx;
  383. font-weight: 400;
  384. }
  385. .left {
  386. display: flex;
  387. flex-direction: column;
  388. .title {
  389. font-size: 32rpx;
  390. color: #2a2a2a;
  391. }
  392. }
  393. .right {
  394. display: flex;
  395. flex-direction: column;
  396. .value {
  397. text-align: right;
  398. font-size: 36rpx;
  399. color: #FF9447;
  400. }
  401. }
  402. }
  403. </style>