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

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