在前面测试通过odoo登录的功能,这次的问题重点是如何访问后台具体的业务类的接口呢?这次就以我们在odoo中安装的lunch模块为例,目标是获取lunch.alert的数据,如下图

具体过程接上次文章,继续完善OdooJsonRpc类的代码,首先是基础代码,这个是需要提供具体的model名称和具体方法,也是是一个很基础的方法,后台的odoo网站会利用类似C#反射的机制调用目标类的方法。

  1. /**
  2. * Calls the method of that particular model
  3. * @param model Model name
  4. * @param method Method name of particular model
  5. * @param args Array of fields
  6. * @param kwargs Object
  7. */
  8. public call(model: string, method: string, args: any, kwargs?: any)
  9. {
  10. kwargs = kwargs || {};
  11. let params =
  12. {
  13. model: model,
  14. method: method,
  15. args: args,
  16. kwargs: kwargs == false ? {} : kwargs,
  17. context: this.getContext()
  18. };
  19. return this.sendRequest("/web/dataset/call_kw", params);
  20. }

调用以上基础call方法的几个基本封装函数有如下几个,基本实现了对数据的CRUD功能,当然基本上是针对一条数据的操作

  1. /**
  2. * Reads that perticular fields of that particular ID
  3. * @param model Model Name
  4. * @param id Id of that record which you want to read
  5. * @param mArgs Array of fields which you want to read of the particular id
  6. */
  7.  
  8. public read(model: string, id: number, mArgs: any): Promise<any>
  9. {
  10. let args =
  11. [
  12. id, [mArgs]
  13. ]
  14. return this.call(model, 'read', args)
  15. }
  16.  
  17. /**
  18. * Provide the name that you want to search
  19. * @param model Model name
  20. * @param name Name that you want to search
  21. */
  22. public nameSearch(model: string, name: string): Promise<any>
  23. {
  24. let kwargs =
  25. {
  26. name: name,
  27. args: [],
  28. operator: "ilike",
  29. limit:
  30. }
  31. return this.call(model, 'name_search', [], kwargs)
  32. }
  33.  
  34. /**
  35. * Provide the IDs and you will get the names of that paticular IDs
  36. * @param model Model name
  37. * @param mArgs Array of IDs that you want to pass
  38. */
  39. public nameGet(model: string, mArgs: any): Promise<any>
  40. {
  41. let args = [mArgs]
  42. return this.call(model, 'name_get', args)
  43. }
  44.  
  45. /**
  46. * Create a new record
  47. * @param model Model name
  48. * @param mArgs Object of fields and value
  49. */
  50. public createRecord(model: string, mArgs: any)
  51. {
  52. let args = [mArgs];
  53. return this.call(model, "create", args, null)
  54. }
  55.  
  56. /**
  57. * Delete the record of particular ID
  58. * @param model Model Name
  59. * @param id Id of record that you want to delete
  60. */
  61. public deleteRecord(model: string, id: number)
  62. {
  63. let mArgs = [id]
  64. return this.call(model, "unlink", mArgs, null)
  65. }
  66.  
  67. /**
  68. * Updates the record of particular ID
  69. * @param model Model Name
  70. * @param id Id of record that you want to update the.
  71. * @param mArgs The Object of fields and value that you want to update
  72. * (e.g)
  73. * let args = {
  74. * "name": "Mtfa"
  75. * }
  76. */
  77. public updateRecord(model: string, id: number, mArgs: any)
  78. {
  79. let args =
  80. [
  81. [id], mArgs
  82. ]
  83. return this.call(model, "write", args, null)
  84. }

针对单条数据的读取,这里还有另外一种方法,类似上面的read函数

  1. /**
  2. * Loads all data of the paricular ID
  3. * @param model Model name
  4. * @param id Id of that particular data which you want to load
  5. */
  6. public load(model: string, id: number): Promise<any>
  7. {
  8. let params =
  9. {
  10. model: model,
  11. id: id,
  12. fields: [],
  13. context: this.getContext()
  14. }
  15. return this.sendRequest("/web/dataset/load", params)
  16. }

还有对odoo多条件查询的情况,尤其还有分页的问题,这里也有这样一个很实用的分页查询的方法,这个在日后app的开发中会经常用到

  1. /**
  2. * Fires query in particular model with fields and conditions
  3. * @param model Model name
  4. * @param domain Conditions that you want to fire on your query
  5. * (e.g) let domain = [
  6. * ["id","=",11]
  7. * ]
  8. * @param fields Fields names which you want to bring from server
  9. * (e.g) let fields = [
  10. * ["id","name","email"]
  11. * ]
  12. * @param limit limit of the record
  13. * @param offset
  14. * @param sort sorting order of data (e.g) let sort = "ascending"
  15. */
  16. public searchRead(model: string, domain: any, fields: any, limit: number, offset: any, sort: string)
  17. {
  18. let params =
  19. {
  20. model: model,
  21. fields: fields,
  22. domain: domain,
  23. offset: offset,
  24. limit: limit,
  25. sort: sort,
  26. context: this.getContext()
  27. };
  28. return this.sendRequest("/web/dataset/search_read", params);
  29. }

到此,访问odoo具体业务类的OdooJsonRpc类封装完毕,完整的代码在这里。接下来怎么获取我们的lunch.alert数据呢??

首先定义我们访问odoo业务类的成员变量,这里我们的model类是lunch.alert,需要获取的字段是message和id,其他参数我们暂使用默认的值

  1. private lunchAlert = "lunch.alert";
  2. private fields = ["message", "id"];
  3. private domain = []
  4. private sort = ""
  5. private limit =
  6. private offset =
  7. private items: Array<{ id: number, message: string }> = []

第二步是,与odoo后台网站交互获取数据的过程

  1. private TestMyOdooModel()
  2. {
  3. this.odooRpc.searchRead(this.lunchAlert,this.domain, this.fields, this.limit, this.offset,this.sort)
  4. .then((lunchAlerts: any) =>
  5. {
  6. let json = JSON.parse(lunchAlerts._body);
  7. if (!json.error)
  8. {
  9. let query = json["result"].records
  10. for (let i in query)
  11. {
  12. this.items.push
  13. ({
  14. id: query[i].id,
  15. message: query[i].message
  16. })
  17. }
  18. this.utils.presentAlert("Lunch Message", this.items[].message,[{text: "Ok"}])
  19. }
  20. else
  21. {
  22. this.utils.presentAlert("LunchAlert", "Parse lunch alert error",[{text: "Ok"}])
  23. }
  24. })
  25. }

如果正确获取数据,我们会弹出第一条数据对应的message.

编译打包成*.apk,在手机上测试,确实成功了,如下图所示。

由于这些都是测试阶段的代码,将来可能会改变,现阶段把这些代码全部放在这里。

测试部分的Page页面odooLogin.ts

  1. import { Component } from '@angular/core';
  2. import {
  3. AlertController,
  4. IonicPage,
  5. Loading,
  6. LoadingController,
  7. NavController,
  8. NavParams
  9. } from 'ionic-angular';
  10. import { OdooJsonRpc } from '../../../../providers/baseService/Odoojsonrpc';
  11. import { Utils } from "../../../../providers/baseService/Utils";
  12.  
  13. @IonicPage()
  14. @Component
  15. ({
  16. selector: 'page-odooLogin',
  17. templateUrl: 'odooLogin.html',
  18. })
  19.  
  20. export class OdooLoginPage
  21. {
  22. private listForProtocol: Array<{ protocol: string}> = []
  23. public perfectUrl: boolean = false
  24. public odooUrl
  25. public selectedProtocol
  26. private dbList: Array<{ dbName: string}> = []
  27. private selectedDatabase
  28. private email
  29. private password
  30.  
  31. constructor(public navCtrl: NavController,
  32. private alert: AlertController, public navParams: NavParams,
  33. private odooRpc: OdooJsonRpc, private loadingCtrl: LoadingController,
  34. private utils: Utils)
  35. {
  36. this.listForProtocol.push({ protocol: "http" })
  37. this.listForProtocol.push({protocol: "https"})
  38. }
  39.  
  40. public checkUrl()
  41. {
  42. this.utils.presentLoading("Please Wait")
  43. this.odooRpc.init
  44. ({
  45. odoo_server: this.selectedProtocol + "://" + this.odooUrl
  46. //http_auth: 'username:password' // optional
  47. })
  48.  
  49. this.odooRpc.getDbList().then((dbList: any) =>
  50. {
  51. console.log(dbList)
  52. this.perfectUrl = true
  53. this.utils.dismissLoading()
  54. this.fillData(dbList)
  55. }).
  56. catch((err: any) =>
  57. {
  58. console.log(err)
  59. this.utils.presentAlert("Error", "You Entered a wrong Odoo URL",
  60. [{
  61. text: "Ok"
  62. }])
  63. this.utils.dismissLoading()
  64. });
  65. }
  66.  
  67. public fillData(res: any)
  68. {
  69. let body = JSON.parse(res._body)
  70. let json = body['result'];
  71. this.dbList.length = ;
  72. for (var key in json)
  73. {
  74. this.dbList.push({ dbName: json[key] });
  75. }
  76. }
  77.  
  78. private login()
  79. {
  80. this.utils.presentLoading("Please wait", , true)
  81. this.odooRpc.login(this.selectedDatabase, this.email, this.password)
  82. .then((res: any) =>
  83. {
  84. let logiData: any = JSON.parse(res._body)["result"];
  85. logiData.password = this.password
  86. localStorage.setItem("token", JSON.stringify(logiData));
  87. //this.utils.dismissLoading()
  88. this.utils.presentAlert("Congratulation", "You login success",[{text: "Ok"}])
  89. this.TestMyOdooModel()
  90. }).
  91. catch((err) =>
  92. {
  93. this.utils.presentAlert("Error", "Username or password must be incorrect",
  94. [{
  95. text: "Ok"
  96. }])
  97. });
  98. }
  99.  
  100. private lunchAlert = "lunch.alert";
  101. private fields = ["message", "id"];
  102. private domain = []
  103. private sort = ""
  104. private limit =
  105. private offset =
  106. private items: Array<{ id: number, message: string }> = []
  107.  
  108. private TestMyOdooModel()
  109. {
  110. this.odooRpc.searchRead(this.lunchAlert,this.domain, this.fields, this.limit, this.offset,this.sort)
  111. .then((lunchAlerts: any) =>
  112. {
  113. let json = JSON.parse(lunchAlerts._body);
  114. if (!json.error)
  115. {
  116. let query = json["result"].records
  117. for (let i in query)
  118. {
  119. this.items.push
  120. ({
  121. id: query[i].id,
  122. message: query[i].message
  123. })
  124. }
  125. this.utils.presentAlert("Lunch Message", this.items[].message,[{text: "Ok"}])
  126. }
  127. else
  128. {
  129. this.utils.presentAlert("LunchAlert", "Parse lunch alert error",[{text: "Ok"}])
  130. }
  131. })
  132. }
  133. }

页面布局部分odooLogin.html

  1. <ion-content class="background">
  2. <ion-card>
  3. <ion-card-content>
  4.  
  5. <div class="spacer" style="height: 10px;"></div>
  6. <ion-item>
  7. <ion-label style="color: #fff">Select Protocol</ion-label>
  8. <ion-select [(ngModel)]="selectedProtocol" style="color: #fff" name="dbNames">
  9. <ion-option *ngFor="let item of listForProtocol" value="{{item.protocol}}">{{item.protocol}}</ion-option>
  10. </ion-select>
  11. </ion-item>
  12. <div class="spacer" style="height: 10px;"></div>
  13. <ion-item>
  14. <ion-input [(ngModel)]="odooUrl" type="url" name="odooUrl" placeholder="Odoo Url"></ion-input>
  15. </ion-item>
  16. <div class="spacer" style="height: 10px;"></div>
  17. <button ion-button block round outline color="light" (click)="checkUrl()" text-center>
  18. Check Url
  19. <ion-icon name="md-arrow-round-forward"></ion-icon>
  20. </button>
  21. <div [hidden]="!perfectUrl">
  22. <form (ngSubmit)="login()" #registerForm="ngForm">
  23. <div class="spacer" style="height: 10px;"></div>
  24. <ion-item>
  25. <ion-input type="email" [(ngModel)]="email" name="email" placeholder="Email" required></ion-input>
  26. </ion-item>
  27. <div class="spacer" style="height: 5px;"></div>
  28. <ion-item>
  29. <ion-input type="password" [(ngModel)]="password" name="pass" placeholder="Password" required></ion-input>
  30. </ion-item>
  31. <div class="spacer" style="height: 10px;"></div>
  32. <div class="spacer" style="height: 10px;"></div>
  33. <ion-item>
  34. <ion-label style="color: #fff">Select Database</ion-label>
  35. <ion-select [(ngModel)]="selectedDatabase" name="selectDatabase" style="color: #fff" required>
  36. <ion-option *ngFor="let item of dbList" value="{{item.dbName}}">{{item.dbName}}</ion-option>
  37. </ion-select>
  38. </ion-item>
  39. <button ion-button block round outline color="light" [disabled]="!registerForm.form.valid" (click)="signin()">Login</button>
  40. </form>
  41. </div>
  42. </ion-card-content>
  43. </ion-card>
  44. </ion-content

CSS效果部分odooLogin.scss

  1. page-odooLogin {
  2. .background {
  3. height: %;
  4. width: %;
  5. background-size: cover !important;
  6. background-position: center center !important;
  7. background-image: url('../assets/imgs/mountain.jpg')
  8. }
  9.  
  10. ion-card.card {
  11. margin-top: %;
  12. box-shadow: none;
  13. background: rgba(, , , 0.5);
  14. border-radius: 5px;
  15. }
  16. a, p,
  17. ion-card-header.card-header {
  18. color: #fff!important;
  19. }
  20.  
  21. .list > .item-block:first-child {
  22. border: medium none;
  23. }
  24.  
  25. .item {
  26. margin-bottom: 10px;
  27. background: rgba(, , , 0.5);
  28. border: medium none;
  29.  
  30. .text-input, {
  31. color: #fff;
  32. }
  33.  
  34. input::-moz-placeholder{
  35. color: #fff!important;
  36. }
  37. input:-moz-placeholder {
  38. color: #fff!important;
  39. }
  40. *:-moz-placeholder{
  41. color: #fff!important;
  42. }
  43. *:-ms-input-placeholder{
  44. color: #fff!important;
  45. }
  46. *::-webkit-input-placeholder{
  47. color: #fff!important;
  48. }
  49. }
  50. }

OdooJsonRpc部分Odoojsonrpc.ts

  1. import { Injectable } from '@angular/core';
  2. import 'rxjs/add/operator/toPromise';
  3. import 'rxjs/Rx';
  4.  
  5. import { Headers, Http } from '@angular/http';
  6. import { Utils } from './Utils';
  7.  
  8. @Injectable()
  9. export class OdooJsonRpc
  10. {
  11. private jsonRpcID: number = ;
  12. private headers: Headers;
  13. private odoo_server: string;
  14. private http_auth: string;
  15. private list = "/web/database/list";
  16. private get_list = "/web/database/get_list";
  17. private jsonrpc = "/jsonrpc";
  18.  
  19. constructor(private http: Http, private utils: Utils)
  20. {
  21. this.http = http;
  22. }
  23.  
  24. /**
  25. * Builds a request for odoo server
  26. * @param url Odoo Server URL
  27. * @param params Object
  28. */
  29. private buildRequest(url: String, params: any)
  30. {
  31. this.jsonRpcID += ;
  32. return JSON.stringify
  33. ({
  34. jsonrpc: "2.0",
  35. method: "call",
  36. id: this.jsonRpcID,
  37. params: params,
  38. });
  39. }
  40.  
  41. /**
  42. * Returns the error message
  43. * @param response Error response from server
  44. */
  45. public handleOdooErrors(response: any)
  46. {
  47. let err: string = response.error.data.message
  48. let msg = err.split("\n")
  49. let errMsg = msg[]
  50.  
  51. this.utils.presentAlert("Error", errMsg, [{
  52. text: "Ok",
  53. role: "cancel"
  54. }])
  55. }
  56.  
  57. /**
  58. * Handles HTTP errors
  59. */
  60. public handleHttpErrors(error: any)
  61. {
  62. return Promise.reject(error.message || error);
  63. }
  64.  
  65. /**
  66. * Sends a JSON request to the odoo server
  67. * @param url Url of odoo
  68. * @param params Object
  69. */
  70. public sendRequest(url: string, params: Object): Promise<any>
  71. {
  72. let options = this.buildRequest(url, params);
  73. this.headers = new Headers({
  74. 'Content-Type': 'application/json; charset=utf-8',
  75. });
  76.  
  77. let result = this.http.post(this.odoo_server + url, options, { headers: this.headers })
  78. .toPromise()
  79. return result;
  80. }
  81.  
  82. public init(configs: any)
  83. {
  84. this.odoo_server = configs.odoo_server;
  85. this.http_auth = configs.http_auth || null;
  86. }
  87.  
  88. public setOdooServer(odoo_server: string)
  89. {
  90. this.odoo_server = odoo_server;
  91. }
  92.  
  93. public setHttpAuth(http_auth: string)
  94. {
  95. this.http_auth = http_auth;
  96. }
  97.  
  98. /**
  99. * Gets the server info
  100. */
  101. public getServerInfo()
  102. {
  103. return this.sendRequest("/web/webclient/version_info", {});
  104. }
  105.  
  106. /**
  107. * Gets the session info
  108. */
  109. public getSessionInfo()
  110. {
  111. return this.sendRequest("/web/session/get_session_info", {});
  112. }
  113.  
  114. /**
  115. * Gets the Odoo Server Version Number
  116. */
  117. public getServerVersionNumber(): Promise<number>
  118. {
  119. return this.getServerInfo().then((res: any): Promise<number> =>
  120. {
  121. return new Promise<number>((resolve) =>
  122. {
  123. resolve(JSON.parse(res._body)["result"]["server_version_info"][]);
  124. });
  125. });
  126. }
  127.  
  128. /**
  129. * Get the database list
  130. */
  131. public getDbList(): Promise<string>
  132. {
  133. let dbParams =
  134. {
  135. context: {}
  136. }
  137. return this.getServerVersionNumber().then((data: number) =>
  138. {
  139. if (data <= )
  140. {
  141. return this.sendRequest(this.get_list, dbParams);
  142. }
  143. else if (data == )
  144. {
  145. return this.sendRequest(this.jsonrpc, dbParams);
  146. }
  147. else
  148. {
  149. return this.sendRequest(this.list, dbParams);
  150. }
  151. })
  152. }
  153.  
  154. /**
  155. * Returns all modules that are installed in your database
  156. */
  157. public modules(): Promise<string>
  158. {
  159. let params =
  160. {
  161. context: {}
  162. }
  163. return this.sendRequest("/web/session/modules", params)
  164. }
  165.  
  166. /**
  167. * Login to the database
  168. * @param db Database name of odoo
  169. * @param login Username
  170. * @param password password
  171. */
  172. public login(db: string, login: string, password: string)
  173. {
  174. let params =
  175. {
  176. db: db,
  177. login: login,
  178. password: password,
  179. base_location: this.odoo_server,
  180. context: {}
  181. };
  182. return this.sendRequest("/web/session/authenticate", params)
  183. }
  184.  
  185. /**
  186. * Check whether the session is live or not
  187. */
  188. public check(): Promise<string>
  189. {
  190. let params =
  191. {
  192. context: this.getContext()
  193. }
  194. return this.sendRequest("/web/session/check", params)
  195. }
  196.  
  197. /**
  198. * Destroy the session
  199. */
  200. public destroy()
  201. {
  202. let params =
  203. {
  204. context: {}
  205. }
  206. return this.sendRequest("/web/session/destroy", params)
  207. }
  208.  
  209. /**
  210. * Fires query in particular model with fields and conditions
  211. * @param model Model name
  212. * @param domain Conditions that you want to fire on your query
  213. * (e.g) let domain = [
  214. * ["id","=",11]
  215. * ]
  216. * @param fields Fields names which you want to bring from server
  217. * (e.g) let fields = [
  218. * ["id","name","email"]
  219. * ]
  220. * @param limit limit of the record
  221. * @param offset
  222. * @param sort sorting order of data (e.g) let sort = "ascending"
  223. */
  224. public searchRead(model: string, domain: any, fields: any, limit: number, offset: any, sort: string)
  225. {
  226. let params =
  227. {
  228. model: model,
  229. fields: fields,
  230. domain: domain,
  231. offset: offset,
  232. limit: limit,
  233. sort: sort,
  234. context: this.getContext()
  235. };
  236. return this.sendRequest("/web/dataset/search_read", params);
  237. }
  238.  
  239. /**
  240. * Calls the method of that particular model
  241. * @param model Model name
  242. * @param method Method name of particular model
  243. * @param args Array of fields
  244. * @param kwargs Object
  245. */
  246. public call(model: string, method: string, args: any, kwargs?: any)
  247. {
  248.  
  249. kwargs = kwargs || {};
  250. let params =
  251. {
  252. model: model,
  253. method: method,
  254. args: args,
  255. kwargs: kwargs == false ? {} : kwargs,
  256. context: this.getContext()
  257. };
  258. return this.sendRequest("/web/dataset/call_kw", params);
  259. }
  260.  
  261. /**
  262. * Reads that perticular fields of that particular ID
  263. * @param model Model Name
  264. * @param id Id of that record which you want to read
  265. * @param mArgs Array of fields which you want to read of the particular id
  266. */
  267.  
  268. public read(model: string, id: number, mArgs: any): Promise<any>
  269. {
  270. let args =
  271. [
  272. id, [mArgs]
  273. ]
  274. return this.call(model, 'read', args)
  275. }
  276.  
  277. /**
  278. * Loads all data of the paricular ID
  279. * @param model Model name
  280. * @param id Id of that particular data which you want to load
  281. */
  282. public load(model: string, id: number): Promise<any>
  283. {
  284. let params =
  285. {
  286. model: model,
  287. id: id,
  288. fields: [],
  289. context: this.getContext()
  290. }
  291. return this.sendRequest("/web/dataset/load", params)
  292. }
  293.  
  294. /**
  295. * Provide the name that you want to search
  296. * @param model Model name
  297. * @param name Name that you want to search
  298. */
  299. public nameSearch(model: string, name: string): Promise<any>
  300. {
  301. let kwargs =
  302. {
  303. name: name,
  304. args: [],
  305. operator: "ilike",
  306. limit:
  307. }
  308. return this.call(model, 'name_search', [], kwargs)
  309. }
  310.  
  311. /**
  312. * Provide the IDs and you will get the names of that paticular IDs
  313. * @param model Model name
  314. * @param mArgs Array of IDs that you want to pass
  315. */
  316. public nameGet(model: string, mArgs: any): Promise<any>
  317. {
  318. let args = [mArgs]
  319. return this.call(model, 'name_get', args)
  320. }
  321.  
  322. /**
  323. * Create a new record
  324. * @param model Model name
  325. * @param mArgs Object of fields and value
  326. */
  327. public createRecord(model: string, mArgs: any)
  328. {
  329. let args = [mArgs];
  330. return this.call(model, "create", args, null)
  331. }
  332.  
  333. /**
  334. * Delete the record of particular ID
  335. * @param model Model Name
  336. * @param id Id of record that you want to delete
  337. */
  338. public deleteRecord(model: string, id: number)
  339. {
  340. let mArgs = [id]
  341. return this.call(model, "unlink", mArgs, null)
  342. }
  343.  
  344. /**
  345. * Updates the record of particular ID
  346. * @param model Model Name
  347. * @param id Id of record that you want to update the.
  348. * @param mArgs The Object of fields and value that you want to update
  349. * (e.g)
  350. * let args = {
  351. * "name": "Mtfa"
  352. * }
  353. */
  354. public updateRecord(model: string, id: number, mArgs: any)
  355. {
  356. let args =
  357. [
  358. [id], mArgs
  359. ]
  360. return this.call(model, "write", args, null)
  361. }
  362.  
  363. /**
  364. * Get the User Context from the response of odoo server
  365. */
  366. private getContext()
  367. {
  368. let response = localStorage.getItem("token");
  369. let jsonData = JSON.parse(response);
  370. let context = jsonData["user_context"];
  371. return context;
  372. }
  373. }

通用类Utils.ts

  1. import { Injectable } from "@angular/core";
  2. import
  3. {
  4. AlertController, Loading,
  5. LoadingController, Toast, ToastController,
  6. ActionSheetController
  7. } from "ionic-angular";
  8.  
  9. @Injectable()
  10. export class Utils
  11. {
  12. private loading: Loading
  13.  
  14. constructor(private alrtCtrl: AlertController,
  15. private loadingCtrl: LoadingController,
  16. private toastCtrl: ToastController,
  17. private actionSheetCtrl: ActionSheetController)
  18. {
  19.  
  20. }
  21.  
  22. public presentAlert(title: string,
  23. message: string,
  24. buttons: [{}],
  25. subtitle?: string,
  26. enableBackdropDismiss?: boolean,
  27. inputs?: [{}]): void
  28. {
  29.  
  30. let alrt = this.alrtCtrl.create
  31. ({
  32. title: title,
  33. subTitle: subtitle,
  34. message: message,
  35. buttons: buttons,
  36. enableBackdropDismiss: enableBackdropDismiss,
  37. inputs: inputs
  38. })
  39.  
  40. alrt.present()
  41. }
  42.  
  43. public presentToast(message: string, duration?: number,
  44. dissmissOnPageChange?: boolean,
  45. position?: string,
  46. showCloseButton?: boolean,
  47. closeButtonText?: string): void
  48. {
  49. let toast = this.toastCtrl.create
  50. ({
  51. message: message,
  52. position: position,
  53. dismissOnPageChange: dissmissOnPageChange,
  54. duration: duration,
  55. showCloseButton: showCloseButton,
  56. closeButtonText: closeButtonText
  57. })
  58. toast.present()
  59. }
  60.  
  61. public presentLoading(content: string, duration?: number,
  62. dissmissOnPageChange?: boolean,
  63. enableBackDropDismiss?: boolean,
  64. showBackDrop?: boolean,
  65. spinner?: string): void
  66. {
  67. this.loading = this.loadingCtrl.create
  68. ({
  69. content: content,
  70. dismissOnPageChange: dissmissOnPageChange,
  71. duration: duration,
  72. enableBackdropDismiss: enableBackDropDismiss,
  73. showBackdrop: showBackDrop,
  74. spinner: spinner
  75. })
  76. this.loading.present()
  77. }
  78.  
  79. public dismissLoading(): void
  80. {
  81. this.loading.dismiss()
  82. }
  83.  
  84. public presentActionSheet(buttons: [{}], title: string, subtitle?: string,
  85. enableBackdropDismiss?: boolean): void
  86. {
  87. let actionCtrl = this.actionSheetCtrl.create
  88. ({
  89. buttons: buttons,
  90. subTitle: subtitle,
  91. title: title,
  92. enableBackdropDismiss: enableBackdropDismiss
  93. })
  94. actionCtrl.present()
  95. }
  96. }

ionic 访问odoo11之具体业务类api接口的更多相关文章

  1. 一次php访问sql server 2008的API接口的采坑

    2018年6月21日17:17:09,注意:不是详细文档,新手可能会看不懂 windows下安装 项目是sql server 2008的k3,php连接数据库写的API,因为是买的时候是别人的程序,测 ...

  2. ionic访问odoo 11接口

    在架设完毕odoo 11的网站之后,第一次面临手机app该如何访问后台网站的问题,是不是模式类似asp.net mvc 那样的模式,或者还存在其他的访问方法,带着这个疑问与困惑,开始的我的研究学习之路 ...

  3. Http下的各种操作类.WebApi系列~通过HttpClient来调用Web Api接口

    1.WebApi系列~通过HttpClient来调用Web Api接口 http://www.cnblogs.com/lori/p/4045413.html HttpClient使用详解(java版本 ...

  4. 熟练掌握HDFS的Java API接口访问

    HDFS设计的主要目的是对海量数据进行存储,也就是说在其上能够存储很大量文件(可以存储TB级的文件).HDFS将这些文件分割之后,存储在不同的DataNode上, HDFS 提供了两种访问接口:She ...

  5. Winform混合式开发框架访问Web API接口的处理

    在我的混合式开发框架里面,集成了WebAPI的访问,这种访问方式不仅可以实现简便的数据交换,而且可以在多种平台上进行接入,如Winform程序.Web网站.移动端APP等多种接入方式,Web API的 ...

  6. Java知多少(107)几个重要的java数据库访问类和接口

    编写访问数据库的Java程序还需要几个重要的类和接口. DriverManager类 DriverManager类处理驱动程序的加载和建立新数据库连接.DriverManager是java.sql包中 ...

  7. 如何让你的 Asp.Net Web Api 接口,拥抱支持跨域访问。

    由于 web api 项目通常是被做成了一个独立站点,来提供数据,在做web api 项目的时候,不免前端会遇到跨域访问接口的问题. 刚开始没做任何处理,用jsonp的方式调用 web api 接口, ...

  8. Asp.Net Web Api 接口,拥抱支持跨域访问。

    如何让你的 Asp.Net Web Api 接口,拥抱支持跨域访问. 由于 web api 项目通常是被做成了一个独立站点,来提供数据,在做web api 项目的时候,不免前端会遇到跨域访问接口的问题 ...

  9. Tomcat 配置 项目 到tomcat目录外面 和 域名绑定访问(api接口、前端网站、后台管理网站)

    先停止tomcat服务 1.进入apache-tomcat-7.0.68/conf/Catalina/localhost(如果之前还都没有启动过tomcat,是不会有此目录的,先启动一次再关闭,会自动 ...

随机推荐

  1. Linux 学习笔记之超详细基础linux命令 Part 9

    Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 8----------------- ...

  2. Java并发编程(七)深入剖析ThreadLocal

    一.对ThreadLocal的理解 ThreadLocal,很多地方叫做线程本地变量,也有些地方叫做线程本地存储,其实意思差不多.可能很多朋友都知道ThreadLocal为变量在每个线程中都创建了一个 ...

  3. 取消Eclipse等号、分号、空格代码自动补全

      本文主要参考了以下文章 http://www.cnblogs.com/a-zx/p/3388041.html 本文基于 Eclipse Java EE IDE for Web Developers ...

  4. 给 Linux 系统“减肥”,系统垃圾清理_系统安装与配置管理_Linux Today - Google Chrome

    给 Linux 系统"减肥",系统垃圾清理  2013/10/16  linux  系统安装与配置管理  评论  15,555 Linux 计算机安装后,在我们不断的使用过程中,因 ...

  5. 【PAT】1083 是否存在相等的差(20 分)

    //这题不是我耍流氓,实在太简单,只能直接贴代码了,凑个数 #include<stdio.h> int aaa[10005]={0}; int main(){ int N;scanf(&q ...

  6. PHP PC端支付宝扫码支付

    前面的文章已经描述过在蚂蚁金服开放平台创建应用签约等流程,详见:PHP App端支付宝支付,这里就不多说了,剩下的分两步,第一步是支付前的准备工作,也就是整合支付类文件,我已经整合好可以直接用,代码开 ...

  7. Hive-1.2.1_05_案例操作

    1. 建库建表 # 建库 create database exercise; # 建表 create table student(Sno int,Sname string,Sex string,Sag ...

  8. log4.net 配置 - 自定义过滤器按LoggerName过滤日志

    自定义过滤器按LoggerName过滤日志,本来想使用 PropertyFilter 来实现,后来研究发现一直不能成功,源代码debug了一下获取一直为null,时间关系只好用 StringMatch ...

  9. JVM虚拟机查找类文件的顺序

    JVM查找类文件的顺序: 在doc下使用set classpath=xxx, 如果没有配置classpath环境变量,JVM只在当前目录下查找要运行的类文件. 如果配置了classpath环境,JVM ...

  10. MATLAB三维作图——隐函数

    MATLAB三维作图——隐函数 作者:凯鲁嘎吉 - 博客园http://www.cnblogs.com/kailugaji/ 对于三维隐函数,没有显式表达式,无法通过Matlab现成的3-D画图函数 ...