buy.blade.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. @include('home.http.common.head')
  5. <style>
  6. /* 会员中心 */
  7. .vip-model {
  8. display: flex;
  9. flex-wrap: nowrap;
  10. justify-content: flex-start;
  11. border: 2px solid #ddd;
  12. padding: 20px 0;
  13. margin-top: 20px;
  14. margin-bottom: 100px;
  15. }
  16. .v-left {
  17. width: 180px;
  18. border-right: 1px solid #ddd;
  19. text-align: center;
  20. }
  21. .v-left .v-name {
  22. font-size: 16px;
  23. font-weight: 600;
  24. margin-bottom: 10px;
  25. }
  26. .v-left .v-logo {
  27. width: 100px;
  28. height: 100px;
  29. border-radius: 100px;
  30. border: 1px solid #ddd;
  31. }
  32. .v-left .vip-interest {
  33. margin: 20px 0;
  34. line-height: 2.8;
  35. }
  36. .v-left .vip-title {
  37. font-size: 24px;
  38. font-weight: 600;
  39. color: #ed4014;
  40. }
  41. .v-right {
  42. flex: 1;
  43. padding-left: 16px;
  44. }
  45. .vip-list {
  46. display: flex;
  47. flex-wrap: nowrap;
  48. justify-content: space-between;
  49. }
  50. .vip-list .vip-item {
  51. width: 20%;
  52. border: 1px solid #ddd;
  53. border-radius: 10px;
  54. text-align: center;
  55. padding-bottom: 10px;
  56. cursor: pointer;
  57. margin-bottom: 12px;
  58. }
  59. .vip-list .active {
  60. border: 2px solid #e12424;
  61. }
  62. .vip-list .vip-name {
  63. font-size: 20px;
  64. line-height: 80px;
  65. background-color: #eee;
  66. border-top-left-radius: 10px;
  67. border-top-right-radius: 10px;
  68. border-bottom: 1px solid #ddd;
  69. }
  70. .vip-list .vip-price {
  71. font-size: 16px;
  72. color: #666;
  73. }
  74. .vip-list .vip-market-price {
  75. margin-left: 10px;
  76. text-decoration: line-through;
  77. }
  78. .vip-list .price-value {
  79. color: #e12424;
  80. font-size: 26px;
  81. font-weight: 600;
  82. margin-left: 3px;
  83. }
  84. .vip-list .vip-desc {
  85. color: #999;
  86. font-size: 12px;
  87. }
  88. .vip-list .vip-red {
  89. color: #e12424;
  90. font-weight: 600;
  91. }
  92. .vip-tips {
  93. color: #999;
  94. font-size: 14px;
  95. margin-bottom: 15px;
  96. }
  97. .pay-line, .pay-type {
  98. display: flex;
  99. flex-wrap: nowrap;
  100. justify-content: flex-start;
  101. line-height: 35px;
  102. }
  103. .pay-item {
  104. border: 1px solid #ddd;
  105. padding: 0 15px;
  106. border-radius: 5px;
  107. cursor: pointer;
  108. height: 35px;
  109. margin-right: 15px;
  110. }
  111. .pay-type .active {
  112. border: 1px solid #e12424;
  113. color: #e12424;
  114. }
  115. .pay-item .iconfont {
  116. margin-right: 5px;
  117. }
  118. .pay-item .icon-zhifubaozhifu {
  119. color: #027AFF;
  120. }
  121. .pay-item .icon-weixinzhifu {
  122. color: #62b900;
  123. }
  124. .pay-cont {
  125. padding: 10px 0;
  126. display: flex;
  127. flex-wrap: nowrap;
  128. justify-content: flex-start;
  129. }
  130. .pay-cont .pay-img {
  131. width: 200px;
  132. height: 200px;
  133. background-color: #eee;
  134. position: relative;
  135. }
  136. .pay-cont .pay-desc {
  137. padding: 20px;
  138. line-height: 3;
  139. font-size: 16px;
  140. }
  141. .pay-cont .iconfont {
  142. vertical-align: middle;
  143. font-size: 16px;
  144. margin: 0 5px 0 10px;
  145. }
  146. .iconfont {
  147. vertical-align: middle;
  148. }
  149. .dis-agreement {
  150. text-align: center;
  151. height: 240px;
  152. line-height: 240px;
  153. font-size: 18px;
  154. font-weight: 600;
  155. color: #ed4014;
  156. }
  157. .pay-agreement span {
  158. font-size: 12px;
  159. color: #999;
  160. margin: 0 !important;
  161. }
  162. .agreement-txt {
  163. cursor: pointer;
  164. }
  165. .agreement-txt:hover {
  166. color: #ed4014;
  167. }
  168. .money-color {
  169. color: #ed4014;
  170. font-size: 18px;
  171. font-weight: 600;
  172. }
  173. .vip-banner {
  174. background-color: #eee;
  175. height: 60px;
  176. width: 100%;
  177. margin-bottom: 15px;
  178. }
  179. .payment-top {
  180. position: relative;
  181. width: 100%;
  182. height: 60px;
  183. background: #FFB703;
  184. color: #333333;
  185. font-size: 20px;
  186. }
  187. .payment-top img {
  188. width: 40px;
  189. height: 40px;
  190. display: inline-block;
  191. margin-right: 10px;
  192. }
  193. </style>
  194. <script type="text/javascript" src="/static/js/qrcode.js"></script>
  195. <script type="text/javascript">
  196. {{--let target = '{{ $target ?? '' }}';--}}
  197. let token = '{{$token ?? ''}}';
  198. let pay_type = "wechat";
  199. let sku_type = 4;
  200. let pmid = "{{ $productInfo->mid ?? '' }}";
  201. let isLogin = "{{$isLogin ? 'true' : 'false'}}"
  202. function selectTerm(type, price) {
  203. sku_type = type;
  204. document.getElementById("payMoney").innerText = price
  205. // 其他的去除
  206. let vipItem1 = document.getElementById("vip_item1").getAttribute("class").replace("active", " ");
  207. document.getElementById("vip_item1").setAttribute("class", vipItem1);
  208. let vipItem2 = document.getElementById("vip_item2").getAttribute("class").replace("active", " ");
  209. document.getElementById("vip_item2").setAttribute("class", vipItem2);
  210. let vipItem3 = document.getElementById("vip_item3").getAttribute("class").replace("active", " ");
  211. document.getElementById("vip_item3").setAttribute("class", vipItem3);
  212. let vipItem4 = document.getElementById("vip_item4").getAttribute("class").replace("active", " ");
  213. document.getElementById("vip_item4").setAttribute("class", vipItem4);
  214. let classVal = document.getElementById("vip_item" + type).getAttribute("class");
  215. document.getElementById("vip_item" + type).setAttribute("class", classVal.concat(" active"))
  216. //创建支付二维码
  217. createPayCode();
  218. }
  219. function createPayCode() {
  220. if (isLogin === 'false') {
  221. showModal();
  222. return false;
  223. }
  224. document.getElementById('spinnerShowBuy').style.display = ""
  225. document.getElementById("qrcode").innerHTML = ""
  226. document.getElementById('qrcode').style.display = "none"
  227. let data = {
  228. type: sku_type,
  229. pay_type: pay_type
  230. }
  231. axios.post(target + '/api/pay/getPayCode/' + pmid, data, {headers: {Authorization: token}}).then(function (response) {
  232. if (!response.data.error) {
  233. let code = response.data.result;
  234. createQrcode(code);
  235. }
  236. }).catch(function (error) {
  237. console.log(error);
  238. });
  239. }
  240. // 设置支付类型
  241. function selectPaytype(type) {
  242. pay_type = type
  243. if (type === 'wechat') {
  244. let str = document.getElementById("payAlipay").getAttribute("class").replace("active", " ")
  245. document.getElementById("payAlipay").setAttribute("class", str);
  246. let classVal = document.getElementById("payWechat").getAttribute("class");
  247. document.getElementById("payWechat").setAttribute("class", classVal.concat(" active"))
  248. } else {
  249. let str = document.getElementById("payWechat").getAttribute("class").replace("active", " ");
  250. document.getElementById("payWechat").setAttribute("class", str);
  251. let classVal = document.getElementById("payAlipay").getAttribute("class");
  252. document.getElementById("payAlipay").setAttribute("class", classVal.concat(" active"))
  253. }
  254. //创建支付二维码
  255. createPayCode();
  256. }
  257. // 创建二维码
  258. function createQrcode(code) {
  259. document.getElementById('qrcode').style.display = ""
  260. document.getElementById('spinnerShowBuy').style.display = "none"
  261. new QRCode(document.getElementById("qrcode"), {
  262. text: "https://www.qasimblog.com/soft/pay/" + code,
  263. width: 200,
  264. height: 200,
  265. correctLevel: 0 // 二维码结构复杂性 0~3
  266. });
  267. // 开始检测支付扫描
  268. startScan(code);
  269. }
  270. let payScanInterval;
  271. let payEndInterval;
  272. function startScan(code) {
  273. if (payScanInterval) {
  274. clearInterval(payScanInterval);
  275. }
  276. if (payEndInterval) {
  277. clearInterval(payEndInterval);
  278. }
  279. payScanInterval = setInterval(() => {
  280. axios.post(target + '/api/pay/checkPayScan/' + code, {}, {headers: {Authorization: token}}).then((response) => {
  281. if (!response.data.error) {
  282. // 提示消息,扫描成功
  283. // 开始检测支付
  284. clearInterval(payScanInterval);
  285. startCheckPayEnd(code);
  286. }
  287. }).catch(function (error) {
  288. console.log(error);
  289. });
  290. }, 1000);
  291. }
  292. // 开始检测支付
  293. function startCheckPayEnd(code) {
  294. if (payEndInterval) {
  295. clearInterval(payEndInterval);
  296. }
  297. payEndInterval = setInterval(() => {
  298. axios.post(target + '/api/pay/checkPayEnd/' + code, {product_type: 1}, {headers: {Authorization: token}}).then((response) => {
  299. if (!response.data.code === 0 || !response.data.error) {
  300. // 关闭定时器
  301. clearInterval(payEndInterval);
  302. alert("恭喜你,支付成功!");
  303. }
  304. }).catch(function (error) {
  305. console.log(error);
  306. });
  307. }, 1000);
  308. }
  309. </script>
  310. </head>
  311. <body>
  312. <div class="header">
  313. @include('home.http.common.header')
  314. </div>
  315. <div class="payment-top" style="display: flex;align-items: center;justify-content: center;">
  316. <img src="{{ $productInfo->logo ?? '' }}" alt="{{ $productInfo->title ?? '' }}">
  317. <span>{{ $productInfo->title ?? '' }} - 会员充值</span>
  318. </div>
  319. <div class="container vip-model">
  320. <div class="v-left">
  321. <img
  322. src="{{ (isset($userInfo->avatar) && $userInfo->avatar) ?$userInfo->avatar: "/static/logo/logo_small.png"}}"
  323. class="v-logo"/>
  324. <p class="v-name">{{ $userInfo->username ?? '' }}</p>
  325. @if(isset($billInfo['validity_type']) && $billInfo['validity_type'] == 2)
  326. <p>会员: 永久有效</p>
  327. @elseif(isset($billInfo['validity_type']) && $billInfo['validity_type'] == 1)
  328. <p>会员有效期</p>
  329. <p>
  330. {{ $billInfo['validity_end_time'] }}
  331. </p>
  332. @else
  333. <p>会员: 无</p>
  334. @endif
  335. <div class="vip-interest">
  336. <p class="vip-title">会员专享</p>
  337. <p>1、会员特权</p>
  338. <p>2、批量转换</p>
  339. <p>3、专属客服</p>
  340. <p>4、次数不限</p>
  341. </div>
  342. </div>
  343. <div class="v-right">
  344. @if(isset($ad) && $ad->logo)
  345. <div class="vip-banner">
  346. <img src="{{$ad->logo}}" style="width: 100%; height: 100%;"/>
  347. </div>
  348. @endif
  349. <div class="vip-list">
  350. @if(isset($productInfo) && $productInfo->price4)
  351. <div id="vip_item4" class="vip-item active" onclick="selectTerm(4,{{ $productInfo->price4 }})">
  352. <div class="vip-name">永久</div>
  353. <div>
  354. <p class="vip-price">
  355. ¥<span class="price-value">{{ $productInfo->price4 }}</span>
  356. @if($productInfo->market_price4)
  357. <span class="vip-market-price">{{ $productInfo->market_price4 }}</span>
  358. @endif
  359. </p>
  360. <p class="vip-desc vip-red">
  361. {{ $productInfo->desc_price4 ?: "超划算,热销中" }}
  362. </p>
  363. </div>
  364. </div>
  365. @endif
  366. @if(isset($productInfo) && $productInfo->price1)
  367. <div id="vip_item1" class="vip-item" onclick="selectTerm(1,{{ $productInfo->price1 }})">
  368. <div class="vip-name">一个月</div>
  369. <div>
  370. <p class="vip-price">
  371. ¥<span class="price-value">{{ $productInfo->price1 }}</span>
  372. @if($productInfo->market_price1)
  373. <span class="vip-market-price">¥{{ $productInfo->market_price1 }}</span>
  374. @endif
  375. </p>
  376. <p class="vip-desc vip-red">
  377. {{ $productInfo->desc_price1 ?: "有效期一个月" }}
  378. </p>
  379. </div>
  380. </div>
  381. @endif
  382. @if(isset($productInfo) && $productInfo->price2)
  383. <div id="vip_item2" class="vip-item" onclick="selectTerm(2,{{ $productInfo->price2 }})">
  384. <div class="vip-name">半年</div>
  385. <div>
  386. <p class="vip-price">
  387. ¥<span class="price-value">{{ $productInfo->price2 }}</span>
  388. @if($productInfo->market_price2)
  389. <span class="vip-market-price">¥{{ $productInfo->market_price2 }}</span>
  390. @endif
  391. </p>
  392. <p class="vip-desc">
  393. {{ $productInfo->desc_price2 ?: "有效期半年" }}
  394. </p>
  395. </div>
  396. </div>
  397. @endif
  398. @if(isset($productInfo) && $productInfo->price3)
  399. <div id="vip_item3" class="vip-item" onclick="selectTerm(3,{{ $productInfo->price3 }})">
  400. <div class="vip-name">一年</div>
  401. <div>
  402. <p class="vip-price">
  403. ¥<span class="price-value">{{ $productInfo->price3 }}</span>
  404. @if($productInfo->market_price3)
  405. <span class="vip-market-price">¥{{ $productInfo->market_price3 }}</span>
  406. @endif
  407. </p>
  408. <p class="vip-desc">
  409. {{ $productInfo->desc_price3 ?: "有效期一年" }}
  410. </p>
  411. </div>
  412. </div>
  413. @endif
  414. </div>
  415. <p class="vip-tips">温馨提示:VIP会员到期后将直接转为非VIP会员</p>
  416. <p class="pay-line">
  417. 支付金额:<span id="payMoney" class="money-color">0</span>元
  418. </p>
  419. <div class="pay-line">
  420. <p>支付方式:</p>
  421. <div class="pay-type">
  422. <div id="payWechat" class="pay-item active" onclick="selectPaytype('wechat')">
  423. <span class="iconfont icon-weixinzhifu"></span>微信支付
  424. </div>
  425. <div id="payAlipay" class="pay-item" onclick="selectPaytype('alipay')">
  426. <span class="iconfont icon-zhifubaozhifu"></span>支付宝支付
  427. </div>
  428. </div>
  429. <div class="pay-agreement">
  430. <label>
  431. <input disabled type="checkbox" checked/>
  432. </label>
  433. <span>同意并接受</span>
  434. <span class="agreement-txt" onclick="agreementModel = true">《软件会员增值服务协议》</span>
  435. </div>
  436. </div>
  437. <div class="pay-cont">
  438. <div class="spinner-border m-5 text-primary" role="status" style="display: block" id="spinnerShowBuy">
  439. <span class="visually-hidden">Loading...</span>
  440. </div>
  441. <div id="qrcode" class="pay-img" style="display: none"></div>
  442. <div class="pay-desc">
  443. <div>
  444. 1、<span class="iconfont icon-saoma1"></span> 请打开微信扫一扫
  445. </div>
  446. <div>
  447. 2、<span class="iconfont icon-erweima1"></span> 扫描左侧二维码
  448. </div>
  449. <div>
  450. 3、<span class="iconfont icon-wancheng1"></span> 请完成支付
  451. </div>
  452. </div>
  453. </div>
  454. <template>
  455. <div class="dis-agreement">请同意服务协议后方可购买产品</div>
  456. </template>
  457. </div>
  458. </div>
  459. @include('home.http.common.footer')
  460. <script>
  461. document.getElementById("payMoney").innerText = "{{ $productInfo->price4 ?? 0}}"
  462. // 创建支付二维码
  463. createPayCode();
  464. </script>
  465. </body>
  466. </html>