-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprice_comparison_cart.js
More file actions
131 lines (126 loc) · 3.4 KB
/
price_comparison_cart.js
File metadata and controls
131 lines (126 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//let shop_item ={rakuten:'楽天',amazon:'Amazon',ebay:'ebay'}; // 表示の順番
const app=new Vue({
el: '#app',
data() {
return {
shop_item: {rakuten:'楽天',amazon:'Amazon',ebay:'ebay'},
cartItems:[],
loading: true,
errored: false,
pop_disabled: true,
pop_nofade: true,
pop_show: false,
}
},
mounted() {
//let item={};
axios.post('add_cart.php',{})
.then(response => {
this.cartItems = response.data
})
.catch(error => {
console.log(error);
})
},
methods: {
delete_cart(del_list) { // カートから削除
/*
del_list.forEach(id=>{
delete this.citems[id];
});
*/
axios.post('delete_cart.php',{
del_list
})
.then(response => {
this.cartItems = response.data
})
.catch(error => {
console.log(error);
})
},
copy() {
let copy_text="";
for(let id in this.cartItems){
copy_text=copy_text
.concat(this.cartItems[id].title)
.concat(": ")
.concat(this.cartItems[id].quantity)
.concat("個\n");
}
//console.log(copy_text)
//this.$copyText(this.$el.querySelector("#items").textContent).then(
this.$copyText(copy_text).then(
(e) => {
//console.log("テキストコピー完了");
//console.log(e);
this.$refs.popover.$emit("enable");
this.pop_show = true;
setTimeout(() => {
this.pop_show = false;
this.$refs.popover.$emit("disable");
}, 1000);
},
(e) => {
console.log("コピーエラー");
console.error(e);
}
);
},
cart_modify(id){
// 引数が何もないときphpのsessionのカート情報を呼び出すだけの機能になる
axios.post('add_cart.php',{
item:{
item_id:id,
image:this.cartItems[id].image,
url:this.cartItems[id].url,
title:this.cartItems[id].title,
price:this.cartItems[id].price,
shop:this.cartItems[id].shop,
quantity:this.cartItems[id].quantity,
}
})
.then(response => {
this.cartItems = response.data
})
.catch(error => {
console.log(error);
})
},
}
})
/*
setTimeout(function () {
$('#copy-button')
// tooltip設定
.tooltip({
trigger: 'manual',
placement:'right'
})
// tooltip表示後の動作を設定
.on('shown.bs.tooltip', function(){
setTimeout((function(){
$(this).tooltip('hide');
}).bind(this), 1500);
})
// クリック時の動作を設定
.on('click', function(){
//$('#items').select();
let copyTarget = document.getElementById("items");
//document.write(copyTarget.value);
let range = document.createRange();
range.selectNode(copyTarget);
window.getSelection().addRange(range);
const copyResult = document.execCommand('copy');
console.log(copyResult)
// コピー結果によって表示変更
if(copyResult){
$('#copy-button').attr('data-bs-original-title', 'コピーしました');
}else{
$('#copy-button').attr('data-bs-original-title', 'コピー失敗しました');
}
// tooltip表示
$(this).tooltip('show');
});
}, 545*1.33); // 545ms timing to load jQuery.js + network estimated delay
*/