Created
June 15, 2018 07:30
-
-
Save naoyeye/0b708a52d05c81d85d0386a470b21688 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// =====html | |
<input type="number" name="price" /> | |
<button class="btn buy">做多</button> | |
<button class="btn sell">做空</button> | |
// =====js | |
const accounts = [ | |
{ | |
'name': 'account-1', | |
'api': 'http://xxx' | |
}, | |
{ | |
'name': 'account-2', | |
'api': 'http://xxx' | |
} | |
{ | |
'name': 'account-3', | |
'api': 'http://xxx' | |
} | |
{ | |
'name': 'account-4', | |
'api': 'http://xxx' | |
} | |
] | |
$('button').click((e) => { | |
var actionType // 做多还是做空 | |
if ($(this).hasClass('buy')) { | |
actionType = 'buy' | |
} else { | |
actionType = 'sell' | |
} | |
var price = $('input[name="price"]').val() | |
$.each(accounts, (account) => { | |
$.ajax({ | |
url: account.api, | |
data: { price: price, actionType: actionType, accountId: account.id }, | |
success: function(resp) { | |
console.log(resp) | |
} | |
}) | |
}) | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🍨