order_room.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <view class="content">
  3. <!-- 背景图 -->
  4. <view class="index_bg">
  5. <view class="welcome">
  6. <image class="welcome_img" src="../../static/index/welcome.png"></image>
  7. </view>
  8. </view>
  9. <!-- 第一层标题 -->
  10. <view class="touming_bg">
  11. <view class="touming_title">研究生公寓(南昌交通学院)</view>
  12. <view class="touming_txt">您辛苦了,欢迎入住!</view>
  13. </view>
  14. <!-- 第二层表单 -->
  15. <view class="two_all">
  16. <view class="select-time" @click="openCalendar">
  17. <view class="select-time-one">
  18. <text class="select-list">{{ startWeek }}入住</text>
  19. <text class="select-list-time">{{ startTime }}</text>
  20. </view>
  21. <view class="select-center">
  22. <view class="select-line1"></view>
  23. <view class="select-circle">{{ ruzhu_num }} 晚</view>
  24. <view class="select-line2"></view>
  25. </view>
  26. <view class="select-time-one">
  27. <text class="select-list">{{ endWeek }}离店</text>
  28. <text class="select-list-time">{{ endTime }}</text>
  29. </view>
  30. </view>
  31. <!-- <uni-popup ref="popup_picker" :mask-click="true">
  32. <view class=popup_bg_picker>
  33. <uni-calendar :selected="info.selected" class="uni-calendar--hook" :clear-date="true" :date="info.date" :insert="info.insert"
  34. :lunar="info.lunar" :startDate="info.startDate" :endDate="info.endDate" :range="info.range" @change="change" />
  35. </view>
  36. </uni-popup> -->
  37. <view class="form_bg">
  38. <view class="form_title">房型:{{ h_type }},1.5米双人床一张。</view>
  39. <view class="form-text">姓名:{{ cardName }}</view>
  40. <view class="form-text">手机:{{ cardPhone }}</view>
  41. <view class="form-text">身份:{{ cardIdentity }}</view>
  42. </view>
  43. </view>
  44. <!-- 注释 -->
  45. <!-- <view class="zhushi">
  46. <text class="zhushi-mark"><text class="zhushi-circle"></text>低价保证</text>
  47. <text class="zhushi-mark"><text class="zhushi-circle"></text>入住免房费</text>
  48. <text class="zhushi-mark"><text class="zhushi-circle"></text>提前选好房</text>
  49. </view> -->
  50. <view class="cancel-rule">取消规则:未办理入住的订单在09月06号之前可以办理退款,09月06号凌晨后均不允许退款操作。</view>
  51. <!-- 支付框 -->
  52. <view class="fukuan">
  53. <view class="fu-price"><text style="font-size: 28rpx;">总计:</text>¥{{ payMount }}</view>
  54. <view class="fu-zhifu" :class="{'room-button2': freeRoom == 0}">
  55. <text v-if="freeRoom == 0">房间已满</text>
  56. <text v-else @tap="getOrderSubmit()">立即支付</text>
  57. </view>
  58. </view>
  59. <!-- 提交订单时弹框 -->
  60. <uni-popup ref="popup_order" type="dialog">
  61. <uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" :content="order_txt" @confirm="dialogConfirm"
  62. ></uni-popup-dialog>
  63. </uni-popup>
  64. </view>
  65. </template>
  66. <script>
  67. import {
  68. accredit
  69. } from '@/static/shared.js';
  70. export default {
  71. data() {
  72. return {
  73. showCalendar: false,
  74. info: {
  75. lunar: true,
  76. range: true,
  77. insert: true,
  78. selected: [],
  79. startDate: '',
  80. date: '',
  81. endDate: ''
  82. },
  83. startTime: '', //到店日期
  84. endTime: '', //离店日期
  85. startDate: '', //默认到店日期接口数据
  86. endDate: '', //默认离店日期接口数据
  87. startWeek: '', // 默认入店日
  88. endWeek: '', // 默认离店
  89. array: ['18:00前到店', '19:00前到店', '20:00前到店', '21:00前到店'],
  90. index: 0,
  91. mayTime: '', // 预计到店时间
  92. typeName: '', //户型名
  93. textNum: 0, //输入框当前字数
  94. cardName: '', //用户名
  95. cardPhone: '', //用户电话
  96. cardIdentity: '', //身份
  97. submitToken: '', //请求令牌
  98. // roomTypeId: '', //房间类型id
  99. remark: '', //备注要求
  100. payMount: 0, //应付金额
  101. price: 0,
  102. freeRoom: 0, //剩余房间
  103. ruzhu_num: 1, //入住夜晚
  104. order_txt: '', //提交订单时信息
  105. msgType: 'warn',
  106. cardNumber: '',
  107. payData: {}
  108. }
  109. },
  110. onLoad(option) {
  111. // console.log('option', option)
  112. this.ruzhu_num = option.ruzhu_num
  113. this.price = option.price
  114. this.payMount = Number(option.price * option.ruzhu_num) //应付金额
  115. this.freeRoom = option.freeRoom //剩余房间
  116. // this.roomTypeId = option.roomTypeId //房间类型id
  117. this.h_type = option.typeName //户型名
  118. this.startTime = option.startTime //到店日期
  119. this.endTime = option.endTime //离店日期
  120. this.startDate = option.enableStartTime.substring(0, 11) + "12:00:00" //默认到店日期接口数据
  121. this.endDate = option.enableEndTime.substring(0, 11) + "14:00:00" //默认离店日期接口数据
  122. this.startWeek = this.$utils.getweekday(this.startDate) // 默认入店日
  123. this.endWeek = this.$utils.getweekday(this.endDate) // 默认离店
  124. this.mayTime = this.startDate.substring(0, 11) + "18:00:00" // 预计到店时间
  125. // console.log(this.$utils.getweekday(this.startDate))
  126. },
  127. mounted() {
  128. // 获取用户信息
  129. this.getUserInfo();
  130. },
  131. onReady() {
  132. var that = this
  133. that.$nextTick(() => {
  134. that.showCalendar = true
  135. })
  136. // TODO 模拟请求异步同步数据
  137. setTimeout(() => {
  138. that.info.date = that.$utils.getDate(new Date()).fullDate
  139. that.info.startDate = that.$utils.getDate(new Date()).fullDate
  140. // that.info.endDate = that.$utils.getDate(new Date(), 6).fullDate
  141. that.info.endDate = that.$utils.getDate(new Date('2023-09-15')).fullDate
  142. if (that.$utils.isEmpty(that.startTime)) {
  143. that.startTime = that.$utils.getDate(new Date()).fullTime
  144. }
  145. if (that.$utils.isEmpty(that.endTime)) {
  146. that.endTime = that.$utils.getDate(new Date(), 1).fullTime
  147. }
  148. if (that.$utils.isEmpty(that.startWeek)) {
  149. that.startWeek = that.$utils.getDate(new Date()).sWeek
  150. }
  151. if (that.$utils.isEmpty(that.endWeek)) {
  152. that.endWeek = that.$utils.getDate(new Date(), 1).eWeek
  153. }
  154. if (that.$utils.isEmpty(that.ruzhu_num)) {
  155. that.ruzhu_num = 1
  156. }
  157. }, 20)
  158. },
  159. methods: {
  160. /**
  161. * 调起支付
  162. */
  163. onBridgeReady() {
  164. var that = this;
  165. // 在这里可以使用WeixinJSBridge对象进行支付调用等操作
  166. // 调用支付接口
  167. if (typeof WeixinJSBridge !== 'undefined') {
  168. WeixinJSBridge.invoke('getBrandWCPayRequest', that.payData,
  169. function(res) {
  170. if (res.err_msg == "get_brand_wcpay_request:ok") {
  171. // 使用以上方式判断前端返回,微信团队郑重提示:
  172. //res.errMsg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  173. uni.showModal({
  174. title: '提示',
  175. content: '支付成功',
  176. showCancel: false,
  177. success: (res) => {
  178. if (res.confirm) {
  179. uni.navigateTo({
  180. url: "/pages/my_orderlist/my_orderlist?Inv=2"
  181. })
  182. }
  183. }
  184. });
  185. } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
  186. uni.showToast({
  187. title: '支付取消',
  188. icon: 'success'
  189. });
  190. } else {
  191. uni.showModal({
  192. title: '提示',
  193. content: res.errMsg,
  194. showCancel: false
  195. })
  196. }
  197. });
  198. }
  199. },
  200. /**
  201. * 获取用户信息
  202. */
  203. getUserInfo() {
  204. var that = this
  205. var tempCardNumber = that.$utils.getEncryptedData('cardNumber')
  206. if (that.$utils.isEmpty(tempCardNumber)) {
  207. uni.showToast({
  208. title: '用户卡号为空'
  209. });
  210. return;
  211. }
  212. that.cardNumber = tempCardNumber;
  213. that.$myRequest({
  214. url: '/hotelReservation/zhotel/appuser.action?card_number=' + that.cardNumber
  215. }).then(res => {
  216. // console.log(res);
  217. let data = res.data.data
  218. if (res.data.code === 200) {
  219. that.cardName = data.user_name
  220. that.cardPhone = data.user_phone
  221. if (data.identity_type === 0) {
  222. that.cardIdentity = '其它'
  223. } else if (data.identity_type === 1) {
  224. that.cardIdentity = '学生'
  225. } else if (data.identity_type === 4) {
  226. that.cardIdentity = '教职工'
  227. } else if (data.identity_type === 5) {
  228. that.cardIdentity = '校友'
  229. } else if (data.identity_type === 6) {
  230. that.cardIdentity = '访客'
  231. } else {
  232. that.cardIdentity = '临时人员'
  233. }
  234. } else {
  235. alert('未获得用户数据')
  236. }
  237. });
  238. },
  239. /**
  240. * 提交订单
  241. */
  242. getOrderSubmit() {
  243. let that = this
  244. that.$myRequest({
  245. method: 'POST',
  246. url: '/hotelReservation/zhotel/apporder_pay.action',
  247. data: {
  248. 'card_number': that.cardNumber,
  249. 'h_type': that.h_type,
  250. 'live_time': that.startDate.substring(0, 10),
  251. 'end_time': that.endDate.substring(0, 10)
  252. },
  253. headers: {
  254. 'Content-Type': 'application/json'
  255. }
  256. }).then(res => {
  257. let data = res.data
  258. if (data.code === 200) {
  259. let d = data.data;
  260. that.payData = {
  261. "appId": d.appId,
  262. "nonceStr": d.nonceStr,
  263. "paySign": d.paySign,
  264. "package": "prepay_id=" + d.prepay_id,
  265. "signType": d.signType,
  266. "timeStamp": d.timeStamp
  267. }
  268. if (typeof WeixinJSBridge === 'undefined') {
  269. if (document.addEventListener) {
  270. document.addEventListener('WeixinJSBridgeReady', that.onBridgeReady, false);
  271. } else if (document.attachEvent) {
  272. document.attachEvent('WeixinJSBridgeReady', that.onBridgeReady);
  273. document.attachEvent('onWeixinJSBridgeReady', ththatis.onBridgeReady);
  274. }
  275. } else {
  276. that.onBridgeReady();
  277. }
  278. } else {
  279. that.msgType = 'warn'
  280. that.order_txt = data.message
  281. that.$refs.popup_order.open()
  282. }
  283. });
  284. },
  285. dialogConfirm() {
  286. uni.showToast({
  287. title: '确定'
  288. })
  289. },
  290. //日历选择器
  291. openCalendar() {
  292. // this.$refs.popup_picker.open()
  293. },
  294. // 重新选择日期
  295. change(e) {
  296. // console.log('1change 返回:', e)
  297. // 模拟动态打卡
  298. // if (this.info.selected.length > 5) return
  299. var before = e.range.before;
  300. var after = e.range.after;
  301. this.info.selected = [{
  302. date: before,
  303. info: '到店'
  304. },
  305. {
  306. date: after,
  307. info: '离店'
  308. }
  309. ];
  310. if (before !== '' && after === '') {
  311. this.startWeek = '周' + e.lunar.ncWeek.substring(2, 3)
  312. } else if (before !== '' && after !== '') {
  313. if ((new Date(after).getTime()) == (new Date(before).getTime())) {
  314. uni.showToast({
  315. title: '不能选同一天',
  316. icon: 'error',
  317. duration: 1500
  318. });
  319. return;
  320. }
  321. if ((new Date(after).getTime()) < (new Date(before).getTime())) {
  322. var temp = before;
  323. before = after;
  324. after = temp;
  325. }
  326. this.endWeek = '周' + e.lunar.ncWeek.substring(2, 3)
  327. this.startTime = before.substring(5, 7) + '月' + before.substring(8, 10) + '日'
  328. this.endTime = after.substring(5, 7) + '月' + after.substring(8, 10) + '日'
  329. this.startDate = before + ' 14:00:00'
  330. this.endDate = after + ' 12:00:00'
  331. this.ruzhu_num = parseInt(((new Date(after).getTime()) - (new Date(before).getTime())) / 1000 / 60 / 60 / 24)
  332. this.payMount = this.ruzhu_num * this.price
  333. }
  334. },
  335. //选择器
  336. bindPickerChange: function(e) {
  337. console.log('picker发送选择改变,携带值为', e.detail.value)
  338. this.index = e.detail.value
  339. this.mayTime = this.startDate.substring(0, 11) + this.array[this.index].substring(0, 5) + ":00"
  340. // console.log(this.mayTime)
  341. },
  342. // 输入框
  343. bindTextAreaBlur: function(e) {
  344. // console.log(e.detail.cursor)
  345. // console.log(e.detail.value)
  346. this.textNum = e.detail.cursor
  347. this.remark = e.detail.value
  348. }
  349. }
  350. }
  351. </script>
  352. <style>
  353. @import url("./css/order_room.css");
  354. </style>