C端小程序
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.

241 lines
7.9 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. // 跳转普通券/消费卡/限时秒杀/砍价详情
  94. wx.navigateTo({
  95. url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}}`
  96. });
  97. } else if (that.data.couponChannelId && that.data.cuserId) {
  98. // 来自转赠
  99. wx.reLaunch({
  100. 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}`
  101. });
  102. } else if (that.data.couponChannelId && app.globalData.type == 'sd') {
  103. // 拼团详情页
  104. wx.redirectTo({
  105. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelId}`,
  106. })
  107. } else if (that.data.optionData.id && app.globalData.type == 'gm') {
  108. // 游戏页面
  109. that.getGameOne(app.globalData.token, that.data.optionData.id)
  110. } else if (that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') {
  111. // 宣传页详情
  112. if (that.data.optionData.bt == '2') {
  113. // 自由图文
  114. wx.redirectTo({
  115. url: `/pages/freeBannerDetail/index?id=${that.data.optionData.id}`,
  116. })
  117. } else {
  118. // 标准格式
  119. wx.redirectTo({
  120. url: `/pages/bannerdetail/index?id=${that.data.optionData.id}`,
  121. })
  122. }
  123. } else if (that.data.orderId&&app.globalData.type=='bg') {
  124. // 参与砍价
  125. wx.navigateTo({
  126. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}`
  127. });
  128. } else if (app.globalData.type == 'uc') {
  129. // 我的
  130. wx.switchTab({
  131. url: '/pages/user/index'
  132. });
  133. } else if (app.globalData.type == 'pc') {
  134. // 停车
  135. wx.switchTab({
  136. url: '/pages/passCar/passCar'
  137. });
  138. } else if (app.globalData.type == 'mc') {
  139. // 我的券包
  140. wx.redirectTo({
  141. url: '/pages/couponorder/index/index'
  142. });
  143. } else if (app.globalData.type == 'mo') {
  144. // 我的订单
  145. wx.redirectTo({
  146. url: '/pages/order/index/index?id=all'
  147. });
  148. } else if (app.globalData.type == 'ca') {
  149. // 我的卡包
  150. wx.redirectTo({
  151. url: '/pages/cardorder/index/index'
  152. });
  153. } else if (app.globalData.type == 'sc') {
  154. // 特享礼遇
  155. wx.redirectTo({
  156. url: '/pages/specialcourtesy/specialcourtesy'
  157. });
  158. } else if (app.globalData.type == 'rb') {
  159. // 限时秒杀
  160. wx.redirectTo({
  161. url: '/pages/rushToBuy/index'
  162. });
  163. } else if (app.globalData.type == 'bl') {
  164. // 砍价专场
  165. wx.redirectTo({
  166. url: '/pages/bargain/bargain'
  167. });
  168. } else if (app.globalData.type == 'mb') {
  169. // 我的砍价
  170. wx.redirectTo({
  171. url: '/pages/bargain/bargain?from=myhtml'
  172. });
  173. } else if (app.globalData.type == 'sl') {
  174. // 拼团专场
  175. wx.redirectTo({
  176. url: '/pages/spellGroup/spellGroup'
  177. });
  178. } else if (app.globalData.type == 'ms') {
  179. // 我的拼团
  180. wx.redirectTo({
  181. url: '/pages/spellGroup/spellGroup?from=myhtml'
  182. });
  183. } else if (app.globalData.type == 'dc') {
  184. // 消费卡
  185. wx.redirectTo({
  186. url: '/pages/discountCardList/discountCardList'
  187. });
  188. } else if (options && options.id && app.globalData.type == 'td') {
  189. // 专题活动页
  190. wx.redirectTo({
  191. url: '/pages/topicDetail/index'
  192. });
  193. } else if (app.globalData.type == 'ml') {
  194. // 门店
  195. wx.redirectTo({
  196. url: '/pages/index/searchbar/index'
  197. });
  198. } else {
  199. wx.switchTab({
  200. url: "/pages/main/index"
  201. });
  202. }
  203. }
  204. },
  205. function (error) {
  206. console.log(error)
  207. wx.showToast({
  208. title: "请授权个人信息",
  209. icon: "none"
  210. });
  211. }
  212. )
  213. .catch(err => {
  214. wx.showToast({
  215. title: err.errMsg,
  216. icon: 'none',
  217. duration: 2000,
  218. mask: false
  219. });
  220. })
  221. },
  222. getGameOne: function (token, id) {
  223. let _this = this;
  224. Http.get({
  225. url: config.api.getOneGame,
  226. data: {
  227. token: token,
  228. id: id
  229. }
  230. }).then(res => {
  231. wx.redirectTo({
  232. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  233. })
  234. })
  235. .catch(err => {
  236. this.alphaClick();
  237. })
  238. },
  239. });