logistics.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. var app = getApp();
  2. // pages/unshop/unshop.js
  3. Page({
  4. data: {
  5. url: app.globalData.urlImages,
  6. Arraylike: [],
  7. order:[],
  8. express:[],
  9. productid:''
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. app.setBarColor();
  16. app.setUserInfo();
  17. var orderid = options.orderId;
  18. this.express(orderid);
  19. this.likeproduct();
  20. // console.log(orderid);
  21. },
  22. express: function (orderid){
  23. var that = this;
  24. wx.request({
  25. url: app.globalData.url + '/routine/auth_api/express?uid='+app.globalData.uid +'&uni='+orderid,
  26. method: 'GET',
  27. success: function (res) {
  28. if(res.data.code==200){
  29. that.setData({
  30. order: res.data.data.order,
  31. express: res.data.data.express
  32. })
  33. }else{
  34. that.setData({
  35. order: [],
  36. express: []
  37. })
  38. }
  39. }
  40. })
  41. },
  42. likeproduct:function(){
  43. var that = this;
  44. wx.request({
  45. url: app.globalData.url + '/routine/auth_api/get_hot_product',
  46. data: { offset: 0, limit:4},
  47. method: 'POST',
  48. success: function (res) {
  49. console.log(res.data.data);
  50. if (res.data.code == 200) {
  51. that.setData({
  52. Arraylike: res.data.data
  53. })
  54. } else {
  55. that.setData({
  56. Arraylike: []
  57. })
  58. }
  59. }
  60. })
  61. },
  62. cart: function (e) {
  63. var that = this;
  64. var id = e.target.dataset.id;
  65. console.log(id);
  66. wx.request({
  67. url: app.globalData.url + '/routine/auth_api/unique?uid=' + app.globalData.uid + '&productId=' + id,
  68. // data: { productId:id},
  69. method: 'GET',
  70. success: function (res) {
  71. if (res.data.code == 200) {
  72. that.setData({
  73. productid: id
  74. })
  75. that.prompt();
  76. } else {
  77. that.setData({
  78. productid: ''
  79. })
  80. that.prompts();
  81. }
  82. }
  83. })
  84. },
  85. prompt: function () {
  86. wx.showToast({
  87. title: this.data.productid ? "加入成功" : "加入失败",
  88. icon: 'success',
  89. duration: 800,
  90. mask: true
  91. })
  92. },
  93. prompts: function () {
  94. wx.showToast({
  95. title: '加入购物车失败!',
  96. icon: 'none',
  97. duration: 2000//持续的时间
  98. })
  99. },
  100. })