抖音c端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px'
  2. let config = require("../../../config/config.js");
  3. let util = require("../../../utils/util");
  4. let Http = require("../../../utils/HttpBasics");
  5. let app = getApp();
  6. const imgurl = require("../../../utils/imgurl");
  7. const QR = require("../../../utils/memberqrcode.js");
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. curHtml: '',
  14. showIdFalg: false,
  15. outOrderNo: '', //支付2.0继续支付id
  16. payOrderNo: "", //评价订单id
  17. evaluateFlag: false, //控制评价显隐藏
  18. serviceUrl: '', //客服外部链接
  19. dynamicRq: "",
  20. expiredSeconds: 0,
  21. showhieRq: false,
  22. mouldType: 0,
  23. showFlag: false,
  24. navigationBarHeight,
  25. upDataRqUrlF: imgurl.upDataRqF.url,
  26. succUrl: imgurl.succ.url,
  27. spcodeUrl: imgurl.spcode.url,
  28. chevronUrl: imgurl.chevron.url,
  29. teljpgUrl: imgurl.teljpg.url,
  30. newUrl: imgurl.new1.url,
  31. weixinTitle: imgurl.weixinTitle.url,
  32. lineUrl: imgurl.line.url,
  33. wm01Url: imgurl.wm01.url,
  34. wm02Url: imgurl.wm02.url,
  35. wm03Url: imgurl.wm03.url,
  36. wm04Url: imgurl.wm04.url,
  37. showModalStatus: false,
  38. flag: 0,
  39. order: null,
  40. orderId: null,
  41. //存储计时器
  42. setInter: "",
  43. mystatus: '',
  44. staticGamedata: {},
  45. showIf: false,
  46. showPage: false,
  47. showButton: false,
  48. cardDetail: null,
  49. supportTransfer: '',
  50. cardIf: false,
  51. contentType: 0,
  52. orderFlag: false, //判断是不是线上配送
  53. },
  54. handleRefund(event) {
  55. const {
  56. status,
  57. result
  58. } = event.detail;
  59. if (status === 'success') {
  60. const {
  61. refundId,
  62. outRefundNo
  63. } = result;
  64. console.log(refundId, outRefundNo);
  65. } else {
  66. const {
  67. errMsg
  68. } = result;
  69. console.log(errMsg);
  70. }
  71. },
  72. applyRefund(event) {
  73. const {
  74. orderId
  75. } = event.detail;
  76. const extra = {
  77. orderId
  78. }; // 开发者需要透传的参数,可自定义内容
  79. return new Promise(resolve => {
  80. resolve(extra);
  81. });
  82. },
  83. showId() {
  84. let this_ = this;
  85. if (!this_.data.showIdFalg) {
  86. tt.showModal({
  87. // title: "查看券码",
  88. content: "是否查看完整券码",
  89. success(res) {
  90. if (res.confirm) {
  91. console.log("confirm, continued");
  92. this_.setData({
  93. showIdFalg: true
  94. })
  95. } else if (res.cancel) {
  96. //取消
  97. console.log("cancel, cold");
  98. } else {
  99. // what happend?
  100. }
  101. },
  102. fail(err) {
  103. console.log(`showModal 调用失败`, err);
  104. },
  105. });
  106. } else {
  107. this.setData({
  108. showIdFalg: false
  109. })
  110. }
  111. },
  112. copeCode(e) {
  113. let code = e.currentTarget.dataset.text
  114. tt.setClipboardData({
  115. data: code,
  116. success: function () {
  117. tt.showToast({
  118. title: '复制成功',
  119. icon: "none"
  120. })
  121. }
  122. })
  123. },
  124. gokuaidi(e) {
  125. let nu = e.currentTarget.dataset.nu
  126. tt.navigateToMiniProgram({
  127. appId: 'wx6885acbedba59c14',
  128. path: `pages/result/result?nu=${nu}&com=&querysource=third_xcx`
  129. })
  130. },
  131. setShow() {
  132. this.setData({
  133. showFlag: true
  134. })
  135. },
  136. hieShow() {
  137. this.setData({
  138. showFlag: false
  139. })
  140. },
  141. goDetail() {
  142. tt.navigateTo({
  143. url: `/pages/coupon/detail/index?couponChannelId=${this.data.order.couponChannelId}`,
  144. success: (res) => {
  145. },
  146. fail: (res) => {
  147. },
  148. });
  149. },
  150. refund() { //退款
  151. Http.post({
  152. url: config.api.refund,
  153. data: {
  154. orderId: this.data.order.id
  155. }
  156. }).then(res => {
  157. tt.navigateTo({
  158. url: `/pages/refund/refund?id=${this.data.order.id}`,
  159. success: (res) => {
  160. },
  161. fail: (res) => {
  162. },
  163. });
  164. }).catch(err => {
  165. tt.showToast({
  166. title: err.message ? err.message : err.data, // 内容
  167. icon: "none"
  168. });
  169. })
  170. },
  171. goRefund(e) {
  172. let this_ = this
  173. if (this_.data.order.couponOrderStatus == 0) {
  174. tt.showModal({
  175. title: "申请退款",
  176. content: "提交申请退款",
  177. confirmText: "确定",
  178. success(res) {
  179. if (res.confirm) {
  180. this_.refund()
  181. console.log("confirm, continued");
  182. } else if (res.cancel) {
  183. console.log("cancel, cold");
  184. } else {
  185. // what happend?
  186. }
  187. },
  188. fail(res) {
  189. console.log(`showModal调用失败`);
  190. },
  191. });
  192. } else if (this_.data.order.couponOrderStatus == 3) { //退款中
  193. tt.navigateTo({
  194. url: `/pages/refund/refund?id=${this.data.order.id}`,
  195. success: (res) => {
  196. },
  197. fail: (res) => {
  198. },
  199. });
  200. }
  201. },
  202. //刷新订单
  203. updetail() {
  204. let that = this
  205. let url = config.api.orderDetail
  206. Http.get({
  207. url: url,
  208. data: {
  209. orderId: this.data.orderId
  210. }
  211. }).then(res => {
  212. tt.hideLoading();
  213. var createDate = util.formatTime(res.data.orders[0].createDate, "yyyy-MM-dd");
  214. let tempData = res.data.orders[0]
  215. tempData.deliveryInfo = tempData.deliveryInfo ? JSON.parse(tempData.deliveryInfo) : ""
  216. tempData.itemGroup = tempData.itemGroup ? JSON.parse(tempData.itemGroup) : ""
  217. tempData.validStartDate = util.formatTime(tempData.validStartDate, "yyyy-MM-dd")
  218. tempData.validEndDate = util.formatTime(tempData.validEndDate, "yyyy-MM-dd")
  219. tempData.couponOrderIdS = tempData.couponOrderId ? tempData.couponOrderId.slice(0, 4) + `******` + tempData.couponOrderId.slice(14) : ''
  220. if (tempData.productAttrs && tempData.skuAttrs) {
  221. tempData.productAttrs = JSON.parse(tempData.productAttrs)
  222. tempData.skuAttrs = JSON.parse(tempData.skuAttrs)
  223. console.log(tempData.productAttrs);
  224. console.log(tempData.skuAttrs);
  225. console.log('****');
  226. tempData.productAttrs.map(item => {
  227. if (item.key == "appointment") {
  228. let tempAppoinObj = JSON.parse(item.data)
  229. if (tempAppoinObj.need_appointment) {
  230. let subscribeSing = "";
  231. if (tempAppoinObj.ahead_time_type == 1) {
  232. subscribeSing = `需提前${tempAppoinObj.ahead_day_num}天致电商家预约`
  233. } else if (tempAppoinObj.ahead_time_type == 2) {
  234. subscribeSing = `需提前${tempAppoinObj.ahead_hour_num}小时致电商家预约`
  235. } else if (tempAppoinObj.ahead_time_type == 3) {
  236. subscribeSing = `需提前${tempAppoinObj.ahead_minute_num}分钟致电商家预约`
  237. }
  238. tempData.subscribeSing = subscribeSing
  239. }
  240. }
  241. if (item.key == "Notification") {
  242. if (item.data != '') {
  243. tempData.curLsit = JSON.parse(item.data)
  244. }
  245. }
  246. if (item.key == "bring_out_meal") {
  247. tempData.besides = item.data
  248. }
  249. if (item.key == "free_pack") {
  250. tempData.pack = item.data
  251. }
  252. if (item.key == "superimposed_discounts") {
  253. tempData.superimposed_discounts = item.data
  254. }
  255. if (item.key == "private_room") {
  256. tempData.private_room = item.data
  257. }
  258. if (item.key == "rec_person_num_max") {
  259. tempData.rec_person_num_max = item.data
  260. }
  261. if (item.key == 'Description') {
  262. tempData.Description = JSON.parse(item.data)
  263. }
  264. if (item.key == "can_no_use_date") {
  265. tempData.can_no_use_date = JSON.parse(item.data)
  266. }
  267. })
  268. tempData.skuAttrs.map(item => {
  269. if (item.key == "commodity") {
  270. if (item.data != '') {
  271. tempData.itemGroup = JSON.parse(item.data)
  272. }
  273. }
  274. })
  275. }
  276. that.setData({
  277. outOrderNo: res.data.id,
  278. order: tempData,
  279. showPage: true,
  280. createDate: createDate,
  281. composeOrderType: tempData.composeOrderType,
  282. contentType: tempData.contentType ? tempData.contentType : 0,
  283. orderFlag: tempData.type == 11 ? true : false, //判断是不是线上配送
  284. })
  285. if (tempData.couponOrderId) { //0未付款 1已支付 2已取消 3退款中 4已退款
  286. that.setRq()
  287. // that.upStatus()
  288. let setInter = setInterval(() => {
  289. if (tempData.couponOrderStatus == 0) {
  290. Http.get({
  291. url: config.api.getStatus,
  292. data: {
  293. couponOrderId: tempData.couponOrderId
  294. }
  295. }).then(res => {
  296. console.log(res);
  297. that.setData({
  298. couponOrderStatus: res.data.CouponOrderStatus
  299. });
  300. if (res.data.CouponOrderStatus == 1 || res.data.CouponOrderStatus == 3) {
  301. /**
  302. * 动态改变上一级页面的核销状态
  303. */
  304. // that.getStaticGame()
  305. //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  306. clearInterval(that.data.setInter);
  307. clearInterval(that.data.templTiem);
  308. that.updetail()
  309. that.setData({
  310. mystatus: res.data.CouponOrderStatus
  311. });
  312. }
  313. })
  314. .catch(err => {
  315. tt.showToast({
  316. title: err.errMsg,
  317. icon: 'none',
  318. duration: 2000,
  319. mask: false
  320. });
  321. })
  322. }
  323. }, 2000);
  324. that.setData({
  325. setInter: setInter
  326. })
  327. }
  328. if (tempData.couponOrderStatus && tempData.couponOrderStatus == 1) { //核销后
  329. that.goIfEvaluate() //判断订单是否能评价
  330. }
  331. }).catch(error => {
  332. console.log(error, "error");
  333. tt.hideLoading();
  334. tt.showModal({
  335. title: '提示',
  336. content: error.errMsg,
  337. showCancel: false
  338. })
  339. })
  340. },
  341. //确认收货
  342. verify() {
  343. Http.post({
  344. url: config.api.verify,
  345. data: {
  346. couponOrderId: this.data.order.couponOrderId
  347. }
  348. }).then(res => {
  349. tt.showToast({
  350. title: '签收成功',
  351. icon: "none"
  352. })
  353. this.updetail()
  354. }).catch(err => {
  355. tt.showModal({
  356. title: '提示',
  357. content: err.message ? err.message : err.data,
  358. showCancel: false
  359. })
  360. })
  361. },
  362. phone: function (e) {
  363. let that = this;
  364. console.log(e);
  365. tt.makePhoneCall({
  366. phoneNumber: e.currentTarget.dataset.merchantlinkphone
  367. });
  368. },
  369. /**
  370. * 跳转到门店列表的详情页面
  371. */
  372. gotoDetail(e) {
  373. tt.navigateTo({
  374. url: `/pages/index/searchbar/detail/index?id=${e.currentTarget.dataset.id}`
  375. })
  376. },
  377. getUserInfo: function () {
  378. let that = this;
  379. // 获取用户信息
  380. Http.get({
  381. url: config.api.getScore,
  382. data: {}
  383. })
  384. .then(res => {
  385. console.log(res)
  386. that.setData({
  387. userName: res.data.nickName,
  388. avatarUrl: res.data.avatarUrl
  389. })
  390. })
  391. },
  392. onShareAppMessage: function (res) {
  393. app.globalData.previewFlag = true
  394. if (res.from === 'button') {
  395. console.log(res, 3333333333333333333333)
  396. // 来自页面内转发按钮
  397. let _this = this;
  398. return {
  399. title: _this.data.userName + '赠送您一张' + _this.data.order.title,
  400. path: '/pages/index/index?couponChannelId=' + this.data.order.couponChannelId + '&cuserId=' + this.data.order.cuserId + '&couponId=' + this.data.order.productId + '&coverImg=' + this.data.order.coverImg + '&userName=' + this.data.userName + '&avatarUrl=' + this.data.avatarUrl + '&couponOrderId=' + this.data.order.couponOrderId + '&updateDate=' + this.data.order.updateDate,
  401. imageUrl: this.data.order.coverImg,
  402. success: function (res) {
  403. // 转发成功
  404. },
  405. fail: function (res) {
  406. // 转发失败
  407. }
  408. }
  409. } else {
  410. console.log(res, 444444444444444444)
  411. }
  412. },
  413. createQrCode: function (url, canvasId, cavW, cavH) {
  414. //调用插件中的draw方法,绘制二维码图片
  415. let that = this;
  416. QR.api.draw(url, canvasId, cavW, cavH, function (res) {
  417. that.setData({
  418. tempFilePath: res
  419. })
  420. });
  421. },
  422. setRq() {
  423. let _this = this
  424. _this.setData({
  425. showhieRq: false,
  426. })
  427. Http.get({ //获取动态二维码
  428. url: config.api.dynamicId,
  429. data: {
  430. couponOrderId: _this.data.order.couponOrderId
  431. }
  432. }).then(res => {
  433. console.log(res, "res")
  434. _this.setData({
  435. dynamicRq: res.data.dynamicId,
  436. expiredSeconds: res.data.expiredSeconds
  437. })
  438. let url = JSON.stringify({
  439. END: "C",
  440. TYPE: "couponorder",
  441. ID: _this.data.dynamicRq
  442. })
  443. if (res.data.expiredSeconds == 0) {
  444. //倒计时为零直接显示券码
  445. } else {
  446. let inre = setInterval(() => {
  447. if (_this.data.expiredSeconds > 1) {
  448. _this.setData({
  449. expiredSeconds: _this.data.expiredSeconds - 1
  450. })
  451. // console.log("有效", _this.data.expiredSeconds)
  452. } else {
  453. // console.log("无效", _this.data.expiredSeconds)
  454. clearInterval(_this.data.templTiem)
  455. _this.setData({
  456. showhieRq: true
  457. })
  458. }
  459. _this.setData({
  460. templTiem: inre
  461. })
  462. }, 1000)
  463. }
  464. _this.createQrCode(url, "qrcode", 350, 350);
  465. }).catch(err => {
  466. tt.showToast({
  467. title: err.message,
  468. icon: 'none',
  469. duration: 2000,
  470. mask: false
  471. });
  472. })
  473. },
  474. goPaySnapshoot(e) {
  475. let id = e.currentTarget.dataset.id;
  476. tt.navigateTo({
  477. url: `/pages/paySnapshoot/paySnapshoot?id=${id}`,
  478. success: (res) => {
  479. },
  480. fail: (res) => {
  481. },
  482. });
  483. },
  484. powerDrawer: function (e) {
  485. let that = this;
  486. console.log(e)
  487. // couponOrderStatus
  488. // 0 未使用
  489. // 1 已使用
  490. // 2 已过期
  491. // 3 已经退款
  492. if (that.data.mystatus == "" || that.data.mystatus == undefined) {
  493. tt.navigateTo({
  494. url: `/pages/orderquanma/index?quancode=${e.currentTarget.dataset.quancode
  495. }&title=${e.currentTarget.dataset.title}&subtitle=${e.currentTarget.dataset.subtitle
  496. }&remark=${e.currentTarget.dataset.remark}&couponorderstatus=${e.currentTarget.dataset.couponorderstatus}&validstatus=${e.currentTarget.dataset.validstatus}
  497. &contentType=${that.data.contentType}`
  498. });
  499. } else {
  500. tt.navigateTo({
  501. url: `/pages/orderquanma/index?quancode=${e.currentTarget.dataset.quancode
  502. }&title=${e.currentTarget.dataset.title}&subtitle=${e.currentTarget.dataset.subtitle
  503. }&remark=${e.currentTarget.dataset.remark}&couponorderstatus=${that.data.mystatus}&validstatus=${e.currentTarget.dataset.validstatus}
  504. &contentType=${that.data.contentType}`
  505. });
  506. }
  507. },
  508. gotogame: function () {
  509. let that = this;
  510. tt.redirectTo({
  511. url: '/pages/game/index?url=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  512. })
  513. },
  514. // 买完卡跳转到立即使用页面
  515. gotoUse: function () {
  516. tt.navigateTo({
  517. url: '/pages/cardorder/index/index'
  518. })
  519. },
  520. // 获取游戏
  521. getStaticGame(token) {
  522. let _this = this;
  523. Http.get({
  524. url: config.api.getGame,
  525. data: {
  526. triggleAction: 3 // 购买触发
  527. }
  528. }).then(res => {
  529. if (res.data.id) {
  530. _this.setData({
  531. showIf: true
  532. })
  533. }
  534. _this.setData({
  535. staticGamedata: res.data
  536. })
  537. })
  538. .catch(err => {
  539. console.log(err);
  540. })
  541. },
  542. goEvaluate() {
  543. let _this = this
  544. tt.rateAwemeOrder({
  545. orderId: _this.data.payOrderNo,
  546. success({
  547. result
  548. }) {
  549. console.log(result);
  550. if (result) {
  551. tt.navigateBack({
  552. delta: 1,
  553. success: (res) => {
  554. },
  555. fail: (res) => {
  556. },
  557. });
  558. // 用户已经评价的逻辑
  559. } else {
  560. // 用户没有评价的逻辑
  561. }
  562. },
  563. fail(err) {
  564. console.log(err);
  565. },
  566. });
  567. },
  568. goIfEvaluate() {
  569. let _this = this
  570. Http.get({
  571. url: config.api.getchanId,
  572. data: {
  573. id: _this.data.order.couponOrderId
  574. }
  575. }).then(res => {
  576. tt.canRateAwemeOrders({
  577. orderIds: [res.data.payOrderNo],
  578. success({
  579. result
  580. }) {
  581. console.log("result", result);
  582. _this.setData({
  583. evaluateFlag: result[0],
  584. payOrderNo: res.data.payOrderNo
  585. })
  586. },
  587. fail(err) {
  588. console.log(err);
  589. },
  590. });
  591. }).catch(err => {
  592. tt.showToast({
  593. title: err.message ? err.message : err.data, // 内容
  594. icon: "none"
  595. });
  596. })
  597. },
  598. /**
  599. * 生命周期函数--监听页面加载
  600. */
  601. onLoad: function (options) {
  602. this.getSeUrl()
  603. this.setData({
  604. mouldType: app.globalData.mouldType
  605. })
  606. let that = this;
  607. // if (options.dingdan && options.dingdan == "order") {
  608. // }
  609. that.setData({
  610. orderId: options.orderId,
  611. });
  612. tt.hideShareMenu()
  613. if (options.cardIf) { //转赠 展示不需
  614. that.setData({
  615. cardIf: true
  616. })
  617. }
  618. tt.showLoading({
  619. title: "加载中"
  620. });
  621. },
  622. onShow: function () {
  623. let that = this;
  624. that.setData({
  625. showButton: false
  626. })
  627. that.updetail()
  628. },
  629. getSeUrl() { //获取客服链接
  630. const openId = tt.getStorageSync('openId');
  631. Http.post({
  632. url: config.api.getServiceUrl,
  633. data: {
  634. appid: app.globalData.appId,
  635. openid: openId
  636. }
  637. }).then(res => {
  638. this.setData({
  639. serviceUrl: res.data ? res.data : ''
  640. })
  641. if (res.data) {
  642. tt.setStorageSync('serviceData', res.data);
  643. }
  644. })
  645. },
  646. goWebView() {
  647. let _this = this
  648. tt.navigateTo({
  649. url: `/pages/serviceWebView/serviceWebView`,
  650. success: (res) => {
  651. },
  652. fail: (res) => {
  653. },
  654. });
  655. },
  656. /**
  657. * 去拼团
  658. */
  659. goToOrderGroup(orderId, orderGroupId, _this) {
  660. let that = this;
  661. // 支付成功
  662. Http.post({
  663. url: config.api.toOrderGroup,
  664. data: {
  665. id: orderGroupId,
  666. orderId,
  667. couponId: _this.data.order.productId
  668. }
  669. })
  670. .then(res => {
  671. tt.redirectTo({
  672. url: `/pages/spellDetail/index?orderId=${orderId}&couponId=${_this.data.order.productId}&orderGroupId=${res.data.orderGroupId}`
  673. });
  674. })
  675. .catch(err => {
  676. console.log(err);
  677. })
  678. // return;
  679. },
  680. /**
  681. * 发起支付
  682. */
  683. orderFunc(e) {
  684. var that = this;
  685. const orderId = "" + that.data.orderId;
  686. that.setData({
  687. showButton: true
  688. })
  689. tt.showLoading({
  690. title: "加载中..."
  691. });
  692. // if (true) {//兼容不支持支付2.0 js-api !tt.canIUse('createOrder')
  693. if (that.data.order.payment > 0) {
  694. if (tt.canIUse('createOrder')) { //支付2.0 js-api
  695. const outOrderNo = that.data.outOrderNo
  696. console.log(outOrderNo, "outOrderNo");
  697. Http.post({
  698. url: config.api.payOrderCreate_2,
  699. data: {
  700. // composeOrderId: outOrderNo
  701. orderId: outOrderNo,
  702. composeOrderType: that.data.composeOrderType
  703. }
  704. }).then(res => {
  705. if (res.data.createPay) {
  706. let tempCallbackData = {
  707. composeOrderId: res.data.outOrderNo
  708. }
  709. // tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id
  710. let options = {
  711. callbackData: tempCallbackData,
  712. goodsList: res.data.goodsList,
  713. payment: res.data.payment,
  714. success: res => {
  715. tt.hideLoading();
  716. that.setData({
  717. showbutton: false,
  718. })
  719. const {
  720. orderId,
  721. outOrderNo
  722. } = res;
  723. // that.setData({ orderId, outOrderNo });
  724. that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, '');
  725. },
  726. fail: res => {
  727. const {
  728. orderId,
  729. outOrderNo,
  730. errNo,
  731. errMsg,
  732. errLogId
  733. } = res;
  734. if (errLogId) {
  735. tt.hideLoading();
  736. that.setData({
  737. showbutton: false,
  738. })
  739. console.log('预下单失败', errNo, errMsg, errLogId);
  740. let tempErrmsg = errMsg.split('开发者拒绝交易:');
  741. tt.showToast({
  742. title: tempErrmsg[tempErrmsg.length - 1],
  743. icon: 'none',
  744. duration: 2000,
  745. mask: false
  746. });
  747. }
  748. if (orderId || outOrderNo) {
  749. tt.hideLoading();
  750. that.setData({
  751. showbutton: false,
  752. })
  753. console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
  754. console.log(that.payOrderUpdate, "payOrderUpdate");
  755. tt.showToast({
  756. title: "取消支付",
  757. icon: 'none',
  758. duration: 2000,
  759. mask: false
  760. });
  761. that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail')
  762. }
  763. },
  764. }
  765. console.log(options, "options");
  766. tt.createOrder(options)
  767. } else {
  768. tt.continueToPay({
  769. outOrderNo: res.data.outOrderNo, // 外部订单号 2个订单号必填一个
  770. success: res => {
  771. // const { orderId, outOrderNo } = res;
  772. // console.log('success res', res);
  773. // console.log('orderId', orderId, 'outOrderNo', outOrderNo);
  774. that.setData({
  775. showButton: false
  776. })
  777. tt.hideLoading();
  778. that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that); // 支付成功
  779. },
  780. fail: res => {
  781. const {
  782. orderId,
  783. outOrderNo,
  784. errNo,
  785. errMsg,
  786. errLogId
  787. } = res;
  788. if (errLogId) {
  789. console.log('查询订单信息失败', errNo, errMsg, errLogId);
  790. that.setData({
  791. showButton: false
  792. })
  793. tt.showToast({
  794. title: errMsg,
  795. icon: 'none',
  796. duration: 2000,
  797. mask: false
  798. });
  799. tt.hideLoading();
  800. }
  801. if (orderId || outOrderNo) {
  802. console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
  803. tt.showToast({
  804. title: errMsg,
  805. icon: 'none',
  806. duration: 2000,
  807. mask: false
  808. });
  809. that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail', that);
  810. that.setData({
  811. showButton: false
  812. })
  813. tt.hideLoading();
  814. }
  815. },
  816. });
  817. }
  818. }).catch(err => {
  819. tt.showToast({
  820. title: err.message ? err.message : err.data, // 内容
  821. icon: "none"
  822. });
  823. })
  824. } else { //不支持支付2.0 js-api
  825. tt.showToast({
  826. title: '请升级抖音', // 内容
  827. icon: "none"
  828. });
  829. return
  830. // 支付金额不为0
  831. Http.post({
  832. url: config.api.payOrderCreate,
  833. data: {
  834. orderId: orderId,
  835. composeOrderType: that.data.composeOrderType
  836. }
  837. }).then(res => {
  838. var payOrderId = "" + res.data.outOrderNo;
  839. tt.hideLoading();
  840. tt.pay({
  841. service: 5,
  842. orderInfo: {
  843. order_id: res.data.payOrderId,
  844. order_token: res.data.payOrderToken,
  845. },
  846. success: res => {
  847. tt.showLoading({
  848. title: '订单正在处理中...',
  849. })
  850. if (res.code == 0) {
  851. setTimeout(function () {
  852. tt.hideLoading()
  853. }, 5000)
  854. that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that); // 支付成功
  855. if (res.errMsg == "requestPayment:ok") {
  856. if (that.data.order.type == 100) {
  857. tt.setStorage({
  858. key: 'couponNum2',
  859. data: "couponNum2"
  860. })
  861. } else if (that.data.order.type != 5) {
  862. tt.setStorage({
  863. key: 'couponNum',
  864. data: "couponNum"
  865. })
  866. }
  867. }
  868. } else if (res.code === 1) {
  869. that.setData({
  870. showButton: false
  871. })
  872. tt.hideLoading();
  873. tt.showToast({
  874. title: '支付超时', // 内容
  875. icon: "none"
  876. });
  877. } else if (res.code === 2) {
  878. that.setData({
  879. showButton: false
  880. })
  881. tt.hideLoading();
  882. tt.showToast({
  883. title: '支付失败', // 内容
  884. icon: "none"
  885. });
  886. } else if (res.code === 3) {
  887. that.setData({
  888. showButton: false
  889. })
  890. tt.hideLoading();
  891. tt.showToast({
  892. title: '支付关闭', // 内容
  893. icon: "none"
  894. });
  895. } else if (res.code === 4) {
  896. that.setData({
  897. showButton: false
  898. })
  899. tt.hideLoading();
  900. tt.showToast({
  901. title: '支付取消', // 内容
  902. icon: "none"
  903. });
  904. } else if (res.code === 9) {
  905. that.setData({
  906. showButton: false
  907. })
  908. tt.hideLoading();
  909. tt.showToast({
  910. title: '订单状态开发者自行获取', // 内容
  911. icon: "none"
  912. });
  913. }
  914. },
  915. fail: res => {
  916. that.setData({
  917. showButton: false
  918. })
  919. that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that);
  920. return;
  921. },
  922. });
  923. }).catch(err => {
  924. tt.hideLoading();
  925. that.setData({
  926. showButton: false
  927. })
  928. tt.showModal({
  929. title: "抱歉",
  930. content: err.message,
  931. showCancel: false
  932. })
  933. });
  934. }
  935. } else {
  936. // 免费券
  937. that.payOrderUpdate(orderId, "0", 1, '', 'free') // 支付成功
  938. if (that.data.order.type == 100) {
  939. tt.setStorage({
  940. key: 'couponNum2',
  941. data: "couponNum2"
  942. })
  943. } else if (that.data.order.type != "5") {
  944. tt.setStorage({
  945. key: 'couponNum',
  946. data: "couponNum"
  947. })
  948. }
  949. tt.showToast({
  950. title: "支付成功",
  951. duration: 2000,
  952. image: imgurl.success.url,
  953. });
  954. }
  955. // } else {//支持 支付2.0 js-api
  956. // }
  957. },
  958. /**
  959. * 支付订单更新
  960. */
  961. payOrderUpdate: (orderId, payOrderId, status, reason, type, _this) => {
  962. // 支付成功
  963. Http.post({
  964. url: config.api.payOrderUpdate,
  965. data: {
  966. payOrderId: payOrderId,
  967. composeOrderId: orderId,
  968. status: status,
  969. reason: reason
  970. }
  971. })
  972. .then(res => {
  973. tt.hideLoading();
  974. _this.setData({
  975. showButton: false
  976. })
  977. if (!type && type != 'free') {
  978. tt.showToast({
  979. title: "购买成功",
  980. duration: 2000,
  981. image: imgurl.success.url,
  982. mask: false,
  983. success: function () {
  984. tt.showLoading({
  985. title: "加载中..."
  986. });
  987. setTimeout(function () {
  988. tt.hideLoading();
  989. }, 1600);
  990. setTimeout(() => {
  991. let url = ""
  992. if (_this.data.orderFlag) {
  993. tt.redirectTo({
  994. url: `/pages/order/detail/index?orderId=${orderId}&dingdan=order`
  995. });
  996. } else {
  997. tt.redirectTo({
  998. url: `/pages/order/detail/index?orderId=${orderId}`
  999. });
  1000. }
  1001. }, 1600);
  1002. }
  1003. });
  1004. } else if (type == 'free') {
  1005. tt.redirectTo({
  1006. url: `/pages/order/detail/index?orderId=${orderId}`
  1007. });
  1008. }
  1009. })
  1010. .catch(err => {
  1011. console.log(err)
  1012. if (!type) {
  1013. setTimeout(function () {
  1014. _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this);
  1015. }, 1500)
  1016. }
  1017. });
  1018. },
  1019. onUnload: function () {
  1020. let that = this;
  1021. clearInterval(that.data.setInter);
  1022. clearInterval(that.data.templTiem);
  1023. },
  1024. onHide: function () {
  1025. let that = this;
  1026. clearInterval(that.data.setInter);
  1027. clearInterval(that.data.templTiem);
  1028. },
  1029. });