index.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>朗读小咖秀</title>
  7. </head>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. }
  13. #container {
  14. overflow: hidden;
  15. width: 100%;
  16. height: 51.1733rem;
  17. margin-bottom: 1.8667rem;
  18. background: url('http://reader-wx.ai160.com/images/reader/v3/bg.jpg') no-repeat;
  19. background-size: 100% 100%;
  20. }
  21. .commoditys {
  22. display: flex;
  23. align-items: center;
  24. justify-content: space-between;
  25. margin: 5.2267rem auto;
  26. width: 9.0133rem;
  27. height: 3.4667rem;
  28. padding: 0.3733rem 0.2667rem;
  29. box-sizing: border-box;
  30. border-radius: 20px;
  31. }
  32. .commodity {
  33. position: relative;
  34. width: 2.5867rem;
  35. height: 2.5867rem;
  36. border-radius: 6px;
  37. padding: 0.0533rem;
  38. background-clip: content-box !important;
  39. border: 2px solid white;
  40. }
  41. .active {
  42. position: absolute;
  43. width: 0.72rem;
  44. height: 0.48rem;
  45. right: 0;
  46. bottom: 0;
  47. }
  48. .aborder {
  49. border-color: #ff935e;
  50. }
  51. .c-1 {
  52. background: url('http://reader-wx.ai160.com/images/reader/v3/299.png') no-repeat;
  53. background-size: contain;
  54. }
  55. .c-2 {
  56. background: url('http://reader-wx.ai160.com/images/reader/v3/99.png') no-repeat;
  57. background-size: contain;
  58. }
  59. .c-3 {
  60. background: url('http://reader-wx.ai160.com/images/reader/v3/15.png') no-repeat;
  61. background-size: contain;
  62. }
  63. .payBox {
  64. position: fixed;
  65. display: flex;
  66. align-items: center;
  67. justify-content: space-between;
  68. box-sizing: border-box;
  69. left: 0;
  70. bottom: 0;
  71. width: 100%;
  72. padding: 15px 18px;
  73. background: white;
  74. }
  75. .payBox .left {
  76. font-size: 0.48rem;
  77. }
  78. .price {
  79. color: #ff9108;
  80. font-size: 0.64rem;
  81. font-weight: bold;
  82. }
  83. .pay {
  84. padding: 0.1867rem 0.6933rem;
  85. background: #ff9108;
  86. color: white;
  87. font-weight: 500;
  88. border-radius: 0.6133rem;
  89. font-size: 0.48rem;
  90. }
  91. .mask {
  92. position: fixed;
  93. display: flex;
  94. align-items: center;
  95. justify-content: center;
  96. width: 100vw;
  97. height: 100vh;
  98. left: 0;
  99. top: 0;
  100. background-color: rgba(0, 0, 0, 0.568);
  101. }
  102. .payTips {
  103. display: flex;
  104. flex-direction: column;
  105. align-items: center;
  106. width: 6.4533rem;
  107. height: 6.96rem;
  108. padding: 1.0133rem;
  109. box-sizing: border-box;
  110. border-radius: 11px;
  111. background: white;
  112. }
  113. .simg {
  114. width: 1.6rem;
  115. height: 1.7867rem;
  116. }
  117. .t1 {
  118. margin: .52rem 1.3333rem;
  119. font-size: 18px;
  120. }
  121. .goXkx {
  122. padding: .1rem 1.3333rem;
  123. font-size: .4267rem;
  124. color: white;
  125. background: linear-gradient(180deg, #66d751 0%, #65d952 100%);
  126. border-radius: .4rem;
  127. }
  128. </style>
  129. <body>
  130. <div id="container">
  131. <div class="commoditys" v-if="products.length>0">
  132. <div :class="['commodity c-1', active==products[0].id?'aborder':'']" @click="selected(products[0])">
  133. <img src="http://reader-wx.ai160.com/images/reader/v3/active.png" class="active" v-show="active==products[0].id" />
  134. </div>
  135. <div :class="['commodity c-2', active==products[2].id?'aborder':'']" @click="selected(products[2])">
  136. <img src="http://reader-wx.ai160.com/images/reader/v3/active.png" class="active" v-show="active==products[2].id" />
  137. </div>
  138. <div :class="['commodity c-3', active==products[1].id?'aborder':'']" @click="selected(products[1])">
  139. <img src="http://reader-wx.ai160.com/images/reader/v3/active.png" class="active" v-show="active==products[1].id" />
  140. </div>
  141. </div>
  142. <div class="payBox" v-if="active!=''">
  143. <div class="left">
  144. {{product.title}}
  145. <span class="price">{{product.price/100}}</span>
  146. </div>
  147. <div class="pay" @click="pay">立即支付</div>
  148. </div>
  149. <div class="mask">
  150. <div class="payTips">
  151. <img src="https://reader-wx.ai160.com/images/reader/v3/right.webp" class="simg" />
  152. <div class="t1">支付成功</div>
  153. <div class="goXkx">去使用</div>
  154. </div>
  155. </div>
  156. </div>
  157. </body>
  158. <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.13/vue.js"></script>
  159. <script src="https://g.tbcdn.cn/mtb/lib-flexible/0.3.2/??flexible_css.js,flexible.js"></script>
  160. <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.6/axios.min.js"></script>
  161. <script>
  162. let app = new Vue({
  163. el: '#container',
  164. data: {
  165. products: [],
  166. product: {},
  167. active: '',
  168. uid: '',
  169. code: ''
  170. },
  171. mounted() {
  172. // 原始URL
  173. var url = location.search
  174. // 创建URLSearchParams对象
  175. console.log(url, 'zzzzzzzzzzzzzzzzz')
  176. var searchParams = new URLSearchParams(url)
  177. // 获取code参数的值
  178. var code = searchParams.get('code')
  179. var uid = searchParams.get('uid')
  180. console.log(uid, '=======', code)
  181. if (code) {
  182. this.uid = uid
  183. this.code = code
  184. axios({
  185. method: 'get',
  186. url: 'https://reader-api.efunbox.cn/wx/v3/product/learn',
  187. headers: {
  188. uid: 'd83d947655f6455a96f4197d31afa6d4',
  189. channelCode: '3001'
  190. }
  191. }).then(res => {
  192. this.products = res.data.data.productList
  193. this.active = res.data.data.productList[0].id
  194. this.product = res.data.data.productList[0]
  195. })
  196. } else {
  197. // this.getWxCode()
  198. }
  199. },
  200. methods: {
  201. selected(e) {
  202. this.active = e.id
  203. this.product = e
  204. },
  205. pay() {
  206. axios({
  207. method: 'post',
  208. url: 'https://reader-api.efunbox.cn/order/create',
  209. headers: {
  210. uid: 'd83d947655f6455a96f4197d31afa6d4',
  211. channelCode: '3001'
  212. },
  213. data: {
  214. productId: this.active
  215. }
  216. }).then(res => {
  217. console.log(res)
  218. axios({
  219. method: 'post',
  220. url: 'https://reader-api.efunbox.cn/wx/pay/efun',
  221. headers: {
  222. uid: this.uid,
  223. channelCode: '3001'
  224. },
  225. data: {
  226. payType: 'WXPAY',
  227. code: this.code,
  228. orderId: res.data.data
  229. }
  230. }).then(res => {
  231. let options = res.data.data
  232. console.log(options, 'rrrses')
  233. WeixinJSBridge.invoke(
  234. 'getBrandWCPayRequest',
  235. {
  236. appId: options.appId, //公众号ID,由商户传入2
  237. timeStamp: options.timeStamp, //时间戳,自1970年以来的秒数
  238. nonceStr: options.nonceStr, //随机串
  239. package: options.package,
  240. signType: options.signType, //微信签名方式:
  241. paySign: options.sign //微信签名
  242. },
  243. async res => {
  244. if (res.err_msg == 'get_brand_wcpay_request:ok') {
  245. console.log('支付成功')
  246. } else {
  247. this.getWxCode()
  248. }
  249. }
  250. )
  251. })
  252. })
  253. },
  254. getWxCode() {
  255. const appId = 'wxf05800eea975a68b'
  256. const redirect_uri = encodeURIComponent('https://h5-pay.ai160.com/reader-ios?uid=d83d947655f6455a96f4197d31afa6d4')
  257. const url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appId + '&redirect_uri=' + redirect_uri + '&response_type=code&scope=snsapi_base#wechat_redirect'
  258. location.href = url
  259. }
  260. }
  261. })
  262. </script>
  263. </html>