Authored by yyq

message ajax

@@ -248,7 +248,7 @@ const readMessage = (uid, mid) => { @@ -248,7 +248,7 @@ const readMessage = (uid, mid) => {
248 248
249 const pickBirthCoupon = (uid, id) => { 249 const pickBirthCoupon = (uid, id) => {
250 return getBirthCouponAsync(uid, id); 250 return getBirthCouponAsync(uid, id);
251 -} 251 +};
252 252
253 module.exports = { 253 module.exports = {
254 getMessageList, 254 getMessageList,
@@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
5 */ 5 */
6 var $ = require('yoho-jquery'); 6 var $ = require('yoho-jquery');
7 7
  8 +var Dialog = require('../common/dialog');
  9 +
8 var $container = $('#message-main-container'), 10 var $container = $('#message-main-container'),
9 $msgCheck = $container.find('.msg-check'), 11 $msgCheck = $container.find('.msg-check'),
10 $readBtn = $container.find('.read-choose-btn'), 12 $readBtn = $container.find('.read-choose-btn'),
@@ -16,6 +18,9 @@ var operationId = []; @@ -16,6 +18,9 @@ var operationId = [];
16 18
17 var pickBusy = false; 19 var pickBusy = false;
18 20
  21 +var Alert = Dialog.Alert,
  22 + Confirm = Dialog.confirm;
  23 +
19 require('./message-content'); 24 require('./message-content');
20 25
21 function hasNew() { 26 function hasNew() {
@@ -50,6 +55,8 @@ function msgOperation(type, data) { @@ -50,6 +55,8 @@ function msgOperation(type, data) {
50 case 'read': 55 case 'read':
51 url = '/home/message/read'; 56 url = '/home/message/read';
52 break; 57 break;
  58 + default:
  59 + break;
53 } 60 }
54 61
55 if (!url) { 62 if (!url) {
@@ -67,10 +74,10 @@ function msgOperation(type, data) { @@ -67,10 +74,10 @@ function msgOperation(type, data) {
67 $checked.parent().parent().removeClass('new-msg'); 74 $checked.parent().parent().removeClass('new-msg');
68 hasNew(); 75 hasNew();
69 } else { 76 } else {
70 - window.location.reload() 77 + window.location.reload();
71 } 78 }
72 } else { 79 } else {
73 - alert(jsonData.message); 80 + new Alert(jsonData.message);
74 } 81 }
75 }); 82 });
76 } 83 }
@@ -89,22 +96,30 @@ $container.on('change', 'input[type="checkbox"]', function() { @@ -89,22 +96,30 @@ $container.on('change', 'input[type="checkbox"]', function() {
89 }); 96 });
90 97
91 $container.on('click', '.del-btn', function() { 98 $container.on('click', '.del-btn', function() {
92 - if (confirm('您确定要删除这条短消息?')) {  
93 - msgOperation('del', $(this).data());  
94 - } 99 + var data = $(this).data();
  100 +
  101 + new Confirm({
  102 + content: '您确定要删除这条短消息?',
  103 + cb: function() {
  104 + msgOperation('del', data);
  105 + }
  106 + }).show();
95 }); 107 });
96 108
97 $container.on('click', '.del-choose-btn', function() { 109 $container.on('click', '.del-choose-btn', function() {
98 if (!operationId.length) { 110 if (!operationId.length) {
99 - alert('请选中您要删除的消息'); 111 + new Alert('请选中您要删除的消息');
100 return; 112 return;
101 } 113 }
102 114
103 - if (confirm('确定要删除您选中的消息')) {  
104 - msgOperation('del', {  
105 - id: operationId.join(',')  
106 - });  
107 - } 115 + new Confirm({
  116 + content: '确定要删除您选中的消息?',
  117 + cb: function() {
  118 + msgOperation('del', {
  119 + id: operationId.join(',')
  120 + });
  121 + }
  122 + }).show();
108 }); 123 });
109 124
110 $container.on('click', '.read-choose-btn', function() { 125 $container.on('click', '.read-choose-btn', function() {
@@ -136,6 +151,6 @@ $pickBtn.click(function() { @@ -136,6 +151,6 @@ $pickBtn.click(function() {
136 151
137 pickBusy = false; 152 pickBusy = false;
138 153
139 - alert(msg); 154 + new Alert(msg);
140 }); 155 });
141 -});  
  156 +});