im商品跳转问题

master
2023-01-12 16:48:31 +08:00
parent 2c494ac0d1
commit b72d831df9
2 changed files with 840 additions and 844 deletions

View File

@ -19,16 +19,13 @@
<view>
<view class="user-name">{{ user.nickName }}</view>
<view class="margin-left padding-chat bg-user-orang" style="border-radius: 35rpx; ">
<text style="word-break: break-all;"
v-if="item.messageType === 'MESSAGE'">{{ item.text }}</text>
<text style="word-break: break-all;" v-if="item.messageType === 'MESSAGE'">{{ item.text }}</text>
<view v-if="item.messageType == 'GOODS'">
<view class="goodsCard u-flex u-row-between u-p-b-0"
style="width:100%;margin: 0 0; ">
<view class="imagebox" @click="jumpGoodDelic">
<image class="image" :src="JSON.parse(item.text)['thumbnail']"
mode="widthFix"></image>
<view class="goodsCard u-flex u-row-between u-p-b-0" style="width:100%;margin: 0 0; ">
<view class="imagebox" @click="jumpGoodDelic(item)">
<image class="image" :src="JSON.parse(item.text)['thumbnail']" mode="widthFix"></image>
</view>
<view class="goodsdesc" @click="jumpGoodDelic">
<view class="goodsdesc" @click="jumpGoodDelic(item)">
<view class="goodsdesc-name">
<text class="goodsCard_goodNmae">{{
JSON.parse(item.text)['goodsName']
@ -49,8 +46,9 @@
<img style="height: 120rpx; width: 120rpx; margin-top: 15rpx;"
:src="JSON.parse(item.text)['groupImages']" mode="widthFix" />
<view class="groupNameOrTime">
<text @click="linkTosOrders(item.text)">{{ JSON.parse(item.text)['groupName']
}}</text>
<text @click="linkTosOrders(item.text)">{{
JSON.parse(item.text)['groupName']
}}</text>
<view class="orderTime">
<text>{{ JSON.parse(item.text)['paymentTime'] }}</text>
</view>
@ -74,27 +72,23 @@
<view class="flex" style="width: 500rpx;">
<view>
<view class="other-name">{{ toUser.name }}</view>
<view class="margin-left padding-chat flex-column-start bg-to-color"
style="border-radius: 35rpx;">
<text style="word-break: break-all;"
v-if="item.messageType === 'MESSAGE'">{{ item.text }}</text>
<view class="margin-left padding-chat flex-column-start bg-to-color" style="border-radius: 35rpx;">
<text style="word-break: break-all;" v-if="item.messageType === 'MESSAGE'">{{ item.text }}</text>
<view v-if="item.messageType === 'GOODS'">
<view class="goodsCard u-flex u-row-between u-p-b-0"
style="width:100%;margin: 0 0; ">
<view class="imagebox" @click="jumpGoodDelic">
<image class="image" :src="JSON.parse(item.text)['thumbnail']"
mode="widthFix"></image>
<view class="goodsCard u-flex u-row-between u-p-b-0" style="width:100%;margin: 0 0; ">
<view class="imagebox" @click="jumpGoodDelic(item)">
<image class="image" :src="JSON.parse(item.text)['thumbnail']" mode="widthFix"></image>
</view>
<view class="goodsdesc" @click="jumpGoodDelic">
<view class="goodsdesc" @click="jumpGoodDelic(item)">
<view class="goodsdesc-name">
<text class="goodsCard_goodNmae">{{
JSON.parse(item.text)['goodsName']
}}</text>
}}</text>
</view>
<view class="goodsdesc-rice" style="margin-top:10rpx; color: orange;"><text
style="font-size:20rpx;">¥{{
JSON.parse(item.text)['price']
}}</text>
}}</text>
</view>
</view>
</view>
@ -106,8 +100,9 @@
<img style="height: 120rpx; width: 120rpx; margin-top: 15rpx;"
:src="JSON.parse(item.text)['groupImages']" mode="widthFix" />
<view class="groupNameOrTime">
<text @click="linkTosOrders(item.text)">{{ JSON.parse(item.text)['groupName']
}}</text>
<text @click="linkTosOrders(item.text)">{{
JSON.parse(item.text)['groupName']
}}</text>
<view class="orderTime">
<text>{{ JSON.parse(item.text)['paymentTime'] }}</text>
</view>
@ -126,17 +121,16 @@
:style="{ position: msgList.length == 0 ? 'fixed' : '', bottom: msgList.length == 0 ? '50px' : '', width: msgList.length == 0 ? '100%' : '' }">
<view class="cartMessage" v-if="showHide && !localImGoodsId && showHideModel">
<view class="goodsCard u-flex u-row-between u-p-b-0">
<view class="imagebox" @click="jumpGoodDelic">
<view class="imagebox" @click="jumpGoodDelic(item)">
<image class="image" :src="goodListData.thumbnail" mode="widthFix"></image>
</view>
<view class="goodsdesc" @click="jumpGoodDelic">
<view class="goodsdesc" @click="jumpGoodDelic(item)">
<view class="goodsdesc-name">
<text class="goodsCard_goodNmae">{{
goodListData.goodsName
}}</text>
</view>
<view class="goodsdesc-rice" style="margin-top:10rpx; color: orange;"><text
style="font-size:20rpx;">¥{{
<view class="goodsdesc-rice" style="margin-top:10rpx; color: orange;"><text style="font-size:20rpx;">¥{{
goodListData.price
}}</text>
</view>
@ -170,9 +164,8 @@
<view class="flex-column-center" style="position: fixed;bottom: -180px;" :animation="animationData">
<view class="bottom-dh-char flex-row-around" style="font-size: 55rpx;">
<!-- vue无法使用软键盘"发送" -->
<input v-model="msg" class="dh-input" type="text" style="background-color: #f0f0f0;"
@confirm="sendMessage" confirm-type="search" placeholder-class="my-neirong-sm"
placeholder="用一句简短的话描述您的问题" />
<input v-model="msg" class="dh-input" type="text" style="background-color: #f0f0f0;" @confirm="sendMessage"
confirm-type="search" placeholder-class="my-neirong-sm" placeholder="用一句简短的话描述您的问题" />
<view @click="sendMessage" class="cu-tag bg-cyan round">
发送
</view>
@ -194,26 +187,26 @@
</template>
<script>
// rpxpx
var l
//
var wh
//
var mgUpHeight
import {
// rpxpx
var l
//
var wh
//
var mgUpHeight
import {
getTalkMessage,
getTalkByUser,
jumpObtain
} from "@/api/im.js";
import SocketService from "@/utils/socket_service.js";
import storage from "@/utils/storage.js";
import {
} from "@/api/im.js";
import SocketService from "@/utils/socket_service.js";
import storage from "@/utils/storage.js";
import {
beautifyTime
} from "@/utils/filters.js"
import config from '@/config/config.js'
export default {
} from "@/utils/filters.js"
import config from '@/config/config.js'
export default {
// imGoodId
onUnload() {
onUnload () {
// #ifdef H5
uni.setStorageSync("imGoodId", '');
// #endif
@ -222,7 +215,7 @@
uni.closeSocket();
}
},
onLoad(options) {
onLoad (options) {
this.sokcet();
// goodsid
this.showHideModel = options.goodsid
@ -272,17 +265,18 @@
}
// this.ws.connect();
this.sokcet()
this.sokcet();
},
onPullDownRefresh() {
onPullDownRefresh () {
this.params.pageNumber = this.params.pageNumber + 1
this.getTalkMessage()
setTimeout(function() {
setTimeout(function () {
uni.stopPullDownRefresh();
}, 1000);
},
data() {
data () {
return {
socketOpen: false, //
storage,
@ -330,7 +324,7 @@
// }
// },
methods: {
sendMessage() {
sendMessage () {
if (this.msg == "") {
return 0;
}
@ -362,7 +356,7 @@
uni.closeSocket();
}
},
sendGoodsMessage() {
sendGoodsMessage () {
let msg = {
operation_type: "MESSAGE",
to: this.toUser.userId,
@ -391,7 +385,7 @@
});
})
},
sokcet() {
sokcet () {
var _this = this;
uni.closeSocket();
this.socketOpen = false;
@ -403,13 +397,13 @@
url: url,
});
// WebSocket
uni.onSocketOpen(function(res) {
uni.onSocketOpen(function (res) {
_this.socketOpen = true;
});
//
uni.onSocketError(function(err) {
uni.onSocketError(function (err) {
if (err && err.code !== 1000) {
setTimeout(function() {
setTimeout(function () {
_this.socketOpen = true;
uni.connectSocket({
url: url,
@ -418,9 +412,9 @@
}
});
//
uni.onSocketClose(function(err) {
uni.onSocketClose(function (err) {
if (err && err.code !== 1000) {
setTimeout(function() {
setTimeout(function () {
_this.socketOpen = true;
uni.connectSocket({
url: url,
@ -429,7 +423,8 @@
}
});
//
uni.onSocketMessage(function(res) {
uni.onSocketMessage(function (res) {
console.log(res.data, 'resresresresresres');
uni.hideLoading()
})
} catch (e) {
@ -439,7 +434,7 @@
},
beautifyTime,
//
linkTosOrders(val) {
linkTosOrders (val) {
let order = JSON.parse(val)
uni.navigateTo({
url: '/pages/order/orderDetail?sn=' + order.sn,
@ -447,25 +442,26 @@
},
//
jumpGoodDelic() {
jumpGoodDelic (item) {
let info = JSON.parse(item.text)
uni.navigateTo({
url: `/pages/product/goods?id=${this.resolve.skuid}&goodsId=${this.resolve.goodsid}`,
url: `/pages/product/goods?id=${info.id}&goodsId=${info.goodsId}`,
});
},
//
cancelModel() {
cancelModel () {
this.showHide = false
},
//
commodityDetails() {
commodityDetails () {
jumpObtain(this.resolve.skuid, this.resolve.goodsid).then((res) => {
this.goodListData = res.data.result.data
})
},
// (-->bug)
goPag(kh) {
goPag (kh) {
this.retractBox(0, 250)
if (this.keyHeight != 0) {
if (kh - this.keyHeight > 0) {
@ -475,7 +471,7 @@
}
},
//
messageBoxMove(x, t) {
messageBoxMove (x, t) {
var animation = uni.createAnimation({
duration: t,
timingFunction: 'linear',
@ -488,7 +484,7 @@
this.anData = animation.export()
},
//
msgGo(type) {
msgGo (type) {
console.log(type, 'typetypetype');
const query = uni.createSelectorQuery()
// 100ms
@ -528,7 +524,7 @@
}, 100)
},
//
answer(id) {
answer (id) {
// id,index
},
@ -574,7 +570,7 @@
// // }, 2000)
// },
//
ckAdd() {
ckAdd () {
if (!this.showTow) {
this.retractBox(-180, 350)
} else {
@ -582,11 +578,11 @@
}
this.showTow = !this.showTow
},
hideKey() {
hideKey () {
uni.hideKeyboard()
},
// /
retractBox(x, t) {
retractBox (x, t) {
var animation = uni.createAnimation({
duration: t,
@ -599,7 +595,7 @@
this.animationData = animation.export()
},
async getTalkMessage() {
async getTalkMessage () {
let type = '';
await getTalkMessage(this.params).then(res => {
if (res.data.success) {
@ -617,16 +613,17 @@
})
}
})
console.log(this.msgList);
this.msgGo(type)
},
touchMoreMessage(e) {
touchMoreMessage (e) {
if (e.target.scrollTop == 0) {
this.params.pageNumber = this.params.pageNumber + 1
this.getTalkMessage()
}
},
async getTalk(userId) {
async getTalk (userId) {
getTalkByUser(userId).then(res => {
if (res.data.success) {
this.toUser = res.data.result
@ -636,7 +633,7 @@
})
},
//
compareTime(index, datetime) {
compareTime (index, datetime) {
if (datetime == undefined) {
return false;
}
@ -678,7 +675,7 @@
* @param format 转换格式
* @returns {*|string}
*/
unixToDate(unix, format) {
unixToDate (unix, format) {
if (!unix) return unix;
let _format = format || "yyyy-MM-dd hh:mm:ss";
const d = new Date(unix);
@ -707,48 +704,48 @@
return _format;
},
}
}
}
</script>
<style lang="scss" scoped>
.orderTime {
.orderTime {
margin-top: 15rpx;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
.wrapper {
.wrapper {
height: auto !important;
}
}
.oederList {
.oederList {
display: flex;
color: black;
font-size: 20rpx;
font-weight: bold;
width: 95%;
}
}
.orderSn {
.orderSn {
width: 350rpx;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
.groupNameOrTime {
.groupNameOrTime {
margin: 15rpx 15rpx;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
.orderGood {
.orderGood {
background-color: #ffffff;
}
}
.goodsCard {
.goodsCard {
border-radius: 20rpx;
margin-top: 15rpx;
background-color: #ffffff;
@ -815,104 +812,104 @@
top: 20rpx;
right: 20rpx;
}
}
}
.cancel {
.cancel {
color: #737373;
position: relative;
bottom: 40rpx;
left: 12%;
}
}
.cartMessage {
.cartMessage {
display: flex;
justify-content: center;
align-items: center;
}
}
.bottom-dh-char {
.bottom-dh-char {
background-color: #f9f9f9;
width: 750rpx;
height: 110rpx;
}
}
.user-name {
.user-name {
text-align: right;
font-size: 24rpx;
color: #737373;
margin-bottom: 10rpx;
margin-right: 10rpx;
}
}
.other-name {
.other-name {
text-align: left;
font-size: 24rpx;
color: #737373;
margin-bottom: 10rpx;
margin-left: 10rpx;
}
}
.column-time {
.column-time {
justify-content: center;
}
}
.center-box {
.center-box {
width: 720rpx;
padding-left: 25rpx;
}
}
.hui-box {
.hui-box {
width: 750rpx;
height: 100%;
}
}
.date-text {
.date-text {
font-size: 12px;
color: grey;
}
}
.dh-input {
.dh-input {
width: 500rpx;
height: 65rpx;
border-radius: 30rpx;
padding-left: 15rpx;
font-size: 35rpx;
background-color: #FFFFFF;
}
}
.box-normal {
.box-normal {
width: 750rpx;
height: 180px;
background-color: #FFFFFF;
}
}
.tb-text view {
.tb-text view {
font-size: 65rpx;
}
}
.tb-text text {
.tb-text text {
font-size: 25rpx;
color: #737373;
}
}
.chat-img {
.chat-img {
border-radius: 50%;
width: 100rpx;
height: 100rpx;
background-color: #f7f7f7;
}
}
.padding-chat {
.padding-chat {
padding: 17rpx 20rpx;
}
}
.tb-nv {
.tb-nv {
width: 50rpx;
height: 50rpx;
}
}
</style>
<style lang="scss" scoped>
@import "./index-app.scss";
@import "./index-app.scss";
</style>

View File

@ -6,7 +6,7 @@ export default class SocketService {
* 单例
*/
static instance = null;
static get Instance() {
static get Instance () {
if (!this.instance) {
this.instance = new SocketService();
}
@ -29,12 +29,12 @@ export default class SocketService {
connectRetryCount = 0;
// 定义连接服务器的方法
connect() {
connect () {
// 连接服务器
if (!window.WebSocket) {
return console.log("您的浏览器不支持WebSocket");
}
this.ws = new WebSocket(config.baseWsUrl+'/'+storage.getAccessToken());
this.ws = new WebSocket(config.baseWsUrl + '/' + storage.getAccessToken());
// 连接成功的事件
this.ws.onopen = () => {
console.log("连接服务端成功");
@ -54,24 +54,23 @@ export default class SocketService {
};
// 得到服务端发送过来的数据
this.ws.onmessage = (msg) => {
// console.log(msg.data)
this.registerCallBack(msg.data);
};
}
// 回调函数的注册
registerCallBack(callBack) {
registerCallBack (callBack) {
// console.log("回调函数的注册", callBack);
this.callBackMapping = callBack;
}
// 取消某一个回调函数
unRegisterCallBack(callBack) {
unRegisterCallBack (callBack) {
console.log("取消某一个回调函数", callBack);
this.callBackMapping = null;
}
// 发送数据的方法
send(data) {
send (data) {
// 判断此时此刻有没有连接成功
if (this.connected) {
this.sendRetryCount = 0;