collect.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. var app = getApp();
  2. // pages/collect/collect.js
  3. Page({
  4. data: {
  5. url: app.globalData.urlImages,
  6. sum:'',
  7. Arraylist:[]
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad: function (options) {
  13. app.setBarColor();
  14. app.setUserInfo();
  15. this.getcollect();
  16. },
  17. getcollect:function(){
  18. var that = this;
  19. var header = {
  20. 'content-type': 'application/x-www-form-urlencoded',
  21. }
  22. wx.request({
  23. url: app.globalData.url + '/routine/auth_api/get_user_collect_product?uid=' + app.globalData.uid,
  24. method: 'GET',
  25. header: header,
  26. success: function (res) {
  27. if (res.data.code==200){
  28. that.setData({
  29. sum: res.data.data.length,
  30. Arraylist: res.data.data
  31. })
  32. }else{
  33. // console.log(res);
  34. that.setData({
  35. sum: 0,
  36. Arraylist: []
  37. })
  38. }
  39. }
  40. })
  41. },
  42. /**
  43. * 生命周期函数--监听页面初次渲染完成
  44. */
  45. onReady: function () {
  46. },
  47. del:function(e){
  48. var that=this;
  49. var id = e.target.dataset.id;
  50. console.log(id);
  51. var header = {
  52. 'content-type': 'application/x-www-form-urlencoded',
  53. };
  54. wx.request({
  55. url: app.globalData.url + '/routine/auth_api/get_user_collect_product_del?uid=' + app.globalData.uid,
  56. data:{pid:id},
  57. method: 'GET',
  58. header: header,
  59. success: function (res) {
  60. if (res.data.code == 200){
  61. that.getcollect();
  62. }
  63. }
  64. })
  65. },
  66. })