C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

402 lignes
16 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. fromflag: '',
  16. couponChannelIdflag: ''
  17. },
  18. judgePhonelngo() {
  19. Http.get({
  20. url: config.api.checkPhoneStatus,
  21. data: {}
  22. }).then(res => {
  23. var tempSkip = app.globalData.skip
  24. if (tempSkip =='redirectTo'){
  25. wx.redirectTo({
  26. url: app.globalData.skipUrl,
  27. })
  28. } else if (tempSkip == 'navigateTo'){
  29. wx.navigateTo({
  30. url: app.globalData.skipUrl,
  31. })
  32. } else if (tempSkip == 'reLaunch'){
  33. wx.reLaunch({
  34. url: app.globalData.skipUrl,
  35. })
  36. } else if (tempSkip == 'switchTab') {
  37. wx.switchTab({
  38. url: app.globalData.skipUrl,
  39. })
  40. }
  41. }).catch(err => {
  42. wx.redirectTo({
  43. url: `/pages/getphoneInfo/index?skipUrl=1`
  44. });
  45. })
  46. },
  47. onLoad: function(options) {
  48. console.log(app.globalData.skip, app.globalData.skipUrl, "跳转地址")
  49. var that = this;
  50. // options.fromflag == 'coupondetail';
  51. // 来自优惠券详情页面
  52. if (options && options.fromflag) {
  53. that.setData({
  54. fromflag: options.fromflag
  55. })
  56. }
  57. if (options && options.goFlaig){
  58. that.se
  59. }
  60. // 来自优惠券列表券详情页面的 couponChannelId
  61. if (options && options.couponChannelIdflag) {
  62. that.setData({
  63. couponChannelIdflag: options.couponChannelIdflag
  64. })
  65. }
  66. if (options && options.spellGroup) {
  67. that.setData({
  68. spellGroup: options.spellGroup
  69. })
  70. } else {
  71. that.setData({
  72. spellGroup: null
  73. })
  74. }
  75. if (options.couponChannelId && !options.cuserId || options.orderId) {
  76. that.setData({
  77. couponChannelId: options.couponChannelId,
  78. orderId: options.orderId
  79. })
  80. }
  81. if (options && options.frommd && options.id) {
  82. that.setData({
  83. id: options.id,
  84. frommd: options.frommd
  85. })
  86. }
  87. // that.setData({
  88. // optionData: null
  89. // })
  90. console.log(wx.getStorageSync('options'), 6666)
  91. that.setData({
  92. optionData: wx.getStorageSync('options') ? JSON.parse(wx.getStorageSync('options')) : null
  93. })
  94. if (options && options.path == 'index') {
  95. that.setData({
  96. path: options.path
  97. })
  98. }
  99. /**
  100. * 来自转赠
  101. */
  102. if (options.couponChannelId && options.cuserId) {
  103. that.setData({
  104. couponChannelId: options.couponChannelId,
  105. cuserId: options.cuserId,
  106. updateDate: options.updateDate,
  107. coverImg: options.coverImg,
  108. userName: options.userName,
  109. avatarUrl: options.avatarUrl,
  110. couponOrderId: options.couponOrderId
  111. })
  112. }
  113. Http.get({
  114. url: config.api.marketicon,
  115. data: {
  116. appId: config.weapp.AppId
  117. }
  118. }).then(res => {
  119. that.setData({
  120. mallImgUrl: res.data.mallImgUrl
  121. });
  122. wx.setNavigationBarTitle({
  123. title: res.data.mallName
  124. })
  125. })
  126. .catch(err => {
  127. wx.showToast({
  128. title: err.errMsg,
  129. icon: 'none',
  130. duration: 2000,
  131. mask: false
  132. });
  133. })
  134. },
  135. backHome: function() {
  136. wx.setStorageSync("tabFlag", 1)
  137. wx.switchTab({
  138. url: '/index/index',
  139. })
  140. },
  141. bindGetUserInfo: function(e) {
  142. let that = this;
  143. var iv = e.detail.iv;
  144. var encryptedData = e.detail.encryptedData;
  145. wx.getUserInfo({
  146. success: function(res) {
  147. Http.post({
  148. url: config.api.getUserInfo,
  149. data: {
  150. encryptedData: encryptedData,
  151. iv: iv
  152. }
  153. }).then(
  154. function(res) {
  155. if (that.data.fromflag == 'poster') {
  156. app.globalData.skipUrl = `/pages/canvas/index?couponChannelId=${that.data.couponChannelId}`
  157. app.globalData.skip = 'redirectTo'
  158. that.judgePhonelngo()
  159. return;
  160. }
  161. //
  162. if (that.data.optionData.orderGroupId) {
  163. app.globalData.skipUrl = `/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}`
  164. app.globalData.skip = 'reLaunch'
  165. that.judgePhonelngo()
  166. return;
  167. }
  168. if (that.data.path == 'index') {
  169. app.globalData.skipUrl = "/pages/game/index"
  170. app.globalData.skip = 'reLaunch'
  171. that.judgePhonelngo()
  172. } else {
  173. //返回主页
  174. // if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup||that.data.couponChannelId && !that.data.cuserId&&app.globalData.type == 'cd') {
  175. if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup && app.globalData.type == 'cd') {
  176. // 跳转普通券/消费卡/限时秒杀/砍价详情
  177. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}`
  178. app.globalData.skip = 'navigateTo'
  179. that.judgePhonelngo()
  180. } else if (that.data.couponChannelId && that.data.cuserId && !that.data.spellGroup && app.globalData.type != 'sd') {
  181. // 来自转赠
  182. app.globalData.skipUrl = `/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}`
  183. app.globalData.skip = 'reLaunch'
  184. that.judgePhonelngo()
  185. } else if (that.data.couponChannelId && app.globalData.type == 'sd' || that.data.couponChannelId && that.data.spellGroup) {
  186. // 拼团详情页
  187. app.globalData.skipUrl = `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelId}`
  188. app.globalData.skip = 'redirectTo'
  189. that.judgePhonelngo()
  190. } else if (that.data.optionData.id && app.globalData.type == 'gm') {
  191. // 游戏页面
  192. that.getGameOne(app.globalData.token, that.data.optionData.id)
  193. } else if (that.data.optionData.id && app.globalData.type == 'td') {
  194. app.globalData.skipUrl = `/pages/topicDetail/index?id=${that.data.optionData.id}`
  195. app.globalData.skip = 'redirectTo'
  196. that.judgePhonelngo()
  197. }
  198. // 报名活动
  199. else if (that.data.optionData.id && app.globalData.type == 'ra') {
  200. app.globalData.skipUrl = `/pages/radetail/index?id=${that.data.optionData.id}`,
  201. app.globalData.skip = 'redirectTo'
  202. that.judgePhonelngo()
  203. }
  204. // 报名签到
  205. else if (that.data.optionData.id && app.globalData.type == 'si') {
  206. app.globalData.skipUrl = `/pages/acSignIn/index?id=${that.data.optionData.id}`,
  207. app.globalData.skip = 'redirectTo'
  208. that.judgePhonelngo()
  209. }
  210. // 门店详情
  211. else if (that.data.optionData.id && app.globalData.type == 'md') {
  212. app.globalData.skipUrl = `/pages/index/searchbar/detail/index?id=${that.data.optionData.id}`,
  213. app.globalData.skip = 'redirectTo'
  214. that.judgePhonelngo()
  215. }
  216. // 通过分享进入的门店详情页面
  217. else if (that.data.id && that.data.frommd == 'md') {
  218. app.globalData.skipUrl = `/pages/index/searchbar/detail/index?id=${that.data.id}`,
  219. app.globalData.skip = 'redirectTo'
  220. that.judgePhonelngo()
  221. } else if (that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') {
  222. // 宣传页详情
  223. if (that.data.optionData.bt == '2') {
  224. // 自由图文
  225. app.globalData.skipUrl = `/pages/freeBannerDetail/index?id=${that.data.optionData.id}`,
  226. app.globalData.skip = 'redirectTo'
  227. that.judgePhonelngo()
  228. } else {
  229. // 标准格式
  230. app.globalData.skipUrl = `/pages/bannerdetail/index?id=${that.data.optionData.id}`,
  231. app.globalData.skip = 'redirectTo'
  232. that.judgePhonelngo()
  233. }
  234. } else if (that.data.orderId || that.data.orderId && app.globalData.type == 'bg') {
  235. // 参与砍价
  236. app.globalData.skipUrl = `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}`,
  237. app.globalData.skip = 'navigateTo'
  238. that.judgePhonelngo()
  239. } else if (app.globalData.type == 'uc') {
  240. // 我的
  241. app.globalData.skipUrl = '/index/user',
  242. app.globalData.skip = 'switchTab'
  243. that.judgePhonelngo()
  244. } else if (app.globalData.type == 'in') {
  245. // 首页
  246. app.globalData.skipUrl = '/index/index',
  247. app.globalData.skip = 'switchTab'
  248. that.judgePhonelngo()
  249. } else if (app.globalData.type == "qd"){
  250. //每日签到
  251. app.globalData.skipUrl = "/pages/activityCalendar/activityCalendar"
  252. app.globalData.skip = 'reLaunch'
  253. that.judgePhonelngo()
  254. }
  255. else if (app.globalData.type == "hdrl") {
  256. //活动日历
  257. app.globalData.skipUrl = `/pages/radetail/index?id=${app.globalData.activityId}`
  258. app.globalData.skip = 'redirectTo'
  259. that.judgePhonelngo()
  260. }
  261. // 积分
  262. else if (app.globalData.type == 'jf') {
  263. app.globalData.skipUrl = '/pages/integralmall/index',
  264. app.globalData.skip = 'redirectTo'
  265. that.judgePhonelngo()
  266. } else if (app.globalData.type == 'pc') {
  267. // 停车
  268. app.globalData.skipUrl = '/index/passCar',
  269. app.globalData.skip = 'switchTab'
  270. that.judgePhonelngo()
  271. } else if (app.globalData.type == 'mc') {
  272. // 我的券包
  273. app.globalData.skipUrl = '/pages/couponorder/index/index',
  274. app.globalData.skip = 'redirectTo'
  275. that.judgePhonelngo()
  276. } else if (app.globalData.type == 'mo') {
  277. // 我的订单
  278. app.globalData.skipUrl = '/pages/order/index/index?id=all',
  279. app.globalData.skip = 'redirectTo'
  280. that.judgePhonelngo()
  281. } else if (app.globalData.type == 'ca') {
  282. // 我的卡包
  283. app.globalData.skipUrl = '/pages/cardorder/index/index',
  284. app.globalData.skip = 'redirectTo'
  285. that.judgePhonelngo()
  286. } else if (app.globalData.type == 'sc') {
  287. // 特享礼遇
  288. app.globalData.skipUrl = '/pages/specialcourtesy/specialcourtesy',
  289. app.globalData.skip = 'redirectTo'
  290. that.judgePhonelngo()
  291. } else if (app.globalData.type == 'rb') {
  292. // 限时秒杀
  293. app.globalData.skipUrl = '/pages/rushToBuy/index',
  294. app.globalData.skip = 'redirectTo'
  295. that.judgePhonelngo()
  296. } else if (app.globalData.type == 'bl') {
  297. // 砍价专场
  298. app.globalData.skipUrl = '/pages/bargain/bargain',
  299. app.globalData.skip = 'redirectTo'
  300. that.judgePhonelngo()
  301. } else if (app.globalData.type == 'mb') {
  302. // 我的砍价
  303. app.globalData.skipUrl = '/pages/bargain/bargain?from=myhtml',
  304. app.globalData.skip = 'redirectTo'
  305. that.judgePhonelngo()
  306. } else if (app.globalData.type == 'sl') {
  307. // 拼团专场
  308. app.globalData.skipUrl = '/pages/spellGroup/spellGroup',
  309. app.globalData.skip = 'redirectTo'
  310. that.judgePhonelngo()
  311. } else if (app.globalData.type == 'ms') {
  312. // 我的拼团
  313. app.globalData.skipUrl = '/pages/spellGroup/spellGroup?from=myhtml',
  314. app.globalData.skip = 'redirectTo'
  315. that.judgePhonelngo()
  316. } else if (app.globalData.type == 'dc') {
  317. // 消费卡
  318. app.globalData.skipUrl = '/pages/discountCardList/discountCardList',
  319. app.globalData.skip = 'redirectTo'
  320. that.judgePhonelngo()
  321. } else if (app.globalData.type == 'td') {
  322. // 专题活动页
  323. app.globalData.skipUrl = '/pages/topicDetail/index',
  324. app.globalData.skip = 'redirectTo'
  325. that.judgePhonelngo()
  326. } else if (app.globalData.type == 'ml') {
  327. // 门店
  328. app.globalData.skipUrl = '/index/searchbar',
  329. app.globalData.skip = 'switchTab'
  330. that.judgePhonelngo()
  331. } else if (that.data.fromflag == 'coupondetail' && that.data.couponChannelIdflag) {
  332. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelIdflag}`,
  333. app.globalData.skip = 'redirectTo'
  334. that.judgePhonelngo()
  335. } else if (that.data.fromflag == 'spellcoupondetail' && that.data.couponChannelIdflag) {
  336. app.globalData.skipUrl = `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelIdflag}`,
  337. app.globalData.skip = 'redirectTo'
  338. that.judgePhonelngo()
  339. } else {
  340. app.globalData.skipUrl = "/index/index",
  341. app.globalData.skip = 'switchTab'
  342. that.judgePhonelngo()
  343. }
  344. }
  345. },
  346. function(error) {
  347. console.log(error)
  348. wx.showToast({
  349. title: "请授权个人信息",
  350. icon: "none"
  351. });
  352. }
  353. )
  354. .catch(err => {
  355. wx.showToast({
  356. title: err.errMsg,
  357. icon: 'none',
  358. duration: 2000,
  359. mask: false
  360. });
  361. })
  362. }
  363. })
  364. },
  365. getGameOne: function(token, id) {
  366. let _this = this;
  367. Http.get({
  368. url: config.api.getOneGame,
  369. data: {
  370. token: token,
  371. id: id
  372. }
  373. }).then(res => {
  374. wx.redirectTo({
  375. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  376. })
  377. })
  378. .catch(err => {
  379. wx.showModal({
  380. title: '提示',
  381. content: err.message,
  382. showCancel: false,
  383. success: function(res) {
  384. // 如果游戏下架或者找不到,重启首页
  385. if (res.confirm) {
  386. wx.reLaunch({
  387. url: '/pages/index/index',
  388. })
  389. }
  390. }
  391. })
  392. this.alphaClick();
  393. })
  394. },
  395. });