success.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="content">
  3. <text class="success-icon yticon icon-xuanzhong2"></text>
  4. <text class="tit">支付成功</text>
  5. <!-- #ifdef MP -->
  6. <view class="subscribe-box" style="padding-top: 50px;">
  7. <view class="subscribe-title" style="float: left">获取实时发货信息与订单状态</view>
  8. <view class="subscribe-start" style="float: left;padding-left: 10px;color: red" @tap="subscribeMessage">立即订阅</view>
  9. </view>
  10. <!-- #endif -->
  11. <view class="btn-group">
  12. <navigator url="/pages/order/list?state=0" open-type="redirect" class="mix-btn">查看订单</navigator>
  13. <navigator url="/pages/index/index" open-type="switchTab" class="mix-btn hollow">返回首页</navigator>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import { WxaSubscribeTemplate } from '@/util/const';
  19. import { subscribeMessage,getSubscribeTemplate } from '@/util/miniProgram';
  20. export default {
  21. data() {
  22. return {
  23. SUBSCRIBE_BTN_STATUS_STORAGE_KEY: 'subscribeBtnStatus' // 存储键
  24. }
  25. },
  26. methods: {
  27. subscribeMessage() {
  28. const that = this;
  29. that.$api.request('get', 'social/app/get-subscribe-template-list', {}, failres => {
  30. that.$api.msg(failres.msg);
  31. }).then(res => {
  32. getSubscribeTemplate(res.data); // 确保传递了数据
  33. const event = [WxaSubscribeTemplate.ORDER_SUCCESSFUL,WxaSubscribeTemplate.ORDER_FULFILLMENT];
  34. subscribeMessage(event, () => {
  35. // 订阅后记录一下订阅状态
  36. uni.removeStorageSync(this.SUBSCRIBE_BTN_STATUS_STORAGE_KEY);
  37. uni.setStorageSync(this.SUBSCRIBE_BTN_STATUS_STORAGE_KEY, '已订阅');
  38. // 隐藏订阅按钮
  39. this.showSubscribeBtn = false;
  40. });
  41. });
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang='scss'>
  47. .content{
  48. display: flex;
  49. flex-direction: column;
  50. justify-content: center;
  51. align-items: center;
  52. }
  53. .success-icon{
  54. font-size: 160upx;
  55. color: #2AAC34;
  56. margin-top: 100upx;
  57. }
  58. .tit{
  59. font-size: 38upx;
  60. color: #303133;
  61. }
  62. .btn-group{
  63. padding-top: 100upx;
  64. }
  65. .mix-btn {
  66. margin-top: 30upx;
  67. display: flex;
  68. align-items: center;
  69. justify-content: center;
  70. width: 600upx;
  71. height: 80upx;
  72. font-size: $font-lg;
  73. color: #fff;
  74. background-color: #2AAC34;
  75. border-radius: 10upx;
  76. &.hollow{
  77. background: #fff;
  78. color: #303133;
  79. border: 1px solid #ccc;
  80. }
  81. }
  82. .subscribe-box {
  83. .subscribe-img {
  84. width: 44rpx;
  85. height: 44rpx;
  86. }
  87. .subscribe-title {
  88. font-weight: 500;
  89. font-size: 32rpx;
  90. line-height: 36rpx;
  91. color: #434343;
  92. }
  93. .subscribe-start {
  94. color: var(--ui-BG-Main);
  95. font-weight: 700;
  96. font-size: 32rpx;
  97. line-height: 36rpx;
  98. }
  99. }
  100. </style>