reward.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="answerPopup-box bg">
  3. <view class="header-nav" :style="{height: `calc(88rpx + ${statusBarHeight}px)`,paddingTop: statusBarHeight + 'px'}">
  4. <view class="arrow-left" :style="{top: statusBarHeight + 'px'}" @click="goBack">
  5. <image src="/static/images/icon_back_b.png" mode="aspectFill"></image>返回
  6. </view>
  7. </view>
  8. <!-- 正确 -->
  9. <image class="tipimg" src="/static/images/course_answer_img.png"
  10. mode="aspectFill"></image>
  11. <view class="answerPopup-title">恭喜你,回答正确</view>
  12. <view class="answerPopup-desc">您有一份奖励待领取哦</view>
  13. <view class="answerPopup-btn" @click="handleReceive">领取</view>
  14. <view class="footer-tips">重庆云联融智提供技术支持</view>
  15. </view>
  16. </template>
  17. <script>
  18. // import wx from 'jweixin-module';
  19. // import { initJssdk } from "@/utils/common.js"
  20. export default {
  21. data() {
  22. return {
  23. mchId:'',
  24. packageInfo: '',
  25. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  26. menuButtonH: 45,
  27. }
  28. },
  29. onLoad() {
  30. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  31. this.menuButtonH = menuButtonInfo.height
  32. },
  33. methods: {
  34. goBack() {
  35. uni.navigateBack();
  36. },
  37. handleReceive() {
  38. this.packageInfo = uni.getStorageSync('receive_package') || ''
  39. this.mchId = uni.getStorageSync('mchId') || ''
  40. this.handleTest()
  41. },
  42. handleTest() {
  43. const that = this
  44. if (wx.canIUse('requestMerchantTransfer')) {
  45. wx.requestMerchantTransfer({
  46. mchId:that.mchId,
  47. appId:wx.getAccountInfoSync().miniProgram.appId,
  48. package:that.packageInfo,
  49. success: (res) => {
  50. },
  51. fail: (res) => {
  52. },
  53. });
  54. } else {
  55. wx.showModal({
  56. content: '你的微信版本过低,请更新至最新版本。',
  57. showCancel: false,
  58. });
  59. }
  60. // wx.ready(() => {
  61. // // config信息验证后会执行ready方法,所有接口调用都必须在config之后
  62. // wx.checkJsApi({
  63. // jsApiList: ['requestMerchantTransfer'],
  64. // success: function(res) {
  65. // if (res.checkResult['requestMerchantTransfer']) {
  66. // WeixinJSBridge.invoke('requestMerchantTransfer', {
  67. // mchId: mchId || that.mchId,
  68. // appId: appId,
  69. // package: packageVal,
  70. // },
  71. // function(res) {
  72. // if (res.err_msg === 'requestMerchantTransfer:ok') {
  73. // // res.err_msg将在页面展示成功后返回应用时返回success,并不代表付款成功
  74. // }
  75. // }
  76. // );
  77. // } else {
  78. // alert('你的微信版本过低,请更新至最新版本。');
  79. // }
  80. // }
  81. // });
  82. // });
  83. // wx.error(function(res){
  84. // // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  85. // });
  86. },
  87. initWXConfig(packageVal) {
  88. const isWechat = String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
  89. if(isWechat) {
  90. let url = window.location.href.split('#')[0]
  91. initJssdk((data)=>{
  92. this.handleTest(packageVal,data.appId,data.mchId)
  93. },url)
  94. } else {
  95. uni.showToast({
  96. title: '请在微信浏览器中打开'
  97. })
  98. }
  99. }
  100. },
  101. onUnload() {
  102. uni.removeStorageSync('receive_package')
  103. uni.removeStorageSync('mchId')
  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. .header-nav {
  115. height: 88rpx;
  116. display: flex;
  117. align-items: center;
  118. justify-content: center;
  119. overflow: hidden;
  120. box-sizing: border-box;
  121. width: 100%;
  122. position: fixed;
  123. top: 0;
  124. left: 0;
  125. }
  126. .arrow-left {
  127. position: absolute;
  128. left: 24rpx;
  129. height: 88rpx;
  130. display: flex;
  131. align-items: center;
  132. justify-content: flex-start;
  133. overflow: hidden;
  134. image {
  135. height: 28px;
  136. width: 28px;
  137. }
  138. }
  139. .footer-tips {
  140. width: 100%;
  141. position: absolute;
  142. left: 0;
  143. bottom: 14rpx;
  144. text-align: center;
  145. font-family: PingFang SC,PingFang SC;
  146. font-weight: 500;
  147. font-size: 12px;
  148. color: #bbb;
  149. }
  150. .answerPopup {
  151. &-box {
  152. width: 100%;
  153. height: 100vh;
  154. background: linear-gradient(180deg, #FFFAF6 50%, #FEECD8 100%);
  155. background-color: #fff;
  156. font-weight: 400;
  157. box-sizing: border-box;
  158. position: relative;
  159. @include u-flex(column, center, center);
  160. font-family: PingFang SC, PingFang SC;
  161. font-weight: 400;
  162. .tipimg {
  163. width: 206rpx;
  164. height: 206rpx;
  165. margin-bottom: 16rpx;
  166. }
  167. }
  168. &-title {
  169. font-weight: 600;
  170. font-size: 36rpx;
  171. color: #222222;
  172. }
  173. &-desc {
  174. margin-top: 30rpx;
  175. font-size: 28rpx;
  176. color: #757575;
  177. }
  178. &-btn {
  179. width: 464rpx;
  180. height: 84rpx;
  181. margin-top: 10vh;
  182. margin-bottom: 16vh;
  183. background: #FF5C03;
  184. border-radius: 42rpx;
  185. font-weight: 500;
  186. font-size: 32rpx;
  187. color: #FFFFFF;
  188. text-align: center;
  189. line-height: 84rpx;
  190. }
  191. }
  192. </style>