抖音c端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

936 wiersze
30 KiB

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