123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- //const ip = 'http://192.168.0.251/obpm';
- const ip = 'https://tdmtest.liugong.com/obpm';
- /**
- * 全部接口
- */
- const urls = {
- ip: ip,
- home: ip + '/app/home/index', //首页数据
- login: ip + '/runtime/login/loginWithCiphertext2', //用户登陆
- myprofile: ip + '/runtime/users/myprofile', //用户登陆
-
- user_register: ip + '/app/user/register', //用户注册
- accessToken: ip + '/rest/accessToken?secret=11ec-db2f-ca248770-8df3-890eb68cafa4', //用户注册
- // wt_list:ip + '/runtime/__gAPYBW4YxB3UePM3lqO/views/__km3aURKW95BHxp12XVt/documents?parentId=&sortCol=&sortStatus=&lines=10&treedocid=&parentNodeId=&_docid=&_fieldid=&isRelate=&startDate=&endDate=&parentParam=&isQueryButton=false',
- wt_list:ip + '/runtime/__gAPYBW4YxB3UePM3lqO/views/__km3aURKW95BHxp12XVt/documents?lines=10&isQueryButton=false',//获取列表数据、更换viewID
-
- wt_xqsh:ip + '/runtime/__gAPYBW4YxB3UePM3lqO/views/__MhHakFCgVJAm81MFUnt/documents?lines=10&isQueryButton=false',
- wt_sysh:ip + '/runtime/__gAPYBW4YxB3UePM3lqO/views/__r4IN5HOqV4HIips1s0Q/documents?lines=10&isQueryButton=false',
- wt_xqpz:ip + '/runtime/__gAPYBW4YxB3UePM3lqO/views/__yoOF16IOiZdmrbDOujU/documents?lines=10&isQueryButton=false',
- wt_sypz:ip + '/runtime/__gAPYBW4YxB3UePM3lqO/views/__b6gD17cP1g4gFdTq0Ox/documents?lines=10&isQueryButton=false',
- wt_rwfp:ip + '/runtime/__gAPYBW4YxB3UePM3lqO/views/__m9w03S06KHbg3KioRIh/documents?lines=10&isQueryButton=false',
-
- documents: ip + '/runtime/__gAPYBW4YxB3UePM3lqO/documents/', //获取文档详情
- empty: ip + '/runtime/__gAPYBW4YxB3UePM3lqO/forms/__0FLGNncOS1lz0T9jsFn/empty?formId=__0FLGNncOS1lz0T9jsFn&appId=__gAPYBW4YxB3UePM3lqO', //创建委托单文档
- }
- /**
- * 封装的http请求wt_
- */
- const request = (opt) => {
- opt = opt || {};
- opt.url = opt.url || '';
- opt.data = opt.data || null;
- opt.method = opt.method || 'GET';
- opt.contentType = opt.contentType || 'application/json;charset=UTF-8'
- opt.header = opt.header || {
- "Content-Type": opt.contentType,
- //"Authorization": getUser().token ? getUser().token : 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NzAxMzYzMjEsInN1YiI6IkFpNmhsbGhOalMydWxsOVRLR2IiLCJleHAiOjE2NzAxMzk5MjEsIm5iZiI6MTY3MDEzNjMyMX0.cNQpCWUwVjA2jkrKCnybIfxl6iQQJ-xj3S8dmQSmQ3A',
- "accessToken": getUser().accessToken || ''
- };
- opt.loading = opt.loading || 'true';
- opt.success = opt.success || function() {};
- console.log("**************************************参数调式***************************************************");
- console.log("请求地址:" + opt.url + " 请求参数:" + JSON.stringify(opt.data));
- console.log("************************************************************************************************");
- if (opt.loading == 'true') {
- uni.showLoading({
- title: '正在加载',
- mask: true
- });
- }
- uni.request({
- url: opt.url,
- data: opt.data,
- method: opt.method,
- header: opt.header,
- dataType: 'json',
- success: res => {
- setTimeout(() => {
- uni.hideLoading();
- }, 500)
- /*******************系统内部错误***************************/
- if (res.data.code === 500) {
- uni.showModal({
- content: res.data.msg,
- showCancel: false
- });
- return;
- }
- if (res.statusCode === 401) {
- uni.removeStorageSync('user');
- uni.showModal({
- title: '提示',
- content: '登录超时,请先登陆!',
- success: res => {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/login'
- })
- }
- }
- });
- return;
- }
- opt.success(res);
- },
- fail: e => {
- uni.hideLoading();
- uni.getNetworkType({
- success: res => {
- if (res.networkType == 'none') {
- uni.showModal({
- content: '当前网络不可用,请检查网络稍后重试',
- showCancel: false
- });
- } else {
- uni.showModal({
- content: '服务异常,请稍后重试',
- showCancel: false
- })
- }
- }
- });
- }
- })
- }
- const getUser = () => {
- return uni.getStorageSync('user');
- }
- module.exports = {
- urls,
- request,
- getUser
- };
|