From ebd22b0eee30102e1ca5ad831237fffb8379e5be Mon Sep 17 00:00:00 2001 From: "geng.tang@qq.com" Date: Tue, 2 Jan 2024 21:41:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=94=B6=E8=B4=A7=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/captcha.js | 8 +- api/order.js | 4 +- node_modules/js/package.json | 46 ++------ package-lock.json | 43 ++++--- pages.json | 13 ++- pages/order/delivery.vue | 214 +++++++++++++++++++++++++++++++---- pages/order/detail.vue | 30 +++-- pages/order/index.vue | 4 +- utils/request/index.js | 1 + 9 files changed, 267 insertions(+), 96 deletions(-) diff --git a/api/captcha.js b/api/captcha.js index 6fff247..51f40ae 100755 --- a/api/captcha.js +++ b/api/captcha.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // api地址 const api = { image: 'captcha/image', - sendSmsCaptcha: 'captcha/sendSmsCaptcha' + sendSmsCode: '/sendSmsCaptcha' } // 图形验证码 @@ -12,6 +12,6 @@ export function image() { } // 发送短信验证码 -export function sendSmsCaptcha(data) { - return request.post(api.sendSmsCaptcha, data, { load: false }) -} +export const sendSmsCode = (data) => { + return request.post(api.sendSmsCode, data) +} \ No newline at end of file diff --git a/api/order.js b/api/order.js index 1113f06..4431fc2 100755 --- a/api/order.js +++ b/api/order.js @@ -38,8 +38,8 @@ export function cancel(orderId, data) { } // 确认收货 -export function receipt(orderId, data) { - return request.post(api.receipt, { orderId, ...data }) +export function receipt(data) { + return request.post(api.receipt, data) } // 核销二维码 diff --git a/node_modules/js/package.json b/node_modules/js/package.json index 3aa8895..09f994c 100644 --- a/node_modules/js/package.json +++ b/node_modules/js/package.json @@ -1,44 +1,12 @@ { - "_args": [ - [ - "js@0.1.0", - "E:\\202308\\yunxinwei-uniapp" - ] - ], - "_development": true, - "_from": "js@0.1.0", - "_id": "js@0.1.0", - "_inBundle": false, - "_integrity": "sha512-ZBbGYOpact8QAH9RprFWL4RAESYwbDodxiuDjOnzwzzk9pBzKycoifGuUrHHcDixE/eLMKPHRaXenTgu1qXBqA==", - "_location": "/js", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "js@0.1.0", - "name": "js", - "escapedName": "js", - "rawSpec": "0.1.0", - "saveSpec": null, - "fetchSpec": "0.1.0" - }, - "_requiredBy": [ - "#DEV:/" - ], - "_resolved": "https://registry.npmmirror.com/js/-/js-0.1.0.tgz", - "_spec": "0.1.0", - "_where": "E:\\202308\\yunxinwei-uniapp", - "author": { - "name": "Marco Aurelio", - "email": "thecoreh@gmail.com" - }, + "name": "js", + "description": "A better `node -p`.", + "author": "Marco Aurelio ", + "version": "0.1.0", "bin": { - "js": "bin/js" + "js": "./bin/js" }, "dependencies": { "commander": "~1.1.1" - }, - "description": "A better `node -p`.", - "name": "js", - "version": "0.1.0" -} + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c48802e..f388079 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,52 +1,69 @@ { + "name": "yunxinwei-uniapp", + "lockfileVersion": 3, "requires": true, - "lockfileVersion": 1, - "dependencies": { - "@dcloudio/types": { + "packages": { + "": { + "dependencies": { + "dayjs": "^1.11.10", + "luch-request": "^3.0.8" + }, + "devDependencies": { + "js": "^0.1.0", + "js-md5": "^0.7.3" + } + }, + "node_modules/@dcloudio/types": { "version": "2.6.12", "resolved": "https://registry.npmjs.org/@dcloudio/types/-/types-2.6.12.tgz", "integrity": "sha512-mrCMwcINy1IFjU9VUqLeWBkj404yWs5paLDttBcA+eqUjanuUQbBcTVPqlrGgkyzLXDcV2oDDZRSNxNpXi4kMQ==" }, - "commander": { + "node_modules/commander": { "version": "1.1.1", "resolved": "https://registry.npmmirror.com/commander/-/commander-1.1.1.tgz", "integrity": "sha512-71Rod2AhcH3JhkBikVpNd0pA+fWsmAaVoti6OR38T76chA7vE3pSerS0Jor4wDw+tOueD2zLVvFOw5H0Rcj7rA==", "dev": true, - "requires": { + "dependencies": { "keypress": "0.1.x" + }, + "engines": { + "node": ">= 0.6.x" } }, - "dayjs": { + "node_modules/dayjs": { "version": "1.11.10", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.10.tgz", "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" }, - "js": { + "node_modules/js": { "version": "0.1.0", "resolved": "https://registry.npmmirror.com/js/-/js-0.1.0.tgz", "integrity": "sha512-ZBbGYOpact8QAH9RprFWL4RAESYwbDodxiuDjOnzwzzk9pBzKycoifGuUrHHcDixE/eLMKPHRaXenTgu1qXBqA==", "dev": true, - "requires": { + "dependencies": { "commander": "~1.1.1" + }, + "bin": { + "js": "bin/js" } }, - "js-md5": { + "node_modules/js-md5": { "version": "0.7.3", "resolved": "https://registry.npmmirror.com/js-md5/-/js-md5-0.7.3.tgz", "integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ==", "dev": true }, - "keypress": { + "node_modules/keypress": { "version": "0.1.0", "resolved": "https://registry.npmmirror.com/keypress/-/keypress-0.1.0.tgz", "integrity": "sha512-x0yf9PL/nx9Nw9oLL8ZVErFAk85/lslwEP7Vz7s5SI1ODXZIgit3C5qyWjw4DxOuO/3Hb4866SQh28a1V1d+WA==", "dev": true }, - "luch-request": { + "node_modules/luch-request": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/luch-request/-/luch-request-3.0.8.tgz", "integrity": "sha512-5ZVp1y4tFaizbGMOuQwbeyfHnf4PhQAwQ3S1Fm1tS7juMoB14pXslxWriElhiSq6ytYYW0KVC8RShfHiNujFcQ==", - "requires": { + "dependencies": { "@dcloudio/types": "^2.0.16" } } diff --git a/pages.json b/pages.json index e726a86..45bdc27 100755 --- a/pages.json +++ b/pages.json @@ -293,8 +293,7 @@ { "path": "pages/order/delivery", "style": { - "navigationBarTitleText": "确认收货", - "enablePullDownRefresh": true + "navigationBarTitleText": "确认收货" } }, { @@ -513,5 +512,15 @@ "custom": { "^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue" } + }, + "condition" : { //模式配置,仅开发期间生效 + "current": 0, //当前激活的模式(list 的索引项) + "list": [ + { + "name": "", //模式名称 + "path": "", //启动页面,必选 + "query": "" //启动参数,在页面的onLoad函数里面得到 + } + ] } } diff --git a/pages/order/delivery.vue b/pages/order/delivery.vue index 275f0e8..66ca176 100755 --- a/pages/order/delivery.vue +++ b/pages/order/delivery.vue @@ -36,17 +36,29 @@ + + + + + + {{time}} {{text}} + + + + + + {{ submitText }} - + @@ -58,10 +70,51 @@ import { pageOrder, removeOrder, - receiptOrder, + receipt, getOrder } from '@/websoft/api/order.js' - import { fileUrl } from '@/config.js'; + import { sendSmsCode } from '@/api/captcha.js' + import { fileUrl } from '@/config.js' + import { isMobile } from '@/utils/verify' + + + // 表单验证规则 + const rules = { + receiptPhone: [{ + required: true, + message: '请输入手机号', + trigger: ['blur', 'change'] + }, { + // 自定义验证函数 + validator: (rule, value, callback) => { + // 返回true表示校验通过,返回false表示不通过 + return isMobile(value) + }, + message: '手机号码不正确', + // 触发器可以同时用blur和change + trigger: ['blur'], + }], + captcha: [{ + required: true, + message: '请输入验证码', + trigger: ['blur', 'change'] + }], + emergentUser: [{ + required: true, + message: '请输入紧急联系人', + trigger: ['blur', 'change'] + }], + officeAddress: [{ + required: true, + message: '请输入单位地址', + trigger: ['blur', 'change'] + }], + homeAddress: [{ + required: true, + message: '请输入家庭地址', + trigger: ['blur', 'change'] + }], + } export default { data() { @@ -69,12 +122,24 @@ form: {}, order: {}, orderSourceData: [], + // 验证码(主要代码,直接复制使用即可) + time: '', + text: '获取验证码', + receiptPhone: '', + captcha: '', + emergentUser: '', + officeAddress: '', + homeAddress: '', // 按钮禁用 - disabled: false, + // disabled: false, submitText: '证件已上传并确认收货', } }, + // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕 + onReady() { + this.$refs.uForm.setRules(this.rules) + }, /** * 生命周期函数--监听页面加载 */ @@ -88,48 +153,116 @@ methods: { // 加载订单 - getData(){ + getData() { const app = this const { orderId } = this getOrder(orderId).then(res => { - console.log("res: ",res); app.order = res.data if(res.data.orderSourceData.length > 0){ app.orderSourceData = JSON.parse(res.data.orderSourceData) } }) }, + //获取验证码(主要代码,直接复制使用即可) + getCaptcha() { + if(this.disabled){ + uni.showToast({ + title: '请耐心等待', + icon: 'none' + }) + return + } + var that = this; + + if (!that.receiptPhone) { + uni.showToast({ + title: '请输入手机号', + icon: 'none' + }) + return + } + console.log('that====: '); + sendSmsCaptcha({ + phone: that.receiptPhone, + type: 'RECEIPT' + }).then(result => { + console.log(result) + if(result){ + if(result.code == 0) { + that.$success("发送短信验证码成功") + that.orderSourceData = [] + // 刷新订单列表 + that.getData() + + that.disabled = true + that.setInterValFunc() + } else { + that.$toast(result.message) + } + } + + }).catch(err => { + console.log('e2: ',err); + that.$toast(err.message) + }).finally(e => { + console.log('e3: ',e); + }) + }, + + setInterValFunc() { + this.time = 60; + this.text = '秒'; + this.setTime = setInterval(() => { + if (this.time - 1 == 0) { + this.time = ''; + this.text = '重新获取'; + this.code = ''; + this.disabled = false; + clearInterval(this.setTime); + } else { + this.disabled = true; + this.time--; + } + }, 1000); + }, + // 重置 - resetting(){ + /* resetting(){ const app = this const { orderId } = app - receiptOrder({ - orderId, - orderSourceData: '' + receipt({ + orderId: orderId, + orderSourceData: '', }).then(result => { app.$success("重置成功") app.orderSourceData = [] - // 刷新订单列表 + receiptPhone = '' + captcha = '' + emergentUser = '' + officeAddress = '' + homeAddress = '' + time = '' + text = '获取验证码' app.getData() }) - }, + }, */ // 表单提交 handleSubmit() { const app = this - const { orderId,orderSourceData } = app + const { orderId,orderSourceData,captcha,receiptPhone,emergentUser,officeAddress, homeAddress } = app if(orderSourceData.length < 5) { return } - receiptOrder({ - orderId, - orderSourceData: JSON.stringify(orderSourceData) - }).then(result => { - app.$success("上传成功") - uni.navigateBack() + receipt(app).then(result => { + if(result.code == 0) { + app.$success("上传成功") + uni.navigateBack() + } else { + app.$toast(result.message) + } }).catch(err => { app.$toast(err.message) }) - }, // 上传图片 @@ -219,9 +352,9 @@ background: linear-gradient(to right, $main-bg, $main-bg2); // 禁用按钮 - &.disabled { + /* &.disabled { opacity: 0.6; - } + } */ } } @@ -328,4 +461,39 @@ width: 700rpx; margin: 20rpx auto; } + + .captcha_input { + font-size: 28rpx; + font-weight: 400; + color: #CACACA; + } + + .yanzhengma { + position: absolute; + right: 0; + top: -8rpx; + bottom: 0; + width: 140rpx; + height: 60rpx; + line-height: 60rpx; + text-align: center; + background: #00BD87; + border-radius: 30rpx; + font-size: 22rpx; + font-family: PingFang SC; + font-weight: 500; + color: #FFFFFF; + } + + .captcha-item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 10rpx; + border-bottom: 3rpx solid #DDDDDD; + margin-bottom: 25rpx; + position: relative; + } + + diff --git a/pages/order/detail.vue b/pages/order/detail.vue index 1fdc125..95d97dc 100755 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -442,11 +442,16 @@ - + 逾期天数 {{ item.expirationDay }}天 + + 剩余天数 + {{ item.expirationDay }}天 + + @@ -639,7 +644,7 @@ app.isLoading = true OrderApi.getOrder(app.orderId) .then(result => { - console.log("result: ", result); + console.log("result: {}", result); const order = result.data app.order = order app.equipment = result.data.equipment @@ -812,15 +817,18 @@ content: '确认收到商品了吗?', success(o) { if (o.confirm) { - OrderApi.receipt(orderId) - .then(result => { - // 显示成功信息 - app.$success(result.message) - setTimeout(() => { - // 刷新当前订单数据 - app.getOrderDetail(true) - }, 1500) - }) + // OrderApi.receipt(orderId) + // .then(result => { + // // 显示成功信息 + // app.$success(result.message) + // setTimeout(() => { + // // 刷新当前订单数据 + // app.getOrderDetail(true) + // }, 1500) + // }) + this.$navTo('pages/order/delivery', { + orderId + }) } } }); diff --git a/pages/order/index.vue b/pages/order/index.vue index 325b06d..7ff3ebf 100755 --- a/pages/order/index.vue +++ b/pages/order/index.vue @@ -50,10 +50,10 @@ v-if="item.orderStatus == 30">设备编号:{{ item.equipment.equipmentCode }} 设备名称:{{ item.equipmentGoods.goodsName }} 设备型号:{{ item.equipmentGoods.batteryModel }} - 逾期状态: + 逾期状态: (已逾期{{ Math.abs(item.expirationDay) }}天) 逾期状态: 即将过期 + v-if="item.payStatus == 10 && item.expirationDay < 7 && item.expirationDay > 0">逾期状态: 即将过期