抖音c端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 1 Jahr
vor 2 Jahren
vor 1 Jahr
vor 1 Jahr
vor 2 Jahren
vor 2 Jahren
vor 1 Jahr
vor 1 Jahr
vor 2 Jahren
vor 2 Jahren
vor 1 Jahr
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  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. console.log(orderId, 'orderId');
  288. // 支付成功
  289. Http.post({
  290. url: config.api.payOrderUpdate,
  291. data: {
  292. payOrderId: payOrderId,
  293. composeOrderId: orderId,
  294. status: status,
  295. reason: reason,
  296. mallTenantId: that.data.mallTenantId
  297. }
  298. })
  299. .then(res => {
  300. tt.hideLoading()
  301. // 有价券
  302. if (!type && type != 'free') {
  303. console.log('Over Here! type');
  304. setTimeout(() => {
  305. console.log(_this.data.orderFlag, orderId, that.data.mallTenantId, 'notice!!!');
  306. let url = ""
  307. if (_this.data.orderFlag) {
  308. tt.redirectTo({
  309. url: `/pages/order/detail/index?orderId=${orderId}&dingdan=order&mallTenantId=${that.data.mallTenantId}`
  310. });
  311. } else {
  312. tt.redirectTo({
  313. url: `/pages/order/detail/index?orderId=${orderId}&mallTenantId=${that.data.mallTenantId}`
  314. });
  315. }
  316. }, 1600);
  317. } else if (type == 'free') {
  318. console.log('Over Here! type2');
  319. tt.navigateTo({
  320. url: `/pages/order/detail/index?orderId=${orderId
  321. }&mallTenantId=${that.data.mallTenantId}`
  322. });
  323. }
  324. })
  325. .catch(err => {
  326. console.log(err);
  327. console.log('Over Here! type3');
  328. if (!type) {
  329. setTimeout(function () {
  330. _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this, composeOrderType);
  331. }, 2000)
  332. }
  333. })
  334. },
  335. // 获得未支付的订单
  336. getUnPaidOrder(couponId) {
  337. let that = this;
  338. Http.get({
  339. url: config.api.getUnPaidOrder,
  340. data: {
  341. couponId: couponId,
  342. mallTenantId: this.data.mallTenantId || ''
  343. }
  344. }).then(res => {
  345. that.setData({
  346. disOrderNumber: res.data.orderNumber,
  347. composeOrderType: res.data.composeOrderType
  348. })
  349. if (res.data && res.data.pressEndDate) {
  350. that.setData({
  351. dispressEndDate: true
  352. })
  353. } else {
  354. that.setData({
  355. dispressEndDate: false
  356. })
  357. }
  358. if (that.data.dispressEndDate) {
  359. tt.showModal({
  360. title: '提示',
  361. content: "您有未支付订单,请到“我的-我的砍价”进行支付",
  362. confirmText: "我的砍价",
  363. success: function (res) {
  364. if (res.confirm) {
  365. tt.navigateTo({
  366. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.disOrderNumber}&composeOrderType=${that.data.composeOrderType}`,
  367. })
  368. }
  369. }
  370. })
  371. } else {
  372. tt.showModal({
  373. title: '提示',
  374. content: '您有未支付订单,请先进行支付',
  375. confirmText: "去支付",
  376. success: function (res1) {
  377. if (res1.confirm) {
  378. if (that.data.composeOrderType > 0) { //券包
  379. tt.navigateTo({
  380. url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}&mallTenantId=${that.data.mallTenantId}`,
  381. })
  382. } else {
  383. tt.navigateTo({
  384. url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}&mallTenantId=${that.data.mallTenantId}`,
  385. })
  386. }
  387. }
  388. }
  389. })
  390. }
  391. }).catch(error => {
  392. tt.showToast({
  393. title: error.message,
  394. icon: "none",
  395. duration: 3000
  396. })
  397. })
  398. },
  399. /**
  400. * 发起支付
  401. */
  402. orderFunc(discount) {
  403. if (this.data.showbutton) return;
  404. let that = this;
  405. tt.showLoading({
  406. title: "加载中..."
  407. });
  408. that.setData({
  409. showbutton: true,
  410. })
  411. Http.get({
  412. url: config.api.checkUserStatus,
  413. data: {
  414. token: app.globalData.token,
  415. }
  416. }).then(res => {
  417. Http.get({
  418. url: config.api.checkPhoneStatus,
  419. data: {}
  420. }).then(res => {
  421. //
  422. // if (!tt.canIUse('createOrder') || that.data.data.type == 50 || that.data.priceAndStockObj.salePrice == 0) {
  423. //积分券和免费券
  424. // 发起砍价
  425. if (discount == 'discount') {
  426. var data = {
  427. couponChannelId: "" + that.data.couponChannelId,
  428. couponId: "" + that.data.couponId,
  429. formId: "" + that.data.formId,
  430. press: true
  431. }
  432. } else if (discount == 'discount1') {
  433. var data = {
  434. couponChannelId: "" + that.data.couponChannelId,
  435. couponId: "" + that.data.couponId,
  436. formId: "" + that.data.formId,
  437. press: false
  438. }
  439. } else if (that.data.couponChannelId == null) {
  440. var data = {
  441. couponId: "" + that.data.couponId,
  442. formId: "" + that.data.formId,
  443. };
  444. } else {
  445. var data = {
  446. couponChannelId: "" + that.data.couponChannelId,
  447. couponId: "" + that.data.couponId,
  448. formId: "" + that.data.formId,
  449. }
  450. }
  451. console.log(data, "data")
  452. let url = ""
  453. let tempObj;
  454. let tempArr = []
  455. if (that.data.data.type == 12) {
  456. url = config.api.couponPackageSave
  457. tempObj = {
  458. signleOrder: {
  459. couponChannelId: "" + that.data.couponChannelId,
  460. couponId: "" + that.data.couponId,
  461. formId: "" + that.data.formId,
  462. },
  463. count: "1"
  464. }
  465. tempArr.push(tempObj)
  466. } else {
  467. url = config.api.orderSave
  468. data.mallTenantId = that.data.mallTenantId || ''
  469. }
  470. /**
  471. * orderSave 下单
  472. */
  473. Http.post({
  474. url: url,
  475. data: that.data.data.type == 12 ? JSON.stringify(tempArr) : data
  476. }).then(res => {
  477. if (discount != 'discount') {
  478. if (typeof (res) != "undefined") {
  479. let orderId = "" + res.data.mainOrderId;
  480. that.setData({
  481. orderId: orderId,
  482. composeOrderType: res.data.composeOrderType
  483. });
  484. if (res.data.payment > 0) {
  485. // 支付金额不为0
  486. if (tt.canIUse('createOrder')) {
  487. Http.post({
  488. url: config.api.payOrderCreate_2,
  489. data: {
  490. orderId: orderId,
  491. composeOrderType: res.data.composeOrderType,
  492. mallTenantId: that.data.mallTenantId
  493. }
  494. }).then(res => {
  495. console.log(res, "789789");
  496. let tempCallbackData = res.data.callbackData
  497. // tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id
  498. let options = {
  499. callbackData: tempCallbackData,
  500. goodsList: res.data.goodsList,
  501. payment: res.data.payment,
  502. success: res => {
  503. console.log('save,success!');
  504. tt.hideLoading();
  505. that.setData({
  506. showbutton: false,
  507. })
  508. const {
  509. orderId,
  510. outOrderNo
  511. } = res;
  512. that.setData({
  513. orderId,
  514. outOrderNo
  515. });
  516. that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, '');
  517. },
  518. fail: res => {
  519. console.log('save,fail!');
  520. const {
  521. orderId,
  522. outOrderNo,
  523. errNo,
  524. errMsg,
  525. errLogId
  526. } = res;
  527. if (errLogId) {
  528. tt.hideLoading();
  529. that.setData({
  530. showbutton: false,
  531. })
  532. console.log('预下单失败', errNo, errMsg, errLogId);
  533. let tempErrmsg = errMsg.split('开发者拒绝交易:');
  534. tt.showToast({
  535. title: tempErrmsg[tempErrmsg.length - 1],
  536. icon: 'none',
  537. duration: 2000,
  538. mask: false
  539. });
  540. }
  541. if (orderId || outOrderNo) {
  542. tt.hideLoading();
  543. that.setData({
  544. showbutton: false,
  545. })
  546. console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
  547. console.log(that.payOrderUpdate, "payOrderUpdate");
  548. tt.showToast({
  549. title: "取消支付",
  550. icon: 'none',
  551. duration: 2000,
  552. mask: false
  553. });
  554. that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail')
  555. }
  556. },
  557. }
  558. console.log(options, "options");
  559. tt.createOrder(options)
  560. })
  561. } else { //不支持2.0支付
  562. /**
  563. * 支付订单创建
  564. */
  565. tt.showToast({
  566. title: '请升级抖音', // 内容
  567. icon: "none"
  568. });
  569. return
  570. Http.post({
  571. url: config.api.payOrderCreate,
  572. data: {
  573. orderId: orderId,
  574. composeOrderType: res.data.composeOrderType
  575. }
  576. }).then(res => {
  577. var payOrderId = "" + res.data.outOrderNo;
  578. tt.hideLoading();
  579. tt.pay({
  580. service: 5,
  581. orderInfo: {
  582. order_id: res.data.payOrderId,
  583. order_token: res.data.payOrderToken,
  584. },
  585. success: res => {
  586. tt.showLoading({
  587. title: '订单正在处理中...',
  588. })
  589. if (res.code === 0) {
  590. that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that, that.data.composeOrderType);
  591. if (res.errMsg == "requestPayment:ok") {
  592. /**
  593. * 用户支付成功以后跳转到券包列表
  594. */
  595. if (that.data.cardType == 100) {
  596. tt.setStorage({
  597. key: 'couponNum2',
  598. data: "couponNum2"
  599. })
  600. } else if (that.data.data.type != 5 && that.data.cardType != 100) {
  601. tt.setStorage({
  602. key: 'couponNum',
  603. data: "couponNum"
  604. })
  605. }
  606. }
  607. } else if (res.code === 1) {
  608. that.setData({
  609. showbutton: false
  610. })
  611. tt.hideLoading();
  612. tt.showToast({
  613. title: '支付超时', // 内容
  614. icon: "none"
  615. });
  616. } else if (res.code === 2) {
  617. that.setData({
  618. showbutton: false
  619. })
  620. tt.hideLoading();
  621. tt.showToast({
  622. title: '支付失败', // 内容
  623. icon: "none"
  624. });
  625. } else if (res.code === 3) {
  626. that.setData({
  627. showbutton: false
  628. })
  629. tt.hideLoading();
  630. tt.showToast({
  631. title: '支付关闭', // 内容
  632. icon: "none"
  633. });
  634. } else if (res.code === 4) {
  635. that.setData({
  636. showbutton: false
  637. })
  638. tt.hideLoading();
  639. tt.showToast({
  640. title: '支付取消', // 内容
  641. icon: "none"
  642. });
  643. } else if (res.code === 9) {
  644. that.setData({
  645. showbutton: false
  646. })
  647. tt.hideLoading();
  648. tt.showToast({
  649. title: '订单状态开发者自行获取', // 内容
  650. icon: "none"
  651. });
  652. }
  653. },
  654. fail: res => {
  655. tt.hideLoading();
  656. /**
  657. * 支付失败,需要更新订单的状态
  658. */
  659. that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that, that.data.composeOrderType);
  660. that.setData({
  661. showbutton: false
  662. })
  663. return;
  664. },
  665. complete: res => {}
  666. });
  667. /// End payment --------
  668. })
  669. .catch(err => {
  670. tt.hideLoading();
  671. tt.showToast({
  672. title: err.message,
  673. icon: 'none',
  674. duration: 2000,
  675. mask: false
  676. });
  677. })
  678. }
  679. } else {
  680. // 免费券
  681. that.payOrderUpdate(orderId, "0", 1, '', 'free', that, that.data.composeOrderType);
  682. if (that.data.cardType == 100) {
  683. tt.setStorage({
  684. key: 'couponNum2',
  685. data: "couponNum2"
  686. })
  687. } else if (that.data.data.type != "5" && that.data.cardType != 100) {
  688. tt.setStorage({
  689. key: 'couponNum',
  690. data: "couponNum"
  691. })
  692. }
  693. }
  694. }
  695. } else {
  696. if (res) {
  697. tt.navigateTo({
  698. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.mainOrderId}&composeOrderType=${res.data.composeOrderType}`,
  699. })
  700. }
  701. }
  702. }).catch(err => {
  703. tt.hideLoading();
  704. that.setData({
  705. showbutton: false,
  706. })
  707. if (err.code == 3012) {
  708. that.getUnPaidOrder(that.data.couponId);
  709. } else {
  710. tt.showToast({
  711. title: err.message ? err.message : err.data,
  712. icon: 'none',
  713. duration: 2000,
  714. success(res) {
  715. console.log(res);
  716. },
  717. fail(res) {
  718. console.log("showToast 调用失败", res);
  719. },
  720. });
  721. }
  722. })
  723. // } else {
  724. // //有价券
  725. // console.log(tt.canIUse('createOrder'), "是否支持2.0js-api");
  726. // if (tt.canIUse('createOrder')) {
  727. // //支持 支付2.0 js-api
  728. // let tempCallbackData = {}
  729. // tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id
  730. // let options = {
  731. // callbackData: tempCallbackData,
  732. // goodsList: [
  733. // {
  734. // quantity: 1, // 购买数量 必填
  735. // price: that.data.priceAndStockObj.salePrice, // 商品价格 必填
  736. // goodsName: that.data.data.title, // 商品名称 必填
  737. // goodsPhoto: that.data.data.coverImg, // 商品图片链接 必填
  738. // goodsId: that.data.data.couponChannel.ttSpuId, // 商品ID 必填
  739. // goodsType: 1, // 商品类型 必填
  740. // goodsLabels: ['过期退', '随时退', '免预约'], // 商品标签 非必填
  741. // dateRule: '', // 使用规则 非必填
  742. // },
  743. // ],
  744. // payment: {
  745. // totalAmount: that.data.priceAndStockObj.salePrice, // 订单总价 必填
  746. // },
  747. // success: res => {
  748. // tt.hideLoading();
  749. // that.setData({
  750. // showbutton: false,
  751. // })
  752. // const { orderId, outOrderNo } = res;
  753. // that.setData({ orderId, outOrderNo });
  754. // that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, '');
  755. // },
  756. // fail: res => {
  757. // const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
  758. // if (errLogId) {
  759. // tt.hideLoading();
  760. // that.setData({
  761. // showbutton: false,
  762. // })
  763. // console.log('预下单失败', errNo, errMsg, errLogId);
  764. // let tempErrmsg = errMsg.split('开发者拒绝交易:');
  765. // tt.showToast({
  766. // title: tempErrmsg[tempErrmsg.length - 1],
  767. // icon: 'none',
  768. // duration: 2000,
  769. // mask: false
  770. // });
  771. // }
  772. // if (orderId || outOrderNo) {
  773. // tt.hideLoading();
  774. // that.setData({
  775. // showbutton: false,
  776. // })
  777. // console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
  778. // console.log(that.payOrderUpdate, "payOrderUpdate");
  779. // tt.showToast({
  780. // title: "取消支付",
  781. // icon: 'none',
  782. // duration: 2000,
  783. // mask: false
  784. // });
  785. // that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail')
  786. // }
  787. // },
  788. // }
  789. // console.log(options, "options");
  790. // tt.createOrder(options)
  791. // } else {
  792. // //不支持 支付2.0 js -api
  793. // }
  794. // }
  795. }).catch(err => {
  796. tt.hideLoading()
  797. that.setData({
  798. showbutton: false,
  799. })
  800. if (err.code == 2011) {
  801. tt.showToast({
  802. title: "商户信息没找到",
  803. image: './../../../assets/images/fail.png',
  804. duration: 2000,
  805. mask: false
  806. });
  807. } else if (err.code == 2013) {
  808. tt.showToast({
  809. title: "商户信息禁用",
  810. image: './../../../assets/images/fail.png',
  811. duration: 2000,
  812. mask: false
  813. });
  814. } else if (err.code == 3000) {
  815. tt.showToast({
  816. title: "库存不足",
  817. image: './../../../assets/images/fail.png',
  818. duration: 2000,
  819. mask: false
  820. });
  821. } else if (err.code == 3001) {
  822. tt.showToast({
  823. title: "您已超过限购",
  824. image: './../../../assets/images/fail.png',
  825. duration: 2000,
  826. mask: false
  827. });
  828. } else if (err.code == 3002) {
  829. tt.showToast({
  830. title: "订单失败",
  831. image: './../../../assets/images/fail.png',
  832. duration: 2000,
  833. mask: false
  834. });
  835. } else if (err.code == 3003) {
  836. tt.showToast({
  837. title: "订单不存在",
  838. image: './../../../assets/images/fail.png',
  839. duration: 2000,
  840. mask: false
  841. });
  842. } else if (err.code == 3004) {
  843. tt.showToast({
  844. title: "订单不存在",
  845. image: './../../../assets/images/fail.png',
  846. duration: 2000,
  847. mask: false
  848. });
  849. } else if (err.code == 4003) {
  850. tt.showToast({
  851. title: "卡券已作废",
  852. image: './../../../assets/images/fail.png',
  853. duration: 2000,
  854. mask: false
  855. });
  856. } else if (err.code == 3012) {
  857. that.getUnPaidOrder(that.data.couponId);
  858. } else if (err.code == 11005) {
  859. /**
  860. * 将值传到用户手机号授权的页面
  861. *
  862. */
  863. if (app.globalData.ifCongPh == 1) {
  864. tt.navigateTo({
  865. url: `/pages/getPhone/getPhone?couponChannelId=${that.data.couponChannelId}&mallTenantId=${that.data.mallTenantId}&path=qr`,
  866. });
  867. } else {
  868. this.setData({
  869. showPhoem: true
  870. })
  871. }
  872. } else if (err.code == 11006) {
  873. // 用户手机已加密
  874. tt.navigateTo({
  875. url: `/pages/getPhone/getPhone?couponChannelId=${that.data.couponChannelId}&mallTenantId=${that.data.mallTenantId}&path=qr`
  876. });
  877. } else {
  878. tt.showToast({
  879. title: err.message,
  880. icon: 'none',
  881. duration: 2000,
  882. mask: false
  883. });
  884. }
  885. })
  886. }).catch(err => {
  887. tt.hideLoading()
  888. that.setData({
  889. showbutton: false,
  890. })
  891. console.log(err)
  892. if (err.code == 11004) {
  893. tt.navigateTo({
  894. url: `/pages/getuserinfo/getuserinfo?fromflag=confirmation&confirmationFlag=${that.data.couponChannelId}&mallTenantId=${that.data.mallTenantId}`,
  895. })
  896. } else {
  897. tt.showToast({
  898. title: err.message,
  899. icon: "none",
  900. duration: 2500
  901. })
  902. }
  903. })
  904. },
  905. })