From e5d13a791f907dd2db5e77798d8a7a509ae41de9 Mon Sep 17 00:00:00 2001 From: zmj <1493694146@qq.com> Date: Tue, 25 Jun 2024 15:34:24 +0800 Subject: [PATCH] add --- api/user.js | 4 + components/goodPopup.vue | 4 +- pageQuota/vipUser/index.vue | 168 +++++++++++++++++----------- pages/login/login.vue | 4 +- pagesOrder/setPayPassword/index.vue | 5 +- pagesOrder/settle/settle.vue | 153 +++++++++++++++---------- 6 files changed, 213 insertions(+), 125 deletions(-) diff --git a/api/user.js b/api/user.js index 4e9c57d..c0d94dd 100644 --- a/api/user.js +++ b/api/user.js @@ -141,4 +141,8 @@ export const getCreateLists = (data) => { export const getloginSms = (data) => { return request.post('/user/user/login_sms', data); +} + +export const getReportingSms = (data) => { + return request.post('/user/user/reporting_sms', data); } \ No newline at end of file diff --git a/components/goodPopup.vue b/components/goodPopup.vue index 3ce66f7..6736a34 100644 --- a/components/goodPopup.vue +++ b/components/goodPopup.vue @@ -28,14 +28,14 @@ ¥ {{ subtotal }} - + 购买重量* - + 购买数量* + + + + + + 重新获取({{cutDown}}) + {{flag?'获取验证码':'重新获取' }} + + + @@ -67,8 +80,6 @@ - {{Role==1?'完成并收款':'完成'}} @@ -193,7 +204,8 @@ getStoreByPhone, getUserLabel, getUserShip, - getCreateLists + getCreateLists, + getReportingSms } from "@/api/user.js" import Push from "@/utils/push.js" import { @@ -204,51 +216,6 @@ config } from "@/config/app.js" - - // scoket - let timer = null - const userInfo = useUserStore().userInfo; - const connection = new Push({ - url: config.WSS_URL, // websocket地址 - app_key: '2ce3ce22329517213caa7dad261f5695', - }); - - // 浏览器监听user-1 - const user_channel = connection.subscribe(`wechat_mmp_${userInfo.id}`); - - user_channel.on('message', function(data) { - console.log("收到消息--", data); - try { - if (timer) clearTimeout(timer); - uni.hideLoading() - currentTab.value = 2 - formData.real_name = '' - formData.mobile = '' - formData.address = '' - formData.label_name = '' - formData.city = '' - formData.area = '' - formData.street = '' - formData.village = '' - formData.brigade = '' - currentAddressIndex.value = 0 - tabsList.forEach(item => { - item.name = '请选择' - }) - getLists() - getCount() - - } catch (error) { - - } - }); - // 断线事件 - user_channel.on('close', function() { - - }); - // scoket结束 - - const showPop1 = ref(false) const Role = ref('') const range = ref({}) @@ -266,15 +233,14 @@ }).catch(err => { uni.$u.toast('未查到店铺信息,请检查手机号码') }) - } - // 用户选择的门店信息 let STORE_INFO = reactive({ id: "" }) + // 门店手机号保留一天 const setPhoneOneDay = () => { if (uni.getStorageSync('VIP_PHONE')) return; const currentDate = new Date(); @@ -285,7 +251,6 @@ phone: storePhone.value })); } - const getPhoneOneDay = () => { if (uni.getStorageSync('VIP_PHONE')) { let data = JSON.parse(uni.getStorageSync('VIP_PHONE')) @@ -296,25 +261,48 @@ } } } + // 手机保留一天结束 + // 验证码 + const cutDown = ref(0) + const flag = ref(true) + const code = ref('') + const checkPhone = (phone) => { + const regex = /^1[3-9]\d{9}$/; + return regex.test(formData.mobile) ? true : false + } + const getCode = async () => { + if (!checkPhone(formData.mobile)) return uni.$u.toast('请输入正确的手机号') + await getReportingSms({ + account: formData.mobile + }) + flag.value = false + cutDown.value = 60 + let timer = setInterval(() => { + cutDown.value-- + if (cutDown.value <= 0) clearInterval(timer) + }, 1000) + } + // 验证码结束 const currentTab = ref(1) const formData = reactive({ store_id: STORE_INFO.id, - mobile: "", + mobile: "19130550023", province: 510000, city: '', area: "", street: "", village: "", brigade: "", - real_name: "", + real_name: "赵明军", auth_code: "", address: "", label_name: "", label_id: "", - user_ship: '' + user_ship: '', + code: '8888' }) const conformRole = (e) => { @@ -337,7 +325,6 @@ const addressTbasChange = (e) => { currentAddressIndex.value = e.index } - const addressList = reactive({ city: [], area: [], @@ -345,7 +332,6 @@ village: [], brigade: [] }) - const addressLiClick = async (i, item) => { if (i == 0) { formData.city = item.city_code @@ -392,7 +378,6 @@ .name return currentAddressIndex.value++ } - const getCityList = async () => { let res = await cityListApi({ province_code: formData.province @@ -422,9 +407,30 @@ }, ]); + + + // 支付相关 + // scoket + let timer = null + const userInfo = useUserStore().userInfo; + const connection = new Push({ + url: config.WSS_URL, // websocket地址 + app_key: '2ce3ce22329517213caa7dad261f5695', + }); + + // 浏览器监听user-1 + const user_channel = connection.subscribe(`wechat_mmp_${userInfo.id}`); + user_channel.on('message', function(data) { + console.log("收到消息--", data); + try { + if (timer) clearTimeout(timer); + paySuccessToTabs2() + } catch (error) {} + }); const submit = async () => { if (!formData.real_name) return uni.$u.toast('请填写真实姓名'); if (!formData.mobile) return uni.$u.toast('请填写电话号码'); + if (!formData.code) return uni.$u.toast('请输入短信验证码'); uni.showLoading({ title: '支付中...' }); @@ -469,26 +475,53 @@ getCount() }) } - } - const rePay = (item) => { uni.scanCode({ success: function(res) { + uni.showLoading({ + title: '支付中...' + }); reVipRechargeApi({ id: item.id, auth_code: res.result }).then(res => { - uni.$u.toast('操作成功'); - getCount() - getLists() + timer = setTimeout(() => { + uni.hideLoading(); + uni.$u.toast('支付超时'); + }, 30000) }) } }); - } + // 支付成功后清除formData并且切换tabs2 + const paySuccessToTabs2 = () => { + uni.hideLoading() + uni.showToast({ + title: '支付成功', + duration: 2000, + success() { + currentTab.value = 2 + formData.real_name = '' + formData.mobile = '' + formData.address = '' + formData.label_name = '' + formData.city = '' + formData.area = '' + formData.street = '' + formData.village = '' + formData.brigade = '' + currentAddressIndex.value = 0 + tabsList.forEach(item => { + item.name = '请选择' + }) + getLists() + getCount() + } + }); + } // 邀请用户数 const count = ref(0) @@ -687,4 +720,13 @@ .slot-content { padding-bottom: 50rpx; } + + .code-btn { + display: flex; + align-items: center; + } + + .btn-text { + color: #20B128; + } \ No newline at end of file diff --git a/pages/login/login.vue b/pages/login/login.vue index d497af0..de72004 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -120,6 +120,9 @@ // 微信公众号绑定 const officialCode = () => { + console.log("jinfas") + return + uni.navigateTo({ url: `/pages/code/code?id=${userStore.userInfo.id}`, success: () => { @@ -168,7 +171,6 @@ } else { userStore.setUserInfo(res.data); //再次登录 已有手机号 判断是否员工 - //身份授权成功 核销人员 if (res.data.is_staff == 1) { userStore.setUserInfo(res.data); diff --git a/pagesOrder/setPayPassword/index.vue b/pagesOrder/setPayPassword/index.vue index c113ac9..7cbcee1 100644 --- a/pagesOrder/setPayPassword/index.vue +++ b/pagesOrder/setPayPassword/index.vue @@ -85,10 +85,12 @@ form.password.length < 6 ? form.password += e : showKeyBorad.value = false + if (form.password.length == 6) showKeyBorad.value = false; } else { form.rePassword.length < 6 ? form.rePassword += e : showKeyBorad.value = false + if (form.rePassword.length == 6) showKeyBorad.value = false; } } @@ -102,10 +104,9 @@ // 键盘事件结束 - - const submit = async () => { if (!form.code) return uni.$u.toast('请输入验证码'); + if (form.password.length < 6) return uni.$u.toast('请输入6位数密码'); if (form.password !== form.rePassword) return uni.$u.toast('两次密码不一致'); await setPayPassword({ ...form diff --git a/pagesOrder/settle/settle.vue b/pagesOrder/settle/settle.vue index 4dc095a..d82ee71 100644 --- a/pagesOrder/settle/settle.vue +++ b/pagesOrder/settle/settle.vue @@ -77,50 +77,6 @@ - - 支付方式 - - - - 微信支付 - - - - - - - - - - - - 余额支付 - ( 可用¥{{userInfo.now_money}} - ) - - - - - - - - - - - 采购款支付 - ( 可用¥{{userInfo.purchase_funds}} - ) - - - - - - - @@ -130,22 +86,77 @@ - - - - 共 {{ cartList.length }} 款 - - 合计: - - - {{ c_price(orderInfo.pay_price, 0) }} - .{{ c_price(orderInfo.pay_price, 1) }} - + + + + + 支付方式 + + + + 微信支付 + + + + + + + + + + + + 余额支付 + ( + 可用¥{{userInfo.now_money}} + ) + + + + + + + + + + + 采购款支付 + ( + 可用¥{{userInfo.purchase_funds}} + ) + + + + + + - - 预付款提交 + + + + + 共 {{ cartList.length }} 款 + + 合计: + + + {{ c_price(orderInfo.pay_price, 0) }} + .{{ c_price(orderInfo.pay_price, 1) }} + + + + + 预付款提交 + + \ No newline at end of file