order_mark.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <template>
  2. <view class="content">
  3. <!-- 第一层模块 -->
  4. <view class="one-order3" v-if="orderList.houseOrder.orderStatus == 8">
  5. <view class="one-order-title">订单已完成 / 期待您再次光临<text class="all-price">¥{{orderList.houseOrder.payPrice}}</text></view>
  6. <view class="one-order-menshi">水电扣除<text class="menshi-price">¥{{orderList.totalFree}}</text></view>
  7. <!-- <view class="room-button-6"@click="getOrderDelete(orderList.houseOrder.orderNumber)">
  8. <text>删除订单</text>
  9. </view> -->
  10. <view class="room-button2-6" @click="navigateToWanchengZaici(orderList.houseOrder.houseId)">
  11. <text>再次预定</text>
  12. </view>
  13. </view>
  14. <view class="one-order3" v-else-if="orderList.houseOrder.orderStatus == 5">
  15. <view class="one-order-title">待结账</view>
  16. <view class="one-order-menshi" v-if="billXin.flag==1">
  17. 预退款<text class="menshi-price">¥{{billXin.refundFee}}</text>
  18. </view>
  19. <view class="one-order-menshi" v-if="billXin.flag==2">
  20. 预补缴<text class="menshi-price">¥{{billXin.supperFee}}</text>
  21. </view>
  22. <!-- <view class="room-button-6">
  23. <text>删除订单</text>
  24. </view> -->
  25. <view class="room-button2-6" v-if="billXin.flag==1">
  26. <text>退款</text>
  27. </view>
  28. <view class="room-button2-6" v-if="billXin.flag==2">
  29. <text>补缴</text>
  30. </view>
  31. </view>
  32. <view class="one-order" v-else>
  33. <view class="one-order-title">
  34. <text v-if="orderList.houseOrder.orderStatus == 9">订单已取消 / 期待您再次光临</text>
  35. <text v-if="orderList.houseOrder.orderStatus == 1">请在15分钟之内支付</text>
  36. <text v-if="orderList.houseOrder.orderStatus == 3">预定成功 / 等待您的入住</text>
  37. <text v-if="orderList.houseOrder.orderStatus == 4">办理成功 / 期待您的到来</text>
  38. <text class="all-price">¥{{orderList.houseOrder.payPrice}}</text>
  39. </view>
  40. <!-- <view class="one-order-menshi">门市价<text class="menshi-price">¥{{orderList.roomTypeUsualPrice}}</text></view>
  41. <view class="one-order-fuli">教师福利<text class="fuli-price">¥{{orderList.roomTypeDiscountPrice}}</text></view>
  42. <view class="one-order-yufukuan">
  43. 预付款<text class="yufukuan-price">¥{{orderList.payAmount}}</text>
  44. </view> -->
  45. <!-- <view class="one-order-zhu">
  46. 注:水费为0.62元/吨,电费为1.1元/度;补助吨数为3吨,补助度
  47. 数为10度,超出标准需在预付款中扣除,未超出原路返回预
  48. 付款
  49. </view> -->
  50. <view class="room-button" v-if="orderList.houseOrder.orderStatus != 4&&orderList.houseOrder.orderStatus != 9">
  51. <text v-if="orderList.houseOrder.orderStatus == 1" @click="openQu(orderList.houseOrder.orderNumber,'warn',orderList.houseOrder.houseNumberId)">取消订单</text>
  52. <text v-if="orderList.houseOrder.orderStatus == 3" @click="openQu(orderList.houseOrder.orderNumber,'warn',orderList.houseOrder.houseNumberId)">办理退款</text>
  53. </view>
  54. <view class="room-button2" :class="{'buttonNo': orderList.houseOrder.orderStatus == 4}">
  55. <text v-if="orderList.houseOrder.orderStatus == 9" @click="navigateToZaici(orderList.houseOrder.reserveLiveTime,orderList.houseOrder.reserveLeaveTime,orderList.houseOrder.houseId)">再次预定</text>
  56. <!-- <text v-if="orderList.houseOrder.orderStatus == 9" @click="openDel(orderList.houseOrder.orderNumber,'warn',orderList.houseOrder.houseNumberId)">删除</text> -->
  57. <text v-if="orderList.houseOrder.orderStatus == 1" @click="getOrderPay(orderList.houseOrder.id,orderList.houseOrder.price)">支付</text>
  58. <text v-if="orderList.houseOrder.orderStatus == 4" @click="openTui(orderList.houseOrderid.orderNumber,'warn')">办理退房</text>
  59. <text v-if="orderList.houseOrder.orderStatus == 3" @click="openRu(orderList.houseOrder.id,'warn')">办理入住</text>
  60. </view>
  61. </view>
  62. <!-- 第二层模块 -->
  63. <view class="two-order" :class="{'two-order3': orderList.houseOrder.orderStatus == 4,'two-order4': orderList.houseOrder.orderStatus == 8||orderList.houseOrder.orderStatus == 5}">
  64. <view class="two-order-title">订单信息</view>
  65. <view class="two-order-name">预定人信息:<text class="two-order-txt">{{orderList.houseOrder.reserveName}}</text></view>
  66. <view class="two-order-phone">手机号码:<text class="two-order-txt">{{orderList.houseOrder.reservePhone}}</text></view>
  67. <view class="two-order-count">订 单 号:<text class="two-order-txt">{{orderList.houseOrder.orderNumber}}</text></view>
  68. <view class="two-order-time">下单时间:<text class="two-order-txt">{{orderList.houseOrder.createTime}}</text></view>
  69. <view class="two-order-xing">户 型:<text class="two-order-txt">{{orderList.house.roomName}}</text></view>
  70. <view class="two-order-zhuTime">入离时间:
  71. <text class="two-order-txt" v-if="orderList.houseOrder.reserveLiveTime,orderList.houseOrder.reserveLeaveTime">
  72. <view>入住日{{orderList.houseOrder.reserveLiveTime}}后 </view>
  73. <view>离店日{{orderList.houseOrder.reserveLeaveTime}}前</view></text>
  74. </view>
  75. <view class="two-order-secret" v-if="orderList.houseOrder.orderStatus ==4">房间门锁密码:{{orderList.passWord}}</view>
  76. <view class="two-order-shui" v-if="orderList.houseOrder.orderStatus == 8||orderList.houseOrder.orderStatus ==5||orderList.houseOrder.orderStatus ==4">水起码:{{orderList.startOfWater}}吨</view>
  77. <view class="two-order-dian" v-if="orderList.houseOrder.orderStatus == 8||orderList.houseOrder.orderStatus ==5||orderList.houseOrder.orderStatus ==4">电起码:{{orderList.startOfElectric}}度</view>
  78. <view class="two-order-shui2" v-if="orderList.houseOrder.orderStatus == 8||orderList.houseOrder.orderStatus == 5">水止码:{{orderList.endOfWater}}吨</view>
  79. <view class="two-order-dian2" v-if="orderList.houseOrder.orderStatus == 8||orderList.houseOrder.orderStatus == 5">电止码:{{orderList.endOfElectric}}度</view>
  80. <view class="two-order-lidian2" v-if="orderList.houseOrder.orderStatus == 8">退房时间:{{}}</view>
  81. </view>
  82. <view class="order-mark">您的满意是我们最大的追求</view>
  83. <!-- 提示时弹框 -->
  84. <uni-popup ref="popup_order2" type="dialog">
  85. <uni-popup-dialog :type="msgType2" cancelText="关闭" confirmText="确定" :content='order_txt2' @confirm="dialogConfirm"
  86. @close="dialogClose"></uni-popup-dialog>
  87. </uni-popup>
  88. <uni-popup ref="popup_order" type="dialog">
  89. <uni-popup-dialog :type="msgType" cancelText="关闭" :content='order_txt'></uni-popup-dialog>
  90. </uni-popup>
  91. </view>
  92. </template>
  93. <script>
  94. import {
  95. getorderdetail,
  96. getorderbill,
  97. quxiaoorder,
  98. getorderpay,
  99. getchapay,
  100. getorderdelete,
  101. getorderhold,
  102. getorderreturn
  103. } from '../../utils/api_hotel.js'
  104. export default {
  105. data(){
  106. return {
  107. orderList:{},//订单整体
  108. orderId:'',//订单号
  109. billXin:'',//结账信息
  110. order_txt:'',//弹框提示信息
  111. msgType:'warn',
  112. msgType2:'warn',
  113. order_txt:'',//
  114. order_txt2:'',//
  115. tankuang:false,//弹框是否确定
  116. order_txt_id:'',
  117. houseNumberId:'',
  118. appId: "", //公众号ID,由商户传入
  119. timeStamp: "", //时间戳,自1970年以来的秒数
  120. nonceStr: "", //随机串
  121. package: "",
  122. signType: "", //微信签名方式:
  123. paySign:'',
  124. }
  125. },
  126. onShow() {
  127. // 获取当前小程序的页面栈
  128. let pages = getCurrentPages();
  129. // 数组中索引最大的页面--当前页面
  130. let currentPage = pages[pages.length-1];
  131. // 打印出当前页面中的 options
  132. this.orderId=currentPage.options.orderId
  133. this.getOrderInfo(this.orderId)
  134. this.getOrderBill(this.orderId)
  135. },
  136. onload(option){
  137. console.log('不能执行onload')
  138. },
  139. methods:{
  140. //获取每个订单详情
  141. getOrderInfo() {
  142. let _self = this
  143. _self.orderList = []
  144. var data="?houseOrderId="+_self.orderId
  145. getorderdetail(data).then((res) => {
  146. if (res.success) {
  147. _self.orderList=res.data
  148. return;
  149. } else {
  150. console.log('获取订单列表失败')
  151. }
  152. }).catch((err) => {
  153. uni.showModal({
  154. content:err.message
  155. })
  156. });
  157. },
  158. //待确认的弹框操作
  159. dialogConfirm() {
  160. this.$refs.popup_order2.close()
  161. this.tankuang=true
  162. if(this.tankuang==true) {
  163. if(this.order_txt2=='确定删除?') {
  164. this.getOrderDelete(this.order_txt_id)
  165. } else if(this.order_txt2=='确定退房?') {
  166. this.getOrderReturn(this.order_txt_id)
  167. } else if(this.order_txt2=='确定入住?') {
  168. this.getOrderHold(this.order_txt_id)
  169. } else if(this.order_txt2=='确定取消订单?') {
  170. this.getOrderCancel(this.order_txt_id,this.houseNumberId)
  171. }
  172. }
  173. },
  174. dialogClose(){
  175. this.$refs.popup_order2.close()
  176. },
  177. //删除弹框
  178. openDel(orderId,type){
  179. this.order_txt_id=orderId
  180. this.msgType2 = type
  181. this.order_txt2='确定删除?'
  182. this.$refs.popup_order2.open()
  183. },
  184. //退房弹框
  185. openTui(orderId,type) {
  186. this.order_txt_id=orderId
  187. this.msgType2 = type
  188. this.order_txt2='确定退房?'
  189. this.$refs.popup_order2.open()
  190. },
  191. //入住弹框
  192. openRu(orderId,type) {
  193. this.order_txt_id=orderId
  194. this.msgType2 = type
  195. this.order_txt2='确定入住?'
  196. this.$refs.popup_order2.open()
  197. },
  198. //取消订单弹框
  199. openQu(orderId,type,houseNumberId) {
  200. this.order_txt_id=orderId
  201. this.houseNumberId=houseNumberId
  202. this.msgType2 = type
  203. this.order_txt2='确定取消订单?'
  204. this.$refs.popup_order2.open()
  205. },
  206. // 订单结账信息
  207. getOrderBill() {
  208. let _self = this
  209. var data=_self.orderId
  210. getorderbill(data).then((res) => {
  211. if (res.success) {
  212. if(res.data.flag!='3') {
  213. this.billXin=res.data
  214. }
  215. return;
  216. } else {
  217. console.log('获取结账信息失败')
  218. }
  219. }).catch((err) => {
  220. this.$message.error(err.message)
  221. });
  222. // this.$axios.get(`/hotel/ihotel-api/ihotel/hotelOrder/user/order/bill/${this.orderId}`,
  223. // {
  224. // headers:{
  225. // 'token':localStorage.getItem('token')
  226. // }
  227. // }).then(res => {
  228. // res = res.data
  229. // if (res.success) {
  230. // // console.log(res)
  231. // if(res.data.flag!='3') {
  232. // this.billXin=res.data
  233. // }
  234. // } else {
  235. // console.log('获取结账信息失败')
  236. // }
  237. // });
  238. },
  239. // 订单取消再次预订
  240. navigateToZaici(enableStartTime,enableEndTime,roomTypeId){
  241. uni.reLaunch({
  242. url:"../index/index"
  243. // url:'../order_room/order_room?roomTypeId='+roomTypeId
  244. })
  245. },
  246. // 待支付取消订单
  247. getOrderCancel(order_txt_id,houseNumberId) {
  248. let _self = this
  249. var data={
  250. "usersId": localStorage.getItem('usersId'),
  251. "orderNumber": order_txt_id, //订单号
  252. "houseNumberId": houseNumberId, //房间号id
  253. }
  254. quxiaoorder(data).then((res) => {
  255. if (res.success) {
  256. this.order_txt='取消成功'
  257. this.$refs.popup_order.open()
  258. this.getOrderInfo()
  259. return;
  260. } else {
  261. this.order_txt=res.message
  262. this.$refs.popup_order.open()
  263. }
  264. }).catch((err) => {
  265. uni.showModal({
  266. content:err.message
  267. })
  268. });
  269. },
  270. // 支付订单
  271. getOrderPay(id,price) {
  272. if(localStorage.getItem('code')=='undefined'){
  273. uni.navigateTo({
  274. url:'/pages/huoquCode/huoquCode'
  275. })
  276. return
  277. }
  278. let _self = this
  279. var data={
  280. "houseOrderId": id, //订单号id
  281. "usersId": localStorage.getItem('usersId'), //用户id localStorage.getItem('usersId')
  282. "totalPrice": price //支付金额
  283. }
  284. getorderpay(data).then((res) => {
  285. if (res.success) {
  286. _self.appId=res.data.appId
  287. _self.timeStamp=res.data.timeStamp
  288. _self.nonceStr=res.data.nonceStr
  289. _self.package=res.data.packageVal
  290. _self.signType=res.data.signType
  291. _self.paySign=res.data.paySign
  292. _self.onBridgeReady();
  293. } else if(res.code=='500'){
  294. uni.navigateTo({
  295. url:'/pages/huoquCode/huoquCode'
  296. })
  297. }
  298. }).catch((err) => {
  299. uni.navigateTo({
  300. url:'/pages/huoquCode/huoquCode'
  301. })
  302. });
  303. // this.$axios.get(`/hotel/ihotel-api/ihotel/hotelOrder/user/order/pay/${orderId}`,
  304. // {
  305. // headers:{
  306. // 'token':localStorage.getItem('token')
  307. // }
  308. // }).then(res => {
  309. // res = res.data
  310. // if (res.success) {
  311. // if(res.data.payAmount==0) {
  312. // uni.navigateTo({
  313. // url: '../zhifuchenggong/zhifuchenggong?orderId='+res.data.orderId
  314. // })
  315. // } else {
  316. // window.location.href = res.data.payUrl;
  317. // }
  318. // } else {
  319. // this.order_txt=res.message
  320. // this.$refs.popup_order.open()
  321. // console.log('支付失败')
  322. // }
  323. // });
  324. },
  325. onBridgeReady() {
  326. WeixinJSBridge.invoke('getBrandWCPayRequest', {
  327. "appId": this.appId, //公众号ID,由商户传入
  328. "timeStamp": this.timeStamp, //时间戳,自1970年以来的秒数
  329. "nonceStr": this.nonceStr, //随机串
  330. "package": this.package,
  331. "signType": this.signType, //微信签名方式:
  332. "paySign": this.paySign //微信签名
  333. },
  334. function(res) {
  335. if (res.err_msg == "get_brand_wcpay_request:ok") {
  336. uni.navigateTo({
  337. url:'/pages/my_orderlist/my_orderlist?Inv=3'
  338. })
  339. // 使用以上方式判断前端返回,微信团队郑重提示:
  340. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  341. }else{
  342. this.chapayIf()
  343. }
  344. });
  345. },
  346. //查询是否支付成功
  347. chapayIf(){
  348. var data={
  349. "outTradeNo": this.orderNumber,//订单号id
  350. }
  351. getchapay(data).then((res) => {
  352. if (res.success) {
  353. if(res.data.tradeState=="SUCCESS"){
  354. uni.showModal({
  355. content:'支付成功',
  356. success: (res) => {
  357. uni.switchTab({
  358. url:'pages/my_orderlist/my_orderlist?Inv=3'
  359. })
  360. },
  361. })
  362. }else{
  363. uni.showModal({
  364. content:res.data.tradeStateDesc
  365. })
  366. }
  367. // return;
  368. } else {
  369. }
  370. }).catch((err) => {
  371. uni.showModal({
  372. content:err.message
  373. })
  374. });
  375. },
  376. // 删除订单
  377. getOrderDelete(order_txt_id) {
  378. let _self = this
  379. getorderdelete(_self.order_txt_id).then((res) => {
  380. if (res.success) {
  381. this.order_txt='删除订单成功'
  382. this.$refs.popup_order.open()
  383. this.getOrderInfo()
  384. return;
  385. } else {
  386. this.order_txt=res.message
  387. this.$refs.popup_order.open()
  388. }
  389. }).catch((err) => {
  390. this.$message.error(err.message)
  391. });
  392. // this.$axios.defaults.headers.common['token'] = localStorage.getItem('token');
  393. // this.$axios.delete(`/hotel/ihotel-api/ihotel/hotelOrder/user/order/${this.order_txt_id}`,).then(res => {
  394. // res = res.data
  395. // if (res.success) {
  396. // this.order_txt='删除订单成功'
  397. // this.$refs.popup_order.open()
  398. // this.getOrderInfo()
  399. // } else {
  400. // this.order_txt=res.message
  401. // this.$refs.popup_order.open()
  402. // }
  403. // });
  404. },
  405. // 订单已完成再次预订
  406. navigateToWanchengZaici(roomTypeId){
  407. uni.reLaunch({
  408. url:"../index/index"
  409. // url:'../order_room/order_room?roomTypeId='+roomTypeId
  410. })
  411. },
  412. // 办理入住
  413. getOrderHold(order_txt_id) {
  414. let _self = this
  415. getorderhold(_self.order_txt_id).then((res) => {
  416. if (res.success) {
  417. this.order_txt='办理入住成功'
  418. this.$refs.popup_order.open()
  419. this.getOrderInfo()
  420. return;
  421. } else {
  422. this.order_txt=res.message
  423. this.$refs.popup_order.open()
  424. }
  425. }).catch((err) => {
  426. this.$message.error(err.message)
  427. });
  428. // this.$axios.defaults.headers.common['token'] = localStorage.getItem('token');
  429. // this.$axios.put(`/hotel/ihotel-api/ihotel/hotelOrder/user/order/hold/${this.order_txt_id}`,).then(res => {
  430. // res = res.data
  431. // if (res.success) {
  432. // this.order_txt='办理入住成功'
  433. // this.$refs.popup_order.open()
  434. // this.getOrderInfo()
  435. // } else {
  436. // this.order_txt=res.message
  437. // this.$refs.popup_order.open()
  438. // }
  439. // });
  440. },
  441. // 办理退房
  442. getOrderReturn(order_txt_id) {
  443. let _self = this
  444. getorderreturn(_self.order_txt_id).then((res) => {
  445. if (res.success) {
  446. this.order_txt='退房成功'
  447. this.$refs.popup_order.open()
  448. this.getOrderInfo()
  449. this.getOrderBill()
  450. return;
  451. } else {
  452. this.order_txt=res.message
  453. this.$refs.popup_order.open()
  454. }
  455. }).catch((err) => {
  456. this.$message.error(err.message)
  457. });
  458. // this.$axios.defaults.headers.common['token'] = localStorage.getItem('token');
  459. // this.$axios.put(`/hotel/ihotel-api/ihotel/hotelOrder/user/order/return/${this.order_txt_id}`,).then(res => {
  460. // res = res.data
  461. // if (res.success) {
  462. // this.order_txt='退房成功'
  463. // this.$refs.popup_order.open()
  464. // this.getOrderInfo()
  465. // this.getOrderBill()
  466. // } else {
  467. // this.order_txt=res.message
  468. // this.$refs.popup_order.open()
  469. // }
  470. // });
  471. },
  472. }
  473. }
  474. </script>
  475. <style>
  476. @import url("./css/order_mark.css");
  477. </style>