抖音c端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

index.js 32 KiB

il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 2 ans
il y a 1 an
il y a 1 an
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 1 an
il y a 1 an
il y a 1 an
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 1 an
il y a 1 an
il y a 1 an
il y a 2 ans
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 1 an
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px'
  2. var config = require("../../../config/config.js");
  3. var app = getApp();
  4. const Http = require("../../../utils/HttpBasics");
  5. const util = require("../../../utils/util");
  6. const imgurl = require("../../../utils/imgurl");
  7. Page({
  8. data: {
  9. priceAndStockObj: {}, //存放价格和库存
  10. isGetUser: true, //判断是否授权抖音
  11. mouldType: 0,
  12. navigationBarHeight,
  13. homeSelectedO: imgurl.homeSelectedO.url,
  14. isshowposter: false, //是否显示分享弹框
  15. fenxiang: imgurl.fenxiang1.url,
  16. fenxiangUrl: imgurl.fenxiang.url,
  17. clockUrl: imgurl.clock.url,
  18. yushouUrl: imgurl.yushou.url,
  19. teljpgUrl: imgurl.teljpg.url,
  20. closedUrl: imgurl.closed.url,
  21. quesGouUrl: imgurl.ques_gou.url,
  22. headbgUrl: imgurl.headbg.url,
  23. quesBgUrl: imgurl.ques_bg.url,
  24. close02: imgurl.close02.url,
  25. share01: imgurl.share01.url,
  26. fail: imgurl.fail.url,
  27. wmhome: imgurl.wmhome.url,
  28. swiperCurrent: 0,
  29. detailPicture: [],
  30. coverPicture: [],
  31. couponList: [],
  32. data: {
  33. title: null
  34. },
  35. showPage: false,
  36. questions1: null,
  37. questions2: null,
  38. carList: [],
  39. couponChannelId: null,
  40. orderId: "",
  41. hour: null,
  42. day: null,
  43. month: null,
  44. year: null,
  45. minute: "",
  46. tempFilePaths: null,
  47. userInfo: {},
  48. hasUserInfo: false,
  49. // canIUse: tt.canIUse('button.open-type.getUserInfo'),
  50. id: null,
  51. result: [],
  52. end_time: null,
  53. checked: false,
  54. questionnaire: {},
  55. questionId: null,
  56. widthScreen: null,
  57. moveData: null,
  58. rotateData: null,
  59. alphaData: null,
  60. scaleData: null,
  61. skewData: null,
  62. matrixData: null,
  63. opacity: 0,
  64. queueData: null,
  65. zIndex: 11,
  66. display: "none",
  67. showbutton: false,
  68. cardData: null,
  69. showCardOffer: false,
  70. isSamePeople: true,
  71. statusText: '',
  72. isReceived: false,
  73. receivedDisabled: false,
  74. clock: "结束",
  75. day: "00",
  76. hour: "00",
  77. min: "00",
  78. sec: "00",
  79. clock02: "00",
  80. day02: "00",
  81. hour02: "00",
  82. min02: "00",
  83. sec02: "00",
  84. countdown: "",
  85. showbutton1: false,
  86. limitCondition: "",
  87. minLimit: 0,
  88. maxLimit: 0,
  89. dispressEndDate: false,
  90. barTitle: "",
  91. activityStatus: "",
  92. //图文混排
  93. curHtml: '',
  94. contentType: 0,
  95. page: 1, //查询商户优惠券page
  96. idList: [],
  97. showBox: false, //手机号授权框
  98. spuIdObj: {},
  99. mallTenantId: '',
  100. mallList: [],
  101. imId: "",
  102. goodId: "",
  103. IMorderId: "",
  104. use_num_per_consume: ""
  105. },
  106. /**
  107. * 显示分享弹框
  108. */
  109. showshare: function () {
  110. this.setData({
  111. isshowposter: true,
  112. })
  113. },
  114. imCallback(e) {
  115. console.log("跳转IM客服成功", e);
  116. },
  117. onimError(e) {
  118. console.log("拉起IM客服失败", e.detail);
  119. },
  120. getIm() { //获取im客服id
  121. const that = this
  122. Http.get({
  123. url: config.api.getIm,
  124. data: {
  125. mallTenantId: this.data.mallTenantId || ''
  126. }
  127. }).then(res => {
  128. console.log(res, 'getIm');
  129. const imId = res.data.imId || ''
  130. that.setData({
  131. imId: imId
  132. })
  133. }).catch(err => {
  134. console.log(err, 'res');
  135. })
  136. },
  137. getCouponList: function (id) { //获取其他活动
  138. let that = this;
  139. let data;
  140. data = {
  141. status: 0,
  142. merchantIds: id,
  143. pageNum: that.data.page,
  144. pageSize: 5,
  145. }
  146. Http.post({
  147. url: config.api.listByMerchant,
  148. data: data
  149. }).then(res => {
  150. if (res.data.page.list <= 0) {
  151. return
  152. }
  153. let dataLsit = []
  154. // dataLsit = that.data.couponList
  155. dataLsit = res.data.page.list
  156. dataLsit.map((item, index) => {
  157. if (item.id == that.data.couponChannelId) {
  158. dataLsit.splice(index, 1)
  159. }
  160. })
  161. if (that.data.page > 1) {
  162. let tmpeLsit = that.data.couponList
  163. tmpeLsit.push(...dataLsit)
  164. that.setData({
  165. couponList: tmpeLsit,
  166. })
  167. } else {
  168. that.setData({
  169. couponList: dataLsit,
  170. })
  171. }
  172. // if (res.data && res.data.qrCode){
  173. // that.setData({
  174. // qrCode: res.data.qrCode,
  175. // })
  176. // }
  177. })
  178. .catch(err => {
  179. tt.showToast({
  180. title: err.errMsg,
  181. icon: 'none',
  182. duration: 2000,
  183. mask: false
  184. });
  185. })
  186. },
  187. setPhone(paramData) { //子组件调用这个方法说明手机号已经授权成功
  188. this.setData({
  189. showBox: paramData.detail,
  190. })
  191. tt.showToast({
  192. title: '授权成功', // 内容
  193. icon: 'none', // 图标
  194. success: (res) => {
  195. },
  196. fail: (res) => {
  197. },
  198. });
  199. },
  200. setBox(paramData) {
  201. this.setData({
  202. showBox: paramData.detail
  203. })
  204. tt.showToast({
  205. title: '取消授权', // 内容
  206. icon: 'none', // 图标
  207. success: (res) => {
  208. },
  209. fail: (res) => {
  210. },
  211. });
  212. },
  213. /**
  214. * 隐藏分享弹框
  215. */
  216. hidemodal: function () {
  217. this.setData({
  218. isshowposter: false,
  219. })
  220. },
  221. /**
  222. * 显示分享海报
  223. */
  224. /* showPoster: function() {
  225. //跳转到海报生成页
  226. console.log(this.data.canIUse)
  227. // return;
  228. tt.navigateTo({
  229. url: `/pages/canvas/index?couponChannelId=${this.data.data.id}`
  230. })
  231. }, */
  232. showPoster: function () {
  233. //跳转到海报生成页
  234. let that = this;
  235. Http.get({
  236. url: config.api.checkUserStatus,
  237. data: {
  238. token: app.globalData.token
  239. }
  240. }).then(res => {
  241. tt.navigateTo({
  242. url: `/pages/canvas/index?couponChannelId=${that.data.data.id}`
  243. })
  244. }).catch(err => {
  245. console.log(err)
  246. if (err.code == 11004) {
  247. // 用户昵称未授权
  248. tt.redirectTo({
  249. url: `/pages/getuserinfo/getuserinfo?couponChannelId=${that.data.data.id}&fromflag=poster`
  250. })
  251. }
  252. })
  253. },
  254. swiperChange: function (e) {
  255. this.setData({
  256. swiperCurrent: e.detail.current
  257. });
  258. },
  259. gohome(e) {
  260. console.log(e.currentTarget.dataset.id, "123")
  261. tt.navigateTo({
  262. url: `/pages/fillIndent/fillIndent?couponChannelId=${e.currentTarget.dataset.couponchannelid}&couponId=${e.currentTarget.dataset.couponid}&shippingtype=${e.currentTarget.dataset.shippingtype}`,
  263. })
  264. },
  265. gochild(e) {
  266. let id = e.currentTarget.dataset.id
  267. tt.navigateTo({
  268. url: `/pages/coupon/childDetail/childDetail?couponIds=${id}`,
  269. })
  270. },
  271. //获取当前登录用户信息
  272. getUserInfo: function () {
  273. let that = this;
  274. // 获取用户信息
  275. Http.get({
  276. url: config.api.getScore,
  277. data: {}
  278. })
  279. .then(res => {
  280. console.log(res)
  281. that.getQueryCardStatus()
  282. if (that.data.cardData.cuserId != res.data.id) {
  283. console.log(2222, 6666)
  284. that.setData({
  285. isSamePeople: false
  286. })
  287. }
  288. })
  289. },
  290. //获取卡转赠状态
  291. getQueryCardStatus() {
  292. let that = this;
  293. let param = {
  294. id: this.data.cardData.couponOrderId,
  295. cUserId: this.data.cardData.cuserId,
  296. updateDate: util.timestampToTime(Number(that.data.cardData.updateDate), "YYYY-MM-DD hh:mm:ss")
  297. }
  298. Http.get({
  299. url: config.api.queryCardStatus,
  300. data: param
  301. })
  302. .then(res => {
  303. console.log(res, 333333333333)
  304. })
  305. .catch(err => {
  306. that.setData({
  307. isReceived: true,
  308. statusText: err.message
  309. })
  310. })
  311. },
  312. receiveCard() {
  313. let that = this;
  314. let param = {
  315. id: this.data.cardData.couponOrderId,
  316. cUserId: this.data.cardData.cuserId,
  317. updateDate: util.timestampToTime(Number(this.data.cardData.updateDate), "YYYY-MM-DD hh:mm:ss")
  318. }
  319. this.setData({
  320. receivedDisabled: true
  321. })
  322. Http.post({
  323. url: config.api.cardAccept,
  324. data: param
  325. })
  326. .then(res => {
  327. tt.showToast({
  328. title: '领取成功!',
  329. icon: 'none',
  330. duration: 2000,
  331. mask: false
  332. });
  333. tt.reLaunch({
  334. url: '/pages/complete/index?couponOrderId=' + this.data.cardData.couponOrderId,
  335. })
  336. })
  337. .catch(err => {
  338. tt.showToast({
  339. title: err.message,
  340. icon: 'none',
  341. duration: 2000,
  342. mask: false
  343. });
  344. that.setData({
  345. receivedDisabled: false
  346. })
  347. })
  348. },
  349. closeAlert() {
  350. this.setData({
  351. showCardOffer: false
  352. })
  353. },
  354. goback: function () {
  355. tt.reLaunch({
  356. url: '/index/index',
  357. })
  358. },
  359. /**
  360. * 点击提交问题单选
  361. */
  362. formSubmit: function (e) {
  363. console.log(e);
  364. let that = this;
  365. /**
  366. * 多选
  367. */
  368. if (e.currentTarget.dataset.flags == 'multi') {
  369. if (that.data.anwserId.length == 0) {
  370. var answserIs = null
  371. } else {
  372. var answserIs = that.data.anwserId.join(",");
  373. }
  374. } else if (e.currentTarget.dataset.flags == 'single') {
  375. var answserIs = e.detail.value;
  376. }
  377. console.log(answserIs)
  378. console.log(e.currentTarget.dataset.questionid)
  379. Http.post({
  380. url: config.api.answerQuestion,
  381. data: {
  382. answer: answserIs,
  383. questionId: e.currentTarget.dataset.questionid
  384. }
  385. })
  386. .then(res => {
  387. that.closeQuestion();
  388. })
  389. .catch(err => {
  390. tt.showToast({
  391. title: err.message,
  392. icon: 'none',
  393. duration: 2000,
  394. mask: false
  395. });
  396. })
  397. },
  398. /**
  399. * 多选
  400. */
  401. checkboxChange: function (e) {
  402. console.log(e)
  403. this.setData({
  404. anwserId: e.detail.value
  405. })
  406. },
  407. closeQuestion: function () {
  408. let that = this;
  409. that.setData({
  410. display: "none",
  411. zIndex: 11,
  412. opacity: 0
  413. })
  414. setTimeout(function () {
  415. that.orderFunc();
  416. }, 500)
  417. },
  418. ifGetUser() {
  419. Http.get({
  420. url: config.api.checkUserStatus,
  421. data: {
  422. token: app.globalData.token
  423. }
  424. }).then(res => {}).catch(err => {
  425. if (err.code == 11004) {
  426. this.setData({
  427. isGetUser: false
  428. })
  429. }
  430. })
  431. },
  432. gotopay: function (e) {
  433. tt.navigateTo({
  434. url: `/pages/coupon/confirmation/confirmation?couponChannelId=${this.data.couponChannelId}&mallTenantId=${this.data.mallTenantId}`,
  435. })
  436. return
  437. },
  438. setIntervalTime(end_time) {
  439. let that = this;
  440. var EndTime = end_time;
  441. var NowTime = new Date().getTime();
  442. var total_micro_second = EndTime - NowTime || [];
  443. // 渲染倒计时时钟
  444. let obj = that.dateformat(total_micro_second);
  445. if (total_micro_second > 0) {
  446. that.setData({
  447. clock: obj,
  448. day: obj.a1,
  449. hour: obj.b1,
  450. min: obj.c1,
  451. sec: obj.d1,
  452. })
  453. } else {
  454. that.setData({
  455. clock: "00",
  456. day: "00",
  457. hour: "00",
  458. min: "00",
  459. sec: "00",
  460. })
  461. //如果倒计时结束,需要重新查询一下券的状态
  462. // 给getDetail一个标识
  463. that.getDetail(that.data.couponChannelId, 'endclock');
  464. }
  465. total_micro_second -= 1000;
  466. },
  467. countdown: function (end_time) {
  468. let that = this;
  469. that.setIntervalTime(end_time);
  470. that.data.setInterval = setInterval(function () {
  471. that.setIntervalTime(end_time);
  472. }, 1000)
  473. },
  474. // 时间格式化输出,如11:03 25:19 每1s都会调用一次
  475. dateformat(micro_second) {
  476. // 总秒数
  477. var second = Math.floor(micro_second / 1000);
  478. // 天数
  479. var day = Math.floor(second / 3600 / 24) < 10 ? "0" + Math.floor(second / 3600 / 24) : Math.floor(second / 3600 / 24);
  480. // 小时
  481. var hr = Math.floor(second / 3600 % 24) < 10 ? "0" + Math.floor(second / 3600 % 24) : Math.floor(second / 3600 % 24);
  482. // 分钟
  483. var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60);
  484. // 秒
  485. var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60);
  486. // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
  487. return {
  488. a1: day,
  489. b1: hr,
  490. c1: min,
  491. d1: sec
  492. }
  493. },
  494. /**
  495. * 获取用户信息
  496. */
  497. onLoad(option) {
  498. let options = null
  499. if (option.params) {
  500. options = JSON.parse(option.params)
  501. } else {
  502. options = option
  503. }
  504. const dealData = options => {
  505. console.log(options, 'options');
  506. if (options.mallTenantId || options.tenantId) {
  507. tt.setStorageSync('locationSwitch', 0);
  508. this.setData({
  509. mallTenantId: options.mallTenantId || options.tenantId,
  510. })
  511. }
  512. Http.get({
  513. url: '/mall/subMall?isAll=1',
  514. }).then(res => {
  515. console.log(res.data, 'subMall');
  516. const mallList = res.data
  517. mallList.forEach((item, index) => {
  518. if (item.tenantId == (options.mallTenantId || options.tenantId)) {
  519. tt.setStorageSync('mallTenantId', options.mallTenantId || options.tenantId)
  520. tt.setStorageSync('mallIndex', index)
  521. }
  522. })
  523. }).catch(err => {})
  524. this.setData({
  525. mouldType: app.globalData.mouldType,
  526. })
  527. let that = this;
  528. if (options.g) {
  529. app.globalData.havePlayEd1 = true;
  530. }
  531. tt.showLoading({
  532. title: "加载中..."
  533. });
  534. that.setData({
  535. onshow: false
  536. })
  537. if (options && (options.couponChannelId || options.couponIds)) {
  538. if (options.couponIds) {
  539. this.setData({
  540. couponIds: options.couponIds
  541. })
  542. that.getDetail(options.couponIds, 'notendclock');
  543. } else {
  544. that.getDetail(options.couponChannelId, 'notendclock');
  545. that.getSupId(options.couponChannelId)
  546. }
  547. }
  548. /**
  549. * 转赠判断
  550. */
  551. if (options.cuserId) {
  552. this.setData({
  553. showCardOffer: true,
  554. cardData: options
  555. })
  556. this.getUserInfo()
  557. }
  558. that.setData({
  559. couponChannelId: options.couponChannelId,
  560. title: that.data.data.title ? that.data.data.title : '',
  561. });
  562. if (options.cardType) {
  563. that.setData({
  564. cardType: options.cardType
  565. })
  566. }
  567. }
  568. if (app.globalData.token) {
  569. dealData(options)
  570. } else {
  571. app.tokenCallback = token => {
  572. dealData(options)
  573. }
  574. }
  575. },
  576. getHtml(couponChannelId) {
  577. Http.get({
  578. url: config.api.couponHtmlDetail,
  579. data: {
  580. couponChannelId: couponChannelId
  581. }
  582. }).then(res => {
  583. console.log(res)
  584. if (res.code == 200 && res.data.html) {
  585. this.setData({
  586. curHtml: decodeURI(res.data.html)
  587. })
  588. app.globalData.curHtml = this.data.curHtml;
  589. console.log(app.globalData.curHtml)
  590. }
  591. })
  592. },
  593. getSupId(id) {
  594. Http.get({
  595. url: config.api.getSpuid,
  596. data: {
  597. id: id,
  598. mallTenantId: this.data.mallTenantId || ''
  599. }
  600. }).then(res => {
  601. if (res.data) {
  602. this.setData({
  603. spuIdObj: res.data,
  604. goodId: res.data.spuId
  605. })
  606. }
  607. }).catch(err => {
  608. // tt.showToast({
  609. // title: err.message,
  610. // icon: 'none',
  611. // duration: 2000,
  612. // mask: false
  613. // });
  614. })
  615. },
  616. getCouponPriceAndStock(couponChannelId) { //获取券价格与库存
  617. Http.get({
  618. url: config.api.couponPriceAndStock,
  619. data: {
  620. couponChannelId,
  621. mallTenantId: this.data.mallTenantId || ''
  622. }
  623. }).then(res => {
  624. let tempBoj = JSON.parse(res.data)
  625. console.log(tempBoj, "$");
  626. this.setData({
  627. priceAndStockObj: tempBoj
  628. })
  629. })
  630. },
  631. getCouponMerchant(couponChannelId) { //获取适用门店
  632. Http.get({
  633. url: config.api.couponMerchant,
  634. data: {
  635. couponChannelId: couponChannelId,
  636. mallTenantId: this.data.mallTenantId || ''
  637. }
  638. }).then(res => {
  639. const keys = Object.keys(res.data)
  640. const mallList = []
  641. let i = 0
  642. keys.forEach(item => {
  643. const arr = item.split('|')
  644. const obj = {
  645. tenantId: arr[0],
  646. mallName: arr[1],
  647. merchantVoList: res.data[item],
  648. expand: false
  649. }
  650. if (i == 0) {
  651. obj.expand = true
  652. }
  653. mallList.push(obj)
  654. i++
  655. })
  656. this.setData({
  657. mallList: mallList
  658. })
  659. })
  660. },
  661. getDetail: function (couponChannelId, flag) {
  662. let that = this;
  663. let data = {};
  664. that.getCouponMerchant(couponChannelId); //获取适用门店
  665. that.getCouponPriceAndStock(couponChannelId); //获取券价格和库存
  666. if (that.data.couponIds) {
  667. data.couponId = couponChannelId
  668. } else {
  669. data.couponChannelId = couponChannelId
  670. }
  671. if (that.data.mallTenantId) {
  672. data.mallTenantId = that.data.mallTenantId
  673. }
  674. var parmer = {
  675. url: config.api.newCouponDetail,
  676. data: data
  677. };
  678. Http.get(parmer)
  679. .then(res => {
  680. //aaa
  681. if (res.data.contentType != undefined && res.data.contentType == 1) {
  682. //获取图文展示详情html
  683. this.setData({
  684. contentType: res.data.contentType
  685. })
  686. this.getHtml(couponChannelId);
  687. }
  688. that.setData({
  689. couponId: res.data.couponId
  690. })
  691. that.setData({
  692. showPage: true
  693. })
  694. if (res && res.data && res.data.detailPicture) {
  695. that.setData({
  696. detailPicture: JSON.parse(res.data.detailPicture)
  697. })
  698. }
  699. if (res && res.data && res.data.coverPicture) {
  700. that.setData({
  701. coverPicture: JSON.parse(res.data.coverPicture)
  702. })
  703. }
  704. if (res && res.data && res.data.conditions) {
  705. that.setData({
  706. limitCondition: JSON.parse(res.data.conditions).type
  707. })
  708. if (JSON.parse(res.data.conditions).type == 2 && (JSON.parse(res.data.conditions).min || JSON.parse(res.data.conditions).min == 0)) {
  709. that.setData({
  710. minLimit: JSON.parse(res.data.conditions).min
  711. })
  712. }
  713. if (JSON.parse(res.data.conditions).type == 2 && (JSON.parse(res.data.conditions).max) || JSON.parse(res.data.conditions).max == 0) {
  714. that.setData({
  715. maxLimit: JSON.parse(res.data.conditions).max
  716. })
  717. }
  718. }
  719. /**
  720. * 将优惠券优惠卡的详情的BarTitle
  721. * 设置成券的名称
  722. */
  723. // tt.setNavigationBarTitle({
  724. // title: res.data.title
  725. // })
  726. that.setData({
  727. barTitle: res.data.title
  728. })
  729. tt.setNavigationBarTitle({
  730. title: res.data.title,
  731. success() {
  732. console.log("setNavigationBarTitle 调用成功");
  733. },
  734. fail(res) {
  735. console.log(`setNavigationBarTitle 调用失败:`, res.errMsg);
  736. },
  737. });
  738. var EndTime = res.data.validStartDate;
  739. var NowTime = new Date().getTime();
  740. /**
  741. * activityStatus==0 活动未开始
  742. * activityStatus==1 活动已开始
  743. * flag == endclock 说明倒计时已经结束
  744. */
  745. if (res.data.endTime && res.data.beginTime) {
  746. that.setData({
  747. begin_time: res.data.beginTime,
  748. end_time: res.data.endTime,
  749. activityStatus: res.data.actStatus ? res.data.actStatus : ''
  750. })
  751. if (res.data.actStatus == 0 && flag != 'endclock') {
  752. that.countdown(res.data.beginTime);
  753. } else if (res.data.actStatus != 0 && flag != 'endclock') {
  754. that.countdown(res.data.endTime);
  755. } else {
  756. clearInterval(that.data.setInterval)
  757. }
  758. if (res.data.actStatus == 0) {
  759. var beginTime = util.timestampToTime(res.data.beginTime, "YYYY-MM-DD hh:mm:ss");
  760. if (util.timechuo(beginTime).indexOf('-') == 0) {
  761. that.setData({
  762. beginTime: "活动已结束",
  763. });
  764. } else {
  765. that.setData({
  766. beginTime: util.timechuo(beginTime)
  767. });
  768. }
  769. } else {
  770. var endTime = util.timestampToTime(res.data.endTime, "YYYY-MM-DD hh:mm:ss");
  771. if (util.timechuo(endTime).indexOf('-') == 0) {
  772. that.setData({
  773. endtime: "活动已结束",
  774. });
  775. } else {
  776. that.setData({
  777. endtime: util.timechuo(endTime)
  778. });
  779. }
  780. }
  781. }
  782. tt.hideLoading();
  783. that.setData({
  784. data: res.data,
  785. });
  786. if (res.data.type == 10) {
  787. that.setData({
  788. salePriceStr: res.data.salePriceStr,
  789. pickEndDate: util.timestampToTime(res.data.pickEndDate, "YYYY-MM-DD"),
  790. pickStartDate: util.timestampToTime(res.data.pickStartDate, "YYYY-MM-DD"),
  791. priceStr: res.data.priceStr,
  792. tailPriceStr: res.data.tailPriceStr,
  793. origPriceStr: res.data.origPriceStr
  794. })
  795. }
  796. if (res.data.validType == 1) {
  797. that.setData({
  798. soldStartTime: util.timestampToTime(res.data.soldStartTime, "YYYY-MM-DD") || null,
  799. soldEndTime: util.timestampToTime(res.data.soldEndTime, "YYYY-MM-DD") || null,
  800. validStartDate: util.timestampToTime(res.data.validStartDate, "YYYY-MM-DD"),
  801. validEndDate: util.timestampToTime(res.data.validEndDate, "YYYY-MM-DD"),
  802. pickStartDate: util.timestampToTime(res.data.pickStartDate, "YYYY-MM-DD"),
  803. pickEndDate: util.timestampToTime(res.data.pickEndDate, "YYYY-MM-DD"),
  804. });
  805. } else {
  806. if (res.data.validDays) {
  807. that.setData({
  808. validDays: res.data.validDays
  809. });
  810. }
  811. }
  812. if (res.data.itemGroup) {
  813. let tempObj = this.data.data
  814. tempObj.itemGroup = JSON.parse(tempObj.itemGroup)
  815. this.setData({
  816. data: tempObj
  817. })
  818. console.log(this.data.data, "data");
  819. }
  820. if (res.data.productAttrs && res.data.skuAttrs) {
  821. let tempObj = this.data.data
  822. tempObj.productAttrs = JSON.parse(tempObj.productAttrs)
  823. tempObj.skuAttrs = JSON.parse(tempObj.skuAttrs)
  824. tempObj.productAttrs.map(item => {
  825. if (item.key == "appointment") {
  826. let tempAppoinObj = JSON.parse(item.data)
  827. if (tempAppoinObj.need_appointment) {
  828. let subscribeSing = "";
  829. if (tempAppoinObj.ahead_time_type == 1) {
  830. subscribeSing = `需提前${tempAppoinObj.ahead_day_num}天预约`
  831. } else if (tempAppoinObj.ahead_time_type == 2) {
  832. subscribeSing = `需提前${tempAppoinObj.ahead_hour_num}小时预约`
  833. } else if (tempAppoinObj.ahead_time_type == 3) {
  834. subscribeSing = `需提前${tempAppoinObj.ahead_minute_num}分钟预约`
  835. }
  836. tempObj.subscribeSing = subscribeSing
  837. }
  838. }
  839. if (item.key == "limit_use_rule") {
  840. console.log(item, 'item');
  841. if (item.data != '') {
  842. let tempAppoinObj = JSON.parse(item.data)
  843. that.setData({
  844. use_num_per_consume: tempAppoinObj.use_num_per_consume || ""
  845. })
  846. }
  847. }
  848. if (item.key == "Notification") {
  849. if (item.data != '') {
  850. tempObj.curLsit = JSON.parse(item.data)
  851. }
  852. }
  853. if (item.key == "bring_out_meal") {
  854. tempObj.besides = item.data
  855. }
  856. if (item.key == "free_pack") {
  857. tempObj.pack = item.data
  858. }
  859. if (item.key == "superimposed_discounts") {
  860. tempObj.superimposed_discounts = item.data
  861. }
  862. if (item.key == "private_room") {
  863. tempObj.private_room = item.data
  864. }
  865. if (item.key == "rec_person_num_max") {
  866. tempObj.rec_person_num_max = item.data
  867. }
  868. if (item.key == 'Description' && item.isRequired) {
  869. tempObj.Description = JSON.parse(item.data)
  870. }
  871. if (item.key == "can_no_use_date") {
  872. tempObj.can_no_use_date = JSON.parse(item.data)
  873. }
  874. })
  875. tempObj.skuAttrs.map(item => {
  876. if (item.key == "commodity" && item.data) {
  877. tempObj.itemGroup = JSON.parse(item.data)
  878. }
  879. })
  880. this.setData({
  881. data: tempObj
  882. })
  883. console.log(this.data.data, "data");
  884. const mallTenantId = this.data.data.tenantId
  885. tt.setStorageSync('mallTenantId', mallTenantId)
  886. }
  887. }).catch(err => {
  888. console.log(err, 'err');
  889. tt.showToast({
  890. title: err.message,
  891. icon: 'none',
  892. duration: 2000,
  893. mask: false
  894. });
  895. })
  896. },
  897. /**
  898. * 邀请好友继续砍价
  899. */
  900. inviteFriend: function (e) {
  901. let that = this;
  902. let formId = e.detail.formId;
  903. that.setData({
  904. formId: formId,
  905. showbutton1: true
  906. })
  907. that.orderFunc("discount");
  908. },
  909. /**
  910. * 支付订单更新
  911. */
  912. payOrderUpdate: (orderId, payOrderId, status, reason, type, _this, composeOrderType) => {
  913. let that = this;
  914. // 支付成功
  915. Http.post({
  916. url: config.api.payOrderUpdate,
  917. data: {
  918. payOrderId: payOrderId,
  919. composeOrderId: orderId,
  920. status: status,
  921. reason: reason,
  922. mallTenantId: this.data.mallTenantId || ''
  923. }
  924. })
  925. .then(res => {
  926. tt.hideLoading()
  927. // 有价券
  928. if (!type && type != 'free') {
  929. tt.navigateTo({
  930. url: `/pages/order/detail/index?orderId=${orderId
  931. }`
  932. });
  933. } else if (type == 'free') {
  934. tt.navigateTo({
  935. url: `/pages/order/detail/index?orderId=${orderId
  936. }`
  937. });
  938. }
  939. })
  940. .catch(err => {
  941. console.log(err);
  942. if (!type) {
  943. setTimeout(function () {
  944. _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this, composeOrderType);
  945. }, 2000)
  946. }
  947. })
  948. },
  949. checkPhoneStatus: function () {
  950. let that = this;
  951. Http.get({
  952. url: config.api.checkPhoneStatus,
  953. data: {}
  954. })
  955. .then(res => {
  956. console.log(666, '授权成功!')
  957. that.receiveCard()
  958. })
  959. .catch(err => {
  960. if (err.code == 11005) {
  961. /**
  962. * 手机号没有授权,将值传到用户手机号授权的页面
  963. *
  964. */
  965. tt.redirectTo({
  966. url: "/pages/getphoneInfo/index?path=index&cuserId=" + that.data.cardData.cuserId + "&couponChannelId=" + that.data.cardData.couponChannelId + "&userName=" + that.data.cardData.userName + "&coverImg=" + that.data.cardData.coverImg + "&avatarUrl=" + that.data.cardData.avatarUrl + "&couponOrderId=" + that.data.cardData.couponOrderId + "&updateDate=" + that.data.cardData.updateDate
  967. });
  968. } else if (err.code == 11006) {
  969. // 用户手机已加密
  970. tt.redirectTo({
  971. url: "/pages/phoneinput/phoneinput?path=index&cuserId=" + that.data.cardData.cuserId + "&couponChannelId=" + that.data.cardData.couponChannelId + "&userName=" + that.data.cardData.userName + "&coverImg=" + that.data.cardData.coverImg + "&avatarUrl=" + that.data.cardData.avatarUrl + "&couponOrderId=" + that.data.cardData.couponOrderId + "&updateDate=" + that.data.cardData.updateDate,
  972. });
  973. } else {
  974. tt.showToast({
  975. title: err.message,
  976. icon: 'none',
  977. duration: 2000,
  978. mask: false
  979. });
  980. }
  981. })
  982. },
  983. // 券包支付
  984. /**
  985. * 发起支付
  986. */
  987. orderFunc(discount) {
  988. tt.navigateTo({
  989. url: `/pages/coupon/confirmation/confirmation?couponChannelId=${this.data.couponChannelId}`,
  990. })
  991. // return
  992. },
  993. // 获得未支付的订单
  994. getUnPaidOrder(couponId) {
  995. let that = this;
  996. Http.get({
  997. url: config.api.getUnPaidOrder,
  998. data: {
  999. couponId: couponId
  1000. }
  1001. }).then(res => {
  1002. that.setData({
  1003. disOrderNumber: res.data.orderNumber,
  1004. composeOrderType: res.data.composeOrderType
  1005. })
  1006. if (res.data && res.data.pressEndDate) {
  1007. that.setData({
  1008. dispressEndDate: true
  1009. })
  1010. } else {
  1011. that.setData({
  1012. dispressEndDate: false
  1013. })
  1014. }
  1015. if (that.data.dispressEndDate) {
  1016. tt.showModal({
  1017. title: '提示',
  1018. content: "您有未支付订单,请到“我的-我的砍价”进行支付",
  1019. confirmText: "我的砍价",
  1020. success: function (res) {
  1021. if (res.confirm) {
  1022. tt.navigateTo({
  1023. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.disOrderNumber}&composeOrderType=${that.data.composeOrderType}`,
  1024. })
  1025. }
  1026. }
  1027. })
  1028. } else {
  1029. tt.showModal({
  1030. title: '提示',
  1031. content: '您有未支付订单,请先进行支付',
  1032. confirmText: "去支付",
  1033. success: function (res1) {
  1034. if (res1.confirm) {
  1035. if (that.data.composeOrderType > 0) { //券包
  1036. tt.navigateTo({
  1037. url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}`,
  1038. })
  1039. } else {
  1040. tt.navigateTo({
  1041. url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}`,
  1042. })
  1043. }
  1044. }
  1045. }
  1046. })
  1047. }
  1048. }).catch(error => {
  1049. tt.showToast({
  1050. title: error.message,
  1051. icon: "none",
  1052. duration: 3000
  1053. })
  1054. })
  1055. },
  1056. onShow() {
  1057. this.ifGetUser() //判断是否授权抖音
  1058. this.getIm()
  1059. this.setData({
  1060. mouldType: app.globalData.mouldType,
  1061. showbutton: false,
  1062. showbutton1: false
  1063. })
  1064. if (this.data.end_time && this.data.activityStatus != 0) {
  1065. this.countdown(this.data.end_time)
  1066. } else if (this.data.begin_time && this.data.activityStatus == 0) {
  1067. this.countdown(this.data.begin_time)
  1068. }
  1069. },
  1070. onUnload: function () {
  1071. let that = this;
  1072. clearInterval(that.data.setInterval)
  1073. },
  1074. onHide: function () {
  1075. let that = this;
  1076. clearInterval(that.data.setInterval)
  1077. },
  1078. onShareAppMessage: function (options) {
  1079. app.globalData.previewFlag = true
  1080. var that = this;
  1081. console.log(options)
  1082. var shareObj = {
  1083. title: that.data.data.title,
  1084. path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}`,
  1085. success: function (res) {
  1086. if (res.errMsg == 'shareAppMessage:ok') {}
  1087. },
  1088. fail: function (err) {
  1089. // if (err.errMsg == 'shareAppMessage:fail cancel') { } else if (err.errMsg == 'shareAppMessage:fail') { }
  1090. }
  1091. };
  1092. // 来自页面内的按钮的转发
  1093. if (options.from == 'button' && options.channel != 'video') {
  1094. var eData = options.target.dataset.id;
  1095. shareObj.path = `/pages/index/index?couponChannelId=${eData}&frommd=JC`;
  1096. } else
  1097. if (options.channel == 'video') {
  1098. // return {
  1099. // channel: 'video', // 必写 video
  1100. //     templateId: '',   // 分享的模版 id (如果未设置就是默认,下面会说如何设置)
  1101. // title: `${that.data.barTitle}`,     // 分享的标题
  1102. // desc: `${that.data.data.dyTitle}`,     // 分享的内容介绍目前没有用
  1103. //     path: `/pages/index/index`,  // 分享的路径
  1104. // extra: {
  1105. // videoTopics: [ that.data.data.dyTitle] // 只有抖音才会有的属性
  1106. // },
  1107. // }
  1108. shareObj.channel = 'video';
  1109. shareObj.title = `${that.data.data.title}`;
  1110. shareObj.extra = {
  1111. spu_id: that.data.spuIdObj.spuId
  1112. }
  1113. }
  1114. console.log(shareObj)
  1115. // 返回shareObj
  1116. return shareObj;
  1117. },
  1118. // onShareAppMessage: function(e) {
  1119. // console.log("onShareAppMessage", e);
  1120. // return {
  1121. // channel: 'video',
  1122. // title: "测试小程序分享",
  1123. // desc: "这是默认的分享文案,用户可以直接发送,也可以在发布器内修改",
  1124. // extra: {
  1125. // spu_id:"7091460633887279111" //开发者在抖音开放平台设置的商品id
  1126. // },
  1127. // success: function(e) {
  1128. // console.log("分享成功");
  1129. // },
  1130. // fail: function(e) {
  1131. // console.log(e,"分享成功失败")
  1132. // }
  1133. // };
  1134. // },
  1135. // 下拉刷新
  1136. onPullDownRefresh: function () {
  1137. this.getDetail(this.data.couponChannelId);
  1138. tt.stopPullDownRefresh()
  1139. },
  1140. onReachBottom: function () {
  1141. this.setData({
  1142. page: this.data.page + 1
  1143. })
  1144. if (this.data.idList.length > 0) {
  1145. this.getCouponList(this.data.idList)
  1146. }
  1147. }
  1148. });