reward.vue 4.4 KB

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