优化问题

This commit is contained in:
duan 2024-05-30 09:12:02 +08:00
parent 66e15baaee
commit cb7d853707
8 changed files with 296 additions and 146 deletions

View File

@ -19,24 +19,24 @@ class webSocketUtils {
});
} catch (e) {
console.log('catch');
this.reconnect();
// this.reconnect();
}
}
// 进入这个页面的时候创建websocket连接【整个页面随时使用】
connectSocketInit (data) {
console.log(data,"初始化")
console.log(data,"初始化")
this.data = data;
// console.log('this.url==', this.url);
// console.log('this.params==', this.params);
console.log('this.url==', this.url);
this.socketTask = uni.connectSocket({
url: this.url,
success: () => {
console.log('正准备建立websocket中...');
uni.hideLoading();
// uni.hideLoading();
// 返回实例
return this.socketTask;
},
});
console.log('this.params==', this.params);
this.socketTask.onOpen((res) => {
this.connectNum = 1;
console.log('WebSocket连接正常');
@ -48,7 +48,7 @@ class webSocketUtils {
clearInterval(this.heartbeatInterval);
this.is_open_socket = true;
this.canReconnect = true;
this.start();
// this.start();
// 注:只有连接正常打开中 ,才能正常收到消息
this.socketTask.onMessage((e) => {
// 字符串转json
@ -71,7 +71,7 @@ class webSocketUtils {
title: `网络连接失败,正尝试第${this.connectNum}次连接`,
icon: 'none',
});
this.reconnect();
// this.reconnect();
this.connectNum += 1;
} else {
// uni.$emit('connectError');
@ -91,7 +91,7 @@ class webSocketUtils {
this.is_open_socket = false;
if (this.canReconnect) {
this.reconnect();
// this.reconnect();
this.canReconnect = false;
}
});

View File

@ -12,11 +12,11 @@
</view>
</view>
<view class="navTop">
<view @click="clickEvent(1)">
<view @click="clickEvent(1)" :class="[active==1?'fonts':'']">
余额明细
<view :class="[active==1?'xian':'']" style="left: 36rpx;"> </view>
</view>
<view @click="clickEvent(2)">
<view @click="clickEvent(2)" :class="[active==2?'fonts':'']">
积分明细
<view :class="[active==2?'xian':'']" style="left: 36rpx;"> </view>
</view>
@ -25,11 +25,11 @@
<!-- <image :src="require('')" style="width: 76rpx;height: 76rpx;float: left;" mode=""></image> -->
<view class="listrigth">
<view>{{item.biz_name}}</view>
<view>+{{item.amount}}</view>
<view :class="[item.biz_code=='accountGroupPay'?'':'colorStyle']">{{item.biz_code=='accountGroupPay'?'-':'+'}}{{item.amount}}</view>
</view>
<view class="listrigth2">
<view>{{item.create_time}}</view>
<view>充值成功</view>
<view>{{$u.timeFormat(item.create_time, 'yyyy-mm-dd hh:MM:ss')}}</view>
<view>余额:{{item.balance}}</view>
</view>
</view>
@ -84,8 +84,9 @@
<style scoped lang="less">
.bild {
height: 488rpx;
height: 320rpx;
background-image: url('https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/czmxbg.png');
background-size: 750rpx 320rpx;
display: flex;
justify-content: space-around;
align-items: center;
@ -113,19 +114,23 @@
justify-content: space-around;
align-items: center;
color: #333;
margin-top: -50rpx;
margin-top: -60rpx;
padding: 0 120rpx;
.fonts {
font-size: 34rpx;
}
>view {
position: relative;
.xian {
width: 58rpx;
height: 6rpx;
background: #F1CB66;
background: #FFAA62;
border-radius: 2rpx 2rpx 2rpx 2rpx;
position: absolute;
bottom: -6rpx;
bottom: -16rpx;
}
}
@ -133,6 +138,7 @@
.listStyle {
padding: 28rpx;
padding-top: 50rpx;
width: 100%;
.listrigth,
@ -140,10 +146,13 @@
display: flex;
justify-content: space-between;
align-items: center;
padding-left: 32rpx;
// padding-left: 32rpx;
}
.listrigth {
.colorStyle{
color: #FF7127;
}
>view {
font-weight: bold;
font-size: 32rpx;

View File

@ -0,0 +1,163 @@
<template>
<view class="towcontentitem">
<view class="towcontentitemone flex-start">
<image class="towcontentitemoneimage" :src="userInfo.logo" mode="aspectFill"></image>
<view class="towcontentitemonetext flex-colum-start">
<text class="towcontentitemonetextone">{{userInfo.chainName || '暂无昵称'}}</text>
</view>
</view>
<view class="towcontentitemthere flex-start">
余额<text class="towcontentitemtheretext">{{userInfo.amount || '0.00'}}</text>
</view>
<view class="towcontentitemtow flex-between">
<text class="towcontentitemtowetext">VIP{{userInfo.code || '无'}}</text>
</view>
<view class="towcontentitevip">
VIP{{userInfo.is_vip}}
</view>
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/erweima.png" class="imgStyle" mode=""
@click="clickEvent"></image>
</view>
</template>
<script>
export default {
props: ['userInfo'],
data() {
return {}
},
methods: {
clickEvent() {
uni.navigateTo({
url: '/pages/pay_code/pay_code?shopInfo='+JSON.stringify(this.userInfo)
})
}
}
}
</script>
<style lang="scss" scoped>
.towcontentitem {
width: 100%;
position: relative;
padding: 32rpx;
border-radius: 12rpx;
background: linear-gradient(126deg, #FFFBF2 0%, #F2D093 100%);
border-radius: 12rpx 12rpx 12rpx 12rpx;
&::after {
position: absolute;
bottom: 0;
right: 68rpx;
content: '';
display: inline-block;
width: 240rpx;
height: 232rpx;
background: url(https://czg-qr-order.oss-cn-beijing.aliyuncs.com/member.png) no-repeat;
background-size: 100% 100%;
}
.towcontentitemimage {
top: 0;
left: 0;
position: absolute;
width: 100%;
height: 100%;
border-radius: 12rpx;
z-index: 5;
}
.towcontentitemone {
width: 100%;
position: relative;
z-index: 9;
.towcontentitemoneimage {
width: 76rpx;
height: 76rpx;
border-radius: 50%;
}
.towcontentitemonetext {
height: 76rpx;
margin-left: 16rpx;
.towcontentitemonetextone {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 500;
font-size: 36rpx;
color: #333333;
}
.towcontentitemonetexttow {
font-size: 24rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #422A07;
}
}
}
.towcontentitemprogressa {
padding: 8rpx 44rpx;
z-index: 10;
position: relative;
margin-top: 54rpx;
}
.towcontentitemtow {
margin-top: 84rpx;
z-index: 10;
font-size: 24rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #422A07;
}
.towcontentitevip {
position: absolute;
right: 0;
top: 0;
width: 92rpx;
height: 40rpx;
font-size: 20rpx;
background: #F4C380;
border-radius: 0rpx 12rpx 0rpx 12rpx;
text-align: center;
line-height: 40rpx;
color: #fff;
font-family: Source Han Sans CN-Medium;
font-weight: Medium;
}
.towcontentitemthere {
margin-left: 92rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: Medium;
font-size: 24rpx;
color: #333333;
.towcontentitemtheretext {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: bold;
font-size: 36rpx;
color: #333333;
}
}
}
.imgStyle {
width: 54rpx;
height: 52rpx;
position: absolute;
right: 50rpx;
bottom: 30rpx;
// border: 2px solid #fff;
z-index: 666;
}
</style>

View File

@ -1,23 +1,6 @@
<template>
<view class="content">
<view class="towcontentitem">
<view class="towcontentitemone flex-start">
<image class="towcontentitemoneimage" :src="userInfo.logo" mode="aspectFill"></image>
<view class="towcontentitemonetext flex-colum-start">
<text class="towcontentitemonetextone">{{userInfo.chainName || '暂无昵称'}}</text>
</view>
</view>
<view class="towcontentitemthere flex-start">
余额<text class="towcontentitemtheretext">{{userInfo.amount || '0.00'}}</text>
</view>
<view class="towcontentitemtow flex-between">
<text class="towcontentitemtowetext">vip{{userInfo.code || '无'}}</text>
</view>
<view class="towcontentitevip">
vip{{userInfo.is_vip}}
</view>
</view>
<card :userInfo="userInfo"></card>
<view class="therecontent">
<input type="number" v-model="amount" placeholder="自定义金额">
</view>
@ -37,7 +20,9 @@
</template>
<script>
import card from './components/card.vue'
export default {
components:{card},
data() {
return {
inputshow: 0,
@ -51,11 +36,11 @@
onLoad(e) {
console.log(e,'调试2')
if (e.type == 'list') {//
this.paygetShopByMember(e.shopId_id)
this.paygetShopByMember(e.shopId)
}else{
this.paygetShopByMember(e.shopId_id)
this.paygetShopByMember(e.shopId)
}
this.paygetActive(e.shopId_id) //
this.paygetActive(e.shopId) //
},
methods: {
async paygetShopByMember(w) {

View File

@ -1,24 +1,7 @@
<template>
<!-- 会员详情 -->
<view class="content">
<view class="towcontentitem">
<view class="towcontentitemone flex-start">
<image class="towcontentitemoneimage" :src="userInfo.logo" mode="aspectFill"></image>
<view class="towcontentitemonetext flex-colum-start">
<text class="towcontentitemonetextone">{{userInfo.chainName || '暂无昵称'}}</text>
</view>
</view>
<view class="towcontentitemthere flex-start">
余额<text class="towcontentitemtheretext">{{userInfo.amount || '0.00'}}</text>
</view>
<view class="towcontentitemtow flex-between">
<text class="towcontentitemtowetext">vip{{userInfo.code || '无'}}</text>
</view>
<view class="towcontentitevip">
vip{{userInfo.is_vip}}
</view>
</view>
<card :userInfo="userInfo"></card>
<view class="memberdetailsStyle">
<text>会员详情</text>
<view @click="goUrl('member/billDetails')">
@ -35,7 +18,9 @@
</template>
<script>
import card from './components/card.vue'
export default {
components:{card},
data() {
return {
info:null,

View File

@ -94,7 +94,8 @@
支付方式
</view>
<view class="">
<u-radio-group v-model="radiovalue1" iconPlacement="right" :size="28" placement="column">
<u-radio-group v-model="radiovalue1" iconPlacement="right" @change="groupChange" :size="28"
placement="column">
<u-radio activeColor="#ffd158" name="1">
<view class="dfs">
<image style="width:44rpx;height:44rpx"
@ -177,7 +178,7 @@
</view>
</view>
<!-- 支付密码 -->
<payPassword ref="payPwd" @accountPayevent="accountPayevent" v-show="ispws"></payPassword>
<payPassword ref="payPwd" @accountPayevent="accountPayevent" v-if="ispws"></payPassword>
</view>
</template>
@ -215,13 +216,10 @@
onUnload() {
uni.$off('getMessage')
// uni.showToast({
// title: this.radiovalue1 + '-110',
// duration:5000
// })
this.ispws = false
},
onLoad(e) {
// console.log(e, 140)
let res = JSON.parse(e.tableId)
this.listinfo.detailList = res
@ -254,6 +252,11 @@
})
},
methods: {
groupChange(n) {
// console.log('groupChange', n);
this.radiovalue1 = n
uni.cache.set('radiovalue1',n)
},
// fangdouevent() {
// this.$u.debounce(() => {
// this.showpopupclick()
@ -269,6 +272,7 @@
}
},
async getAount() {
console.log(uni.cache.get('userInfo'), '余额中userId不显示打印')
let res = await this.api.shopUserInfo({
// shopId:ID
"shopId": uni.cache.get('shopUser'),
@ -280,7 +284,6 @@
}
},
getMessage(msg) {
if (msg.status != 'success') {
uni.showToast({
title: msg.msg,
@ -288,23 +291,17 @@
})
this.socketTicket.Close()
uni.$off('getMessage')
return false;
} else {
switch (msg.type) {
case 'createOrder': //
this.listinfoid = msg.data.id //id
this.orderInfo = msg.data
this.showpopupclickdd()
// let item = JSON.stringify(msg.data)
// uni.redirectTo({
// url: '/pages/order_detail/order_detail?tableId=' + item
// });
break;
}
console.log(msg, 'socke返回数据')
} else if (msg.type == 'createOrder') {
console.log(msg, 'createOrder执行')
this.listinfoid = msg.data.id //id
this.orderInfo = msg.data
this.showpopupclickdd()
}
},
handlemessage() {
this.socketTicket ? this.socketTicket.Close() : null //socket
// this.socketTicket ? this.socketTicket.Close() : null //socket
this.socketTicket = new webSocketUtils(
`${uni.conf.baseUrlwws}/websocket/table/${uni.cache.get('tableCode')}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`,
5000)
@ -358,65 +355,14 @@
//
goRecharge() {
uni.pro.navigateTo('/pages/member/index', {
shopId_id: uni.cache.get('shopUser')
shopId_id: this.amountVIP.shopId
})
},
async showpopupclickdd(i) {
showpopupclickdd(i) {
console.log(this.radiovalue1, 'radiovalue1的值')
if (this.radiovalue1 == 1) {
let res = await this.api.payorderPay({
orderId: this.listinfoid
}) //
if (res.code == 0) {
// uni.showLoading({
// title: '',
// mask: true
// })
// #ifdef MP-WEIXIN
//
uni.requestPayment({
provider: 'wxpay', //-
partnerid: res.data.appId, //
timeStamp: res.data.timeStamp, //
nonceStr: res.data.nonceStr, //
package: res.data.package, //
signType: res.data.signType, //
paySign: res.data.paySign, //
success: (res) => {
uni.showToast({
title: "支付成功"
})
uni.cache.set('shopUser', '') //shopUser
this.paymodfiyOrderInfo()
setTimeout(res => {
uni.redirectTo({
url: '/pages/order/successful?orderId=' + this
.listinfoid + '&orderInfo=' + JSON.stringify(
this.orderInfo) + '&payType' + this
.radiovalue1
});
}, 1000)
// uni.redirectTo({
// url: "/pages/mall/order/ordersuccess?id=" + datareslane.data
// .order_id,
// });
},
fail: (err) => {
uni.showToast({
icon: 'none',
title: '支付失败'
})
uni.hideLoading()
// uni.redirectTo({
// url: '/pages/order/order_detail?orderId=' + this.listinfoid
// });
},
complete: (data) => {
console.log(data, '成功与否')
}
});
// #endif
}
this.showpopupclickdds()
} else {
//
// 0
@ -433,6 +379,63 @@
}
}
},
//
async showpopupclickdds() {
let res = await this.api.payorderPay({
orderId: this.listinfoid
}) //
if (res.code == 0) {
// uni.showLoading({
// title: '',
// mask: true
// })
// #ifdef MP-WEIXIN
//
uni.requestPayment({
provider: 'wxpay', //-
partnerid: res.data.appId, //
timeStamp: res.data.timeStamp, //
nonceStr: res.data.nonceStr, //
package: res.data.package, //
signType: res.data.signType, //
paySign: res.data.paySign, //
success: (res) => {
uni.showToast({
title: "支付成功"
})
uni.cache.set('shopUser', '') //shopUser
this.paymodfiyOrderInfo()
setTimeout(res => {
uni.redirectTo({
url: '/pages/order/successful?orderId=' + this
.listinfoid + '&orderInfo=' + JSON.stringify(
this.orderInfo) + '&payType' + this
.radiovalue1
});
}, 1000)
// uni.redirectTo({
// url: "/pages/mall/order/ordersuccess?id=" + datareslane.data
// .order_id,
// });
},
fail: (err) => {
uni.showToast({
icon: 'none',
title: '支付失败'
})
// uni.hideLoading()
// uni.redirectTo({
// url: '/pages/order/order_detail?orderId=' + this.listinfoid
// });
},
complete: (data) => {
console.log(data, '成功与否')
}
});
// #endif
}
},
//
async accountPayevent(pwd) {
this.ispws = false

View File

@ -310,6 +310,8 @@
})
try {
if (res.data) {
let time = new Date
console.log(time,'时间戳')
uni.cache.set('shopUser', res.data)
this.handlemessage()
}
@ -398,11 +400,12 @@
}
},
handlemessage() {
this.socketTicket ? this.socketTicket.Close() : null //socket
console.log(this.socketTicket,'是否存在socketTicket1')
// this.socketTicket ? this.socketTicket.Close() : null //socket
this.socketTicket = new webSocketUtils(
`${uni.conf.baseUrlwws}/websocket/table/${uni.cache.get('tableCode')}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`,
5000)
console.log(this.socketTicket,'是否存在socketTicket3')
},
//
socketSendMsg(data) {

View File

@ -1,21 +1,21 @@
<template>
<view class="container">
<view class="header">
<text class="t">{{shopUser.nickName}}</text>
<text class="t"></text>
</view>
<view class="code-wrap">
<view class="num-wrap">
<text class="t">账户余额</text>
<text class="num">{{shopUser.amount}}</text>
<text class="num">{{shopInfo.amount}}</text>
</view>
<view class="line-code">
<tki-barcode ref="tkiBarcode" show :opations="tkiOptions"></tki-barcode>
<tki-barcode ref="tkiBarcode" show :opations="tkiOptions"></tki-barcode>
</view>
<view class="ewm-wrap">
<uqrcode ref="uqrcode" canvas-id="qrcode" :value="createcardNo"></uqrcode>
</view>
<view class="name">
<text>使用门店{{shopUser.name}}</text>
<text>使用门店{{shopInfo.shopName}}</text>
</view>
<view class="line"></view>
</view>
@ -35,20 +35,22 @@
fontSize: 28,
textMargin: 14
},
shopUser: {},
createcardNo: ''
createcardNo: '',
shopInfo: null
};
},
onLoad() {
this.shopUser = uni.cache.get('shopUser')
onLoad(e) {
this.shopInfo = JSON.parse(e.shopInfo)
this.logincreateCardNo();
},
methods: {
async logincreateCardNo() {
let res = await this.api.logincreateCardNo()
let res = await this.api.logincreateCardNo({
"shopId": this.shopInfo.shopId
})
if (res.code == 0) {
this.createcardNo = res.data
this.$refs.tkiBarcode.setval(this.createcardNo)//
this.$refs.tkiBarcode.setval(this.createcardNo) //
}
}
}