C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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