function.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. //查询报价单
  2. function getQuotation(page, limit, startTime, endTime){
  3. layer.load(3);
  4. var url = "";
  5. if(idVal == "0"){ //未审核
  6. url = "/wxRefund/getUserRefund";
  7. } else { //已审核
  8. url = "/wxRefund/getAuditRefund";
  9. }
  10. $.ajax({
  11. url: url,
  12. type: "get",
  13. data: {
  14. "page": page,
  15. "limit": limit,
  16. "startTime": startTime,
  17. "endTime": endTime,
  18. "refundState": idVal
  19. },
  20. headers: {"token": localStorage.getItem("token")},
  21. dataType: "json",
  22. success: (data) => {
  23. if(data.msg == "200"){
  24. $(".content_div div").remove();
  25. $.each(data.data, (index, item) => {
  26. //状态显示
  27. var buttonElem = "";
  28. if(item.refundState == "0"){ //未审核
  29. buttonElem = "<button class=\"ignore_button button_div_head\" onclick='ignoreClick(this)'><img src=\"/images/demandForSingle/ban.png\"/><span data-locale=\"jujue\">"+ paramReturn("拒绝", parent.type) +"</span></button>\n" +
  30. "<button class=\"offer_button button_div_head\" onclick='offerClick(this)'><img src=\"/images/refund/tongyi.png\"/><span data-locale=\"tongyituikuan\">"+ paramReturn("同意退款", parent.type) +"</span></button>\n";
  31. } else if(item.refundState == "1"){ //已同意
  32. buttonElem = "<button class=\"offer_button button_div_head audit_refund\"><img src=\"/images/refund/yitongyi.png\"/><span data-locale=\"yitongyi\">"+ paramReturn("已同意", parent.type) +"</span></button>\n";
  33. } else if(item.refundState == "2"){ //拒绝
  34. buttonElem = "<button class=\"ignore_button button_div_head audit_refund\"><img src=\"/images/refund/refused.png\"/><span data-locale=\"yijujue\">"+ paramReturn("已拒绝", parent.type) +"</span></button>\n" +
  35. "<button class=\"offer_button button_div_head\" onclick='offerClick(this)'><img src=\"/images/refund/tongyi.png\"/><span data-locale=\"tongyituikuan\">"+ paramReturn("同意退款", parent.type) +"</span></button>\n";
  36. }
  37. $(".content_div").append("<div offerCode="+ item.offerCode +" uuid="+ AES_ECB_encrypt(AES_ECB_encrypt(item.releaseUuid, null), null) +" class=\"content_column\">\n" +
  38. "<div class=\"content_div_input\">\n" +
  39. "<div class=\"head_name\" style=\"width: 5%;\">"+ (index + 1) +"</div>\n" +
  40. "<div class=\"head_name\" style=\"width: 20%;\">"+ item.offerName +"</div>\n" +
  41. "<div class=\"head_name\" style=\"width: 15%;\">"+ item.uuid +"</div>\n" +
  42. "<div class=\"head_name\" style=\"width: 10%;\">"+ item.jdrq.split(" ")[0] +"</div>\n" +
  43. "<div class=\"head_name\" style=\"width: 10%;\">"+ (item.refundType == "1" ? ""+ paramReturn("部分退款", parent.type) +"" : ""+ paramReturn("全部退款", parent.type) +"") +"</div>\n" +
  44. "<div class=\"head_name\" style=\"width: 10%;\">"+ item.refundReason.split(",")[0] +"</div>\n" +
  45. "<div class=\"head_name\" style=\"width: 10%;\">"+ item.refundFee +"</div>\n" +
  46. "<div class=\"head_name\" style=\"width: 20%;\">\n" +
  47. buttonElem +
  48. "</div>\n" +
  49. "</div>\n" +
  50. "</div>")
  51. });
  52. //自定义样式分页
  53. laypage.render({
  54. elem: 'demo2'
  55. ,count: data.count
  56. ,theme: '#1E9FFF'
  57. , limit: limit
  58. , curr: page
  59. , jump: function (obj,first) {
  60. if (!first) {
  61. getQuotation(obj.curr,obj.limit, startTime, endTime);
  62. }
  63. }
  64. , prev: '<em><i class="layui-icon">&#xe603;</i></em>'
  65. , next: '<em><i class="layui-icon">&#xe602;</i></em>'
  66. });
  67. }
  68. layer.closeAll("loading");
  69. },
  70. error: () => {
  71. layer.alert(paramReturn("服务器异常,请联系管理员", parent.type), {icon: 2});
  72. layer.closeAll("loading");
  73. }
  74. });
  75. }
  76. //同意退款
  77. function offerClick(obj){
  78. layer.confirm("确认此操作吗?",{
  79. btn: ['确定', '取消'],
  80. title: false,
  81. skin: 'layclass'
  82. }, function () {
  83. layer.load(3);
  84. var uuid = $(obj).parent().parent().parent().attr("uuid");
  85. var offerCode = $(obj).parent().parent().parent().attr("offerCode")
  86. console.log(offerCode)
  87. sendPrivateText(offerCode);
  88. return false;
  89. $.ajax({
  90. url: "/wxRefund/refusedRefund",
  91. type: "put",
  92. data: {
  93. "refundState": "1",
  94. "releaseUuid": AES_ECB_decrypt(AES_ECB_decrypt(uuid, null), null)
  95. },
  96. headers: {"token": localStorage.getItem("token")},
  97. dataType: "json",
  98. success: (data) => {
  99. if(data.msg == "200"){
  100. layer.msg(data.data, {icon: 1});
  101. sendPrivateText(offerCode);
  102. } else {
  103. layer.msg(data.data, {icon: 2});
  104. }
  105. getQuotation(1, 7, startTime, endTime);//查询报价单数据渲染
  106. layer.closeAll("loading");
  107. },
  108. error: () => {
  109. layer.alert(paramReturn("服务器异常,请联系管理员", parent.type), {icon: 2});
  110. layer.closeAll("loading");
  111. }
  112. });
  113. },function (){
  114. layer.closeAll()
  115. })
  116. }
  117. //拒绝
  118. function ignoreClick(obj){
  119. layer.confirm("确认此操作吗?",{
  120. btn: ['确定', '取消'],
  121. title: false,
  122. skin: 'layclass'
  123. }, function () {
  124. layer.load(3);
  125. var uuid = $(obj).parent().parent().parent().attr("uuid");
  126. var offerCode = $(obj).parent().parent().parent().attr("offerCode")
  127. $.ajax({
  128. url: "/wxRefund/refusedRefund",
  129. type: "put",
  130. data: {
  131. "refundState": "2",
  132. "releaseUuid": AES_ECB_decrypt(AES_ECB_decrypt(uuid, null), null)
  133. },
  134. headers: {"token": localStorage.getItem("token")},
  135. dataType: "json",
  136. success: (data) => {
  137. layer.closeAll("loading");
  138. if(data.msg == "200"){
  139. layer.msg(data.data, {icon: 1});
  140. getQuotation(1, 7, startTime, endTime);//查询报价单数据渲染
  141. sendPrivateText(offerCode);
  142. }
  143. },
  144. error: () => {
  145. layer.alert(paramReturn("服务器异常,请联系管理员", parent.type), {icon: 2});
  146. layer.closeAll("loading");
  147. }
  148. });
  149. },function (){
  150. layer.closeAll()
  151. })
  152. }
  153. //注册并登录环信账号
  154. function registerUser(){
  155. var options = {
  156. username: parent.username.toLowerCase(),
  157. password: '123456',
  158. nickname: parent.nickname,
  159. appKey: WebIM.config.appkey,
  160. success: function () { },
  161. error: function (err) {
  162. let errorData = JSON.parse(err.data);
  163. },
  164. };
  165. conn.registerUser(options);
  166. var options1 = {
  167. user: parent.username.toLowerCase(),
  168. pwd: '123456',
  169. appKey: WebIM.config.appkey
  170. };
  171. conn.open(options1);
  172. //
  173. setTimeout(function (){
  174. let options = {
  175. nickname: parent.nickname,
  176. avatarurl: parent.headImg,
  177. }
  178. //修改用户信息
  179. conn.updateOwnUserInfo(options);
  180. //查询列表
  181. conn.getSessionList().then((res) => {
  182. })
  183. },2000);
  184. }
  185. // 单聊发送文本消息
  186. function sendPrivateText(offerCode) {
  187. if(typeof offerCode == "null"){
  188. console.log("发送消息失败")
  189. return false;
  190. }
  191. let id = conn.getUniqueId(); // 生成本地消息id
  192. let msg = new WebIM.message('txt', id); // 创建文本消息
  193. msg.set({
  194. msg: '我已对您的退款申请进行了操作,请注意查看', // 消息内容
  195. to: offerCode, // 接收消息对象(用户id)
  196. chatType: 'singleChat', // 设置为单聊
  197. success: function (id, serverMsgId) {
  198. },
  199. fail: function(e){
  200. console.log("失败");
  201. }
  202. });
  203. conn.send(msg.body);
  204. $(".chat__room-info-input textarea").val("");
  205. }