laundry-info.vue 11 KB

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