C端小程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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