kira 6 years ago
parent 4c97b2cc8a
commit 6d2662ded7

@ -29,7 +29,7 @@ public class EncourageMoneyController {
private EncourageService encourageService;
@RequestMapping(value = "/orders/{orderId}", method = RequestMethod.PUT)
@RequestMapping(value = "/orders/{orderId}", method = RequestMethod.GET)
public JSONObject takeEncourageMoney(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser,
@ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) {
String user_id = "";

@ -6,15 +6,12 @@ import com.alibaba.fastjson.JSONObject;
import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.domain.OpenImUser;
import com.taobao.api.domain.Userinfos;
import com.taobao.api.request.OpenimCustmsgPushRequest;
import com.taobao.api.request.OpenimRelationsGetRequest;
import com.taobao.api.request.OpenimUsersAddRequest;
import com.taobao.api.request.OpenimUsersGetRequest;
import com.taobao.api.request.OpenimUsersUpdateRequest;
import com.taobao.api.response.OpenimCustmsgPushResponse;
import com.taobao.api.response.OpenimRelationsGetResponse;
import com.taobao.api.response.OpenimUsersAddResponse;
import com.taobao.api.response.OpenimUsersGetResponse;
import com.taobao.api.response.OpenimUsersUpdateResponse;
@ -23,6 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@ -112,14 +110,15 @@ public class OpenimClient {
String secret = "7639427973bd671be15c9d0c1e9c90b4";
String url = "https://eco.taobao.com/router/rest";
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimRelationsGetRequest req = new OpenimRelationsGetRequest();
req.setBegDate("20180701");
req.setEndDate("20180711");
OpenImUser obj1 = new OpenImUser();
obj1.setUid("imuser123");
obj1.setTaobaoAccount(false);
req.setUser(obj1);
OpenimRelationsGetResponse rsp = null;
OpenimUsersAddRequest req = new OpenimUsersAddRequest();
List<Userinfos> list2 = new ArrayList<Userinfos>();
Userinfos obj3 = new Userinfos();
list2.add(obj3);
obj3.setNick("im123");
obj3.setUserid("im123");
obj3.setPassword("xxxxxx");
req.setUserinfos(list2);
OpenimUsersAddResponse rsp = null;
try {
rsp = client.execute(req);
} catch (ApiException e) {

@ -6,8 +6,8 @@
<script src="https://g.alicdn.com/aliww/??h5.openim.sdk/1.0.6/scripts/wsdk.js,h5.openim.kit/0.3.3/scripts/kit.js"
charset="utf-8"></script>
<script>
window.uid = 'taki';
window.touid = 'mitsuha';
window.uid = 'imuser123';
window.touid = 'imuser1234';
window.onload = function () {
WKIT.init({
container: document.getElementById('J_demo'),
@ -20,10 +20,20 @@
logo: 'http://img.alicdn.com/tps/i3/TB12LD9IFXXXXb3XpXXSyFWJXXX-82-82.png',
pluginUrl: 'http://192.168.0.43:9001/service_contact_list.html?uid='
+ window.uid,
onMsgReceived: function (data) {
document.getElementById("J_wkitPluginFrame").contentWindow.updateContractList(data);
onLoginSuccess: function (data) {
WKIT.Conn.sdk.Event.on('MSG_RECEIVED', function (data) {
document.getElementById("J_wkitPluginFrame").contentWindow
.updateContractList(data.data);
});
WKIT.Conn.sdk.Base.startListenAllMsg();
}
});
}
function switchTouid(touid) {
WKIT.switchTouid({
touid: touid,
});
}
</script>
</html>

@ -9,24 +9,27 @@
<script>
var unreadMap = {};
var sdk = new WSDK();
var sdk = new WSDK();
var queryParam = getQueryString();
function login() {
sdk.Base.login({
uid: queryParam['uid'],
appkey: '24960261',
credential: 'xxxxxx',
timeout: 4000,
success: function (data) {
initUnreadMsgAndContact();
console.log('login success', data);
},
error: function (error) {
console.log('get login msg count fail', error);
}
});
uid: queryParam['uid'],
appkey: '24960261',
credential: 'xxxxxx',
timeout: 4000,
success: function (data) {
initUnreadMsgAndContact();
sdk.Event.on('MSG_RECEIVED', function (data) {
console.log(data);
});
sdk.Base.startListenAllMsg();
},
error: function (error) {
login();
}
});
}
function loadContactList() {
@ -37,58 +40,55 @@
$("#contact").html(str);
var contact_list = '';
for (var key in unreadMap) {
contact_list += "<li>" + key + ":" + unreadMap[key] + "</li>";
contact_list +=
"<li onclick=switchToUser('" + key + "')>" + key + ":" + unreadMap[key] + "</li>";
}
$("#contact_list").html(contact_list);
}
function initUnreadMsgAndContact() {
sdk.Base.getRecentContact({
count: 40,
success: function (data) {
console.log('get contact msg count success', data);
var cnts = data.data.cnts;
for (var i = cnts.length - 1; i >= 0; i--) {
unreadMap[sdk.Base.getNick(cnts[i].to)] = 0;
}
getUnreadMsgCount();
},
error: function (error) {
console.log('get contact msg count fail', error);
}
count: 40,
success: function (data) {
var cnts = data.data.cnts;
for (var i = cnts.length - 1; i >= 0; i--) {
unreadMap[sdk.Base.getNick(cnts[i].to)] = 0;
}
getUnreadMsgCount();
},
error: function (error) {
console.log('get contact msg count fail', error);
}
})
}
function getUnreadMsgCount() {
sdk.Base.getUnreadMsgCount({
count: 40,
success: function (data) {
console.log('get unread msg count success', data);
var unreads = data.data;
for (var i = unreads.length - 1; i >= 0; i--) {
unreadMap[sdk.Base.getNick(unreads[i].contact)] =
unreads[i].msgCount;
}
loadContactList();
},
error: function (error) {
console.log('get recent contact fail', error);
}
});
count: 40,
success: function (data) {
var unreads = data.data;
for (var i = unreads.length - 1; i >= 0; i--) {
unreadMap[sdk.Base.getNick(unreads[i].contact)] =
unreads[i].msgCount;
}
loadContactList();
},
error: function (error) {
console.log('get recent contact fail', error);
}
});
}
function setReadState(touid) {
sdk.Chat.setReadState({
touid: touid,
timestamp: Math.floor((+new Date()) / 1000),
success: function (data) {
console.log('set read state success', data);
},
error: function (error) {
console.log('set read state fail', error);
}
});
touid: touid,
timestamp: Math.floor((+new Date()) / 1000),
success: function (data) {
},
error: function (error) {
console.log('set read state fail', error);
}
});
}
function startListenMsg(touid) {
@ -116,16 +116,33 @@
}
return args;
}
function updateContractList(data) {
var msg =data.msgs[0];
var msg = data.msgs[0];
var msg_uid = sdk.Base.getNick(msg.from);
if(unreadMap[msg_uid]){
unreadMap[msg_uid] = unreadMap[msg_uid]+1;
}else {
if (unreadMap[msg_uid]) {
unreadMap[msg_uid] = unreadMap[msg_uid] + 1;
} else {
unreadMap[msg_uid] = 1;
}
loadContactList();
}
function switchToUser(touid) {
parent.switchTouid(touid);
sdk.Chat.setReadState({
touid: touid,
timestamp: Math.floor((+new Date()) / 1000),
success: function(data){
console.log('set read state success', data);
},
error: function(error){
console.log('set read state fail', error);
}
});
unreadMap[touid]=0;
loadContactList();
}
</script>
<script>
window.onload = function () {

@ -14,7 +14,7 @@
uid: 'mitsuha',
appkey: 24960261,
credential: 'xxxxxx',
touid: 'taki',
touid: 'imuser123',
logo: 'http://img.alicdn.com/tps/i3/TB12LD9IFXXXXb3XpXXSyFWJXXX-82-82.png',
});
}

Loading…
Cancel
Save