index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // pages/customized/index/index.js
  2. // customized/pages/made/car/car.js
  3. let app = getApp();
  4. let host = app.globalData.servsers; // 请求的url
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. carNum:null,
  11. madeList:[
  12. {
  13. src:'/customized/images/customized/cup_black_small.png',
  14. name:'奶缸-黑色 350ml',
  15. price:'¥45.00',
  16. btnText:'去定制',
  17. btnDisabled:false,
  18. state:true,
  19. },
  20. {
  21. src: '/customized/images/customized/cup_black_small_2.png',
  22. name: '奶缸-白色 350ml',
  23. price: '¥45.00',
  24. btnText: '去定制',
  25. btnDisabled: true,
  26. state: false,
  27. },
  28. {
  29. src: '/customized/images/customized/cup_black_small_3.png',
  30. name: '马克杯-白色 450ml',
  31. price: '¥45.00',
  32. btnText: '去定制',
  33. btnDisabled: true,
  34. state: false,
  35. },
  36. {
  37. src: '/customized/images/customized/cup_black_small_4.png',
  38. name: '马克杯-白色 300ml',
  39. price: '¥45.00',
  40. btnText: '去定制',
  41. btnDisabled: true,
  42. state: false,
  43. }
  44. ]
  45. },
  46. /**
  47. * 生命周期函数--监听页面加载
  48. */
  49. onLoad: function (options) {
  50. },
  51. /**
  52. * 生命周期函数--监听页面初次渲染完成
  53. */
  54. onReady: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面显示
  58. */
  59. onShow: function () {
  60. this.getCarlist(this)
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload: function () {
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh: function () {
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom: function () {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage: function () {
  86. },
  87. customized(e){
  88. if (!e.currentTarget.dataset.state){
  89. return;
  90. }
  91. console.log('canvas')
  92. let user_id = getApp().globalData.user_id;
  93. console.log(user_id, "user_iduser_iduser_id")
  94. if (!user_id) {
  95. wx.navigateTo({
  96. url: '/pages/authorize/authorize?link=customized',
  97. })
  98. } else {
  99. wx.navigateTo({
  100. url: "/customized/pages/made/made",
  101. })
  102. }
  103. },
  104. getCarlist(that) {
  105. wx.request({
  106. url: host + '/queryShopCar',
  107. method: 'post',
  108. header: {
  109. 'content-type': 'application/x-www-form-urlencoded'
  110. },
  111. data: {
  112. userId: app.globalData.user_id //app.globalData.user_id //'oovpNwjlsY6xx8ceCebFa1dOLd9E' //app.globalData.user_id,
  113. },
  114. success: function (res) {
  115. console.log('购物车列表数据', res)
  116. that.setData({
  117. carNum: res.data.length
  118. })
  119. }
  120. })
  121. },
  122. })