C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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