reward.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. this.$nextTick(()=>{
  28. this.handleTest()
  29. })
  30. },
  31. handleTest() {
  32. const that = this
  33. console.log(that.mchId)
  34. console.log('wxb9b453d37c5fad45',wx.getAccountInfoSync().miniProgram.appId)
  35. console.log(that.packageInfo)
  36. if (wx.canIUse('requestMerchantTransfer')) {
  37. wx.requestMerchantTransfer({
  38. mchId:that.mchId,
  39. appId:wx.getAccountInfoSync().miniProgram.appId,
  40. package:that.packageInfo,
  41. success: (res) => {
  42. // res.err_msg将在页面展示成功后返回应用时返回ok,并不代表付款成功
  43. console.log('success:', res);
  44. console.log(that.mchId)
  45. console.log('wxb9b453d37c5fad45',wx.getAccountInfoSync().miniProgram.appId)
  46. console.log(that.packageInfo)
  47. },
  48. fail: (res) => {
  49. console.log('fail:', res);
  50. console.log('11111-----')
  51. console.log(that.mchId)
  52. console.log('wxb9b453d37c5fad45',wx.getAccountInfoSync().miniProgram.appId)
  53. console.log(that.packageInfo)
  54. },
  55. });
  56. } else {
  57. wx.showModal({
  58. content: '你的微信版本过低,请更新至最新版本。',
  59. showCancel: false,
  60. });
  61. }
  62. // wx.ready(() => {
  63. // // config信息验证后会执行ready方法,所有接口调用都必须在config之后
  64. // wx.checkJsApi({
  65. // jsApiList: ['requestMerchantTransfer'],
  66. // success: function(res) {
  67. // if (res.checkResult['requestMerchantTransfer']) {
  68. // WeixinJSBridge.invoke('requestMerchantTransfer', {
  69. // mchId: that.mchId,
  70. // appId: appId,
  71. // package: packageVal,
  72. // },
  73. // function(res) {
  74. // if (res.err_msg === 'requestMerchantTransfer:ok') {
  75. // // res.err_msg将在页面展示成功后返回应用时返回success,并不代表付款成功
  76. // }
  77. // }
  78. // );
  79. // } else {
  80. // alert('你的微信版本过低,请更新至最新版本。');
  81. // }
  82. // }
  83. // });
  84. // });
  85. // wx.error(function(res){
  86. // // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  87. // });
  88. },
  89. initWXConfig(packageVal) {
  90. const isWechat = String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
  91. if(isWechat) {
  92. let url = window.location.href.split('#')[0]
  93. initJssdk((data)=>{
  94. this.handleTest(packageVal,data.appId,data.mchId)
  95. },url)
  96. } else {
  97. uni.showToast({
  98. title: '请在微信浏览器中打开'
  99. })
  100. }
  101. }
  102. }
  103. }
  104. </script>
  105. <style scoped lang="scss">
  106. @mixin u-flex($flexD, $alignI, $justifyC) {
  107. display: flex;
  108. flex-direction: $flexD;
  109. align-items: $alignI;
  110. justify-content: $justifyC;
  111. }
  112. .footer-tips {
  113. width: 100%;
  114. position: absolute;
  115. left: 0;
  116. bottom: 14rpx;
  117. text-align: center;
  118. font-family: PingFang SC,PingFang SC;
  119. font-weight: 500;
  120. font-size: 12px;
  121. color: #bbb;
  122. }
  123. .answerPopup {
  124. &-box {
  125. width: 100%;
  126. height: 100vh;
  127. background: linear-gradient(180deg, #FFFAF6 50%, #FEECD8 100%);
  128. background-color: #fff;
  129. font-weight: 400;
  130. box-sizing: border-box;
  131. position: relative;
  132. @include u-flex(column, center, center);
  133. font-family: PingFang SC, PingFang SC;
  134. font-weight: 400;
  135. .tipimg {
  136. width: 206rpx;
  137. height: 206rpx;
  138. margin-bottom: 16rpx;
  139. }
  140. }
  141. &-title {
  142. font-weight: 600;
  143. font-size: 36rpx;
  144. color: #222222;
  145. }
  146. &-desc {
  147. margin-top: 30rpx;
  148. font-size: 28rpx;
  149. color: #757575;
  150. }
  151. &-btn {
  152. width: 464rpx;
  153. height: 84rpx;
  154. margin-top: 10vh;
  155. margin-bottom: 16vh;
  156. background: #FF5C03;
  157. border-radius: 42rpx;
  158. font-weight: 500;
  159. font-size: 32rpx;
  160. color: #FFFFFF;
  161. text-align: center;
  162. line-height: 84rpx;
  163. }
  164. }
  165. </style>