抖音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.

преди 2 години
преди 2 години
преди 2 години
преди 2 години
преди 2 години
преди 2 години
преди 2 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px'
  2. var config = require("../../config/config.js");
  3. const Http = require("../../utils/HttpBasics");
  4. var app = getApp();
  5. Page({
  6. data: {
  7. navigationBarHeight,
  8. canIUse: tt.canIUse("button.open-type.getPhoneNumber"),
  9. couponChannelId: "",
  10. path: null,
  11. paramData: null,
  12. signActivity: "",
  13. mineFlag: null,
  14. skipUrl: 0,
  15. fillIndentId: "",
  16. couponId: "",
  17. // skip: app.globalData.skip
  18. },
  19. onLoad: function(options) {
  20. var that = this;
  21. console.log(options.skipUrl, "options.skipUrl")
  22. if (options.skipUrl) {
  23. that.setData({
  24. skipUrl: options.skipUrl
  25. })
  26. }
  27. that.setData({
  28. path: options.path
  29. })
  30. that.setData({
  31. paramData: options
  32. })
  33. if (options && options.fillIndentId && options.couponId) {
  34. that.setData({
  35. fillIndentId: options.fillIndentId,
  36. couponId: options.couponId
  37. })
  38. }
  39. if (options && options.couponChannelId) {
  40. that.setData({
  41. couponChannelId: options.couponChannelId
  42. });
  43. }
  44. if (options && options.mineFlag) {
  45. that.setData({
  46. mineFlag: options.mineFlag
  47. })
  48. }
  49. if (options && options.signActivity) {
  50. that.setData({
  51. signActivity: options.signActivity
  52. });
  53. }
  54. Http.get({
  55. url: config.api.marketicon,
  56. data: {
  57. appId: app.globalData.appId
  58. }
  59. }).then(res => {
  60. that.setData({
  61. mallImgUrl: res.data.mallImgUrl
  62. });
  63. tt.setNavigationBarTitle({
  64. title: res.data.mallName
  65. })
  66. })
  67. .catch(err => {
  68. tt.showToast({
  69. title: err.errMsg,
  70. icon: 'none',
  71. duration: 2000,
  72. mask: false
  73. });
  74. })
  75. },
  76. onShow: function() {
  77. tt.checkSession({
  78. success() {
  79. //session_key 未过期,并且在本生命周期一直有效
  80. },
  81. fail() {
  82. // session_key 已经失效,需要重新执行登录流程
  83. console.log("session_key 过期")
  84. tt.login({
  85. success: (res) => {
  86. if (res.code) {
  87. let usrdata = {
  88. appId: app.globalData.appId,
  89. code: res.code,
  90. }
  91. Http.post({
  92. url: config.api.login,
  93. data: usrdata
  94. }).then(res => {
  95. Http.setToken(res.data.token);
  96. app.globalData.token = res.data.token;
  97. })
  98. }
  99. }
  100. })
  101. }
  102. })
  103. },
  104. backHome(){
  105. console.log("我调用的返回");
  106. tt.navigateBack({
  107. delta: 1,
  108. success: (res) => {
  109. },
  110. fail: (res) => {
  111. },
  112. });
  113. // tt.reLaunch({
  114. // url: "/pages/index/index",
  115. // success: (res) => {
  116. // },
  117. // fail: (res) => {
  118. // },
  119. // });
  120. },
  121. getPhoneNumber: function(e) {
  122. var that = this;
  123. var iv = e.detail.iv;
  124. var encryptedData = e.detail.encryptedData;
  125. Http.post({
  126. url: config.api.getUserPhone,
  127. data: {
  128. encryptedData: encryptedData,
  129. iv: iv
  130. }
  131. }).then(res => {
  132. app.globalData.phone = res.data.phone;
  133. if (that.data.skipUrl == '1') {
  134. console.log(app.globalData.skip, app.globalData.skipUrl, "跳转地址")
  135. if (app.globalData.skip == 'redirectTo') {
  136. tt.redirectTo({
  137. url: app.globalData.skipUrl,
  138. })
  139. return;
  140. } else if (app.globalData.skip == 'navigateTo') {
  141. tt.navigateTo({
  142. url: app.globalData.skipUrl,
  143. })
  144. return;
  145. } else if (app.globalData.skip == 'reLaunch') {
  146. tt.reLaunch({
  147. url: app.globalData.skipUrl,
  148. })
  149. return;
  150. } else if (app.globalData.skip == 'switchTab') {
  151. tt.redirectTo({
  152. url: app.globalData.skipUrl,
  153. })
  154. return;
  155. }else if (app.globalData.skip == 'navigateBack') {
  156. tt.navigateBack({
  157. delta: 1,
  158. })
  159. return;
  160. }
  161. }
  162. //确认订单
  163. if (that.data.path == "qr") {
  164. tt.redirectTo({
  165. url: `/pages/coupon/confirmation/confirmation?couponChannelId=${that.data.couponChannelId}`
  166. })
  167. }
  168. //线上配送
  169. if (that.data.path == "fi") {
  170. tt.redirectTo({
  171. url: `/pages/fillIndent/fillIndent?id=${that.data.fillIndentId}&couponId=${that.data.couponId}`
  172. })
  173. }
  174. // 来着问卷
  175. if (that.data.path == "wj") {
  176. tt.redirectTo({
  177. url: `/pages/questionnaire/questionnaire?id=${that.data.wjId}`
  178. })
  179. return;
  180. }
  181. /**a
  182. * 来自我的
  183. */
  184. if (that.data.path == 'main') {
  185. tt.redirectTo({
  186. url: `/index/user`
  187. })
  188. return;
  189. }
  190. /**
  191. * 来自积分兑换
  192. */
  193. if (that.data.path == 'jifen') {
  194. tt.redirectTo({
  195. url: `/pages/integralmall/payIntegcoupondetail/index?couponChannelId=${that.data.paramData.couponChannelId}&couponId=${that.data.paramData.couponId}`
  196. })
  197. return;
  198. }
  199. /**
  200. * 来自拼团详情
  201. */
  202. if (that.data.path == 'spell') {
  203. if (that.data.paramData.avatarUrl) {
  204. tt.redirectTo({
  205. url: `/pages/joinFrDpell/index?couponId=${that.data.paramData.couponId}&orderGroupId=${that.data.paramData.orderGroupId}&couponChannelId=${that.data.paramData.couponChannelId}&orderId=${that.data.paramData.orderId}&avatarUrl=${that.data.paramData.avatarUrl}&nickName=${that.data.paramData.nickName}`
  206. })
  207. } else {
  208. tt.redirectTo({
  209. url: `/pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
  210. })
  211. }
  212. return;
  213. }
  214. /**
  215. * fromId若存在来自卡转赠
  216. */
  217. if (that.data.path == 'index' && !that.data.paramData.cuserId) {
  218. tt.redirectTo({
  219. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  220. })
  221. } else if (that.data.path == 'index' && that.data.paramData.cuserId) {
  222. tt.redirectTo({
  223. url: "/pages/coupon/detail/index?cuserId=" + that.data.paramData.cuserId + '&couponChannelId=' + that.data.paramData.couponChannelId + '&coverImg=' + that.data.paramData.coverImg + '&avatarUrl=' + that.data.paramData.avatarUrl + '&userName=' + that.data.paramData.userName + '&couponOrderId=' + that.data.paramData.couponOrderId + "&updateDate=" + that.data.paramData.updateDate
  224. })
  225. }
  226. /**
  227. * 活动报名
  228. */
  229. else if (that.data.signActivity) {
  230. tt.redirectTo({
  231. url: `/pages/radetail/joinActivity/edit?activityId=${that.data.signActivity}`
  232. })
  233. } else if (that.data.mineFlag == 'mine') {
  234. tt.redirectTo({
  235. url: '/index/user'
  236. });
  237. } else if (that.data.mineFlag == 'index') {
  238. tt.redirectTo({
  239. url: app.globalData.goHomeUrl
  240. });
  241. } else {
  242. tt.showToast({
  243. title: res.data.msg,
  244. icon: "success",
  245. success: function(res) {
  246. if (that.data.couponChannelId) {
  247. tt.redirectTo({
  248. url: "/pages/coupon/detail/index?couponChannelId=" + that.data.couponChannelId + "&flag=pay"
  249. })
  250. } else {
  251. tt.redirectTo({
  252. url: '/index/passCar',
  253. })
  254. }
  255. }
  256. });
  257. }
  258. }).catch(err => {
  259. tt.showToast({
  260. title: err.message,
  261. icon: 'none',
  262. duration: 2000,
  263. mask: false
  264. });
  265. })
  266. },
  267. });