refund_success.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. const util = require('../../utils/utils.js')
  2. let videoAd = null;
  3. var app = getApp();
  4. Page({
  5. data: {
  6. },
  7. onLoad: function (options) {
  8. if (wx.createRewardedVideoAd) {
  9. videoAd = wx.createRewardedVideoAd({
  10. adUnitId: 'adunit-edc5c4664389a87a'
  11. })
  12. videoAd.onLoad(() => {})
  13. videoAd.onError((err) => {})
  14. videoAd.onClose((res) => {
  15. if (res && res.isEnded || res === undefined) {
  16. app.request('/deposit/refund', '', 'POST').then(res => {
  17. console.log(res);
  18. if (res.statusCode == 200) {
  19. wx.showToast({
  20. title: '加速成功,稍后到账',
  21. icon:'none'
  22. })
  23. }
  24. })
  25. } else {
  26. wx.showToast({
  27. title: '加速失败!',
  28. icon:'none'
  29. })
  30. }
  31. })
  32. }
  33. },
  34. home: util.throttle(function (e) {
  35. if(app.globalData.compatible){
  36. wx.reLaunch({
  37. url: '/pages/compatible/index/index',
  38. })
  39. }else{
  40. wx.reLaunch({
  41. url: '/pages/index/index',
  42. })
  43. }
  44. },1000),
  45. ad(){
  46. if (videoAd) {
  47. videoAd.show().catch(() => {
  48. // 失败重试
  49. videoAd.load()
  50. .then(() => videoAd.show())
  51. .catch(err => {
  52. console.log('激励视频 广告显示失败')
  53. })
  54. })
  55. }
  56. },
  57. onReady: function () {
  58. },
  59. onShow: function () {
  60. },
  61. onHide: function () {
  62. },
  63. onUnload: function () {
  64. },
  65. onPullDownRefresh: function () {
  66. },
  67. onReachBottom: function () {
  68. },
  69. onShareAppMessage: function () {
  70. }
  71. })