123456789101112131415161718192021222324252627282930 |
- function httpError(err) {
- console.error(err);
- wx.hideLoading();
- wx.showToast({
- title: '请稍后再试!',
- })
- }
- export function httpCloud(params) {
- !params.noLoading && wx.showLoading();
- const par = params || {};
- wx.cloud.callFunction({
- // 云函数名称
- name: par.name,
- // 传给云函数的参数
- data: {
- ...(par.data || {}),
- type: par.type
- },
- success: function (res) {
- wx.hideLoading();
- if(!/ok/g.test(res.errMsg)) return httpError(res);
- if(res.result.code != 0) return wx.showToast({
- title: '请稍后再试!',
- })
- par.call && par.call(res.result.data);
- },
- fail: httpError
- })
- }
|