-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
81 lines (60 loc) · 1.65 KB
/
app.js
File metadata and controls
81 lines (60 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { DB } from "./db/DB.js";
const request = require('./utils/request.js')
const utils = require('./utils/util.js')
var marketList = new DB();
var dataObj = require("data/data.js")
App({
request: request,
marketList: marketList,
utils,
/**
* 当小程序初始化完成时,会触发 onLaunch(全局只触发一次)
*/
onLaunch: function () {
var storageData = wx.getStorageSync('marketList');
if (!storageData) {
this.getMarketBase();
this.getFinance();
}
},
getMarketBase: function () {
var url = this.globalData.exbaseBaseUrl + "/GetExbaseInfo";
wx.request({
url: url,
success: function (res) {
dataObj.marketList.marketBase = res.data.base;
wx.clearStorageSync();
wx.setStorageSync('marketList', dataObj.marketList);
}
})
},
getFinance:function(){
var url = "https://op.juhe.cn/onebox/exchange/query?key=ebb4522dcc134fabac4e8b29c77eac47";
wx.request({
url: url,
success:function(res){
console.log(res.data.result.list[0][5]/100)
dataObj.marketList.finance = res.data.result.list[0][5] /100;
wx.setStorageSync('marketList', dataObj.marketList)
}
})
},
/**
* 当小程序启动,或从后台进入前台显示,会触发 onShow
*/
onShow: function (options) {
},
/**
* 当小程序从前台进入后台,会触发 onHide
*/
onHide: function () {
},
/**
* 当小程序发生脚本错误,或者 api 调用失败时,会触发 onError 并带上错误信息
*/
onError: function (msg) {
},
globalData: {
exbaseBaseUrl: "http://45.77.25.254/api_v1/"
}
})