| 12
 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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 
 | const app = getApp();
 const typeMap = {
 "arrival-report": "/order/psn027/v1",
 "customs-clearance": "/order/psn026/v1",
 "base-info": "/order/base/info/v1",
 "pre-allocated-manifest": "/order/psn004/v1",
 };
 
 
 function getData(type, masterBlNo) {
 if (!masterBlNo || masterBlNo.length === 0) {
 wx.showModal({
 title: "提示",
 content: "请输入提运单号",
 showCancel: false,
 });
 return Promise.reject();
 }
 
 wx.showLoading({
 title: "加载中",
 });
 
 return new Promise((resolve, reject) => {
 wx.request({
 url: app.globalData.baseUrl + typeMap[type],
 data: {
 masterBlNo,
 },
 header: { "content-type": "application/json" },
 method: "GET",
 dataType: "json",
 responseType: "text",
 success: (result) => {
 wx.hideLoading();
 
 if (result.data.code != 200) {
 wx.showModal({
 showCancel: false,
 title: "错误",
 content: result.data.msg,
 });
 }
 if (!result.data.data || result.data.code != 200) {
 reject();
 }
 
 resolve(result.data);
 },
 fail: (e) => {
 console.log(e.message);
 wx.showModal({
 showCancel: false,
 title: "错误",
 content: "请检查网络!",
 });
 reject();
 },
 complete: () => {
 
 setStorage(masterBlNo);
 },
 });
 });
 }
 
 
 function getStorage() {
 const data = wx.getStorageSync("history");
 if (data === "") return [];
 return JSON.parse(data);
 }
 
 
 function setStorage(value) {
 const oldData = getStorage();
 
 const isExist = oldData.some((item) => item.value === value);
 if (isExist) return Promise.reject();
 
 return new Promise((resolve, reject) => {
 wx.setStorage({
 key: "history",
 
 data: JSON.stringify(oldData.concat([{ time: +new Date(), value }])),
 success(r) {
 resolve(r);
 },
 fail(e) {
 reject(e);
 },
 });
 });
 }
 module.exports = {
 getData,
 setStorage,
 getStorage,
 };
 
 |