抖音c端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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