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

439 lines
13 KiB

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