1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <!-- 聊天内容 -->
- <scroll-view class="scroll-view" scroll-y="true" scroll-with-animation="true"
- :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'+ item._id">
- <view class="chat-time" v-if="item.time != ''">
- {{item.time}}
- </view>
- <view class="msg-m msg-left" v-if="item.speaker != user._id">
- <image @tap="toShop()" class="user-img"
- :src="shop.logo&&shop.logo.length>0?shop.logo[0].url:''">
- </image>
- <!-- 文字 -->
- <view class="message" v-if="item.msg_type =='0'">
- <view class="msg-text">{{item.content}}</view>
- </view>
- <!-- 图像 -->
- <view class="message img" v-else-if="item.msg_type =='1'"
- @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'" @tap="toView(item)">
- <view class="msg-goods">
- <image :src="item.goodsInfo&&item.goodsInfo.file" class="image"
- mode="scaleToFill">
- </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.stop="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'" @tap="toView(item)">
- <view class="msg-order">
- <view class="order_1">
- <view class="image" v-for="(tago,index) in item.ordernfo.goods"
- :key="index">
- <image v-if="tago.file.length>0" :src="tago.file&&tago.file[0].url"
- class="image" mode="scaleToFill">
- </image>
- <image v-else :src="tago.goods&&tago.goods.file[0].url" class="image"
- mode="scaleToFill">
- </image>
- </view>
- </view>
- <view class="order_2">
- <view class="no">订单号:{{item.ordernfo.no}}</view>
- <view class="status">
- <text>{{item.ordernfo.status}}</text>
- <view class="button" @tap.stop="toSend(item)" v-if="item.is_send=='0'">
- <text>发送连接</text>
- </view>
- </view>
- </view>
- </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:''">
- </image>
- <!-- 文字 -->
- <view class="message" v-if="item.msg_type =='0'">
- <view class="msg-text">{{item.content}}</view>
- </view>
- <!-- 图像 -->
- <view class="message img" v-else-if="item.msg_type =='1'"
- @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'" @tap="toView(item)">
- <view class="msg-goods">
- <image :src="item.goodsInfo&&item.goodsInfo.file" class="image"
- mode="scaleToFill">
- </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.stop="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'" @tap="toView(item)">
- <view class="msg-order">
- <view class="order_1">
- <view class="images" v-for="(tago,index) in item.ordernfo.goods"
- :key="index">
- <image v-if="tago.file.length>0" :src="tago.file&&tago.file[0].url"
- class="image" mode="scaleToFill">
- </image>
- <image v-else :src="tago.goods&&tago.goods.file[0].url" class="image"
- mode="scaleToFill">
- </image>
- </view>
- </view>
- <view class="order_2">
- <view class="no">订单号:{{item.ordernfo.no}}</view>
- <view class="status">
- <text>{{item.ordernfo.status}}</text>
- <view class="button" @tap.stop="toSend(item)" v-if="item.is_send=='0'">
- <text>发送连接</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="two">
- <submit_1 @choseImg="choseImg" @inputs="inputs" @heights="heights" @sendGoods="sendGoods"
- @sendOrder="sendOrder"></submit_1>
- </view>
- </view>
- <!-- 规格 -->
- <uni-popup ref="specShow" background-color="#fff" type="bottom" :is-mask-click="false">
- <view class="popup">
- <view class="close">
- <text @click="toClose" class="iconfont icon-shanchu"></text>
- </view>
- <view class="info_1" v-if="popupShow=='1'">
- <goods_1 :marketList="list" @toPage="toPage" @toSend="toGoods"></goods_1>
- </view>
- <view class="info_1" v-else-if="popupShow=='2'">
- <order_1 :tabs="tabs" :status="status" :orderList="list" @toPage="toPage" @toSend="toOrder"
- @tabsChange="tabsChange">
- </order_1>
- </view>
- </view>
- </uni-popup>
- </mobile-frame>
- </template>
- <script>
- import moment from 'moment';
- import submit_1 from './components/submit_1.vue';
- import goods_1 from './components/goods_1.vue';
- import order_1 from './components/order_1.vue';
- export default {
- components: {
- submit_1,
- goods_1,
- order_1,
- },
- data() {
- return {
- // 用户信息
- user: {},
- // 房间号id
- id: '',
- // 店铺信息
- shop: {},
- shop_id: "",
- // 商品或订单信息条件
- goods: {},
- // 订单状态
- statusList: [],
- // 历史记录
- msgList: [],
- // 订单列表
- list: [],
- status: '0',
- tabs: {
- active: '0',
- menu: []
- },
- // 聊天记录
- total: 0,
- skip: 0,
- limit: 6,
- page: 0,
- // 判断是否跳到最后一条
- is_bottom: true,
- // 判断是否下拉刷新复位
- triggered: false,
- scrollToView: '', //滑动最后一条信息
- // 规格弹框
- popupShow: '1',
- // 判断是否是选择图片刷新
- is_img: false
- };
- },
- onShow: async function() {
- const that = this;
- // 判断是否是选择图片刷新
- if (!that.is_img) {
- if (that.id) {
- await that.clearPage();
- await that.search()
- }
- await that.searchOther();
- }
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `goods`, e);
- that.$set(that, `id`, e.id);
- that.$set(that, `shop_id`, e.shop);
- that.watchlogin();
- },
- computed: {
- listenWebsocket() {
- return this.$store.state.websocketData;
- }
- },
- watch: {
- listenWebsocket: function(newstr) {
- if (newstr && newstr.type == 'chat' && newstr.room == this.id) {
- this.msgList.push(newstr);
- this.goBottom();
- }
- }
- },
- methods: {
- // 监听用户是否登录
- watchlogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: async function(res) {
- let user = that.$jwt(res.data);
- if (user) {
- // 查询状态
- let arr = await that.$api(`/dictData`, 'GET', {
- code: 'order_process'
- })
- if (arr.errcode == '0') that.$set(that, `statusList`, arr.data);
- that.$set(that, `user`, user)
- }
- }
- })
- },
- // 查询商品或订单信息
- async searchOther() {
- const that = this;
- let res;
- let statusList = that.statusList.filter((i) => {
- return i.value != '-2' && i.value != '-3';
- });
- var menu = statusList.map((item) => {
- return {
- title: item.label,
- active: item.value
- }
- })
- that.$set(that.tabs, `menu`, menu)
- // 发送商品信息
- 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": 'goods' + 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);
- }
- } 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 status = that.statusList.find(i => i.value == res.data.status)
- // 过滤店铺订单
- let shop_goods;
- if (that.goods.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
- }
- let data = {
- "_id": 'order' + 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);
- }
- }
- // 跳转到最后一条数据 与前面的:id进行对照
- // 如果是下拉刷新聊天记录不跳到最后一条
- if (that.is_bottom == true) that.goBottom();
- },
- // 查询历史记录
- async search() {
- const that = this;
- // 查询房间信息
- // 如果是下拉刷新聊天记录不请求房间信息
- if (that.is_bottom == true) {
- res = await that.$api(`/room/${that.id}`, `GET`, {}, 'chat')
- if (res.errcode == '0') {
- that.$set(that, `shop`, res.data && res.data.shop);
- if (res.data && res.data.shop && res.data.shop.name) {
- uni.setNavigationBarTitle({
- title: res.data.shop.name
- });
- }
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- }
- let info = {
- skip: that.skip,
- limit: that.limit,
- room: that.id
- }
- let res;
- res = await that.$api(`/chatRecord`, `GET`, {
- ...info,
- }, 'chat');
- if (res.errcode == '0') {
- let msgList = [...res.data, ...that.msgList];
- msgList.sort(function(a, b) {
- return a.time > b.time ? 1 : -1;
- });
- that.$set(that, `total`, res.total)
- 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'
- }
- } else if (val.msg_type == '3') {
- // 订单
- res = await that.$api(`/viewOrder/getOrder/${val.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
- }
- val.ordernfo = ordernfo
- val.is_send = '1'
- }
- }
- }
- that.$set(that, `msgList`, msgList);
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- let id = that.msgList.filter(i => {
- if (i.speaker != that.user._id) return i.is_read = '0';
- })
- let ids = id.map(i => {
- return i._id
- })
- if (ids.length > 0) {
- // 信息已读
- res = await that.$api(`/chatRecord/read`, `POST`, {
- ids
- }, 'chat')
- if (res.errcode == '0') {} else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- }
- },
- // 进行图片的预览
- previewImg(e) {
- const that = this;
- // 预览图片
- uni.previewImage({
- current: 0,
- urls: [e],
- longPressActions: {
- itemList: ['发送给朋友', '保存图片', '收藏'],
- success: function(data) {
- console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) +
- '张图片');
- },
- fail: function(err) {
- console.log(err.errMsg);
- }
- }
- });
- },
- // 判断是否是选择图片刷新
- choseImg(e) {
- const that = this;
- that.$set(that, `is_img`, e)
- },
- //接受输入内容
- async inputs(e) {
- const that = this;
- let user = that.user
- if (user._id) {
- //时间间隔处理
- let data = {
- "speaker": user._id,
- "content": e.message,
- "time": moment().format('YYYY-MM-DD HH:mm:ss'),
- "msg_type": e.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') {
- that.msgList.push(res.data);
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- // 跳转到最后一条数据 与前面的:id进行对照
- that.goBottom();
- } else {
- uni.showToast({
- title: '未登录账号无法发送消息 ,请及时登录!',
- icon: 'none'
- })
- }
- },
- // 发送连接
- 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'
- })
- }
- },
- // 发送商品
- async sendGoods() {
- const that = this;
- let res;
- let info = {
- skip: that.skip,
- limit: that.limit,
- shop: that.shop._id || that.shop_id
- };
- // 首页产品列表
- res = await that.$api(`/viewGoods/indexGoodsList`, `GET`, {
- ...info
- });
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- that.$set(that, `list`, list);
- that.$set(that, `total`, res.total)
- that.$set(that, `popupShow`, '1')
- that.$refs.specShow.open();
- }
- },
- // 发送商品
- async toGoods(e) {
- const that = this;
- let user = that.user
- if (user._id) {
- let res;
- // 商品
- res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
- id: e._id
- });
- 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 = {
- "speaker": user._id,
- "content": e._id,
- "time": moment().format('YYYY-MM-DD HH:mm:ss'),
- "msg_type": '2',
- };
- if (!that.id) data.shop = that.shop_id
- else data.room = that.id
- res = await that.$api(`/chatRecord`, `POST`, data, 'chat');
- if (res.errcode == '0') {
- res.data.goodsInfo = goodsInfo
- res.data.is_send = '1'
- that.msgList.push(res.data);
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- }
- // 跳转到最后一条数据 与前面的:id进行对照
- that.goBottom();
- that.toClose();
- } else {
- uni.showToast({
- title: '未登录账号无法发送消息 ,请及时登录!',
- icon: 'none'
- })
- }
- },
- // 分页
- toPage(e) {
- const that = this;
- let list = that.list;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- if (that.popupShow == '1') that.sendGoods();
- else that.sendOrder();
- uni.hideLoading();
- }
- },
- // 发送订单
- async sendOrder() {
- const that = this;
- let user = that.user;
- let status = that.status;
- let info = {
- skip: that.skip,
- limit: that.limit,
- customer: user._id,
- shop: that.shop._id || that.shop_id,
- status: status
- }
- let res;
- if (status == '0') {
- res = await that.$api(`/order`, 'GET', {
- ...info,
- });
- } else {
- res = await that.$api(`/orderDetail`, 'GET', {
- ...info,
- });
- }
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- for (let val of list) {
- val.zhStatus = that.searchStatus(val.status)
- }
- that.$set(that, `list`, list);
- that.$set(that, `total`, res.total)
- that.$set(that, `popupShow`, '2')
- that.$refs.specShow.open();
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- },
- // 发送订单
- async toOrder(e) {
- const that = this;
- let user = that.user
- if (user._id) {
- let res;
- // 订单
- if (e.status == '0') res = await that.$api(`/order/${e._id}`)
- else res = await that.$api(`/orderDetail/${e._id}`);
- if (res.errcode == '0') {
- let status = that.statusList.find(i => i.value == res.data.status)
- // 过滤店铺订单
- let shop_goods;
- if (e.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
- }
- //时间间隔处理
- let data = {
- "speaker": user._id,
- "content": e._id,
- "time": moment().format('YYYY-MM-DD HH:mm:ss'),
- "msg_type": '3',
- };
- if (!that.id) data.shop = that.shop_id
- else data.room = that.id
- res = await that.$api(`/chatRecord`, `POST`, data, 'chat');
- if (res.errcode == '0') {
- res.data.ordernfo = ordernfo
- res.data.is_send = '1'
- that.msgList.push(res.data);
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- }
- // 跳转到最后一条数据 与前面的:id进行对照
- that.goBottom();
- that.toClose();
- } else {
- uni.showToast({
- title: '未登录账号无法发送消息 ,请及时登录!',
- icon: 'none'
- })
- }
- },
- // 查询状态
- searchStatus(e) {
- const that = this;
- let data = that.statusList.find((i) => i.value == e);
- if (data) return data.label
- else return '暂无'
- },
- // 选择选项卡
- tabsChange(e) {
- const that = this;
- that.$set(that.tabs, `active`, e.active)
- that.$set(that, `status`, e.active);
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- that.sendOrder()
- },
- // 关闭弹框
- toClose() {
- const that = this;
- that.$refs.specShow.close();
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- },
- // 店铺
- toShop() {
- const that = this;
- let id = that.shop._id
- uni.navigateTo({
- url: `/pagesHome/shop/index?id=${id}`
- })
- },
- // 查看详情
- toView(e) {
- const that = this;
- if (e.msg_type == '2') {
- let id = e.content;
- uni.navigateTo({
- url: `/pagesHome/order/detail?id=${id}`
- })
- } else {
- let status = e.ordernfo.is_status;
- uni.navigateTo({
- url: `/pagesMy/order/index?status=${status}`
- })
- }
- },
- //输入框高度
- heights(e) {
- const that = this;
- that.goBottom();
- },
- // 滚动到底部
- async goBottom() {
- const that = this;
- that.scrollToView = '';
- let lastItem = that.msgList.at(-1);
- that.$nextTick(function() {
- that.scrollToView = 'msg' + (lastItem._id)
- })
- },
- // 下拉刷新分页
- getFresh(e) {
- const that = this;
- that.triggered = true;
- let msgList = that.msgList;
- let limit = that.limit;
- setTimeout(() => {
- if (that.total > msgList.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.$set(that, `is_bottom`, false)
- that.search();
- uni.hideLoading();
- } else {
- uni.showToast({
- title: `没有更多聊天记录了`,
- icon: 'none'
- })
- }
- that.triggered = false;
- }, 1000)
- },
- clearPage() {
- const that = this;
- that.$set(that, `msgList`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- },
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- overflow: hidden;
- .one {
- position: relative;
- flex-grow: 1;
- .scroll-view {
- .chat-ls {
- padding: 2vw 2vw 0 2vw;
- .chat-time {
- font-size: 24rpx;
- color: rgba(39, 40, 50, 0.3);
- line-height: 34rpx;
- padding: 10rpx 0rpx;
- text-align: center;
- }
- .msg-m {
- display: flex;
- padding: 20rpx 0;
- .user-img {
- flex: none;
- width: 80rpx;
- height: 80rpx;
- border-radius: 40rpx;
- border: 1px solid #c0c0c0;
- }
- .message {
- flex: none;
- max-width: 480rpx;
- }
- .img {
- margin: 0 20rpx;
- }
- .msg-text {
- font-size: 32rpx;
- color: rgba(39, 40, 50, 1);
- line-height: 44rpx;
- padding: 18rpx 24rpx;
- word-break: break-all;
- }
- .msg-img {
- 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-order {
- width: 460rpx;
- padding: 20rpx 10rpx;
- background-color: #f0f0f0;
- border-radius: 10rpx;
- .order_1 {
- display: flex;
- flex-wrap: wrap;
- margin: 10rpx 0;
- .image {
- width: 100rpx;
- height: 100rpx;
- border-radius: 10rpx;
- margin: 0 5rpx 0 0;
- border: 1rpx solid #858585;
- }
- }
- .order_2 {
- margin: 10rpx 0;
- .no {
- font-size: 12px;
- }
- .status {
- display: flex;
- justify-content: space-between;
- margin: 5rpx 0;
- text {
- padding: 1rpx 2rpx;
- border-radius: 5px;
- font-size: 12px;
- color: #ff0000;
- }
- .button {
- text-align: right;
- text {
- font-size: 12px;
- padding: 10rpx;
- border-radius: 10rpx;
- color: #FF4500;
- background-color: #FFF8DC;
- }
- }
- }
- }
- }
- }
- .msg-left {
- flex-direction: row;
- .msg-text {
- word-break: break-all;
- margin-left: 16rpx;
- background-color: #f1f1f1;
- border-radius: 0rpx 20rpx 20rpx 20rpx;
- }
- .ms-img {
- margin-left: 16rpx;
- }
- }
- .msg-right {
- flex-direction: row-reverse;
- .msg-text {
- margin-right: 16rpx;
- background-color: rgba(255, 228, 49, 0.8);
- border-radius: 20rpx 0rpx 20rpx 20rpx;
- }
- .ms-img {
- margin-right: 16rpx;
- }
- }
- }
- }
- }
- .two {
- background-color: #f0f0f0;
- border-top: 1px solid rgba(39, 40, 50, 0.1);
- }
- }
- .uni-popup {
- z-index: 9999 !important;
- }
- .popup {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 80vh;
- .close {
- text-align: right;
- padding: 2vw;
- }
- .info_1 {
- position: relative;
- display: flex;
- flex-direction: column;
- height: 74vh;
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- </style>
|