123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- import WechatShare from '../wechat/WechatShare.js';
- let envHost = process.env.API_ROOT;
- let enter_url = "";
- let gWxShare = null;
- let mobile = {
- Android: function () {
- return navigator.userAgent.match(/Android/i);
- },
- BlackBerry: function () {
- return navigator.userAgent.match(/BlackBerry/i);
- },
- iOS: function () {
- return navigator.userAgent.match(/iPhone|iPad|iPod/i);
- },
- Opera: function () {
- return navigator.userAgent.match(/Opera Mini/i);
- },
- Windows: function () {
- return navigator.userAgent.match(/IEMobile/i);
- },
- any: function () {
- return (mobile.Android() || mobile.BlackBerry() || mobile.iOS() || mobile.Opera() || mobile.Windows());
- }
- };
- class Api {
- static host() {
- return envHost;
- }
- static special(special_id) {
- return this.host() + "/mobile/index.php?act=special&op=index&page=10&curpage=1&client_type=ajax&special_id=" + special_id;
- }
- static brands() {
- return this.host() + "/mobile/index.php?act=brand&op=home&client_type=ajax";
- }
- static functionList() {
- return this.host() + "/mobile/index.php?client_type=ajax&act=category&op=index"
- }
- static goodsDetail(goods_id) {
- return this.host() + `/mobile/index.php?goods_id=${goods_id}&act=goods_common&op=index&client_type=ajax`
- }
- static searchSuggest() {
- return this.host() + '/mobile/index.php?act=search&op=history&curpage=1&client_type=ajax'
- }
- static search() {
- return this.host() + '/mobile/index.php?act=search&op=suggest_words&client_type=ajax'
- }
- static goodsContent(goods_id) {
- return this.host() + `/mobile/index.php?act=goods_common&op=detail_ajax&goods_id=${goods_id}&client_type=ajax`
- }
- static memberInfo() {
- return this.host() + '/mobile/index.php?act=member_info&op=get&client_type=ajax'
- }
- static shoppingCart() {
- return this.host() + '/mobile/index.php?act=cart&op=list&client_type=ajax'
- }
- static changeOrderState(action, order_id) {
- return this.host() + '/mobile/index.php?act=member_order&op=change_state&client_type=ajax&act_type=' + action + "&order_id=" + order_id
- }
- static orderList() {
- return this.host() + '/mobile/index.php?act=member_order&page=30&op=list&page=15&client_type=ajax'
- }
- static refundOrder(order_sn) {
- return this.host() + '/mobile/index.php?act=member_refund&op=order_refund&client_type=ajax&order_sn=' + order_sn
- }
- static deliverInfo(order_id) {
- return this.host() + '/mobile/index.php?act=member_order&op=search_deliver&order_id=' + order_id
- }
- static shoppingCartEdit(quantity, cart_id) {
- return this.host() + `/mobile/index.php?quantity=${quantity}&act=cart&op=edit&cart_id=${cart_id}&client_type=ajax`
- }
- static shoppingCartAdd(quantity, goods_id) {
- return this.host() + `/mobile/index.php?quantity=${quantity}&act=cart&goods_id=${goods_id}&op=addex&client_type=ajax`
- }
- static userBonus() {
- return this.host() + '/mobile/index.php?act=cart&op=rate_money&client_type=ajax'
- }
- static addressList() {
- return this.host() + '/mobile/index.php?act=member_address&op=address_list&client_type=ajax';
- }
- static homeTabs() {
- return this.host() + "/mobile/index.php?act=mshop&op=tabs&client_type=ajax"
- }
- static login(mobile, code) {
- return this.host() + `/mobile/index.php?act=login&op=bind_mobile&client_type=ajax&mobile=${mobile}&code=${code}`;
- }
- static getCode(mobile) {
- return this.host() + `/mobile/index.php?act=login&op=getcodex&client_type=ajax&mobile=${mobile}&type=register`;
- }
- static getFCode() {
- return this.host() + '/mobile/index.php?act=member_fcode&op=list&curpage=1&client_type=ajax';
- }
- static stepFirst(ifcart, cart_id, goods_id, num) {
- let goods_datas = '';
- if (ifcart == 0) {
- goods_datas = goods_id + '|' + num;
- }
- else {
- goods_datas = cart_id;
- }
- return this.host() + `/mobile/index.php?act=member_buy&op=step_first&curpage=1&ifcart=${ifcart}&cart_id=${goods_datas}&client_type=ajax`;
- }
- static stepSecond(cart_ids, goods_id, goods_num, addr_id, inv_id, vat_hash, offpay_hash, offpay_hash_batch) {
- let ifcart = cart_ids !== '' ? true : false;
- let iscart = ifcart ? 1 : 0;
- let cartids = ifcart ? cart_ids : (goods_id + '|' + goods_num);
- return this.host() + `/mobile/index.php?client_type=ajax&act=member_buy&op=step_second&payment=jspay&usebonus=1&ifcart=${iscart}&cart_id=${cartids}&address_id=${addr_id}&invoice_id=${inv_id}&vat_hash=${vat_hash}&offpay_hash=${offpay_hash}&offpay_hash_batch=${offpay_hash_batch}`;
- }
- static getAddress() {
- return this.host() + '/mobile/index.php?act=app_update&op=area&curpage=1&client_type=ajax';
- }
- static addAddress(true_name, area_id, address, mobile) {
- return this.host() + `/mobile/index.php?act=member_address&op=address_add&curpage=1&client_type=ajax&true_name=${true_name}&area_id=${area_id}&address=${address}&mob_phone=${mobile}`;
- }
- static setDefaultAddress(id, is_default) {
- return this.host() + `/mobile/index.php?act=member_address&op=set_default&curpage=1&client_type=ajax&address_id=${id}&is_default=${is_default}`;
- }
- static paySn(pay_sn) {
- return this.host() + `/mobile/index.php?act=member_order&op=pay_info&curpage=1&pay_sn=${pay_sn}&client_type=ajax`;
- }
- static init_url() {
- if (enter_url == "") {
- enter_url = window.location.href;
- }
- }
- static create_share(data, href) {
- if (mobile.iOS()) {
- gWxShare = new WechatShare(data, this.sign_url());
- return gWxShare;
- }
- else {
- return new WechatShare(data, this.sign_url());
- }
- }
- static sign_url() {
- let temp;
- if (mobile.iOS()) {
- Api.init_url();
- temp = enter_url;
- } else {
- temp = window.location.href;
- }
- return decodeURIComponent(temp);
- }
- }
- export default Api
|