抖音c端
Não pode escolher mais do que 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.

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