userCenter.js 1.9 KB

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