C端小程序
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

157 рядки
4.8 KiB

  1. var config = require("../../config/config.js");
  2. var app = getApp();
  3. const Http = require("../../utils/HttpBasics");
  4. Page({
  5. data: {
  6. canIUse: wx.canIUse("button.open-type.getUserInfo"),
  7. path:null,
  8. couponChannelId: null,
  9. cuserId:null,
  10. coverImg:null,
  11. couponOrderId:null,
  12. optionData:null
  13. },
  14. onLoad: function(options) {
  15. var that = this;
  16. if (options.couponChannelId && !options.cuserId||options.orderId) {
  17. that.setData({
  18. couponChannelId: options.couponChannelId,
  19. orderId:options.orderId
  20. })
  21. }
  22. this.setData({
  23. optionData:options
  24. })
  25. if (options&&options.path == 'index') {
  26. that.setData({
  27. path: options.path
  28. })
  29. }
  30. /**
  31. * 来自转赠
  32. */
  33. if (options.couponChannelId && options.cuserId){
  34. console.log(1231231231,options)
  35. that.setData({
  36. couponChannelId: options.couponChannelId,
  37. cuserId: options.cuserId,
  38. coverImg: options.coverImg,
  39. userName: options.userName,
  40. avatarUrl: options.avatarUrl,
  41. couponOrderId: options.couponOrderId
  42. })
  43. }
  44. Http.get({
  45. url: config.api.marketicon,
  46. data: {
  47. appId: config.weapp.AppId
  48. }
  49. }).then(res => {
  50. that.setData({
  51. mallImgUrl: res.data.mallImgUrl
  52. });
  53. wx.setNavigationBarTitle({
  54. title: res.data.mallName
  55. })
  56. })
  57. .catch(err => {
  58. wx.showToast({
  59. title: err.errMsg,
  60. icon: 'none',
  61. duration: 2000,
  62. mask: false
  63. });
  64. })
  65. },
  66. bindGetUserInfo: function (e) {
  67. let that = this;
  68. var iv = e.detail.iv;
  69. var encryptedData = e.detail.encryptedData;
  70. Http.post({
  71. url: config.api.getUserInfo,
  72. data: {
  73. encryptedData: encryptedData,
  74. iv: iv
  75. }
  76. })
  77. .then(
  78. function (res) {
  79. console.log(res, that.data,6666666666)
  80. if (that.data.optionData.orderGroupId){
  81. wx.reLaunch({
  82. url: `/pages/joinFrDpell/index?couponId=${that.data.optionData.couponId}&orderGroupId=${that.data.optionData.orderGroupId}&couponChannelId=${that.data.optionData.couponChannelId}&orderId=${that.data.optionData.orderId}&avatarUrl=${that.data.optionData.avatarUrl}&nickName=${that.data.optionData.nickName}`
  83. });
  84. return;
  85. }
  86. if (that.data.path == 'index') {
  87. wx.reLaunch({
  88. url: "/pages/game/index"
  89. });
  90. } else {
  91. //返回主页
  92. if (that.data.couponChannelId && !that.data.cuserId&&app.globalData.type == 'cd') {
  93. wx.navigateTo({
  94. url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}}`
  95. });
  96. } else if (that.data.couponChannelId && that.data.cuserId) {
  97. /**
  98. * 来自转赠
  99. */
  100. wx.reLaunch({
  101. url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}&cuserId=${that.data.cuserId}&coverImg=${that.data.coverImg}&userName=${that.data.userName}&avatarUrl=${that.data.avatarUrl}&couponOrderId=${that.data.couponOrderId}&updateDate=${that.data.updateDate}`
  102. });
  103. } else if (that.data.orderId&&app.globalData.type=='bg') {
  104. wx.navigateTo({
  105. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}&from=${"friend"}`
  106. });
  107. } else if (app.globalData.type == 'uc') {
  108. wx.switchTab({
  109. url: '/pages/user/index'
  110. });
  111. } else if (app.globalData.type == 'pc') {
  112. wx.switchTab({
  113. url: '/pages/passCar/passCar'
  114. });
  115. } else if (app.globalData.type == 'co') {
  116. wx.redirectTo({
  117. url: '/pages/couponorder/index/index'
  118. });
  119. } else if (app.globalData.type == 'or') {
  120. wx.redirectTo({
  121. url: '/pages/couponorder/index/index'
  122. });
  123. } else if (app.globalData.type == 'sc') {
  124. wx.redirectTo({
  125. url: '/pages/specialcourtesy/specialcourtesy'
  126. });
  127. } else if (app.globalData.type == 'rb') {
  128. wx.redirectTo({
  129. url: '/pages/rushToBuy/index'
  130. });
  131. } else {
  132. wx.switchTab({
  133. url: "/pages/main/index"
  134. });
  135. }
  136. }
  137. },
  138. function (error) {
  139. console.log(error)
  140. wx.showToast({
  141. title: "请授权个人信息",
  142. icon: "none"
  143. });
  144. }
  145. )
  146. .catch(err => {
  147. wx.showToast({
  148. title: err.errMsg,
  149. icon: 'none',
  150. duration: 2000,
  151. mask: false
  152. });
  153. })
  154. }
  155. });