kira 6 years ago
parent 4c97b2cc8a
commit 6d2662ded7

@ -29,7 +29,7 @@ public class EncourageMoneyController {
private EncourageService encourageService; 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, public JSONObject takeEncourageMoney(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser,
@ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) { @ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) {
String user_id = ""; String user_id = "";

@ -6,15 +6,12 @@ import com.alibaba.fastjson.JSONObject;
import com.taobao.api.ApiException; import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient; import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient; import com.taobao.api.TaobaoClient;
import com.taobao.api.domain.OpenImUser;
import com.taobao.api.domain.Userinfos; import com.taobao.api.domain.Userinfos;
import com.taobao.api.request.OpenimCustmsgPushRequest; import com.taobao.api.request.OpenimCustmsgPushRequest;
import com.taobao.api.request.OpenimRelationsGetRequest;
import com.taobao.api.request.OpenimUsersAddRequest; import com.taobao.api.request.OpenimUsersAddRequest;
import com.taobao.api.request.OpenimUsersGetRequest; import com.taobao.api.request.OpenimUsersGetRequest;
import com.taobao.api.request.OpenimUsersUpdateRequest; import com.taobao.api.request.OpenimUsersUpdateRequest;
import com.taobao.api.response.OpenimCustmsgPushResponse; import com.taobao.api.response.OpenimCustmsgPushResponse;
import com.taobao.api.response.OpenimRelationsGetResponse;
import com.taobao.api.response.OpenimUsersAddResponse; import com.taobao.api.response.OpenimUsersAddResponse;
import com.taobao.api.response.OpenimUsersGetResponse; import com.taobao.api.response.OpenimUsersGetResponse;
import com.taobao.api.response.OpenimUsersUpdateResponse; import com.taobao.api.response.OpenimUsersUpdateResponse;
@ -23,6 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -112,14 +110,15 @@ public class OpenimClient {
String secret = "7639427973bd671be15c9d0c1e9c90b4"; String secret = "7639427973bd671be15c9d0c1e9c90b4";
String url = "https://eco.taobao.com/router/rest"; String url = "https://eco.taobao.com/router/rest";
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret); TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimRelationsGetRequest req = new OpenimRelationsGetRequest(); OpenimUsersAddRequest req = new OpenimUsersAddRequest();
req.setBegDate("20180701"); List<Userinfos> list2 = new ArrayList<Userinfos>();
req.setEndDate("20180711"); Userinfos obj3 = new Userinfos();
OpenImUser obj1 = new OpenImUser(); list2.add(obj3);
obj1.setUid("imuser123"); obj3.setNick("im123");
obj1.setTaobaoAccount(false); obj3.setUserid("im123");
req.setUser(obj1); obj3.setPassword("xxxxxx");
OpenimRelationsGetResponse rsp = null; req.setUserinfos(list2);
OpenimUsersAddResponse rsp = null;
try { try {
rsp = client.execute(req); rsp = client.execute(req);
} catch (ApiException e) { } 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" <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> charset="utf-8"></script>
<script> <script>
window.uid = 'taki'; window.uid = 'imuser123';
window.touid = 'mitsuha'; window.touid = 'imuser1234';
window.onload = function () { window.onload = function () {
WKIT.init({ WKIT.init({
container: document.getElementById('J_demo'), container: document.getElementById('J_demo'),
@ -20,9 +20,19 @@
logo: 'http://img.alicdn.com/tps/i3/TB12LD9IFXXXXb3XpXXSyFWJXXX-82-82.png', logo: 'http://img.alicdn.com/tps/i3/TB12LD9IFXXXXb3XpXXSyFWJXXX-82-82.png',
pluginUrl: 'http://192.168.0.43:9001/service_contact_list.html?uid=' pluginUrl: 'http://192.168.0.43:9001/service_contact_list.html?uid='
+ window.uid, + window.uid,
onMsgReceived: function (data) { onLoginSuccess: function (data) {
document.getElementById("J_wkitPluginFrame").contentWindow.updateContractList(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> </script>

@ -21,10 +21,13 @@
timeout: 4000, timeout: 4000,
success: function (data) { success: function (data) {
initUnreadMsgAndContact(); initUnreadMsgAndContact();
console.log('login success', data); sdk.Event.on('MSG_RECEIVED', function (data) {
console.log(data);
});
sdk.Base.startListenAllMsg();
}, },
error: function (error) { error: function (error) {
console.log('get login msg count fail', error); login();
} }
}); });
} }
@ -37,7 +40,8 @@
$("#contact").html(str); $("#contact").html(str);
var contact_list = ''; var contact_list = '';
for (var key in unreadMap) { 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); $("#contact_list").html(contact_list);
} }
@ -46,8 +50,6 @@
sdk.Base.getRecentContact({ sdk.Base.getRecentContact({
count: 40, count: 40,
success: function (data) { success: function (data) {
console.log('get contact msg count success', data);
var cnts = data.data.cnts; var cnts = data.data.cnts;
for (var i = cnts.length - 1; i >= 0; i--) { for (var i = cnts.length - 1; i >= 0; i--) {
unreadMap[sdk.Base.getNick(cnts[i].to)] = 0; unreadMap[sdk.Base.getNick(cnts[i].to)] = 0;
@ -64,7 +66,6 @@
sdk.Base.getUnreadMsgCount({ sdk.Base.getUnreadMsgCount({
count: 40, count: 40,
success: function (data) { success: function (data) {
console.log('get unread msg count success', data);
var unreads = data.data; var unreads = data.data;
for (var i = unreads.length - 1; i >= 0; i--) { for (var i = unreads.length - 1; i >= 0; i--) {
unreadMap[sdk.Base.getNick(unreads[i].contact)] = unreadMap[sdk.Base.getNick(unreads[i].contact)] =
@ -83,7 +84,6 @@
touid: touid, touid: touid,
timestamp: Math.floor((+new Date()) / 1000), timestamp: Math.floor((+new Date()) / 1000),
success: function (data) { success: function (data) {
console.log('set read state success', data);
}, },
error: function (error) { error: function (error) {
console.log('set read state fail', error); console.log('set read state fail', error);
@ -116,6 +116,7 @@
} }
return args; return args;
} }
function updateContractList(data) { function updateContractList(data) {
var msg = data.msgs[0]; var msg = data.msgs[0];
var msg_uid = sdk.Base.getNick(msg.from); var msg_uid = sdk.Base.getNick(msg.from);
@ -126,6 +127,22 @@
} }
loadContactList(); 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>
<script> <script>
window.onload = function () { window.onload = function () {

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

Loading…
Cancel
Save