memberConvert.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api');
  3. var user = require('../../../utils/user.js');
  4. var app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. code:''
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. },
  17. codeInput(e){
  18. this.setData({
  19. code:e.detail.value
  20. })
  21. },
  22. confirmConvert(){
  23. if(this.data.code==''){
  24. wx.showToast({
  25. title: '请输入兑换码',
  26. icon: 'none',
  27. duration: 2000
  28. });
  29. }else{
  30. this.exchangeMemberCoupon();
  31. }
  32. },
  33. exchangeMemberCoupon(){
  34. util.request(api.exchangeMemberCoupon, {
  35. userId:app.globalData.userInfo.id,
  36. memberCode:this.data.code
  37. },'GET')
  38. .then(res=>{
  39. console.info(res);
  40. if (res.errno === 0) {
  41. let endTime=res.data.endTime.substr(0,10);
  42. wx.navigateTo({
  43. url: '/pages/member/becomeMember/becomeMember?endTime='+endTime,
  44. })
  45. } else {
  46. util.showErrorToast(res.errmsg);
  47. }
  48. });
  49. },
  50. /**
  51. * 生命周期函数--监听页面初次渲染完成
  52. */
  53. onReady: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面显示
  57. */
  58. onShow: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面隐藏
  62. */
  63. onHide: function () {
  64. },
  65. /**
  66. * 生命周期函数--监听页面卸载
  67. */
  68. onUnload: function () {
  69. },
  70. /**
  71. * 页面相关事件处理函数--监听用户下拉动作
  72. */
  73. onPullDownRefresh: function () {
  74. },
  75. /**
  76. * 页面上拉触底事件的处理函数
  77. */
  78. onReachBottom: function () {
  79. },
  80. /**
  81. * 用户点击右上角分享
  82. */
  83. onShareAppMessage: function () {
  84. }
  85. })