Compare commits
No commits in common. "804579f19f8af9b79b452afb934c5f8e3261622d" and "9b988c95858eddee2305a93ba789ba34195d30cf" have entirely different histories.
804579f19f
...
9b988c9585
@ -15,15 +15,15 @@
|
||||
<view v-if="connectingStatus" class="connecting-status">{{ connectingStatus }}</view>
|
||||
|
||||
<!-- 聊天消息区域 -->
|
||||
<scroll-view class="chat-messages" scroll-y="true"
|
||||
upper-threshold="50" @scrolltoupper="loadMoreHistory" @scroll="onScroll">
|
||||
<scroll-view :scroll-into-view="scrollToView" class="chat-messages" lower-threshold="100" scroll-y="true"
|
||||
upper-threshold="100" @scrolltolower="loadMoreHistory" @scrolltoupper="loadMoreHistory">
|
||||
<!-- 加载历史消息提示 -->
|
||||
<view v-if="isLoadingHistory" class="message-time">加载历史消息...</view>
|
||||
|
||||
<!-- 消息列表 -->
|
||||
<block v-for="(message, index) in messages" :key="index">
|
||||
<!-- 时间分割线 -->
|
||||
<view v-if="needShowTime(index)" class="message-time">{{ message.times }}</view>
|
||||
<view v-if="needShowTime(index)" class="message-time">{{ formatTime(message.time) }}</view>
|
||||
|
||||
<!-- 消息项 -->
|
||||
<view :id="'msg-' + index" :class="{
|
||||
@ -56,8 +56,8 @@
|
||||
|
||||
<script>
|
||||
import { menuButtonInfo, picUrl, request } from '@/utils'
|
||||
import { apiArr } from '@/api/customerService'
|
||||
import mqttTool from '@/utils/mqtt'
|
||||
import { apiArr } from '../../../api/customerService'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -76,7 +76,6 @@ export default {
|
||||
userAvatar: '',
|
||||
// 消息列表
|
||||
messages: [],
|
||||
|
||||
// 输入的消息
|
||||
inputMessage: '',
|
||||
// 是否可以发送消息
|
||||
@ -106,11 +105,9 @@ export default {
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
console.log('客服聊天页面onLoad触发')
|
||||
const meun = menuButtonInfo()
|
||||
this.top = meun.top
|
||||
this.localHeight = meun.height
|
||||
console.log('导航栏信息:top:', this.top, 'height:', this.localHeight)
|
||||
// 获取聊天对象信息
|
||||
if (options.item) {
|
||||
const item = JSON.parse(options.item)
|
||||
@ -122,10 +119,7 @@ export default {
|
||||
this.chatTarget.title = this.chatTarget.employee_name
|
||||
this.getMqttConfig().then(() => {
|
||||
// 获取配置后再初始化聊天
|
||||
console.log('获取MQTT配置成功,开始初始化聊天')
|
||||
this.initChat()
|
||||
}).catch(error => {
|
||||
console.error('获取MQTT配置失败:', error)
|
||||
})
|
||||
} else {
|
||||
// 客服选择聊天列表进来
|
||||
@ -139,15 +133,11 @@ export default {
|
||||
this.chatTarget.openId = this.chatTarget.client_id_one
|
||||
}
|
||||
// 初始化MQTT连接
|
||||
console.log('开始初始化聊天')
|
||||
this.initChat()
|
||||
}
|
||||
} else {
|
||||
console.log('没有接收到参数item')
|
||||
}
|
||||
// 初始化用户头像
|
||||
this.userAvatar = picUrl + uni.getStorageSync('headPhoto')
|
||||
console.log('用户头像:', this.userAvatar)
|
||||
},
|
||||
onShow() {
|
||||
},
|
||||
@ -232,11 +222,7 @@ export default {
|
||||
// 连接成功后启动心跳包
|
||||
this.startKeepalive()
|
||||
// 连接成功后立即加载历史消息
|
||||
console.log('连接成功,开始加载历史消息')
|
||||
await this.loadHistoryMessages()
|
||||
console.log('历史消息加载完成,消息数量:', this.messages.length)
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error('初始化聊天失败', error)
|
||||
this.connectingStatus = '连接失败,请检查网络'
|
||||
@ -305,23 +291,16 @@ export default {
|
||||
|
||||
// 加载历史消息
|
||||
async loadHistoryMessages() {
|
||||
console.log('loadHistoryMessages方法调用')
|
||||
console.log('加载条件检查:hasMoreHistory:', this.hasMoreHistory, 'isLoadingHistory:', this.isLoadingHistory)
|
||||
|
||||
if (!this.hasMoreHistory || this.isLoadingHistory) {
|
||||
console.log('不满足加载条件:hasMoreHistory:', this.hasMoreHistory, 'isLoadingHistory:', this.isLoadingHistory)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
this.isLoadingHistory = true
|
||||
console.log('开始加载历史消息,当前页码:', this.pageNum)
|
||||
|
||||
// 确保已经获取了mqttConfig.bindId
|
||||
if (!this.chatTarget.bindId) {
|
||||
console.log('没有bindId,开始获取MQTT配置')
|
||||
await this.getMqttConfig()
|
||||
console.log('获取MQTT配置成功,bindId:', this.chatTarget.bindId)
|
||||
}
|
||||
|
||||
const params = {
|
||||
@ -335,13 +314,11 @@ export default {
|
||||
const res = await request(apiArr.csGetMsgRecord, 'POST', params)
|
||||
|
||||
console.log('历史消息返回结果:', res)
|
||||
if (res && res.msg_record) {
|
||||
const historyMessages = res.msg_record
|
||||
if (res && res.code === 1 && res.data && res.data.msg_record) {
|
||||
const historyMessages = res.data.msg_record
|
||||
|
||||
console.log('原始历史消息数量:', historyMessages.length)
|
||||
// 如果没有更多历史消息了
|
||||
if (historyMessages.length === 0) {
|
||||
console.log('没有更多历史消息了')
|
||||
this.hasMoreHistory = false
|
||||
return
|
||||
}
|
||||
@ -350,74 +327,30 @@ export default {
|
||||
const formattedMessages = historyMessages.map(msg => ({
|
||||
content: msg.content,
|
||||
time: new Date(msg.create_time).getTime(),
|
||||
times: msg.update_time,
|
||||
isSelf: msg.send_client === this.selfClientId, // 修正判断条件
|
||||
isLoading: false
|
||||
})).reverse(); // 反转消息顺序,确保最早的消息在最前面
|
||||
|
||||
console.log('格式化后的历史消息:', formattedMessages)
|
||||
// 将格式化后的历史消息添加到消息列表开头
|
||||
const previousMessageCount = this.messages.length;
|
||||
console.log('添加前消息数量:', previousMessageCount)
|
||||
this.messages = [...formattedMessages, ...this.messages];
|
||||
console.log('添加后消息数量:', this.messages.length)
|
||||
this.messages = [...formattedMessages, ...this.messages]
|
||||
|
||||
// 增加页码
|
||||
this.pageNum++;
|
||||
console.log('下一页页码:', this.pageNum)
|
||||
|
||||
// 如果是首次加载,滚动到底部显示最新消息
|
||||
if (previousMessageCount === 0) {
|
||||
setTimeout(() => {
|
||||
console.log('首次加载,滚动到底部,消息数量:', this.messages.length)
|
||||
// 使用更可靠的滚动方式
|
||||
uni.pageScrollTo({
|
||||
scrollTop: 999999,
|
||||
duration: 300
|
||||
});
|
||||
}, 100);
|
||||
} else {
|
||||
// 不是首次加载时,保持当前滚动位置,不自动滚动到底部
|
||||
// 确保新加载的历史消息在顶部可见
|
||||
console.log('非首次加载,新增消息数量:', formattedMessages.length)
|
||||
}
|
||||
} else {
|
||||
console.log('接口返回数据格式不正确或无消息记录')
|
||||
// 仅当不是第一页时才设置hasMoreHistory为false
|
||||
if (this.pageNum > 1) {
|
||||
this.hasMoreHistory = false
|
||||
}
|
||||
this.pageNum++
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载历史消息失败', error)
|
||||
} finally {
|
||||
this.isLoadingHistory = false
|
||||
console.log('加载历史消息结束')
|
||||
}
|
||||
},
|
||||
|
||||
// 滚动事件监听
|
||||
onScroll(e) {
|
||||
console.log('滚动事件触发,scrollTop:', e.detail.scrollTop)
|
||||
},
|
||||
|
||||
// 加载更多历史消息
|
||||
loadMoreHistory() {
|
||||
console.log('滚动到顶部事件触发')
|
||||
// 滚动到顶部时加载更多历史消息
|
||||
console.log('当前条件:isLoadingHistory:', this.isLoadingHistory, 'hasMoreHistory:', this.hasMoreHistory, 'pageNum:', this.pageNum)
|
||||
|
||||
// 重置hasMoreHistory为true,确保可以继续加载
|
||||
if (!this.hasMoreHistory && this.pageNum === 1) {
|
||||
console.log('重置hasMoreHistory为true')
|
||||
this.hasMoreHistory = true
|
||||
}
|
||||
|
||||
if (!this.isLoadingHistory && this.hasMoreHistory) {
|
||||
console.log('开始加载更多历史消息')
|
||||
this.loadHistoryMessages()
|
||||
} else {
|
||||
console.log('不满足加载更多条件:isLoadingHistory:', this.isLoadingHistory, 'hasMoreHistory:', this.hasMoreHistory)
|
||||
loadMoreHistory(e) {
|
||||
// 当滚动到顶部时加载更多历史消息
|
||||
if (e && e.detail.direction === 'top') {
|
||||
if (!this.isLoadingHistory && this.hasMoreHistory) {
|
||||
this.loadHistoryMessages()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -500,11 +433,7 @@ export default {
|
||||
// 滚动到底部
|
||||
scrollToBottom() {
|
||||
setTimeout(() => {
|
||||
console.log('手动滚动到底部')
|
||||
uni.pageScrollTo({
|
||||
scrollTop: 999999,
|
||||
duration: 300
|
||||
});
|
||||
this.scrollToView = 'msg-' + (this.messages.length - 1)
|
||||
}, 100)
|
||||
},
|
||||
|
||||
@ -585,10 +514,4 @@ export default {
|
||||
|
||||
<style>
|
||||
@import url("./index.css");
|
||||
</style>
|
||||
<style scoped>
|
||||
:root {
|
||||
--header-height: 80px; /* 头部高度 */
|
||||
--input-height: 80px; /* 输入区域高度 */
|
||||
}
|
||||
</style>
|
||||
@ -271,6 +271,24 @@ image {
|
||||
height: 40rpx;
|
||||
}
|
||||
|
||||
.car_right {
|
||||
width: 470rpx;
|
||||
height: 70rpx;
|
||||
background: linear-gradient(91deg, #FF7658 0%, #FF370B 100%);
|
||||
border-radius: 100rpx 100rpx 100rpx 100rpx;
|
||||
font-size: 36rpx;
|
||||
color: #FFFFFF;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 26rpx;
|
||||
}
|
||||
|
||||
.car_right_disabled {
|
||||
background: #CCCCCC;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.cars {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -293,6 +311,13 @@ image {
|
||||
top: -10rpx;
|
||||
}
|
||||
|
||||
.car_right .input {
|
||||
font-size: 36rpx;
|
||||
color: #FFFFFF;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
|
||||
.shadow {
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
position: fixed;
|
||||
@ -544,6 +569,7 @@ image {
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
width: 90%;
|
||||
padding-left: 80rpx;
|
||||
margin: 20rpx 0;
|
||||
}
|
||||
@ -597,12 +623,8 @@ image {
|
||||
border-radius: 40rpx;
|
||||
padding: 10rpx 15rpx;
|
||||
white-space: nowrap;
|
||||
margin: 20rpx 30rpx;
|
||||
display: inline-block;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
|
||||
.itemSize_active {
|
||||
background: #FF370B;
|
||||
color: #fff;
|
||||
@ -618,7 +640,6 @@ image {
|
||||
.itemSize_top {
|
||||
display: flex;
|
||||
margin-left: 30rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.itemSize_info {
|
||||
@ -636,201 +657,4 @@ image {
|
||||
font-weight: 500;
|
||||
margin-top: 10rpx;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.car_right_box {
|
||||
display: flex;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.car_right {
|
||||
width: 220rpx;
|
||||
height: 70rpx;
|
||||
/* background: linear-gradient(91deg, #FF7658 0%, #FF370B 100%); */
|
||||
background: #ff712c;
|
||||
border-radius: 20rpx 0 0 20rpx;
|
||||
color: #FFFFFF;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 26rpx;
|
||||
}
|
||||
|
||||
.seckill {
|
||||
width: 220rpx;
|
||||
height: 70rpx;
|
||||
background: #ff3b31;
|
||||
border-radius: 0 20rpx 20rpx 0;
|
||||
color: #FFFFFF;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 26rpx;
|
||||
}
|
||||
|
||||
.car_right2 {
|
||||
width: 470rpx;
|
||||
height: 70rpx;
|
||||
background: #ffb1a5;
|
||||
border-radius: 100rpx 100rpx 100rpx 100rpx;
|
||||
font-size: 36rpx;
|
||||
color: #FFFFFF;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 26rpx;
|
||||
}
|
||||
|
||||
/* 立即购买弹窗样式 */
|
||||
.address-section {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.address-info {
|
||||
padding: 20rpx 30rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
margin-bottom: 20rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.address-main {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.address-name-phone {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.name {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.phone {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.address-detail {
|
||||
color: #666;
|
||||
line-height: 40rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.copy-icon {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
background: url('https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_copy.png') no-repeat center;
|
||||
background-size: contain;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.address-arrow {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.quantity-control {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
position: absolute;
|
||||
bottom: 10rpx;
|
||||
right: 40rpx;
|
||||
}
|
||||
|
||||
.decrease-btn {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
background-color: #f5f5f5;
|
||||
border: 1rpx solid #ccc;
|
||||
border-radius: 50%;
|
||||
line-height: 33rpx;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.increase-btn {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
background-color: #ff502a;
|
||||
border-radius: 50%;
|
||||
line-height: 33rpx;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.quantity {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin: 0 20rpx;
|
||||
min-width: 40rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.payment-section {
|
||||
background-color: #fff;
|
||||
margin-bottom: 20rpx;
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
|
||||
.payment-item {
|
||||
padding: 30rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.payment-icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.payment-icon image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.payment-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.payment-name {
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 5rpx;
|
||||
}
|
||||
|
||||
.payment-desc {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.payment-select {
|
||||
color: #FF7658;
|
||||
}
|
||||
|
||||
.pay-button {
|
||||
width: 50%;
|
||||
height: 70rpx;
|
||||
margin: 0 auto;
|
||||
line-height: 70rpx;
|
||||
text-align: center;
|
||||
background: linear-gradient(91deg, #FF7658 0%, #FF370B 100%);
|
||||
color: #fff;
|
||||
font-size: 34rpx;
|
||||
font-weight: bold;
|
||||
border-radius: 50rpx;
|
||||
}
|
||||
|
||||
.car_right_buy {
|
||||
width: 220rpx;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
@ -175,29 +175,23 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="car_right_box">
|
||||
<view class="car_right" v-if="
|
||||
info.commodity_goods_info_list[currentGGIndex].stock_quantity > 0 &&
|
||||
(!info.commodity_goods_info_list[currentGGIndex].cart_count ||
|
||||
info.commodity_goods_info_list[currentGGIndex].cart_count.count == 0)
|
||||
" @click="addCar">
|
||||
加入购物车
|
||||
</view>
|
||||
|
||||
<view class="car_right" @click="changeCar" v-if="
|
||||
info.commodity_goods_info_list[currentGGIndex].cart_count.count > 0
|
||||
&& info.commodity_goods_info_list[currentGGIndex].stock_quantity > 0
|
||||
">
|
||||
加入购物车
|
||||
</view>
|
||||
|
||||
<view class="seckill" v-if="info.commodity_goods_info_list[currentGGIndex].stock_quantity != 0"
|
||||
@click="showBuyPopup">
|
||||
立即购买
|
||||
</view>
|
||||
<view class="car_right" v-if="
|
||||
info.commodity_goods_info_list[currentGGIndex].stock_quantity > 0 &&
|
||||
(!info.commodity_goods_info_list[currentGGIndex].cart_count ||
|
||||
info.commodity_goods_info_list[currentGGIndex].cart_count.count == 0)
|
||||
" @click="addCar">
|
||||
加入购物车
|
||||
</view>
|
||||
|
||||
<view class="car_right2" v-if="info.commodity_goods_info_list[currentGGIndex].stock_quantity < 1">
|
||||
<view class="car_right" @click="changeCar" v-if="
|
||||
info.commodity_goods_info_list[currentGGIndex].cart_count.count > 0
|
||||
&& info.commodity_goods_info_list[currentGGIndex].stock_quantity > 0
|
||||
">
|
||||
加入购物车
|
||||
</view>
|
||||
|
||||
<view class="car_right car_right_disabled"
|
||||
v-if="info.commodity_goods_info_list[currentGGIndex].stock_quantity < 1">
|
||||
已售罄
|
||||
</view>
|
||||
</view>
|
||||
@ -304,7 +298,7 @@
|
||||
<view class="itemSize_name" style="display: flex;">
|
||||
<view v-if="currentGG.is_same_day" class="isDay">当日达</view>{{ changeName }}
|
||||
</view>
|
||||
<view class="itemSize_price">¥{{ changePrice }}/{{ goodsUnit }}</view>
|
||||
<view class="itemSize_price">¥{{ changePrice }}/袋</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="itemSizeBox" v-for="(item, index) in info.commodity_goods_info_list" :key="item.id"
|
||||
@ -313,75 +307,6 @@
|
||||
{{ item.goods_spec }} / {{ item.goods_unit }}</text>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 立即购买 -->
|
||||
<u-popup :show="showBuy" round="20rpx" mode="bottom" @close="closeBuy">
|
||||
<view class="popup-header">
|
||||
<h3 class="popup-header-h3">立即购买</h3>
|
||||
<view class="popup-header-view" @click="closeBuy">取消</view>
|
||||
</view>
|
||||
<view class="address-section">
|
||||
<view class="address-info" @click="editAddress()">
|
||||
<view class="address-main" v-if="defAddress && Object.keys(defAddress).length > 0">
|
||||
<view class="address-name-phone">
|
||||
<text class="name">{{ defAddress.name }}</text>
|
||||
<text class="phone">{{ defAddress.phone }}</text>
|
||||
</view>
|
||||
<view class="address-detail">
|
||||
{{ defAddress.address }}{{ defAddress.house_number }}
|
||||
<view class="copy-icon" @click.stop="copyAddress" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="address-main" v-else>
|
||||
<view class="address-name-phone">
|
||||
<text class="name">请选择收货地址</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="address-arrow"><u-icon name="arrow-right" size="25"></u-icon></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="itemSize_top">
|
||||
<image :src="changeImg" class="itemSize-img"></image>
|
||||
<view class="itemSize_info">
|
||||
<view class="itemSize_name">{{ changeName }}</view>
|
||||
<view class="itemSize_price">¥{{ changePrice }}/{{ goodsUnit }}</view>
|
||||
</view>
|
||||
<view class="quantity-control">
|
||||
<view class="decrease-btn" @tap.stop="decreaseQuantity()">-</view>
|
||||
<view class="quantity">{{ changeCount }}</view>
|
||||
<view class="increase-btn" @tap.stop="increaseQuantity()">+</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="itemSize" v-for="(item, index) in info.commodity_goods_info_list" :key="item.id"
|
||||
@click="changeGG(item, index)" :class="index == currentGGIndex ? 'itemSize_active' : ''">
|
||||
{{ item.goods_name }} {{ item.goods_spec }} / {{ item.goods_unit }}
|
||||
</view>
|
||||
<view class="fenge"></view>
|
||||
<!-- 支付方式 -->
|
||||
<view class="payment-section">
|
||||
<view class="payment-item" @click="selectPayment('wechat')">
|
||||
<view class="payment-icon">
|
||||
<image
|
||||
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_wechat.png"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="payment-content">
|
||||
<view class="payment-name">微信支付</view>
|
||||
</view>
|
||||
<view class="payment-select" v-if="selectedPayment === 'wechat'">
|
||||
<image
|
||||
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png"
|
||||
mode="aspectFit" style="width: 30rpx; height: 30rpx;"></image>
|
||||
</view>
|
||||
<view class="payment-select" v-else>
|
||||
<image
|
||||
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png"
|
||||
mode="aspectFit" style="width: 30rpx; height: 30rpx;"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="pay-button" @click="submitBuyOrder">立即支付</view>
|
||||
</u-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -420,16 +345,10 @@ export default {
|
||||
comments: [],
|
||||
show: false,
|
||||
showSize: false,
|
||||
// 立即购买相关
|
||||
showBuy: false,
|
||||
changeCount: 0,
|
||||
defAddress: {},
|
||||
selectedPayment: 'wechat', // 默认微信支付
|
||||
|
||||
changeImg: "",
|
||||
changeName: "",
|
||||
changePrice: "",
|
||||
goodsUnit: "",
|
||||
selectedGoods: null, // 保存传入的商品规格信息
|
||||
qrcodePath: null, // 存储当前页面的二维码路径
|
||||
};
|
||||
@ -559,7 +478,6 @@ export default {
|
||||
this.changeImg = picUrl + this.currentGG.commodity_pic[0]
|
||||
this.changeName = this.currentGG.goods_alias
|
||||
this.changePrice = this.currentGG.sales_price
|
||||
this.goodsUnit = this.currentGG.goods_unit
|
||||
});
|
||||
},
|
||||
|
||||
@ -590,73 +508,8 @@ export default {
|
||||
this.changeImg = picUrl + item.commodity_pic[0]
|
||||
this.changeName = item.goods_alias
|
||||
this.changePrice = item.sales_price
|
||||
this.goodsUnit = item.goods_unit
|
||||
this.getComment(item.goods_id)
|
||||
},
|
||||
// 立即购买相关方法
|
||||
showBuyPopup() {
|
||||
this.changeCount = 1;
|
||||
this.showBuy = true;
|
||||
// 检查是否有选中的地址
|
||||
const selectedAddress = uni.getStorageSync('selectedAddress');
|
||||
if (selectedAddress && Object.keys(selectedAddress).length > 0) {
|
||||
this.defAddress = selectedAddress;
|
||||
// 清除选中状态,避免重复应用
|
||||
uni.removeStorageSync('selectedAddress');
|
||||
} else {
|
||||
// 如果没有选中的地址,则获取默认地址
|
||||
this.getUserAddress();
|
||||
}
|
||||
},
|
||||
closeBuy() {
|
||||
this.showBuy = false;
|
||||
uni.removeStorageSync('selectedAddress');
|
||||
this.changeCount = 1;
|
||||
},
|
||||
editAddress() {
|
||||
NavgateTo('/packages/shop/address/index');
|
||||
},
|
||||
// 数量加减
|
||||
decreaseQuantity() {
|
||||
if (this.changeCount > 1) {
|
||||
this.changeCount--;
|
||||
}
|
||||
},
|
||||
increaseQuantity() {
|
||||
const stock = this.info.commodity_goods_info_list[this.currentGGIndex].stock_quantity;
|
||||
if (this.changeCount < stock) {
|
||||
this.changeCount++;
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '库存不足',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
// 获取默认收货地址
|
||||
getUserAddress() {
|
||||
request(apiArr.getUserDefAddress, "POST", {}).then(res => {
|
||||
this.defAddress = res.default_address;
|
||||
});
|
||||
},
|
||||
// 选择支付方式
|
||||
selectPayment(type) {
|
||||
this.selectedPayment = type;
|
||||
},
|
||||
// 复制收货地址
|
||||
copyAddress() {
|
||||
if (this.defAddress && Object.keys(this.defAddress).length > 0) {
|
||||
uni.setClipboardData({
|
||||
data: this.defAddress.address + this.defAddress.house_number,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: '地址复制成功',
|
||||
icon: 'success'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
car() {
|
||||
NavgateTo("../shopCar/index");
|
||||
},
|
||||
@ -774,69 +627,6 @@ export default {
|
||||
closeSize() {
|
||||
this.showSize = false;
|
||||
},
|
||||
// 提交立即购买订单
|
||||
submitBuyOrder() {
|
||||
// 检查是否选择了收货地址
|
||||
if (!this.defAddress || !this.defAddress.address) {
|
||||
uni.showToast({
|
||||
title: '请选择收货地址',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据平台设置不同的trans_type值
|
||||
// 小程序: 71, App: 51
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
let trans_type = 51; // 默认App环境
|
||||
|
||||
// 运行时判断是否为小程序环境
|
||||
if (systemInfo.platform === 'devtools' || systemInfo.platform === 'unknown') {
|
||||
trans_type = 71; // 开发工具或未知环境默认为小程序
|
||||
}
|
||||
|
||||
// 条件编译:针对不同平台设置不同值
|
||||
// #ifdef MP
|
||||
trans_type = 71; // 所有小程序平台
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
trans_type = 51; // App平台
|
||||
// #endif
|
||||
|
||||
// 原始逻辑:创建订单后再进行支付
|
||||
const params = {
|
||||
user_id: uni.getStorageSync('userId'),
|
||||
// 固定设置为1
|
||||
order_cate: 1,
|
||||
goods_list: [{
|
||||
supplier_id: this.info.supplier_id,
|
||||
supplier_name: this.currentGG.supplier_name || '',
|
||||
is_same_day: this.currentGG.is_same_day,
|
||||
receiving_name: this.defAddress.name,
|
||||
receiving_phone: this.defAddress.phone,
|
||||
receiving_address: this.defAddress.address + this.defAddress.house_number,
|
||||
merchant_id: this.defAddress.address_id,
|
||||
goods_and_count: [{
|
||||
goods_id: this.currentGG.id,
|
||||
count: this.changeCount,
|
||||
price: this.currentGG.sales_price
|
||||
}]
|
||||
}]
|
||||
}
|
||||
console.log("🚀 ~ params:", params)
|
||||
|
||||
request(apiArr.createOrder, "POST", params).then(resVal => {
|
||||
const param = {
|
||||
order_id: resVal.order_id,
|
||||
user_id: uni.getStorageSync('userId'),
|
||||
trans_type: trans_type
|
||||
}
|
||||
request(apiArr.mergePreorder, "POST", param).then(res => {
|
||||
this.handleMergePreorderResponse(res, resVal.order_id);
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取评论
|
||||
getComment(id) {
|
||||
let params = {}
|
||||
|
||||
@ -909,6 +909,7 @@ image {
|
||||
}
|
||||
|
||||
.itemSize {
|
||||
width: 30%;
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
background: #F6F7FB;
|
||||
@ -916,8 +917,6 @@ image {
|
||||
padding: 10rpx 15rpx;
|
||||
white-space: nowrap;
|
||||
margin: 20rpx 30rpx;
|
||||
display: inline-block;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.itemSize_active {
|
||||
|
||||
@ -324,7 +324,7 @@
|
||||
<image :src="changeImg" class="itemSize-img"></image>
|
||||
<view class="itemSize_info">
|
||||
<view class="itemSize_name">{{ changeName }}</view>
|
||||
<view class="itemSize_price">¥{{ changePrice }}/{{ goodsUnit }}</view>
|
||||
<view class="itemSize_price">¥{{ changePrice }}/袋</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="itemSize" v-for="(item, index) in info.commodity_goods_info_list" :key="item.id"
|
||||
@ -382,7 +382,7 @@
|
||||
<image :src="changeImg" class="itemSize-img"></image>
|
||||
<view class="itemSize_info">
|
||||
<view class="itemSize_name">{{ changeName }}</view>
|
||||
<view class="itemSize_price">¥{{ changePrice }}/{{ goodsUnit }}</view>
|
||||
<view class="itemSize_price">¥{{ changePrice }}/袋</view>
|
||||
</view>
|
||||
<view class="quantity-control">
|
||||
<view class="decrease-btn" @tap.stop="decreaseQuantity()">-</view>
|
||||
@ -557,7 +557,6 @@ export default {
|
||||
changeImg: "",
|
||||
changeName: "",
|
||||
changePrice: "",
|
||||
goodsUnit: "",
|
||||
|
||||
endTime: "",
|
||||
endTheCountdownDay: '',
|
||||
@ -1044,7 +1043,6 @@ export default {
|
||||
this.changeImg = this.currentGG.commodity_pic[0];
|
||||
this.changeName = this.currentGG.goods_alias;
|
||||
this.changePrice = this.currentGG.sales_price;
|
||||
this.goodsUnit = this.currentGG.goods_unit;
|
||||
} else {
|
||||
// 商品列表为空时的处理
|
||||
this.currentGG = null;
|
||||
@ -1052,7 +1050,6 @@ export default {
|
||||
this.changeImg = '';
|
||||
this.changeName = '';
|
||||
this.changePrice = '';
|
||||
this.goodsUnit = '';
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -1082,7 +1079,6 @@ export default {
|
||||
this.changeImg = item.commodity_pic[0]
|
||||
this.changeName = item.goods_alias
|
||||
this.changePrice = item.sales_price
|
||||
this.goodsUnit = item.goods_unit;
|
||||
},
|
||||
car() {
|
||||
const item = {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
}
|
||||
|
||||
.top-image{
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
}
|
||||
|
||||
.emptyCommunity {
|
||||
@ -87,8 +87,8 @@
|
||||
}
|
||||
|
||||
.work-order-icon {
|
||||
width: 55rpx;
|
||||
height: 55rpx;
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<view class="searchBox" :style="{ height: localHeight + 'px', paddingTop: top + 'px' }">
|
||||
<view class="searchBox_add" @click="addCommunity">
|
||||
<image class="top-image"
|
||||
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/workOrder_community_2.svg">
|
||||
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/workOrder_community.png" mode="aspectFill">
|
||||
</image>
|
||||
<view class="emptyCommunity">
|
||||
{{ communityVal }}
|
||||
@ -43,11 +43,11 @@
|
||||
<view class="work-order-card" v-if="index == 1 && showWorkOrderSection"
|
||||
@click="navigateToWorkOrderDashboard">
|
||||
<image class="work-order-icon"
|
||||
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/workOrder_2.svg" mode="aspectFill" />
|
||||
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/workOrder.png" mode="aspectFill" />
|
||||
<text class="work-order-text">工单台</text>
|
||||
</view>
|
||||
<view class="work-order-card" v-if="index == 0" @click="navigateToRoutingInspection">
|
||||
<image class="work-order-icon" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/polling_2.svg"
|
||||
<image class="work-order-icon" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/polling.png"
|
||||
mode="aspectFill" />
|
||||
<text class="work-order-text">巡更巡检</text>
|
||||
</view>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user