index.html 9.2 KB

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