diff --git a/common/js/globalData.js b/common/js/globalData.js index 96de592..1ca02c2 100644 --- a/common/js/globalData.js +++ b/common/js/globalData.js @@ -1,5 +1,6 @@ export default { deptId: 101, + from: 'customer', initPageNum: 1, initPageSize: 5 } \ No newline at end of file diff --git a/common/js/request.js b/common/js/request.js index 0556ff0..b994517 100644 --- a/common/js/request.js +++ b/common/js/request.js @@ -6,9 +6,17 @@ export default { uni.addInterceptor('request', { invoke(args) { // request 触发前拼接 url - // args.url = 'https://www.opsoul.com' + args.url; + args.url = 'https://www.opsoul.com' + args.url; // args.url = 'http://192.168.2.3:80' + args.url; - args.url = 'http://127.0.0.1:80' + args.url; + // args.url = 'http://127.0.0.1:80' + args.url; + if (args.data) { + args.data.deptId = globalData.deptId; + args.data.from = globalData.from; + } + if (args.header) { + args.header.deptId = globalData.deptId; + args.header.from = globalData.from; + } // console.log("停止触发"); // return false; }, @@ -61,14 +69,8 @@ export default { } }) }, - async login() { - // 从缓存中获取登录信息 - let userInfo = uni.getStorageSync('userProfile'); - if (userInfo) { - return true; - } - - userInfo = await wx.getUserProfile({ + async login() { + let userInfo = await wx.getUserProfile({ desc: '用于小程序登录' }); console.log("从微信获取基本用户信息:" + userInfo); @@ -110,7 +112,7 @@ export default { console.log("通过后台服务获取用户信息:" + userInfo); if (!userInfo || userInfo.customerId == null || userInfo.customerId == undefined) { uni.showToast({ - icon: 'error', + icon: 'none', title: '微信用户信息获取失败,请退出小程序重试' }) return false; @@ -225,5 +227,26 @@ export default { data: params }) return res[1].data; - } + }, + async listByStep(params = {goodsCategoryId : null}) { + let res = await uni.request({ + url: '/goods/deptcategory/listByStep', + method: 'POST', + data: params + }) + return res[1].data; + }, + async uploadFile(filePath) { + let res = await uni.uploadFile({ + url: this.address + '/tool/qiniu/upload', + filePath: filePath, + name: 'uploadFile' + }) + let resStr = res[1].data; + let resObj = {}; + if (resStr != null && resStr.length > 0) { + resObj = JSON.parse(resStr); + } + return resObj; + }, } diff --git a/pages/index/home.vue b/pages/index/home.vue index 2a59d14..2ffcc75 100644 --- a/pages/index/home.vue +++ b/pages/index/home.vue @@ -1,24 +1,28 @@ @@ -87,7 +92,7 @@ -