Commit dfddc2da by 施宇

22

parent 3e740fda
...@@ -30,7 +30,7 @@ Component({ ...@@ -30,7 +30,7 @@ Component({
saveSendMsg(evt){ saveSendMsg(evt){
msgStorage.saveMsg(evt.detail.msg, evt.detail.type); msgStorage.saveMsg(evt.detail.msg, evt.detail.type);
if ((evt.detail.type !== 'cmd') && (!evt.detail.customer)){ if ((!evt.detail.template) && (!evt.detail.customer)){
this.data.__comps__.inputbar.cancelEmoji(); this.data.__comps__.inputbar.cancelEmoji();
} }
} }
......
...@@ -56,7 +56,6 @@ Component({ ...@@ -56,7 +56,6 @@ Component({
sendMessage() { sendMessage() {
if (this.data.isTopic) { if (this.data.isTopic) {
let self = this; let self = this;
console.log(self.data.userMessage)
this.triggerEvent( this.triggerEvent(
"newTextMsg", { "newTextMsg", {
msg: self.data.userMessage msg: self.data.userMessage
...@@ -127,10 +126,10 @@ Component({ ...@@ -127,10 +126,10 @@ Component({
inputMessage: "", inputMessage: "",
}); });
}, },
sendCmd: function () { sendTemplateMessage: function () {
let me = this; let me = this;
let id = WebIM.conn.getUniqueId(); let id = WebIM.conn.getUniqueId();
let msg = new WebIM.message(msgType.CMD, id); let msg = new WebIM.message(msgType.TEXT, id);
let userId = wx.getStorageSync('user_id'); let userId = wx.getStorageSync('user_id');
let companyName = wx.getStorageSync('imNick'); let companyName = wx.getStorageSync('imNick');
let avatar = wx.getStorageSync('avatar'); let avatar = wx.getStorageSync('avatar');
...@@ -144,18 +143,18 @@ Component({ ...@@ -144,18 +143,18 @@ Component({
touserid: touserid, touserid: touserid,
name1: this.data.username.name == companyName ? this.data.username.name1 : this.data.username.name, name1: this.data.username.name == companyName ? this.data.username.name1 : this.data.username.name,
img1: this.data.username.name == companyName ? this.data.username.img1 : this.data.username.img, img1: this.data.username.name == companyName ? this.data.username.img1 : this.data.username.img,
timer: WebIM.time() timer: WebIM.time(),
isTemplate:'1'
}); });
console.log(params) console.log(params)
msg.set({ msg.set({
msg: 'template', msg: '',
from: me.data.username.myName, from: me.data.username.myName,
to: me.data.username.your, to: me.data.username.your,
action: "template", // action: "template",
ext: params, ext: params,
success: function () { success: function () {
console.log('发送模板成功') console.log('发送模板成功')
console.log(me.data.username.your)
// getApp().addChatMember(me.data.username.your) // getApp().addChatMember(me.data.username.your)
// disp.fire('em.chat.sendSuccess', id); // disp.fire('em.chat.sendSuccess', id);
}, },
...@@ -170,7 +169,8 @@ Component({ ...@@ -170,7 +169,8 @@ Component({
this.triggerEvent( this.triggerEvent(
"newTextMsg", { "newTextMsg", {
msg: msg, msg: msg,
type: msgType.CMD, type: msgType.TEXT,
template:true
}, { }, {
bubbles: true, bubbles: true,
composed: true composed: true
...@@ -198,7 +198,7 @@ Component({ ...@@ -198,7 +198,7 @@ Component({
template: template template: template
}); });
wx.removeStorageSync('template'); wx.removeStorageSync('template');
this.sendCmd(); this.sendTemplateMessage();
}; };
if (customer) { if (customer) {
this.setData({ this.setData({
......
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
</view> </view>
</view> </view>
</template> </template>
<!-- view 换成 scroll-view效果更好 用view是为了要stopPullDownRefresh --> <!-- view 换成 scroll-view效果更好 用view是为了要stopPullDownRefresh -->
<scroll-view scroll-y="true" class="{{ view }} wrap {{isIPX?'scroll_view_X': ''}}" bind:tap="onTap" scroll-into-view="{{ toView }}"> <scroll-view scroll-y="true" class="{{ view }} wrap {{isIPX?'scroll_view_X': ''}}" bind:tap="onTap" scroll-into-view="{{ toView }}">
<view class="message" wx:for="{{ chatMsg }}" wx:key="{{ item.mid }}" id="{{ item.mid }}"> <view class="message" wx:for="{{ chatMsg }}" wx:key="{{ item.mid }}" id="{{ item.mid }}">
...@@ -44,13 +42,13 @@ ...@@ -44,13 +42,13 @@
<block wx:else> <block wx:else>
<image class="avatar" src="{{item.ext.img?item.ext.img:'/res/images/imgs/s.png'}}" /> <image class="avatar" src="{{item.ext.img?item.ext.img:'/res/images/imgs/s.png'}}" />
</block> </block>
<view class="msg {{item.msg.type=='cmd'?'cmd-msg':''}}"> <view class="msg {{item.ext.isTemplate?'cmd-msg':''}}">
<image class="err {{(item.style == 'self' && item.isFail) ? 'show' : 'hide'}}" src="../../../images/msgerr.png" /> <image class="err {{(item.style == 'self' && item.isFail) ? 'show' : 'hide'}}" src="../../../images/msgerr.png" />
<view wx:if="{{ item.msg.type == 'img'}}"> <view wx:if="{{ item.msg.type == 'img'}}">
<template is="{{ item.msg.type }}" data="{{ item }}" /> <template is="{{ item.msg.type }}" data="{{ item }}" />
</view> </view>
<view wx:if="{{ item.msg.type == 'cmd'}}"> <view wx:if="{{item.ext.isTemplate}}">
<template is="{{ item.msg.type }}" data="{{ item }}" /> <template is="cmd" data="{{ item }}" />
</view> </view>
<view wx:elif="{{ item.msg.type == 'txt' || item.msg.type == 'emoji' }}"> <view wx:elif="{{ item.msg.type == 'txt' || item.msg.type == 'emoji' }}">
<view class="template" wx:for="{{ item.msg.data }}" wx:key=""> <view class="template" wx:for="{{ item.msg.data }}" wx:key="">
......
...@@ -29,13 +29,13 @@ Page({ ...@@ -29,13 +29,13 @@ Page({
goodId: options.goodId || '', goodId: options.goodId || '',
type: options.type || '' type: options.type || ''
}); });
this.getData(false) this.getData(false,true)
getApp().globalData.bus.off('editGood'); getApp().globalData.bus.off('editGood');
getApp().globalData.bus.on('editGood', () => { getApp().globalData.bus.on('editGood', () => {
me.getData(true) me.getData(true,true)
}) })
}, },
getData: function (bool) { getData: function (bool,isLoading) {
let me = this; let me = this;
let token = wx.getStorageSync('access_token'); let token = wx.getStorageSync('access_token');
let goodId = me.data.goodId; let goodId = me.data.goodId;
...@@ -84,7 +84,7 @@ Page({ ...@@ -84,7 +84,7 @@ Page({
info: {} info: {}
}) })
} }
}, true) }, isLoading)
}, },
editGood: function () { editGood: function () {
if (!judgeToken(true) && this.data.type == 3) { if (!judgeToken(true) && this.data.type == 3) {
...@@ -104,7 +104,7 @@ Page({ ...@@ -104,7 +104,7 @@ Page({
let userId = wx.getStorageSync("user_id"); let userId = wx.getStorageSync("user_id");
let avatar = wx.getStorageSync("avatar"); let avatar = wx.getStorageSync("avatar");
let obj = { let obj = {
userId: data.im_username, // userId: data.im_username,
type: data.goods_name, type: data.goods_name,
price: data.currency == 1 ? '¥' + data.price : '$' + data.price, price: data.currency == 1 ? '¥' + data.price : '$' + data.price,
brand: data.brand_name, brand: data.brand_name,
...@@ -113,9 +113,9 @@ Page({ ...@@ -113,9 +113,9 @@ Page({
hq: data.delivery_time, hq: data.delivery_time,
time: changeTime(data.add_time * 1000), time: changeTime(data.add_time * 1000),
goodImage: data.goods_images, goodImage: data.goods_images,
userName: data.company_name, // userName: data.company_name,
targetId: data.user_id, // targetId: data.user_id,
userImg: data.avatar, // userImg: data.avatar,
}; };
let queryObj = { let queryObj = {
myName: my, myName: my,
...@@ -211,12 +211,13 @@ Page({ ...@@ -211,12 +211,13 @@ Page({
refreshGood: function () { refreshGood: function () {
let me = this; let me = this;
console.log(this.data.goodId) console.log(this.data.goodId)
getData(apis.goodsSave, 'get', { getData(apis.goodsPolish, 'get', {
token: wx.getStorageSync('access_token') || '', token: wx.getStorageSync('access_token') || '',
goods_id: me.data.goodId goods_id: me.data.goodId
}, function (res) { }, function (res) {
if (res.errcode == 0) { if (res.errcode == 0) {
tips('操作成功') tips('操作成功');
me.getData(false,false)
} else { } else {
tips(res.errmsg) tips(res.errmsg)
} }
......
...@@ -82,7 +82,7 @@ Page({ ...@@ -82,7 +82,7 @@ Page({
let userId = wx.getStorageSync("user_id"); let userId = wx.getStorageSync("user_id");
let avatar = wx.getStorageSync("avatar"); let avatar = wx.getStorageSync("avatar");
let obj = { let obj = {
userId: data.im_username, // userId: data.im_username,
type: topData.goods_name, type: topData.goods_name,
price: topData.currency == 1 ? '¥' + topData.price : '$' + topData.price, price: topData.currency == 1 ? '¥' + topData.price : '$' + topData.price,
brand: topData.brand_name, brand: topData.brand_name,
...@@ -91,9 +91,9 @@ Page({ ...@@ -91,9 +91,9 @@ Page({
hq: topData.delivery_time, hq: topData.delivery_time,
time: changeTime(topData.add_time*1000), time: changeTime(topData.add_time*1000),
goodImage: topData.goods_images || '', goodImage: topData.goods_images || '',
userName: data.company_name, // userName: data.company_name,
targetId: data.user_id, // targetId: data.user_id,
userImg: data.avatar, // userImg: data.avatar,
}; };
let queryObj = { let queryObj = {
myName: my, myName: my,
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<view class="message-c bold ellipsis">{{ item.name||'--' }}</view> <view class="message-c bold ellipsis">{{ item.name||'--' }}</view>
<view class="message-t ellipsis" wx:if="{{ item.msg.data[0].data }}">{{ item.msg.data[0].data }}</view> <view class="message-t ellipsis" wx:if="{{ item.msg.data[0].data }}">{{ item.msg.data[0].data }}</view>
<view class="message-t ellipsis" wx:if="{{item.msg.type == 'img' }}">[图片]</view> <view class="message-t ellipsis" wx:if="{{item.msg.type == 'img' }}">[图片]</view>
<view class="message-t ellipsis" wx:if="{{item.msg.type == 'cmd' }}">{{item.ext.type}} {{item.ext.price}}</view> <view class="message-t ellipsis" wx:if="{{item.ext.isTemplate}}">{{item.ext.type}} {{item.ext.price}}</view>
</view> </view>
</view> </view>
<view class="message-r"> <view class="message-r">
......
...@@ -111,6 +111,10 @@ const apis = { ...@@ -111,6 +111,10 @@ const apis = {
* 商品修改 * 商品修改
*/ */
goodsSave: goods_url + '/goods/save', goodsSave: goods_url + '/goods/save',
/**
* 商品擦亮
*/
goodsPolish: goods_url + '/goods/polish',
/*** /***
* 商品上下架 * 商品上下架
*/ */
......
...@@ -124,15 +124,15 @@ const webimListen = () => { ...@@ -124,15 +124,15 @@ const webimListen = () => {
conn.closed = true; conn.closed = true;
WebIM.conn.close(); WebIM.conn.close();
}, },
onCmdMessage(message) { // onCmdMessage(message) {
if (message) { // if (message) {
if (onMessageError(message)) { // if (onMessageError(message)) {
addImUser(message) // addImUser(message)
msgStorage.saveReceiveMsg(message, msgType.CMD); // msgStorage.saveReceiveMsg(message, msgType.CMD);
} // }
calcUnReadSpot(message); // calcUnReadSpot(message);
} // }
}, // },
onTextMessage(message) { onTextMessage(message) {
if (message) { if (message) {
if (onMessageError(message)) { if (onMessageError(message)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment