receiveMoney.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>领取奖励</title>
  8. <!--引入 element-ui 的样式,-->
  9. <link rel="stylesheet"
  10. href="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742018383195/element-ui.css">
  11. <!-- 必须先引入vue, 后使用element-ui -->
  12. <script
  13. src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017957144/vue.js"></script>
  14. <!-- 引入element 的组件库-->
  15. <script
  16. src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017747738/element-ui.js"></script>
  17. <!-- <script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
  18. <script>
  19. var vConsole = new window.VConsole();
  20. </script> -->
  21. </head>
  22. <style>
  23. body {
  24. margin: 0;
  25. padding: 0;
  26. }
  27. .box {
  28. width: 100vw;
  29. height: 100vh;
  30. box-sizing: border-box;
  31. background: #FAFAFA;
  32. }
  33. .page6 {
  34. width: 100vw;
  35. height: 100vh;
  36. background: url('./img/red_packet.png') no-repeat center;
  37. background-size: 100vw 100vh;
  38. background-repeat: no-repeat;
  39. display: flex;
  40. justify-content: center;
  41. align-items: center;
  42. }
  43. .cash_prize {
  44. width: 325px;
  45. height: 192px;
  46. background: #FFFFFF;
  47. border-radius: 20px;
  48. padding: 20px 20px 15px;
  49. box-sizing: border-box;
  50. }
  51. .cash_prize_title {
  52. font-weight: 500;
  53. font-size: 14px;
  54. color: #222222;
  55. text-align: center;
  56. padding-bottom: 15px;
  57. }
  58. .cash_input input {
  59. height: 50px;
  60. background: #F4F4F4;
  61. border-radius: 20px;
  62. text-align: start;
  63. }
  64. .cash_btn {
  65. width: 100%;
  66. height: 52px;
  67. margin-top: 20px;
  68. }
  69. .prize_dialog {
  70. position: fixed;
  71. top: 0;
  72. left: 0;
  73. width: 100%;
  74. height: 100%;
  75. background-color: rgba(0, 0, 0, 0.5);
  76. /* 半透明黑色 */
  77. z-index: 1000;
  78. /* 确保遮罩层在顶部 */
  79. transition: opacity 0.5s ease;
  80. /* 可选:添加透明度过渡效果 */
  81. }
  82. .dialog-body {
  83. width: 100%;
  84. height: 100%;
  85. z-index: 1001;
  86. /* 确保遮罩层在顶部 */
  87. display: flex;
  88. flex-direction: column;
  89. align-items: center;
  90. justify-content: center;
  91. }
  92. .dialog-tip {
  93. width: 100%;
  94. height: 100px;
  95. }
  96. .dialog-bg {
  97. width: 295px;
  98. height: 251px;
  99. position: relative;
  100. }
  101. .prize-msg {
  102. position: absolute;
  103. text-align: center;
  104. }
  105. .money-title {
  106. font-weight: 500;
  107. font-size: 16px;
  108. color: #FF4E4E;
  109. padding-top: 90px;
  110. padding-bottom: 10px;
  111. }
  112. .money-content {
  113. margin-bottom: 30px;
  114. height: 60px;
  115. display: flex;
  116. justify-content: center;
  117. align-items: center;
  118. }
  119. .prize-money {
  120. font-weight: bold;
  121. font-size: 60px;
  122. color: #FF4E4E;
  123. }
  124. .prize-unit {
  125. font-weight: 500;
  126. font-size: 16px;
  127. color: #FF4E4E;
  128. padding-left: 10px;
  129. padding-top: 28px;
  130. }
  131. .dialog-btn {
  132. width: 235px;
  133. height: 52px;
  134. margin-bottom: 10px;
  135. }
  136. .money-tip {
  137. font-weight: 400;
  138. font-size: 12px;
  139. color: #999999;
  140. margin-bottom: 15px;
  141. }
  142. .dialog-close {
  143. width: 30px;
  144. height: 30px;
  145. margin-top: 20px;
  146. }
  147. </style>
  148. <body>
  149. <div id="box" class="box">
  150. <div class="page6">
  151. <div class="cash_prize">
  152. <div class="cash_prize_title">请输入您的兑换码</div>
  153. <el-input v-model="input" placeholder="请输入" class="cash_input"></el-input>
  154. <el-button type="warning" round class="cash_btn" @click="getMoney">领取</el-button>
  155. </div>
  156. <!-- 奖励弹窗 -->
  157. <div class="prize_dialog" v-if="showPrizeDialog">
  158. <div class="dialog-body">
  159. <img class="dialog-tip" src="./img/dialog-tip.png" />
  160. <img class="dialog-bg" src="./img/dialog-bg.png" />
  161. <div class="prize-msg">
  162. <div class="money-title">微信红包</div>
  163. <div class="money-content">
  164. <span class="prize-money">{{prizeMoney}}</span>
  165. <span class="prize-unit">元</span>
  166. </div>
  167. <img class="dialog-btn" src="./img/dialog-btn.png" @click="closePop" />
  168. <div class="money-tip">红包到账会有延迟情况,请以实际为准</div>
  169. </div>
  170. <img class="dialog-close" src="./img/dialog-close.png" @click="closePop" />
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. </body>
  176. <script>
  177. new Vue({
  178. el: '#box',
  179. data () {
  180. return {
  181. httpUrl: '',
  182. bId: null,
  183. env: '',
  184. input: '',
  185. showPrizeDialog: false,
  186. prizeMoney: null
  187. }
  188. },
  189. created () {
  190. this.bId = this.getQueryParam('bId')
  191. this.env = this.getQueryParam('env')
  192. if (!this.env || this.env === 'prod') {
  193. this.httpUrl = 'https://wlapi.wefanbot.com'
  194. } else {
  195. this.httpUrl = 'http://test.wefanbot.com:18993'
  196. }
  197. // 授权
  198. this.getAuth()
  199. },
  200. methods: {
  201. getAuth () {
  202. // 获取url上的code
  203. let code = this.getQueryParam('code')
  204. if (code) {
  205. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  206. .then(res => {
  207. return res.json()
  208. }).then(result => {
  209. let { data, code, msg } = result
  210. if (code === 1) {
  211. this.openId = data.openId
  212. }
  213. })
  214. } else {
  215. let redirect_uri = window.location.href
  216. // code 不存在,走微信网页授权逻辑
  217. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  218. window.location.replace(url)
  219. }
  220. },
  221. getMoney () {
  222. fetch(this.httpUrl + '/scrm/v1/wxcp-live-code-counselor/p/prizeCode', {
  223. method: 'post',
  224. body: JSON.stringify({
  225. code: this.input,
  226. openId: this.openId,
  227. }),
  228. headers: {
  229. 'Content-Type': 'application/json'
  230. }
  231. }).then(res => {
  232. return res.json()
  233. }).then(result => {
  234. let { data, code, msg } = result
  235. if (data) {
  236. this.prizeMoney = data.money
  237. this.showPrizeDialog = true
  238. } else {
  239. this.$message({
  240. message: msg,
  241. type: 'warning'
  242. })
  243. }
  244. })
  245. },
  246. closePop () {
  247. this.showPrizeDialog = false
  248. this.input = ''
  249. this.prizeMoney = null
  250. },
  251. // 截取url中的数据
  252. getQueryParam (paramName) {
  253. // 获取当前URL的查询字符串部分
  254. const queryString = window.location.search;
  255. // 创建一个URLSearchParams对象
  256. const urlParams = new URLSearchParams(queryString);
  257. // 返回指定参数的值,如果不存在则返回null
  258. return urlParams.get(paramName);
  259. },
  260. }
  261. })
  262. </script>
  263. </html>