jiangping
2024-07-16 39613118a5bae23c45498c4f5a939e83595f99f5
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
import { baseUrl } from "./config"
 
export function request(options){
  return new Promise(resolve => {
    wx.request({
      url: baseUrl + options.url,
      data: options.options || {},
      method: options.method || "GET",
      header: {
        'content-type': 'application/x-www-form-urlencoded',
      },
      timeout: 12000,
      success: (res) => {
        if (res.code === 0) {
          // res.msg && toast(res.msg)
          resolve(res.data || true)
        } else {
          res.msg && toast(res.msg || '发生错误', 'none')
          resolve(res.data || false)
        }
      },
      fail() {
        wxToast('网络错误', 'none')
      }
    })
  } )
}