抖音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.

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