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

314 lines
10 KiB

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