12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- //app.js
- import WxAuthor from './utils/WxAuthor'
- App({
- onLaunch: function() {
- let self = this;
- // 登录
- new WxAuthor(self)
- },
- globalData: {
- userId: {
- openid: '',
- unionid: ''
- },
- userInfo: null,
- defaultAddress: null,
- fcodeErr: '',
- backLogin: false,
- arrayTree: [],
- fromSource: '',
- channel: '欧耶商城',
- record: null,
- card_type: ''
- },
- setFromSource(fromSource) {
- this.globalData.fromSource = fromSource
- },
- checkDefaultAddress(address) {
- this.globalData.defaultAddress = address
- },
- clearAddress() {
- this.globalData.defaultAddress = null
- },
- setArrayTree(tree) {
- this.globalData.arrayTree = tree
- },
- setCardType(card_type) {
- this.globalData.card_type = card_type
- },
- showToast(title, icon, duration){
- wx.showToast({
- icon: icon || 'none',
- title,
- duration: 2000 || duration
- })
- },
- trim(str) {
- str = str.replace(/\s+/g, "")
- return str
- },
- checkCurrentRecord(record) {
- this.globalData.record = record
- },
- clearRecord() {
- this.globalData.record = null
- },
- getValueByKey(key = '', data = []){
- if(!data.length) return {}
- return data.filter(val => val.card_type === key)[0] || {}
- },
- })
|