|
@@ -245,8 +245,67 @@
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
- listenWebsocket: function(newstr) {
|
|
|
+ listenWebsocket: async function(newstr) {
|
|
|
if (newstr && newstr.type == 'chat' && newstr.room == this.id) {
|
|
|
+ if (newstr.msg_type == '2') {
|
|
|
+ // 商品
|
|
|
+ res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
|
|
|
+ id: newstr.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,
|
|
|
+ }
|
|
|
+ newstr.goodsInfo = goodsInfo
|
|
|
+ newstr.is_send = '1'
|
|
|
+ }
|
|
|
+ } else if (newstr.msg_type == '3') {
|
|
|
+ // 订单
|
|
|
+ res = await that.$api(`/viewOrder/getOrder/${newstr.content}`)
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ let status = that.statusList.find(i => i.value == res.data.status)
|
|
|
+ // 过滤店铺订单
|
|
|
+ let shop_goods;
|
|
|
+ if (res.data.status != '0') {
|
|
|
+ // 已支付订单
|
|
|
+ shop_goods = res.data.goods
|
|
|
+ } else {
|
|
|
+ // 未支付订单
|
|
|
+ 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)
|
|
|
+ if (shop_goods.length > 0) shop_goods = shop_goods[0].goods
|
|
|
+ }
|
|
|
+ let ordernfo = {
|
|
|
+ "no": res.data && res.data.no,
|
|
|
+ "goods": shop_goods,
|
|
|
+ "status": status.label || '暂无',
|
|
|
+ "is_status": res.data.status
|
|
|
+ }
|
|
|
+ newstr.ordernfo = ordernfo
|
|
|
+ newstr.is_send = '1'
|
|
|
+ }
|
|
|
+ }
|
|
|
this.msgList.push(newstr);
|
|
|
this.goBottom();
|
|
|
}
|