globalMixin.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. let app = getApp();
  2. module.exports = {
  3. data: {
  4. // skin: app.globalData.skin,
  5. isIpx: app.globalData.isIpx,
  6. isblack: app.globalData.isblack,
  7. goods_sale_unit: '件',
  8. isparse_formdata: 0
  9. },
  10. onReady: function() {
  11. let that = this;
  12. app.getConfig().then(res=>{
  13. let common_header_backgroundimage = res.data.common_header_backgroundimage || '';
  14. app.globalData.common_header_backgroundimage = common_header_backgroundimage;
  15. let skin = {};
  16. let primaryColor = res.data.skin || '#ff5344';
  17. let goods_sale_unit = res.data.goods_sale_unit;
  18. skin.color = primaryColor;
  19. if(primaryColor) {
  20. skin.light = app.util.getLightColor(skin.color, 0.4);
  21. skin.lighter = app.util.getLightColor(skin.color, 0.8);
  22. }
  23. let h = {};
  24. let isparse_formdata = res.data.isparse_formdata;
  25. let token = wx.getStorageSync('token');
  26. if(token){
  27. console.log('mixinsisparse_formdata', isparse_formdata)
  28. h.isparse_formdata = isparse_formdata;
  29. } else {
  30. isparse_formdata = 0;
  31. h.isparse_formdata = 0;
  32. }
  33. console.log(h)
  34. wx.setStorageSync('isparse_formdata', isparse_formdata);
  35. that.setData({ skin, goods_sale_unit, ...h })
  36. app.globalData.skin = skin;
  37. app.globalData.goods_sale_unit = goods_sale_unit;
  38. }).catch(()=>{
  39. that.setData({
  40. skin: {
  41. color: '#ff5344',
  42. subColor: '#ed7b3a',
  43. lighter: '#fff9f4'
  44. }
  45. })
  46. })
  47. }
  48. }