app.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //app.js
  2. import WxAuthor from './utils/WxAuthor'
  3. App({
  4. onLaunch: function() {
  5. let self = this;
  6. // 登录
  7. new WxAuthor(self)
  8. },
  9. globalData: {
  10. userId: {
  11. openid: '',
  12. unionid: ''
  13. },
  14. userInfo: null,
  15. defaultAddress: null,
  16. fcodeErr: '',
  17. backLogin: false,
  18. arrayTree: [],
  19. fromSource: '',
  20. channel: '欧耶商城',
  21. record: null,
  22. card_type: ''
  23. },
  24. setFromSource(fromSource) {
  25. this.globalData.fromSource = fromSource
  26. },
  27. checkDefaultAddress(address) {
  28. this.globalData.defaultAddress = address
  29. },
  30. clearAddress() {
  31. this.globalData.defaultAddress = null
  32. },
  33. setArrayTree(tree) {
  34. this.globalData.arrayTree = tree
  35. },
  36. setCardType(card_type) {
  37. this.globalData.card_type = card_type
  38. },
  39. showToast(title, icon, duration){
  40. wx.showToast({
  41. icon: icon || 'none',
  42. title,
  43. duration: 2000 || duration
  44. })
  45. },
  46. trim(str) {
  47. str = str.replace(/\s+/g, "")
  48. return str
  49. },
  50. checkCurrentRecord(record) {
  51. this.globalData.record = record
  52. },
  53. clearRecord() {
  54. this.globalData.record = null
  55. },
  56. getValueByKey(key = '', data = []){
  57. if(!data.length) return {}
  58. return data.filter(val => val.card_type === key)[0] || {}
  59. },
  60. })