laundry-info.vue 10 KB

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