bind.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="bind">
  3. <view class="bind-content">
  4. <view v-if="show_btn == 1" class="btn-list">
  5. <view @click="_getGift" class="btn">领取玩具</view>
  6. </view>
  7. <view v-if="show_btn == 2" class="btn-list">
  8. <view class="disabled">{{ error_msg }}</view>
  9. </view>
  10. <view class="tip">
  11. <view>领取规则:</view>
  12. <view style="margin-top: 10rpx">下单添加客服免费领取玩具,随刊赠送</view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. show_btn: 0,
  22. kailin_uid: null,
  23. work_userid: null,
  24. };
  25. },
  26. onLoad(param) {
  27. if (!this.$checkAccess.alterLogin()) {
  28. return;
  29. }
  30. this.kailin_uid = param.kailin_uid;
  31. this.work_userid = param.work_userid;
  32. if (param.kailin_uid && param.work_userid) {
  33. this.$http.request("api/work_bind/user", { work_userid: param.work_userid, kailin_uid: param.kailin_uid }).then((re) => {
  34. // 成功渲染数据
  35. console.log("api/work_bind/user", re);
  36. if (re.code == "success") {
  37. this.show_btn = 1;
  38. } else {
  39. this.show_btn = 2;
  40. this.error_msg = re.data.error || "登记失败,请联系客服";
  41. }
  42. });
  43. }
  44. },
  45. methods: {
  46. _getGift() {
  47. this.$http.request("api/orders_receive/receive").then((re) => {
  48. // 成功渲染数据
  49. console.log("api/work_bind/get_gift", re);
  50. if (re.code == "success") {
  51. console.log("领取成功");
  52. uni.showModal({
  53. content: "您已成功领取",
  54. showCancel: false,
  55. confirmText: "查看订单",
  56. success: () => {
  57. uni.redirectTo({
  58. url: "/pages/orders/index",
  59. });
  60. },
  61. });
  62. } else {
  63. console.log("领取失败");
  64. this.show_btn = 2;
  65. this.error_msg = re.msg;
  66. uni.showModal({
  67. content: re.msg,
  68. showCancel: false,
  69. confirmText: "回到首页",
  70. success: () => {
  71. uni.switchTab({
  72. url: "/pages/index/index",
  73. });
  74. },
  75. });
  76. }
  77. });
  78. },
  79. },
  80. };
  81. </script>
  82. <style lang="less" scoped>
  83. .bind {
  84. width: 100vw;
  85. height: 100vh;
  86. position: relative;
  87. background-image: url("https://baokan-mp.oss-cn-shenzhen.aliyuncs.com/static/wanju_bgimg.png");
  88. background-size: 100% 100%;
  89. background-repeat: no-repeat;
  90. box-sizing: border-box;
  91. .bind-content {
  92. position: absolute;
  93. bottom: 50rpx;
  94. .btn-list {
  95. display: flex;
  96. flex-direction: column;
  97. gap: 30rpx;
  98. align-items: center;
  99. .btn {
  100. width: 300rpx;
  101. height: 80rpx;
  102. display: flex;
  103. justify-content: center;
  104. align-items: center;
  105. box-sizing: border-box;
  106. background-color: #f46f2a;
  107. border-radius: 60rpx;
  108. color: #fff;
  109. font-weight: bold;
  110. font-size: 36rpx;
  111. }
  112. .disabled {
  113. color: #f46f2a;
  114. font-size: 36rpx;
  115. font-weight: bold;
  116. }
  117. }
  118. .tip {
  119. width: 100vw;
  120. box-sizing: border-box;
  121. padding: 0 80rpx;
  122. color: #f46f2a;
  123. margin-top: 40rpx;
  124. font-size: 30rpx;
  125. font-weight: bold;
  126. }
  127. }
  128. }
  129. </style>