jihuo.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="container">
  3. <!-- <image src="../../static/images/jihuo_bg.png" mode="widthFix" class="bg-img"></image> -->
  4. <view class="input-box flex-y-center">
  5. <input type="text" maxlength="500" v-model="num" placeholder="请输入激活编号" class="input-box-put" />
  6. <image class="saoma" @click="saoma" mode="widthFix" src="../../static/images/saoma.png" ></image>
  7. </view>
  8. <view class="btm-btn" @click="jihuo">立即激活</view>
  9. </view>
  10. </template>
  11. <script>
  12. // #ifdef H5
  13. import getWXSign from "@/static/js/config.js";
  14. // #endif
  15. export default {
  16. data() {
  17. return {
  18. num: ""
  19. }
  20. },
  21. onLoad() {
  22. // this.jcdetail();
  23. },
  24. methods: {
  25. saoma(e) {
  26. // #ifdef MP-WEIXIN
  27. uni.scanCode({
  28. success: (res) => {
  29. console.log('条码类型:' + res.scanType);
  30. console.log('条码内容:' + res.result);
  31. this.num = res.result;
  32. }
  33. });
  34. // #endif
  35. // #ifdef H5
  36. getWXSign().then(res => {
  37. console.log('wx_getLocation');
  38. this.$wx.scanQRCode({
  39. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  40. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  41. success: (res) => {
  42. console.log(res, "qrCode")
  43. this.num = res.resultStr;
  44. }
  45. })
  46. })
  47. // #endif
  48. },
  49. jihuo() {
  50. if (this.num === '') {
  51. uni.showToast({
  52. title: "请输入账号",
  53. icon: "none"
  54. })
  55. return false
  56. }
  57. this.request({
  58. url: "user/bind",
  59. data: {
  60. code: this.num,
  61. token: uni.getStorageSync("token"),
  62. },
  63. }).then(res => {
  64. console.log(res, "res")
  65. if (res.code === '200') {
  66. uni.showToast({
  67. title: "激活成功",
  68. icon: 'none'
  69. })
  70. setTimeout(() => {
  71. uni.navigateBack({
  72. delta: 1
  73. })
  74. }, 2000)
  75. }
  76. }).catch((res) => {
  77. uni.showToast({
  78. title: res.message,
  79. icon: 'none'
  80. })
  81. });
  82. }
  83. }
  84. }
  85. </script>
  86. <style>
  87. page {
  88. background-color: #FDFDFE;
  89. }
  90. .container {
  91. height: calc(100vh - var(--window-top));
  92. position: relative;
  93. }
  94. .bg-img {
  95. display: block;
  96. width: 100%;
  97. height: 317rpx;
  98. }
  99. .input-box-put {
  100. width: 600rpx;
  101. height: 100%;
  102. }
  103. .input-box {
  104. width: 670rpx;
  105. height: 110rpx;
  106. background: #ffffff;
  107. border-radius: 8rpx;
  108. box-shadow: 0 0 14rpx 0 rgba(162, 180, 203, 0.25);
  109. margin: 10rpx auto;
  110. box-sizing: border-box;
  111. padding: 0 40rpx;
  112. font-size: 30rpx;
  113. }
  114. .btm-btn {
  115. width: 670rpx;
  116. height: 98rpx;
  117. background: linear-gradient(315deg, #3387ff 2%, #569bff 99%);
  118. border-radius: 8rpx;
  119. box-shadow: 0px 0px 8rpx 0px rgba(51, 135, 255, 0.2);
  120. font-size: 32rpx;
  121. font-weight: 500;
  122. text-align: center;
  123. color: #fff;
  124. line-height: 98rpx;
  125. position: absolute;
  126. left: 40rpx;
  127. bottom: 120rpx;
  128. }
  129. .saoma {
  130. width: 50rpx;
  131. height: 50rpx;margin-left: 20rpx;
  132. }
  133. </style>