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

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