You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
3.3 KiB

  1. // pages/getMerchant/index.js
  2. const config = require('../../config/config.js')
  3. const Http = require('../../utils/HttpBasics.js')
  4. const util = require('../../utils/util.js')
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. phone: '',
  12. paramData: []
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. console.log(options)
  19. this.setData({
  20. paramData: options
  21. })
  22. if (options.a == 2) {
  23. wx.setNavigationBarTitle({
  24. title: '会员赠券'
  25. })
  26. } else {
  27. wx.setNavigationBarTitle({
  28. title: '会员积分'
  29. })
  30. }
  31. },//204391258
  32. /**
  33. * 生命周期函数--监听页面初次渲染完成
  34. */
  35. onReady: function () {
  36. },
  37. checkMerchant(e) {
  38. let id = e.target.id;
  39. this.data.selectList.map((item, index) => {
  40. if (id == item.id) {
  41. this.setData({
  42. selectMerchant: item``
  43. })
  44. }
  45. })
  46. },
  47. submitForm() {
  48. const reg = /^1[0|1|2|3|4|5|6|7|8|9]\d{9}$/;
  49. let _this = this;
  50. if (!reg.test(this.data.phone)) {
  51. wx.showToast({
  52. title: '抱歉,请输入正确的手机号',
  53. icon: 'none',
  54. duration: 2000,
  55. mask: false
  56. });
  57. return;
  58. }
  59. Http.get({
  60. url: config.api.findByPhone,
  61. data: {
  62. phone: _this.data.phone,
  63. }
  64. })
  65. .then(res => {
  66. console.log(res, 'res');
  67. if (res.data.id) {
  68. if (res.data.status == 1) {
  69. wx.showModal({
  70. title: "抱歉",
  71. content: "会员已被锁定",
  72. showCancel: false
  73. })
  74. return;
  75. }
  76. if (this.data.paramData.a == 1) {
  77. wx.navigateTo({
  78. url: `/pages/Add/index?id=${res.data.id}&levelName=${res.data.level}&nickName=${res.data.nickName}&name=${res.data.name}&phone=${res.data.phone}&score=${res.data.score}&credit=${res.data.credit}`
  79. })
  80. }
  81. if (this.data.paramData.a == 2) {
  82. wx.navigateTo({
  83. url: `/pages/giveCoupon/index?id=${res.data.id}&levelName=${res.data.level}&nickName=${res.data.nickName}&name=${res.data.name}&phone=${res.data.phone}&score=${res.data.score}&credit=${res.data.credit}`
  84. })
  85. }
  86. } else {
  87. wx.showToast({
  88. title: '抱歉,会员信息不存在!',
  89. icon: 'none',
  90. duration: 2000,
  91. mask: false
  92. });
  93. }
  94. })
  95. .catch(err => {
  96. wx.showToast({
  97. title: err.message,
  98. icon: 'none',
  99. duration: 2000,
  100. mask: false
  101. });
  102. });
  103. },
  104. getList(e) {
  105. console.log(e.detail.value)
  106. this.setData({
  107. phone: e.detail.value
  108. })
  109. },
  110. /**
  111. * 生命周期函数--监听页面显示
  112. */
  113. onShow: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面隐藏
  117. */
  118. onHide: function () {
  119. },
  120. /**
  121. * 生命周期函数--监听页面卸载
  122. */
  123. onUnload: function () {
  124. },
  125. /**
  126. * 页面相关事件处理函数--监听用户下拉动作
  127. */
  128. onPullDownRefresh: function () {
  129. },
  130. /**
  131. * 页面上拉触底事件的处理函数
  132. */
  133. onReachBottom: function () {
  134. },
  135. /**
  136. * 用户点击右上角分享
  137. */
  138. onShareAppMessage: function () {
  139. }
  140. })