抖音c端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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