爱简收旧衣按件回收前端代码仓库
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.

438 lines
13 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
  1. <template>
  2. <view class="withdraw-container">
  3. <!-- 顶部banner轮播图 -->
  4. <!-- <view class="banner">
  5. <swiper
  6. :indicator-dots="false"
  7. :autoplay="true"
  8. :interval="3000"
  9. :duration="500"
  10. circular
  11. style="width: 100%; height: 390rpx;"
  12. >
  13. <swiper-item v-for="(item, index) in bannerList" :key="item.id || index">
  14. <image v-if="item.image" :src="item.image" mode="aspectFill" style="width: 100%; height: 100%;" />
  15. </swiper-item>
  16. </swiper>
  17. </view>
  18. <view class="nav-bar">
  19. <view class="back" @tap="goBack">
  20. <uni-icons type="left" size="20"></uni-icons>
  21. </view>
  22. <text class="title">提现</text>
  23. </view> -->
  24. <navbar title="提现" leftClick @leftClick="$utils.navigateBack" />
  25. <!-- 主内容卡片 -->
  26. <view class="main-card" :style="{ marginLeft: '24rpx', marginRight: '24rpx' }">
  27. <!-- <view class="section-title">微信提现</view> -->
  28. <view class="form-group">
  29. <view class="form-label">真实姓名</view>
  30. <input class="form-input" v-model="realName" placeholder="请输入" placeholder-class="input-placeholder" />
  31. </view>
  32. <view class="divider"></view>
  33. <view class="form-group">
  34. <view class="form-label">提现金额</view>
  35. <input class="form-input" v-model="amount" placeholder="请输入" placeholder-class="input-placeholder" />
  36. </view>
  37. </view>
  38. <!-- 说明文字 -->
  39. <view class="desc-area">
  40. <text>
  41. 请仔细检查并确认相关信息因用户个人疏忽导致的充值错误需由用户自行承担
  42. <text class="desc-link" @tap="showNotice">提现须知</text>
  43. </text>
  44. </view>
  45. <!-- 提现须知弹窗 -->
  46. <view v-if="showNoticePopup" class="notice-popup">
  47. <view class="popup-mask" @tap="closeNotice"></view>
  48. <view class="popup-content">
  49. <view class="popup-title">提现须知</view>
  50. <scroll-view class="popup-body" scroll-y>
  51. <!-- <view class="section">
  52. <text class="section-title">1.适用范围:</text>
  53. <text class="section-content">(1)本规则仅适用于可提现账户</text>
  54. </view>
  55. <view class="section">
  56. <text class="section-title">2.提现规则:</text>
  57. <text class="section-content">(1)提现时间:订单确认收货次月25日可提现由于财务审核遇节假日不可抗力等原因部分时间段将无法支持提现操作具体请以提现页面信息为准</text>
  58. <text class="section-content">(2)提现限额:单笔提现不能低于人民币10元不能超过5万元具体请以提现页面信息为准</text>
  59. <text class="section-content">到账时间:一般发起提现申请后48小时内到账您在瀚海回收绑定的微信账户上</text>
  60. <text class="section-content">(3)提现账号绑定:一个瀚海回收账号只可以绑定一个微信账号</text>
  61. <text class="section-content">(4)账号进行提现:需要确认您填写的微信账号信息是真实有效的否则有可能会导致您提现失败</text>
  62. <text class="section-content">(5)提现条件:您应满足瀚海回收提现的前置条件并根据提现页面提示的流</text>
  63. </view> -->
  64. <uv-parse :content="withdrawal_instructions"></uv-parse>
  65. </scroll-view>
  66. <view class="popup-footer">
  67. <text class="confirm-btn" @tap="closeNotice">知道了</text>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 底部按钮 -->
  72. <view class="footer-btn-area">
  73. <button :class="['main-btn', fromPromotion ? 'promotion' : '', loading ? 'loading' : '']"
  74. :disabled="loading"
  75. @tap="submitWithdraw">
  76. {{ loading ? '提现中...' : '提现' }}
  77. </button>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import pullRefreshMixin from '@/pages/mixins/pullRefreshMixin.js'
  83. import navbar from '@/compoent/base/navbar.vue'
  84. import api from '@/api/api.js'
  85. import config from '@/config.js'
  86. export default {
  87. mixins: [pullRefreshMixin],
  88. components: {
  89. navbar
  90. },
  91. data() {
  92. return {
  93. realName: '',
  94. amount: '',
  95. showNoticePopup: false,
  96. fromPromotion: false,
  97. bannerList: [],
  98. loading: false
  99. }
  100. },
  101. onLoad(options) {
  102. if (options && options.fromPromotion === 'true') {
  103. this.fromPromotion = true
  104. }
  105. this.bannerList = getApp().globalData.bannerList || []
  106. },
  107. computed: {
  108. withdrawal_instructions() {
  109. const item = getApp().globalData.configData.find(i => i.keyName === 'withdrawal_instructions')
  110. return item ? item.keyContent : ''
  111. },
  112. },
  113. methods: {
  114. async onRefresh() {
  115. // 模拟刷新数据
  116. await new Promise(resolve => setTimeout(resolve, 1000))
  117. uni.stopPullRefresh()
  118. },
  119. goBack() {
  120. uni.navigateBack()
  121. },
  122. showNotice() {
  123. this.showNoticePopup = true
  124. },
  125. closeNotice() {
  126. this.showNoticePopup = false
  127. },
  128. async submitWithdraw() {
  129. // 表单验证
  130. if (!this.realName) {
  131. uni.showToast({ title: '请输入真实姓名', icon: 'none' })
  132. return
  133. }
  134. if (!this.amount) {
  135. uni.showToast({ title: '请输入提现金额', icon: 'none' })
  136. return
  137. }
  138. // 验证金额格式
  139. const amountNum = parseFloat(this.amount)
  140. if (isNaN(amountNum) || amountNum <= 0) {
  141. uni.showToast({ title: '请输入有效的提现金额', icon: 'none' })
  142. return
  143. }
  144. // 验证最小提现金额
  145. if (amountNum < 1) {
  146. uni.showToast({ title: '单笔提现不能低于1元', icon: 'none' })
  147. return
  148. }
  149. // 验证最大提现金额
  150. if (amountNum > 50000) {
  151. uni.showToast({ title: '单笔提现不能超过5万元', icon: 'none' })
  152. return
  153. }
  154. if (this.loading) {
  155. return
  156. }
  157. this.loading = true
  158. try {
  159. // 调用提现接口
  160. const withdrawData = {
  161. userName: this.realName,
  162. money: amountNum
  163. }
  164. const result = await api('withdraw', withdrawData, '提现申请中...')
  165. if (result.code === 200) {
  166. // 提现申请成功,调用微信商户转账
  167. await this.requestWechatTransfer(result.result)
  168. } else {
  169. uni.showToast({
  170. title: result.message || '提现申请失败',
  171. icon: 'none'
  172. })
  173. }
  174. } catch (error) {
  175. console.error('提现失败:', error)
  176. uni.showToast({
  177. title: error.message || '提现申请失败',
  178. icon: 'none'
  179. })
  180. } finally {
  181. this.loading = false
  182. }
  183. },
  184. // 微信商户转账
  185. async requestWechatTransfer(withdrawData) {
  186. try {
  187. let payData = withdrawData.response
  188. // 调用微信商户转账API
  189. const transferResult = await new Promise((resolve, reject) => {
  190. // 拉起微信收款确认页面
  191. if (!wx.canIUse('requestMerchantTransfer')) {
  192. wx.showModal({
  193. content: '你的微信版本过低,请更新至最新版本。',
  194. showCancel: false,
  195. });
  196. return
  197. }
  198. // 在真机环境中,调用API
  199. wx.requestMerchantTransfer({
  200. mchId: config.mchId,
  201. appId: wx.getAccountInfoSync().miniProgram.appId,
  202. package: payData.packageInfo,
  203. success: (res) => {
  204. resolve(res)
  205. },
  206. fail: (res) => {
  207. reject(res)
  208. },
  209. complete: (res) => {
  210. }
  211. });
  212. })
  213. // 转账成功后调用成功接口
  214. await api('withdrawSUccess', { id: withdrawData.id }, '确认提现中...')
  215. this.realName = ''
  216. this.amount = ''
  217. } catch (error) {
  218. throw error
  219. }
  220. },
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. .withdraw-container {
  226. min-height: 100vh;
  227. background: #f8f8f8;
  228. padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
  229. }
  230. .main-card {
  231. background: #fff;
  232. border-radius: 32rpx;
  233. box-shadow: 0 8rpx 32rpx rgba(60, 167, 250, 0.06);
  234. padding: 48rpx 36rpx 32rpx 36rpx;
  235. position: relative;
  236. }
  237. .section-title {
  238. font-size: 34rpx;
  239. font-weight: bold;
  240. color: #222;
  241. margin-bottom: 40rpx;
  242. }
  243. .form-group {
  244. margin-bottom: 0;
  245. }
  246. .form-label {
  247. font-size: 28rpx;
  248. color: #222;
  249. font-weight: 500;
  250. margin-bottom: 16rpx;
  251. }
  252. .form-input {
  253. width: 100%;
  254. font-size: 28rpx;
  255. color: #222;
  256. background: none;
  257. border: none;
  258. outline: none;
  259. padding: 16rpx 0 22rpx 0;
  260. }
  261. .input-placeholder {
  262. color: #ccc;
  263. font-size: 28rpx;
  264. }
  265. .divider {
  266. border-bottom: 1rpx solid #eee;
  267. margin: 0 0 24rpx 0;
  268. }
  269. .desc-area {
  270. margin: 36rpx 40rpx 0 40rpx;
  271. font-size: 24rpx;
  272. color: #bbb;
  273. line-height: 1.7;
  274. text-align: left;
  275. }
  276. .desc-link {
  277. color: #FFA800;
  278. margin-left: 4rpx;
  279. white-space: nowrap;
  280. }
  281. .footer-btn-area {
  282. position: fixed;
  283. left: 0;
  284. right: 0;
  285. bottom: 0;
  286. z-index: 10;
  287. background: #fff;
  288. padding: 24rpx 0 env(safe-area-inset-bottom);
  289. display: flex;
  290. justify-content: center;
  291. }
  292. .main-btn {
  293. width: 92%;
  294. height: 100rpx;
  295. background: linear-gradient(90deg, #FFD36D 0%, #FFA800 100%);
  296. color: #fff;
  297. font-size: 36rpx;
  298. border-radius: 50rpx;
  299. font-weight: bold;
  300. margin: 0 auto;
  301. display: flex;
  302. align-items: center;
  303. justify-content: center;
  304. box-shadow: 0 4rpx 16rpx rgba(255, 168, 0, 0.08);
  305. border: none;
  306. }
  307. .main-btn.promotion {
  308. background: linear-gradient(90deg, #c2fdab 0%, #08eae0 100%);
  309. color: #222;
  310. }
  311. .main-btn.loading {
  312. opacity: 0.7;
  313. pointer-events: none;
  314. }
  315. .main-btn:disabled {
  316. opacity: 0.7;
  317. pointer-events: none;
  318. }
  319. .notice-popup {
  320. position: fixed;
  321. left: 0;
  322. right: 0;
  323. top: 0;
  324. bottom: 0;
  325. z-index: 2000;
  326. display: flex;
  327. align-items: center;
  328. justify-content: center;
  329. }
  330. .popup-mask {
  331. position: absolute;
  332. left: 0;
  333. right: 0;
  334. top: 0;
  335. bottom: 0;
  336. background: rgba(0, 0, 0, 0.55);
  337. }
  338. .popup-content {
  339. position: relative;
  340. width: 86vw;
  341. max-width: 650rpx;
  342. background: #fff;
  343. border-radius: 40rpx;
  344. overflow: hidden;
  345. box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.10);
  346. display: flex;
  347. flex-direction: column;
  348. align-items: center;
  349. }
  350. .popup-title {
  351. text-align: center;
  352. font-size: 38rpx;
  353. font-weight: bold;
  354. color: #222;
  355. margin: 48rpx 0 32rpx 0;
  356. }
  357. .popup-body {
  358. max-height: 600rpx;
  359. padding: 0 40rpx 0 40rpx !important;
  360. font-size: 28rpx;
  361. color: #888;
  362. line-height: 1.9;
  363. margin-bottom: 24rpx;
  364. box-sizing: border-box;
  365. width: 100%;
  366. }
  367. .section-title {
  368. font-size: 28rpx;
  369. color: #888;
  370. font-weight: bold;
  371. margin-top: 0;
  372. margin-bottom: 0;
  373. display: block;
  374. }
  375. .section-content {
  376. font-size: 28rpx;
  377. color: #888;
  378. margin-bottom: 8rpx;
  379. display: block;
  380. word-break: break-all;
  381. }
  382. .popup-footer {
  383. border-top: 1rpx solid #f2f2f2;
  384. width: 100%;
  385. padding: 24rpx 0 32rpx 0;
  386. display: flex;
  387. justify-content: center;
  388. }
  389. .confirm-btn {
  390. color: #FFA800;
  391. font-size: 34rpx;
  392. font-weight: bold;
  393. text-align: center;
  394. }
  395. </style>