|
@@ -573,16 +573,20 @@
|
|
|
<input id="desc" name="inputDesc" type="text" class="form-control">
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="row mb-3">
|
|
|
+ <!-- <div class="row mb-3">
|
|
|
<div class="col-12 text-center">
|
|
|
<img src="" alt="" id="img" width="60" height="60">
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
<div class="row mb-3">
|
|
|
<label for="inputNumber" class="col-sm-2 col-form-label">圖片</label>
|
|
|
- <div class="col-sm-10">
|
|
|
+ <div class="col-sm-10 blk-file">
|
|
|
<input id="image" name="image" class="form-control" type="file">
|
|
|
</div>
|
|
|
+ <div class="col-sm-10 blk-imgurl">
|
|
|
+ <div id="imgUrl"></div>
|
|
|
+ </div>
|
|
|
+ <span class="btn-changeImg btn">更改圖片</span>
|
|
|
</div>
|
|
|
<div class="row mb-3">
|
|
|
<legend class="col-form-label col-sm-2 pt-0">顯示</legend>
|
|
@@ -914,6 +918,13 @@ let Data;
|
|
|
let category;
|
|
|
let imgurl;
|
|
|
|
|
|
+$('.blk-file').hide();
|
|
|
+$('.btn-changeImg').click(function() {
|
|
|
+ $('.blk-imgurl').hide();
|
|
|
+ $('.blk-file').show();
|
|
|
+ $(this).hide();
|
|
|
+})
|
|
|
+
|
|
|
function getpathId(){
|
|
|
let id = window.location.search.split('?').pop();
|
|
|
return id.split('=')[1];
|
|
@@ -934,7 +945,8 @@ axios({
|
|
|
console.log(Data);
|
|
|
$('#title').val(res.data.title);
|
|
|
$('#desc').val(res.data.context);
|
|
|
- $('#img').attr('src', res.data.imgurl);
|
|
|
+ $('#imgUrl').text(res.data.imgurl);
|
|
|
+ // $('#img').attr('src', res.data.imgurl);
|
|
|
if(res.data.is_active) {
|
|
|
$('#is_active_checkbox').attr('checked', true)
|
|
|
} else {
|
|
@@ -966,8 +978,6 @@ function handleFileSelect(evt) {
|
|
|
|
|
|
// Read in the image file as a data URL.
|
|
|
reader.readAsText(f);
|
|
|
- imgurl = imageFile;
|
|
|
- console.log(imgurl)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -977,6 +987,20 @@ $("#nft_add_form").submit(function(e) {
|
|
|
var title = $('#title').val();
|
|
|
var image = $('#image').val();
|
|
|
var context = $('#desc').val();
|
|
|
+ if(image) {
|
|
|
+ image = $('#image').val();
|
|
|
+ let front = image.split(/(\\|\/)/g).pop();
|
|
|
+ let type = front.split('.').pop();
|
|
|
+ if(type == 'jpg' || type == 'jpeg') {
|
|
|
+ type = 'jpeg';
|
|
|
+ } else if (type == 'png') {
|
|
|
+ type = 'png';
|
|
|
+ }
|
|
|
+ console.log(front,type);
|
|
|
+ image = imageFile;
|
|
|
+ } else {
|
|
|
+ image = '';
|
|
|
+ }
|
|
|
|
|
|
console.log('title = ' + title + ', image = ' + image); // test
|
|
|
|
|
@@ -1036,12 +1060,12 @@ axios({
|
|
|
Swal.fire({
|
|
|
title: '成功',
|
|
|
icon: 'success',
|
|
|
- text: '新增成功',
|
|
|
+ text: '編輯成功',
|
|
|
confirmButtonColor: '#3085d6'
|
|
|
});
|
|
|
- // window.setTimeout(() => {
|
|
|
- // window.location.href = 'nft.html';
|
|
|
- // }, 2000);
|
|
|
+ window.setTimeout(() => {
|
|
|
+ window.location.href = 'nft.html';
|
|
|
+ }, 2000);
|
|
|
}).catch(err => {
|
|
|
console.log(err);
|
|
|
Swal.fire({
|