createOrder.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <template>
  2. <view class="page" :style="{'height':(h)+'px','padding-top':mt+'px'}">
  3. <c-nav-bar title="新增订单" :showIcon="true"></c-nav-bar>
  4. <view class="box box1">
  5. <view class="tit">预订信息</view>
  6. <u-cell-group :border="false" customStyle="margin:0 -30rpx">
  7. <u-cell>
  8. <text slot="icon" class="label">姓名</text>
  9. <view slot="title" class="title">
  10. <u--input border="none" class="input" inputAlign="right" placeholderStyle="font-size:26rpx"
  11. placeholder="请输入姓名" v-model="dataForm.guestName"></u--input>
  12. </view>
  13. </u-cell>
  14. <u-cell>
  15. <text slot="icon" class="label">手机号码</text>
  16. <view slot="title" class="title">
  17. <u--input border="none" class="input" inputAlign="right" placeholderStyle="font-size:26rpx"
  18. placeholder="请输入手机号码" v-model="dataForm.guestPhone"></u--input>
  19. </view>
  20. </u-cell>
  21. <u-cell :isLink="true" @click="showLaiyuan=true">
  22. <text slot="icon" class="label">订单来源</text>
  23. <view slot="title" class="title">
  24. {{dataForm.guestSourceName}}
  25. </view>
  26. </u-cell>
  27. </u-cell-group>
  28. </view>
  29. <view class="box box1">
  30. <view class="tit">房间信息</view>
  31. <u-cell-group :border="false" customStyle="margin:0 -30rpx">
  32. <u-cell>
  33. <text slot="icon" class="label">入住日期</text>
  34. <view slot="title" class="title">
  35. {{dataForm.arriveDate}}
  36. <!-- <u--input border="none" class="input" inputAlign="right" placeholderStyle="font-size:26rpx" :disabled="true"
  37. placeholder="" v-model="dataForm.arriveDate"></u--input> -->
  38. </view>
  39. </u-cell>
  40. <u-cell>
  41. <text slot="icon" class="label">离店日期</text>
  42. <view slot="title" class="title">
  43. {{dataForm.leaveDate}}
  44. <!-- <u--input border="none" class="input" inputAlign="right" placeholderStyle="font-size:26rpx" :disabled="true"
  45. placeholder="" v-model="dataForm.leaveDate"></u--input> -->
  46. </view>
  47. </u-cell>
  48. <u-cell isLink="true">
  49. <text slot="icon" class="label">共几晚</text>
  50. <view slot="title" class="title">
  51. {{dataForm.num}}
  52. </view>
  53. </u-cell>
  54. <u-cell isLink="true" @click="checkInTypeShow=true">
  55. <text slot="icon" class="label">入住类型</text>
  56. <view slot="title" class="title">
  57. {{dataForm.detailFormList[0].checkInTypeName}}
  58. </view>
  59. </u-cell>
  60. <u-cell isLink="true">
  61. <text slot="icon" class="label">房间类型</text>
  62. <view slot="title" class="title">
  63. {{dataForm.houseBaseId}}
  64. </view>
  65. </u-cell>
  66. <u-cell>
  67. <text slot="icon" class="label">房间号</text>
  68. <view slot="title" class="title">
  69. {{dataForm.detailFormList[0].roomNumber}}
  70. </view>
  71. </u-cell>
  72. <u-cell>
  73. <text slot="icon" class="label">房价</text>
  74. <view slot="title" class="title">
  75. {{dataForm.detailFormList[0].roomAmount}}
  76. </view>
  77. </u-cell>
  78. <u-cell>
  79. <text slot="icon" class="label">备注</text>
  80. <view slot="title" class="title">
  81. <u--input border="none" class="input" inputAlign="right" placeholderStyle="font-size:26rpx"
  82. type="textarea" placeholder="请输入" v-model="dataForm.remarks" height="200"></u--input>
  83. </view>
  84. </u-cell>
  85. </u-cell-group>
  86. </view>
  87. <view class="box">
  88. <view class="tit tit2"><text>消费信息</text> <u-icon @click="addBreast()" name="plus-circle" label="添加消费"
  89. labelColor="#1372FF" labelSize="24" color="1372FF" size="30"></u-icon></view>
  90. <u-swipe-action>
  91. <u-swipe-action-item :show="item.show" :index="index" class=""
  92. v-for="(item, index) in dataForm.detailFormList[0].breakfastData" :key="index" @click="click(index)"
  93. :options="options">
  94. <view class="goodsInfo item">
  95. <view class="title-wrap">
  96. <text class="title u-line-2">{{item.breakfastName}}/{{item.num}}/{{item.price}}</text>
  97. </view>
  98. </view>
  99. </u-swipe-action-item>
  100. <u-swipe-action-item :show="item.show" :index="index" class=""
  101. v-for="(item, index) in dataForm.detailFormList[0].otherData" :key="index" @click="click2(index)"
  102. :options="options">
  103. <view class="goodsInfo item">
  104. <view class="title-wrap">
  105. <text class="title u-line-2">{{item.projectName}}/{{item.num}}/{{item.defaultPrice}}</text>
  106. </view>
  107. </view>
  108. </u-swipe-action-item>
  109. </u-swipe-action>
  110. </view>
  111. <view class="box">
  112. <view class="tit tit2"><text>收款信息</text> <u-icon @click="addpay()" name="plus-circle" label="添加收款"
  113. labelColor="#1372FF" labelSize="24" color="1372FF" size="30"></u-icon></view>
  114. <u-swipe-action>
  115. <u-swipe-action-item :show="item.show" :index="index" class="goodsInfo"
  116. v-for="(item, index) in dataForm.flowRecord" :key="index" @click="click3(index)" :options="options">
  117. <view class="item">
  118. <view class="title-wrap">
  119. <text
  120. class="title u-line-2">{{item.flowTypeName}}/{{item.payTypeName}}/{{item.amount}}</text>
  121. </view>
  122. </view>
  123. </u-swipe-action-item>
  124. </u-swipe-action>
  125. </view>
  126. <view class="footer">
  127. <view class="total"><text>订单金额:</text><text>¥{{totalMOney}}</text></view>
  128. <view class="btns">
  129. <text @click="confirmOrder(2)">直接入住</text>
  130. <text @click="confirmOrder(1)">提交订单</text>
  131. </view>
  132. </view>
  133. <u-picker :itemHeight="88" :immediateChange="true" :show="showLaiyuan" :columns="laiyuan" title="来源选择"
  134. keyName="guestSource" :defaultIndex="passengerDefault" @cancel="showLaiyuan=false;"
  135. @confirm="passengerConfirm"></u-picker>
  136. <u-picker :itemHeight="88" :immediateChange="true" :show="checkInTypeShow" :columns="checkInType" title="入住类型选择"
  137. keyName="label" :defaultIndex="passengerDefault2" @cancel="checkInTypeShow=false;"
  138. @confirm="passengerConfirm2"></u-picker>
  139. </view>
  140. </template>
  141. <script>
  142. export default {
  143. data() {
  144. return {
  145. titleStyle: {
  146. fontSize: '34rpx',
  147. fontWeight: "bold",
  148. },
  149. showLaiyuan: false,
  150. checkInTypeShow: false,
  151. passengerDefault: [0],
  152. passengerDefault2: [0],
  153. options: [{
  154. text: '删除',
  155. style: {
  156. backgroundColor: '#dd524d'
  157. }
  158. }],
  159. totalMOney: 0, //订单总金额
  160. dataForm: {
  161. arriveDate: "",
  162. detailFormList: [{
  163. breakfastAmount: 0,
  164. checkInPersonList: [],
  165. checkInType: 0,
  166. checkInTypeName: '',
  167. id: 0,
  168. otherAmount: 0,
  169. roomAmount: 0,
  170. roomIds: "",
  171. breakfastData: [],
  172. otherData: [],
  173. roomNumber: "",
  174. }],
  175. flowRecord: [],
  176. guestName: "",
  177. guestPhone: "",
  178. guestSourceId: null,
  179. guestSourceName: null,
  180. homestayId: this.$store.state.moduleHouse.homestayId,
  181. houseBaseId: 0,
  182. houseBaseName: '',
  183. leaveDate: "",
  184. num: 0,
  185. orderStatus: null,
  186. remarks: "",
  187. },
  188. checkInType: [
  189. [{
  190. label: '正常入住',
  191. val: 1
  192. }, {
  193. label: '自用房',
  194. val: 2
  195. },
  196. {
  197. label: '免费入住',
  198. val: 3
  199. }
  200. ]
  201. ],
  202. roomId: '',
  203. laiyuan: [[]]
  204. }
  205. },
  206. onLoad(opt) {
  207. this.getLaiyuan();
  208. this.roomId = opt.roomId.split(',');
  209. if (opt.id) { //编辑
  210. if (opt.orderStatus) {
  211. this.orderStatus = opt.orderStatus;
  212. }
  213. this.dataForm.id = opt.id;
  214. this.getInfo2()
  215. } else {
  216. //新增获取简单信息
  217. this.getInfo();
  218. }
  219. },
  220. methods: {
  221. //添加早餐
  222. addBreast() {
  223. let list = JSON.stringify(this.dataForm.detailFormList[0].breakfastData);
  224. let list2 = JSON.stringify(this.dataForm.detailFormList[0].otherData)
  225. uni.navigateTo({
  226. url: '/pages/house/breast?list1=' + list + '&list2=' + list2,
  227. events: {
  228. addSuccess: data => {
  229. this.dataForm.detailFormList[0].breakfastData = data.data1.filter((item) => item
  230. .num && item
  231. .num != 0);
  232. this.dataForm.detailFormList[0].otherData = data.data2.filter((item) => item.num &&
  233. item.num !=
  234. 0);
  235. this.totalMOney = this.dataForm.detailFormList[0].roomAmount;
  236. for (let i = 0; i < this.dataForm.detailFormList[0].breakfastData.length; i++) {
  237. this.totalMOney += parseFloat(this.dataForm.detailFormList[0].breakfastData[i]
  238. .price);
  239. }
  240. for (let i = 0; i < this.dataForm.detailFormList[0].otherData.length; i++) {
  241. this.totalMOney += parseFloat(this.dataForm.detailFormList[0].otherData[i]
  242. .defaultPrice);
  243. }
  244. }
  245. }
  246. })
  247. },
  248. //添加收款
  249. addpay() {
  250. uni.navigateTo({
  251. url: '/pages/house/payAdd?money=' + this.dataForm.detailFormList[0].roomAmount + '&list=' +
  252. JSON.stringify(this.dataForm.flowRecord),
  253. events: {
  254. addSuccess: data => {
  255. if (data.data.amount != 0) {
  256. this.dataForm.flowRecord.push(data.data)
  257. // if(data.data.flowType==1){ //收款
  258. // this.totalMOney+=parseFloat(data.data.amount);
  259. // }else{
  260. // this.totalMOney=parseFloat(data.data.amount);
  261. // }
  262. }
  263. }
  264. }
  265. })
  266. },
  267. confirmOrder(orderStatus) {
  268. //orderStatus//预约入住 1,直接入住2
  269. this.dataForm.orderStatus = orderStatus
  270. this.$api.post('/merchant/hotel/order/placeOrder', this.dataForm).then(res => {
  271. if (res.data.code == 0) {
  272. this.$showToast('下单成功');
  273. setTimeout(() => {
  274. uni.reLaunch({
  275. url: '/pagesMy/orderList/orderList'
  276. })
  277. }, 1500)
  278. }
  279. })
  280. },
  281. click(index) {
  282. console.log(index)
  283. this.dataForm.detailFormList[0].breakfastData.splice(index, 1);
  284. },
  285. click2(index) {
  286. this.dataForm.detailFormList[0].otherData.splice(index, 1);
  287. },
  288. click3(index) {
  289. this.dataForm.flowRecord.splice(index, 1);
  290. },
  291. getLaiyuan() {
  292. this.$api.get("/merchant/hotel/room/state/getSourceDownBox", {
  293. homestayId: this.dataForm.homestayId,
  294. })
  295. .then((res) => {
  296. if (res.data.code == 0) {
  297. this.laiyuan = [res.data.data];
  298. }
  299. });
  300. },
  301. getInfo2(){//详情信息
  302. },
  303. // 房型列表
  304. getInfo() {
  305. this.$api.post('/merchant/hotel/order/getRoomInfoList', this.roomId).then(res => {
  306. console.log(res)
  307. if (res.data.code == 0) {
  308. this.dataForm.detailFormList[0].roomIds = res.data.data.roomIds;
  309. this.dataForm.detailFormList[0].roomNumber = res.data.data.roomNumber;
  310. this.dataForm.detailFormList[0].checkInType = res.data.data.checkInType;
  311. this.dataForm.detailFormList[0].checkInTypeName = this.checkInType[0].filter((item => item
  312. .val == res.data.data.checkInType))[0].label;
  313. this.dataForm.detailFormList[0].roomAmount = res.data.data.roomAmount;
  314. this.dataForm.arriveDate = res.data.data.arriveDate;
  315. this.dataForm.leaveDate = res.data.data.leaveDate;
  316. this.dataForm.houseBaseId = res.data.data.houseBaseId;
  317. this.dataForm.num = res.data.data.num;
  318. this.totalMOney = res.data.data.roomAmount;
  319. }
  320. })
  321. },
  322. // 来源
  323. passengerConfirm(e) {
  324. this.dataForm.guestSourceId = e.value[0].id;
  325. this.dataForm.guestSourceName = e.value[0].guestSource;
  326. this.showLaiyuan = false;
  327. },
  328. //入住类型
  329. passengerConfirm2() {
  330. this.dataForm.detailFormList[0].checkInType = e.value[0].val;
  331. this.dataForm.detailFormList[0].checkInTypeName = e.value[0].guestSource;
  332. this.checkInTypeShow = false;
  333. }
  334. }
  335. }
  336. </script>
  337. <style>
  338. .u-swipe-action-item__right__button__wrapper__text {
  339. font-size: 28rpx !important;
  340. }
  341. </style>
  342. <style lang="scss" scoped>
  343. .u-swipe-action-item__right__button__wrapper {
  344. height: 36px
  345. }
  346. .u-swipe-action-item__right__button__wrapper__text {
  347. font-size: 28rpx;
  348. }
  349. .footer {
  350. position: fixed;
  351. bottom: 0;
  352. width: 100%;
  353. background-color: #fff;
  354. left: 0;
  355. z-index: 9;
  356. padding: 30rpx;
  357. box-sizing: border-box;
  358. .total {
  359. text {
  360. color: #1372FF;
  361. font-size: 32rpx;
  362. &:first-child {
  363. color: #333;
  364. }
  365. }
  366. }
  367. .btns {
  368. display: flex;
  369. justify-content: space-between;
  370. margin-top: 30rpx;
  371. text {
  372. display: inline-block;
  373. width: 48%;
  374. height: 96rpx;
  375. line-height: 96rpx;
  376. text-align: center;
  377. font-size: 34rpx;
  378. border-radius: 48rpx;
  379. border: 1rpx solid #D1D1D1;
  380. color: #999;
  381. &:last-child {
  382. background-color: #1372FF;
  383. color: #fff;
  384. }
  385. }
  386. }
  387. }
  388. .u-cell__body {
  389. padding: 0 !important;
  390. }
  391. .page {
  392. background: #F3F4F4;
  393. padding-bottom: 260rpx;
  394. box-sizing: border-box;
  395. overflow-y: auto;
  396. overflow-x: auto;
  397. }
  398. .box {
  399. background-color: #fff;
  400. margin: 20rpx auto 0;
  401. border-radius: 10rpx;
  402. width: 96%;
  403. padding: 0 30rpx 30rpx;
  404. box-sizing: border-box;
  405. .label {
  406. color: #333;
  407. font-size: 30rpx;
  408. }
  409. &.box1 {
  410. padding: 0 30rpx;
  411. .title {
  412. text-align: right;
  413. }
  414. }
  415. .title {
  416. color: #999;
  417. }
  418. }
  419. .tit,
  420. .tit2 {
  421. font-size: 32rpx;
  422. font-weight: bold;
  423. padding-top: 30rpx;
  424. color: #333;
  425. margin-bottom: 10rpx;
  426. }
  427. .tit2 {
  428. display: flex;
  429. justify-content: space-between;
  430. align-items: center;
  431. }
  432. .goodsInfo.item {
  433. padding: 20rpx 0;
  434. text {
  435. font-size: 30rpx;
  436. }
  437. }
  438. </style>