抖音c端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

918 rindas
29 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. couponIds: "",
  10. showPhoem: false,
  11. couponChannelId: "",
  12. showPage: false,
  13. data: {},
  14. spuIdObj: {},
  15. priceAndStockObj: {},
  16. mallTenantId: ''
  17. },
  18. onLoad: function (options) {
  19. console.log(options);
  20. if (options.mallTenantId) {
  21. this.setData({
  22. mallTenantId: options.mallTenantId,
  23. })
  24. }
  25. tt.showLoading({
  26. title: "加载中..."
  27. });
  28. let that = this
  29. if (app.globalData.token) {
  30. if (options && options.couponChannelId) {
  31. that.setData({
  32. couponChannelId: options.couponChannelId
  33. })
  34. that.getDetail(options.couponChannelId, 'notendclock');
  35. }
  36. } else {
  37. app.tokenCallback = token => {
  38. that.setData({
  39. couponChannelId: options.couponChannelId
  40. })
  41. if (options && options.couponChannelId) {
  42. that.getDetail(options.couponChannelId, 'notendclock');
  43. }
  44. }
  45. }
  46. },
  47. goInstructions() {
  48. tt.navigateTo({
  49. url: '/pages/coupon/instructions/instructions?couponChannelId=' + this.data.couponChannelId,
  50. success: (res) => {
  51. },
  52. fail: (res) => {
  53. },
  54. });
  55. },
  56. getSupId(id) {
  57. Http.get({
  58. url: config.api.getSpuid,
  59. data: {
  60. id: id
  61. }
  62. }).then(res => {
  63. if (res.data) {
  64. this.setData({
  65. spuIdObj: res.data
  66. })
  67. }
  68. }).catch(err => {
  69. // tt.showToast({
  70. // title: err.message,
  71. // icon: 'none',
  72. // duration: 2000,
  73. // mask: false
  74. // });
  75. })
  76. },
  77. setPhone(paramData) {
  78. //子组件调用这个方法说明手机号已经授权成功
  79. this.setData({
  80. showPhoem: paramData.detail,
  81. })
  82. tt.showToast({
  83. title: '授权成功', // 内容
  84. icon: 'none', // 图标
  85. success: (res) => {
  86. },
  87. fail: (res) => {
  88. },
  89. });
  90. },
  91. setBox(paramData) {
  92. this.setData({
  93. showPhoem: paramData.detail
  94. })
  95. tt.showToast({
  96. title: '取消授权', // 内容
  97. icon: 'none', // 图标
  98. success: (res) => {
  99. tt.reLaunch({
  100. url: "/index/index",
  101. success(res) {
  102. console.log(`${res}`);
  103. app.globalData.selected = 0
  104. },
  105. fail(err) {
  106. console.log(`navigateTo调用失败`, err);
  107. },
  108. });
  109. },
  110. fail: (res) => {
  111. },
  112. });
  113. },
  114. getCouponPriceAndStock(couponChannelId) { //获取券价格与库存
  115. Http.get({
  116. url: config.api.couponPriceAndStock,
  117. data: {
  118. couponChannelId,
  119. mallTenantId: this.data.mallTenantId || ''
  120. }
  121. }).then(res => {
  122. let tempBoj = JSON.parse(res.data)
  123. console.log(tempBoj, "$");
  124. this.setData({
  125. priceAndStockObj: tempBoj
  126. })
  127. })
  128. },
  129. getDetail: function (couponChannelId, flag) {
  130. let that = this;
  131. let data = {};
  132. that.getCouponPriceAndStock(couponChannelId); //获取券价格和库存
  133. if (that.data.couponIds) {
  134. data.couponId = couponChannelId
  135. } else {
  136. data.couponChannelId = couponChannelId
  137. }
  138. var parmer = {
  139. url: config.api.newCouponDetail,
  140. data: data
  141. };
  142. Http.get(parmer).then(res => {
  143. that.setData({
  144. couponId: res.data.couponId
  145. })
  146. /**
  147. * activityStatus==0 活动未开始
  148. * activityStatus==1 活动已开始
  149. * flag == endclock 说明倒计时已经结束
  150. */
  151. if (res.data.endTime && res.data.beginTime) {
  152. that.setData({
  153. begin_time: res.data.beginTime,
  154. end_time: res.data.endTime,
  155. activityStatus: res.data.actStatus ? res.data.actStatus : ''
  156. })
  157. if (res.data.actStatus == 0 && flag != 'endclock') {
  158. that.countdown(res.data.beginTime);
  159. } else if (res.data.actStatus != 0 && flag != 'endclock') {
  160. that.countdown(res.data.endTime);
  161. } else {
  162. clearInterval(that.data.setInterval)
  163. }
  164. if (res.data.actStatus == 0) {
  165. var beginTime = util.formatTime(res.data.beginTime, "yyyy-MM-dd hh:mm:ss");
  166. if (util.timechuo(beginTime).indexOf('-') == 0) {
  167. that.setData({
  168. beginTime: "活动已结束",
  169. });
  170. } else {
  171. that.setData({
  172. beginTime: util.timechuo(beginTime)
  173. });
  174. }
  175. } else {
  176. var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss");
  177. if (util.timechuo(endTime).indexOf('-') == 0) {
  178. that.setData({
  179. endtime: "活动已结束",
  180. });
  181. } else {
  182. that.setData({
  183. endtime: util.timechuo(endTime)
  184. });
  185. }
  186. }
  187. }
  188. tt.hideLoading();
  189. that.setData({
  190. data: res.data,
  191. });
  192. if (res.data.type == 10) {
  193. that.setData({
  194. salePriceStr: res.data.salePriceStr,
  195. pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
  196. pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
  197. priceStr: res.data.priceStr,
  198. tailPriceStr: res.data.tailPriceStr,
  199. origPriceStr: res.data.origPriceStr
  200. })
  201. }
  202. if (res.data.validType == 1) {
  203. that.setData({
  204. validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dd"),
  205. validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dd"),
  206. pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
  207. pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
  208. });
  209. } else {
  210. if (res.data.validDays) {
  211. that.setData({
  212. validDays: res.data.validDays
  213. });
  214. }
  215. }
  216. if (res.data.itemGroup) {
  217. let tempObj = this.data.data
  218. tempObj.itemGroup = JSON.parse(tempObj.itemGroup)
  219. this.setData({
  220. data: tempObj
  221. })
  222. console.log(this.data.data, "data");
  223. }
  224. if (res.data.productAttrs && res.data.skuAttrs) {
  225. let tempObj = this.data.data
  226. tempObj.productAttrs = JSON.parse(tempObj.productAttrs)
  227. tempObj.skuAttrs = JSON.parse(tempObj.skuAttrs)
  228. tempObj.productAttrs.map(item => {
  229. if (item.key == "Notification") {
  230. if (item.data != '') {
  231. tempObj.curLsit = JSON.parse(item.data)
  232. }
  233. }
  234. if (item.key == "bring_out_meal") {
  235. tempObj.besides = item.data
  236. }
  237. if (item.key == "free_pack") {
  238. tempObj.pack = item.data
  239. }
  240. if (item.key == "superimposed_discounts") {
  241. tempObj.superimposed_discounts = item.data
  242. }
  243. if (item.key == "private_room") {
  244. tempObj.private_room = item.data
  245. }
  246. if (item.key == "rec_person_num_max") {
  247. tempObj.rec_person_num_max = item.data
  248. }
  249. if (item.key == 'Description') {
  250. tempObj.Description = JSON.parse(item.data)
  251. }
  252. if (item.key == "can_no_use_date") {
  253. tempObj.can_no_use_date = JSON.parse(item.data)
  254. }
  255. })
  256. tempObj.skuAttrs.map(item => {
  257. if (item.key == "commodity") {
  258. if (item.data != '') {
  259. tempObj.itemGroup = JSON.parse(item.data)
  260. }
  261. }
  262. })
  263. this.setData({
  264. data: tempObj
  265. })
  266. console.log(this.data.data, "data");
  267. }
  268. }).catch(err => {
  269. tt.showToast({
  270. title: err.message,
  271. icon: 'none',
  272. duration: 2000,
  273. mask: false
  274. });
  275. })
  276. },
  277. /**
  278. * 支付订单更新
  279. */
  280. payOrderUpdate: (orderId, payOrderId, status, reason, type, _this, composeOrderType) => {
  281. let that = this;
  282. // 支付成功
  283. Http.post({
  284. url: config.api.payOrderUpdate,
  285. data: {
  286. payOrderId: payOrderId,
  287. composeOrderId: orderId,
  288. status: status,
  289. reason: reason
  290. }
  291. })
  292. .then(res => {
  293. tt.hideLoading()
  294. // 有价券
  295. if (!type && type != 'free') {
  296. tt.navigateTo({
  297. url: `/pages/order/detail/index?orderId=${orderId
  298. }`
  299. });
  300. } else if (type == 'free') {
  301. tt.navigateTo({
  302. url: `/pages/order/detail/index?orderId=${orderId
  303. }`
  304. });
  305. }
  306. })
  307. .catch(err => {
  308. console.log(err);
  309. if (!type) {
  310. setTimeout(function () {
  311. _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this, composeOrderType);
  312. }, 2000)
  313. }
  314. })
  315. },
  316. // 获得未支付的订单
  317. getUnPaidOrder(couponId) {
  318. let that = this;
  319. Http.get({
  320. url: config.api.getUnPaidOrder,
  321. data: {
  322. couponId: couponId,
  323. mallTenantId: this.data.mallTenantId || ''
  324. }
  325. }).then(res => {
  326. that.setData({
  327. disOrderNumber: res.data.orderNumber,
  328. composeOrderType: res.data.composeOrderType
  329. })
  330. if (res.data && res.data.pressEndDate) {
  331. that.setData({
  332. dispressEndDate: true
  333. })
  334. } else {
  335. that.setData({
  336. dispressEndDate: false
  337. })
  338. }
  339. if (that.data.dispressEndDate) {
  340. tt.showModal({
  341. title: '提示',
  342. content: "您有未支付订单,请到“我的-我的砍价”进行支付",
  343. confirmText: "我的砍价",
  344. success: function (res) {
  345. if (res.confirm) {
  346. tt.navigateTo({
  347. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.disOrderNumber}&composeOrderType=${that.data.composeOrderType}`,
  348. })
  349. }
  350. }
  351. })
  352. } else {
  353. tt.showModal({
  354. title: '提示',
  355. content: '您有未支付订单,请先进行支付',
  356. confirmText: "去支付",
  357. success: function (res1) {
  358. if (res1.confirm) {
  359. if (that.data.composeOrderType > 0) { //券包
  360. tt.navigateTo({
  361. url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}&mallTenantId=${that.data.mallTenantId}`,
  362. })
  363. } else {
  364. tt.navigateTo({
  365. url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}&mallTenantId=${that.data.mallTenantId}`,
  366. })
  367. }
  368. }
  369. }
  370. })
  371. }
  372. }).catch(error => {
  373. tt.showToast({
  374. title: error.message,
  375. icon: "none",
  376. duration: 3000
  377. })
  378. })
  379. },
  380. /**
  381. * 发起支付
  382. */
  383. orderFunc(discount) {
  384. if (this.data.showbutton) return;
  385. let that = this;
  386. tt.showLoading({
  387. title: "加载中..."
  388. });
  389. that.setData({
  390. showbutton: true,
  391. })
  392. Http.get({
  393. url: config.api.checkUserStatus,
  394. data: {
  395. token: app.globalData.token,
  396. }
  397. }).then(res => {
  398. Http.get({
  399. url: config.api.checkPhoneStatus,
  400. data: {}
  401. }).then(res => {
  402. //
  403. // if (!tt.canIUse('createOrder') || that.data.data.type == 50 || that.data.priceAndStockObj.salePrice == 0) {
  404. //积分券和免费券
  405. // 发起砍价
  406. if (discount == 'discount') {
  407. var data = {
  408. couponChannelId: "" + that.data.couponChannelId,
  409. couponId: "" + that.data.couponId,
  410. formId: "" + that.data.formId,
  411. press: true
  412. }
  413. } else if (discount == 'discount1') {
  414. var data = {
  415. couponChannelId: "" + that.data.couponChannelId,
  416. couponId: "" + that.data.couponId,
  417. formId: "" + that.data.formId,
  418. press: false
  419. }
  420. } else if (that.data.couponChannelId == null) {
  421. var data = {
  422. couponId: "" + that.data.couponId,
  423. formId: "" + that.data.formId,
  424. };
  425. } else {
  426. var data = {
  427. couponChannelId: "" + that.data.couponChannelId,
  428. couponId: "" + that.data.couponId,
  429. formId: "" + that.data.formId,
  430. }
  431. }
  432. console.log(data, "data")
  433. let url = ""
  434. let tempObj;
  435. let tempArr = []
  436. if (that.data.data.type == 12) {
  437. url = config.api.couponPackageSave
  438. tempObj = {
  439. signleOrder: {
  440. couponChannelId: "" + that.data.couponChannelId,
  441. couponId: "" + that.data.couponId,
  442. formId: "" + that.data.formId,
  443. },
  444. count: "1"
  445. }
  446. tempArr.push(tempObj)
  447. } else {
  448. url = config.api.orderSave
  449. data.mallTenantId = that.data.mallTenantId || ''
  450. }
  451. /**
  452. * orderSave 下单
  453. */
  454. Http.post({
  455. url: url,
  456. data: that.data.data.type == 12 ? JSON.stringify(tempArr) : data
  457. }).then(res => {
  458. if (discount != 'discount') {
  459. if (typeof (res) != "undefined") {
  460. let orderId = "" + res.data.mainOrderId;
  461. that.setData({
  462. orderId: orderId,
  463. composeOrderType: res.data.composeOrderType
  464. });
  465. if (res.data.payment > 0) {
  466. // 支付金额不为0
  467. if (tt.canIUse('createOrder')) {
  468. Http.post({
  469. url: config.api.payOrderCreate_2,
  470. data: {
  471. orderId: orderId,
  472. composeOrderType: res.data.composeOrderType,
  473. mallTenantId: that.data.mallTenantId
  474. }
  475. }).then(res => {
  476. console.log(res, "789789");
  477. let tempCallbackData = res.data.callbackData
  478. // tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id
  479. let options = {
  480. callbackData: tempCallbackData,
  481. goodsList: res.data.goodsList,
  482. payment: res.data.payment,
  483. success: res => {
  484. tt.hideLoading();
  485. that.setData({
  486. showbutton: false,
  487. })
  488. const {
  489. orderId,
  490. outOrderNo
  491. } = res;
  492. that.setData({
  493. orderId,
  494. outOrderNo
  495. });
  496. that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, '');
  497. },
  498. fail: res => {
  499. const {
  500. orderId,
  501. outOrderNo,
  502. errNo,
  503. errMsg,
  504. errLogId
  505. } = res;
  506. if (errLogId) {
  507. tt.hideLoading();
  508. that.setData({
  509. showbutton: false,
  510. })
  511. console.log('预下单失败', errNo, errMsg, errLogId);
  512. let tempErrmsg = errMsg.split('开发者拒绝交易:');
  513. tt.showToast({
  514. title: tempErrmsg[tempErrmsg.length - 1],
  515. icon: 'none',
  516. duration: 2000,
  517. mask: false
  518. });
  519. }
  520. if (orderId || outOrderNo) {
  521. tt.hideLoading();
  522. that.setData({
  523. showbutton: false,
  524. })
  525. console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
  526. console.log(that.payOrderUpdate, "payOrderUpdate");
  527. tt.showToast({
  528. title: "取消支付",
  529. icon: 'none',
  530. duration: 2000,
  531. mask: false
  532. });
  533. that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail')
  534. }
  535. },
  536. }
  537. console.log(options, "options");
  538. tt.createOrder(options)
  539. })
  540. } else { //不支持2.0支付
  541. /**
  542. * 支付订单创建
  543. */
  544. tt.showToast({
  545. title: '请升级抖音', // 内容
  546. icon: "none"
  547. });
  548. return
  549. Http.post({
  550. url: config.api.payOrderCreate,
  551. data: {
  552. orderId: orderId,
  553. composeOrderType: res.data.composeOrderType
  554. }
  555. }).then(res => {
  556. var payOrderId = "" + res.data.outOrderNo;
  557. tt.hideLoading();
  558. tt.pay({
  559. service: 5,
  560. orderInfo: {
  561. order_id: res.data.payOrderId,
  562. order_token: res.data.payOrderToken,
  563. },
  564. success: res => {
  565. tt.showLoading({
  566. title: '订单正在处理中...',
  567. })
  568. if (res.code === 0) {
  569. that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that, that.data.composeOrderType);
  570. if (res.errMsg == "requestPayment:ok") {
  571. /**
  572. * 用户支付成功以后跳转到券包列表
  573. */
  574. if (that.data.cardType == 100) {
  575. tt.setStorage({
  576. key: 'couponNum2',
  577. data: "couponNum2"
  578. })
  579. } else if (that.data.data.type != 5 && that.data.cardType != 100) {
  580. tt.setStorage({
  581. key: 'couponNum',
  582. data: "couponNum"
  583. })
  584. }
  585. }
  586. } else if (res.code === 1) {
  587. that.setData({
  588. showbutton: false
  589. })
  590. tt.hideLoading();
  591. tt.showToast({
  592. title: '支付超时', // 内容
  593. icon: "none"
  594. });
  595. } else if (res.code === 2) {
  596. that.setData({
  597. showbutton: false
  598. })
  599. tt.hideLoading();
  600. tt.showToast({
  601. title: '支付失败', // 内容
  602. icon: "none"
  603. });
  604. } else if (res.code === 3) {
  605. that.setData({
  606. showbutton: false
  607. })
  608. tt.hideLoading();
  609. tt.showToast({
  610. title: '支付关闭', // 内容
  611. icon: "none"
  612. });
  613. } else if (res.code === 4) {
  614. that.setData({
  615. showbutton: false
  616. })
  617. tt.hideLoading();
  618. tt.showToast({
  619. title: '支付取消', // 内容
  620. icon: "none"
  621. });
  622. } else if (res.code === 9) {
  623. that.setData({
  624. showbutton: false
  625. })
  626. tt.hideLoading();
  627. tt.showToast({
  628. title: '订单状态开发者自行获取', // 内容
  629. icon: "none"
  630. });
  631. }
  632. },
  633. fail: res => {
  634. tt.hideLoading();
  635. /**
  636. * 支付失败,需要更新订单的状态
  637. */
  638. that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that, that.data.composeOrderType);
  639. that.setData({
  640. showbutton: false
  641. })
  642. return;
  643. },
  644. complete: res => {}
  645. });
  646. /// End payment --------
  647. })
  648. .catch(err => {
  649. tt.hideLoading();
  650. tt.showToast({
  651. title: err.message,
  652. icon: 'none',
  653. duration: 2000,
  654. mask: false
  655. });
  656. })
  657. }
  658. } else {
  659. // 免费券
  660. that.payOrderUpdate(orderId, "0", 1, '', 'free', that, that.data.composeOrderType);
  661. if (that.data.cardType == 100) {
  662. tt.setStorage({
  663. key: 'couponNum2',
  664. data: "couponNum2"
  665. })
  666. } else if (that.data.data.type != "5" && that.data.cardType != 100) {
  667. tt.setStorage({
  668. key: 'couponNum',
  669. data: "couponNum"
  670. })
  671. }
  672. }
  673. }
  674. } else {
  675. if (res) {
  676. tt.navigateTo({
  677. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.mainOrderId}&composeOrderType=${res.data.composeOrderType}`,
  678. })
  679. }
  680. }
  681. }).catch(err => {
  682. tt.hideLoading();
  683. that.setData({
  684. showbutton: false,
  685. })
  686. if (err.code == 3012) {
  687. that.getUnPaidOrder(that.data.couponId);
  688. } else {
  689. tt.showToast({
  690. title: err.message ? err.message : err.data,
  691. icon: 'none',
  692. duration: 2000,
  693. success(res) {
  694. console.log(res);
  695. },
  696. fail(res) {
  697. console.log("showToast 调用失败", res);
  698. },
  699. });
  700. }
  701. })
  702. // } else {
  703. // //有价券
  704. // console.log(tt.canIUse('createOrder'), "是否支持2.0js-api");
  705. // if (tt.canIUse('createOrder')) {
  706. // //支持 支付2.0 js-api
  707. // let tempCallbackData = {}
  708. // tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id
  709. // let options = {
  710. // callbackData: tempCallbackData,
  711. // goodsList: [
  712. // {
  713. // quantity: 1, // 购买数量 必填
  714. // price: that.data.priceAndStockObj.salePrice, // 商品价格 必填
  715. // goodsName: that.data.data.title, // 商品名称 必填
  716. // goodsPhoto: that.data.data.coverImg, // 商品图片链接 必填
  717. // goodsId: that.data.data.couponChannel.ttSpuId, // 商品ID 必填
  718. // goodsType: 1, // 商品类型 必填
  719. // goodsLabels: ['过期退', '随时退', '免预约'], // 商品标签 非必填
  720. // dateRule: '', // 使用规则 非必填
  721. // },
  722. // ],
  723. // payment: {
  724. // totalAmount: that.data.priceAndStockObj.salePrice, // 订单总价 必填
  725. // },
  726. // success: res => {
  727. // tt.hideLoading();
  728. // that.setData({
  729. // showbutton: false,
  730. // })
  731. // const { orderId, outOrderNo } = res;
  732. // that.setData({ orderId, outOrderNo });
  733. // that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, '');
  734. // },
  735. // fail: res => {
  736. // const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
  737. // if (errLogId) {
  738. // tt.hideLoading();
  739. // that.setData({
  740. // showbutton: false,
  741. // })
  742. // console.log('预下单失败', errNo, errMsg, errLogId);
  743. // let tempErrmsg = errMsg.split('开发者拒绝交易:');
  744. // tt.showToast({
  745. // title: tempErrmsg[tempErrmsg.length - 1],
  746. // icon: 'none',
  747. // duration: 2000,
  748. // mask: false
  749. // });
  750. // }
  751. // if (orderId || outOrderNo) {
  752. // tt.hideLoading();
  753. // that.setData({
  754. // showbutton: false,
  755. // })
  756. // console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
  757. // console.log(that.payOrderUpdate, "payOrderUpdate");
  758. // tt.showToast({
  759. // title: "取消支付",
  760. // icon: 'none',
  761. // duration: 2000,
  762. // mask: false
  763. // });
  764. // that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail')
  765. // }
  766. // },
  767. // }
  768. // console.log(options, "options");
  769. // tt.createOrder(options)
  770. // } else {
  771. // //不支持 支付2.0 js -api
  772. // }
  773. // }
  774. }).catch(err => {
  775. tt.hideLoading()
  776. that.setData({
  777. showbutton: false,
  778. })
  779. if (err.code == 2011) {
  780. tt.showToast({
  781. title: "商户信息没找到",
  782. image: './../../../assets/images/fail.png',
  783. duration: 2000,
  784. mask: false
  785. });
  786. } else if (err.code == 2013) {
  787. tt.showToast({
  788. title: "商户信息禁用",
  789. image: './../../../assets/images/fail.png',
  790. duration: 2000,
  791. mask: false
  792. });
  793. } else if (err.code == 3000) {
  794. tt.showToast({
  795. title: "库存不足",
  796. image: './../../../assets/images/fail.png',
  797. duration: 2000,
  798. mask: false
  799. });
  800. } else if (err.code == 3001) {
  801. tt.showToast({
  802. title: "您已超过限购",
  803. image: './../../../assets/images/fail.png',
  804. duration: 2000,
  805. mask: false
  806. });
  807. } else if (err.code == 3002) {
  808. tt.showToast({
  809. title: "订单失败",
  810. image: './../../../assets/images/fail.png',
  811. duration: 2000,
  812. mask: false
  813. });
  814. } else if (err.code == 3003) {
  815. tt.showToast({
  816. title: "订单不存在",
  817. image: './../../../assets/images/fail.png',
  818. duration: 2000,
  819. mask: false
  820. });
  821. } else if (err.code == 3004) {
  822. tt.showToast({
  823. title: "订单不存在",
  824. image: './../../../assets/images/fail.png',
  825. duration: 2000,
  826. mask: false
  827. });
  828. } else if (err.code == 4003) {
  829. tt.showToast({
  830. title: "卡券已作废",
  831. image: './../../../assets/images/fail.png',
  832. duration: 2000,
  833. mask: false
  834. });
  835. } else if (err.code == 3012) {
  836. that.getUnPaidOrder(that.data.couponId);
  837. } else if (err.code == 11005) {
  838. /**
  839. * 将值传到用户手机号授权的页面
  840. *
  841. */
  842. // tt.navigateTo({
  843. // url: `/pages/getPhone/getPhone?couponChannelId=${that.data.couponChannelId}&path=qr`
  844. // });
  845. this.setData({
  846. showPhoem: true
  847. })
  848. } else if (err.code == 11006) {
  849. // 用户手机已加密
  850. tt.navigateTo({
  851. url: `/pages/getPhone/getPhone?couponChannelId=${that.data.couponChannelId}&path=qr`
  852. });
  853. } else {
  854. tt.showToast({
  855. title: err.message,
  856. icon: 'none',
  857. duration: 2000,
  858. mask: false
  859. });
  860. }
  861. })
  862. }).catch(err => {
  863. tt.hideLoading()
  864. that.setData({
  865. showbutton: false,
  866. })
  867. console.log(err)
  868. if (err.code == 11004) {
  869. tt.navigateTo({
  870. url: `/pages/getuserinfo/getuserinfo?fromflag=confirmation&confirmationFlag=${that.data.couponChannelId}`,
  871. })
  872. } else {
  873. tt.showToast({
  874. title: err.message,
  875. icon: "none",
  876. duration: 2500
  877. })
  878. }
  879. })
  880. },
  881. })