C端小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

402 rindas
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.switchTab({
  137. url: '/index/index',
  138. })
  139. },
  140. bindGetUserInfo: function(e) {
  141. let that = this;
  142. var iv = e.detail.iv;
  143. var encryptedData = e.detail.encryptedData;
  144. wx.getUserInfo({
  145. success: function(res) {
  146. Http.post({
  147. url: config.api.getUserInfo,
  148. data: {
  149. encryptedData: encryptedData,
  150. iv: iv
  151. }
  152. }).then(
  153. function(res) {
  154. if (that.data.fromflag == 'poster') {
  155. app.globalData.skipUrl = `/pages/canvas/index?couponChannelId=${that.data.couponChannelId}`
  156. app.globalData.skip = 'redirectTo'
  157. that.judgePhonelngo()
  158. return;
  159. }
  160. //
  161. if (that.data.optionData.orderGroupId) {
  162. 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}`
  163. app.globalData.skip = 'reLaunch'
  164. that.judgePhonelngo()
  165. return;
  166. }
  167. if (that.data.path == 'index') {
  168. app.globalData.skipUrl = "/pages/game/index"
  169. app.globalData.skip = 'reLaunch'
  170. that.judgePhonelngo()
  171. } else {
  172. //返回主页
  173. // if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup||that.data.couponChannelId && !that.data.cuserId&&app.globalData.type == 'cd') {
  174. if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup && app.globalData.type == 'cd') {
  175. // 跳转普通券/消费卡/限时秒杀/砍价详情
  176. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}`
  177. app.globalData.skip = 'navigateTo'
  178. that.judgePhonelngo()
  179. } else if (that.data.couponChannelId && that.data.cuserId && !that.data.spellGroup && app.globalData.type != 'sd') {
  180. // 来自转赠
  181. 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}`
  182. app.globalData.skip = 'reLaunch'
  183. that.judgePhonelngo()
  184. } else if (that.data.couponChannelId && app.globalData.type == 'sd' || that.data.couponChannelId && that.data.spellGroup) {
  185. // 拼团详情页
  186. app.globalData.skipUrl = `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelId}`
  187. app.globalData.skip = 'redirectTo'
  188. that.judgePhonelngo()
  189. } else if (that.data.optionData.id && app.globalData.type == 'gm') {
  190. // 游戏页面
  191. that.getGameOne(app.globalData.token, that.data.optionData.id)
  192. } else if (that.data.optionData.id && app.globalData.type == 'td') {
  193. app.globalData.skipUrl = `/pages/topicDetail/index?id=${that.data.optionData.id}`
  194. app.globalData.skip = 'redirectTo'
  195. that.judgePhonelngo()
  196. }
  197. // 报名活动
  198. else if (that.data.optionData.id && app.globalData.type == 'ra') {
  199. app.globalData.skipUrl = `/pages/radetail/index?id=${that.data.optionData.id}`,
  200. app.globalData.skip = 'redirectTo'
  201. that.judgePhonelngo()
  202. }
  203. // 报名签到
  204. else if (that.data.optionData.id && app.globalData.type == 'si') {
  205. app.globalData.skipUrl = `/pages/acSignIn/index?id=${that.data.optionData.id}`,
  206. app.globalData.skip = 'redirectTo'
  207. that.judgePhonelngo()
  208. }
  209. // 门店详情
  210. else if (that.data.optionData.id && app.globalData.type == 'md') {
  211. app.globalData.skipUrl = `/pages/index/searchbar/detail/index?id=${that.data.optionData.id}`,
  212. app.globalData.skip = 'redirectTo'
  213. that.judgePhonelngo()
  214. }
  215. // 通过分享进入的门店详情页面
  216. else if (that.data.id && that.data.frommd == 'md') {
  217. app.globalData.skipUrl = `/pages/index/searchbar/detail/index?id=${that.data.id}`,
  218. app.globalData.skip = 'redirectTo'
  219. that.judgePhonelngo()
  220. } else if (that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') {
  221. // 宣传页详情
  222. if (that.data.optionData.bt == '2') {
  223. // 自由图文
  224. app.globalData.skipUrl = `/pages/freeBannerDetail/index?id=${that.data.optionData.id}`,
  225. app.globalData.skip = 'redirectTo'
  226. that.judgePhonelngo()
  227. } else {
  228. // 标准格式
  229. app.globalData.skipUrl = `/pages/bannerdetail/index?id=${that.data.optionData.id}`,
  230. app.globalData.skip = 'redirectTo'
  231. that.judgePhonelngo()
  232. }
  233. } else if (that.data.orderId || that.data.orderId && app.globalData.type == 'bg') {
  234. // 参与砍价
  235. app.globalData.skipUrl = `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}`,
  236. app.globalData.skip = 'navigateTo'
  237. that.judgePhonelngo()
  238. } else if (app.globalData.type == 'uc') {
  239. // 我的
  240. app.globalData.skipUrl = '/index/user',
  241. app.globalData.skip = 'switchTab'
  242. that.judgePhonelngo()
  243. } else if (app.globalData.type == 'in') {
  244. // 首页
  245. app.globalData.skipUrl = '/index/index',
  246. app.globalData.skip = 'switchTab'
  247. that.judgePhonelngo()
  248. } else if (app.globalData.type == "qd"){
  249. //每日签到
  250. app.globalData.skipUrl = "/pages/activityCalendar/activityCalendar"
  251. app.globalData.skip = 'reLaunch'
  252. that.judgePhonelngo()
  253. }
  254. else if (app.globalData.type == "hdrl") {
  255. //活动日历
  256. app.globalData.skipUrl = `/pages/radetail/index?id=${app.globalData.activityId}`
  257. app.globalData.skip = 'redirectTo'
  258. that.judgePhonelngo()
  259. }
  260. // 积分
  261. else if (app.globalData.type == 'jf') {
  262. app.globalData.skipUrl = '/pages/integralmall/index',
  263. app.globalData.skip = 'redirectTo'
  264. that.judgePhonelngo()
  265. } else if (app.globalData.type == 'pc') {
  266. // 停车
  267. app.globalData.skipUrl = '/index/passCar',
  268. app.globalData.skip = 'switchTab'
  269. that.judgePhonelngo()
  270. } else if (app.globalData.type == 'mc') {
  271. // 我的券包
  272. app.globalData.skipUrl = '/pages/couponorder/index/index',
  273. app.globalData.skip = 'redirectTo'
  274. that.judgePhonelngo()
  275. } else if (app.globalData.type == 'mo') {
  276. // 我的订单
  277. app.globalData.skipUrl = '/pages/order/index/index?id=all',
  278. app.globalData.skip = 'redirectTo'
  279. that.judgePhonelngo()
  280. } else if (app.globalData.type == 'ca') {
  281. // 我的卡包
  282. app.globalData.skipUrl = '/pages/cardorder/index/index',
  283. app.globalData.skip = 'redirectTo'
  284. that.judgePhonelngo()
  285. } else if (app.globalData.type == 'sc') {
  286. // 特享礼遇
  287. app.globalData.skipUrl = '/pages/specialcourtesy/specialcourtesy',
  288. app.globalData.skip = 'redirectTo'
  289. that.judgePhonelngo()
  290. } else if (app.globalData.type == 'rb') {
  291. // 限时秒杀
  292. app.globalData.skipUrl = '/pages/rushToBuy/index',
  293. app.globalData.skip = 'redirectTo'
  294. that.judgePhonelngo()
  295. } else if (app.globalData.type == 'bl') {
  296. // 砍价专场
  297. app.globalData.skipUrl = '/pages/bargain/bargain',
  298. app.globalData.skip = 'redirectTo'
  299. that.judgePhonelngo()
  300. } else if (app.globalData.type == 'mb') {
  301. // 我的砍价
  302. app.globalData.skipUrl = '/pages/bargain/bargain?from=myhtml',
  303. app.globalData.skip = 'redirectTo'
  304. that.judgePhonelngo()
  305. } else if (app.globalData.type == 'sl') {
  306. // 拼团专场
  307. app.globalData.skipUrl = '/pages/spellGroup/spellGroup',
  308. app.globalData.skip = 'redirectTo'
  309. that.judgePhonelngo()
  310. } else if (app.globalData.type == 'ms') {
  311. // 我的拼团
  312. app.globalData.skipUrl = '/pages/spellGroup/spellGroup?from=myhtml',
  313. app.globalData.skip = 'redirectTo'
  314. that.judgePhonelngo()
  315. } else if (app.globalData.type == 'dc') {
  316. // 消费卡
  317. app.globalData.skipUrl = '/pages/discountCardList/discountCardList',
  318. app.globalData.skip = 'redirectTo'
  319. that.judgePhonelngo()
  320. } else if (app.globalData.type == 'td') {
  321. // 专题活动页
  322. app.globalData.skipUrl = '/pages/topicDetail/index',
  323. app.globalData.skip = 'redirectTo'
  324. that.judgePhonelngo()
  325. } else if (app.globalData.type == 'ml') {
  326. // 门店
  327. app.globalData.skipUrl = '/index/searchbar',
  328. app.globalData.skip = 'switchTab'
  329. that.judgePhonelngo()
  330. } else if (that.data.fromflag == 'coupondetail' && that.data.couponChannelIdflag) {
  331. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelIdflag}`,
  332. app.globalData.skip = 'redirectTo'
  333. that.judgePhonelngo()
  334. } else if (that.data.fromflag == 'spellcoupondetail' && that.data.couponChannelIdflag) {
  335. app.globalData.skipUrl = `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelIdflag}`,
  336. app.globalData.skip = 'redirectTo'
  337. that.judgePhonelngo()
  338. } else {
  339. app.globalData.skipUrl = "/index/index",
  340. app.globalData.skip = 'switchTab'
  341. that.judgePhonelngo()
  342. }
  343. }
  344. },
  345. function(error) {
  346. console.log(error)
  347. wx.showToast({
  348. title: "请授权个人信息",
  349. icon: "none"
  350. });
  351. }
  352. )
  353. .catch(err => {
  354. wx.showToast({
  355. title: err.errMsg,
  356. icon: 'none',
  357. duration: 2000,
  358. mask: false
  359. });
  360. })
  361. }
  362. })
  363. },
  364. getGameOne: function(token, id) {
  365. let _this = this;
  366. Http.get({
  367. url: config.api.getOneGame,
  368. data: {
  369. token: token,
  370. id: id
  371. }
  372. }).then(res => {
  373. wx.redirectTo({
  374. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  375. })
  376. })
  377. .catch(err => {
  378. wx.showModal({
  379. title: '提示',
  380. content: err.message,
  381. showCancel: false,
  382. success: function(res) {
  383. // 如果游戏下架或者找不到,重启首页
  384. if (res.confirm) {
  385. wx.reLaunch({
  386. url: '/pages/index/index',
  387. })
  388. }
  389. }
  390. })
  391. this.alphaClick();
  392. })
  393. },
  394. });