laundry-info.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view class="flex-common-css">
  3. <Nav title=" " leftIconColor="#333" titleColor="#333" bgckgroundBox='transparent'></Nav>
  4. <image class="bg-img" src="@/static/img/order/bg.png" mode=""></image>
  5. <view class="p-24-24-0 box-border-box">
  6. <view class="mb-24" v-if="infoData.order_status == 1">
  7. <view class="fs-40 fc-3 mb-8">
  8. {{infoData.order_status_str}},剩余{{time.m}}:{{time.s}}
  9. </view>
  10. <view class="fs-24 fc-FB3D03">
  11. 10分钟内未支付,订单将自动取消
  12. </view>
  13. </view>
  14. <view class="mb-24" v-else>
  15. <view class="fs-48 fc-3 fw-600">
  16. {{infoData.order_status_str}}
  17. </view>
  18. </view>
  19. <view class="bgc-f b-rad-20 p-24 box-border-box">
  20. <view class="p-b-20 mb-24 b-b-F9F9F9 fs-32 fc-3" v-show="infoData.order_status == 1">
  21. 请尽快支付
  22. </view>
  23. <view class="p-b-20 mb-24 b-b-F9F9F9 fs-32 fc-3"
  24. v-show="infoData.order_status == 5 || infoData.order_status == 6">
  25. 感谢你对君子校园的信任,期待你再次光临
  26. </view>
  27. <view class="align-items-center flex-wrap-wrap">
  28. <view class="w-33 flex-direction align-items-center" @click="pay"
  29. v-show="infoData.order_status == 1">
  30. <image class="mb-4 icon" src="@/static/img/order/qzf.png" mode=""></image>
  31. <view class="fs-24 fc-41ABF5">
  32. 去支付
  33. </view>
  34. </view>
  35. <view @click="goToUrl" class="w-33 flex-direction align-items-center"
  36. v-show="infoData.order_status == 5 || infoData.order_status == 6 || infoData.order_status == 7">
  37. <image class="mb-4 icon" src="@/static/img/order/zlyd.png" mode=""></image>
  38. <view class="fs-24 fc-41ABF5">
  39. 再来一单
  40. </view>
  41. </view>
  42. <view class="w-33 flex-direction align-items-center">
  43. <button class="item-box-button" open-type="contact" :bindcontact="handleContact"></button>
  44. <image class="mb-4 icon" src="@/static/img/order/lxkf.png" mode=""></image>
  45. <view class="fs-24 fc-3">
  46. 联系客服
  47. </view>
  48. </view>
  49. <view class="w-33 flex-direction align-items-center" v-show="infoData.order_status == 2"
  50. @click="cancelOrder">
  51. <image class="mb-4 icon" src="@/static/img/order/qxdd.png" mode=""></image>
  52. <view class="fs-24 fc-3">
  53. 取消订单
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <scroll-view :scroll-y="true" class="scroll-view-css p-24 box-border-box" @scrolltolower="scrolltolower">
  60. <view class="bgc-f b-rad-20 p-24 box-border-box mb-20">
  61. <view class="w-420 fc-3 fs-32 fw-600 text-overflow-ellipsis-one mb-24">
  62. {{infoData.site_name}}
  63. </view>
  64. <view class="goods-box" :class="infoData.item.length >= 4 && goodsShow?'goodsShowOne':'goodsShowTwo'">
  65. <view class="align-items-center flex-justify-space mb-20" v-for="(item,index) in infoData.item">
  66. <image class="goods-img mr-16" :src="item.goods_img" mode=""></image>
  67. <view class="">
  68. <view class="align-items-center flex-justify-space mb-2">
  69. <view class="fs-28 fc-3 w-376 text-overflow-ellipsis-one mr-36">
  70. {{item.goods_name}}
  71. </view>
  72. <view class="fs-32 fc-3 fw-600">
  73. ¥{{item.goods_money}}
  74. </view>
  75. </view>
  76. <view class="fs-24 fc-9">
  77. x{{item.goods_num}}
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="align-items-center flex-justify-center p-24 b-b-F9F9F9 mb-32" @click="openGoods"
  83. v-if="infoData.item.length > 4 && infoData.item">
  84. <view class="fs-24 fc-9 mr-4">
  85. {{goodsShow?'展开':'收起'}}{{infoData.item.length - 4}}件商品
  86. </view>
  87. <image v-if="goodsShow" class="icon-right" src="@/static/img/order/top.png" mode=""></image>
  88. <image v-else class="icon-right" src="@/static/img/order/bottom.png" mode=""></image>
  89. </view>
  90. <view class="align-items-center flex-justify-end">
  91. <view class="fs-28 fc-9">
  92. 共{{infoData.goods_number}}件,
  93. </view>
  94. <view class="fs-28 fc-3">
  95. 金额
  96. </view>
  97. <view class="fs-24 fw-600 fc-3">
  98. ¥
  99. </view>
  100. <view class="fs-36 fw-600 fc-3">
  101. {{infoData.pay_money}}
  102. </view>
  103. </view>
  104. </view>
  105. <view class="bgc-f b-rad-20 p-24 box-border-box mb-20">
  106. <view class="display-flex flex-justify-space mb-26">
  107. <view class="fs-28 fc-9">
  108. 订单编号
  109. </view>
  110. <view class="align-items-center flex-justify-end">
  111. <view class="fs-28 fc-3 w-480 mr-8 text-align-right">
  112. {{infoData.order_sn}}
  113. </view>
  114. <image class="icon-fz" src="@/static/img/order/fz.png" mode="" @click="copy(infoData.order_sn)"></image>
  115. </view>
  116. </view>
  117. <view class="display-flex flex-justify-space mb-26">
  118. <view class="fs-28 fc-9">
  119. 识别码
  120. </view>
  121. <view class="fs-28 fc-3 w-480 text-align-right">
  122. {{infoData.only_code}}
  123. </view>
  124. </view>
  125. <view class="display-flex flex-justify-space mb-26">
  126. <view class="fs-28 fc-9">
  127. 下单时间
  128. </view>
  129. <view class="fs-28 fc-3 w-480 text-align-right">
  130. {{infoData.created_at}}
  131. </view>
  132. </view>
  133. <view class="display-flex flex-justify-space mb-26">
  134. <view class="fs-28 fc-9">
  135. 支付方式
  136. </view>
  137. <view class="fs-28 fc-3 w-480 text-align-right">
  138. {{infoData.pay_type_str}}
  139. </view>
  140. </view>
  141. <view class="display-flex flex-justify-space">
  142. <view class="fs-28 fc-9">
  143. 备注
  144. </view>
  145. <view class="fs-28 fc-3 w-480 text-align-right">
  146. {{infoData.note?infoData.note:'无'}}
  147. </view>
  148. </view>
  149. </view>
  150. </scroll-view>
  151. </view>
  152. </template>
  153. <script>
  154. import {
  155. laundryOrderInfo,
  156. laundryOrderCancel,
  157. laundryPay
  158. } from "@/api/laundryOrder.js"
  159. import tools from "@/service/tools";
  160. export default {
  161. components: {},
  162. data() {
  163. return {
  164. goodsData: [{
  165. name: '1'
  166. }, {
  167. name: '2'
  168. }],
  169. goodsShow: true,
  170. infoData: {},
  171. time: {
  172. day: '',
  173. h: "",
  174. m: '',
  175. s: '',
  176. },
  177. isAJAX: false
  178. };
  179. },
  180. onLoad(data) {
  181. if (data) {
  182. // console.log(data);
  183. this.laundryOrderInfo(data.orderId)
  184. }
  185. },
  186. mounted() {},
  187. onUnload() {
  188. const takeOutData = {}
  189. laundryOrderInfo({
  190. order_id: this.infoData.id
  191. }).then((res) => {
  192. if (res.code == 1) {
  193. takeOutData.id = this.infoData.id
  194. takeOutData.order_status = res.data.order_status
  195. takeOutData.order_status_str = res.data.order_status_str
  196. uni.$emit('takeOutData', takeOutData)
  197. }
  198. })
  199. },
  200. methods: {
  201. copy(value) {
  202. uni.setClipboardData({
  203. data: value,
  204. success() {
  205. tools.success('复制成功')
  206. },
  207. fail() {
  208. tools.error("复制失败")
  209. }
  210. })
  211. },
  212. goToUrl() {
  213. uni.navigateTo({
  214. url: '/pages-buy/dry-clean'
  215. })
  216. },
  217. pay() {
  218. this.getExpressPay(this.infoData.id)
  219. },
  220. getExpressPay(id) {
  221. // 干洗支付
  222. if (this.isAJAX) {
  223. return
  224. }
  225. this.isAJAX = true;
  226. laundryPay({
  227. order_id: id
  228. }).then((ret) => {
  229. if (ret.code === 1) {
  230. uni.requestPayment({
  231. provider: "wxpay", //支付类型-固定值
  232. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  233. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  234. package: ret.data.wx_pay.package, // 固定值
  235. signType: ret.data.wx_pay.signType, //固定值
  236. paySign: ret.data.wx_pay.paySign, //签名
  237. success: (ren) => {
  238. tools.success("支付成功");
  239. this.isAJAX = false;
  240. this.laundryOrderInfo(this.infoData.id)
  241. },
  242. fail: (err) => {
  243. this.isAJAX = false;
  244. tools.error("支付失败");
  245. },
  246. });
  247. } else {
  248. this.isAJAX = false;
  249. tools.error("支付失败");
  250. }
  251. })
  252. },
  253. cancelOrder() {
  254. // 干洗取消订单
  255. uni.showModal({
  256. title: '提示',
  257. content: '是否取消订单?',
  258. confirmText: '确定',
  259. confirmColor: '#FB3D03',
  260. success: (res) => {
  261. if (res.confirm === true) {
  262. if (this.isAJAX) {
  263. return
  264. }
  265. this.isAJAX = true;
  266. laundryOrderCancel({
  267. order_id: this.infoData.id
  268. }).then((res) => {
  269. if (res.code == 1) {
  270. tools.success(res.msg)
  271. setTimeout(() =>{
  272. this.laundryOrderInfo(this.infoData.id)
  273. }, 1500)
  274. this.isAJAX = false;
  275. } else {
  276. tools.error(res.msg)
  277. this.isAJAX = false;
  278. }
  279. })
  280. }
  281. }
  282. });
  283. },
  284. openGoods() {
  285. this.goodsShow = !this.goodsShow
  286. },
  287. scrolltolower() {
  288. // console.log('触底');
  289. },
  290. laundryOrderInfo(id) {
  291. laundryOrderInfo({
  292. order_id: id
  293. }).then((res) => {
  294. if (res.code == 1) {
  295. this.infoData = res.data
  296. if (this.infoData.order_status == 1) {
  297. let createDate = new Date(res.data.created_at); //格式化订单创建时候的时间
  298. createDate.setMinutes(createDate.getMinutes() + 10)
  299. this.setCountDown(createDate)
  300. }
  301. }
  302. })
  303. },
  304. setCountDown(sTime) {
  305. let end = new Date(sTime).getTime();
  306. let now = new Date().getTime();
  307. let msec = end - now;
  308. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  309. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  310. let m = parseInt(msec / 1000 / 60 % 60);
  311. let s = parseInt(msec / 1000 % 60);
  312. this.time.h = h > 9 ? h : '0' + h;
  313. this.time.m = m > 9 ? m : '0' + m;
  314. this.time.s = s > 9 ? s : '0' + s;
  315. msec -= 1000;
  316. if (this.time.day >= 1) {
  317. this.showTime = true;
  318. } else {
  319. this.showTime = false;
  320. };
  321. if (msec >= 0) {
  322. setTimeout(() => {
  323. this.setCountDown(sTime);
  324. }, 1000);
  325. } else {
  326. this.isTimeEnd = true;
  327. this.bText = '活动结束';
  328. this.time.h = '--';
  329. this.time.m = '--';
  330. this.time.s = '--';
  331. };
  332. }
  333. },
  334. }
  335. </script>
  336. <style lang="scss" scoped>
  337. .bg-img {
  338. position: fixed;
  339. left: 0;
  340. top: 0;
  341. z-index: -1;
  342. width: 100%;
  343. height: 320rpx;
  344. }
  345. .w-33 {
  346. width: 33%;
  347. position: relative;
  348. }
  349. .item-box-button {
  350. position: absolute;
  351. width: 100%;
  352. height: 88rpx;
  353. top: 0;
  354. left: 0;
  355. z-index: 100;
  356. background-color: transparent;
  357. border: none !important;
  358. }
  359. button::after {
  360. border: none !important;
  361. }
  362. .p-24-24-0 {
  363. padding: 24rpx 24rpx 0;
  364. }
  365. .icon {
  366. width: 48rpx;
  367. height: 48rpx;
  368. }
  369. .w-420 {
  370. width: 420rpx;
  371. }
  372. .goods-img {
  373. width: 108rpx;
  374. height: 108rpx;
  375. border-radius: 8rpx;
  376. }
  377. .w-376 {
  378. width: 376rpx;
  379. }
  380. .icon-right {
  381. width: 32rpx;
  382. height: 32rpx;
  383. }
  384. .w-480 {
  385. width: 480rpx;
  386. }
  387. .icon-fz {
  388. width: 24rpx;
  389. height: 24rpx;
  390. }
  391. .goods-box {
  392. overflow: hidden;
  393. }
  394. .goodsShowOne {
  395. max-height: 508rpx;
  396. transition: all .5s linear;
  397. }
  398. .goodsShowTwo {
  399. height: auto;
  400. transition: all .5s linear;
  401. }
  402. </style>