抖音c端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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