抖音c端
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

1132 líneas
31 KiB

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