From feb7d7b6edefead94ffad377d1243f5ced3b4286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=B2=E4=B9=88=E4=BA=86?= Date: Tue, 4 Apr 2023 08:47:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=8E=A5=E5=8F=A3=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api/device.js | 10 ++ common/css/base.scss | 1 + common/js/list.js | 35 +++---- common/js/request.js | 60 ++++++------ common/js/share.js | 18 ++-- components/Cn-empty/Cn-empty.vue | 6 +- pages/index/comp/indexZhuYongHu.vue | 139 ++++++++-------------------- pages/index/index.vue | 84 ++++++++++++++--- 8 files changed, 184 insertions(+), 169 deletions(-) create mode 100644 common/api/device.js diff --git a/common/api/device.js b/common/api/device.js new file mode 100644 index 0000000..77f23b0 --- /dev/null +++ b/common/api/device.js @@ -0,0 +1,10 @@ +import request from '../js/request'; +import config from '../js/config'; + +export function getDeviceList(params) { + return request({ + url: '/EquipmentDelivery/queryEquipmentByProject', + method: 'post', + data: params, + }); +} diff --git a/common/css/base.scss b/common/css/base.scss index e70ca06..a55d842 100644 --- a/common/css/base.scss +++ b/common/css/base.scss @@ -234,6 +234,7 @@ page { /deep/ .uni-forms-item:last-of-type { margin-bottom: 0 !important; } + position: relative; } .status-point-success { diff --git a/common/js/list.js b/common/js/list.js index 1ec82fe..a2eafd4 100644 --- a/common/js/list.js +++ b/common/js/list.js @@ -1,38 +1,38 @@ export default { - onPullDownRefresh () { + onPullDownRefresh() { this.store && this.store.reload(); this.store.loadedCallback = () => { uni.stopPullDownRefresh(); }; }, - onReachBottom () { - if (this.store.status != "noMore") { + onReachBottom() { + if (this.store.status != 'noMore') { this.store.next && this.store.next(); } }, - data () { + data() { return { store: {}, }; }, methods: { - DataSource (url) { + DataSource(url) { var me = this; return { data: [], - status: "more", + status: 'more', empty: false, total: 0, header: { - "Content-Type": "application/json;charset=UTF-8", + 'Content-Type': 'application/json;charset=UTF-8', }, params: { currentPage: 1, pageSize: 20, }, - reload () { + reload() { this.data = []; - this.status = "loading"; + this.status = 'loading'; this.empty = false; this.params.currentPage = 1; this.next(); @@ -40,28 +40,31 @@ export default { callBack: null, firstCallBack: null, loadedCallback: null, - next () { + next() { me.$request({ url: url, data: this.params, header: this.header, - method: "POST", + method: 'POST', }).then((res) => { console.warn(res); - let resultData = res.rows || res.data?.list || res.data?.records || []; + let resultData = + res.data?.list || res.data?.records || []; if (this.params.currentPage == 1) { this.data = resultData; if (resultData.length == 0 || resultData == 0) { this.empty = true; - } else if (resultData.length < this.params.pageSize) { - this.status = "noMore"; + } else if ( + resultData.length < this.params.pageSize + ) { + this.status = 'noMore'; } else if (res.total == resultData.length) { - this.status = "noMore"; + this.status = 'noMore'; } } else { this.data.push(...resultData); if (resultData.length < this.params.pageSize) { - this.status = "noMore"; + this.status = 'noMore'; } } diff --git a/common/js/request.js b/common/js/request.js index 88744e2..3f0b9c4 100644 --- a/common/js/request.js +++ b/common/js/request.js @@ -1,80 +1,86 @@ - -import config from "./config"; -let arr = [] +import config from './config'; +let arr = []; export default (options = {}) => { if (options.data == undefined) { - options.data = {} + options.data = {}; } // 防止接口重复点击 if (arr.indexOf(options.url) === -1) { - arr.push(options.url) + arr.push(options.url); } else { return new Promise((resolve, reject) => { reject({ code: -1, - msg: '请勿重复提交' - }) - }) + msg: '请勿重复提交', + }); + }); } return new Promise((reslove, reject) => { uni.request({ - url: options.url.indexOf('http') === -1 ? config.domain + options.url : options.url, + url: + options.url.indexOf('http') === -1 + ? config.domain + options.url + : options.url, data: { ...options.data, }, header: { - "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", - "Authorization":"12", - ...options.header + 'Content-Type': 'application/json;charset=UTF-8', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", + Authorization: '12', + ...options.header, }, method: options.method || 'GET', success: async (res) => { console.log(res); if (arr.indexOf(options.url) > -1) { - arr.splice(arr.indexOf(options.url), 1) + arr.splice(arr.indexOf(options.url), 1); } - if (res.data.resultCode !== 10000 && res.data.code !== 'A0000' ) { - errHandler(res.data) - reject(res.data) + if ( + res.data.resultCode !== 10000 && + res.data.code !== 'A0000' + ) { + errHandler(res.data); + reject(res.data); } else { - reslove(res.data) + reslove(res.data); } }, fail: (err) => { if (arr.indexOf(options.url) > -1) { - arr.splice(arr.indexOf(options.url), 1) + arr.splice(arr.indexOf(options.url), 1); } - reject(err) + reject(err); uni.showToast({ icon: 'none', title: '网络异常,请稍后再试', - }) + }); uni.reLaunch({ url: '/pages/user/login', }); }, - }) - }) -} + }); + }); +}; /** * 错误处理 * @param {Number} code 错误码 */ -function errHandler (res) { +function errHandler(res) { switch (res.resultCode) { case '401': // #ifdef MP uni.removeStorageSync('Cookie'); uni.clearStorageSync(); // #endif - uni.reLaunch({ url: '/pages/user/login' }) - break + uni.reLaunch({ url: '/pages/user/login' }); + break; default: uni.showToast({ title: res.msg || '服务端未知错误', duration: 2000, - icon: 'none' + icon: 'none', }); break; } diff --git a/common/js/share.js b/common/js/share.js index 810ab21..d8eb7b0 100644 --- a/common/js/share.js +++ b/common/js/share.js @@ -1,20 +1,18 @@ export default { - data () { - return { - - }; + data() { + return {}; }, // #ifdef MP - onShareAppMessage (res) { + onShareAppMessage(res) { return { - title: "荣创科技", - path: "/pages/index/index", + title: '荣创科技', + path: '/pages/index/index', }; }, - onShareTimeline () { + onShareTimeline() { return { - title: "荣创科技", - path: "/pages/index/index", + title: '荣创科技', + path: '/pages/index/index', }; }, // #endif diff --git a/components/Cn-empty/Cn-empty.vue b/components/Cn-empty/Cn-empty.vue index a681d30..e5c1f00 100644 --- a/components/Cn-empty/Cn-empty.vue +++ b/components/Cn-empty/Cn-empty.vue @@ -34,9 +34,10 @@ export default { align-items: center; position: absolute; left: 50%; - top: 50%; - transform: translate(-50%, -50%); + top: 0%; + transform: translate(-50%, 0); } + .empty-text { margin-top: 30rpx; font-size: 28rpx; @@ -45,6 +46,7 @@ export default { color: #666; line-height: 32rpx; } + .empty-img { width: 244rpx; height: 320rpx; diff --git a/pages/index/comp/indexZhuYongHu.vue b/pages/index/comp/indexZhuYongHu.vue index 5d0f4ee..a120519 100644 --- a/pages/index/comp/indexZhuYongHu.vue +++ b/pages/index/comp/indexZhuYongHu.vue @@ -32,17 +32,32 @@ - - + +