C端小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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