index.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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: 14px 10px;
  29. box-sizing: border-box;
  30. border-radius: 20px;
  31. }
  32. .commodity {
  33. position: relative;
  34. width: 97px;
  35. height: 97px;
  36. border-radius: 6px;
  37. border: 2px solid white;
  38. }
  39. .active {
  40. position: absolute;
  41. width: 27px;
  42. height: 18px;
  43. right: 0;
  44. bottom: 0;
  45. }
  46. .aborder {
  47. border-color: #ff935e;
  48. }
  49. .c-1 {
  50. background: url('http://reader-wx.ai160.com/images/reader/v3/299.png');
  51. background-size: contain;
  52. }
  53. .c-2 {
  54. background: url('http://reader-wx.ai160.com/images/reader/v3/99.png');
  55. background-size: contain;
  56. }
  57. .c-3 {
  58. background: url('http://reader-wx.ai160.com/images/reader/v3/15.png');
  59. background-size: contain;
  60. }
  61. .payBox {
  62. position: fixed;
  63. display: flex;
  64. align-items: center;
  65. justify-content: space-between;
  66. box-sizing: border-box;
  67. left: 0;
  68. bottom: 0;
  69. width: 100%;
  70. padding: 15px 18px;
  71. background: white;
  72. }
  73. .payBox .left {
  74. font-size: 0.48rem;
  75. }
  76. .price {
  77. color: #ff9108;
  78. font-size: 0.64rem;
  79. font-weight: bold;
  80. }
  81. .pay {
  82. padding: 0.1867rem 0.6933rem;
  83. background: #ff9108;
  84. color: white;
  85. font-weight: 500;
  86. border-radius: 0.6133rem;
  87. font-size: 0.48rem;
  88. }
  89. </style>
  90. <body>
  91. <div id="container">
  92. <div class="commoditys" v-if="products.length>0">
  93. <div :class="['commodity c-1', active==products[0].id?'aborder':'']" @click="selected(products[0])">
  94. <img src="http://reader-wx.ai160.com/images/reader/v3/active.png" class="active" v-show="active==products[0].id" />
  95. </div>
  96. <div :class="['commodity c-2', active==products[2].id?'aborder':'']" @click="selected(products[2])">
  97. <img src="http://reader-wx.ai160.com/images/reader/v3/active.png" class="active" v-show="active==products[2].id" />
  98. </div>
  99. <div :class="['commodity c-3', active==products[1].id?'aborder':'']" @click="selected(products[1])">
  100. <img src="http://reader-wx.ai160.com/images/reader/v3/active.png" class="active" v-show="active==products[1].id" />
  101. </div>
  102. </div>
  103. <div class="payBox">
  104. <div class="left">
  105. 终身会员
  106. <span class="price">{{product.price/100}}</span>
  107. </div>
  108. <div class="pay" @click="pay">立即支付</div>
  109. </div>
  110. </div>
  111. </body>
  112. <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.13/vue.js"></script>
  113. <script src="https://g.tbcdn.cn/mtb/lib-flexible/0.3.2/??flexible_css.js,flexible.js"></script>
  114. <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.6/axios.min.js"></script>
  115. <script>
  116. let app = new Vue({
  117. el: '#container',
  118. data: {
  119. products: [],
  120. product: {},
  121. active: '',
  122. code: ''
  123. },
  124. mounted() {
  125. // 原始URL
  126. var url = location.search
  127. // 创建URLSearchParams对象
  128. console.log(url, 'zzzzzzzzzzzzzzzzz')
  129. var searchParams = new URLSearchParams(url)
  130. // 获取code参数的值
  131. var code = searchParams.get('code')
  132. console.log(searchParams, '=======', code) // 输出:021gINll25JRUb49AYll2au8ga0gINl-
  133. if (code) {
  134. this.code = code
  135. axios({
  136. method: 'get',
  137. url: 'https://reader-api.efunbox.cn/wx/v3/product/learn',
  138. headers: {
  139. uid: 'd83d947655f6455a96f4197d31afa6d4',
  140. channelCode: '3001'
  141. }
  142. }).then(res => {
  143. this.products = res.data.data.productList
  144. this.active = res.data.data.productList[0].id
  145. this.product = res.data.data.productList[0]
  146. })
  147. } else {
  148. this.getWxCode()
  149. }
  150. },
  151. methods: {
  152. selected(e) {
  153. this.active = e.id
  154. this.product = e
  155. },
  156. pay() {
  157. axios({
  158. method: 'post',
  159. url: 'https://reader-api.efunbox.cn/order/create',
  160. headers: {
  161. uid: 'd83d947655f6455a96f4197d31afa6d4',
  162. channelCode: '3001'
  163. },
  164. data: {
  165. productId: this.active
  166. }
  167. }).then(res => {
  168. console.log(res)
  169. axios({
  170. method: 'post',
  171. url: 'https://reader-api.efunbox.cn/wx/pay/efun',
  172. headers: {
  173. uid: 'd83d947655f6455a96f4197d31afa6d4',
  174. channelCode: '3001'
  175. },
  176. data: {
  177. payType: 'WXPAY',
  178. orderId: res.data.data
  179. }
  180. }).then(res => {})
  181. /* WeixinJSBridge.invoke(
  182. 'getBrandWCPayRequest',
  183. {
  184. appId: res.appId, //公众号ID,由商户传入2
  185. timeStamp: res.timeStamp, //时间戳,自1970年以来的秒数
  186. nonceStr: res.nonceStr, //随机串
  187. package: res.package,
  188. signType: res.signType, //微信签名方式:
  189. paySign: res.paySign //微信签名
  190. },
  191. async res => {
  192. if (res.err_msg == 'get_brand_wcpay_request:ok') {
  193. payIsSuccess()
  194. }
  195. }
  196. ) */
  197. })
  198. },
  199. getWxCode() {
  200. const appId = 'wxf05800eea975a68b'
  201. const redirect_uri = encodeURIComponent('https://h5-pay.ai160.com/reader-ios')
  202. const url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appId + '&redirect_uri=' + redirect_uri + '&response_type=code&scope=snsapi_base#wechat_redirect'
  203. location.href = url
  204. }
  205. }
  206. })
  207. </script>
  208. </html>