userCenter.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. mui.init();
  2. mui.ready(function() {
  3. getUserInfo();
  4. mobile.getCartNum();
  5. getNum();
  6. getIntegral();
  7. getMoney();
  8. $('.icon-kefu').parents('a').attr('href','tel:'+mobile.getParam('customer_tel'));
  9. $('.icon-kefu').parents('a').find('.pr15').html(mobile.getParam('customer_tel'));
  10. $('.mui-bar-tab').on('tap', 'a', function(e) {
  11. location.href=$(this).attr("href");
  12. });
  13. $('.mui-table-view').on('tap', 'li', function(e) {
  14. if($(this).attr("data-url")){
  15. location.href=$(this).attr("data-url");
  16. }
  17. });
  18. $('.mui-table').on('tap', '.mui-table-cell', function(e) {
  19. if($(this).attr("data-url")){
  20. location.href=$(this).attr("data-url");
  21. }
  22. });
  23. });
  24. //获取用户信息
  25. function getUserInfo() {
  26. if(user.is_share=="1"){
  27. $("#share-div").removeClass("mui-hidden");
  28. }
  29. if(user.username){
  30. $("#userName").html(user.username);
  31. }else{
  32. $("#userName").html(user.nickname);
  33. }
  34. if(user.headimgurl){
  35. $(".user-avatar").css("background-image","url("+user.headimgurl+")");
  36. }
  37. }
  38. //获取各类型订单数量
  39. function getNum() {
  40. mobile.ajaxPost(base + '/userOrder/getNum', {}, function(json) {
  41. if (json.data) {
  42. $.each(json.data, function(key, value) {
  43. if ($('#' + key)) {
  44. if (value != 0) {
  45. $('#' + key).html(value);
  46. $('#' + key).removeClass('mui-hidden');
  47. }
  48. }
  49. });
  50. }
  51. },"");
  52. }
  53. //获取积分
  54. function getIntegral() {
  55. mobile.ajaxPost(base + '/userIntegral/getIntegral', {}, function(json) {
  56. $('#integral').html(json.data);
  57. },"");
  58. }
  59. //获取余额
  60. function getMoney() {
  61. mobile.ajaxPost(base + '/userMoney/getMoney', {}, function(json) {
  62. $('#money').html("¥"+json.data);
  63. },"");
  64. }