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

1126 行
30 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 || options.tenantId) {
  473. this.setData({
  474. mallTenantId: options.mallTenantId || options.tenantId,
  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. mallTenantId: this.data.mallTenantId || ''
  544. }
  545. }).then(res => {
  546. if (res.data) {
  547. this.setData({
  548. spuIdObj: res.data
  549. })
  550. }
  551. }).catch(err => {
  552. // tt.showToast({
  553. // title: err.message,
  554. // icon: 'none',
  555. // duration: 2000,
  556. // mask: false
  557. // });
  558. })
  559. },
  560. getCouponPriceAndStock(couponChannelId) { //获取券价格与库存
  561. Http.get({
  562. url: config.api.couponPriceAndStock,
  563. data: {
  564. couponChannelId,
  565. mallTenantId: this.data.mallTenantId || ''
  566. }
  567. }).then(res => {
  568. let tempBoj = JSON.parse(res.data)
  569. console.log(tempBoj, "$");
  570. this.setData({
  571. priceAndStockObj: tempBoj
  572. })
  573. })
  574. },
  575. getCouponMerchant(couponChannelId) { //获取适用门店
  576. Http.get({
  577. url: config.api.couponMerchant,
  578. data: {
  579. couponChannelId: couponChannelId,
  580. mallTenantId: this.data.mallTenantId || ''
  581. }
  582. }).then(res => {
  583. const keys = Object.keys(res.data)
  584. const mallList = []
  585. let i = 0
  586. keys.forEach(item => {
  587. const arr = item.split('|')
  588. const obj = {
  589. tenantId: arr[0],
  590. mallName: arr[1],
  591. merchantVoList: res.data[item],
  592. expand: false
  593. }
  594. if (i == 0) {
  595. obj.expand = true
  596. }
  597. mallList.push(obj)
  598. i++
  599. })
  600. this.setData({
  601. mallList: mallList
  602. })
  603. })
  604. },
  605. getDetail: function (couponChannelId, flag) {
  606. let that = this;
  607. let data = {};
  608. that.getCouponMerchant(couponChannelId); //获取适用门店
  609. that.getCouponPriceAndStock(couponChannelId); //获取券价格和库存
  610. if (that.data.couponIds) {
  611. data.couponId = couponChannelId
  612. } else {
  613. data.couponChannelId = couponChannelId
  614. }
  615. if (that.data.mallTenantId) {
  616. data.mallTenantId = that.data.mallTenantId
  617. }
  618. var parmer = {
  619. url: config.api.newCouponDetail,
  620. data: data
  621. };
  622. Http.get(parmer)
  623. .then(res => {
  624. //aaa
  625. if (res.data.contentType != undefined && res.data.contentType == 1) {
  626. //获取图文展示详情html
  627. this.setData({
  628. contentType: res.data.contentType
  629. })
  630. this.getHtml(couponChannelId);
  631. }
  632. that.setData({
  633. couponId: res.data.couponId
  634. })
  635. that.setData({
  636. showPage: true
  637. })
  638. if (res && res.data && res.data.detailPicture) {
  639. that.setData({
  640. detailPicture: JSON.parse(res.data.detailPicture)
  641. })
  642. }
  643. if (res && res.data && res.data.coverPicture) {
  644. that.setData({
  645. coverPicture: JSON.parse(res.data.coverPicture)
  646. })
  647. }
  648. if (res && res.data && res.data.conditions) {
  649. that.setData({
  650. limitCondition: JSON.parse(res.data.conditions).type
  651. })
  652. if (JSON.parse(res.data.conditions).type == 2 && (JSON.parse(res.data.conditions).min || JSON.parse(res.data.conditions).min == 0)) {
  653. that.setData({
  654. minLimit: JSON.parse(res.data.conditions).min
  655. })
  656. }
  657. if (JSON.parse(res.data.conditions).type == 2 && (JSON.parse(res.data.conditions).max) || JSON.parse(res.data.conditions).max == 0) {
  658. that.setData({
  659. maxLimit: JSON.parse(res.data.conditions).max
  660. })
  661. }
  662. }
  663. /**
  664. * 将优惠券优惠卡的详情的BarTitle
  665. * 设置成券的名称
  666. */
  667. // tt.setNavigationBarTitle({
  668. // title: res.data.title
  669. // })
  670. that.setData({
  671. barTitle: res.data.title
  672. })
  673. tt.setNavigationBarTitle({
  674. title: res.data.title,
  675. success() {
  676. console.log("setNavigationBarTitle 调用成功");
  677. },
  678. fail(res) {
  679. console.log(`setNavigationBarTitle 调用失败:`, res.errMsg);
  680. },
  681. });
  682. var EndTime = res.data.validStartDate;
  683. var NowTime = new Date().getTime();
  684. /**
  685. * activityStatus==0 活动未开始
  686. * activityStatus==1 活动已开始
  687. * flag == endclock 说明倒计时已经结束
  688. */
  689. if (res.data.endTime && res.data.beginTime) {
  690. that.setData({
  691. begin_time: res.data.beginTime,
  692. end_time: res.data.endTime,
  693. activityStatus: res.data.actStatus ? res.data.actStatus : ''
  694. })
  695. if (res.data.actStatus == 0 && flag != 'endclock') {
  696. that.countdown(res.data.beginTime);
  697. } else if (res.data.actStatus != 0 && flag != 'endclock') {
  698. that.countdown(res.data.endTime);
  699. } else {
  700. clearInterval(that.data.setInterval)
  701. }
  702. if (res.data.actStatus == 0) {
  703. var beginTime = util.formatTime(res.data.beginTime, "yyyy-MM-dd hh:mm:ss");
  704. if (util.timechuo(beginTime).indexOf('-') == 0) {
  705. that.setData({
  706. beginTime: "活动已结束",
  707. });
  708. } else {
  709. that.setData({
  710. beginTime: util.timechuo(beginTime)
  711. });
  712. }
  713. } else {
  714. var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss");
  715. if (util.timechuo(endTime).indexOf('-') == 0) {
  716. that.setData({
  717. endtime: "活动已结束",
  718. });
  719. } else {
  720. that.setData({
  721. endtime: util.timechuo(endTime)
  722. });
  723. }
  724. }
  725. }
  726. tt.hideLoading();
  727. that.setData({
  728. data: res.data,
  729. });
  730. if (res.data.type == 10) {
  731. that.setData({
  732. salePriceStr: res.data.salePriceStr,
  733. pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
  734. pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
  735. priceStr: res.data.priceStr,
  736. tailPriceStr: res.data.tailPriceStr,
  737. origPriceStr: res.data.origPriceStr
  738. })
  739. }
  740. if (res.data.validType == 1) {
  741. that.setData({
  742. validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dd"),
  743. validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dd"),
  744. pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
  745. pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
  746. });
  747. } else {
  748. if (res.data.validDays) {
  749. that.setData({
  750. validDays: res.data.validDays
  751. });
  752. }
  753. }
  754. if (res.data.itemGroup) {
  755. let tempObj = this.data.data
  756. tempObj.itemGroup = JSON.parse(tempObj.itemGroup)
  757. this.setData({
  758. data: tempObj
  759. })
  760. console.log(this.data.data, "data");
  761. }
  762. if (res.data.productAttrs && res.data.skuAttrs) {
  763. let tempObj = this.data.data
  764. tempObj.productAttrs = JSON.parse(tempObj.productAttrs)
  765. tempObj.skuAttrs = JSON.parse(tempObj.skuAttrs)
  766. tempObj.productAttrs.map(item => {
  767. if (item.key == "appointment") {
  768. let tempAppoinObj = JSON.parse(item.data)
  769. if (tempAppoinObj.need_appointment) {
  770. let subscribeSing = "";
  771. if (tempAppoinObj.ahead_time_type == 1) {
  772. subscribeSing = `需提前${tempAppoinObj.ahead_day_num}天致电商家预约`
  773. } else if (tempAppoinObj.ahead_time_type == 2) {
  774. subscribeSing = `需提前${tempAppoinObj.ahead_hour_num}小时致电商家预约`
  775. } else if (tempAppoinObj.ahead_time_type == 3) {
  776. subscribeSing = `需提前${tempAppoinObj.ahead_minute_num}分钟致电商家预约`
  777. }
  778. tempObj.subscribeSing = subscribeSing
  779. }
  780. }
  781. if (item.key == "Notification") {
  782. if (item.data != '') {
  783. tempObj.curLsit = JSON.parse(item.data)
  784. }
  785. }
  786. if (item.key == "bring_out_meal") {
  787. tempObj.besides = item.data
  788. }
  789. if (item.key == "free_pack") {
  790. tempObj.pack = item.data
  791. }
  792. if (item.key == "superimposed_discounts") {
  793. tempObj.superimposed_discounts = item.data
  794. }
  795. if (item.key == "private_room") {
  796. tempObj.private_room = item.data
  797. }
  798. if (item.key == "rec_person_num_max") {
  799. tempObj.rec_person_num_max = item.data
  800. }
  801. if (item.key == 'Description') {
  802. tempObj.Description = JSON.parse(item.data)
  803. }
  804. if (item.key == "can_no_use_date") {
  805. tempObj.can_no_use_date = JSON.parse(item.data)
  806. }
  807. })
  808. tempObj.skuAttrs.map(item => {
  809. if (item.key == "commodity" && item.data) {
  810. tempObj.itemGroup = JSON.parse(item.data)
  811. }
  812. })
  813. this.setData({
  814. data: tempObj
  815. })
  816. console.log(this.data.data, "data");
  817. const mallTenantId = this.data.data.tenantId
  818. tt.setStorageSync('mallTenantId', mallTenantId)
  819. }
  820. }).catch(err => {
  821. tt.showToast({
  822. title: err.message,
  823. icon: 'none',
  824. duration: 2000,
  825. mask: false
  826. });
  827. })
  828. },
  829. /**
  830. * 邀请好友继续砍价
  831. */
  832. inviteFriend: function (e) {
  833. let that = this;
  834. let formId = e.detail.formId;
  835. that.setData({
  836. formId: formId,
  837. showbutton1: true
  838. })
  839. that.orderFunc("discount");
  840. },
  841. /**
  842. * 支付订单更新
  843. */
  844. payOrderUpdate: (orderId, payOrderId, status, reason, type, _this, composeOrderType) => {
  845. let that = this;
  846. // 支付成功
  847. Http.post({
  848. url: config.api.payOrderUpdate,
  849. data: {
  850. payOrderId: payOrderId,
  851. composeOrderId: orderId,
  852. status: status,
  853. reason: reason,
  854. mallTenantId: this.data.mallTenantId || ''
  855. }
  856. })
  857. .then(res => {
  858. tt.hideLoading()
  859. // 有价券
  860. if (!type && type != 'free') {
  861. tt.navigateTo({
  862. url: `/pages/order/detail/index?orderId=${orderId
  863. }`
  864. });
  865. } else if (type == 'free') {
  866. tt.navigateTo({
  867. url: `/pages/order/detail/index?orderId=${orderId
  868. }`
  869. });
  870. }
  871. })
  872. .catch(err => {
  873. console.log(err);
  874. if (!type) {
  875. setTimeout(function () {
  876. _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this, composeOrderType);
  877. }, 2000)
  878. }
  879. })
  880. },
  881. checkPhoneStatus: function () {
  882. let that = this;
  883. Http.get({
  884. url: config.api.checkPhoneStatus,
  885. data: {}
  886. })
  887. .then(res => {
  888. console.log(666, '授权成功!')
  889. that.receiveCard()
  890. })
  891. .catch(err => {
  892. if (err.code == 11005) {
  893. /**
  894. * 手机号没有授权,将值传到用户手机号授权的页面
  895. *
  896. */
  897. tt.redirectTo({
  898. 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
  899. });
  900. } else if (err.code == 11006) {
  901. // 用户手机已加密
  902. tt.redirectTo({
  903. 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,
  904. });
  905. } else {
  906. tt.showToast({
  907. title: err.message,
  908. icon: 'none',
  909. duration: 2000,
  910. mask: false
  911. });
  912. }
  913. })
  914. },
  915. // 券包支付
  916. /**
  917. * 发起支付
  918. */
  919. orderFunc(discount) {
  920. tt.navigateTo({
  921. url: `/pages/coupon/confirmation/confirmation?couponChannelId=${this.data.couponChannelId}`,
  922. })
  923. // return
  924. },
  925. // 获得未支付的订单
  926. getUnPaidOrder(couponId) {
  927. let that = this;
  928. Http.get({
  929. url: config.api.getUnPaidOrder,
  930. data: {
  931. couponId: couponId
  932. }
  933. }).then(res => {
  934. that.setData({
  935. disOrderNumber: res.data.orderNumber,
  936. composeOrderType: res.data.composeOrderType
  937. })
  938. if (res.data && res.data.pressEndDate) {
  939. that.setData({
  940. dispressEndDate: true
  941. })
  942. } else {
  943. that.setData({
  944. dispressEndDate: false
  945. })
  946. }
  947. if (that.data.dispressEndDate) {
  948. tt.showModal({
  949. title: '提示',
  950. content: "您有未支付订单,请到“我的-我的砍价”进行支付",
  951. confirmText: "我的砍价",
  952. success: function (res) {
  953. if (res.confirm) {
  954. tt.navigateTo({
  955. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.disOrderNumber}&composeOrderType=${that.data.composeOrderType}`,
  956. })
  957. }
  958. }
  959. })
  960. } else {
  961. tt.showModal({
  962. title: '提示',
  963. content: '您有未支付订单,请先进行支付',
  964. confirmText: "去支付",
  965. success: function (res1) {
  966. if (res1.confirm) {
  967. if (that.data.composeOrderType > 0) { //券包
  968. tt.navigateTo({
  969. url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}`,
  970. })
  971. } else {
  972. tt.navigateTo({
  973. url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}`,
  974. })
  975. }
  976. }
  977. }
  978. })
  979. }
  980. }).catch(error => {
  981. tt.showToast({
  982. title: error.message,
  983. icon: "none",
  984. duration: 3000
  985. })
  986. })
  987. },
  988. onShow() {
  989. this.ifGetUser() //判断是否授权抖音
  990. this.setData({
  991. mouldType: app.globalData.mouldType,
  992. showbutton: false,
  993. showbutton1: false
  994. })
  995. if (this.data.end_time && this.data.activityStatus != 0) {
  996. this.countdown(this.data.end_time)
  997. } else if (this.data.begin_time && this.data.activityStatus == 0) {
  998. this.countdown(this.data.begin_time)
  999. }
  1000. },
  1001. onUnload: function () {
  1002. let that = this;
  1003. clearInterval(that.data.setInterval)
  1004. },
  1005. onHide: function () {
  1006. let that = this;
  1007. clearInterval(that.data.setInterval)
  1008. },
  1009. onShareAppMessage: function (options) {
  1010. app.globalData.previewFlag = true
  1011. var that = this;
  1012. console.log(options)
  1013. var shareObj = {
  1014. title: that.data.data.title,
  1015. path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}`,
  1016. success: function (res) {
  1017. if (res.errMsg == 'shareAppMessage:ok') {}
  1018. },
  1019. fail: function (err) {
  1020. // if (err.errMsg == 'shareAppMessage:fail cancel') { } else if (err.errMsg == 'shareAppMessage:fail') { }
  1021. }
  1022. };
  1023. // 来自页面内的按钮的转发
  1024. if (options.from == 'button' && options.channel != 'video') {
  1025. var eData = options.target.dataset.id;
  1026. shareObj.path = `/pages/index/index?couponChannelId=${eData}&frommd=JC`;
  1027. } else
  1028. if (options.channel == 'video') {
  1029. // return {
  1030. // channel: 'video', // 必写 video
  1031. //     templateId: '',   // 分享的模版 id (如果未设置就是默认,下面会说如何设置)
  1032. // title: `${that.data.barTitle}`,     // 分享的标题
  1033. // desc: `${that.data.data.dyTitle}`,     // 分享的内容介绍目前没有用
  1034. //     path: `/pages/index/index`,  // 分享的路径
  1035. // extra: {
  1036. // videoTopics: [ that.data.data.dyTitle] // 只有抖音才会有的属性
  1037. // },
  1038. // }
  1039. shareObj.channel = 'video';
  1040. shareObj.title = `${that.data.data.title}`;
  1041. shareObj.extra = {
  1042. spu_id: that.data.spuIdObj.spuId
  1043. }
  1044. }
  1045. console.log(shareObj)
  1046. // 返回shareObj
  1047. return shareObj;
  1048. },
  1049. // onShareAppMessage: function(e) {
  1050. // console.log("onShareAppMessage", e);
  1051. // return {
  1052. // channel: 'video',
  1053. // title: "测试小程序分享",
  1054. // desc: "这是默认的分享文案,用户可以直接发送,也可以在发布器内修改",
  1055. // extra: {
  1056. // spu_id:"7091460633887279111" //开发者在抖音开放平台设置的商品id
  1057. // },
  1058. // success: function(e) {
  1059. // console.log("分享成功");
  1060. // },
  1061. // fail: function(e) {
  1062. // console.log(e,"分享成功失败")
  1063. // }
  1064. // };
  1065. // },
  1066. // 下拉刷新
  1067. onPullDownRefresh: function () {
  1068. this.getDetail(this.data.couponChannelId);
  1069. tt.stopPullDownRefresh()
  1070. },
  1071. onReachBottom: function () {
  1072. this.setData({
  1073. page: this.data.page + 1
  1074. })
  1075. if (this.data.idList.length > 0) {
  1076. this.getCouponList(this.data.idList)
  1077. }
  1078. }
  1079. });