C端小程序
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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