index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="page">
  3. <view class="wallet-header">
  4. <view class="wallet-header_title">
  5. <view class="wallet-header_title-left">
  6. <uv-icon name="level" color="white" size="28"></uv-icon>
  7. <text class="font16">我的钱包</text>
  8. </view>
  9. <text class="wallet-header_title-refund" @click="handleRefund">退款</text>
  10. </view>
  11. <view class="wallet-header_balance">
  12. <text class="font18 mr10" style="vertical-align: top">¥</text>
  13. <text style="font-size: 32px; line-height: 32px;font-weight: 600;">{{ ((account.balance || 0) / 100).toFixed(2) }}
  14. </text>
  15. </view>
  16. <view class="wallet-header_pounds">
  17. <view>
  18. <text>充值余额:</text>
  19. <text>{{ (account.rechargeBalance / 100).toFixed(2) }}</text>
  20. </view>
  21. <view>
  22. <text>赠款余额:</text>
  23. <text>{{ (account.grantsBalance / 100).toFixed(2) }}</text>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="wallet-body">
  28. <uv-tabs :list="tabs" :current="tab" @click="handleTabClick"></uv-tabs>
  29. <uv-list>
  30. <uv-list-item
  31. clickable :show-arrow="item.type===3" v-for="(item,index) in dataList" :key="index" @click="handleClickDetail(item)">
  32. <template #default>
  33. <view class="wallet-item">
  34. <view class="wallet-item_header">
  35. <view class="flex-inline">
  36. <text class="wallet-item_header-type">{{ fmtDictName('WalletDetail.type', item.type) }}</text>
  37. <uv-tags class="ml10" style="margin-left: 10px;" size="mini" plain
  38. :type="item.status==0?'primary':(item.status==1?'success':'error')"
  39. :text="fmtDictName('WalletDetail.status', item.status)"></uv-tags>
  40. </view>
  41. <text class="wallet-item_header-amt">{{ (item.amount / 100).toFixed(2) }}元</text>
  42. </view>
  43. <view class="wallet-item_body">
  44. <text class="wallet-item_body-order">{{ item.orderNo }}</text>
  45. <text class="wallet-item_body-time">{{ fmtDateTime(item.transactionTime) }}</text>
  46. </view>
  47. </view>
  48. </template>
  49. </uv-list-item>
  50. </uv-list>
  51. <uv-empty mode="order" v-if="!dataList||dataList.length===0" text="暂无数据"></uv-empty>
  52. </view>
  53. <view class="wallet-bottom">
  54. <uv-button
  55. type="primary"
  56. color="#19A497"
  57. @click="to(`/pages-user/wallet/recharge`)">充值
  58. </uv-button>
  59. </view>
  60. </view>
  61. </template>
  62. <script setup lang="ts">
  63. import {onPullDownRefresh, onReachBottom, onShow, onLoad} from "@dcloudio/uni-app";
  64. import {ref} from "vue";
  65. import {body, get} from "@/utils/https";
  66. import {checkLogin} from "@/utils/auth";
  67. import {fmtDictName, fmtDateTime} from "@/utils/common";
  68. const account = ref();
  69. const dataList = ref([])
  70. const tab = ref(0);
  71. const tabs = ref([
  72. {
  73. name: "全部",
  74. value: 0,
  75. },
  76. {
  77. name: "充值",
  78. value: 1,
  79. },
  80. {
  81. name: "退款",
  82. value: 2,
  83. },
  84. {
  85. name: "消费",
  86. value: 3,
  87. },
  88. ]);
  89. const handleRefund = () => {
  90. to(`/pages-user/wallet/refund`)
  91. }
  92. onLoad((options: any) => {
  93. if (options.tab) {
  94. tab.value = options.tab;
  95. }
  96. })
  97. onShow((options: any) => {
  98. checkLogin().then(() => {
  99. loadData();
  100. })
  101. })
  102. onReachBottom(() => {
  103. loadData();
  104. });
  105. onPullDownRefresh(() => {
  106. loadData();
  107. });
  108. const to = (url: string) => {
  109. uni.navigateTo({
  110. url
  111. })
  112. }
  113. const handleTabClick = (e: any) => {
  114. let {name, value, index} = e
  115. tab.value = index;
  116. console.log(index)
  117. loadData();
  118. }
  119. const loadData = () => {
  120. get(`/account/balance`).then(res => {
  121. account.value = res;
  122. })
  123. get(`/account/walletDetailList`, {type: tab.value}).then((list: any) => {
  124. dataList.value = list;
  125. })
  126. }
  127. const handleClickDetail = (walletDetail: any) => {
  128. if(walletDetail.type!=3){
  129. return;
  130. }
  131. uni.navigateTo({
  132. url: `/pages-order/detail/index?id=${walletDetail.id}&type=${walletDetail.type}&orderNo=${walletDetail.orderNo}`,
  133. });
  134. };
  135. </script>
  136. <style lang="scss">
  137. .page {
  138. height: 100vh;
  139. width: 100vw;
  140. background: linear-gradient(
  141. 180deg,
  142. #e0ebff 0%,
  143. rgba(255, 255, 255, 0) 60.13%
  144. );
  145. display: flex;
  146. flex-direction: column;
  147. .wallet-header {
  148. border-radius: 20rpx;
  149. background-color: $uni-color-primary;
  150. margin: 20rpx;
  151. display: flex;
  152. flex-direction: column;
  153. padding: 20rpx;
  154. &_title {
  155. display: inline-flex;
  156. justify-content: space-between;
  157. color: whitesmoke;
  158. &-left {
  159. display: inline-flex;
  160. align-items: center;
  161. align-content: center;
  162. color: whitesmoke;
  163. }
  164. &-refund {
  165. color: #127779;
  166. padding: 6rpx 28rpx;
  167. font-size: 26rpx;
  168. border-radius: 14px;
  169. background-color: #65C0B7;
  170. display: flex;
  171. align-items: center;
  172. justify-content: center;
  173. align-content: center;
  174. }
  175. }
  176. &_balance {
  177. display: inline-flex;
  178. color: white;
  179. align-content: center;
  180. margin-top: 40rpx;
  181. }
  182. &_pounds {
  183. margin-top: 20rpx;
  184. display: inline-flex;
  185. align-content: center;
  186. align-items: center;
  187. color: white;
  188. justify-content: space-between;
  189. }
  190. }
  191. .wallet-body {
  192. flex: 1;
  193. overflow-y: scroll;
  194. overflow-x: hidden;
  195. margin: 20rpx 20rpx 60rpx 20rpx;
  196. .wallet-item {
  197. display: flex;
  198. flex-direction: column;
  199. padding: 14rpx;
  200. border-radius: 8rpx;
  201. margin: 10rpx 16 prx 10rpx 10rpx;
  202. &_header {
  203. display: inline-flex;
  204. flex-wrap: nowrap;
  205. justify-content: space-between;
  206. &-type {
  207. font-weight: 500;
  208. font-size: 14px;
  209. margin-right: 15rpx;
  210. }
  211. &-status {
  212. font-size: 12px;
  213. margin-left: 6px;
  214. border: 1px solid $uni-color-primary;
  215. border-radius: 2rpx;
  216. }
  217. &-amt {
  218. font-weight: 500;
  219. font-size: 17px;
  220. }
  221. }
  222. &_body {
  223. padding: 10rpx 0;
  224. display: inline-flex;
  225. justify-content: space-between;
  226. &-order, &-time {
  227. font-size: 12px;
  228. color: $uni-color-subtitle
  229. }
  230. }
  231. }
  232. }
  233. .wallet-bottom {
  234. width: 100%;
  235. height: 36px;
  236. }
  237. }
  238. </style>