liuyan.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import { $wuxToast } from '../../dist/index'
  2. var app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. lynr:''
  9. },
  10. onChange(e) {
  11. let that = this;
  12. let id = e.currentTarget.id;
  13. let values = e.detail.value;
  14. if (id == 'lynr') {
  15. that.setData({
  16. lynr: values
  17. });
  18. }
  19. },
  20. getList: function () {
  21. let uid = app.globalData.openid;
  22. var that = this;
  23. wx.request({
  24. url: app.data.resturl + '/lylist.action',
  25. data: {
  26. uid: uid
  27. },
  28. success: function (res) {
  29. console.log(res);
  30. that.setData({
  31. dlist: res.data.dlist
  32. })
  33. }
  34. })
  35. },
  36. showError: function (info) {
  37. $wuxToast().show({
  38. type: 'text',
  39. duration: 1500,
  40. color: '#fff',
  41. text: info
  42. })
  43. },
  44. saveInfo: function () {
  45. let lynr = this.data.lynr;
  46. if (lynr == null || lynr == '') {
  47. this.showError('请输入内容');
  48. return;
  49. }
  50. let that = this;
  51. let uid = app.globalData.openid;
  52. wx.request({
  53. url: app.data.resturl + '/addLiuyan.action',
  54. method: 'post',
  55. header: {
  56. 'content-type': 'application/x-www-form-urlencoded'
  57. },
  58. data: {
  59. lynr: lynr,
  60. uid: uid
  61. },
  62. success: function (res) {
  63. let code = res.data.code;
  64. if (code == 200) {
  65. that.getList();
  66. }
  67. }
  68. })
  69. },
  70. /**
  71. * 生命周期函数--监听页面加载
  72. */
  73. onLoad: function (options) {
  74. },
  75. /**
  76. * 生命周期函数--监听页面初次渲染完成
  77. */
  78. onReady: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面显示
  82. */
  83. onShow: function () {
  84. var that = this
  85. that.getList();
  86. }
  87. })