reward.vue 4.6 KB

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