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

index.js 32 KiB

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