roomconfirmitem.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view class="pages writeoffitem">
  3. <view class="writeoffitem-number">
  4. <view class="number">订单编号:{{resdata.ordersn}}</view>
  5. <view class="time">预订时间:{{resdata.addDate}}</view>
  6. </view>
  7. <view class="wrap">
  8. <view class="write-radius radio-select have-room">
  9. <radio-group @change="haveroomf">
  10. <label class="uni-list-cell uni-list-cell-pd" v-for="(radio, index) in haveroom" :key="radio.value">
  11. <view>
  12. <radio :value="radio.value" :checked="index === haveroomcurrent" />
  13. </view>
  14. <view>{{radio.name}}</view>
  15. </label>
  16. </radio-group>
  17. </view>
  18. <view class="write-radius radio-select clear-room">
  19. <radio-group @change="clearroomf">
  20. <label class="uni-list-cell uni-list-cell-pd" v-for="(radio, index) in clearroom" :key="radio.value">
  21. <view>
  22. <radio :value="radio.value" :checked="index ===clearroomcurrent" />
  23. </view>
  24. <view>{{radio.name}}</view>
  25. </label>
  26. </radio-group>
  27. </view>
  28. <view class="write-radius pay-way">
  29. <view class="pay-way-left">支付方式</view>
  30. <view class="pay-way-right">电子券支付</view>
  31. </view>
  32. <view class="write-radius hotel-info">
  33. <view class="hotel-info-room">
  34. <image class="room-image" :src="resdata.litpic" mode="scaleToFill"></image>
  35. <view class="hotel-info-text">
  36. <view class="hotel-info-text-item hotel-info-text-hotel">{{hotelname}}</view>
  37. <view class="hotel-info-text-item hotel-info-text-room">{{roomname}}</view>
  38. <view class="hotel-info-text-item hotel-info-text-service">
  39. <text class="hotel-info-text-service-item" v-if="breakfirst">{{breakfirst}}</text>
  40. <text class="hotel-info-text-service-item" v-if="roomwindow">{{roomwindow}}</text>
  41. <text class="hotel-info-text-service-item" v-if="roomstyle">{{roomstyle}}</text>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="room-detail">
  46. <view class="room-detail-item room-detail-time">
  47. <view class="room-detail-time-data">
  48. 入住:{{resdata.usedate}} 离店:{{resdata.departdate}}
  49. </view>
  50. <view class="room-detail-time-total">
  51. 共{{havenight}}晚
  52. </view>
  53. </view>
  54. <!-- <view class="room-detail-item">
  55. <view class="room-list">
  56. <view class="room-list-item">
  57. <view class="room-list-item-date">2020-08-19</view>
  58. <view class="room-list-item-number">1间</view>
  59. </view>
  60. <view class="room-list-item">
  61. <view class="room-list-item-date">2020-08-19</view>
  62. <view class="room-list-item-number">1间</view>
  63. </view>
  64. </view>
  65. <view class="room-list-total">
  66. </view>
  67. </view> -->
  68. <view class="pay-total">
  69. <view class="pay-total-item pay-total-number">
  70. <view class="pay-total-til">总计</view>
  71. <view class="pay-total-con">¥{{resdata.price}}</view>
  72. </view>
  73. <view class="pay-total-item pay-total-way">
  74. <view class="pay-total-til">预订方式</view>
  75. <view class="pay-total-con">全款支付</view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- room-detail end -->
  80. </view>
  81. <!-- hotel-info end -->
  82. <view class="write-radius contact-info">
  83. <view class="contact-info-item contact-info-name">
  84. <view class="contact-info-item-til">联系人:</view>
  85. <view class="contact-info-item-con">{{resdata.linkman}}</view>
  86. </view>
  87. <view class="contact-info-item contact-info-phone">
  88. <view class="contact-info-item-til">联系电话:</view>
  89. <view class="contact-info-item-con">{{resdata.linktel}}</view>
  90. </view>
  91. </view>
  92. <!-- contact-info end -->
  93. </view>
  94. <view class="bottom-btn-wrap">
  95. <button class="bottom-btn" @click="roomconfirm" type="primary">确认</button>
  96. </view>
  97. </view>
  98. </template>
  99. <script>
  100. export default{
  101. components:{
  102. },
  103. props:{
  104. },
  105. data(){
  106. return{
  107. id:'',
  108. haveroomcurrent:0,
  109. haveroom:[
  110. {value: '1',name: '有房'},
  111. {value: '2',name: '无房'},
  112. ],
  113. haveroomvalue:1,
  114. clearroom:[
  115. {value: '1',name: '清空库存'},
  116. {value: '2',name: '不清空库存'},
  117. ],
  118. clearroomvalue:1,
  119. clearroomcurrent:1,
  120. params:{
  121. token:'',
  122. },
  123. confirmparams:{
  124. token:'',
  125. },
  126. hotelname:'',
  127. roomname:'',
  128. resdata:{},
  129. breakfirst:'',
  130. roomstyle:'',
  131. roomwindow:'',
  132. havenight:'',//共几晚
  133. }
  134. },
  135. onLoad(option){
  136. //检查登录,获取token
  137. let loginRes = this.checkLogin('pages/index/index', '2');
  138. if(!loginRes){return false;}
  139. this.params.token=loginRes[0];
  140. this.id = option.id;
  141. this.params = Object.assign(this.params,{id:option.id});
  142. this.getdetail();
  143. },
  144. methods:{
  145. //获取订单详情
  146. getdetail:function(){
  147. this.$api.http.post(this.config.apiBaseurl+'hotel/reserve/detail', this.params,{
  148. header: {
  149. Accept:'application/json',
  150. Authorization: 'Bearer '+ this.params.token, //注意Bearer后面有一空格
  151. }
  152. } ).then(res => {
  153. if(res.data.code=='1001'){
  154. uni.redirectTo({
  155. url:`/pages/login/login?backpage=/pages/roomconfirm/roomconfirmitem/roomconfirmitem?id=${this.id}&backtype=2`,
  156. });
  157. };
  158. this.resdata = res.data;
  159. this.hotelname = res.data.hotel.title;
  160. this.roomname = res.data.room.roomname;
  161. this.breakfirst = res.data.room.breakfirst;
  162. this.roomstyle = res.data.room.roomstyle;
  163. this.roomwindow = res.data.room.roomwindow;
  164. //计算几晚
  165. let day1 = Date.parse(new Date(res.data.usedate.replace(/-/g, '/'))) / 1000;
  166. let day2 = Date.parse(new Date(res.data.departdate.replace(/-/g, '/'))) / 1000;
  167. this.havenight = Math.abs((day1 - day2) / (3600 * 24));
  168. console.log(JSON.parse(JSON.stringify(res.data)));
  169. }).catch(err => {
  170. });
  171. },
  172. //提交
  173. roomconfirm:function(){
  174. this.confirmparams.token = this.params.token;
  175. this.confirmparams = Object.assign(this.confirmparams,{orderId:this.id,has:this.haveroomvalue,is_clear:this.clearroomvalue});
  176. this.$api.http.post(this.config.apiBaseurl+'hotel/reserve/confirm', this.confirmparams,{
  177. header: {
  178. Accept:'application/json',
  179. Authorization: 'Bearer '+ this.params.token, //注意Bearer后面有一空格
  180. }
  181. } ).then(res => {
  182. uni.showToast({
  183. icon:'none',
  184. title:res.data.message,
  185. duration: 2000
  186. });
  187. //确认成功跳转到列表页
  188. if(res.data.state == 'ok'){
  189. setTimeout(()=>{
  190. uni.redirectTo({
  191. url:`/pages/roomconfirm/roomconfirm`,
  192. fail:function(e){
  193. console.log(e);
  194. }
  195. });
  196. },1000);
  197. };
  198. console.log(res);
  199. }).catch(err => {
  200. console.log(err);
  201. });
  202. },
  203. haveroomf: function(evt) {
  204. for (let i = 0; i < this.haveroom.length; i++) {
  205. if (this.haveroom[i].value === evt.target.value) {
  206. this.current = i;
  207. break;
  208. }
  209. }
  210. this.haveroomvalue = evt.target.value;
  211. },
  212. clearroomf: function(evt) {
  213. for (let i = 0; i < this.clearroom.length; i++) {
  214. if (this.clearroom[i].value === evt.target.value) {
  215. this.current = i;
  216. break;
  217. }
  218. }
  219. this.clearroomvalue = evt.target.value;
  220. },
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. page{background-color: $uni-bg-color-grey;}
  226. @import url("/common/css/order.scss");
  227. </style>