| 1 | import Server from './server'; |
| 2 | |
| 3 | class API extends Server{ |
| 4 | /** |
| 5 | * 用途:上传图片 |
| 6 | * @url https://elm.cangdu.org/v1/addimg/shop |
| 7 | * 返回status为1表示成功 |
| 8 | * @method post |
| 9 | * @return {promise} |
| 10 | */ |
| 11 | async uploadImg(params = {}){ |
| 12 | try{ |
| 13 | let result = await this.axios('post', '//elm.cangdu.org/v1/addimg/shop', params); |
| 14 | if(result && result.status === 1){ |
| 15 | return result; |
| 16 | }else{ |
| 17 | let err = { |
| 18 | tip: '上传图片失败', |
| 19 | response: result, |
| 20 | data: params, |
| 21 | url: '//elm.cangdu.org/v1/addimg/shop', |
| 22 | } |
| 23 | throw err; |
| 24 | } |
| 25 | }catch(err){ |
| 26 | throw err; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * 用途:获取记录数据 |
| 32 | * @url https://api.cangdu.org/shopro/data/record |
| 33 | * 返回http_code为200表示成功 |
| 34 | * @method get |
| 35 | * @return {promise} |
| 36 | */ |
| 37 | async getRecord(params = {}){ |
| 38 | try{ |
| 39 | let result = await this.axios('get', `/shopro/data/record/${params.type}`); |
| 40 | if(result && (result.data instanceof Object) && result.http_code === 200){ |
| 41 | return result.data; |
| 42 | }else{ |
| 43 | let err = { |
| 44 | tip: '获取记录数据失败', |
| 45 | response: result, |
| 46 | data: params, |
| 47 | url: 'https://api.cangdu.org/shopro/data/record', |
| 48 | } |
| 49 | throw err; |
| 50 | } |
| 51 | }catch(err){ |
| 52 | throw err; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * 用途:获取商品数据 |
| 58 | * @url https://api.cangdu.org/shopro/data/products |
| 59 | * 返回http_code为200表示成功 |
| 60 | * @method get |
nothing calls this directly
no outgoing calls
no test coverage detected