index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <view class="balance-container">
  3. <uv-navbar
  4. title="我的钱包"
  5. placeholder
  6. autoBack
  7. bgColor="#f7f7f7"
  8. ></uv-navbar>
  9. <view class="balance-top">
  10. <image
  11. class="balance-img"
  12. :src="$handleImageUrl('/personalCenter/wallet/icon_img.png')"
  13. alt=""
  14. />
  15. <view class="balance-info">
  16. <view class="balance-info-left">
  17. <view class="balance-nums">
  18. <text class="balance-nums-text">¥</text>
  19. <text class="balance-nums-num">
  20. {{ $addDecimals(balance || 0, 2) }}
  21. </text>
  22. </view>
  23. <view class="balance-nums-unit">余额(元)</view>
  24. </view>
  25. <view class="balance-info-right">
  26. <view class="balance-info-btn" @click.stop="goToWithdraw"
  27. >去提现</view
  28. >
  29. <!-- <view class="balance-nums-unit right-text" @click.stop="turnClick"
  30. >转积分</view
  31. > -->
  32. </view>
  33. </view>
  34. </view>
  35. <view class="balance-list">
  36. <view class="balance-list-title u-flex-center">
  37. <image
  38. class="balance-list-title-img"
  39. :src="$handleImageUrl('/personalCenter/wallet/icon1.png')"
  40. alt=""
  41. />
  42. <text class="balance-list-title-text">余额明细</text>
  43. </view>
  44. <view
  45. class="balance-list-item u-flex-center-sb"
  46. v-for="(item, index) in pointsList"
  47. :key="index"
  48. >
  49. <view class="balance-list-item-content-left">
  50. <view class="balance-list-item-content-title">{{
  51. item.businessName
  52. }}</view>
  53. <view
  54. class="balance-list-item-content-notes"
  55. v-if="item.remark || item.sourceCode"
  56. >{{ item.remark }}({{ item.sourceCode }})</view
  57. >
  58. <view class="balance-list-item-content-time">{{
  59. item.createTime
  60. }}</view>
  61. </view>
  62. <view
  63. class="balance-list-item-content-right"
  64. :style="{ color: item.billType ? '#ff0000' : '#1a1a1a' }"
  65. >
  66. <text v-if="item.billType">+</text>
  67. <text v-else>-</text>
  68. <text>{{ item.entryValue }}</text>
  69. </view>
  70. </view>
  71. <noData
  72. v-if="pointsList == 0"
  73. :config="{ top: 5, content: '暂无数据~' }"
  74. />
  75. <loadMore v-if="pointsList.length > 0" :status="status" />
  76. </view>
  77. <!-- 转换积分 -->
  78. <!-- <RedeemPoints
  79. ref="redeemPointsRef"
  80. @confirm="handleExchangeConfirm"
  81. title="转换"
  82. /> -->
  83. </view>
  84. </template>
  85. <script setup>
  86. import { ref } from "vue";
  87. import {
  88. onLoad,
  89. onReachBottom,
  90. onPullDownRefresh,
  91. onShow,
  92. } from "@dcloudio/uni-app";
  93. import { userBalanceRecordPage_Api } from "@/api/index";
  94. import { balanceToIntegral_Api } from "@/api/index.js";
  95. import { isSetPayPassword_Api, totalBalance_Api } from "@/api/userInfo.js";
  96. const balance = ref(0); // 余额
  97. const params = ref({ pageNum: 1, pageSize: 10 });
  98. const pointsList = ref([]);
  99. const status = ref("loading");
  100. const redeemPointsRef = ref(null);
  101. const isSetPayPassword = ref(null);
  102. // 获取余额明细列表
  103. const getList = () => {
  104. status.value = "loading";
  105. uni.showLoading({
  106. title: "加载中...",
  107. mask: true,
  108. });
  109. userBalanceRecordPage_Api(params.value)
  110. .then((res) => {
  111. uni.hideLoading();
  112. if (res && res.code == 200) {
  113. uni.stopPullDownRefresh();
  114. pointsList.value = pointsList.value.concat(res.rows);
  115. if (res.total <= pointsList.value.length) {
  116. status.value = "noMore";
  117. } else {
  118. status.value = "more";
  119. }
  120. }
  121. })
  122. .catch((err) => {
  123. uni.hideLoading();
  124. });
  125. };
  126. // 跳转提现页面
  127. const goToWithdraw = () => {
  128. uni.navigateTo({
  129. url: "/pages/user/wallet/reflect?pageType=1",
  130. });
  131. };
  132. // 获取账户信息
  133. const accountInfo = () => {
  134. totalBalance_Api().then((res) => {
  135. if (res && res.code == 200) {
  136. balance.value = res.data || "0.00";
  137. }
  138. });
  139. };
  140. // 转换积分
  141. const turnClick = () => {
  142. // console.log(item);
  143. if (!isSetPayPassword.value) {
  144. uni.$uv.toast("请先设置支付密码");
  145. setTimeout(() => {
  146. uni.navigateTo({
  147. url: "/pages/set/payPassword",
  148. });
  149. }, 500);
  150. return;
  151. }
  152. redeemPointsRef.value.open({
  153. totalNum: (balance.value * 1).toFixed(2),
  154. });
  155. };
  156. // 转换积分确认
  157. const handleExchangeConfirm = (data) => {
  158. console.log("转换积分确认", data);
  159. return;
  160. let form = {
  161. payPassword: data.payPassword,
  162. integral: data.exchangePoints,
  163. };
  164. uni.showLoading({ title: "转换中...", mask: true });
  165. balanceToIntegral_Api(form)
  166. .then((res) => {
  167. uni.hideLoading();
  168. // console.log(res);
  169. if (res && res.code == 200) {
  170. uni.$uv.toast("兑换成功");
  171. exchangePopupRef.value.close();
  172. handleReset();
  173. }
  174. })
  175. .catch((err) => {
  176. console.log(err);
  177. uni.hideLoading();
  178. });
  179. };
  180. // onShow(() => {
  181. // if (isSetPayPassword.value == null) {
  182. // try {
  183. // isSetPayPassword_Api().then((res) => {
  184. // // console.log(res);
  185. // if (res && res.code == 200 && res.data != null) {
  186. // isSetPayPassword.value = res.data ? true : false;
  187. // }
  188. // });
  189. // } catch (error) {}
  190. // }
  191. // });
  192. onLoad((options) => {
  193. accountInfo();
  194. params.value.pageNum = 1;
  195. pointsList.value = [];
  196. getList();
  197. });
  198. onReachBottom(() => {
  199. if (status.value !== "loading" && status.value !== "noMore") {
  200. params.value.pageNum++;
  201. getList();
  202. }
  203. });
  204. onPullDownRefresh(() => {
  205. accountInfo();
  206. params.value.pageNum = 1;
  207. pointsList.value = [];
  208. getList();
  209. });
  210. </script>
  211. <style lang="scss" scoped>
  212. .balance-container {
  213. background: #f7f7f7;
  214. min-height: 100vh;
  215. box-sizing: border-box;
  216. .balance-top {
  217. padding: 167rpx 30rpx 0 30rpx;
  218. min-height: 364rpx;
  219. position: relative;
  220. box-sizing: border-box;
  221. .balance-img {
  222. position: absolute;
  223. left: 30rpx;
  224. top: 30rpx;
  225. width: 690rpx;
  226. height: 334rpx;
  227. z-index: 1;
  228. }
  229. .balance-info {
  230. position: relative;
  231. z-index: 2;
  232. padding: 0 32rpx 0 37rpx;
  233. display: flex;
  234. align-items: center;
  235. justify-content: space-between;
  236. .balance-info-left {
  237. flex: 1;
  238. margin-right: 20rpx;
  239. .balance-nums {
  240. font-size: 40rpx;
  241. font-weight: normal;
  242. color: #ffffff;
  243. // line-height: 38rpx;
  244. margin-bottom: 30rpx;
  245. .balance-nums-text {
  246. font-size: 28rpx;
  247. font-weight: normal;
  248. color: #ffffff;
  249. margin-right: 5rpx;
  250. }
  251. }
  252. }
  253. .balance-nums-unit {
  254. font-size: 30rpx;
  255. font-weight: 400;
  256. color: #ffffff;
  257. }
  258. .balance-info-btn {
  259. flex-shrink: 0;
  260. width: 166rpx;
  261. height: 68rpx;
  262. line-height: 68rpx;
  263. background: #ffffff;
  264. border-radius: 34rpx;
  265. box-shadow: 0px 3rpx 6rpx 0px rgba(68, 16, 16, 0.43);
  266. font-size: 30rpx;
  267. font-weight: 700;
  268. color: #ef7373;
  269. text-align: center;
  270. }
  271. .right-text {
  272. text-align: center;
  273. margin-top: 16rpx;
  274. color: #ffffff;
  275. }
  276. }
  277. }
  278. .balance-list {
  279. padding: 30rpx 54rpx;
  280. margin-top: 30rpx;
  281. // background: url("https://shop.xiaocaituan.com/image/personalCenter/wallet/icon_bg.png");
  282. background-image: url("https://shop.xiaocaituan.com/image/personalCenter/wallet/icon_bg.png");
  283. background-repeat: no-repeat;
  284. background-size: 100% 1079rpx;
  285. background-color: #ffffff;
  286. .balance-list-title {
  287. .balance-list-title-img {
  288. width: 61rpx;
  289. height: 48rpx;
  290. }
  291. .balance-list-title-text {
  292. font-size: 34rpx;
  293. font-weight: 700;
  294. color: #1a1a1a;
  295. margin-left: 10rpx;
  296. }
  297. }
  298. .balance-list-item {
  299. padding: 30rpx 0;
  300. border-bottom: 1rpx solid #f0f0f0;
  301. .balance-list-item-content-left {
  302. flex: 1;
  303. .balance-list-item-content-title {
  304. font-size: 28rpx;
  305. }
  306. .balance-list-item-content-notes {
  307. font-size: 26rpx;
  308. color: #666666;
  309. margin-top: 5rpx;
  310. }
  311. .balance-list-item-content-time {
  312. font-size: 22rpx;
  313. color: #999999;
  314. margin-top: 5rpx;
  315. }
  316. }
  317. .balance-list-item-content-right {
  318. flex-shrink: 0;
  319. margin-left: 20rpx;
  320. font-size: 30rpx;
  321. font-weight: 700;
  322. }
  323. }
  324. }
  325. }
  326. </style>