From 2f8fa0cc3e060907d5ca812616dd8e1f16034877 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=82=93=E5=B9=B3=E8=89=BA?= <52643018@qq.com>
Date: Fri, 24 Sep 2021 18:15:34 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=89=AB=E7=A0=81=E6=94=AF?=
=?UTF-8?q?=E4=BB=98=E7=9B=B8=E5=85=B3=E6=89=80=E6=9C=89=E6=B6=89=E5=8F=8A?=
=?UTF-8?q?=E5=88=B0=E7=9A=84=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/js/sandBox.js | 7 +-
components/lf-payPassword/lf-payPassword.vue | 6 +-
pages.json | 6 +-
pages/aboutpay/confirmcash.vue | 54 +++++-
pages/aboutpay/paystate.vue | 18 +-
pages/business/center/center.vue | 33 +++-
pages/business/payment/money.vue | 22 ++-
pages/business/payment/paystate.vue | 20 ++-
pages/business/payment/wait.vue | 65 ++++++-
pages/user/member/code.vue | 171 ++++++++++++++++---
pages/user/my/setPassword.vue | 2 +-
11 files changed, 344 insertions(+), 60 deletions(-)
diff --git a/common/js/sandBox.js b/common/js/sandBox.js
index 47d1d21..127fc84 100644
--- a/common/js/sandBox.js
+++ b/common/js/sandBox.js
@@ -95,14 +95,17 @@ export const sandBox = {
showCancel: false,
success:(res)=>{
if (res.confirm) {
- wx.navigateTo({
+ // wx.navigateTo 邓平艺 于2021.09.24修改,
+ // 原因:未登录点击后跳转到登录页,当登录成功,
+ // 再次跳转回来时,用户点击页面返回,原有页面和弹窗还存在
+ uni.redirectTo({
url:`/pages/user/register/register?url=${url}`
})
return;
}
},
cancel:()=>{
- wx.navigateTo({
+ uni.redirectTo({
url:`/pages/user/register/register?url=${url}`
})
return;
diff --git a/components/lf-payPassword/lf-payPassword.vue b/components/lf-payPassword/lf-payPassword.vue
index 22346d0..de3e85e 100644
--- a/components/lf-payPassword/lf-payPassword.vue
+++ b/components/lf-payPassword/lf-payPassword.vue
@@ -21,7 +21,7 @@
-
+
@@ -41,6 +41,10 @@
showCountdown: {
type: Boolean,
default: false
+ },
+ buttonText: {
+ type: String,
+ default: '确认'
}
},
data(){
diff --git a/pages.json b/pages.json
index d786023..3361ac6 100644
--- a/pages.json
+++ b/pages.json
@@ -21,13 +21,15 @@
{
"path": "pages/aboutpay/paystate",
"style": {
- "navigationStyle": "custom"
+ "navigationStyle": "custom",
+ "navigationBarTitleText":"支付结果"
}
},
{
"path": "pages/aboutpay/confirmcash",
"style": {
- "navigationStyle": "custom"
+ "navigationStyle": "custom",
+ "navigationBarTitleText":"确认金额"
}
},
{
diff --git a/pages/aboutpay/confirmcash.vue b/pages/aboutpay/confirmcash.vue
index 4540ca2..b488f93 100644
--- a/pages/aboutpay/confirmcash.vue
+++ b/pages/aboutpay/confirmcash.vue
@@ -6,7 +6,7 @@
请核对支付金额
- ¥478.50
+ ¥{{ amount }}
剩余支付时间
@@ -23,7 +23,7 @@
-
+
@@ -33,18 +33,62 @@
diff --git a/pages/aboutpay/paystate.vue b/pages/aboutpay/paystate.vue
index d428265..1bdc95e 100644
--- a/pages/aboutpay/paystate.vue
+++ b/pages/aboutpay/paystate.vue
@@ -1,6 +1,6 @@
-
+
@@ -11,11 +11,11 @@
支付
- ¥478.50
+ ¥{{ amount }}
失败
-
+
@@ -26,7 +26,17 @@
export default {
data() {
return {
- payState: true
+ payState: 1,
+ amount: 0
+ }
+ },
+ onLoad(options){
+ this.payState = Boolean(Number(options.payState));
+ this.amount = options.amount;
+ },
+ methods: {
+ backHome(){
+ this.$url('/pages/index/index/index', {type: 'launch'});
}
}
}
diff --git a/pages/business/center/center.vue b/pages/business/center/center.vue
index 5214f62..4654813 100644
--- a/pages/business/center/center.vue
+++ b/pages/business/center/center.vue
@@ -135,14 +135,35 @@
onScanCode(){
uni.scanCode({
complete: res => {
- console.log(res);
- // 二维码内的内容
- let result = res.result;
-
- // 成功后页面跳转 TODO 待对接判断result
- this.$url('/pages/business/payment/money?user_id=1');
+ if(res.errMsg == 'scanCode:ok'){
+ // 二维码内的内容
+ let result = this.codeParse(res.result);
+ if(this.$shared.isValueType(result) == 'object'){
+ if(result.rand && result.time && result.u_id){
+ let url = '/pages/business/payment/money';
+ url += `?u_id=${result.u_id}`;
+ url += `&rand=${result.rand}`;
+ url += `&time=${result.time}`;
+ this.$url(url);
+ }
+ }else{
+ this.$msg('不是有效的支付码');
+ }
+ }else{
+ this.$msg('请扫二维码或条形码');
+ }
}
})
+ },
+ codeParse(str){
+ str = String(str);
+ let new_data = null;
+ try{
+ new_data = JSON.parse(str);
+ }catch{
+ new_data = str;
+ }
+ return new_data;
}
}
}
diff --git a/pages/business/payment/money.vue b/pages/business/payment/money.vue
index 7b354e6..9fbda42 100644
--- a/pages/business/payment/money.vue
+++ b/pages/business/payment/money.vue
@@ -24,12 +24,16 @@
data(){
return {
money: '',
- user_id: 0
+ user_id: 0,
+ rand: 0,
+ time: 0
}
},
onLoad(options){
- if(options.user_id){
- this.user_id = options.user_id;
+ if(options.u_id){
+ this.user_id = options.u_id;
+ this.time = options.time;
+ this.rand = options.rand;
}else{
this.$msg('二维码错误', {icon: 'error'}).then(() => {
this.$toBack();
@@ -45,6 +49,8 @@
api: 'api/supplier/offline/order',
data: {
user_id: this.user_id,
+ time: this.time,
+ rand: this.rand,
amount: this.money
},
header: {
@@ -52,10 +58,14 @@
}
}).then(res => {
if(res.data.code == 200){
- this.$url('/pages/business/payment/wait', {type: 'redirect'})
+ let url = '/pages/business/payment/wait?user_id='+ this.user_id;
+ url += '&amount='+ this.amount;
+ this.$url(url, {type: 'redirect'});
}else{
- let msg = res.data.msg || '网络错误';
- this.$msg(msg);
+ let message = res.data.message || '网络错误';
+ this.$msg(message).then(() => {
+ this.$toBack();
+ })
}
})
}
diff --git a/pages/business/payment/paystate.vue b/pages/business/payment/paystate.vue
index 56deaa3..bbe9a10 100644
--- a/pages/business/payment/paystate.vue
+++ b/pages/business/payment/paystate.vue
@@ -1,9 +1,9 @@
-
+
-
+
@@ -11,11 +11,11 @@
到账
- ¥478.50
+ ¥{{ amount }}
失败
-
+
@@ -26,7 +26,17 @@
export default {
data() {
return {
- payState: true
+ payState: 1,
+ amount: 0
+ }
+ },
+ onLoad(options){
+ this.payState = Boolean(Number(options.payState));
+ this.amount = options.amount;
+ },
+ methods: {
+ backHome(){
+ this.$url('/pages/business/center/center', {type: 'launch'});
}
}
}
diff --git a/pages/business/payment/wait.vue b/pages/business/payment/wait.vue
index cb5d95a..96357ed 100644
--- a/pages/business/payment/wait.vue
+++ b/pages/business/payment/wait.vue
@@ -10,14 +10,71 @@
export default {
data(){
return {
-
+ user_id: 0,
+ amount: 0,
+ timer: null,
+ num: 5,
+ count: 0,
+ overtime: false
}
},
- onLoad(){
-
+ onLoad(options){
+ this.user_id = options.user_id;
+ this.amount = options.amount;
+ this.startTimer();
+ },
+ onUnload(){
+ if(this.timer){
+ clearInterval(this.timer);
+ this.timer = null;
+ }
},
methods: {
-
+ startTimer(){
+ if(this.timer){
+ clearInterval(this.timer);
+ this.timer = null;
+ }
+ this.count++;
+ let max_date = 60 * 2; // 两分钟
+ let current_date = this.count * 5; // 当前秒数
+ if(current_date >= max_date){
+ this.overtime = true;
+ }
+ this.checkOrderPay();
+ this.timer = setInterval(() => {
+ this.num--;
+ if(this.num <= 0){
+ clearInterval(this.timer);
+ this.timer = null;
+ this.num = 5;
+ this.startTimer();
+ }
+ }, 1000);
+ },
+ checkOrderPay(){
+ let token = this.$cookieStorage.get('store_token');
+ this.$http.get({
+ api: 'api/supplier/offline/check_order_pay',
+ data: {
+ user_id: this.user_id
+ },
+ header: {
+ token: token
+ }
+ }).then(res => {
+ if(res.data.code == 200){
+ let url = '/pages/business/payment/paystate';
+ url += '?payState=1';
+ url += '&amount='+ this.amount;
+ this.$url(url, {type: 'redirect'});
+ }else if(this.overtime){
+ let url = '/pages/business/payment/paystate';
+ url += '?payState=0';
+ this.$url(url, {type: 'redirect'});
+ }
+ })
+ }
}
}
diff --git a/pages/user/member/code.vue b/pages/user/member/code.vue
index 59976f4..53b34ca 100644
--- a/pages/user/member/code.vue
+++ b/pages/user/member/code.vue
@@ -7,22 +7,24 @@
-
+
- 182****5380
+ {{ userInfo.mobile_replace }}
-
-
-
-
- 余额 ¥1829.83
-
-
-
-
-
+
- {{ num }}s后自动刷新
+ 余额 ¥{{ centerInfo.balance }}
+
+
+
+
+
+
+
+ {{ num }}s后自动刷新
+
@@ -39,32 +41,38 @@
return {
config: {
bar: {
- code: 'E01181016286106',
+ code: '',
color: '#000', // 条形码的颜色
bgColor: '#FFFFFF', // 背景色
width: 586, // 宽度
height: 210 // 高度
},
qrc: {
- code: "https://weixin.qq.com/g/AwYAAHO3aO4zlasEij6bLsk4hlZd5XNFkkBmqyS55mLPFxmn5c9PaI1omqLhd24fABCD23333",
+ code: "",
size: 352, // 二维码大小
level: 4, //等级 0~4
bgColor: '#FFFFFF', //二维码背景色 默认白色
- // border: {
- // color: ['#8A2387', '#F27121'], //边框颜色支持渐变色
- // lineWidth: 3, //边框宽度
- // },
- // img: '/static/logo.png', //图片
- // iconSize: 40, //二维码图标的大小
color: '#000000', //边框颜色支持渐变色
}
},
timer: null,
- num: 90
+ num: 120,
+ refresh: 120,
+ token: '',
+ userInfo: {},
+ centerInfo: {balance: 0},
+ show_code: false,
+ show_code_count: 0,
+ show_count: 0
}
},
onLoad(){
- this.refreshCode();
+ var token = this.$cookieStorage.get('user_token');
+ this.token = token;
+ this.getIsSetPayPwd();
+ this.getMeInfo();
+ this.getUcenter();
+
// 设置手机屏幕亮度
uni.getScreenBrightness({
success: (res) => {
@@ -76,6 +84,12 @@
}
})
},
+ onShow(){
+ this.show_count++;
+ if(this.show_count > 1){
+ this.getIsSetPayPwd();
+ }
+ },
onUnload(){
if(this.timer){
clearInterval(this.timer);
@@ -86,6 +100,55 @@
})
},
methods: {
+ // 获取用户是否设置了支付密码
+ getIsSetPayPwd(){
+ this.$http.post({
+ api: 'api/user/isset_pay_pwd',
+ header: {
+ Authorization: this.token
+ }
+ }).then(res => {
+ console.log("====",res)
+ if(res.data.status){
+ this.refreshCode();
+ }else{
+ uni.showModal({
+ title: '温馨提示',
+ content: res.data.message,
+ showCancel: false,
+ confirmColor: '#1c8482',
+ confirmText: '去设置',
+ success: result => {
+ if(result.confirm){
+ this.$url('/pages/user/my/setPassword');
+ }
+ }
+ })
+ }
+ })
+ },
+ // 获取页面信息
+ getMeInfo(){
+ this.$http.get({
+ api: 'api/me',
+ header: {
+ Authorization: this.token
+ }
+ }).then(res => {
+ this.userInfo = res.data.data;
+ })
+ },
+ // 获取积分等信息
+ getUcenter(){
+ this.$http.get({
+ api: 'api/users/ucenter',
+ header: {
+ Authorization: this.token
+ }
+ }).then(res => {
+ this.centerInfo = res.data.data;
+ })
+ },
// rpx 转 px
rpxTransformPx(num){
let systemInfo = uni.getSystemInfoSync();
@@ -98,15 +161,75 @@
clearInterval(this.timer);
this.timer = null;
}
+ this.getPay();
this.timer = setInterval(() => {
this.num--;
+ if(this.num % 5 === 0){
+ this.getPay({silence: true});
+ }
if(this.num <= 0){
clearInterval(this.timer);
this.timer = null;
- this.num = 90;
+ this.num = this.refresh;
this.refreshCode(); // 重新执行
}
}, 1000);
+ },
+ getPay(options = {}){
+ if(!options.silence){
+ if(this.show_code_count >= 1){
+ uni.showLoading({
+ title: '正在刷新'
+ })
+ }else{
+ uni.showLoading({
+ title: '正在拉取数据'
+ })
+ }
+ }
+ this.$http.get({
+ api: 'api/offline/get_pay',
+ data: {
+ refresh: 0
+ },
+ header: {
+ Authorization: this.token
+ }
+ }).then(res => {
+ if(res.data.code == 200){
+ let detail = res.data.data;
+ let u_id = this.userInfo.id;
+ if(!options.silence){
+ let str = JSON.stringify({
+ rand: detail.rand,
+ time: detail.time,
+ u_id: u_id
+ });
+ this.config.bar.code = str;
+ this.config.qrc.code = str;
+ this.show_code = true;
+ this.show_code_count++;
+ }
+ if(detail.clerk_id){
+ // 商家已扫码, 跳转至确认金额页
+ let amount = detail.amount;
+ let brand_id = detail.brand_id;
+ let clerk_id = detail.clerk_id;
+ let url = '/pages/aboutpay/confirmcash';
+ url += `?clerk_id=${clerk_id}`;
+ url += `&brand_id=${brand_id}`;
+ url += `&amount=${amount}`;
+ this.$url(url);
+ }
+ }
+ if(!options.silence){
+ uni.hideLoading();
+ }
+ }).catch(err => {
+ if(!options.silence){
+ uni.hideLoading();
+ }
+ });
}
}
}
diff --git a/pages/user/my/setPassword.vue b/pages/user/my/setPassword.vue
index cce1c69..c1ce413 100644
--- a/pages/user/my/setPassword.vue
+++ b/pages/user/my/setPassword.vue
@@ -140,7 +140,7 @@
this.$toBack();
})
}else{
- this.$msg(res.data.data);
+ this.$msg(res.data.message);
}
})
}else{