C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

308 行
10 KiB

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