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.

247 line
8.1 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. console.log(options)
  17. if (options.couponChannelId && !options.cuserId||options.orderId) {
  18. that.setData({
  19. couponChannelId: options.couponChannelId,
  20. orderId:options.orderId
  21. })
  22. }
  23. that.setData({
  24. optionData: wx.getStorageSync('options') ? JSON.parse(wx.getStorageSync('options')):null
  25. })
  26. console.log(that.data.optionData)
  27. if (options&&options.path == 'index') {
  28. that.setData({
  29. path: options.path
  30. })
  31. }
  32. /**
  33. * 来自转赠
  34. */
  35. if (options.couponChannelId && options.cuserId){
  36. that.setData({
  37. couponChannelId: options.couponChannelId,
  38. cuserId: options.cuserId,
  39. coverImg: options.coverImg,
  40. userName: options.userName,
  41. avatarUrl: options.avatarUrl,
  42. couponOrderId: options.couponOrderId
  43. })
  44. }
  45. Http.get({
  46. url: config.api.marketicon,
  47. data: {
  48. appId: config.weapp.AppId
  49. }
  50. }).then(res => {
  51. that.setData({
  52. mallImgUrl: res.data.mallImgUrl
  53. });
  54. wx.setNavigationBarTitle({
  55. title: res.data.mallName
  56. })
  57. })
  58. .catch(err => {
  59. wx.showToast({
  60. title: err.errMsg,
  61. icon: 'none',
  62. duration: 2000,
  63. mask: false
  64. });
  65. })
  66. },
  67. bindGetUserInfo: function (e) {
  68. let that = this;
  69. var iv = e.detail.iv;
  70. var encryptedData = e.detail.encryptedData;
  71. Http.post({
  72. url: config.api.getUserInfo,
  73. data: {
  74. encryptedData: encryptedData,
  75. iv: iv
  76. }
  77. })
  78. .then(
  79. function (res) {
  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.id && app.globalData.type == 'td') {
  111. wx.redirectTo({
  112. url: `/pages/topicDetail/index?id=${that.data.optionData.id}`
  113. });
  114. } else if (that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') {
  115. // 宣传页详情
  116. if (that.data.optionData.bt == '2') {
  117. // 自由图文
  118. wx.redirectTo({
  119. url: `/pages/freeBannerDetail/index?id=${that.data.optionData.id}`,
  120. })
  121. } else {
  122. // 标准格式
  123. wx.redirectTo({
  124. url: `/pages/bannerdetail/index?id=${that.data.optionData.id}`,
  125. })
  126. }
  127. } else if (that.data.orderId&&app.globalData.type=='bg') {
  128. // 参与砍价
  129. wx.navigateTo({
  130. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}`
  131. });
  132. } else if (app.globalData.type == 'uc') {
  133. // 我的
  134. wx.switchTab({
  135. url: '/pages/user/index'
  136. });
  137. } else if (app.globalData.type == 'pc') {
  138. // 停车
  139. wx.switchTab({
  140. url: '/pages/passCar/passCar'
  141. });
  142. } else if (app.globalData.type == 'mc') {
  143. // 我的券包
  144. wx.redirectTo({
  145. url: '/pages/couponorder/index/index'
  146. });
  147. } else if (app.globalData.type == 'mo') {
  148. // 我的订单
  149. wx.redirectTo({
  150. url: '/pages/order/index/index?id=all'
  151. });
  152. } else if (app.globalData.type == 'ca') {
  153. // 我的卡包
  154. wx.redirectTo({
  155. url: '/pages/cardorder/index/index'
  156. });
  157. } else if (app.globalData.type == 'sc') {
  158. // 特享礼遇
  159. wx.redirectTo({
  160. url: '/pages/specialcourtesy/specialcourtesy'
  161. });
  162. } else if (app.globalData.type == 'rb') {
  163. // 限时秒杀
  164. wx.redirectTo({
  165. url: '/pages/rushToBuy/index'
  166. });
  167. } else if (app.globalData.type == 'bl') {
  168. // 砍价专场
  169. wx.redirectTo({
  170. url: '/pages/bargain/bargain'
  171. });
  172. } else if (app.globalData.type == 'mb') {
  173. // 我的砍价
  174. wx.redirectTo({
  175. url: '/pages/bargain/bargain?from=myhtml'
  176. });
  177. } else if (app.globalData.type == 'sl') {
  178. // 拼团专场
  179. wx.redirectTo({
  180. url: '/pages/spellGroup/spellGroup'
  181. });
  182. } else if (app.globalData.type == 'ms') {
  183. // 我的拼团
  184. wx.redirectTo({
  185. url: '/pages/spellGroup/spellGroup?from=myhtml'
  186. });
  187. } else if (app.globalData.type == 'dc') {
  188. // 消费卡
  189. wx.redirectTo({
  190. url: '/pages/discountCardList/discountCardList'
  191. });
  192. } else if (app.globalData.type == 'td') {
  193. // 专题活动页
  194. wx.redirectTo({
  195. url: '/pages/topicDetail/index'
  196. });
  197. }
  198. else if (app.globalData.type == 'ml') {
  199. // 门店
  200. wx.switchTab({
  201. url: '/pages/index/searchbar/index'
  202. });
  203. } else {
  204. wx.switchTab({
  205. url: "/pages/main/index"
  206. });
  207. }
  208. }
  209. },
  210. function (error) {
  211. console.log(error)
  212. wx.showToast({
  213. title: "请授权个人信息",
  214. icon: "none"
  215. });
  216. }
  217. )
  218. .catch(err => {
  219. wx.showToast({
  220. title: err.errMsg,
  221. icon: 'none',
  222. duration: 2000,
  223. mask: false
  224. });
  225. })
  226. },
  227. getGameOne: function (token, id) {
  228. let _this = this;
  229. Http.get({
  230. url: config.api.getOneGame,
  231. data: {
  232. token: token,
  233. id: id
  234. }
  235. }).then(res => {
  236. wx.redirectTo({
  237. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  238. })
  239. })
  240. .catch(err => {
  241. this.alphaClick();
  242. })
  243. },
  244. });