123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- $(".sendbox").hide();
- $(document).on("click", ".collectcontent", function (event) {
- $(".sendbox").show(500);
- $(this).addClass("select");
- $(".select").siblings().removeClass('select');
- });
- $(document).on("click", ".close", function (event) {
-
- $(".sendbox").hide(500);
- $(".collectcontent").removeClass("select");
- });
- function collection(collectuserid='') {
- console.log('Call collection(' + collectuserid + ')');
- var collectcontent = '';
- $.ajax({
- method: "GET",
- url: "https://ark.cards:8228/collection/" + collectuserid + "",
- dataType: "json",
- })
- .done(function (msg) {
- for (var i in msg) {
- for(var j in msg[i]) {
- collectcontent += '\
- <div class="collectcontent col">\
- <input style="display: none;" type="checkbox" value="'+ msg[i][j].id + '" name="nftid" id="' + msg[i][j].id + '">\
- <label for="'+ msg[i][j].id + '">\
- <div class="collectcard card h-100">\
- <a target="_blank">\
- <img src="'+ msg[i][j].imgurl + '"class="card-img-top" alt="...">\
- </a>\
- <div class="card-body p-2">\
- <a target="_blank">\
- <h5 class="card-title pt-3">'+ msg[i][j].title + '</h5>\
- </a>\
- </div>\
- </div>\
- </label>\
- </div>';
-
- }
- }
- $('.sec05-moblie-container').html(collectcontent);
- });
- }
- function shop(collectuserid='') {
- console.log('Call shop(' + collectuserid + ')');
- $.ajax({
- method: "GET",
- url: "https://ark.cards:8228/shop/" + collectuserid + "",
-
- dataType: "json",
- })
- .done(function (msg) {
- console.log(msg);
-
- let msgLen = Object.keys(msg).length;
- console.log(msgLen);
- var nftmall = '';
- var buybox = "";
- for (var i = 0; i < msgLen; i++) {
- nftmall += '\
- <div class="nftmall col">\
- <input style="display:none" type="checkbox" value="'+ msg[i].id + '" name="nftid" class="nftname" id="' + msg[i].id + '">\
- <label for="'+ msg[i].id + '">\
- <div class="collectcard card h-100">\
- <a target="_blank">\
- <img src="'+ msg[i].imgurl + '"class="card-img-top" alt="...">\
- </a>\
- <div class="card-body p-2">\
- <a target="_blank">\
- <h5 class="card-title pt-3">'+ msg[i].title + '</h5>\
- </a>\
- </div>\
- </div>\
- </label>\
- </div>';
-
- }
- buybox += '\
- <div class="p-2">\
- <input style="border-radius: 10px; border:none; display: none;" class="p-2 w-100 mb-3" type="text" name="userid" value="' + collectuserid + '" placeholder="請輸入您的userid" required>\
- <div class="text-end px-2">\
- <p class="text-start text-white mb-2">※一次只能購買一則NFT收藏品</p>\
- <button type="button" style="border:1px solid #fff; border-radius: 30px;" class="close btn text-white px-3">取消</button>\
- <input style="border-radius: 30px; background:#fff; border: none;" class="send-btn px-3 ms-1 py-2" type="submit" value="購買">\
- </div>\
- </div>\
- </div>';
- $('.sec06-nft-mall').html(nftmall);
- $('.buybox').html(buybox);
- });
- }
- function get_data(collectuserid='') {
- console.log('Call get_data(' + collectuserid + ')');
- $.ajax({
- method: "GET",
- url: "https://ark.cards:8228/receive/" + collectuserid + "",
-
- dataType: "json",
- })
- .done(function (msg) {
- console.log(msg);
- var Qrcodeimg = '';
- var useraddress = '';
- Qrcodeimg += '\
- <img class="img-fluid" src="./qrcode/'+ collectuserid + '.png" alt="">\
- ';
- useraddress += '\
- '+ msg.useraddress + '\
- ';
- $('#Qrcode').html(Qrcodeimg);
- $('#copy').html(useraddress);
- });
- }
- $(".buybox").hide();
- $(document).on("click", ".nftmall", function (event) {
- $(".buybox").show(500);
- $(this).addClass("select");
- $(".select").siblings().removeClass('select');
- });
- $(document).on("click", ".close", function (event) {
-
- $(".buybox").hide(500);
- $(".nftmall").removeClass("select");
- $(".nftname").prop("checked", false);
- });
- $.fn.serializeObject = function () {
- var o = {};
- var a = this.serializeArray();
-
-
- $.each(a, function () {
- if (o[this.name]) {
- console.log(o[this.name], o[this.value]);
- if (!o[this.name].push) {
- o[this.name] = [o[this.name]];
- }
- o[this.name].push(this.value || '');
- } else {
- o[this.name] = this.value || '';
- }
- });
- return o;
- };
- $(".collect-send").submit(function (e) {
-
- var jsonInfo = $('.collect-send').serializeObject();
- var jsonString = JSON.stringify(jsonInfo);
- console.log(jsonString);
- Swal.fire({
- title: '您是否確認要發送?',
- text: "發送後,NFT將從您的錢包轉移至接收者的錢包!",
- icon: 'warning',
- showCancelButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
- confirmButtonText: '立即發送',
- cancelButtonText: '取消'
- }).then((result) => {
- if (result.isConfirmed) {
- $.ajax({
- type: 'POST',
- url: 'https://ark.cards:8228/send',
- data: jsonString,
- dataType: 'json',
- async: false,
- success: function (data) {
- console.log('發送成功: ' + JSON.stringify(data));
-
- Swal.fire({
- icon: 'success',
- confirmButtonColor: '#3085d6',
- html: '發送成功'
- });
- },
- beforeSend: function () {
- console.log('beforeSend');
- },
- complete: function () {
- console.log('complete');
- location.reload();
- },
- error: function (jqXHR, textStatus, errorThrown) {
- console.log(JSON.stringify(jqXHR));
- console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
- console.log('送出失敗: ' + jqXHR.responseText);
- }
- });
- return false;
- }
- })
- });
- $(".nft-buy").submit(function (e) {
-
- var jsonInfo = $('.nft-buy').serializeObject();
- var jsonString = JSON.stringify(jsonInfo);
- console.log(jsonString),
- $.ajax({
- type: 'POST',
- url: 'https://ark.cards:8228/buy',
- data: jsonString,
- dataType: 'json',
- success: function (data) {
- console.log('購買成功: ' + data);
- alert("購買成功");
- location.reload();
- },
- beforeSend: function () {
- console.log('beforeSend');
- },
- complete: function () {
- console.log('complete');
- },
- error: function (jqXHR, textStatus, errorThrown) {
- console.log(JSON.stringify(jqXHR));
- console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
- console.log('送出失敗: ' + jqXHR.responseText);
- }
- });
- return false;
- });
- function copyEvent(id) {
- var str = document.getElementById(id);
- window.getSelection().selectAllChildren(str);
- document.execCommand("Copy")
- toastr.options = {
-
- "closeButton": false,
- "debug": false,
- "newestOnTop": false,
- "progressBar": false,
- "positionClass": "toast-top-center",
- "preventDuplicates": false,
- "onclick": null,
- "showDuration": "300",
- "hideDuration": "1000",
- "timeOut": "1000",
- "extendedTimeOut": "1000",
- "showEasing": "swing",
- "hideEasing": "linear",
- "showMethod": "fadeIn",
- "hideMethod": "fadeOut"
- }
- toastr.success("複製成功");
- }
|