index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view class="wallet-main">
  3. <view class="wallet-hi">
  4. <view class="wallet-hi-title">Hi,您好!</view>
  5. <text class="wallet-hi-text">为了您更好地使用钱包功能</text>
  6. <!-- <text class="wallet-hi-text">为了您更好地使用钱包功能, <text class="wallet-active" @click="onAddBankCard" >添加银行卡> </text> </text> -->
  7. </view>
  8. <view class="wallet-box card-box ">
  9. <view class="wallet-box-top">
  10. <view class="flex-center-column">
  11. <text class="wallet-box-title">钱包总额(元)</text>
  12. <view class="wallet-box-price">{{ data.balance }}</view>
  13. </view>
  14. <view>
  15. <view class="wallet-box-btn1 flex-center" @click="onWithdrawal">提现</view>
  16. <view class="wallet-box-btn2 flex-center" @click="onIncome">收支明细</view>
  17. </view>
  18. </view>
  19. <up-divider v-if="userType === 2"></up-divider>
  20. <view class="wallet-box-bottom" v-if="userType === 2">
  21. <view class="flex-center-column">
  22. <text class="wallet-box-title">可提现(元)</text>
  23. <view class="wallet-box-price2">{{ data.balance }}</view>
  24. </view>
  25. <view class="flex-center-column">
  26. <text class="wallet-box-title">待入账(元)</text>
  27. <view class="wallet-box-price2">{{ data.orderFrozenBalance }}</view>
  28. </view>
  29. <view class="flex-center-column">
  30. <text class="wallet-box-title">银行卡(张)</text>
  31. <view class="wallet-box-price2">0</view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="bank-box">
  36. <view v-for="item in bankList" :key="item.cardCode" :style="`background: ${item.color};border-radius: 8px;`" @click="onBankCardDetails(item)" >
  37. <BankItem bankCode="ABC" bankName="中国农业银行" cardType="储蓄卡" cardCode="5106365986893"/>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script setup>
  43. import { ref } from 'vue';
  44. import BankItem from '@/pages_mine/components/bank-item/bank-item.vue';
  45. import { getVolunteerAccountInfo,getAccountInfo,getWithdrawStatus } from "@/api/mine";
  46. import {
  47. onShow
  48. } from '@dcloudio/uni-app';
  49. const bankList = ref([
  50. // {
  51. // bankCode: 'ABC',
  52. // bankName: '中国农业银行',
  53. // cardType: '储蓄卡',
  54. // cardCode: '5106365986893',
  55. // color: 'linear-gradient(135deg, rgba(43, 102, 248, 1) 0%, rgba(27, 69, 178, 1) 100%), rgba(0, 0, 0, 0)'
  56. // },
  57. // {
  58. // bankCode: 'ABC',
  59. // bankName: '中国农业银行',
  60. // cardType: '储蓄卡',
  61. // cardCode: '5106365986893',
  62. // color: 'linear-gradient(135deg, rgba(43, 102, 248, 1) 0%, rgba(27, 69, 178, 1) 100%), rgba(0, 0, 0, 0)'
  63. // },
  64. ])
  65. const userType = uni.getStorageSync('userType') //读取本地存储
  66. const data = ref({
  67. balance: 0
  68. });
  69. const onWithdrawal = () => {
  70. getWithdrawStatus().then(res => {
  71. if(res.code === 200){
  72. // uni.navigateTo({
  73. // url: '/pages_mine/pages/withdrawal/index'
  74. // })
  75. uni.redirectTo({ url: `/pages_mine/pages/withdrawal/index` });
  76. }
  77. })
  78. }
  79. const onIncome = () => {
  80. uni.navigateTo({
  81. url: '/pages_mine/pages/income/index'
  82. })
  83. }
  84. const onAddBankCard = () => {
  85. uni.navigateTo({
  86. url: '/pages_mine/pages/addBankCard/index'
  87. })
  88. }
  89. const onBankCardDetails = (record) => {
  90. uni.navigateTo({
  91. url: '/pages_mine/pages/bankCardDetails/index'
  92. })
  93. }
  94. const init = async() => {
  95. try {
  96. uni.showLoading({
  97. title: '数据加载中...'
  98. });
  99. if(userType === 2){
  100. const res = await getVolunteerAccountInfo();
  101. data.value =res.data;
  102. }
  103. if(userType === 1){
  104. const res = await getAccountInfo();
  105. console.log(1,res);
  106. data.value = res.data;
  107. }
  108. } catch (error) {
  109. console.log('error', error);
  110. uni.showToast({
  111. title: error.msg,
  112. icon: 'error',
  113. });
  114. } finally {
  115. uni.hideLoading();
  116. }
  117. }
  118. onShow(()=>{
  119. init();
  120. })
  121. </script>
  122. <style lang="scss" scoped>
  123. .card-box {
  124. border-radius: 8px;
  125. background: rgba(255, 255, 255, 1);
  126. padding: 20px;
  127. margin-bottom: 12px;
  128. }
  129. .bank-box {
  130. border-radius: 8px;
  131. margin-bottom: 12px;
  132. }
  133. .wallet-main {
  134. position: fixed;
  135. top: 0px;
  136. left: 0px;
  137. right: 0px;
  138. bottom: 0px;
  139. background: rgba(245, 245, 245, 1);
  140. padding: 12px;
  141. overflow: auto;
  142. .wallet-hi-title {
  143. font-size: 20px;
  144. font-weight: 700;
  145. line-height: 28.96px;
  146. color: rgba(51, 51, 51, 1);
  147. }
  148. .wallet-hi-text {
  149. font-size: 14px;
  150. font-weight: 500;
  151. line-height: 20.27px;
  152. color: rgba(153, 153, 153, 1);
  153. }
  154. .wallet-active {
  155. font-size: 14px;
  156. font-weight: 500;
  157. line-height: 20.27px;
  158. color: rgba(255, 87, 4, 1);
  159. }
  160. .wallet-hi {
  161. margin-bottom: 20px;
  162. }
  163. .wallet-box-title {
  164. font-size: 12px;
  165. font-weight: 500;
  166. line-height: 17.38px;
  167. color: rgba(199, 199, 199, 1);
  168. margin-bottom: 8px;
  169. }
  170. .wallet-box-price {
  171. font-size: 30px;
  172. font-weight: 500;
  173. line-height: 35.16px;
  174. color: rgba(252, 228, 187, 1);
  175. }
  176. .wallet-box-price2 {
  177. font-size: 24px;
  178. font-weight: 400;
  179. line-height: 28.13px;
  180. color: rgba(252, 228, 187, 1);
  181. }
  182. .wallet-box {
  183. border-radius: 12px;
  184. background: linear-gradient(131.81deg, rgba(65, 65, 95, 1) 0%, rgba(45, 48, 74, 1) 100%);
  185. margin-bottom: 14px;
  186. .wallet-box-top {
  187. display: flex;
  188. align-content: center;
  189. justify-content: space-between;
  190. .wallet-box-btn1 {
  191. width: 78px;
  192. height: 30px;
  193. opacity: 1;
  194. border-radius: 4px;
  195. background: linear-gradient(222.81deg, rgba(255, 227, 194, 1) 0%, rgba(255, 226, 192, 1) 0%, rgba(255, 225, 189, 1) 0%, rgba(251, 204, 147, 1) 100%);
  196. margin-bottom: 14px;
  197. font-size: 16px;
  198. font-weight: 700;
  199. line-height: 23.17px;
  200. color: rgba(50, 52, 80, 1);
  201. }
  202. .wallet-box-btn2 {
  203. width: 78px;
  204. height: 30px;
  205. opacity: 1;
  206. border-radius: 4px;
  207. border: 1px solid rgba(255, 218, 172, 1);
  208. font-size: 16px;
  209. font-weight: 500;
  210. letter-spacing: 0px;
  211. line-height: 23.17px;
  212. color: rgba(255, 218, 172, 1);
  213. }
  214. }
  215. .wallet-box-bottom{
  216. display: flex;
  217. align-items: center;
  218. justify-content: space-around;
  219. }
  220. }
  221. }
  222. </style>