|
@@ -7,7 +7,7 @@
|
|
|
:scroll-into-view="scrollToView" refresher-enabled="true" :refresher-triggered="triggered"
|
|
|
@refresherrefresh="getFresh">
|
|
|
<view class="list-scroll-view">
|
|
|
- <view class="chat-ls" v-for="(item,index) in msgList" :key="index" :id="'msg'+ index">
|
|
|
+ <view class="chat-ls" v-for="(item,index) in msgList" :key="index" :id="'msg'+ item._id">
|
|
|
<view class="chat-time" v-if="item.time != ''">
|
|
|
{{item.time}}
|
|
|
</view>
|
|
@@ -24,6 +24,37 @@
|
|
|
@tap="previewImg(item.content)">
|
|
|
<image :src="item.content" class="msg-img" mode="widthFix"></image>
|
|
|
</view>
|
|
|
+ <!-- 商品 -->
|
|
|
+ <view class="message img" v-else-if="item.msg_type =='2'">
|
|
|
+ <view class="msg-goods">
|
|
|
+ <image :src="item.goodsInfo&&item.goodsInfo.file" class="image" mode="widthFix">
|
|
|
+ </image>
|
|
|
+ <view class="goods_1">
|
|
|
+ <view class="name textOver">{{item.goodsInfo&&item.goodsInfo.name}}</view>
|
|
|
+ <view class="money">
|
|
|
+ <text class="money_1"
|
|
|
+ v-if="item.goodsInfo&&item.goodsInfo.spec&&item.goodsInfo.spec.leader_price"><text>团长价¥</text>{{item.goodsInfo.spec.leader_price||0}}</text>
|
|
|
+ <text class="money_2"
|
|
|
+ v-else-if="item.goodsInfo&&item.goodsInfo.spec&&item.goodsInfo.spec.price"><text>特价¥</text>{{item.goodsInfo.spec.price||0}}</text>
|
|
|
+ <text class="money_2"
|
|
|
+ v-else><text>¥</text>{{item.goodsInfo.spec.sell_money||0}}</text>
|
|
|
+ <text
|
|
|
+ class="money_2"><text>¥</text>{{item.goodsInfo.spec.flow_money||0}}</text>
|
|
|
+ </view>
|
|
|
+ <view class="act" v-if="item.goodsInfo&&item.goodsInfo.act">
|
|
|
+ <text class="label" v-for="(tag,index) in item.goodsInfo.act"
|
|
|
+ :key="index">{{tag}}</text>
|
|
|
+ </view>
|
|
|
+ <view class="button" @tap="toSend(item)" v-if="item.is_send=='0'">
|
|
|
+ <text>发送连接</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <!-- 订单 -->
|
|
|
+ <view class="message img" v-else-if="item.msg_type =='3'">
|
|
|
+ <view class="msg-text">{{item.content}}</view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
<view class="msg-m msg-right" v-else-if="item.speaker == user._id">
|
|
|
<image class="user-img" :src="user.icon&&user.icon.length>0?user.icon[0].url:''">
|
|
@@ -37,6 +68,37 @@
|
|
|
@tap="previewImg(item.content)">
|
|
|
<image :src="item.content" class="msg-img" mode="widthFix"></image>
|
|
|
</view>
|
|
|
+ <!-- 商品 -->
|
|
|
+ <view class="message img" v-else-if="item.msg_type =='2'">
|
|
|
+ <view class="msg-goods">
|
|
|
+ <image :src="item.goodsInfo&&item.goodsInfo.file" class="image" mode="widthFix">
|
|
|
+ </image>
|
|
|
+ <view class="goods_1">
|
|
|
+ <view class="name textOver">{{item.goodsInfo&&item.goodsInfo.name}}</view>
|
|
|
+ <view class="money">
|
|
|
+ <text class="money_1"
|
|
|
+ v-if="item.goodsInfo&&item.goodsInfo.spec&&item.goodsInfo.spec.leader_price"><text>团长价¥</text>{{item.goodsInfo.spec.leader_price||0}}</text>
|
|
|
+ <text class="money_2"
|
|
|
+ v-else-if="item.goodsInfo&&item.goodsInfo.spec&&item.goodsInfo.spec.price"><text>特价¥</text>{{item.goodsInfo.spec.price||0}}</text>
|
|
|
+ <text class="money_2"
|
|
|
+ v-else><text>¥</text>{{item.goodsInfo.spec.sell_money||0}}</text>
|
|
|
+ <text
|
|
|
+ class="money_2"><text>¥</text>{{item.goodsInfo.spec.flow_money||0}}</text>
|
|
|
+ </view>
|
|
|
+ <view class="act" v-if="item.goodsInfo&&item.goodsInfo.act">
|
|
|
+ <text class="label" v-for="(tag,index) in item.goodsInfo.act"
|
|
|
+ :key="index">{{tag}}</text>
|
|
|
+ </view>
|
|
|
+ <view class="button" @tap="toSend(item)" v-if="item.is_send=='0'">
|
|
|
+ <text>发送连接</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <!-- 订单 -->
|
|
|
+ <view class="message img" v-else-if="item.msg_type =='3'">
|
|
|
+ <view class="msg-text">{{item.content}}</view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -65,8 +127,10 @@
|
|
|
// 店铺信息
|
|
|
shop: {},
|
|
|
shop_id: "",
|
|
|
- // 商品或订单信息
|
|
|
+ // 商品或订单信息条件
|
|
|
goods: {},
|
|
|
+ // 订单状态
|
|
|
+ statusList: [],
|
|
|
// 历史记录
|
|
|
msgList: [],
|
|
|
total: 0,
|
|
@@ -80,10 +144,11 @@
|
|
|
scrollToView: '', //滑动最后一条信息
|
|
|
};
|
|
|
},
|
|
|
- onShow() {
|
|
|
+ onShow: async function() {
|
|
|
const that = this;
|
|
|
that.clearPage();
|
|
|
- if (that.id) that.search()
|
|
|
+ if (that.id) await that.search()
|
|
|
+ await that.searchOther();
|
|
|
},
|
|
|
onLoad: async function(e) {
|
|
|
const that = this;
|
|
@@ -111,12 +176,105 @@
|
|
|
const that = this;
|
|
|
uni.getStorage({
|
|
|
key: 'token',
|
|
|
- success: function(res) {
|
|
|
+ success: async function(res) {
|
|
|
let user = that.$jwt(res.data);
|
|
|
- if (user) that.$set(that, `user`, user)
|
|
|
+ if (user) {
|
|
|
+ let res;
|
|
|
+
|
|
|
+ that.$set(that, `user`, user)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ // 查询商品或订单信息
|
|
|
+ async searchOther() {
|
|
|
+ const that = this;
|
|
|
+ let res;
|
|
|
+ // 发送商品信息
|
|
|
+ if (that.goods && that.goods.goods) {
|
|
|
+ // 商品
|
|
|
+ res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
|
|
|
+ id: that.goods.goods
|
|
|
+ });
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ let indexSpecs;
|
|
|
+ // 显示最低价格的规格信息,不考虑库存问题
|
|
|
+ if (res.data.specs && res.data.specs.length > 0) {
|
|
|
+ // 规格排序
|
|
|
+ indexSpecs = res.data.specs.sort(function(a, b) {
|
|
|
+ let i, j;
|
|
|
+ if (a.price) i = 'price'
|
|
|
+ else i = 'sell_money'
|
|
|
+ if (b.price) j = 'price'
|
|
|
+ else j = 'sell_money'
|
|
|
+ return a[i] - b[j];
|
|
|
+ })
|
|
|
+ }
|
|
|
+ let act = res.data.act.map(i => {
|
|
|
+ return i.tag
|
|
|
+ })
|
|
|
+ let goodsInfo = {
|
|
|
+ "file": res.data && res.data.goods && res.data.goods.file && res.data.goods.file[0]
|
|
|
+ .url,
|
|
|
+ "name": res.data && res.data.goods && res.data.goods.name,
|
|
|
+ "spec": indexSpecs[0],
|
|
|
+ "act": act
|
|
|
+ }
|
|
|
+ let data = {
|
|
|
+ "_id": 'xx' + moment(new Date()).valueOf(),
|
|
|
+ "speaker": that.user._id,
|
|
|
+ "content": that.goods.goods,
|
|
|
+ "goodsInfo": goodsInfo,
|
|
|
+ "time": moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ "msg_type": '2',
|
|
|
+ "is_send": '0'
|
|
|
+ }
|
|
|
+ if (!that.id) data.shop = that.shop_id
|
|
|
+ else data.room = that.id
|
|
|
+ that.msgList.push(data);
|
|
|
+ // 跳转到最后一条数据 与前面的:id进行对照
|
|
|
+ // 如果是下拉刷新聊天记录不跳到最后一条
|
|
|
+ if (that.is_bottom == true) that.goBottom();
|
|
|
+ }
|
|
|
+ } else if (that.goods && that.goods.order) {
|
|
|
+ // 订单
|
|
|
+ if (that.goods.status == '0') res = await that.$api(`/order/${that.goods.order}`)
|
|
|
+ else res = await that.$api(`/orderDetail/${that.goods.order}`);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ // 查询状态
|
|
|
+ let arr = await that.$api(`/dictData`, 'GET', {
|
|
|
+ code: 'order_process'
|
|
|
+ })
|
|
|
+ if (arr.errcode == '0') that.$set(that, `statusList`, arr.data);
|
|
|
+ let status = arr.data.find(i => i.value == res.data.status)
|
|
|
+ // 过滤店铺订单
|
|
|
+ let shop_goods;
|
|
|
+ if (!that.id) shop_goods = res.data.goods.filter(i => i.shop == that.shop_id)
|
|
|
+ else shop_goods = res.data.goods.filter(i => i.shop == that.shop._id)
|
|
|
+ let ordernfo = {
|
|
|
+ "no": res.data && res.data.no,
|
|
|
+ "goods": shop_goods,
|
|
|
+ "status": status.label || '暂无'
|
|
|
+ }
|
|
|
+ let data = {
|
|
|
+ "_id": 'dd' + moment(new Date()).valueOf(),
|
|
|
+ "speaker": that.user._id,
|
|
|
+ "content": that.goods.order,
|
|
|
+ "ordernfo": ordernfo,
|
|
|
+ "time": moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ "msg_type": '3',
|
|
|
+ "is_send": '0'
|
|
|
+ }
|
|
|
+ if (!that.id) data.shop = that.shop_id
|
|
|
+ else data.room = that.id
|
|
|
+ that.msgList.push(data);
|
|
|
+ console.log(data);
|
|
|
+ // 跳转到最后一条数据 与前面的:id进行对照
|
|
|
+ // 如果是下拉刷新聊天记录不跳到最后一条
|
|
|
+ if (that.is_bottom == true) that.goBottom();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
// 查询历史记录
|
|
|
async search() {
|
|
|
const that = this;
|
|
@@ -134,9 +292,44 @@
|
|
|
msgList.sort(function(a, b) {
|
|
|
return a.time > b.time ? 1 : -1;
|
|
|
});
|
|
|
+ for (let val of msgList) {
|
|
|
+ if (val.msg_type == '2') {
|
|
|
+ // 商品
|
|
|
+ res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
|
|
|
+ id: val.content
|
|
|
+ });
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ let indexSpecs;
|
|
|
+ // 显示最低价格的规格信息,不考虑库存问题
|
|
|
+ if (res.data.specs && res.data.specs.length > 0) {
|
|
|
+ // 规格排序
|
|
|
+ indexSpecs = res.data.specs.sort(function(a, b) {
|
|
|
+ let i, j;
|
|
|
+ if (a.price) i = 'price'
|
|
|
+ else i = 'sell_money'
|
|
|
+ if (b.price) j = 'price'
|
|
|
+ else j = 'sell_money'
|
|
|
+ return a[i] - b[j];
|
|
|
+ })
|
|
|
+ }
|
|
|
+ let act = res.data.act.map(i => {
|
|
|
+ return i.tag
|
|
|
+ })
|
|
|
+ let goodsInfo = {
|
|
|
+ "file": res.data && res.data.goods && res.data.goods.file && res.data.goods
|
|
|
+ .file[0]
|
|
|
+ .url,
|
|
|
+ "name": res.data && res.data.goods && res.data.goods.name,
|
|
|
+ "spec": indexSpecs[0],
|
|
|
+ "act": act,
|
|
|
+ }
|
|
|
+ val.goodsInfo = goodsInfo
|
|
|
+ val.is_send = '1'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
that.$set(that, `msgList`, msgList);
|
|
|
that.$set(that, `total`, res.total)
|
|
|
-
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: res.errmsg,
|
|
@@ -179,21 +372,6 @@
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
- // 发送商品信息
|
|
|
- if (that.goods && that.goods.goods) {
|
|
|
- // 商品
|
|
|
- res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
|
|
|
- id: that.goods.goods
|
|
|
- });
|
|
|
- if (res.errcode == '0') {
|
|
|
- console.log(res.data);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 订单
|
|
|
- }
|
|
|
- // 跳转到最后一条数据 与前面的:id进行对照
|
|
|
- // 如果是下拉刷新聊天记录不跳到最后一条
|
|
|
- if (that.is_bottom == true) that.goBottom();
|
|
|
},
|
|
|
// 进行图片的预览
|
|
|
previewImg(e) {
|
|
@@ -249,6 +427,31 @@
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+ // 发送连接
|
|
|
+ async toSend(e) {
|
|
|
+ const that = this;
|
|
|
+ //时间间隔处理
|
|
|
+ let data = {
|
|
|
+ "speaker": e.speaker,
|
|
|
+ "content": e.content,
|
|
|
+ "time": moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ "msg_type": e.msg_type
|
|
|
+ };
|
|
|
+ if (!that.id) data.shop = that.shop_id
|
|
|
+ else data.room = that.id
|
|
|
+ let res = await that.$api(`/chatRecord`, `POST`, data, 'chat');
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ e.is_send = '1'
|
|
|
+ that.msgList = that.msgList.map(t => {
|
|
|
+ return t.time === e.time ? e : t;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.errmsg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
// 店铺
|
|
|
toShop() {
|
|
|
const that = this;
|
|
@@ -266,8 +469,9 @@
|
|
|
goBottom() {
|
|
|
const that = this;
|
|
|
that.scrollToView = '';
|
|
|
+ let lastItem = that.msgList.at(-1);
|
|
|
that.$nextTick(function() {
|
|
|
- that.scrollToView = 'msg' + (that.msgList.length - 1)
|
|
|
+ that.scrollToView = 'msg' + (lastItem._id)
|
|
|
})
|
|
|
},
|
|
|
// 下拉刷新分页
|
|
@@ -367,6 +571,82 @@
|
|
|
max-width: 400rpx;
|
|
|
border-radius: 20rpx;
|
|
|
}
|
|
|
+
|
|
|
+ .msg-goods {
|
|
|
+ display: flex;
|
|
|
+ padding: 20rpx 10rpx;
|
|
|
+ background-color: #f0f0f0;
|
|
|
+ border-radius: 10rpx;
|
|
|
+
|
|
|
+ .image {
|
|
|
+ width: 100rpx;
|
|
|
+ height: 100rpx;
|
|
|
+ border-radius: 10rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .goods_1 {
|
|
|
+ width: 350rpx;
|
|
|
+ margin: 0 0 0 10rpx;
|
|
|
+
|
|
|
+ .name {
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .money {
|
|
|
+ .money_1 {
|
|
|
+ color: #23B67A;
|
|
|
+ font-size: 16px;
|
|
|
+ padding: 0 1vw 0 0;
|
|
|
+ font-weight: bold;
|
|
|
+
|
|
|
+ text {
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .money_2 {
|
|
|
+ font-size: 16px;
|
|
|
+ padding: 0 1vw 0 0;
|
|
|
+ color: #ff0000;
|
|
|
+ font-weight: bold;
|
|
|
+
|
|
|
+ text {
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .money_2:last-child {
|
|
|
+ font-size: 14px;
|
|
|
+ color: #858585;
|
|
|
+ text-decoration: line-through;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .act {
|
|
|
+ .label {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #FFA500;
|
|
|
+ border: 1px solid #FFA500;
|
|
|
+ border-radius: 5px;
|
|
|
+ padding: 0 1vw;
|
|
|
+ margin: 0 1vw 0 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .button {
|
|
|
+ text-align: right;
|
|
|
+ margin: 1rpx 0;
|
|
|
+
|
|
|
+ text {
|
|
|
+ font-size: 12px;
|
|
|
+ padding: 10rpx;
|
|
|
+ border-radius: 10rpx;
|
|
|
+ color: #FF4500;
|
|
|
+ background-color: #FFF8DC;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.msg-left {
|