reward.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="answerPopup-box bg">
  3. <!-- 正确 -->
  4. <image class="tipimg" src="/static/images/course_answer_img.png"
  5. mode="aspectFill"></image>
  6. <view class="answerPopup-title">恭喜你,回答正确</view>
  7. <view class="answerPopup-desc">您有一份奖励待领取哦</view>
  8. <view class="answerPopup-btn" @click="handleReceive">领取</view>
  9. <view class="footer-tips">重庆云联融智提供技术支持</view>
  10. </view>
  11. </template>
  12. <script>
  13. import wx from 'jweixin-module';
  14. import { initJssdk } from "@/utils/common.js"
  15. export default {
  16. data() {
  17. return {
  18. mchId:'',
  19. packageInfo: ''
  20. }
  21. },
  22. methods: {
  23. handleReceive() {
  24. this.packageInfo = uni.getStorageSync('receive_package') || ''
  25. this.mchId = uni.getStorageSync('mchId') || ''
  26. this.initWXConfig(this.packageInfo)
  27. },
  28. handleTest(packageVal,appId,mchId) {
  29. const that = this
  30. wx.ready(() => {
  31. // config信息验证后会执行ready方法,所有接口调用都必须在config之后
  32. wx.checkJsApi({
  33. jsApiList: ['requestMerchantTransfer'],
  34. success: function(res) {
  35. if (res.checkResult['requestMerchantTransfer']) {
  36. WeixinJSBridge.invoke('requestMerchantTransfer', {
  37. mchId: mchId || that.mchId,
  38. appId: appId,
  39. package: packageVal,
  40. },
  41. function(res) {
  42. if (res.err_msg === 'requestMerchantTransfer:ok') {
  43. // res.err_msg将在页面展示成功后返回应用时返回success,并不代表付款成功
  44. }
  45. }
  46. );
  47. } else {
  48. alert('你的微信版本过低,请更新至最新版本。');
  49. }
  50. }
  51. });
  52. });
  53. wx.error(function(res){
  54. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  55. });
  56. },
  57. initWXConfig(packageVal) {
  58. const isWechat = String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
  59. if(isWechat) {
  60. let url = window.location.href.split('#')[0]
  61. initJssdk((data)=>{
  62. this.handleTest(packageVal,data.appId,data.mchId)
  63. },url)
  64. } else {
  65. uni.showToast({
  66. title: '请在微信浏览器中打开'
  67. })
  68. }
  69. }
  70. }
  71. }
  72. </script>
  73. <style scoped lang="scss">
  74. @mixin u-flex($flexD, $alignI, $justifyC) {
  75. display: flex;
  76. flex-direction: $flexD;
  77. align-items: $alignI;
  78. justify-content: $justifyC;
  79. }
  80. .footer-tips {
  81. width: 100%;
  82. position: absolute;
  83. left: 0;
  84. bottom: 14rpx;
  85. text-align: center;
  86. font-family: PingFang SC,PingFang SC;
  87. font-weight: 500;
  88. font-size: 12px;
  89. color: #bbb;
  90. }
  91. .answerPopup {
  92. &-box {
  93. width: 100%;
  94. height: 100vh;
  95. background: linear-gradient(180deg, #FFFAF6 50%, #FEECD8 100%);
  96. background-color: #fff;
  97. font-weight: 400;
  98. box-sizing: border-box;
  99. position: relative;
  100. @include u-flex(column, center, center);
  101. font-family: PingFang SC, PingFang SC;
  102. font-weight: 400;
  103. .tipimg {
  104. width: 206rpx;
  105. height: 206rpx;
  106. margin-bottom: 16rpx;
  107. }
  108. }
  109. &-title {
  110. font-weight: 600;
  111. font-size: 36rpx;
  112. color: #222222;
  113. }
  114. &-desc {
  115. margin-top: 30rpx;
  116. font-size: 28rpx;
  117. color: #757575;
  118. }
  119. &-btn {
  120. width: 464rpx;
  121. height: 84rpx;
  122. margin-top: 10vh;
  123. margin-bottom: 16vh;
  124. background: #FF5C03;
  125. border-radius: 42rpx;
  126. font-weight: 500;
  127. font-size: 32rpx;
  128. color: #FFFFFF;
  129. text-align: center;
  130. line-height: 84rpx;
  131. }
  132. }
  133. </style>