Commit c0e7b452 by 施宇

11

parent c3026ab2
Showing with 1468 additions and 540 deletions
const WebIM = require("utils/WebIM")["default"]; const WebIM = require("utils/WebIM")["default"];
let msgStorage = require("components/chat/msgstorage"); // let msgStorage = require("components/chat/msgstorage");
let msgType = require("components/chat/msgtype"); // let msgType = require("components/chat/msgtype");
let disp = require("utils/broadcast"); // let disp = require("utils/broadcast");
function calcUnReadSpot(message) { let chat = require('utils/chat.js');
let myName = wx.getStorageSync("myUsername"); import { getData } from './utils/util.js';
let allMembers = wx.getStorageSync("member") || []; //好友 import { apis } from './utils/api.js';
let count = allMembers.reduce(function (result, curMember, idx) { // function calcUnReadSpot(message) {
let chatMsgs = wx.getStorageSync(curMember.toLowerCase() + myName.toLowerCase()) || []; // let myName = wx.getStorageSync("myUsername");
// let allMembers = wx.getStorageSync("member") || []; //好友
return result + chatMsgs.length; // let count = allMembers.reduce(function (result, curMember, idx) {
}, 0); // let chatMsgs = wx.getStorageSync(curMember.toLowerCase() + myName.toLowerCase()) || [];
getApp().globalData.unReadMessageNum = count;
disp.fire("em.xmpp.unreadspot", message); // return result + chatMsgs.length;
} // }, 0);
function onMessageError(err) { // getApp().globalData.unReadMessageNum = count;
if (err.type === "error") { // disp.fire("em.xmpp.unreadspot", message);
wx.showToast({ // }
title: err.errorText // function onMessageError(err) {
}); // if (err.type === "error") {
return false; // wx.showToast({
} // title: err.errorText
return true; // });
} // return false;
function addMember(id) { // }
// return true;
// }
// function addMember(id) {
// let member = wx.getStorageSync("member") || [];
// let index = member.indexOf(id);
// if (index == -1) {
// member.push(id)
// }
// wx.setStorage({
// key: "member",
// data: member
// });
// }
App({
globalData: {
unReadMessageNum: 0,
token:wx.getStorageSync('access_token'),
isIPX: false, //是否为iphone X
customerNum:"18664936975",
customerName:"IC业务助手"
},
// conn: {
// closed: false,
// curOpenOpt: {},
// open(opt) {
// // /* wx.showLoading({
// // title: '正在初始化客户端...',
// // mask: true
// // }) */
// this.curOpenOpt = opt;
// WebIM.conn.open(opt);
// this.closed = false;
// },
// reopen() {
// if (this.closed) {
// WebIM.conn.open(this.curOpenOpt);
// this.closed = false;
// }
// }
// },
getImUser: chat.getImUser,
addChatMember: function (id) {
let token = wx.getStorageSync('access_token') || ''
let member = wx.getStorageSync("member") || []; let member = wx.getStorageSync("member") || [];
let index = member.indexOf(id); let index = member.indexOf(id);
if (index == -1) { if (index == -1) {
...@@ -32,32 +76,16 @@ function addMember(id) { ...@@ -32,32 +76,16 @@ function addMember(id) {
key: "member", key: "member",
data: member data: member
}); });
} getData(apis.addrecord, 'GET', {
"token": token,
App({ "user_id": id
globalData: { }, function (res) {
unReadMessageNum: 0, if (res.errcode === 0) {
token:wx.getStorageSync('access_token'),
isIPX: false //是否为iphone X } else {
}, console.log('添加聊天成员失败')
conn: {
closed: false,
curOpenOpt: {},
open(opt) {
// /* wx.showLoading({
// title: '正在初始化客户端...',
// mask: true
// }) */
this.curOpenOpt = opt;
WebIM.conn.open(opt);
this.closed = false;
},
reopen() {
if (this.closed) {
WebIM.conn.open(this.curOpenOpt);
this.closed = false;
}
} }
}, false);
}, },
onLaunch() { onLaunch() {
let me = this; let me = this;
...@@ -68,9 +96,9 @@ App({ ...@@ -68,9 +96,9 @@ App({
success(res) { success(res) {
if(res.data){ if(res.data){
// wx.switchTab({ wx.switchTab({
// url: '/pages/tab/home/home' url: '/pages/tab/home/home'
// }); });
} }
} }
...@@ -82,74 +110,74 @@ App({ ...@@ -82,74 +110,74 @@ App({
success(res) { success(res) {
if (res.authSetting['scope.userInfo']) { if (res.authSetting['scope.userInfo']) {
// 已经授权 // 已经授权
// wx.switchTab({ wx.switchTab({
// url: '/pages/tab/home/home' url: '/pages/tab/home/home'
// }) })
} }
} }
}) })
this.getImUser()
// wx.setStorage({
// key: "myUsername",
// data: '7a2765fc7caa5e512a6d1270bcf98bf0'
// });
wx.setStorage({ // this.conn.open({
key: "myUsername", // apiUrl: WebIM.config.apiURL,
data: '18271408717' // user: '7a2765fc7caa5e512a6d1270bcf98bf0',
}); // pwd: 'ic_55028838',
// appKey: WebIM.config.appkey
this.conn.open({ // });
apiUrl: WebIM.config.apiURL,
user: '18271408717',
pwd: '123456',
appKey: WebIM.config.appkey
});
WebIM.conn.listen({
onOpened(message) {
},
onReconnect() {
wx.showToast({
title: "重连中...",
duration: 2000
});
},
onSocketConnected() {
/* wx.showToast({
title: "socket连接成功",
duration: 2000
}); */
},
onClosed() {
wx.showToast({
title: "网络已断开",
icon: 'none',
duration: 2000
});
me.conn.closed = true;
WebIM.conn.close();
},
onCmdMessage(message) {
},
onTextMessage(message) {
addMember(message.from)
if (message) {
if (onMessageError(message)) {
msgStorage.saveReceiveMsg(message, msgType.TEXT);
}
calcUnReadSpot(message);
}
}, chat.webimListen();
onPictureMessage(message) { // WebIM.conn.listen({
// onOpened(message) {
}, // },
// 各种异常 // onReconnect() {
onError(error) { // wx.showToast({
console.log(error) // title: "重连中...",
}, // duration: 2000
}); // });
// },
// onSocketConnected() {
// /* wx.showToast({
// title: "socket连接成功",
// duration: 2000
// }); */
// },
// onClosed() {
// wx.showToast({
// title: "网络已断开",
// icon: 'none',
// duration: 2000
// });
// me.conn.closed = true;
// WebIM.conn.close();
// },
// onCmdMessage(message) {
// },
// onTextMessage(message) {
// chat.addMember(message.from)
// if (message) {
// if (chat.onMessageError(message)) {
// msgStorage.saveReceiveMsg(message, msgType.TEXT);
// }
// chat.calcUnReadSpot(message);
// }
// },
// onPictureMessage(message) {
// },
// // 各种异常
// onError(error) {
// console.log(error)
// },
// });
this.checkIsIPhoneX(); this.checkIsIPhoneX();
}, },
checkIsIPhoneX: function () { checkIsIPhoneX: function () {
......
...@@ -30,7 +30,10 @@ Component({ ...@@ -30,7 +30,10 @@ 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'){
this.data.__comps__.inputbar.cancelEmoji(); this.data.__comps__.inputbar.cancelEmoji();
}
} }
}, },
...@@ -40,6 +43,7 @@ Component({ ...@@ -40,6 +43,7 @@ Component({
ready(){ ready(){
this.data.__comps__.inputbar = this.selectComponent("#chat-inputbar"); this.data.__comps__.inputbar = this.selectComponent("#chat-inputbar");
this.data.__comps__.msglist = this.selectComponent("#chat-msglist"); this.data.__comps__.msglist = this.selectComponent("#chat-msglist");
}, },
moved(){}, moved(){},
detached(){ detached(){
......
...@@ -16,20 +16,8 @@ Component({ ...@@ -16,20 +16,8 @@ Component({
}, },
methods: { methods: {
openCamera(){
var me = this;
wx.chooseImage({
count: 1,
sizeType: ["original", "compressed"],
sourceType: ["camera"],
success(res){
me.upLoadImage(res);
}
});
},
sendImage(){ sendImage(){
var me = this; let me = this;
wx.chooseImage({ wx.chooseImage({
count: 1, count: 1,
sizeType: ["original", "compressed"], sizeType: ["original", "compressed"],
...@@ -49,23 +37,23 @@ Component({ ...@@ -49,23 +37,23 @@ Component({
}, },
upLoadImage(res){ upLoadImage(res){
var me = this; let me = this;
var tempFilePaths = res.tempFilePaths; let tempFilePaths = res.tempFilePaths;
var token = WebIM.conn.context.accessToken let token = WebIM.conn.context.accessToken
wx.getImageInfo({ wx.getImageInfo({
src: res.tempFilePaths[0], src: res.tempFilePaths[0],
success(res){ success(res){
var allowType = { let allowType = {
jpg: true, jpg: true,
gif: true, gif: true,
png: true, png: true,
bmp: true bmp: true
}; };
var str = WebIM.config.appkey.split("#"); let str = WebIM.config.appkey.split("#");
var width = res.width; let width = res.width;
var height = res.height; let height = res.height;
var index = res.path.lastIndexOf("."); let index = res.path.lastIndexOf(".");
var filetype = (~index && res.path.slice(index + 1)) || ""; let filetype = (~index && res.path.slice(index + 1)) || "";
if(filetype.toLowerCase() in allowType){ if(filetype.toLowerCase() in allowType){
wx.uploadFile({ wx.uploadFile({
url: "https://a1.easemob.com/" + str[0] + "/" + str[1] + "/chatfiles", url: "https://a1.easemob.com/" + str[0] + "/" + str[1] + "/chatfiles",
...@@ -76,11 +64,11 @@ Component({ ...@@ -76,11 +64,11 @@ Component({
Authorization: "Bearer " + token Authorization: "Bearer " + token
}, },
success(res){ success(res){
var data = res.data; let data = res.data;
var dataObj = JSON.parse(data); let dataObj = JSON.parse(data);
var id = WebIM.conn.getUniqueId(); // 生成本地消息 id let id = WebIM.conn.getUniqueId(); // 生成本地消息 id
var msg = new WebIM.message(msgType.IMAGE, id); let msg = new WebIM.message(msgType.IMAGE, id);
var file = { let file = {
type: msgType.IMAGE, type: msgType.IMAGE,
size: { size: {
width: width, width: width,
...@@ -90,15 +78,31 @@ Component({ ...@@ -90,15 +78,31 @@ Component({
filetype: filetype, filetype: filetype,
filename: tempFilePaths[0] filename: tempFilePaths[0]
}; };
let userId = wx.getStorageSync('user_id');
let companyName = wx.getStorageSync('company_name');
let avatar = wx.getStorageSync('avatar');
msg.set({ msg.set({
apiUrl: WebIM.config.apiURL, apiUrl: WebIM.config.apiURL,
body: file, body: file,
from: me.data.username.myName, from: me.data.username.myName,
to: me.getSendToParam(), to: me.getSendToParam(),
ext: {
id: userId,
name: companyName,
img: avatar,
touserid: me.data.username.id == userId ? me.data.username.touserid : me.data.username.id,
name1: me.data.username.name == companyName ? me.data.username.name1 : me.data.username.name,
img1: me.data.username.name == companyName ? me.data.username.img1 : me.data.username.img,
timer: WebIM.time()
},
roomType: false, roomType: false,
chatType: me.data.chatType, chatType: me.data.chatType,
success: function (argument) { success: function (argument) {
console.log('发送图片成功')
disp.fire('em.chat.sendSuccess', id); disp.fire('em.chat.sendSuccess', id);
},
fail:function(){
console.log('发送图片失败')
} }
}); });
if(me.data.chatType == msgType.chatType.CHAT_ROOM){ if(me.data.chatType == msgType.chatType.CHAT_ROOM){
......
...@@ -15,92 +15,82 @@ Component({ ...@@ -15,92 +15,82 @@ Component({
data: { data: {
inputMessage: "", // render input 的值 inputMessage: "", // render input 的值
userMessage: "", // input 的实时值 userMessage: "", // input 的实时值
template: null,
}, },
methods: { methods: {
focus(){ focus() {
this.triggerEvent("inputFocused", null, { bubbles: true }); this.triggerEvent("inputFocused", null, {
}, bubbles: true
});
blur(){
this.triggerEvent("inputBlured", null, { bubbles: true });
},
isGroupChat(){
return this.data.chatType == msgType.chatType.CHAT_ROOM;
}, },
getSendToParam(){ blur() {
return this.isGroupChat() ? this.data.username.groupId : this.data.username.your; this.triggerEvent("inputBlured", null, {
bubbles: true
});
}, },
// bindinput 不能打冒号! // bindinput 不能打冒号!
bindMessage(e){ bindMessage(e) {
this.setData({ this.setData({
userMessage: e.detail.value userMessage: e.detail.value
}); });
}, },
emojiAction(emoji){ emojiAction(emoji) {
var str; var str;
var msglen = this.data.userMessage.length - 1; var msglen = this.data.userMessage.length - 1;
if(emoji && emoji != "[del]"){ if (emoji && emoji != "[del]") {
str = this.data.userMessage + emoji; str = this.data.userMessage + emoji;
} }
else if(emoji == "[del]"){
let start = this.data.userMessage.lastIndexOf("[");
let end = this.data.userMessage.lastIndexOf("]");
let len = end - start;
if(end != -1 && end == msglen && len >= 3 && len <= 4){
str = this.data.userMessage.slice(0, start);
}
else{
str = this.data.userMessage.slice(0, msglen);
}
}
this.setData({ this.setData({
userMessage: str, userMessage: str,
inputMessage: str inputMessage: str
}); });
}, },
sendMessage(){ sendMessage() {
let me = this; let me = this;
String.prototype.trim = function () {
String.prototype.trim=function()
{
return this.replace(/(^\s*)|(\s*$)/g, ''); return this.replace(/(^\s*)|(\s*$)/g, '');
} }
if(!this.data.userMessage.trim()){ if (!this.data.userMessage.trim()) {
return; return;
} }
let id = WebIM.conn.getUniqueId(); let id = WebIM.conn.getUniqueId();
let msg = new WebIM.message(msgType.TEXT, id); let msg = new WebIM.message(msgType.TEXT, id);
let userId = wx.getStorageSync('user_id');
let companyName = wx.getStorageSync('company_name');
let avatar = wx.getStorageSync('avatar');
msg.set({ msg.set({
msg: this.data.userMessage, msg: this.data.userMessage,
from: this.data.username.myName, from: this.data.username.myName,
to: this.getSendToParam(), to: this.data.username.your,
ext: {
id: userId,
name: companyName,
img: avatar,
touserid: this.data.username.id == userId ? this.data.username.touserid : this.data.username.id,
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,
timer: WebIM.time()
},
roomType: false, roomType: false,
chatType: this.data.chatType, chatType: this.data.chatType,
success(id, serverMsgId){ success(id, serverMsgId) {
//console.log('成功了') console.log('发送消息成功')
disp.fire('em.chat.sendSuccess', id, me.data.userMessage); disp.fire('em.chat.sendSuccess', id, me.data.userMessage);
}, },
fail(id, serverMsgId){ fail(id, serverMsgId) {
console.log('失败了') console.log('发送消息失败')
} }
}); });
if(this.data.chatType == msgType.chatType.CHAT_ROOM){
msg.setGroup("groupchat");
}
WebIM.conn.send(msg.body); WebIM.conn.send(msg.body);
this.triggerEvent( this.triggerEvent(
"newTextMsg", "newTextMsg", {
{
msg: msg, msg: msg,
type: msgType.TEXT, type: msgType.TEXT,
}, }, {
{
bubbles: true, bubbles: true,
composed: true composed: true
} }
...@@ -111,12 +101,75 @@ Component({ ...@@ -111,12 +101,75 @@ Component({
inputMessage: "", inputMessage: "",
}); });
}, },
sendCmd: function () {
let me = this;
let id = WebIM.conn.getUniqueId();
let msg = new WebIM.message(msgType.CMD, id);
let userId = wx.getStorageSync('user_id');
let companyName = wx.getStorageSync('company_name');
let avatar = wx.getStorageSync('avatar');
let params = Object.assign({}, me.data.template, {
id: userId,
name: companyName,
img: avatar,
touserid: this.data.username.id == userId ? this.data.username.touserid : this.data.username.id,
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,
timer: WebIM.time()
});
msg.set({
msg: 'template',
from: me.data.username.myName,
to: me.data.username.your,
action: "template",
ext: params,
success: function () {
console.log('发送模板成功')
console.log(me.data.username.your)
getApp().addChatMember(me.data.username.your)
disp.fire('em.chat.sendSuccess', id);
},
fail: function () {
console.log('发送模板失败');
}
});
console.log(msg.body)
getApp().addChatMember(me.data.username.your)
WebIM.conn.send(msg.body);
this.triggerEvent(
"newTextMsg", {
msg: msg,
type: msgType.CMD,
}, {
bubbles: true,
composed: true
}
);
}
}, },
// lifetimes // lifetimes
created(){}, created() {
attached(){},
moved(){}, },
detached(){}, attached() {
ready(){},
},
moved() {
},
detached() { },
ready() {
let template = wx.getStorageSync('template') || '';
if (!template) {
return
} else {
this.setData({
template: template
});
wx.removeStorageSync('template');
this.sendCmd();
}
},
}); });
\ No newline at end of file
...@@ -7,24 +7,46 @@ ...@@ -7,24 +7,46 @@
<template name="img"> <template name="img">
<image class="avatar" src="{{ item.msg.data }}" style="width:90px; height:120px; margin:2px auto;" mode="aspectFit" bind:tap="previewImage" data-url="{{ item.msg.data }}" /> <image class="avatar" src="{{ item.msg.data }}" style="width:90px; height:120px; margin:2px auto;" mode="aspectFit" bind:tap="previewImage" data-url="{{ item.msg.data }}" />
</template> </template>
<template name="cmd">
<view class="tel-view">
<image src="{{ item.ext.goodImage?item.ext.goodImage:'/res/images/imgs/defaultgood.png' }}" class="good-img"></image>
<view class="right-content">
<view class="cmd-type">{{ item.ext.type }}</view>
<view class="cmd-price">{{ item.ext.price }}</view>
<view class="cmd-com">
<view class="cmd-text">品牌:</view>
<view class="cmd-value">{{ item.ext.brand }}</view>
</view>
<view class="cmd-com">
<view class="cmd-text">数量:</view>
<view class="cmd-value">{{ item.ext.num }}</view>
</view>
<view class="cmd-com">
<view class="cmd-text">货期:</view>
<view class="cmd-value">{{ item.ext.hq }}</view>
</view>
<view class="cmd-com">
<view class="cmd-text">时间:</view>
<view class="cmd-value">{{ item.ext.time }}</view>
</view>
</view>
</view>
</template>
<!-- view 换成 scroll-view效果更好 用view是为了要stopPullDownRefresh --> <!-- view 换成 scroll-view效果更好 用view是为了要stopPullDownRefresh -->
<view scroll-y="true" class="{{ view }} wrap {{isIPX?'scroll_view_X': ''}}" bind:tap="onTap" scroll-into-view="{{ toView }}"> <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 }}">
<view class="{{ item.style }}"> <view class="{{ item.style }}">
<!-- <view class="user"> <image class="avatar" src="{{item.ext.img?item.ext.img:'/res/images/imgs/s.png'}}" />
<text class="user-text">{{ item.yourname + ' ' + item.time}}</text> <view class="msg {{item.msg.type=='cmd'?'cmd-msg':''}}">
</view> -->
<image class="avatar" src="../../../images/theme@2x.png" />
<view class="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" />
<!-- <image wx:if="{{item.style == 'self'}}" src="../../../images/poprightarrow@2x.png" class="msg_poprightarrow" /> -->
<!-- <image wx:if="{{item.style == ''}}" src="../../../images/popleftarrow@2x.png" class="msg_popleftarrow" /> -->
<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'}}">
<template is="{{ item.msg.type }}" data="{{ item }}" />
</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="">
<template is="{{ item.type }}" data="{{ item }}" /> <template is="{{ item.type }}" data="{{ item }}" />
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
z-index: 0; z-index: 0;
top: 50px; top: 50px;
}*/ }*/
.scroll_view,
.scroll_view_change { .scroll_view, .scroll_view_change {
/*width: 100%; /*width: 100%;
position: absolute; position: absolute;
left: 0; left: 0;
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
background-color: #fff; background-color: #fff;
} }
.scroll_view_X, .scroll_view_X, .scroll_view_change_X {
.scroll_view_change_X{
margin-bottom: 244rpx; margin-bottom: 244rpx;
} }
...@@ -31,19 +30,19 @@ ...@@ -31,19 +30,19 @@
height: auto; height: auto;
margin: 0 24rpx 30rpx; margin: 0 24rpx 30rpx;
position: relative; position: relative;
} }
.time { .time {
margin:0rpx 0 0 92rpx margin: 0rpx 0 0 92rpx;
} }
.self .time{
margin:0rpx 92rpx 0 0 ; .self .time {
margin: 0rpx 92rpx 0 0;
} }
.time .time-text { .time .time-text {
font-size: 22rpx; font-size: 22rpx;
color:#ADB6BF; color: #adb6bf;
} }
.user .user-text { .user .user-text {
...@@ -60,7 +59,6 @@ ...@@ -60,7 +59,6 @@
border-radius: 8rpx; border-radius: 8rpx;
float: left; float: left;
margin: 0 24rpx 0 0; margin: 0 24rpx 0 0;
} }
.msg { .msg {
...@@ -71,12 +69,17 @@ ...@@ -71,12 +69,17 @@
font-size: 24rpx; font-size: 24rpx;
text-align: left; text-align: left;
word-break: break-all; word-break: break-all;
background-color: #DFECFC; background-color: #dfecfc;
border-radius:8rpx; border-radius: 8rpx;
position: relative; position: relative;
color: #515559; color: #515559;
} }
.cmd-msg {
padding: 0;
background-color: #f5f9fc !important;
}
.msg .msg_poprightarrow { .msg .msg_poprightarrow {
position: absolute; position: absolute;
right: -10rpx; right: -10rpx;
...@@ -85,8 +88,8 @@ ...@@ -85,8 +88,8 @@
margin-top: -10rpx; margin-top: -10rpx;
} }
.msg .msg_popleftarrow{ .msg .msg_popleftarrow {
position:absolute; position: absolute;
left: -14rpx; left: -14rpx;
height: 18rpx; height: 18rpx;
width: 18rpx; width: 18rpx;
...@@ -123,7 +126,7 @@ ...@@ -123,7 +126,7 @@
} }
.self .msg { .self .msg {
background-color: #FCF2DF; background-color: #fcf2df;
} }
.self .msg:before { .self .msg:before {
...@@ -136,15 +139,68 @@ ...@@ -136,15 +139,68 @@
.template { .template {
display: inline; display: inline;
} }
.err{
.err {
width: 32rpx; width: 32rpx;
height: 32rpx; height: 32rpx;
position: absolute; position: absolute;
left: -40rpx; left: -40rpx;
} }
.hide{
.hide {
display: none; display: none;
} }
.show{
.show {
display: block; display: block;
} }
.good-img {
height: 100rpx;
width: 100rpx;
position: absolute;
left:24rpx;
top:24rpx;
border-radius: 8rpx;
}
.tel-view {
font-size: 26rpx;
border: 1px solid #e6ecf2;
position: relative;
padding:24rpx 24rpx 24rpx 145rpx;
}
.cmd-type {
color: #515559;
font-size: 32rpx;
font-weight: 600;
}
.cmd-price {
font-size: 28rpx;
color: #ea1717;
font-weight: 600;
margin-top: 6rpx;
}
.cmd-text {
color: #8a9299;
position: absolute;
width: 78rpx;
left:0;
}
.cmd-value {
color: #515559;
}
.cmd-com::after{
display: block;
content:"";
clear: both;
}
.cmd-com{
margin-top:10rpx;
position: relative;
padding-left:78rpx;
}
let WebIM = require("../../utils/WebIM")["default"]; let WebIM = require("../../utils/WebIM")["default"];
let msgType = require("msgtype"); let msgType = require("msgtype");
module.exports = function(sendableMsg, type, myName){ module.exports = function (sendableMsg, type, myName) {
var time = WebIM.time(); var time = WebIM.time();
var renderableMsg = { var renderableMsg = {
info: { info: {
...@@ -10,40 +10,34 @@ module.exports = function(sendableMsg, type, myName){ ...@@ -10,40 +10,34 @@ module.exports = function(sendableMsg, type, myName){
}, },
username: sendableMsg.body.from == myName ? sendableMsg.body.to : sendableMsg.body.from, username: sendableMsg.body.from == myName ? sendableMsg.body.to : sendableMsg.body.from,
yourname: sendableMsg.body.from, yourname: sendableMsg.body.from,
name:sendableMsg.body.from == myName ? sendableMsg.body.ext.name1: sendableMsg.body.ext.name,
img: sendableMsg.body.from == myName ? sendableMsg.body.ext.img1: sendableMsg.body.ext.img,
msg: { msg: {
type: type, type: type,
url: sendableMsg.body.body.url, url: sendableMsg.body.body.url,
data: getMsgData(sendableMsg, type), data: getMsgData(sendableMsg, type),
}, },
ext:sendableMsg.body.ext,
style: sendableMsg.body.from == myName ? "self" : "", style: sendableMsg.body.from == myName ? "self" : "",
time: time, time: time,
mid: sendableMsg.type + sendableMsg.id, mid: sendableMsg.type + sendableMsg.id,
chatType: sendableMsg.body.chatType chatType: sendableMsg.body.chatType
}; };
if(type == msgType.IMAGE){ if (type == msgType.IMAGE) {
renderableMsg.msg.size = { renderableMsg.msg.size = {
width: sendableMsg.body.body.size.width, width: sendableMsg.body.body.size.width,
height: sendableMsg.body.body.size.height, height: sendableMsg.body.body.size.height,
}; };
}else if (type == msgType.AUDIO) {
renderableMsg.msg.length = sendableMsg.body.length;
}else if (type == msgType.FILE){
renderableMsg.msg.data = [{data: "[当前不支持此格式消息展示]", type: "txt"}];
renderableMsg.msg.type = 'txt';
} }
return renderableMsg; return renderableMsg;
function getMsgData(sendableMsg, type){ function getMsgData(sendableMsg, type) {
if(type == msgType.TEXT){ if (type == msgType.TEXT) {
return WebIM.parseEmoji(sendableMsg.value.replace(/\n/mg, "")); return WebIM.parseEmoji(sendableMsg.value.replace(/\n/mg, ""));
} } else if (type == msgType.EMOJI) {
else if(type == msgType.EMOJI){
return sendableMsg.value; return sendableMsg.value;
} } else if (type == msgType.IMAGE) {
else if(type == msgType.IMAGE || type == msgType.VIDEO || type == msgType.AUDIO){
return sendableMsg.body.body.url; return sendableMsg.body.body.url;
} else if (type == msgType.FILE) {
return sendableMsg.body.body.msg
} }
return ""; return "";
} }
......
...@@ -2,10 +2,9 @@ let Disp = require("../../utils/Dispatcher"); ...@@ -2,10 +2,9 @@ let Disp = require("../../utils/Dispatcher");
let msgPackager = require("msgpackager"); let msgPackager = require("msgpackager");
let msgType = require("msgtype"); let msgType = require("msgtype");
let msgStorage = new Disp(); let msgStorage = new Disp();
let disp = require("../../utils/broadcast"); msgStorage.saveReceiveMsg = function (receiveMsg, type) {
msgStorage.saveReceiveMsg = function(receiveMsg, type){
let sendableMsg; let sendableMsg;
if(type == msgType.IMAGE){ if (type == msgType.IMAGE) {
sendableMsg = { sendableMsg = {
id: receiveMsg.id, id: receiveMsg.id,
type: type, type: type,
...@@ -16,7 +15,6 @@ msgStorage.saveReceiveMsg = function(receiveMsg, type){ ...@@ -16,7 +15,6 @@ msgStorage.saveReceiveMsg = function(receiveMsg, type){
type: receiveMsg.type, type: receiveMsg.type,
ext: receiveMsg.ext, ext: receiveMsg.ext,
chatType: receiveMsg.type, chatType: receiveMsg.type,
toJid: "",
body: { body: {
type: type, type: type,
url: receiveMsg.url, url: receiveMsg.url,
...@@ -29,8 +27,7 @@ msgStorage.saveReceiveMsg = function(receiveMsg, type){ ...@@ -29,8 +27,7 @@ msgStorage.saveReceiveMsg = function(receiveMsg, type){
}, },
}, },
}; };
} } else if (type == msgType.TEXT || type == msgType.EMOJI || type == msgType.CMD) {
else if(type == msgType.TEXT || type == msgType.EMOJI){
sendableMsg = { sendableMsg = {
id: receiveMsg.id, id: receiveMsg.id,
type: type, type: type,
...@@ -41,7 +38,6 @@ msgStorage.saveReceiveMsg = function(receiveMsg, type){ ...@@ -41,7 +38,6 @@ msgStorage.saveReceiveMsg = function(receiveMsg, type){
type: receiveMsg.type, type: receiveMsg.type,
ext: receiveMsg.ext, ext: receiveMsg.ext,
chatType: receiveMsg.type, chatType: receiveMsg.type,
toJid: "",
body: { body: {
type: type, type: type,
msg: receiveMsg.data, msg: receiveMsg.data,
...@@ -49,119 +45,28 @@ msgStorage.saveReceiveMsg = function(receiveMsg, type){ ...@@ -49,119 +45,28 @@ msgStorage.saveReceiveMsg = function(receiveMsg, type){
}, },
value: receiveMsg.data value: receiveMsg.data
}; };
} } else {
else if (type == msgType.FILE) {
sendableMsg = {
id: receiveMsg.id,
type: type,
body: {
id: receiveMsg.id,
length: receiveMsg.file_length,
from: receiveMsg.from,
to: receiveMsg.to,
type: receiveMsg.type,
ext: receiveMsg.ext,
chatType: receiveMsg.type,
toJid: "",
body: {
type: type,
url: receiveMsg.url,
filename: receiveMsg.filename,
msg: "当前不支持此格式消息展示",
},
},
value: receiveMsg.data
};
}
else if(type == msgType.AUDIO){
sendableMsg = {
id: receiveMsg.id,
type: type,
accessToken: receiveMsg.token || receiveMsg.accessToken,
body: {
id: receiveMsg.id,
length: receiveMsg.length,
from: receiveMsg.from,
to: receiveMsg.to,
type: receiveMsg.type,
ext: receiveMsg.ext,
chatType: type,
toJid: "",
body: {
type: type,
url: receiveMsg.url,
filename: receiveMsg.filename,
filetype: receiveMsg.filetype,
from: receiveMsg.from,
to: receiveMsg.to
},
},
};
}
else{
return; return;
} }
this.saveMsg(sendableMsg, type, receiveMsg); this.saveMsg(sendableMsg, type);
}; };
msgStorage.saveMsg = function(sendableMsg, type, receiveMsg){ msgStorage.saveMsg = function (sendableMsg, type) {
//console.log('sendableMsgsendableMsg', sendableMsg)
let me = this; let me = this;
let myName = wx.getStorageSync("myUsername"); let myName = wx.getStorageSync("myUsername");
let sessionKey; let sessionKey;
// 仅用作群聊收消息,发消息没有 receiveMsg sessionKey = sendableMsg.body.from == myName ?
if(receiveMsg && receiveMsg.type == "groupchat"){ sendableMsg.body.to + myName :
sessionKey = receiveMsg.to + myName; sendableMsg.body.from + myName;
}
// 群聊发 & 单发 & 单收
else{
sessionKey = sendableMsg.body.from == myName
? sendableMsg.body.to + myName
: sendableMsg.body.from + myName;
}
let curChatMsg = wx.getStorageSync(sessionKey) || []; let curChatMsg = wx.getStorageSync(sessionKey) || [];
let renderableMsg = msgPackager(sendableMsg, type, myName); let renderableMsg = msgPackager(sendableMsg, type, myName);
if(type == msgType.AUDIO) {
renderableMsg.msg.length = sendableMsg.body.length;
renderableMsg.msg.token = sendableMsg.accessToken;
}
curChatMsg.push(renderableMsg); curChatMsg.push(renderableMsg);
//console.log('renderableMsgrenderableMsg', renderableMsg)
if(type == msgType.AUDIO){
renderableMsg.msg.token = sendableMsg.accessToken;
//如果是音频则请求服务器转码
// wx.downloadFile({
// url: sendableMsg.body.body.url,
// header: {
// "X-Requested-With": "XMLHttpRequest",
// Accept: "audio/mp3",
// Authorization: "Bearer " + sendableMsg.accessToken
// },
// success(res){
// // wx.playVoice({
// // filePath: res.tempFilePath
// // });
// renderableMsg.msg.url = res.tempFilePath;
// save();
// },
// fail(e){
// console.log("downloadFile failed", e);
// }
// });
}
// else{
// save();
// }
save(); save();
function save(){
function save() {
wx.setStorage({ wx.setStorage({
key: sessionKey, key: sessionKey,
data: curChatMsg, data: curChatMsg,
success(){ success() {
if (type == msgType.AUDIO || type == msgType.VIDEO) {
disp.fire('em.chat.audio.fileLoaded');
}
me.fire("newChatMsg", renderableMsg, type, curChatMsg, sessionKey); me.fire("newChatMsg", renderableMsg, type, curChatMsg, sessionKey);
} }
}); });
......
...@@ -6,6 +6,7 @@ module.exports = { ...@@ -6,6 +6,7 @@ module.exports = {
AUDIO: "audio", AUDIO: "audio",
EMOJI: "emoji", EMOJI: "emoji",
FILE: "chat", FILE: "chat",
CMD:'cmd',
// //
chatType: { chatType: {
SINGLE_CHAT: "singleChat", SINGLE_CHAT: "singleChat",
......
let startX = 0
Component({
/**
* 组件的初始数据
*/
data: {
translateX: 0
},
/**
* 组件的方法列表
*/
methods: {
deleteItem: function (e) {
this.setData({
translateX: 0
})
this.triggerEvent('deleteChatItem', {}, {bubbles: true})
},
/**
* 滑动删除事件-滑动开始
*/
touchStartHandler: function(e) {
startX = e.touches[0].pageX
},
/**
* 滑动删除事件-滑动
*/
touchMoveHandler: function(e) {
let pageX = e.touches[0].pageX
let moveX = pageX - startX
if(Math.abs(moveX) < 80) {
return
}
// e.target.style.WebkitTransform = `translateX(${moveX}px)`
if (moveX > 0) { // 右滑 隐藏删除
if (Math.abs(this.data.translateX) == 0) {
return
} else {
this.setData({
translateX: 0
})
}
} else { // 左滑 显示删除
if (Math.abs(this.data.translateX) >= 160) {
return
} else {
this.setData({
translateX: -160
})
}
}
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class='swipedelete-wrapper' bindtouchmove='touchMoveHandler' bindtouchstart='touchStartHandler' style="transform:translateX({{translateX}}rpx)">
<slot></slot>
<view class='swipedelete-btn' bindtap='deleteItem'>删除</view>
</view>
\ No newline at end of file
.swipedelete-wrapper {
transition: all .4s ease;
position: relative;
}
.swipedelete-btn {
/* position:absolute;
top:0;
right:-180rpx;
text-align:center;
background: #f00;
color:#fff;
width:160rpx;
height:100%;
display:flex;
justify-content:center;
align-items:center;*/
position:absolute;
right: -160rpx;
top:0;
background-color:#D0021B;
width:160rpx;
height:100%;
text-align:center;
color: #fff;
display:flex;
align-items:center;
justify-content:center;
}
\ No newline at end of file
...@@ -12,8 +12,9 @@ Page({ ...@@ -12,8 +12,9 @@ Page({
onLoad(options) { onLoad(options) {
let username = JSON.parse(options.username); let username = JSON.parse(options.username);
this.setData({ username: username }); this.setData({ username: username });
console.log(username)
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
title: username.your title: username.title
}); });
}, },
......
// pages/detail/good/index.js // pages/detail/good/index.js
import { getData } from '../../../utils/util.js'; import { getData, changeTime } from '../../../utils/util.js';
import { apis } from '../../../utils/api.js'; import { apis } from '../../../utils/api.js';
Page({ Page({
...@@ -9,26 +9,33 @@ Page({ ...@@ -9,26 +9,33 @@ Page({
data: { data: {
info: null, info: null,
editOrShow:-1,//1编辑 2在线沟通 editOrShow:-1,//1编辑 2在线沟通
goodId:"",
type:"",
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
let goodId = options.goodId || ''; this.setData({
let type = options.type||''; goodId: options.goodId || '',
this.getData(goodId,type) type: options.type || ''
})
}, },
getData: function (goodId, type) { getData: function () {
let me = this; let me = this;
let token = wx.getStorageSync('access_token'); let token = wx.getStorageSync('access_token');
let url = ""; let url = "";
let goodId = me.data.goodId;
let type = me.data.type;
if (type == 1) { if (type == 1) {
url = apis.goodsInfo; url = apis.goodsInfo;
} else if (type == 2) { } else if (type == 2) {
url = apis.goodsSearch; url = apis.goodsSearch;
} else { } else {
return; return;
} }
getData(url, 'get', { getData(url, 'get', {
"goods_id/eq": goodId, "goods_id/eq": goodId,
...@@ -70,6 +77,47 @@ Page({ ...@@ -70,6 +77,47 @@ Page({
} }
}, true) }, true)
}, },
editGood:function(){
wx.navigateTo({
url: "/pages/form/good/index?goodId="+this.data.goodId,
})
},
sendTemplate:function(){
let data = this.data.info;
let my = wx.getStorageSync("myUsername");
let companyName = wx.getStorageSync("company_name");
let userId = wx.getStorageSync("user_id");
let avatar = wx.getStorageSync("avatar");
let obj = {
userId: data.im_username,
type: data.goods_name,
price: data.currency == 1 ? '¥' + data.price : '$' + data.price,
brand: data.brand_name,
fz: data.encap,
num: data.stock + '',
hq: data.delivery_time,
time: changeTime(data.add_time * 1000),
goodImage: data.goods_images,
userName: data.company_name,
targetId: data.user_id,
userImg: data.avatar,
};
let queryObj = {
myName: my,
your: data.im_username,
name: data.company_name,
name1: companyName,
id: userId,
touserid: data.user_id,
title: data.company_name,
img: data.avatar,
img1: avatar
};
wx.setStorageSync('template', obj);
wx.navigateTo({
url: "/pages/detail/chat/index?username=" + JSON.stringify(queryObj)
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
...@@ -81,7 +129,7 @@ Page({ ...@@ -81,7 +129,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
this.getData()
}, },
/** /**
......
...@@ -64,15 +64,15 @@ ...@@ -64,15 +64,15 @@
<text class="c-com">{{dateUtil.dateFormat(info.update_time*1000)}}</text> <text class="c-com">{{dateUtil.dateFormat(info.update_time*1000)}}</text>
</view> </view>
</view> </view>
<cover-image class="right" src="{{info.goods_images?info.goods_images:'/res/images/imgs/iclogo.png'}}"></cover-image> <image class="right" src="{{info.goods_images?info.goods_images:'/res/images/imgs/defaultgood.png'}}"></image>
</view> </view>
</view> </view>
</view> </view>
<view class="zxgt btn-com btn-com-y" wx:if="{{editOrShow==2}}"> <view class="zxgt btn-com btn-com-y" wx:if="{{editOrShow==2}}" bindtap="sendTemplate">
<text class="icon iconfont iconiconxiantiaoshouji11"></text> <text class="icon iconfont iconiconxiantiaoshouji11"></text>
<text class="gt-t">在线沟通</text> <text class="gt-t">在线沟通</text>
</view> </view>
<view class="zxgt btn-com btn-com-b" wx:if="{{editOrShow==1}}"> <view class="zxgt btn-com btn-com-b" wx:if="{{editOrShow==1}}" bindtap="editGood">
<text class="gt-t">编辑商品</text> <text class="gt-t">编辑商品</text>
</view> </view>
</view> </view>
\ No newline at end of file
// pages/detail/xj/index.js // pages/detail/xj/index.js
import { getData } from '../../../utils/util.js'; import { getData, changeTime } from '../../../utils/util.js';
import { apis } from '../../../utils/api.js'; import { apis } from '../../../utils/api.js';
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
info: null info: null,
topInfo:"",
}, },
/** /**
...@@ -16,12 +18,29 @@ Page({ ...@@ -16,12 +18,29 @@ Page({
onLoad: function (options) { onLoad: function (options) {
let inquiryItemsId = options.inquiryItemsId || ''; let inquiryItemsId = options.inquiryItemsId || '';
let offerId = options.offerId || ''; let offerId = options.offerId || '';
this.getData(inquiryItemsId, offerId) // this.getData(inquiryItemsId, offerId)
this.getTopInfo(inquiryItemsId,offerId)
}, },
getData: function (inquiryItemsId, offerId) { getTopInfo: function (inquiryItemsId, offerId) {
let me = this; let me = this;
let token = wx.getStorageSync('access_token'); let token = wx.getStorageSync('access_token');
getData(apis.inquiryInfo, 'get', { "inquiry_items_id/eq": inquiryItemsId, token: token }, function (res) {
if (res.errcode == 0) {
me.setData({
topInfo: res.inquiry_list[inquiryItemsId]
});
console.log(me.data.topInfo)
me.getData(inquiryItemsId, offerId,token)
} else if (res.errcode == 105001) {
me.setData({
topInfo: ""
})
}
}, true)
},
getData: function (inquiryItemsId, offerId, token) {
let me = this;
getData(apis.inquiryMyOffer, 'get', { getData(apis.inquiryMyOffer, 'get', {
"offer_id/eq": offerId, "offer_id/eq": offerId,
"inquiry_items_id/eq": inquiryItemsId, "inquiry_items_id/eq": inquiryItemsId,
...@@ -43,7 +62,50 @@ Page({ ...@@ -43,7 +62,50 @@ Page({
info: {} info: {}
}) })
} }
}, true) }, false)
},
sendTemplate:function(){
let data = this.data.info;
let my = wx.getStorageSync("myUsername");
let companyName = wx.getStorageSync("company_name");
let userId = wx.getStorageSync("user_id");
let avatar = wx.getStorageSync("avatar");
let img = "";
if(this.data.topInfo){
img = this.data.topInfo.goods_images||''
}else{
img = ""
}
let obj = {
userId: data.im_username,
type: data.goods_name,
price: data.currency == 1?'¥'+data.price:'$'+data.price,
brand: data.brand_name,
fz: data.encap,
num: data.number+'',
hq: data.delivery_time,
time: changeTime(data.add_time*1000),
goodImage: img,
userName: data.company_name,
targetId: data.user_id,
userImg: data.avatar,
};
let queryObj = {
myName: my,
your: data.im_username,
name: data.company_name,
name1: companyName,
id: userId,
touserid: data.user_id,
title: data.company_name,
img: data.avatar,
img1: avatar
};
wx.setStorageSync('template', obj);
wx.navigateTo({
url: "/pages/detail/chat/index?username=" + JSON.stringify(queryObj)
})
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
</view> </view>
</view> </view>
<view class="zxgt btn-com btn-com-y" wx:if="{{info}}"> <view class="zxgt btn-com btn-com-y" wx:if="{{info}}" bindtap="sendTemplate">
<text class="icon iconfont iconiconxiantiaoshouji11"></text> <text class="icon iconfont iconiconxiantiaoshouji11"></text>
<text class="gt-t">在线沟通</text> <text class="gt-t">在线沟通</text>
</view> </view>
......
// pages/form/bj/index.js // pages/form/bj/index.js
import { getData, tips } from '../../../utils/util.js';
import { apis } from '../../../utils/api.js';
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
isShowSwitch:false, inquiryItemsId: "",
offerId: "",
type: "",
isShowSwitch: false,
isShowTime: false,
currency: 1,
isClick: true
}, },
formSubmit: function (e) {
let obj = e.detail.value;
if (!obj.goods_name) {
tips('请填写型号');
return
} else if (!obj.brand_name) {
tips('请填写品牌');
return
} else if (!obj.number) {
tips('请填写数量');
return
} else if (!obj.price) {
tips('请填写价格');
return
} else {
if (obj.hq == 2) {//期货
if (!obj.day) {
tips('请填写货期');
return
}
}
}
this.postData(obj);
},
postData: function (obj) {
let me = this;
let token = wx.getStorageSync('access_token');
let url;
obj.hq == 1 ? obj.delivery_time = '现货' : obj.delivery_time = obj.day + '天';
obj.currency = this.data.currency;
obj.token = token;
if (me.data.type == 1) {
obj.inquiry_items_id = me.data.inquiryItemsId;
url = apis.offeradd;
} else {
obj.offer_id = me.data.offerId;
url = apis.offercontinue;
}
delete obj.day;
delete obj.hq;
if (me.data.isClick) {
me.setData({
isClick: false
})
getData(url, 'get', obj, function (res) {
if (res.errcode == 0) {
tips('提交成功')
// wx.showToast({
// title: '提交成功',
// icon: 'none',
// duration: 2000,
// success: function () {
// wx.navigateBack()
// }
// })
me.setData({
isClick: true
});
} else {
tips('提交失败')
me.setData({
isClick: true
})
}
}, true)
}
},
radioChange(e) {
let val = e.detail.value;
this.setData({
isShowTime: val == 1 ? false : true
})
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
console.log(options)
this.setData({
inquiryItemsId: options.inquiryItemsId || "",
offerId: options.offerId || "",
type: options.type || ""
})
}, },
/** /**
...@@ -63,10 +154,16 @@ Page({ ...@@ -63,10 +154,16 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
}, },
switchPrice:function(){ changePrice: function (e) {
let type = e.target.dataset.pricetype;
this.setData({
currency: type,
isShowSwitch: false
})
},
switchPrice: function () {
this.setData({ this.setData({
isShowSwitch:!this.data.isShowSwitch isShowSwitch: !this.data.isShowSwitch
}) })
} }
}) })
\ No newline at end of file
...@@ -7,70 +7,72 @@ ...@@ -7,70 +7,72 @@
</view> </view>
<text class="icon iconfont iconiconxiantiaoshouji13 close-icon"></text> <text class="icon iconfont iconiconxiantiaoshouji13 close-icon"></text>
</view> </view>
<form bindsubmit="formSubmit">
<view class="form-item row verCenter"> <view class="form-item row verCenter">
<text class="form-item-title">*型号</text> <text class="form-item-title">*型号</text>
<view class="form-item-right"> <view class="form-item-right">
<input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass" type="text"></input> <input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass" type="text" name="goods_name"></input>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top"> <view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*品牌</text> <text class="form-item-title">*品牌</text>
<view class="form-item-right"> <view class="form-item-right">
<input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass" type="text"></input> <input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass" type="text" name="brand_name"></input>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top"> <view class="form-item row verCenter px-hr-top">
<text class="form-item-title"> 封装</text> <text class="form-item-title"> 封装</text>
<view class="form-item-right"> <view class="form-item-right">
<input placeholder="请输入封装" placeholder-class="placeholderClass" type="text"></input> <input placeholder="请输入封装" placeholder-class="placeholderClass" type="text" name="encap"></input>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top"> <view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*数量</text> <text class="form-item-title">*数量</text>
<view class="form-item-right"> <view class="form-item-right">
<input placeholder="请输入数量(必填)" placeholder-class="placeholderClass" type="number"></input> <input placeholder="请输入数量(必填)" placeholder-class="placeholderClass" type="number" name="number"></input>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top bj-item"> <view class="form-item row verCenter px-hr-top bj-item">
<text class="form-item-title">*报价</text> <text class="form-item-title">*报价</text>
<view class="form-item-right row verCenter bothSide"> <view class="form-item-right row verCenter bothSide">
<input placeholder="请输入单价" placeholder-class="placeholderClass" type="number"></input> <input placeholder="请输入单价" placeholder-class="placeholderClass" type="number" name="price"></input>
<view class="price-type" bindtap="switchPrice"> <view class="price-type" bindtap="switchPrice">
<text class="price-value">RMB</text> <text class="price-value">{{currency == 1?'RMB':'USD'}}</text>
<text class="icon iconfont iconbianzu1"></text> <text class="icon iconfont iconbianzu1"></text>
</view> </view>
</view> </view>
<view class="price-ul {{isShowSwitch?'show':''}}"> <view class="price-ul {{isShowSwitch?'show':''}}">
<view class="price-li active">RMB</view> <view class="price-li {{currency == 1?'active':''}}" data-pricetype="1" bindtap="changePrice">RMB</view>
<view class="price-li px-hr-top">USD</view> <view class="price-li px-hr-top {{currency == 2?'active':''}}" data-pricetype="2" bindtap="changePrice">USD</view>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top qx-item"> <view class="form-item row verCenter px-hr-top qx-item">
<text class="form-item-title">*货期</text> <text class="form-item-title">*货期</text>
<view class="form-item-right"> <view class="form-item-right">
<radio-group> <radio-group name="hq" bindchange="radioChange">
<label> <label>
<radio value="1"/>现货 <radio value="1" checked/>现货
</label> </label>
<label> <label>
<radio value="2"/>期货 <radio value="2" />期货
</label> </label>
</radio-group> </radio-group>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top"> <view class="form-item row verCenter px-hr-top" hidden="{{!isShowTime}}">
<text class="form-item-title">*时间</text> <text class="form-item-title">*时间</text>
<view class="form-item-right"> <view class="form-item-right">
<input placeholder="请输入货期时间(天)" placeholder-class="placeholderClass" type="text"></input> <input placeholder="请输入货期时间(天)" placeholder-class="placeholderClass" type="text" name="day"></input>
</view> </view>
</view> </view>
<view class="form-hr"></view> <view class="form-hr"></view>
<view class="form-item row px-hr-bottom"> <view class="form-item row px-hr-bottom">
<text class="form-item-title">备注</text> <text class="form-item-title">备注</text>
<view class="form-item-right"> <view class="form-item-right">
<textarea placeholder="请输入备注" placeholder-class="placeholderClass" maxlength="-1" /> <textarea placeholder="请输入备注" placeholder-class="placeholderClass" maxlength="-1" name="remark"/>
</view> </view>
</view> </view>
<view class="btn-com btn-com-b hf-btn">回复报价</view> <button class="btn-com btn-com-b hf-btn" form-type="submit">回复报价</button>
</form>
</view> </view>
\ No newline at end of file
// pages/form/good/index.js // pages/form/good/index.js
import { getData, chooseImg, tips } from '../../../utils/util.js';
import { apis } from '../../../utils/api.js';
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
isShowSwitch: false isShowSwitch: false,
isShowTime: false,
imgUrl: null,
currency: 1,
isClick: true,
goodsName: "",
brandName: "",
encap: "",
stock: "",
price: "",
day: "",
goodId: "",
hq:"1"
}, },
...@@ -13,9 +27,152 @@ Page({ ...@@ -13,9 +27,152 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.setData({
goodId: options.goodId || "",
});
if (this.data.goodId) {
wx.setNavigationBarTitle({
title: '编辑商品'
})
this.getGoodData();
} else {
wx.setNavigationBarTitle({
title: '新增商品'
})
}
}, },
getGoodData: function () {
let me = this;
let token = wx.getStorageSync('access_token');
let goodId = me.data.goodId;
getData(apis.goodsInfo, 'get', {
"goods_id/eq": goodId,
"token": token,
}, function (res) {
if (res.errcode == 0) {
if (res.total == 0) {
return
} else {
let infoObj = res.goods_list[me.data.goodId]
me.renderForm(infoObj)
}
} else {
tips('获取商品详情失败');
}
}, true)
},
renderForm: function (infoObj) {
this.setData({
goodsName:infoObj.goods_name,
brandName: infoObj.brand_name,
encap: infoObj.encap,
stock: infoObj.stock,
price: infoObj.price,
currency: infoObj.currency,
imgUrl:infoObj.goods_images
});
if(infoObj.delivery_time !== '现货'){
let day = infoObj.delivery_time.replace('天','');
console.log(day)
this.setData({
isShowTime:2,
hq:2,
day:day
});
}
},
formSubmit: function (e) {
let obj = e.detail.value;
if (!obj.goods_name) {
tips('请填写型号');
return
} else if (!obj.brand_name) {
tips('请填写品牌');
return
} else if (!obj.stock) {
tips('请填写库存');
return
} else if (!obj.price) {
tips('请填写价格');
return
} else {
if (obj.hq == 2) {//期货
if (!obj.day) {
tips('请填写货期');
return
}
}
}
this.postData(obj);
},
postData: function (obj) {
let me = this;
let token = wx.getStorageSync('access_token');
let url = "";
obj.hq == 1 ? obj.delivery_time = '现货' : obj.delivery_time = obj.day + '天';
obj.currency = this.data.currency;
obj.goods_images = this.data.imgUrl || '';
obj.token = token;
if (me.data.goodId) {
obj.goods_id = me.data.goodId;
url = apis.goodsSave
} else {
url = apis.goodsAdd;
}
delete obj.day;
delete obj.hq;
if (me.data.isClick) {
me.setData({
isClick: false
})
getData(url, 'get', obj, function (res) {
if (res.errcode == 0) {
tips('操作成功')
me.setData({
isClick: true
});
setTimeout(() => {
wx.navigateBack()
}, 1000)
} else {
tips('操作失败')
me.setData({
isClick: true
})
}
}, true)
}
},
radioChange(e) {
let val = e.detail.value;
this.setData({
isShowTime: val == 1 ? false : true,
hq:val
})
},
uploadImg: function () {
let me = this;
chooseImg(apis.ossupload, 1, function (url) {
me.setData({
imgUrl: url
})
})
},
deleteImg: function () {
this.setData({
imgUrl: null
})
},
deleteGood:function(){
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
...@@ -64,6 +221,13 @@ Page({ ...@@ -64,6 +221,13 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
}, },
changePrice: function (e) {
let type = e.target.dataset.pricetype;
this.setData({
currency: type,
isShowSwitch: false
})
},
switchPrice: function () { switchPrice: function () {
this.setData({ this.setData({
isShowSwitch: !this.data.isShowSwitch isShowSwitch: !this.data.isShowSwitch
......
{ {
"usingComponents": {}, "usingComponents": {},
"navigationBarTitleText": "新增商品" "navigationBarTitleText": ""
} }
\ No newline at end of file
...@@ -8,66 +8,79 @@ ...@@ -8,66 +8,79 @@
<text class="icon iconfont iconiconxiantiaoshouji13 close-icon"></text> <text class="icon iconfont iconiconxiantiaoshouji13 close-icon"></text>
</view> </view>
<view class="upload-view column verCenter"> <view class="upload-view column verCenter">
<view class="upload column verCenter rowCenter"> <view class="upload column verCenter rowCenter" bindtap="uploadImg" wx:if="{{!imgUrl}}">
<text class="icon iconfont iconiconxiantiaoshouji15"></text> <text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text class="upload-text">上传图片</text> <text class="upload-text">上传图片</text>
</view> </view>
<view class="hasImg" wx:else>
<cover-image src="{{imgUrl}}"></cover-image>
<text class="icon iconfont iconiconxiantiaoshouji7 deleteImg" bindtap="deleteImg"></text>
</view>
<view class="text">据说上传图片更容易被采纳报价</view> <view class="text">据说上传图片更容易被采纳报价</view>
</view> </view>
<form bindsubmit="formSubmit">
<view class="form-item row verCenter"> <view class="form-item row verCenter">
<text class="form-item-title">*型号</text> <text class="form-item-title">*型号</text>
<view class="form-item-right"> <view class="form-item-right">
<input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass"></input> <input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass" value="{{goodsName}}" type="text" name="goods_name"></input>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top"> <view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*品牌</text> <text class="form-item-title">*品牌</text>
<view class="form-item-right"> <view class="form-item-right">
<input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass"></input> <input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass" type="text" name="brand_name" value="{{brandName}}"></input>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top"> <view class="form-item row verCenter px-hr-top">
<text class="form-item-title"> 封装</text> <text class="form-item-title"> 封装</text>
<view class="form-item-right"> <view class="form-item-right">
<input placeholder="请输入封装" placeholder-class="placeholderClass"></input> <input placeholder="请输入封装" placeholder-class="placeholderClass" type="text" name="encap" value="{{encap}}"></input>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top"> <view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*库存</text> <text class="form-item-title">*库存</text>
<view class="form-item-right"> <view class="form-item-right">
<input placeholder="请输入库存数量(必填)" placeholder-class="placeholderClass"></input> <input placeholder="请输入库存数量(必填)" placeholder-class="placeholderClass" type="number" name="stock" value="{{stock}}"></input>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top bj-item"> <view class="form-item row verCenter px-hr-top bj-item">
<text class="form-item-title">*报价</text> <text class="form-item-title">*报价</text>
<view class="form-item-right row verCenter bothSide"> <view class="form-item-right row verCenter bothSide">
<input placeholder="请输入单价" placeholder-class="placeholderClass"></input> <input placeholder="请输入单价" placeholder-class="placeholderClass" type="number" name="price" value="{{price}}"></input>
<view class="price-type" bindtap="switchPrice"> <view class="price-type" bindtap="switchPrice">
<text class="price-value">RMB</text> <text class="price-value">{{currency == 1?'RMB':'USD'}}</text>
<text class="icon iconfont iconbianzu1"></text> <text class="icon iconfont iconbianzu1"></text>
</view> </view>
</view> </view>
<view class="price-ul {{isShowSwitch?'show':''}}"> <view class="price-ul {{isShowSwitch?'show':''}}">
<view class="price-li active">RMB</view> <view class="price-li {{currency == 1?'active':''}}" data-pricetype="1" bindtap="changePrice">RMB</view>
<view class="price-li px-hr-top">USD</view> <view class="price-li px-hr-top {{currency == 2?'active':''}}" data-pricetype="2" bindtap="changePrice">USD</view>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top qx-item px-hr-bottom"> <view class="form-item row verCenter px-hr-top qx-item px-hr-bottom">
<text class="form-item-title">*货期</text> <text class="form-item-title">*货期</text>
<view class="form-item-right"> <view class="form-item-right">
<radio-group> <radio-group name="hq" bindchange="radioChange">
<label> <label>
<radio value="1" checked/>现货 <radio value="1" checked="{{hq == 1}}"/>现货
</label> </label>
<label> <label>
<radio value="2" checked/>期货 <radio value="2" checked="{{hq == 2}}"/>期货
</label> </label>
</radio-group> </radio-group>
</view> </view>
</view> </view>
<view class="btn-com btn-com-b hf-btn"> <view class="form-item row verCenter px-hr-bottom" hidden="{{!isShowTime}}">
<text class="icon iconfont iconiconxiantiaoshouji15"></text> <text class="form-item-title">*时间</text>
<text>新增商品</text> <view class="form-item-right">
<input placeholder="请输入货期时间(天)" placeholder-class="placeholderClass" type="text" name="day" value="{{day}}"></input>
</view>
</view> </view>
<!-- <button class="btn-com btn-com-b hf-btn " form-type="submit" style="margin-bottom:{{'goodId'&&'32rpx'}}"> -->
<!-- <text class="icon iconfont iconiconxiantiaoshouji15"></text> -->
<button class="btn-com btn-com-b hf-btn " form-type="submit">
<text>保存</text>
</button>
<!-- <button class="btn-com delete-btn" wx:if="{{goodId}}" bindtap="deleteGood">删除商品</button> -->
</form>
</view> </view>
\ No newline at end of file
// pages/form/xj/index.js // pages/form/xj/index.js
import { getData, chooseImg } from '../../../utils/util.js'; import { getData, chooseImg, tips } from '../../../utils/util.js';
import { apis } from '../../../utils/api.js'; import { apis } from '../../../utils/api.js';
Page({ Page({
...@@ -9,28 +9,81 @@ Page({ ...@@ -9,28 +9,81 @@ Page({
data: { data: {
isShowSwitch: false, isShowSwitch: false,
isShowTime: false, isShowTime: false,
imgUrl:null, imgUrl: null,
currency: 1,
isClick: true
}, },
formSubmit: function (e) { formSubmit: function (e) {
console.log(e) let obj = e.detail.value;
if (!obj.goods_name) {
tips('请填写型号');
return
} else if (!obj.brand_name) {
tips('请填写品牌');
return
} else if (!obj.number) {
tips('请填写数量');
return
} else if (!obj.price) {
tips('请填写价格');
return
} else {
if (obj.hq == 2) {//期货
if (!obj.day) {
tips('请填写货期');
return
}
}
}
this.postData(obj);
},
postData: function (obj) {
let me = this;
let token = wx.getStorageSync('access_token');
obj.hq == 1 ? obj.delivery_time = '现货' : obj.delivery_time = obj.day + '天';
obj.currency = this.data.currency;
obj.goods_images = this.data.imgUrl || '';
obj.token = token;
delete obj.day;
delete obj.hq;
if (me.data.isClick) {
me.setData({
isClick: false
})
getData(apis.inquiryadd, 'get', obj, function (res) {
if (res.errcode == 0) {
tips('发布成功')
me.setData({
isClick: true
})
} else {
tips('发布失败')
me.setData({
isClick: true
})
}
}, true)
}
}, },
radioChange(e) { radioChange(e) {
let val = e.detail.value; let val = e.detail.value;
this.setData({ this.setData({
isShowTime: val == 1?false:true isShowTime: val == 1 ? false : true
}) })
}, },
uploadImg:function(){ uploadImg: function () {
let me = this; let me = this;
chooseImg(apis.ossupload, 1, function(url){ chooseImg(apis.ossupload, 1, function (url) {
me.setData({ me.setData({
imgUrl:url imgUrl: url
}) })
}) })
}, },
deleteImg:function(){ deleteImg: function () {
this.setData({ this.setData({
imgUrl: null imgUrl: null
}) })
...@@ -90,8 +143,14 @@ Page({ ...@@ -90,8 +143,14 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
}, },
changePrice: function (e) {
let type = e.target.dataset.pricetype;
this.setData({
currency: type,
isShowSwitch: false
})
},
switchPrice: function () { switchPrice: function () {
this.setData({ this.setData({
isShowSwitch: !this.data.isShowSwitch isShowSwitch: !this.data.isShowSwitch
}) })
......
...@@ -48,14 +48,14 @@ ...@@ -48,14 +48,14 @@
<view class="form-item-right row verCenter bothSide"> <view class="form-item-right row verCenter bothSide">
<input placeholder="请输入单价" placeholder-class="placeholderClass" type="number" name="price"></input> <input placeholder="请输入单价" placeholder-class="placeholderClass" type="number" name="price"></input>
<view class="price-type" bindtap="switchPrice"> <view class="price-type" bindtap="switchPrice">
<text class="price-value">RMB</text> <text class="price-value">{{currency == 1?'RMB':'USD'}}</text>
<text class="icon iconfont iconbianzu1"></text> <text class="icon iconfont iconbianzu1"></text>
</view> </view>
</view> </view>
<view class="price-ul {{isShowSwitch?'show':''}}"> <view class="price-ul {{isShowSwitch?'show':''}}">
<view class="price-li active">RMB</view> <view class="price-li {{currency == 1?'active':''}}" data-pricetype="1" bindtap="changePrice">RMB</view>
<view class="price-li px-hr-top">USD</view> <view class="price-li px-hr-top {{currency == 2?'active':''}}" data-pricetype="2" bindtap="changePrice">USD</view>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top qx-item"> <view class="form-item row verCenter px-hr-top qx-item">
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
</radio-group> </radio-group>
</view> </view>
</view> </view>
<view class="form-item row verCenter px-hr-top" wx:if="{{isShowTime}}"> <view class="form-item row verCenter px-hr-top" hidden="{{!isShowTime}}">
<text class="form-item-title">*时间</text> <text class="form-item-title">*时间</text>
<view class="form-item-right"> <view class="form-item-right">
<input placeholder="请输入货期时间(天)" placeholder-class="placeholderClass" type="text" name="day"></input> <input placeholder="请输入货期时间(天)" placeholder-class="placeholderClass" type="text" name="day"></input>
......
...@@ -9,7 +9,9 @@ Page({ ...@@ -9,7 +9,9 @@ Page({
data: { data: {
priceList: null, priceList: null,
topInfo: null, topInfo: null,
total: 0 total: 0,
inquiryItemsId: "",
offerId:""
}, },
/** /**
...@@ -18,11 +20,15 @@ Page({ ...@@ -18,11 +20,15 @@ Page({
onLoad: function (options) { onLoad: function (options) {
let inquiryItemsId = options.inquiryItemsId || ''; let inquiryItemsId = options.inquiryItemsId || '';
let offerId = options.offerId || ''; let offerId = options.offerId || '';
this.getTopInfo(inquiryItemsId); this.setData({
this.getList(inquiryItemsId, offerId) inquiryItemsId: inquiryItemsId,
offerId: offerId
});
}, },
getTopInfo: function (id) { getTopInfo: function () {
let me = this; let me = this;
let id = me.data.inquiryItemsId;
getData(apis.inquirySearch, 'get', { "inquiry_items_id/eq": id }, function (res) { getData(apis.inquirySearch, 'get', { "inquiry_items_id/eq": id }, function (res) {
if (res.errcode === 0) { if (res.errcode === 0) {
me.setData({ me.setData({
...@@ -35,8 +41,10 @@ Page({ ...@@ -35,8 +41,10 @@ Page({
} }
}, false) }, false)
}, },
getList: function (inquiryItemsId, offerId) { getList: function () {
let me = this; let me = this;
let inquiryItemsId = me.data.inquiryItemsId;
let offerId = me.data.offerId;
let token = wx.getStorageSync('access_token'); let token = wx.getStorageSync('access_token');
let params = { token: token }; let params = { token: token };
if (offerId) { if (offerId) {
...@@ -53,8 +61,8 @@ Page({ ...@@ -53,8 +61,8 @@ Page({
}) })
} else { } else {
let arr = res.data[0].items || []; let arr = res.data[0].items || [];
for (let i = 0; i < arr.length;i++){ for (let i = 0; i < arr.length; i++) {
arr[i].company_name = res.data[0].company_name||'' arr[i].company_name = res.data[0].company_name || ''
} }
me.setData({ me.setData({
priceList: arr, priceList: arr,
...@@ -81,7 +89,14 @@ Page({ ...@@ -81,7 +89,14 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
this.setData({
priceList: null,
topInfo: null,
total: 0,
})
this.getTopInfo();
this.getList()
}, },
/** /**
...@@ -126,10 +141,18 @@ Page({ ...@@ -126,10 +141,18 @@ Page({
duration: 2000 duration: 2000
}); });
} else { } else {
if (this.data.total == 0) {
wx.navigateTo({
url: "/pages/form/bj/index?type=1&inquiryItemsId=" + this.data.inquiryItemsId,
})
} else {
let offerId = this.data.priceList[0].offer_id || ''
wx.navigateTo({ wx.navigateTo({
url: "/pages/form/bj/index", url: "/pages/form/bj/index?type=2&offerId=" + offerId,
}) })
} }
} }
}
}) })
\ No newline at end of file
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<text class="c-com">{{topInfo.remark||'--'}}</text> <text class="c-com">{{topInfo.remark||'--'}}</text>
</view> </view>
</view> </view>
<cover-image class="right" src="{{topInfo.goods_images?topInfo.goods_images:'/res/images/imgs/iclogo.png'}}"></cover-image> <image class="right" src="{{topInfo.goods_images?topInfo.goods_images:'/res/images/imgs/defaultgood.png'}}"></image>
</view> </view>
</view> </view>
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
</view> </view>
<view class="bj-list"> <view class="bj-list">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata"> <view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/noxb.png" class="img"></cover-image> <image src="/res/images/imgs/noxb.png" class="img"></image>
<!-- <view class="h3 bold">暂无报价信息</view> --> <!-- <view class="h3 bold">暂无报价信息</view> -->
</view> </view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="4"></priceItem> <priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="4"></priceItem>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</view> </view>
<view class="qd-content"> <view class="qd-content">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata"> <view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/noxb.png" class="img"></cover-image> <image src="/res/images/imgs/noxb.png" class="img"></image>
<view class="h3 bold">暂无询报价信息</view> <view class="h3 bold">暂无询报价信息</view>
<view class="p">您还可以发布询价。</view> <view class="p">您还可以发布询价。</view>
<view class="fb_btn btn-com btn-com-b" bindtap="toXj"> <view class="fb_btn btn-com btn-com-b" bindtap="toXj">
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<text class="c-com">{{topInfo.remark||'--'}}</text> <text class="c-com">{{topInfo.remark||'--'}}</text>
</view> </view>
</view> </view>
<cover-image class="right" src="{{topInfo.goods_images?topInfo.goods_images:'/res/images/imgs/iclogo.png'}}"></cover-image> <image class="right" src="{{topInfo.goods_images?topInfo.goods_images:'/res/images/imgs/defaultgood.png'}}"></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
</view> </view>
<view class="bj-list"> <view class="bj-list">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata"> <view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/noxb.png" class="img"></cover-image> <image src="/res/images/imgs/noxb.png" class="img"></image>
<view class="h3 bold">暂无报价信息</view> <view class="h3 bold">暂无报价信息</view>
</view> </view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="3" xb="2"></priceItem> <priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="3" xb="2"></priceItem>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class='head column verCenter'> <view class='head column verCenter'>
<view class="head-logo column"> <view class="head-logo column">
<view class='logo'> <view class='logo'>
<cover-image src="/res/images/imgs/iclogo.png" class="img"></cover-image> <image src="/res/images/imgs/iclogo.png" class="img"></image>
</view> </view>
<text class="t1">IC业务助手</text> <text class="t1">IC业务助手</text>
<text class='t2'>让询报价更轻松、便捷</text> <text class='t2'>让询报价更轻松、便捷</text>
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
</block> </block>
<block wx:else> <block wx:else>
<view class="view column rowCenter verCenter"> <view class="view column rowCenter verCenter">
<cover-image src="/res/images/imgs/test.jpg " class="img"></cover-image> <image src="/res/images/imgs/test.jpg " class="img"></image>
<text class="icon iconfont iconiconxiantiaoshouji7"></text> <text class="icon iconfont iconiconxiantiaoshouji7"></text>
</view> </view>
</block> </block>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<view class="content"> <view class="content">
<text class="time">更新时间:2019-05-10</text> <text class="time">更新时间:2019-05-10</text>
<view class="status row verCenter rowCenter"> <view class="status row verCenter rowCenter">
<cover-image src="/res/images/imgs/test.jpg " class="img"></cover-image> <image src="/res/images/imgs/test.jpg " class="img"></image>
<text class=c"></text> <text class=c"></text>
</view> </view>
<view class="error"> <view class="error">
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<view class="form-item-right row verCenter bothSide"> <view class="form-item-right row verCenter bothSide">
<input placeholder="请输入图形验证码" placeholder-class="placeholderClass" name='captcha' data-type="3" bindinput='bindinputFn'></input> <input placeholder="请输入图形验证码" placeholder-class="placeholderClass" name='captcha' data-type="3" bindinput='bindinputFn'></input>
<view class='code-img'> <view class='code-img'>
<cover-image src="{{captchaUrl}}" class="img" bindtap='refreshVerification'></cover-image> <image src="{{captchaUrl}}" class="img" bindtap='refreshVerification'></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<block wx:elif="{{type === 3}}"> <block wx:elif="{{type === 3}}">
<view class="success column rowCenter verCenter"> <view class="success column rowCenter verCenter">
<cover-image src="/res/images/imgs/scu.png" class="img"></cover-image> <image src="/res/images/imgs/scu.png" class="img"></image>
<text class="t1">恭喜您,密码找回成功</text> <text class="t1">恭喜您,密码找回成功</text>
<text class="t2">请保管好您的账户信息。</text> <text class="t2">请保管好您的账户信息。</text>
</view> </view>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class='head column verCenter'> <view class='head column verCenter'>
<view class="head-logo column"> <view class="head-logo column">
<view class='logo'> <view class='logo'>
<cover-image src="/res/images/imgs/iclogo.png" class="img"></cover-image> <image src="/res/images/imgs/iclogo.png" class="img"></image>
</view> </view>
<text class="t1">IC业务助手</text> <text class="t1">IC业务助手</text>
<text class='t2'>让询报价更轻松、便捷</text> <text class='t2'>让询报价更轻松、便捷</text>
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<view class="form-item-right row verCenter bothSide"> <view class="form-item-right row verCenter bothSide">
<input placeholder="请输入图形验证码" placeholder-class="placeholderClass" name='captcha' data-type="3" bindinput='bindinputFn'></input> <input placeholder="请输入图形验证码" placeholder-class="placeholderClass" name='captcha' data-type="3" bindinput='bindinputFn'></input>
<view class='code-img'> <view class='code-img'>
<cover-image src="{{captchaUrl}}" class="img" bindtap='refreshVerification'></cover-image> <image src="{{captchaUrl}}" class="img" bindtap='refreshVerification'></image>
</view> </view>
</view> </view>
</view> </view>
......
<view class="success column rowCenter verCenter"> <view class="success column rowCenter verCenter">
<cover-image src="/res/images/imgs/success.png" class="img"></cover-image> <image src="/res/images/imgs/success.png" class="img"></image>
<text class="tit">恭喜您,注册成功</text> <text class="tit">恭喜您,注册成功</text>
<navigator url="/pages/person/login/index" class="btn">资质认证</navigator> <navigator url="/pages/person/login/index" class="btn">资质认证</navigator>
<view class="txt"> <view class="txt">
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<view class="form-item-right row verCenter bothSide"> <view class="form-item-right row verCenter bothSide">
<input placeholder="请输入图形验证码" placeholder-class="placeholderClass" name='captcha' data-type="3" bindinput='bindinputFn'></input> <input placeholder="请输入图形验证码" placeholder-class="placeholderClass" name='captcha' data-type="3" bindinput='bindinputFn'></input>
<view class='code-img'> <view class='code-img'>
<cover-image src="{{captchaUrl}}" class="img" bindtap='refreshVerification'></cover-image> <image src="{{captchaUrl}}" class="img" bindtap='refreshVerification'></image>
</view> </view>
</view> </view>
</view> </view>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</view> </view>
<view class="searchresult-content"> <view class="searchresult-content">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata"> <view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/nodata.png" class="img"></cover-image> <image src="/res/images/imgs/nodata.png" class="img"></image>
<view class="h3 bold">未搜索到相关信息</view> <view class="h3 bold">未搜索到相关信息</view>
<view class="p"> <view class="p">
<text wx:if="{{tabIndex == 2}}">您还可以发布询价。</text> <text wx:if="{{tabIndex == 2}}">您还可以发布询价。</text>
......
...@@ -105,7 +105,7 @@ Page({ ...@@ -105,7 +105,7 @@ Page({
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function () {
console.log(111)
}, },
/** /**
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
"usingComponents": { "usingComponents": {
"priceItem": "/components/priceItem/priceItem" "priceItem": "/components/priceItem/priceItem"
}, },
"navigationBarTitleText": "商品管理" "navigationBarTitleText": "商品管理",
"enablePullDownRefresh":true
} }
\ No newline at end of file
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</view> </view>
<view class="good-content"> <view class="good-content">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata"> <view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/nodata.png" class="img"></cover-image> <image src="/res/images/imgs/nodata.png" class="img"></image>
<view class="h3 bold">未搜索到相关信息</view> <view class="h3 bold">未搜索到相关信息</view>
<view class="p">您还可以发布询价。</view> <view class="p">您还可以发布询价。</view>
<view class="btn-com btn-com-b add-good-btn" bindtap="fbGood"> <view class="btn-com btn-com-b add-good-btn" bindtap="fbGood">
......
...@@ -61,7 +61,6 @@ Page({ ...@@ -61,7 +61,6 @@ Page({
let interVal = setInterval(() => { let interVal = setInterval(() => {
let translateY = me.data.translateY; let translateY = me.data.translateY;
if (translateY + allHeight == 0) { if (translateY + allHeight == 0) {
console.log('到底啦');
// clearInterval(interVal); // clearInterval(interVal);
// let arr = me.data.xjList.concat(); // let arr = me.data.xjList.concat();
// let arr1 = arr.splice(arrLen-2,arrLen); // let arr1 = arr.splice(arrLen-2,arrLen);
......
...@@ -7,19 +7,19 @@ ...@@ -7,19 +7,19 @@
<view class="home-content"> <view class="home-content">
<view class="home-function bothSide row"> <view class="home-function bothSide row">
<view class="function-item column verCenter" bindtap="toXj"> <view class="function-item column verCenter" bindtap="toXj">
<cover-image src="/res/images/icons/home-s-1.png" class="img"></cover-image> <image src="/res/images/icons/home-s-1.png" class="img"></image>
<text class="text">发布询价</text> <text class="text">发布询价</text>
</view> </view>
<view class="function-item column verCenter" bindtap="toQd"> <view class="function-item column verCenter" bindtap="toQd">
<cover-image src="/res/images/icons/home-s-2.png" class="img"></cover-image> <image src="/res/images/icons/home-s-2.png" class="img"></image>
<text class="text">抢单专区</text> <text class="text">抢单专区</text>
</view> </view>
<view class="function-item column verCenter" bindtap="fbGood"> <view class="function-item column verCenter" bindtap="fbGood">
<cover-image src="/res/images/icons/home-s-3.png" class="img"></cover-image> <image src="/res/images/icons/home-s-3.png" class="img"></image>
<text class="text">发布商品</text> <text class="text">发布商品</text>
</view> </view>
<view class="function-item column verCenter"> <view class="function-item column verCenter">
<cover-image src="/res/images/icons/home-s-4.png" class="img"></cover-image> <image src="/res/images/icons/home-s-4.png" class="img"></image>
<text class="text">积分兑换</text> <text class="text">积分兑换</text>
</view> </view>
</view> </view>
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
</view> </view>
<view class="price-content"> <view class="price-content">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata"> <view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/noxb.png" class="img" style="width:500rpx;"></cover-image> <image src="/res/images/imgs/noxb.png" class="img" style="width:500rpx;"></image>
<view class="h3 bold">暂无询报价信息</view> <view class="h3 bold">暂无询报价信息</view>
<view class="p" style="color:#61A0F2;padding-top:20rpx;">您还可以发布询价。</view> <view class="p" style="color:#61A0F2;padding-top:20rpx;">您还可以发布询价。</view>
</view> </view>
......
<view class="mine" hover-class="none" hover-stop-propagation="false"> <view class="mine" hover-class="none" hover-stop-propagation="false">
<view class="head row verCenter"> <view class="head row verCenter">
<view class="pic"> <view class="pic">
<cover-image class="im" src="{{userInfo.avatar ? userInfo.avatar:'/res/images/imgs/default.png'}}"></cover-image> <image class="im" src="{{userInfo.avatar ? userInfo.avatar:'/res/images/imgs/default.png'}}"></image>
</view> </view>
<view class="text"> <view class="text">
<text class="t1">{{userInfo.company_name}}</text> <text class="t1">{{userInfo.company_name}}</text>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<!-- 签到弹出层 --> <!-- 签到弹出层 -->
<view wx:if="{{isShow}}" class="layer-mask column verCenter rowCenter" hover-class="none" hover-stop-propagation="false"> <view wx:if="{{isShow}}" class="layer-mask column verCenter rowCenter" hover-class="none" hover-stop-propagation="false">
<view class="layer column verCenter rowCenter"> <view class="layer column verCenter rowCenter">
<cover-image class="im" src="/res/images/imgs/star.png"></cover-image> <image class="im" src="/res/images/imgs/star.png"></image>
<text class="t1">恭喜您获得</text> <text class="t1">恭喜您获得</text>
<view class="txt"> <view class="txt">
<text class="t2">666</text> <text class="t2">666</text>
......
...@@ -9,6 +9,8 @@ Page({ ...@@ -9,6 +9,8 @@ Page({
data: { data: {
unReadSpotNum: 0, unReadSpotNum: 0,
arr: [], arr: [],
userId:"",
customer:{}
}, },
/** /**
...@@ -18,7 +20,6 @@ Page({ ...@@ -18,7 +20,6 @@ Page({
let me = this; let me = this;
//监听未读消息数 //监听未读消息数
disp.on("em.xmpp.unreadspot", function (message) { disp.on("em.xmpp.unreadspot", function (message) {
console.log(111)
me.setData({ me.setData({
arr: me.getChatList(), arr: me.getChatList(),
unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ? '99+' : getApp().globalData.unReadMessageNum, unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ? '99+' : getApp().globalData.unReadMessageNum,
...@@ -50,16 +51,25 @@ Page({ ...@@ -50,16 +51,25 @@ Page({
array.sort((a, b) => { array.sort((a, b) => {
return b.dateTimeNum - a.dateTimeNum return b.dateTimeNum - a.dateTimeNum
}) })
console.log(array)
return array; return array;
}, },
into_singleChatRoom: function (detail) { into_singleChatRoom: function (detail) {
var my = wx.getStorageSync("myUsername"); var my = wx.getStorageSync("myUsername");
console.log(detail)
var nameList = { var nameList = {
myName: my, myName: my,
your: detail.username your: detail.username,
name:detail.ext.name,
name1:detail.ext.name1,
id:detail.ext.id,
touserid:detail.ext.touserid,
title: detail.name,
img:detail.ext.img,
img1:detail.ext.img1
}; };
console.log(JSON.stringify(nameList))
wx.navigateTo({ wx.navigateTo({
url: "/pages/detail/chat/index?username=" + JSON.stringify(nameList) url: "/pages/detail/chat/index?username=" + JSON.stringify(nameList)
}); });
...@@ -67,7 +77,6 @@ Page({ ...@@ -67,7 +77,6 @@ Page({
into_chatRoom: function (event) { into_chatRoom: function (event) {
let detail = event.currentTarget.dataset.item; let detail = event.currentTarget.dataset.item;
this.into_singleChatRoom(detail) this.into_singleChatRoom(detail)
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
...@@ -81,8 +90,39 @@ Page({ ...@@ -81,8 +90,39 @@ Page({
*/ */
onShow: function () { onShow: function () {
let my = wx.getStorageSync("myUsername");
let companyName = wx.getStorageSync("company_name")||'';
let userId = wx.getStorageSync("user_id") || '';
let avatar = wx.getStorageSync("avatar") || '';
let customerKey = 'rendered_' + getApp().globalData.customerNum + my
let customer = wx.getStorageSync(customerKey) || '';
if(customer){
this.setData({
customer:customer[customer.length-1]
})
console.log(this.data.customer)
}else{
this.setData({
customer: {
username: getApp().globalData.customerNum,
ext:{
name: getApp().globalData.customerName,
name1: companyName,
id: userId,
touserid: '',
img: '',
img1: avatar
},
name: getApp().globalData.customerName,
}
})
}
this.setData({ this.setData({
arr: this.getChatList(), arr: this.getChatList(),
userId:wx.getStorageSync('user_id'),
unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ? '99+' : getApp().globalData.unReadMessageNum, unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ? '99+' : getApp().globalData.unReadMessageNum,
}); });
}, },
......
{ {
"usingComponents": {}, "usingComponents": {
"swipe-delete": "../../../components/swipedelete/swipedelete"
},
"navigationBarTitleText": "消息" "navigationBarTitleText": "消息"
} }
\ No newline at end of file
<!--pages/tab/message/message.wxml--> <!--pages/tab/message/message.wxml-->
<view class="message-view"> <scroll-view scroll-y="true" class="message-view">
<view class="nodata" wx:if="{{arr.length == 0}}"> <!-- <view class="nodata" wx:if="{{arr.length == 0}}">
<cover-image src="/res/images/imgs/nomessage.png" class="img"></cover-image> <image src="/res/images/imgs/nomessage.png" class="img"></image>
<view class="h3 bold">暂无询价消息</view> <view class="h3 bold">暂无询价消息</view>
</view> </view> -->
<view class="message-content" wx:else> <view class="message-content">
<view class="tip row bothSide verCenter"> <view class="tip row bothSide verCenter">
<view class="tip-left"> <view class="tip-left">
<text class="icon iconfont iconiconxiantiaoshouji12 tip-icon"></text> <text class="icon iconfont iconiconxiantiaoshouji12 tip-icon"></text>
...@@ -13,12 +13,33 @@ ...@@ -13,12 +13,33 @@
<text class="icon iconfont iconiconxiantiaoshouji13 close-icon"></text> <text class="icon iconfont iconiconxiantiaoshouji13 close-icon"></text>
</view> </view>
<view class="message-list"> <view class="message-list">
<view class="message-item px-hr-bottom row verCenter bothSide nowrap" wx:for="{{ arr }}" wx:key="index" catchtap="into_chatRoom" data-item="{{ item }}"> <view catchtap="into_chatRoom" data-item="{{customer}}">
<view class="message-l row verCenter ellipsis"> <view class="message-item px-hr-bottom row bothSide nowrap">
<cover-image src="/res/images/imgs/iclogo.png" class="message-avar"></cover-image> <view class="message-l row ellipsis">
<image src="/res/images/imgs/timg.jpg" class="message-avar"></image>
<view class="message-l-view ellipsis"> <view class="message-l-view ellipsis">
<view class="message-c bold ellipsis">{{ item.username }}</view> <view class="message-c bold ellipsis">IC助手客服</view>
<view class="message-t ellipsis">{{ item.msg.data[0].data }}</view> <view class="message-t ellipsis" wx:if="{{ customer.msg.data[0].data }}">{{ customer.msg.data[0].data }}</view>
<view class="message-t ellipsis" wx:if="{{customer.msg.type == 'img' }}">[图片]</view>
<view class="message-t ellipsis" wx:if="{{customer.msg.type == 'cmd' }}">{{customer.ext.type}} {{customer.ext.price}}</view>
</view>
</view>
<view class="message-r">
<view class="message-r-t">{{customer.time}}</view>
<view class="message-r-n" wx:if="{{ customer.unReadCount > 0 || customer.unReadCount == '99+' }}">{{ customer.unReadCount }}</view>
</view>
</view>
</view>
<view wx:for="{{ arr }}" wx:key="index" catchtap="into_chatRoom" data-item="{{ item }}">
<swipe-delete>
<view class="message-item px-hr-bottom row bothSide nowrap">
<view class="message-l row ellipsis">
<image src="{{item.img?item.img:'/res/images/imgs/s.png'}}" class="message-avar"></image>
<view class="message-l-view ellipsis">
<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.type == 'img' }}">[图片]</view>
<view class="message-t ellipsis" wx:if="{{item.msg.type == 'cmd' }}">{{item.ext.type}} {{item.ext.price}}</view>
</view> </view>
</view> </view>
<view class="message-r"> <view class="message-r">
...@@ -26,6 +47,8 @@ ...@@ -26,6 +47,8 @@
<view class="message-r-n" wx:if="{{ item.unReadCount > 0 || item.unReadCount == '99+' }}">{{ item.unReadCount }}</view> <view class="message-r-n" wx:if="{{ item.unReadCount > 0 || item.unReadCount == '99+' }}">{{ item.unReadCount }}</view>
</view> </view>
</view> </view>
</swipe-delete>
</view>
</view> </view>
</view> </view>
</view> </scroll-view>
\ No newline at end of file \ No newline at end of file
/* pages/tab/message/message.wxss */ /* pages/tab/message/message.wxss */
page{
overflow: hidden
}
.message-view{ .message-view{
/* overflow: hidden; */
position: fixed;
top:0;
bottom:0;
left:0;
right:0;
overflow: hidden; overflow: hidden;
} }
.tip { .tip {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</view> </view>
<view class="price-content"> <view class="price-content">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata"> <view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/noxb.png" class="img"></cover-image> <image src="/res/images/imgs/noxb.png" class="img"></image>
<view class="h3 bold">暂无询报价信息</view> <view class="h3 bold">暂无询报价信息</view>
<view class="p">您还可以发布询价。</view> <view class="p">您还可以发布询价。</view>
<view class="fb_btn btn-com btn-com-b" bindtap="toXj"> <view class="fb_btn btn-com btn-com-b" bindtap="toXj">
......
...@@ -48,12 +48,13 @@ ...@@ -48,12 +48,13 @@
"list": [] "list": []
}, },
"miniprogram": { "miniprogram": {
"current": 11, "current": 7,
"list": [ "list": [
{ {
"id": -1, "id": -1,
"name": "pages/form/xj/index", "name": "pages/form/xj/index",
"pathName": "pages/form/xj/index", "pathName": "pages/form/xj/index",
"query": "",
"scene": null "scene": null
}, },
{ {
...@@ -83,6 +84,27 @@ ...@@ -83,6 +84,27 @@
"pathName": "pages/person/certification/certificationmanage/index", "pathName": "pages/person/certification/certificationmanage/index",
"query": "", "query": "",
"scene": null "scene": null
},
{
"id": 5,
"name": "pages/form/bj/index",
"pathName": "pages/form/bj/index",
"query": "type=2&offerId=156386287503289",
"scene": null
},
{
"id": 6,
"name": "pages/form/good/index",
"pathName": "pages/form/good/index",
"query": "goodId=156454347576866",
"scene": null
},
{
"id": 7,
"name": "pages/detail/chat/index",
"pathName": "pages/detail/chat/index",
"query": "username={\"myName\":\"7a2765fc7caa5e512a6d1270bcf98bf0\",\"your\":\"06b6a13c7ae849be08c98ceeefd6ee7f\",\"name\":\"sy\",\"name1\":\"11\",\"id\":\"53\",\"touserid\":\"54\",\"title\":\"11\",\"img\":\"http://img.icsales.com/test/images/icsales/201907/18/ee8b86dc8cac0e5df402a72d77a1b75e.png\",\"img1\":\"http://img.icsales.com/test/images/icsales/201907/18/767111a5b24e07d950506ea9452ff57c.jpg\"}",
"scene": null
} }
] ]
} }
......
...@@ -97,7 +97,7 @@ textarea { ...@@ -97,7 +97,7 @@ textarea {
right: 24rpx; right: 24rpx;
background-color: #fff; background-color: #fff;
box-shadow: 2px 2px 5px #ddd; box-shadow: 2px 2px 5px #ddd;
z-index: 2; z-index: 3;
border-radius: 2rpx; border-radius: 2rpx;
display: none; display: none;
} }
...@@ -154,10 +154,24 @@ textarea { ...@@ -154,10 +154,24 @@ textarea {
width:100%; width:100%;
} }
.deleteImg{ .deleteImg{
font-size:48rpx !important; font-size:30rpx !important;
color:#EA1717; color:#fff;
position: absolute; position: absolute;
top:0; top:0;
right:0; right:0;
transform: translate(30%,-30%) transform: translate(30%,-30%);
background-color: #EA1717;
height:44rpx;
width:44rpx;
text-align: center;
line-height: 44rpx;
border-radius: 50%;
}
.delete-btn{
margin-bottom:60rpx;
border:2rpx solid #D8DFE6;
background-color: #fff;
color:#686E73;
box-sizing: border-box;
} }
...@@ -110,12 +110,14 @@ WebIM.parseEmoji = function (msg) { ...@@ -110,12 +110,14 @@ WebIM.parseEmoji = function (msg) {
return objList; return objList;
}; };
WebIM.time = function () { WebIM.time = function (str) {
var date = new Date(); var date = new Date();
var Hours = date.getHours(); var Hours = date.getHours();
var Minutes = date.getMinutes(); var Minutes = date.getMinutes();
var Seconds = date.getSeconds(); var Seconds = date.getSeconds();
var time = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " var Month = date.getMonth() + 1;
var Day = date.getDate() ;
var time = date.getFullYear() + "-" + (Month < 10 ? "0" + Month : Month) + "-" + (Day < 10 ? "0" + Day : Day) + " "
+ (Hours < 10 ? "0" + Hours : Hours) + ":" + (Minutes < 10 ? "0" + Minutes : Minutes) + ":" + (Seconds < 10 ? "0" + Seconds : Seconds); + (Hours < 10 ? "0" + Hours : Hours) + ":" + (Minutes < 10 ? "0" + Minutes : Minutes) + ":" + (Seconds < 10 ? "0" + Seconds : Seconds);
return time; return time;
}; };
...@@ -123,41 +125,41 @@ WebIM.time = function () { ...@@ -123,41 +125,41 @@ WebIM.time = function () {
WebIM.Emoji = { WebIM.Emoji = {
path: "../../../../../images/faces/", path: "../../../../../images/faces/",
map: { map: {
"[):]": "ee_1.png", '[):]': 'ee_1.png',
"[:D]": "ee_2.png", '[:D]': 'ee_2.png',
"[;)]": "ee_3.png", '[;)]': 'ee_3.png',
"[:-o]": "ee_4.png", '[:-o]': 'ee_4.png',
"[:p]": "ee_5.png", '[:p]': 'ee_5.png',
"[(H)]": "ee_6.png", '[(H)]': 'ee_6.png',
"[:@]": "ee_7.png", '[:@]': 'ee_7.png',
"[:s]": "ee_8.png", '[:s]': 'ee_8.png',
"[:$]": "ee_9.png", '[:$]': 'ee_9.png',
"[:(]": "ee_10.png", '[:(]': 'ee_10.png',
"[:'(]": "ee_11.png", '[:"(]': 'ee_11.png',
"[<o)]": "ee_12.png", '[:|]': 'ee_12.png',
"[(a)]": "ee_13.png", '[(a)]': 'ee_13.png',
"[8o|]": "ee_14.png", '[8o|]': 'ee_14.png',
"[8-|]": "ee_15.png", '[8-|]': 'ee_15.png',
"[+o(]": "ee_16.png", '[+o(]': 'ee_16.png',
"[|-)]": "ee_17.png", '[o)]': 'ee_17.png',
"[:|]": "ee_18.png", '[|-)]': 'ee_18.png',
"[*-)]": "ee_19.png", '[*-)]': 'ee_19.png',
"[:-#]": "ee_20.png", '[:-#]': 'ee_20.png',
"[^o)]": "ee_21.png", '[:-*]': 'ee_21.png',
"[:-*]": "ee_22.png", '[^o)]': 'ee_22.png',
"[8-)]": "ee_23.png", '[8-)]': 'ee_23.png',
"[(|)]": "ee_24.png", '[(|)]': 'ee_24.png',
"[(u)]": "ee_25.png", '[(u)]': 'ee_25.png',
"[(S)]": "ee_26.png", '[(S)]': 'ee_26.png',
"[(*)]": "ee_27.png", '[(*)]': 'ee_27.png',
"[(#)]": "ee_28.png", '[(#)]': 'ee_28.png',
"[(R)]": "ee_29.png", '[(R)]': 'ee_29.png',
"[({)]": "ee_30.png", '[({)]': 'ee_30.png',
"[(})]": "ee_31.png", '[(})]': 'ee_31.png',
"[(k)]": "ee_32.png", '[(k)]': 'ee_32.png',
"[(F)]": "ee_33.png", '[(F)]': 'ee_33.png',
"[(W)]": "ee_34.png", '[(W)]': 'ee_34.png',
"[(D)]": "ee_35.png" '[(D)]': 'ee_35.png'
} }
}; };
...@@ -165,49 +167,49 @@ WebIM.EmojiObj = { ...@@ -165,49 +167,49 @@ WebIM.EmojiObj = {
// 相对 emoji.js 路径 // 相对 emoji.js 路径
path: "../../../../../images/faces/", path: "../../../../../images/faces/",
map1: { map1: {
"[):]": "ee_1.png", '[):]': 'ee_1.png',
"[:D]": "ee_2.png", '[:D]': 'ee_2.png',
"[;)]": "ee_3.png", '[;)]': 'ee_3.png',
"[:-o]": "ee_4.png", '[:-o]': 'ee_4.png',
"[:p]": "ee_5.png", '[:p]': 'ee_5.png',
"[(H)]": "ee_6.png", '[(H)]': 'ee_6.png',
"[:@]": "ee_7.png" '[:@]': 'ee_7.png'
}, },
map2: { map2: {
"[:s]": "ee_8.png", '[:s]': 'ee_8.png',
"[:$]": "ee_9.png", '[:$]': 'ee_9.png',
"[:(]": "ee_10.png", '[:(]': 'ee_10.png',
"[:'(]": "ee_11.png", '[:"(]': 'ee_11.png',
"[<o)]": "ee_12.png", '[:|]': 'ee_12.png',
"[(a)]": "ee_13.png", '[(a)]': 'ee_13.png',
"[8o|]": "ee_14.png" '[8o|]': 'ee_14.png'
}, },
map3: { map3: {
"[8-|]": "ee_15.png", '[8-|]': 'ee_15.png',
"[+o(]": "ee_16.png", '[+o(]': 'ee_16.png',
"[|-)]": "ee_17.png", '[o)]': 'ee_17.png',
"[:|]": "ee_18.png", '[|-)]': 'ee_18.png',
"[*-)]": "ee_19.png", '[*-)]': 'ee_19.png',
"[:-#]": "ee_20.png", '[:-#]': 'ee_20.png',
"[^o)]": "ee_21.png", '[:-*]': 'ee_21.png'
}, },
map4: { map4: {
"[:-*]": "ee_22.png", '[^o)]': 'ee_22.png',
"[8-)]": "ee_23.png", '[8-)]': 'ee_23.png',
"[(|)]": "ee_24.png", '[(|)]': 'ee_24.png',
"[(u)]": "ee_25.png", '[(u)]': 'ee_25.png',
"[(S)]": "ee_26.png", '[(S)]': 'ee_26.png',
"[(*)]": "ee_27.png", '[(*)]': 'ee_27.png',
"[(#)]": "ee_28.png" '[(#)]': 'ee_28.png'
}, },
map5: { map5: {
"[(R)]": "ee_29.png", '[(R)]': 'ee_29.png',
"[({)]": "ee_30.png", '[({)]': 'ee_30.png',
"[(})]": "ee_31.png", '[(})]': 'ee_31.png',
"[(k)]": "ee_32.png", '[(k)]': 'ee_32.png',
"[(F)]": "ee_33.png", '[(F)]': 'ee_33.png',
"[(W)]": "ee_34.png", '[(W)]': 'ee_34.png',
"[(D)]": "ee_35.png" '[(D)]': 'ee_35.png'
} }
}; };
......
...@@ -183,7 +183,15 @@ const apis = { ...@@ -183,7 +183,15 @@ const apis = {
/** /**
* 标记会员通知(已读) * 标记会员通知(已读)
*/ */
userMarkmsg: user_url + '/user/markmsg' userMarkmsg: user_url + '/user/markmsg',
/**
* 环信通讯记录添加
*/
addrecord: user_url + '/im/add/record',
/**
* 环信通讯记录列表(最多显示30条最新的聊天记录)
*/
listrecord: user_url + '/im/list/record',
} }
......
import { getData } from '../utils/util.js';
import { apis } from '../utils/api.js';
const WebIM = require("./WebIM")["default"];
let msgStorage = require("../components/chat/msgstorage");
let msgType = require("../components/chat/msgtype");
let disp = require("./broadcast");
let conn = {
closed: false,
curOpenOpt: {},
open(opt) {
/* wx.showLoading({
title: '正在初始化客户端...',
mask: true
}) */
this.curOpenOpt = opt;
WebIM.conn.open(opt);
this.closed = false;
},
reopen() {
if (this.closed) {
WebIM.conn.open(this.curOpenOpt);
this.closed = false;
}
}
};
const calcUnReadSpot = (message) => {
let myName = wx.getStorageSync("myUsername");
let allMembers = wx.getStorageSync("member") || []; //好友
let count = allMembers.reduce(function (result, curMember, idx) {
let chatMsgs = wx.getStorageSync(curMember.toLowerCase() + myName.toLowerCase()) || [];
return result + chatMsgs.length;
}, 0);
getApp().globalData.unReadMessageNum = count;
disp.fire("em.xmpp.unreadspot", message);
}
const onMessageError = (err) => {
if (err.type === "error") {
wx.showToast({
title: err.errorText
});
return false;
}
return true;
}
const getImUser = () => {
let me = this;
let token = wx.getStorageSync('access_token') || ''
getData(apis.authme, 'get', {
"token": token,
}, function (res) {
if (res.err_code == 0) {
wx.setStorageSync('user_id', res.data.user_id+'');
wx.setStorageSync('avatar', res.data.avatar);
wx.setStorageSync('company_name', res.data.company_name);
wx.setStorageSync("myUsername", res.data.im_username);
conn.open({
apiUrl: WebIM.config.apiURL,
user: res.data.im_username,
pwd: res.data.im_password,
appKey: WebIM.config.appkey
})
} else {
console.log('获取环信账号失败')
}
}, false)
};
const webimListen = () => {
WebIM.conn.listen({
onOpened(message) {
},
onReconnect() {
wx.showToast({
title: "重连中...",
duration: 2000
});
},
onSocketConnected() {
/* wx.showToast({
title: "socket连接成功",
duration: 2000
}); */
},
onClosed() {
wx.showToast({
title: "网络已断开",
icon: 'none',
duration: 2000
});
me.conn.closed = true;
WebIM.conn.close();
},
onCmdMessage(message) {
getApp().addChatMember(message.from)
if (message) {
if (onMessageError(message)) {
msgStorage.saveReceiveMsg(message, msgType.CMD);
}
calcUnReadSpot(message);
}
},
onTextMessage(message) {
if (message) {
if (onMessageError(message)) {
msgStorage.saveReceiveMsg(message, msgType.TEXT);
// console.log(111)
}
calcUnReadSpot(message);
}
},
onEmojiMessage(message) {
console.log("onEmojiMessage", message);
if (message) {
if (onMessageError(message)) {
msgStorage.saveReceiveMsg(message, msgType.EMOJI);
}
calcUnReadSpot(message);
}
},
onPictureMessage(message) {
console.log("onPictureMessage", message);
if (message) {
if (onMessageError(message)) {
msgStorage.saveReceiveMsg(message, msgType.IMAGE);
}
calcUnReadSpot(message);
}
},
// 各种异常
onError(error) {
console.log(error)
},
});
};
module.exports = {
// calcUnReadSpot: calcUnReadSpot,
// onMessageError: onMessageError,
webimListen: webimListen,
conn: conn,
getImUser: getImUser
}
\ No newline at end of file
...@@ -74,17 +74,17 @@ const getData = (url, type, param, callBack, loading, isheader) => { ...@@ -74,17 +74,17 @@ const getData = (url, type, param, callBack, loading, isheader) => {
}; };
//上传文件 //上传文件
const uploadFile = (url,paths,callBack) => { const uploadFile = (url, paths, callBack) => {
wx.showLoading({ wx.showLoading({
title: '上传中', title: '上传中',
mask:true mask: true
}) })
for (var i = 0; i < paths.length; i++) { for (var i = 0; i < paths.length; i++) {
wx.uploadFile({ wx.uploadFile({
url: url, url: url,
filePath: paths[i], filePath: paths[i],
name: 'upload', name: 'upload',
formData: { token: wx.getStorageSync('access_token'), source: 2}, formData: { token: wx.getStorageSync('access_token'), source: 2 },
header: { header: {
"Content-Type": "multipart/form-data" "Content-Type": "multipart/form-data"
}, },
...@@ -120,19 +120,39 @@ const uploadFile = (url,paths,callBack) => { ...@@ -120,19 +120,39 @@ const uploadFile = (url,paths,callBack) => {
} }
}; };
const chooseImg = (url,num, callback) => { const chooseImg = (url, num, callback) => {
wx.chooseImage({ wx.chooseImage({
count: num, count: num,
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
success: (res) => { success: (res) => {
uploadFile(url,res.tempFilePaths, (rtn) => { uploadFile(url, res.tempFilePaths, (rtn) => {
callback(rtn) callback(rtn)
}) })
} }
}) })
}; };
const tips = (text) => {
wx.showToast({
title: text,
icon: 'none',
duration: 2000
});
}
const changeTime = (str) => {
var date = new Date(str);
var Hours = date.getHours();
var Minutes = date.getMinutes();
var Seconds = date.getSeconds();
var Month = date.getMonth() + 1;
var Day = date.getDate();
var time = date.getFullYear() + "-" + (Month < 10 ? "0" + Month : Month) + "-" + (Day < 10 ? "0" + Day : Day) + " "
+ (Hours < 10 ? "0" + Hours : Hours) + ":" + (Minutes < 10 ? "0" + Minutes : Minutes) + ":" + (Seconds < 10 ? "0" + Seconds : Seconds);
return time;
};
module.exports = { module.exports = {
getData: getData, getData: getData,
chooseImg: chooseImg chooseImg: chooseImg,
tips: tips,
changeTime: changeTime
} }
\ No newline at end of file
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