猫妈狗爸伴宠师小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

409 lines
8.6 KiB

7 months ago
7 months ago
7 months ago
3 months ago
7 months ago
6 months ago
7 months ago
3 months ago
3 months ago
7 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
7 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
3 months ago
7 months ago
  1. <template>
  2. <!-- <div>交易明细</div> -->
  3. <view class="box">
  4. <view class="top flex" :style="{ borderRadius: '31.5rpx' }">
  5. <view @click="changeTab(0)" :class="{ active : type == 0 }" class="income flex element"
  6. :style="{ borderRadius: '31.5rpx' }">
  7. 收入明细
  8. </view>
  9. <view @click="changeTab(1)" :class="{ active : type == 1 }" class="income flex element"
  10. :style="{ borderRadius: '31.5rpx' }">
  11. 支出明细
  12. </view>
  13. </view>
  14. <view v-for="(item,index) in list" :key="index" class="Recharge">
  15. <view class="flex">
  16. <image style="width: 80rpx;height: 80rpx" src="https://img1.baidu.com/it/u=3034232350,1041791648&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500"
  17. mode="aspectFill"></image>
  18. <view class="text1">
  19. <view class="text2">
  20. {{ item.title }}
  21. <!-- 金额类型标签 -->
  22. <!-- <text v-if="item.moneyType !== undefined" class="money-type-tag" :class="getMoneyTypeClass(item.moneyType)">
  23. {{ getMoneyTypeText(item.moneyType) }}
  24. </text> -->
  25. </view>
  26. <view>
  27. {{ item.createTime }}
  28. </view>
  29. <!-- 审核状态显示 - 只在支出明细中显示 -->
  30. <view v-if="type === 1 && item.auditStatus !== undefined" class="audit-status">
  31. <text v-if="item.auditStatus === 0" class="status-pending">待审核</text>
  32. <text v-if="item.auditStatus === 1" class="status-approved">审核通过</text>
  33. <text v-if="item.auditStatus === 2" class="status-rejected">审核不通过</text>
  34. </view>
  35. <!-- 审核不通过时显示备注 - 只在支出明细中显示 -->
  36. <view v-if="type === 1 && item.auditStatus === 2 && item.remark" class="remark">
  37. 备注{{ item.remark }}
  38. </view>
  39. </view>
  40. </view>
  41. <view class="right-content">
  42. <view class="text3">
  43. {{ item.amount }}
  44. </view>
  45. <!-- 审核通过的提现显示领取按钮 -->
  46. <view v-if="item.auditStatus === 1 && type === 1 && item.state == 0" class="receive-btn" @click="receiveWithdrawal(item)">
  47. 领取
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script setup>
  54. import {
  55. ref
  56. } from "vue"
  57. import { useStore } from 'vuex'
  58. import {
  59. amountLogList
  60. } from "@/api/amount/index.js"
  61. import {
  62. withdrawalSuccessful
  63. } from "@/api/amount/index.js"
  64. import {
  65. onShow,
  66. onLoad
  67. } from "@dcloudio/uni-app"
  68. onLoad((options) => {
  69. console.log(options);
  70. // 如果有type参数,设置默认选中的tab
  71. if (options.type) {
  72. type.value = parseInt(options.type)
  73. }
  74. if (options.moneyType) {
  75. moneyType.value = parseInt(options.moneyType)
  76. }
  77. })
  78. onShow(() => {
  79. getRunningWater()
  80. })
  81. const store = useStore()
  82. const list = ref([]);
  83. const type = ref(0);
  84. const moneyType = ref(1);
  85. // 获取流水
  86. const getRunningWater = async () => {
  87. let response = await amountLogList({
  88. type: type.value,
  89. moneyType : moneyType.value,
  90. userId: store.state.user.userInfo.userId
  91. });
  92. if (response.code == 200) {
  93. list.value = response.data
  94. }
  95. }
  96. const changeTab = (index) => {
  97. type.value = index;
  98. getRunningWater();
  99. }
  100. // 获取金额类型文本
  101. const getMoneyTypeText = (moneyType) => {
  102. switch (moneyType) {
  103. case 0:
  104. return '合伙人余额'
  105. case 1:
  106. return '伴宠师余额'
  107. case 2:
  108. return '保证金余额'
  109. default:
  110. return ''
  111. }
  112. }
  113. // 获取金额类型样式类名
  114. const getMoneyTypeClass = (moneyType) => {
  115. switch (moneyType) {
  116. case 0:
  117. return 'money-type-partner'
  118. case 1:
  119. return 'money-type-sitter'
  120. case 2:
  121. return 'money-type-deposit'
  122. default:
  123. return ''
  124. }
  125. }
  126. // 领取提现
  127. const receiveWithdrawal = async (item) => {
  128. try {
  129. console.log('开始领取提现,item:', item)
  130. // 检查是否支持微信转账
  131. if (typeof wx === 'undefined' || !wx.canIUse('requestMerchantTransfer')) {
  132. console.log('微信API不可用')
  133. uni.hideLoading()
  134. if (result.code === 200) {
  135. uni.showToast({
  136. title: '领取失败,请将微信升级到最新版本',
  137. icon: 'icon',
  138. duration: 1500,
  139. success() {
  140. // 刷新列表
  141. getRunningWater()
  142. }
  143. })
  144. } else {
  145. uni.showToast({
  146. title: result.msg || '领取失败',
  147. icon: 'error',
  148. duration: 2000
  149. })
  150. }
  151. return
  152. }
  153. // 调用微信商户转账API
  154. wx.requestMerchantTransfer({
  155. mchId: '1665639691', // 商户ID
  156. appId: wx.getAccountInfoSync().miniProgram.appId,
  157. package: item.packageInfo || '', // 从后端获取的转账包信息
  158. success: async (res) => {
  159. console.log('微信转账成功:', res)
  160. // 转账成功后调用成功接口
  161. try {
  162. const result = await withdrawalSuccessful({
  163. id: item.id,
  164. userId: store.state.user.userInfo.userId
  165. })
  166. console.log('withdrawalSuccessful result:', result)
  167. uni.hideLoading()
  168. if (result.code === 200) {
  169. uni.showToast({
  170. title: '领取成功',
  171. icon: 'success',
  172. duration: 1500,
  173. success() {
  174. // 刷新列表
  175. getRunningWater()
  176. }
  177. })
  178. } else {
  179. uni.showToast({
  180. title: result.msg || '领取失败',
  181. icon: 'error',
  182. duration: 2000
  183. })
  184. }
  185. } catch (error) {
  186. console.error('调用withdrawalSuccessful失败:', error)
  187. uni.hideLoading()
  188. uni.showToast({
  189. title: '网络异常,请重试',
  190. icon: 'error',
  191. duration: 2000
  192. })
  193. }
  194. },
  195. fail: (res) => {
  196. }
  197. })
  198. } catch (error) {
  199. uni.hideLoading()
  200. console.error('领取提现异常:', error)
  201. uni.showToast({
  202. title: '网络异常,请重试',
  203. icon: 'error',
  204. duration: 2000
  205. })
  206. }
  207. }
  208. </script>
  209. <style scoped lang="scss">
  210. .box {
  211. width: 750rpx;
  212. min-height: 100vh;
  213. background-color: #FFFFFF;
  214. padding: 32rpx 24rpx 0 24rpx;
  215. box-sizing: border-box;
  216. }
  217. .top {
  218. width: 722rpx;
  219. height: 63rpx;
  220. background-color: #F3F3F3;
  221. }
  222. .active {
  223. background-color: #FFBF60;
  224. color: white;
  225. font-weight: 600;
  226. box-shadow: 0 2rpx 8rpx rgba(255, 191, 96, 0.3);
  227. }
  228. .income {
  229. width: 361rpx;
  230. height: 63rpx;
  231. line-height: 63rpx;
  232. font-size: 28rpx;
  233. font-weight: 500;
  234. justify-content: center;
  235. transition: all 0.3s ease;
  236. }
  237. .Recharge {
  238. padding: 32rpx 24rpx;
  239. box-sizing: border-box;
  240. display: flex;
  241. justify-content: space-between;
  242. align-items: flex-start;
  243. border-bottom: 1rpx solid #f5f5f5;
  244. &:last-child {
  245. border-bottom: none;
  246. }
  247. }
  248. .flex {
  249. display: flex;
  250. }
  251. .text1 {
  252. font-size: 26rpx;
  253. color: #666666;
  254. line-height: 1.4;
  255. margin-left: 20rpx;
  256. }
  257. .Recharge image {
  258. width: 80rpx;
  259. height: 80rpx;
  260. border-radius: 8rpx;
  261. margin-top: 0;
  262. }
  263. .text2 {
  264. font-weight: 500;
  265. color: #333333;
  266. font-size: 28rpx;
  267. line-height: 40rpx;
  268. margin-bottom: 8rpx;
  269. display: flex;
  270. align-items: center;
  271. }
  272. .text3 {
  273. color: #FF2A2A;
  274. font-size: 30rpx;
  275. font-weight: 600;
  276. line-height: 44rpx;
  277. }
  278. .right-content {
  279. display: flex;
  280. flex-direction: column;
  281. align-items: flex-end;
  282. min-width: 120rpx;
  283. }
  284. .right-content > .text3 {
  285. margin-bottom: 16rpx;
  286. }
  287. .audit-status {
  288. margin-top: 12rpx;
  289. font-size: 22rpx;
  290. }
  291. .status-pending {
  292. color: #FF9800;
  293. background-color: #FFF3E0;
  294. padding: 6rpx 12rpx;
  295. border-radius: 12rpx;
  296. font-size: 20rpx;
  297. font-weight: 500;
  298. display: inline-block;
  299. }
  300. .status-approved {
  301. color: #4CAF50;
  302. background-color: #E8F5E8;
  303. padding: 6rpx 12rpx;
  304. border-radius: 12rpx;
  305. font-size: 20rpx;
  306. font-weight: 500;
  307. display: inline-block;
  308. }
  309. .status-rejected {
  310. color: #F44336;
  311. background-color: #FFEBEE;
  312. padding: 6rpx 12rpx;
  313. border-radius: 12rpx;
  314. font-size: 20rpx;
  315. font-weight: 500;
  316. display: inline-block;
  317. }
  318. .remark {
  319. margin-top: 12rpx;
  320. color: #666;
  321. font-size: 24rpx;
  322. line-height: 36rpx;
  323. background-color: #f8f8f8;
  324. padding: 12rpx;
  325. border-radius: 8rpx;
  326. border-left: 4rpx solid #F44336;
  327. }
  328. .receive-btn {
  329. background-color: #FFBF60;
  330. color: #FFFFFF;
  331. padding: 12rpx 24rpx;
  332. border-radius: 24rpx;
  333. font-size: 26rpx;
  334. font-weight: 500;
  335. text-align: center;
  336. min-width: 80rpx;
  337. cursor: pointer;
  338. box-shadow: 0 4rpx 12rpx rgba(255, 191, 96, 0.3);
  339. transition: all 0.3s ease;
  340. }
  341. .receive-btn:active {
  342. background-color: #E6A84D;
  343. transform: translateY(2rpx);
  344. box-shadow: 0 2rpx 8rpx rgba(255, 191, 96, 0.2);
  345. }
  346. /* 金额类型标签样式 */
  347. .money-type-tag {
  348. font-size: 20rpx;
  349. font-weight: 500;
  350. padding: 4rpx 8rpx;
  351. border-radius: 8rpx;
  352. margin-left: 12rpx;
  353. display: inline-block;
  354. line-height: 1;
  355. flex-shrink: 0;
  356. }
  357. .money-type-partner {
  358. color: #1976D2;
  359. background-color: #E3F2FD;
  360. }
  361. .money-type-sitter {
  362. color: #388E3C;
  363. background-color: #E8F5E8;
  364. }
  365. .money-type-deposit {
  366. color: #F57C00;
  367. background-color: #FFF3E0;
  368. }
  369. </style>