exchangeCode.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // pages/welfareMall/exchangeCode/exchangeCode.js
  2. import WelfareMall from '../../../api/welfareMall'
  3. import {getMobileCache, getPhoneNumber as getPhoneNumberSync, getColor} from '../../../utils/user'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. config: {},
  10. sn: '',
  11. querySn: '',
  12. hideWindowValue: false,
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad(options) {
  18. },
  19. /**
  20. * 生命周期函数--监听页面初次渲染完成
  21. */
  22. onReady() {
  23. },
  24. /**
  25. * 生命周期函数--监听页面显示
  26. */
  27. onShow: async function() {
  28. let info = await getColor();
  29. this.setData({
  30. config:info.config,
  31. })
  32. },
  33. /**
  34. * 生命周期函数--监听页面隐藏
  35. */
  36. onHide() {
  37. },
  38. /**
  39. * 生命周期函数--监听页面卸载
  40. */
  41. onUnload() {
  42. },
  43. /**
  44. * 页面相关事件处理函数--监听用户下拉动作
  45. */
  46. onPullDownRefresh() {
  47. },
  48. /**
  49. * 页面上拉触底事件的处理函数
  50. */
  51. onReachBottom() {
  52. },
  53. /**
  54. * 用户点击右上角分享
  55. */
  56. onShareAppMessage() {
  57. },
  58. bindText: function (e) {
  59. var text = e.detail.value;
  60. this.setData({
  61. sn: text,
  62. })
  63. },
  64. /**
  65. * 弹框
  66. */
  67. hideWindow(){
  68. this.setData({
  69. hideWindowValue:true
  70. })
  71. },
  72. goPerson(){
  73. wx.switchTab({
  74. url: '../personal/personal'
  75. })
  76. },
  77. /**
  78. * 确认
  79. */
  80. toConfirm: function() {
  81. if(this.data.sn == null || this.data.sn == '' || this.data.sn == undefined){
  82. wx.showToast({
  83. title: '兑换码必填',
  84. icon: 'none',
  85. duration: 1500
  86. })
  87. return
  88. }
  89. WelfareMall.exchangeCoupon({
  90. mobile: getMobileCache(),
  91. sn: this.data.sn,
  92. }).then(res => {
  93. // if (res.code == 200) {
  94. // wx.showToast({
  95. // title: this.data.sn + '券码兑换成功',
  96. // icon: 'none',
  97. // duration: 1500
  98. // })
  99. // this.setData({
  100. // querySn: '',
  101. // })
  102. // }
  103. if (res.code == 200) {
  104. this.hideWindow()
  105. }
  106. }).catch(_ => {
  107. console.log(_)
  108. })
  109. },
  110. })