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

893 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. },
  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 = res.data.callbackData
  466. // tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id
  467. let options = {
  468. callbackData: tempCallbackData,
  469. goodsList: res.data.goodsList,
  470. payment: res.data.payment,
  471. success: res => {
  472. tt.hideLoading();
  473. that.setData({
  474. showbutton: false,
  475. })
  476. const { orderId, outOrderNo } = res;
  477. that.setData({ orderId, outOrderNo });
  478. that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, '');
  479. },
  480. fail: res => {
  481. const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
  482. if (errLogId) {
  483. tt.hideLoading();
  484. that.setData({
  485. showbutton: false,
  486. })
  487. console.log('预下单失败', errNo, errMsg, errLogId);
  488. let tempErrmsg = errMsg.split('开发者拒绝交易:');
  489. tt.showToast({
  490. title: tempErrmsg[tempErrmsg.length - 1],
  491. icon: 'none',
  492. duration: 2000,
  493. mask: false
  494. });
  495. }
  496. if (orderId || outOrderNo) {
  497. tt.hideLoading();
  498. that.setData({
  499. showbutton: false,
  500. })
  501. console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
  502. console.log(that.payOrderUpdate, "payOrderUpdate");
  503. tt.showToast({
  504. title: "取消支付",
  505. icon: 'none',
  506. duration: 2000,
  507. mask: false
  508. });
  509. that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail')
  510. }
  511. },
  512. }
  513. console.log(options, "options");
  514. tt.createOrder(options)
  515. })
  516. } else {//不支持2.0支付
  517. /**
  518. * 支付订单创建
  519. */
  520. tt.showToast({
  521. title: '请升级抖音', // 内容
  522. icon: "none"
  523. });
  524. return
  525. Http.post({
  526. url: config.api.payOrderCreate,
  527. data: {
  528. orderId: orderId,
  529. composeOrderType: res.data.composeOrderType
  530. }
  531. }).then(res => {
  532. var payOrderId = "" + res.data.outOrderNo;
  533. tt.hideLoading();
  534. tt.pay({
  535. service: 5,
  536. orderInfo: {
  537. order_id: res.data.payOrderId,
  538. order_token: res.data.payOrderToken,
  539. },
  540. success: res => {
  541. tt.showLoading({
  542. title: '订单正在处理中...',
  543. })
  544. if (res.code === 0) {
  545. that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that, that.data.composeOrderType);
  546. if (res.errMsg == "requestPayment:ok") {
  547. /**
  548. * 用户支付成功以后跳转到券包列表
  549. */
  550. if (that.data.cardType == 100) {
  551. tt.setStorage({
  552. key: 'couponNum2',
  553. data: "couponNum2"
  554. })
  555. } else if (that.data.data.type != 5 && that.data.cardType != 100) {
  556. tt.setStorage({
  557. key: 'couponNum',
  558. data: "couponNum"
  559. })
  560. }
  561. }
  562. }
  563. else if (res.code === 1) {
  564. that.setData({
  565. showbutton: false
  566. })
  567. tt.hideLoading();
  568. tt.showToast({
  569. title: '支付超时', // 内容
  570. icon: "none"
  571. });
  572. } else if (res.code === 2) {
  573. that.setData({
  574. showbutton: false
  575. })
  576. tt.hideLoading();
  577. tt.showToast({
  578. title: '支付失败', // 内容
  579. icon: "none"
  580. });
  581. } else if (res.code === 3) {
  582. that.setData({
  583. showbutton: false
  584. })
  585. tt.hideLoading();
  586. tt.showToast({
  587. title: '支付关闭', // 内容
  588. icon: "none"
  589. });
  590. } else if (res.code === 4) {
  591. that.setData({
  592. showbutton: false
  593. })
  594. tt.hideLoading();
  595. tt.showToast({
  596. title: '支付取消', // 内容
  597. icon: "none"
  598. });
  599. } else if (res.code === 9) {
  600. that.setData({
  601. showbutton: false
  602. })
  603. tt.hideLoading();
  604. tt.showToast({
  605. title: '订单状态开发者自行获取', // 内容
  606. icon: "none"
  607. });
  608. }
  609. },
  610. fail: res => {
  611. tt.hideLoading();
  612. /**
  613. * 支付失败,需要更新订单的状态
  614. */
  615. that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that, that.data.composeOrderType);
  616. that.setData({
  617. showbutton: false
  618. })
  619. return;
  620. },
  621. complete: res => { }
  622. });
  623. /// End payment --------
  624. })
  625. .catch(err => {
  626. tt.hideLoading();
  627. tt.showToast({
  628. title: err.message,
  629. icon: 'none',
  630. duration: 2000,
  631. mask: false
  632. });
  633. })
  634. }
  635. } else {
  636. // 免费券
  637. that.payOrderUpdate(orderId, "0", 1, '', 'free', that, that.data.composeOrderType);
  638. if (that.data.cardType == 100) {
  639. tt.setStorage({
  640. key: 'couponNum2',
  641. data: "couponNum2"
  642. })
  643. } else if (that.data.data.type != "5" && that.data.cardType != 100) {
  644. tt.setStorage({
  645. key: 'couponNum',
  646. data: "couponNum"
  647. })
  648. }
  649. }
  650. }
  651. } else {
  652. if (res) {
  653. tt.navigateTo({
  654. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.mainOrderId}&composeOrderType=${res.data.composeOrderType}`,
  655. })
  656. }
  657. }
  658. }).catch(err => {
  659. tt.hideLoading();
  660. that.setData({
  661. showbutton: false,
  662. })
  663. if (err.code == 3012) {
  664. that.getUnPaidOrder(that.data.couponId);
  665. } else {
  666. tt.showToast({
  667. title: err.message ? err.message : err.data,
  668. icon: 'none',
  669. duration: 2000,
  670. success(res) {
  671. console.log(res);
  672. },
  673. fail(res) {
  674. console.log("showToast 调用失败", res);
  675. },
  676. });
  677. }
  678. })
  679. // } else {
  680. // //有价券
  681. // console.log(tt.canIUse('createOrder'), "是否支持2.0js-api");
  682. // if (tt.canIUse('createOrder')) {
  683. // //支持 支付2.0 js-api
  684. // let tempCallbackData = {}
  685. // tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id
  686. // let options = {
  687. // callbackData: tempCallbackData,
  688. // goodsList: [
  689. // {
  690. // quantity: 1, // 购买数量 必填
  691. // price: that.data.priceAndStockObj.salePrice, // 商品价格 必填
  692. // goodsName: that.data.data.title, // 商品名称 必填
  693. // goodsPhoto: that.data.data.coverImg, // 商品图片链接 必填
  694. // goodsId: that.data.data.couponChannel.ttSpuId, // 商品ID 必填
  695. // goodsType: 1, // 商品类型 必填
  696. // goodsLabels: ['过期退', '随时退', '免预约'], // 商品标签 非必填
  697. // dateRule: '', // 使用规则 非必填
  698. // },
  699. // ],
  700. // payment: {
  701. // totalAmount: that.data.priceAndStockObj.salePrice, // 订单总价 必填
  702. // },
  703. // success: res => {
  704. // tt.hideLoading();
  705. // that.setData({
  706. // showbutton: false,
  707. // })
  708. // const { orderId, outOrderNo } = res;
  709. // that.setData({ orderId, outOrderNo });
  710. // that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, '');
  711. // },
  712. // fail: res => {
  713. // const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
  714. // if (errLogId) {
  715. // tt.hideLoading();
  716. // that.setData({
  717. // showbutton: false,
  718. // })
  719. // console.log('预下单失败', errNo, errMsg, errLogId);
  720. // let tempErrmsg = errMsg.split('开发者拒绝交易:');
  721. // tt.showToast({
  722. // title: tempErrmsg[tempErrmsg.length - 1],
  723. // icon: 'none',
  724. // duration: 2000,
  725. // mask: false
  726. // });
  727. // }
  728. // if (orderId || outOrderNo) {
  729. // tt.hideLoading();
  730. // that.setData({
  731. // showbutton: false,
  732. // })
  733. // console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
  734. // console.log(that.payOrderUpdate, "payOrderUpdate");
  735. // tt.showToast({
  736. // title: "取消支付",
  737. // icon: 'none',
  738. // duration: 2000,
  739. // mask: false
  740. // });
  741. // that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail')
  742. // }
  743. // },
  744. // }
  745. // console.log(options, "options");
  746. // tt.createOrder(options)
  747. // } else {
  748. // //不支持 支付2.0 js -api
  749. // }
  750. // }
  751. }).catch(err => {
  752. tt.hideLoading()
  753. that.setData({
  754. showbutton: false,
  755. })
  756. if (err.code == 2011) {
  757. tt.showToast({
  758. title: "商户信息没找到",
  759. image: './../../../assets/images/fail.png',
  760. duration: 2000,
  761. mask: false
  762. });
  763. } else if (err.code == 2013) {
  764. tt.showToast({
  765. title: "商户信息禁用",
  766. image: './../../../assets/images/fail.png',
  767. duration: 2000,
  768. mask: false
  769. });
  770. } else if (err.code == 3000) {
  771. tt.showToast({
  772. title: "库存不足",
  773. image: './../../../assets/images/fail.png',
  774. duration: 2000,
  775. mask: false
  776. });
  777. } else if (err.code == 3001) {
  778. tt.showToast({
  779. title: "您已超过限购",
  780. image: './../../../assets/images/fail.png',
  781. duration: 2000,
  782. mask: false
  783. });
  784. } else if (err.code == 3002) {
  785. tt.showToast({
  786. title: "订单失败",
  787. image: './../../../assets/images/fail.png',
  788. duration: 2000,
  789. mask: false
  790. });
  791. } else if (err.code == 3003) {
  792. tt.showToast({
  793. title: "订单不存在",
  794. image: './../../../assets/images/fail.png',
  795. duration: 2000,
  796. mask: false
  797. });
  798. } else if (err.code == 3004) {
  799. tt.showToast({
  800. title: "订单不存在",
  801. image: './../../../assets/images/fail.png',
  802. duration: 2000,
  803. mask: false
  804. });
  805. } else if (err.code == 4003) {
  806. tt.showToast({
  807. title: "卡券已作废",
  808. image: './../../../assets/images/fail.png',
  809. duration: 2000,
  810. mask: false
  811. });
  812. } else if (err.code == 3012) {
  813. that.getUnPaidOrder(that.data.couponId);
  814. } else if (err.code == 11005) {
  815. /**
  816. * 将值传到用户手机号授权的页面
  817. *
  818. */
  819. // tt.navigateTo({
  820. // url: `/pages/getPhone/getPhone?couponChannelId=${that.data.couponChannelId}&path=qr`
  821. // });
  822. this.setData({
  823. showPhoem:true
  824. })
  825. } else if (err.code == 11006) {
  826. // 用户手机已加密
  827. tt.navigateTo({
  828. url: `/pages/getPhone/getPhone?couponChannelId=${that.data.couponChannelId}&path=qr`
  829. });
  830. } else {
  831. tt.showToast({
  832. title: err.message,
  833. icon: 'none',
  834. duration: 2000,
  835. mask: false
  836. });
  837. }
  838. })
  839. }).catch(err => {
  840. tt.hideLoading()
  841. that.setData({
  842. showbutton: false,
  843. })
  844. console.log(err)
  845. if (err.code == 11004) {
  846. tt.navigateTo({
  847. url: `/pages/getuserinfo/getuserinfo?fromflag=confirmation&confirmationFlag=${that.data.couponChannelId}`,
  848. })
  849. } else {
  850. tt.showToast({
  851. title: err.message,
  852. icon: "none",
  853. duration: 2500
  854. })
  855. }
  856. })
  857. },
  858. })