buy.blade.php 17 KB

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