C端小程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

152 řádky
3.1 KiB

  1. // pages/spellDetail/index.js
  2. var config = require("../../../config/config.js");
  3. const Http = require("../../../utils/HttpBasics");
  4. const imgurl = require("../../../utils/imgurl");
  5. const { spellStatus } = require("../../../utils/spell");
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. tuanzhang: imgurl.tuanzhang.url,
  12. spellBg: imgurl.spellBg.url,
  13. position: imgurl.position.url,
  14. close03: imgurl.close03.url,
  15. home: imgurl.wmhome.url,
  16. paramData: null,
  17. data: null,
  18. showErr: false,
  19. showAlert: false,
  20. remainingPoints:0
  21. },
  22. getUserInfo: function () {
  23. let that = this;
  24. // 获取用户信息
  25. Http.get({
  26. url: config.api.getScore,
  27. data: {}
  28. })
  29. .then(res => {
  30. console.log(res)
  31. that.setData({
  32. remainingPoints: Number(res.data.credit) - Number(that.data.data.creditPrice),
  33. userInfo:res.data,
  34. nickName: res.data.nickName,
  35. avatarUrl: res.data.avatarUrl
  36. })
  37. })
  38. },
  39. gotoIndex() {
  40. wx.reLaunch({
  41. url: '/pages/index/index',
  42. })
  43. },
  44. gotoSearch() {
  45. wx.navigateTo({
  46. url: `/pages/spellGroup/spellGroup`,
  47. })
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad: function (options) {
  53. this.setData({
  54. paramData: options
  55. })
  56. this.getDetail(options.couponChannelId);
  57. // 关闭来自于左上角的分享
  58. wx.hideShareMenu()
  59. },
  60. gotoPay() {
  61. let that = this;
  62. wx.showLoading({
  63. title: '订单提交中...',
  64. })
  65. //操作人类型 1:C端用户,2:A端会员,3:B端用户,4:A端用户
  66. let param={
  67. cuserId:that.data.userInfo.id,//用户id
  68. operatorType:1,//操作人类型
  69. creditType: 11,//积分类型-积分兑换
  70. spend:this.data.data.credit,//积分数值
  71. couponId: this.data.data.couponId
  72. }
  73. Http.post({
  74. url: config.api.addIntegral,
  75. data: param
  76. })
  77. .then(res => {
  78. wx.hideLoading()
  79. /// End payment --------
  80. })
  81. .catch(err => {
  82. wx.showToast({
  83. title: err.message,
  84. icon: 'none',
  85. duration: 2000,
  86. mask: false
  87. });
  88. })
  89. },
  90. /**
  91. * 获取券详情信息
  92. */
  93. getDetail(couponChannelId) {
  94. let that = this;
  95. Http.get({
  96. url: config.api.couponDetail,
  97. data: {
  98. couponChannelId: couponChannelId
  99. }
  100. }).then(res => {
  101. wx.stopPullDownRefresh();
  102. that.getUserInfo()
  103. let data = res.data;
  104. that.setData({
  105. data
  106. });
  107. });
  108. },
  109. /**
  110. * 生命周期函数--监听页面初次渲染完成
  111. */
  112. onReady: function () {
  113. },
  114. /**
  115. * 生命周期函数--监听页面显示
  116. */
  117. onShow: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面隐藏
  121. */
  122. onHide: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面卸载
  126. */
  127. onUnload: function () {
  128. },
  129. /**
  130. * 页面相关事件处理函数--监听用户下拉动作
  131. */
  132. onPullDownRefresh: function () {
  133. this.getDetail(this.data.paramData.couponChannelId);
  134. },
  135. /**
  136. * 页面上拉触底事件的处理函数
  137. */
  138. onReachBottom: function () {
  139. }
  140. })