methods.js
1.7 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
"use strict";
var common_vendor = require("../common/vendor.js");
var methods = {
upload(url, callBack) {
let arr = {};
common_vendor.index.chooseImage({
success: (chooseImageRes) => {
const tempFilePaths = chooseImageRes.tempFilePaths;
arr["avatar"] = tempFilePaths[0];
common_vendor.index.uploadFile({
url,
filePath: tempFilePaths[0],
name: "file",
formData: {
user: "test",
token: common_vendor.index.getStorageSync("token")
},
success: (uploadFileRes) => {
console.log(JSON.parse(uploadFileRes.data), "\u56FE\u7247\u8DEF\u5F84");
arr["upImg"] = JSON.parse(uploadFileRes.data).data.url;
callBack(arr);
}
});
}
});
},
pay(res) {
if (res.appId) {
common_vendor.index.requestPayment({
"provider": "wxpay",
timeStamp: res.timeStamp,
nonceStr: res.nonceStr,
package: res.package,
signType: res.signType,
appid: res.appId,
paySign: res.paySign,
success(res2) {
console.log("\u652F\u4ED8\u6210\u529F");
common_vendor.index.showToast({ title: "\u652F\u4ED8\u6210\u529F~" });
setTimeout(() => {
common_vendor.index.navigateBack();
}, 1500);
},
fail(e) {
console.log("\u652F\u4ED8\u5931\u8D25", e);
common_vendor.index.showToast({ title: "\u652F\u4ED8\u53D6\u6D88~", icon: "none" });
}
});
}
},
showTN(title) {
common_vendor.index.showToast({ title, icon: "none" });
setTimeout(() => {
common_vendor.index.navigateBack();
}, 1e3);
}
};
exports.methods = methods;