123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- var loading = dialog({contentType:'load', skin:'bk-popup'}).show();
- var handing = dialog({contentType:'load', skin:'bk-popup', content: '正在处理中...'});
- var Request = GetRequest(),
- member = Request.member;
- var $listWrap = $('#listWrap');
- isRepresent(function(){
- initPage()
- })
- function getFamilyMesListPromise(code) {
- return new Promise(function(resolve, reject) {
- sendPost("patient/family/getFamilyMesList", {
- code: code
- } , "json", "POST",
- function failed (res) {
- loading.close();
-
- }, function(res) {
- resolve(res)
- });
- })
- }
- function addMemberByWxTempPromise(id,state) {
- handing.show();
- return new Promise(function(resolve, reject) {
- sendPost("patient/family/addMenberByWXTemp", {
- id: id,
- state: state
- } , "json", "POST",
- function failed (res) {
- handing.close();
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
- }, function(res) {
- handing.close();
- if(res.status == "200") {
- resolve(res)
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
- }
- });
- })
- }
- function changeState(el,state) {
- var $el = $(el),
- $btns = $el.closest('.btn-menu'),
- $li = $el.closest('.c-list'),
- $agree = $li.find('.state-agree'),
- $reject = $li.find('.state-reject');
-
- $btns.hide();
- if(state == "1") {
- $agree.removeClass('c-hide');
- } else if((state == "2")){
- $reject.removeClass('c-hide');
- }
- }
- function bindEvents() {
- $listWrap.on('click','.btn-reject',function(){
- var self = this;
- var id = $(this).closest('.c-list').attr('data-id');
- addMemberByWxTempPromise(id,2)
- .then(function() {
- changeState(self,2)
- })
- }).on('click','.btn-agree',function(){
- var self = this;
- var id = $(this).closest('.c-list').attr('data-id');
- addMemberByWxTempPromise(id,1)
- .then(function() {
- changeState(self,1)
- })
- })
- }
- function initListPromise() {
- return getFamilyMesListPromise(member)
- .then(function(res) {
- loading.close();
- if(res.status == "200") {
- if(res.data.mes && res.data.mes.length) {
- var html = template('li_tmpl',{list: res.data.mes });
- $listWrap.html(html);
- } else {
- $('#no_result_wrap').show()
- }
-
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
- }
-
- })
- }
- function initPage() {
- initListPromise()
- .then(function() {
- bindEvents();
- })
- .catch(function(e){
- loading.close();
- console && console.error(e);
- });
- }
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
|