success.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="content">
  3. <view class="inner y-bc">
  4. <view class="box-img y-bc">
  5. <image src="@/static/images/wallet/withdrawal_successful.png"></image>
  6. <view class="title">{{statusTitle}}</view>
  7. <text class="desc">{{statusDesc}}</text>
  8. </view>
  9. <view class="btn-box">
  10. <view class="btn" @click="navTo">提现记录</view>
  11. <view class="btn back" v-if="canConfirmReceipt" @click="confirmReceipt">确认收款</view>
  12. <view class="btn back" v-if="canWithdrawAgain" @click="withdrawAgain">再次提现</view>
  13. <view class="btn back" v-if="!canWithdrawAgain && !canConfirmReceipt" @click="goBack()">返回</view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import {getRedPacketLogByCode} from '@/api/integral.js'
  20. export default {
  21. data() {
  22. return {
  23. order:null,
  24. orderCode: null,
  25. wxMerchantTransfer:null,
  26. }
  27. },
  28. computed: {
  29. // 根据订单状态显示标题
  30. statusTitle() {
  31. if (!this.order || this.order.status === undefined) {
  32. return '提现申请成功';
  33. }
  34. const status = Number(this.order.status);
  35. //console.log("提现状态",this.order.status,status)
  36. // -3取消中 -2取消 -1失败 0发送中 1已发送 2取消 3转账处理中 4待收款用户确认 5转账结果尚未明确
  37. if (status === -3) {
  38. return '取消中';
  39. } else if (status === -2 || status === 2) {
  40. return '已取消';
  41. } else if (status === -1) {
  42. return '提现失败';
  43. } else if (status === 0) {
  44. return '发送中';
  45. } else if (status === 1) {
  46. return '提现申请成功';
  47. } else if (status === 3) {
  48. return '转账处理中';
  49. } else if (status === 4) {
  50. return '待确认收款';
  51. } else if (status === 5) {
  52. return '待确认收款';
  53. } else {
  54. return '提现申请成功';
  55. }
  56. },
  57. // 根据订单状态显示描述
  58. statusDesc() {
  59. if (!this.order || this.order.status === undefined) {
  60. return '预计两小时到账';
  61. }
  62. const status = Number(this.order.status);
  63. if (status === -3) {
  64. return this.order.remark || '提现正在取消中';
  65. } else if (status === -2 || status === 2) {
  66. return this.order.remark || '提现已取消';
  67. } else if (status === -1) {
  68. return this.order.remark || '提现失败,请重试';
  69. } else if (status === 0) {
  70. return this.order.remark || '提现请求已发送,正在处理中';
  71. } else if (status === 1) {
  72. return this.order.remark || '预计两小时到账';
  73. } else if (status === 3) {
  74. return this.order.remark || '转账正在处理中,请稍候';
  75. } else if (status === 4) {
  76. return '待收款确认,请在24小时内确认收款';
  77. } else if (status === 5) {
  78. return '转账结果尚未明确,请在24小时内确认收款';
  79. } else {
  80. return '预计两小时到账';
  81. }
  82. },
  83. // 是否可以再次提现(失败、取消等状态可以再次提现)
  84. canWithdrawAgain() {
  85. if (!this.order || this.order.status === undefined) {
  86. return false;
  87. }
  88. const status = Number(this.order.status);
  89. // 失败(-1)、取消(-2,2)状态可以再次提现
  90. return status === -1 || status === -2 || status === 2;
  91. },
  92. // 是否可以确认收款(状态4和5可以拉起微信收款确认页面)
  93. canConfirmReceipt() {
  94. if (!this.order || this.order.status === undefined) {
  95. return false;
  96. }
  97. const status = Number(this.order.status);
  98. // 状态4和5可以确认收款
  99. return status === 4 || status === 5;
  100. }
  101. },
  102. onLoad(option) {
  103. // 兼容旧的order参数
  104. if (option.order) {
  105. try {
  106. this.order = JSON.parse(option.order);
  107. } catch (e) {
  108. console.error('解析order参数失败:', e);
  109. }
  110. }
  111. // 获取orderCode参数
  112. if (option.orderCode) {
  113. this.orderCode = option.orderCode;
  114. // 确认收款后查询订单状态
  115. this.getRedPacketLogByCode(option.orderCode);
  116. }
  117. this.wxMerchantTransfer = uni.requireNativePlugin('wxMerchantTransfer');
  118. },
  119. onShow() {
  120. // 如果页面显示时已有orderCode,再次查询订单状态(用户从微信返回时)
  121. if (this.orderCode) {
  122. this.getRedPacketLogByCode(this.orderCode);
  123. }
  124. },
  125. methods: {
  126. // 查询订单状态
  127. getRedPacketLogByCode(code) {
  128. if (!code) return;
  129. getRedPacketLogByCode({ orderCode: code }).then(res => {
  130. if (res.code == 200) {
  131. //console.log("订单状态查询结果:", res);
  132. // 可以根据订单状态更新UI或进行其他操作
  133. if (res.data) {
  134. this.order = res.data;
  135. }
  136. } else {
  137. console.warn("查询订单状态失败:", res.msg);
  138. }
  139. }, err => {
  140. console.error("查询订单状态错误:", err);
  141. });
  142. },
  143. goBack() {
  144. uni.navigateBack()
  145. },
  146. navTo(){
  147. uni.navigateTo({
  148. url:'/pages/user/wallet/recordList'
  149. })
  150. },
  151. copyOrderSn(text) {
  152. // 复制方法
  153. uni.setClipboardData({
  154. data:text,
  155. success:()=>{
  156. uni.showToast({
  157. title:'内容已成功复制到剪切板',
  158. icon:'none'
  159. })
  160. }
  161. });
  162. },
  163. goOrderDetails(id){
  164. uni.redirectTo({
  165. url: "/pages_user/user/storeOrderDetail?id="+id
  166. })
  167. },
  168. // 再次提现
  169. withdrawAgain() {
  170. uni.navigateBack();
  171. },
  172. // 确认收款(拉起微信收款确认页面)
  173. confirmReceipt() {
  174. if (!this.order) {
  175. uni.showToast({
  176. title: '订单信息不完整',
  177. icon: 'none'
  178. });
  179. return;
  180. }
  181. const appId = this.order.appId;
  182. const mchId = this.order.mchId;
  183. const packageValue = this.order.packageInfo;
  184. if (!appId || !mchId || !packageValue) {
  185. uni.showToast({
  186. title: '缺少必要参数,无法确认收款',
  187. icon: 'none'
  188. });
  189. return;
  190. }
  191. // #ifdef APP-PLUS
  192. const params = {
  193. appId: String(appId),
  194. mchId: String(mchId),
  195. package: String(packageValue)
  196. };
  197. console.log('拉起微信收款确认页面,参数:', params);
  198. this.wxMerchantTransfer.open(params, (res) => {
  199. console.log('确认收款回调结果:', res);
  200. if (res.code === 0) {
  201. // 确认收款成功,重新查询订单状态
  202. if (this.orderCode) {
  203. setTimeout(() => {
  204. this.getRedPacketLogByCode(this.orderCode);
  205. }, 1000);
  206. }
  207. } else if (res.code === -3) {
  208. const resultMessage = (res.message || '').toLowerCase();
  209. if (resultMessage.includes('not installed') || resultMessage.includes('未安装')) {
  210. uni.showModal({
  211. title: '提示',
  212. content: '请先安装微信客户端',
  213. showCancel: false
  214. });
  215. } else {
  216. uni.showModal({
  217. title: '提示',
  218. content: res.message || '当前微信版本不支持,请升级后重试',
  219. showCancel: false
  220. });
  221. }
  222. } else {
  223. uni.showModal({
  224. title: '确认收款失败',
  225. content: res.message || '请稍后重试',
  226. showCancel: false
  227. });
  228. }
  229. });
  230. // #endif
  231. // #ifndef APP-PLUS
  232. uni.showToast({
  233. icon: 'none',
  234. title: '此功能仅在 APP 中可用',
  235. });
  236. // #endif
  237. }
  238. }
  239. }
  240. </script>
  241. <style lang="scss">
  242. page{
  243. height: 100%;
  244. background-color: #FFFFFF;
  245. }
  246. .content{
  247. height: 100%;
  248. display: flex;
  249. flex-direction: column;
  250. justify-content:flex-start;
  251. .inner{
  252. padding:24rpx;
  253. image{
  254. width: 224rpx;
  255. height: 160rpx;
  256. }
  257. .box-img{
  258. margin-top: 160rpx;
  259. .title{
  260. font-family: PingFang SC, PingFang SC;
  261. font-weight: 500;
  262. font-size: 48rpx;
  263. color: #222222;
  264. margin-top: 64rpx;
  265. margin-bottom: 10rpx;
  266. }
  267. .desc{
  268. font-family: PingFang SC, PingFang SC;
  269. font-weight: 500;
  270. font-size: 28rpx;
  271. color: #757575;
  272. }
  273. }
  274. }
  275. .btn-box{
  276. margin-top:60rpx;
  277. box-sizing: border-box;
  278. display: flex;
  279. align-items: center;
  280. justify-content: center;
  281. flex-wrap: wrap;
  282. gap: 24rpx;
  283. .btn{
  284. min-width: 254rpx;
  285. height: 88rpx;
  286. padding: 0 32rpx;
  287. border-radius: 44rpx 44rpx 44rpx 44rpx;
  288. border: 2rpx solid #FF5C03;
  289. display: flex;
  290. align-items: center;
  291. justify-content: center;
  292. font-family: PingFang SC, PingFang SC;
  293. font-weight: 400;
  294. font-size: 32rpx;
  295. color: #FF5C03;
  296. &.back{
  297. background: #FF5C03;
  298. color: #fff;
  299. }
  300. }
  301. }
  302. }
  303. </style>