C端小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

278 lines
9.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 && options.spellGroup){
  17. that.setData({
  18. spellGroup: options.spellGroup
  19. })
  20. }else{
  21. that.setData({
  22. spellGroup: null
  23. })
  24. }
  25. if (options.couponChannelId && !options.cuserId||options.orderId) {
  26. that.setData({
  27. couponChannelId: options.couponChannelId,
  28. orderId:options.orderId
  29. })
  30. }
  31. that.setData({
  32. optionData: wx.getStorageSync('options') ? JSON.parse(wx.getStorageSync('options')):null
  33. })
  34. if (options&&options.path == 'index') {
  35. that.setData({
  36. path: options.path
  37. })
  38. }
  39. /**
  40. * 来自转赠
  41. */
  42. if (options.couponChannelId && options.cuserId){
  43. that.setData({
  44. couponChannelId: options.couponChannelId,
  45. cuserId: options.cuserId,
  46. updateDate: options.updateDate,
  47. coverImg: options.coverImg,
  48. userName: options.userName,
  49. avatarUrl: options.avatarUrl,
  50. couponOrderId: options.couponOrderId
  51. })
  52. }
  53. Http.get({
  54. url: config.api.marketicon,
  55. data: {
  56. appId: config.weapp.AppId
  57. }
  58. }).then(res => {
  59. that.setData({
  60. mallImgUrl: res.data.mallImgUrl
  61. });
  62. wx.setNavigationBarTitle({
  63. title: res.data.mallName
  64. })
  65. })
  66. .catch(err => {
  67. wx.showToast({
  68. title: err.errMsg,
  69. icon: 'none',
  70. duration: 2000,
  71. mask: false
  72. });
  73. })
  74. },
  75. bindGetUserInfo: function (e) {
  76. let that = this;
  77. var iv = e.detail.iv;
  78. var encryptedData = e.detail.encryptedData;
  79. Http.post({
  80. url: config.api.getUserInfo,
  81. data: {
  82. encryptedData: encryptedData,
  83. iv: iv
  84. }
  85. })
  86. .then(
  87. function (res) {
  88. if (that.data.optionData.orderGroupId){
  89. wx.reLaunch({
  90. 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}`
  91. });
  92. return;
  93. }
  94. if (that.data.path == 'index') {
  95. wx.reLaunch({
  96. url: "/pages/game/index"
  97. });
  98. } else {
  99. //返回主页
  100. if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup||that.data.couponChannelId && !that.data.cuserId&&app.globalData.type == 'cd') {
  101. // 跳转普通券/消费卡/限时秒杀/砍价详情
  102. wx.navigateTo({
  103. url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}`
  104. });
  105. } else if (that.data.couponChannelId && that.data.cuserId && !that.data.spellGroup) {
  106. // 来自转赠
  107. wx.reLaunch({
  108. 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}`
  109. });
  110. } else if (that.data.couponChannelId && app.globalData.type == 'sd' || that.data.couponChannelId && that.data.spellGroup) {
  111. // 拼团详情页
  112. wx.redirectTo({
  113. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelId}`,
  114. })
  115. } else if (that.data.optionData.id && app.globalData.type == 'gm') {
  116. // 游戏页面
  117. that.getGameOne(app.globalData.token, that.data.optionData.id)
  118. } else if (that.data.optionData.id && app.globalData.type == 'td') {
  119. wx.redirectTo({
  120. url: `/pages/topicDetail/index?id=${that.data.optionData.id}`
  121. });
  122. } else if (that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') {
  123. // 宣传页详情
  124. if (that.data.optionData.bt == '2') {
  125. // 自由图文
  126. wx.redirectTo({
  127. url: `/pages/freeBannerDetail/index?id=${that.data.optionData.id}`,
  128. })
  129. } else {
  130. // 标准格式
  131. wx.redirectTo({
  132. url: `/pages/bannerdetail/index?id=${that.data.optionData.id}`,
  133. })
  134. }
  135. } else if (that.data.orderId||that.data.orderId&&app.globalData.type=='bg') {
  136. // 参与砍价
  137. wx.navigateTo({
  138. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}`
  139. });
  140. } else if (app.globalData.type == 'uc') {
  141. // 我的
  142. wx.switchTab({
  143. url: '/pages/user/index'
  144. });
  145. } else if (app.globalData.type == 'in') {
  146. // 首页
  147. wx.switchTab({
  148. url: '/pages/main/index'
  149. });
  150. }
  151. // 积分
  152. else if (app.globalData.type == 'jf') {
  153. wx.redirectTo({
  154. url: '/pages/integralmall/index'
  155. });
  156. }else if (app.globalData.type == 'pc') {
  157. // 停车
  158. wx.switchTab({
  159. url: '/pages/passCar/passCar'
  160. });
  161. } else if (app.globalData.type == 'mc') {
  162. // 我的券包
  163. wx.redirectTo({
  164. url: '/pages/couponorder/index/index'
  165. });
  166. } else if (app.globalData.type == 'mo') {
  167. // 我的订单
  168. wx.redirectTo({
  169. url: '/pages/order/index/index?id=all'
  170. });
  171. } else if (app.globalData.type == 'ca') {
  172. // 我的卡包
  173. wx.redirectTo({
  174. url: '/pages/cardorder/index/index'
  175. });
  176. } else if (app.globalData.type == 'sc') {
  177. // 特享礼遇
  178. wx.redirectTo({
  179. url: '/pages/specialcourtesy/specialcourtesy'
  180. });
  181. } else if (app.globalData.type == 'rb') {
  182. // 限时秒杀
  183. wx.redirectTo({
  184. url: '/pages/rushToBuy/index'
  185. });
  186. } else if (app.globalData.type == 'bl') {
  187. // 砍价专场
  188. wx.redirectTo({
  189. url: '/pages/bargain/bargain'
  190. });
  191. } else if (app.globalData.type == 'mb') {
  192. // 我的砍价
  193. wx.redirectTo({
  194. url: '/pages/bargain/bargain?from=myhtml'
  195. });
  196. } else if (app.globalData.type == 'sl') {
  197. // 拼团专场
  198. wx.redirectTo({
  199. url: '/pages/spellGroup/spellGroup'
  200. });
  201. } else if (app.globalData.type == 'ms') {
  202. // 我的拼团
  203. wx.redirectTo({
  204. url: '/pages/spellGroup/spellGroup?from=myhtml'
  205. });
  206. } else if (app.globalData.type == 'dc') {
  207. // 消费卡
  208. wx.redirectTo({
  209. url: '/pages/discountCardList/discountCardList'
  210. });
  211. } else if (app.globalData.type == 'td') {
  212. // 专题活动页
  213. wx.redirectTo({
  214. url: '/pages/topicDetail/index'
  215. });
  216. }
  217. else if (app.globalData.type == 'ml') {
  218. // 门店
  219. wx.switchTab({
  220. url: '/pages/index/searchbar/index'
  221. });
  222. } else {
  223. wx.switchTab({
  224. url: "/pages/main/index"
  225. });
  226. }
  227. }
  228. },
  229. function (error) {
  230. console.log(error)
  231. wx.showToast({
  232. title: "请授权个人信息",
  233. icon: "none"
  234. });
  235. }
  236. )
  237. .catch(err => {
  238. wx.showToast({
  239. title: err.errMsg,
  240. icon: 'none',
  241. duration: 2000,
  242. mask: false
  243. });
  244. })
  245. },
  246. getGameOne: function (token, id) {
  247. let _this = this;
  248. Http.get({
  249. url: config.api.getOneGame,
  250. data: {
  251. token: token,
  252. id: id
  253. }
  254. }).then(res => {
  255. wx.redirectTo({
  256. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  257. })
  258. })
  259. .catch(err => {
  260. wx.showModal({
  261. title: '提示',
  262. content: err.message,
  263. showCancel: false,
  264. success: function (res) {
  265. // 如果游戏下架或者找不到,重启首页
  266. if (res.confirm) {
  267. wx.reLaunch({
  268. url: '/pages/index/index',
  269. })
  270. }
  271. }
  272. })
  273. this.alphaClick();
  274. })
  275. },
  276. });