laundry-info.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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. ¥{{(Number(item.price)*Number(item.goods_num)).toFixed(2)}}
  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-space mb-24">
  91. <view class="fs-28 fc-3">
  92. 配送费
  93. </view>
  94. <view class="fs-32 fc-3">
  95. ¥{{infoData.delivery_money}}
  96. </view>
  97. </view>
  98. <view class="align-items-center flex-justify-end">
  99. <view class="fs-28 fc-9">
  100. 共{{infoData.goods_number}}件,
  101. </view>
  102. <view class="fs-28 fc-3">
  103. 金额
  104. </view>
  105. <view class="fs-24 fw-600 fc-3">
  106. ¥
  107. </view>
  108. <view class="fs-36 fw-600 fc-3">
  109. {{infoData.pay_money}}
  110. </view>
  111. </view>
  112. </view>
  113. <view class="bgc-f b-rad-20 p-24 box-border-box mb-20">
  114. <view class="display-flex flex-justify-space mb-26">
  115. <view class="fs-28 fc-9">
  116. 订单编号
  117. </view>
  118. <view class="align-items-center flex-justify-end">
  119. <view class="fs-28 fc-3 w-480 mr-8 text-align-right">
  120. {{infoData.order_sn}}
  121. </view>
  122. <image class="icon-fz" src="@/static/img/order/fz.png" mode="" @click="copy(infoData.order_sn)">
  123. </image>
  124. </view>
  125. </view>
  126. <view class="display-flex flex-justify-space mb-26">
  127. <view class="fs-28 fc-9">
  128. 识别码
  129. </view>
  130. <view class="fs-28 fc-3 w-480 text-align-right">
  131. {{infoData.only_code}}
  132. </view>
  133. </view>
  134. <view class="display-flex flex-justify-space mb-26">
  135. <view class="fs-28 fc-9">
  136. 下单时间
  137. </view>
  138. <view class="fs-28 fc-3 w-480 text-align-right">
  139. {{infoData.created_at}}
  140. </view>
  141. </view>
  142. <view class="display-flex flex-justify-space mb-26">
  143. <view class="fs-28 fc-9">
  144. 支付方式
  145. </view>
  146. <view class="fs-28 fc-3 w-480 text-align-right">
  147. {{infoData.pay_type_str}}
  148. </view>
  149. </view>
  150. <view class="display-flex flex-justify-space">
  151. <view class="fs-28 fc-9">
  152. 备注
  153. </view>
  154. <view class="fs-28 fc-3 w-480 text-align-right">
  155. {{infoData.note?infoData.note:'无'}}
  156. </view>
  157. </view>
  158. </view>
  159. </scroll-view>
  160. </view>
  161. </template>
  162. <script>
  163. import {
  164. laundryOrderInfo,
  165. laundryOrderCancel,
  166. laundryPay
  167. } from "@/api/laundryOrder.js"
  168. import tools from "@/service/tools";
  169. export default {
  170. components: {},
  171. data() {
  172. return {
  173. goodsData: [{
  174. name: '1'
  175. }, {
  176. name: '2'
  177. }],
  178. goodsShow: true,
  179. infoData: {},
  180. time: {
  181. day: '',
  182. h: "",
  183. m: '',
  184. s: '',
  185. },
  186. isAJAX: false
  187. };
  188. },
  189. onLoad(data) {
  190. if (data) {
  191. // console.log(data);
  192. this.laundryOrderInfo(data.orderId)
  193. }
  194. },
  195. mounted() {},
  196. onUnload() {
  197. const takeOutData = {}
  198. laundryOrderInfo({
  199. order_id: this.infoData.id
  200. }).then((res) => {
  201. if (res.code == 1) {
  202. takeOutData.id = this.infoData.id
  203. takeOutData.order_status = res.data.order_status
  204. takeOutData.order_status_str = res.data.order_status_str
  205. uni.$emit('takeOutData', takeOutData)
  206. }
  207. })
  208. },
  209. methods: {
  210. copy(value) {
  211. uni.setClipboardData({
  212. data: value,
  213. success() {
  214. tools.success('复制成功')
  215. },
  216. fail() {
  217. tools.error("复制失败")
  218. }
  219. })
  220. },
  221. goToUrl() {
  222. uni.navigateTo({
  223. url: '/pages-buy/dry-clean'
  224. })
  225. },
  226. pay() {
  227. this.getExpressPay(this.infoData.id)
  228. },
  229. getExpressPay(id) {
  230. // 干洗支付
  231. if (this.isAJAX) {
  232. return
  233. }
  234. this.isAJAX = true;
  235. laundryPay({
  236. order_id: id
  237. }).then((ret) => {
  238. if (ret.code === 1) {
  239. uni.requestPayment({
  240. provider: "wxpay", //支付类型-固定值
  241. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  242. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  243. package: ret.data.wx_pay.package, // 固定值
  244. signType: ret.data.wx_pay.signType, //固定值
  245. paySign: ret.data.wx_pay.paySign, //签名
  246. success: (ren) => {
  247. tools.success("支付成功");
  248. this.isAJAX = false;
  249. this.laundryOrderInfo(this.infoData.id)
  250. },
  251. fail: (err) => {
  252. this.isAJAX = false;
  253. tools.error("支付失败");
  254. },
  255. });
  256. } else {
  257. this.isAJAX = false;
  258. tools.error("支付失败");
  259. }
  260. })
  261. },
  262. cancelOrder() {
  263. // 干洗取消订单
  264. uni.showModal({
  265. title: '提示',
  266. content: '是否取消订单?',
  267. confirmText: '确定',
  268. confirmColor: '#FB3D03',
  269. success: (res) => {
  270. if (res.confirm === true) {
  271. if (this.isAJAX) {
  272. return
  273. }
  274. this.isAJAX = true;
  275. laundryOrderCancel({
  276. order_id: this.infoData.id
  277. }).then((res) => {
  278. if (res.code == 1) {
  279. tools.success(res.msg)
  280. setTimeout(() => {
  281. this.laundryOrderInfo(this.infoData.id)
  282. }, 1500)
  283. this.isAJAX = false;
  284. } else {
  285. tools.error(res.msg)
  286. this.isAJAX = false;
  287. }
  288. })
  289. }
  290. }
  291. });
  292. },
  293. openGoods() {
  294. this.goodsShow = !this.goodsShow
  295. },
  296. scrolltolower() {
  297. // console.log('触底');
  298. },
  299. laundryOrderInfo(id) {
  300. laundryOrderInfo({
  301. order_id: id
  302. }).then((res) => {
  303. if (res.code == 1) {
  304. this.infoData = res.data
  305. if (this.infoData.order_status == 1) {
  306. let createDate = new Date(res.data.created_at); //格式化订单创建时候的时间
  307. createDate.setMinutes(createDate.getMinutes() + 10)
  308. this.setCountDown(createDate)
  309. }
  310. }
  311. })
  312. },
  313. setCountDown(sTime) {
  314. let end = new Date(sTime).getTime();
  315. let now = new Date().getTime();
  316. let msec = end - now;
  317. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  318. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  319. let m = parseInt(msec / 1000 / 60 % 60);
  320. let s = parseInt(msec / 1000 % 60);
  321. this.time.h = h > 9 ? h : '0' + h;
  322. this.time.m = m > 9 ? m : '0' + m;
  323. this.time.s = s > 9 ? s : '0' + s;
  324. msec -= 1000;
  325. if (this.time.day >= 1) {
  326. this.showTime = true;
  327. } else {
  328. this.showTime = false;
  329. };
  330. if (msec >= 0) {
  331. setTimeout(() => {
  332. this.setCountDown(sTime);
  333. }, 1000);
  334. } else {
  335. this.isTimeEnd = true;
  336. this.bText = '活动结束';
  337. this.time.h = '--';
  338. this.time.m = '--';
  339. this.time.s = '--';
  340. };
  341. }
  342. },
  343. }
  344. </script>
  345. <style lang="scss" scoped>
  346. .bg-img {
  347. position: fixed;
  348. left: 0;
  349. top: 0;
  350. z-index: -1;
  351. width: 100%;
  352. height: 320rpx;
  353. }
  354. .w-33 {
  355. width: 33%;
  356. position: relative;
  357. }
  358. .item-box-button {
  359. position: absolute;
  360. width: 100%;
  361. height: 88rpx;
  362. top: 0;
  363. left: 0;
  364. z-index: 100;
  365. background-color: transparent;
  366. border: none !important;
  367. }
  368. button::after {
  369. border: none !important;
  370. }
  371. .p-24-24-0 {
  372. padding: 24rpx 24rpx 0;
  373. }
  374. .icon {
  375. width: 48rpx;
  376. height: 48rpx;
  377. }
  378. .w-420 {
  379. width: 420rpx;
  380. }
  381. .goods-img {
  382. width: 108rpx;
  383. height: 108rpx;
  384. border-radius: 8rpx;
  385. }
  386. .w-376 {
  387. width: 376rpx;
  388. }
  389. .icon-right {
  390. width: 32rpx;
  391. height: 32rpx;
  392. }
  393. .w-480 {
  394. width: 480rpx;
  395. }
  396. .icon-fz {
  397. width: 24rpx;
  398. height: 24rpx;
  399. }
  400. .goods-box {
  401. overflow: hidden;
  402. }
  403. .goodsShowOne {
  404. max-height: 508rpx;
  405. transition: all .5s linear;
  406. }
  407. .goodsShowTwo {
  408. height: auto;
  409. transition: all .5s linear;
  410. }
  411. </style>