|
5 | 5 | {{use "ui.iview"}} |
6 | 6 |
|
7 | 7 | <div id="app"> |
8 | | - |
9 | 8 | <tabs v-model:value="tab_current" type="card" :animated="false"> |
10 | 9 | <tab-pane label="apijson get" name="tab_get"></tab-pane> |
11 | 10 | <tab-pane label="apijson post" name="tab_post"></tab-pane> |
12 | 11 | <tab-pane label="apijson put" name="tab_put"></tab-pane> |
13 | 12 | </tabs> |
| 13 | + <Row> |
| 14 | + <i-col span="3"><div align="center">login user</div></i-col> |
| 15 | + <i-col span="8"><i-input value="{{=user_info}}" readonly/></i-col> |
| 16 | + {{if request.user:}} |
| 17 | + <i-col span="1"><div align="center"><i-button type="warning" size="large" @click="logout">Logout</i-button></div></i-col> |
| 18 | + {{else:}} |
| 19 | + <i-col span="1"><div align="center"><i-button type="primary" size="large" @click="login">Login</i-button></div></i-col> |
| 20 | + {{pass}} |
| 21 | + </Row> |
14 | 22 | <Row v-if="tab_current==='tab_get'"> |
15 | | - <i-col span="3"><div align="center">POST URL</div></i-col> |
| 23 | + <i-col span="3"><div align="center">HTTP POST URL</div></i-col> |
16 | 24 | <i-col span="8"><i-input value="/apijson/get" readonly/></i-col> |
17 | 25 | </Row> |
18 | 26 | <Row v-if="tab_current==='tab_get'"> |
19 | | - <i-col span="3"><div align="center">demo request data list</div></i-col> |
| 27 | + <i-col span="3"><div align="center"><strong>apijson get</strong> request examples</div></i-col> |
20 | 28 | <i-col span="8"> |
21 | 29 | <i-select v-model="request_data"> |
22 | | - <i-option v-for="item in request_data_list" :value="item.value" :key="item.value">{ item.label }</i-option> |
| 30 | + <i-option v-for="item in request_get" :value="item.value" :key="item.value">{ item.label }</i-option> |
23 | 31 | </i-select> |
24 | 32 | </i-col> |
25 | 33 | </Row> |
| 34 | + |
| 35 | + <Row v-if="tab_current==='tab_post'"> |
| 36 | + <i-col span="3"><div align="center">POST URL</div></i-col> |
| 37 | + <i-col span="8"><i-input value="/apijson/post" readonly/></i-col> |
| 38 | + </Row> |
| 39 | + <Row v-if="tab_current==='tab_post'"> |
| 40 | + <i-col span="3"><div align="center"><strong>apijson post</strong> request examples</div></i-col> |
| 41 | + <i-col span="8"> |
| 42 | + <i-select v-model="request_data"> |
| 43 | + <i-option v-for="item in request_post" :value="item.value" :key="item.value">{ item.label }</i-option> |
| 44 | + </i-select> |
| 45 | + </i-col> |
| 46 | + </Row> |
| 47 | + |
26 | 48 | <Row> |
27 | 49 | <i-col span="3"><div align="center">request data</div></i-col> |
28 | 50 | <i-col span="8"><i-input v-model="request_data" type="textarea" :autosize="{minRows: 3,maxRows: 15}" placeholder="request data" /></i-col> |
|
38 | 60 | el: '#app', |
39 | 61 | delimiters: ['{', '}'], |
40 | 62 | data: { |
41 | | - request_data_list : {{=request_data_list_json}}, |
| 63 | + request_get : {{=request_get_json}}, |
| 64 | + request_post : {{=request_post_json}}, |
42 | 65 | request_data : "", |
43 | 66 | can_post : true, |
44 | 67 | response_data : "", |
45 | | - tab_current : "tab_get" |
| 68 | + tab_current : "tab_get", |
| 69 | + tab2url : { |
| 70 | + "tab_get":"{{=url_for('uliweb_apijson.apijson.views.ApiJson.get')}}", |
| 71 | + "tab_post":"{{=url_for('uliweb_apijson.apijson.views.ApiJson.post')}}" |
| 72 | + } |
46 | 73 | }, |
47 | 74 | methods: { |
48 | 75 | init_default: function(){ |
49 | | - vm.request_data = vm.request_data_list[0].value |
| 76 | + vm.request_data = vm.request_get[0].value |
50 | 77 | }, |
51 | 78 | post_request_data: function(){ |
52 | 79 | $.ajax({ |
53 | 80 | type: "POST", |
54 | 81 | contentType: 'application/json', |
55 | | - url: "{{=url_for('uliweb_apijson.apijson.views.ApiJson.get')}}", |
| 82 | + url: vm.tab2url[vm.tab_current], |
56 | 83 | data: vm.request_data, |
57 | 84 | success: function (data) { |
58 | 85 | vm.response_data = JSON.stringify(data,null,2) |
59 | 86 | vm.can_post = false |
60 | 87 | } |
61 | 88 | }) |
62 | 89 |
|
63 | | - } |
| 90 | + }, |
| 91 | + login: function(){window.location.href="{{=url_for('uliweb_apps.login.views.login')}}"}, |
| 92 | + logout: function(){window.location.href="{{=url_for('uliweb_apps.login.views.logout')}}"} |
64 | 93 | }, |
65 | 94 | watch: { |
66 | 95 | request_data : function(n,o){ |
|
0 commit comments