giftList.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // pages/giftList/giftList.js
  2. var app = getApp()
  3. var giftList = [];
  4. Page({
  5. data: {
  6. giftList: giftList
  7. },
  8. onLoad: function (options) {
  9. var that = this;
  10. var host = getApp().globalData.servsers;
  11. var un_id = getApp().globalData.un_id;
  12. var openid = getApp().globalData.openid;
  13. if ((un_id == undefined || un_id == '' || un_id == null) || (openid == undefined || openid == '' || openid == null)) {
  14. wx.navigateTo({
  15. url: '/pages/authorize/authorize?link=giftList',
  16. })
  17. } else {
  18. wx.request({
  19. url: host + "giftapi/findUserGiftList",
  20. data: {
  21. userId: un_id,
  22. },
  23. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  24. header: {
  25. 'Accept': 'application/json'
  26. },
  27. success: function (res) {
  28. that.setData({
  29. giftList: res.data.userGiftList
  30. })
  31. console.log(res.data.userGiftList);
  32. if (res == null || res.data == null) {
  33. console.error('网络请求失败');
  34. return;
  35. }
  36. }
  37. });
  38. }
  39. },
  40. giftInfor:function(e){
  41. var that = this;
  42. var id = e.currentTarget.dataset.id;
  43. var newCarts = JSON.stringify(that.data.giftList[id]);
  44. newCarts = newCarts.replace(/&/g, "zss");
  45. wx:wx.navigateTo({
  46. url: '/pages/awaitStateFromList/awaitStateFromList?list=' + newCarts,
  47. success: function(res) {},
  48. fail: function(res) {},
  49. complete: function(res) {},
  50. })
  51. }
  52. })
  53. var that;
  54. var Util = require('../../utils/util.js');