酒店桌布为微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

531 lines
11 KiB

9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
8 months ago
9 months ago
9 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
8 months ago
8 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
8 months ago
8 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
  1. <template>
  2. <uv-popup ref="popup" :round="30"
  3. @change="$refs.couponPopup.close()"
  4. bgColor="#f7f7f7">
  5. <view class="content">
  6. <!-- 地址 -->
  7. <view class="address" @click="openAddress">
  8. <image src="/static/image/address/selectIcon.png" mode=""></image>
  9. <view class="">
  10. {{ address.name }}
  11. </view>
  12. <view class="">
  13. {{ address.addressDetail }}
  14. </view>
  15. <view class="icon">
  16. <uv-icon size="30rpx" name="arrow-right"></uv-icon>
  17. </view>
  18. </view>
  19. <view class="submit-unit"
  20. style="margin-top: 20rpx;">
  21. <view class="title">
  22. 您有{{ detail.categoryName }}
  23. </view>
  24. <view class="list">
  25. <view :class="{act : typeIndex == index}" v-for="(item, index) in type"
  26. @click="typeIndex = index" :key="index">
  27. {{ item }}{{ detail.categoryName }}
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 商品信息和数量 -->
  32. <view v-if="typeIndex == 0">
  33. <view class="submit-info">
  34. <view class="title">
  35. {{ detail.categoryName }}租赁
  36. </view>
  37. <view class="box">
  38. <image class="image" :src="unit.pic" mode=""></image>
  39. <view class="info">
  40. <view class="price">
  41. <!-- 租金<text>{{ unit.price }}</text> -->
  42. </view>
  43. <view class="price">
  44. 押金<text>{{ detail.depositPrice }}</text>
  45. </view>
  46. <view class="unit">
  47. 请选择规格
  48. </view>
  49. <view class="">
  50. <uv-number-box
  51. @change="valChange"
  52. v-model="num"></uv-number-box>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 规格 -->
  58. <view class="submit-unit">
  59. <view class="title">
  60. 规格选择
  61. </view>
  62. <view class="list">
  63. <view :class="{act : unitIndex == index}" v-for="(item, index) in detail.hotelGoodsSkuList"
  64. @click="selectUnit(item, index)" :key="index">
  65. {{ item.title }}
  66. </view>
  67. </view>
  68. </view>
  69. <!-- 优惠劵 -->
  70. <!-- <view style="padding: 0 20rpx;">
  71. <uv-cell
  72. icon="coupon"
  73. title="优惠劵"
  74. iconStyle="font-size: 34rpx;"
  75. rightIconStyle="font-size: 34rpx;"
  76. :value="couponText"
  77. @click="$refs.couponPopup.open('bottom')"
  78. isLink>
  79. </uv-cell>
  80. </view> -->
  81. <!-- 费用明细 -->
  82. <view class="expense-detail">
  83. <view class="title">
  84. 费用明细
  85. </view>
  86. <view class="detail" v-if="detail.depositPrice">
  87. <view>
  88. 应付款{{ price }}
  89. </view>
  90. <view>
  91. 押金{{ price }}
  92. </view>
  93. <view v-if="coupon.couponCondition <= price
  94. && coupon.couponFlag">
  95. 优惠-{{ coupon.couponPrice }}
  96. </view>
  97. <view v-if="coupon.couponCondition <= price
  98. && coupon.couponFlag">
  99. 实付款{{ (price - coupon.couponPrice).toFixed(2) }}
  100. </view>
  101. </view>
  102. <uv-cell
  103. icon="coupon"
  104. title="押金优惠"
  105. v-if="coupon.couponFlag"
  106. iconStyle="font-size: 34rpx;"
  107. rightIconStyle="font-size: 34rpx;">
  108. <template #value>
  109. <view class="coupon">
  110. {{ coupon.couponCondition }}立减{{ coupon.couponPrice }}
  111. </view>
  112. </template>
  113. </uv-cell>
  114. </view>
  115. </view>
  116. <addLeaseForm :categoryId="detail.categoryId" ref="addLeaseForm" v-if="typeIndex == 1"/>
  117. <!-- 提交按钮 -->
  118. <view class="submit">
  119. <view class="submit-btn">
  120. <view class="l" @click="addCart" v-if="typeIndex == 0">
  121. 加入租赁车
  122. </view>
  123. <view class="r" @click="orderPay">
  124. {{ submiitTitle }}
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. <uv-popup ref="couponPopup" :round="30">
  130. <couponList
  131. ref="couponList"
  132. height="60vh"
  133. :depositPrice="price"
  134. @select="selectCoupon" />
  135. </uv-popup>
  136. <uv-popup ref="addressPopup" :round="30">
  137. <addressList ref="addressList" height="60vh" @select="selectAddress" />
  138. </uv-popup>
  139. </uv-popup>
  140. </template>
  141. <script>
  142. import addressList from '@/components/address/addressList.vue'
  143. import couponList from '@/components/user/couponList.vue'
  144. import addLeaseForm from './addLeaseForm.vue'
  145. export default {
  146. components: {
  147. addressList,
  148. couponList,
  149. addLeaseForm,
  150. },
  151. props: {
  152. submiitTitle: {
  153. default: '立即下单',
  154. type: String,
  155. },
  156. detail: {
  157. default: {}
  158. },
  159. },
  160. computed : {
  161. price(){
  162. return (this.detail.depositPrice * this.num).toFixed(2)
  163. },
  164. },
  165. data() {
  166. return {
  167. unitIndex: 0,
  168. address: {
  169. name: '请选择联系人',
  170. addressDetail: '',
  171. },
  172. num: 1,
  173. unit: {},
  174. addressTotal: 0,
  175. coupon : {
  176. price : 0,
  177. },
  178. couponText : '请选择',
  179. typeIndex : 0,
  180. type : ['没有', '我有'],
  181. }
  182. },
  183. methods: {
  184. // 打开
  185. open() {
  186. this.$refs.popup.open('bottom')
  187. // this.$refs.couponList.getData()
  188. this.confCoupon()
  189. if (!this.unit.id) {
  190. this.selectUnit(this.detail.hotelGoodsSkuList[0], 0)
  191. }
  192. // 获取地址列表
  193. this.$refs.addressList.getAddressList().then(res => {
  194. this.addressTotal = res.total
  195. if (this.addressTotal != 0) {
  196. this.address = res.records[0]
  197. }
  198. })
  199. },
  200. confCoupon(){
  201. this.$api('confCoupon', res => {
  202. if(res.code == 200){
  203. this.coupon = res.result
  204. }
  205. })
  206. },
  207. valChange(){
  208. // this.coupon = {
  209. // price : 0,
  210. // }
  211. // this.couponText = '请选择'
  212. },
  213. // 选择优惠劵
  214. selectCoupon(e){
  215. this.couponText = e.couponName
  216. this.coupon = e
  217. this.$refs.couponPopup.close()
  218. },
  219. // 关闭
  220. close() {
  221. this.$refs.popup.close()
  222. },
  223. // 打开选择地址
  224. openAddress() {
  225. if (this.addressTotal == 0) {
  226. this.$refs.popup.close()
  227. return uni.navigateTo({
  228. url: '/pages_order/mine/address?type=back'
  229. })
  230. }
  231. this.$refs.addressPopup.open('bottom')
  232. },
  233. // 选择地址
  234. selectAddress(e) {
  235. this.address = e
  236. this.$refs.addressPopup.close()
  237. },
  238. // 选择规格
  239. selectUnit(item, index) {
  240. this.unit = item
  241. this.unitIndex = index
  242. },
  243. addCart() {
  244. this.$api('cartAdd', {
  245. id: this.detail.id,
  246. skuId: this.unit.id,
  247. num : this.num,
  248. }, res => {
  249. if (res.code == 200) {
  250. uni.showToast({
  251. title: '添加成功',
  252. });
  253. this.$refs.popup.close()
  254. }
  255. })
  256. },
  257. // 添加我的物品
  258. submitAddLease() {
  259. this.$refs.addLeaseForm.submit(form => {
  260. form.addressId = this.address.id, //地址id
  261. this.$api('tablecloth', form, res => {
  262. if (res.code == 200) {
  263. uni.redirectTo({
  264. url: '/pages/index/order'
  265. })
  266. }
  267. })
  268. })
  269. },
  270. orderPay() {
  271. // 添加我的物品
  272. if(this.typeIndex == 1){
  273. return this.submitAddLease()
  274. }
  275. // 租赁物品
  276. let data = [
  277. {
  278. id: this.detail.id, //商品id
  279. skuId: this.unit.id, //规格id
  280. addressId: this.address.id, //地址id
  281. sku: this.unit.title, //规格
  282. num: this.num,
  283. }
  284. ]
  285. if (this.$utils.verificationAll(data[0], {
  286. skuId: '请选择规格',
  287. addressId: '请选择地址',
  288. })) {
  289. return
  290. }
  291. this.$api('orderCreate', {req:JSON.stringify(data)}, res => {
  292. if (res.code == 200) {
  293. let form = {
  294. id: res.result.id,
  295. }
  296. if(this.coupon.id){
  297. form.couponId = this.coupon.id
  298. }
  299. this.$api('orderPay', form, res => {
  300. if (res.code == 200) {
  301. uni.requestPayment({
  302. provider: 'wxpay', // 服务提提供商
  303. timeStamp: res.result.timeStamp, // 时间戳
  304. nonceStr: res.result.nonceStr, // 随机字符串
  305. package: res.result.packageValue,
  306. signType: res.result.signType, // 签名算法
  307. paySign: res.result.paySign, // 签名
  308. success: function(res) {
  309. // console.log('支付成功', res);
  310. uni.redirectTo({
  311. url: '/pages/index/order'
  312. })
  313. },
  314. fail: function(err) {
  315. console.log('支付失败', err);
  316. uni.redirectTo({
  317. url:'/pages/index/order'
  318. })
  319. // self.$refs.confirmationPopup.close()
  320. uni.showToast({
  321. icon: 'none',
  322. title: "支付失败"
  323. })
  324. }
  325. });
  326. }
  327. })
  328. }
  329. })
  330. },
  331. }
  332. }
  333. </script>
  334. <style scoped lang="scss">
  335. .content {
  336. max-height: 70vh;
  337. overflow: hidden;
  338. overflow-y: auto;
  339. padding-bottom: 120rpx;
  340. .address {
  341. display: flex;
  342. padding: 20rpx;
  343. background-color: #fff;
  344. image {
  345. width: 30rpx;
  346. height: 30rpx;
  347. margin: 20rpx;
  348. }
  349. view {
  350. margin: 20rpx;
  351. overflow: hidden; //超出的文本隐藏
  352. text-overflow: ellipsis; //溢出用省略号显示
  353. white-space: nowrap; //溢出不换行
  354. }
  355. .icon {
  356. margin-left: auto;
  357. }
  358. }
  359. .submit-info {
  360. background-color: #fff;
  361. padding: 30rpx;
  362. margin-top: 20rpx;
  363. .title {
  364. font-size: 30rpx;
  365. padding: 10rpx;
  366. font-weight: 600;
  367. }
  368. .box {
  369. display: flex;
  370. margin-top: 10rpx;
  371. .image {
  372. width: 200rpx;
  373. height: 200rpx;
  374. border-radius: 20rpx;
  375. margin-right: 20rpx;
  376. }
  377. .info {
  378. flex: 1;
  379. .unit {
  380. font-size: 24rpx;
  381. padding: 10rpx 20rpx;
  382. color: #717171;
  383. display: flex;
  384. align-items: center;
  385. }
  386. .price {
  387. color: $uni-color;
  388. font-size: 28rpx;
  389. padding: 10rpx 20rpx;
  390. text {
  391. font-size: 36rpx;
  392. font-weight: 900;
  393. }
  394. }
  395. }
  396. }
  397. }
  398. .submit-unit {
  399. padding: 30rpx;
  400. background-color: #fff;
  401. .title {
  402. font-size: 28rpx;
  403. font-weight: 600;
  404. }
  405. .list {
  406. display: flex;
  407. flex-wrap: wrap;
  408. font-size: 22rpx;
  409. .act {
  410. color: $uni-color;
  411. border: 1px solid $uni-color;
  412. background-color: #F9E7DE;
  413. }
  414. view {
  415. border-radius: 15rpx;
  416. width: 320rpx;
  417. background-color: #F3F3F3;
  418. border: 1px solid #F3F3F3;
  419. margin: 10rpx;
  420. display: flex;
  421. justify-content: center;
  422. padding: 15rpx 0;
  423. }
  424. }
  425. }
  426. .expense-detail {
  427. padding: 30rpx;
  428. background-color: #fff;
  429. font-size: 28rpx;
  430. .title {
  431. font-weight: 600;
  432. }
  433. .detail {
  434. background-color: #F6F6F6;
  435. color: #717171;
  436. margin: 10rpx 0;
  437. padding: 10rpx 20rpx;
  438. line-height: 50rpx;
  439. }
  440. .coupon{
  441. text-align: center;
  442. color: #5c5;
  443. }
  444. }
  445. .submit{
  446. background-color: #fff;
  447. position: fixed;
  448. left: 0;
  449. bottom: 0;
  450. padding-bottom: env(safe-area-inset-bottom);
  451. width: 100%;
  452. .submit-btn {
  453. width: 600rpx;
  454. height: 80rpx;
  455. color: #fff;
  456. border-radius: 40rpx;
  457. font-size: 28rpx;
  458. margin: 20rpx auto;
  459. display: flex;
  460. justify-content: center;
  461. align-items: center;
  462. border: 1rpx solid $uni-color;
  463. overflow: hidden;
  464. .l {
  465. flex: 1;
  466. display: flex;
  467. justify-content: center;
  468. align-items: center;
  469. color: $uni-color;
  470. }
  471. .r {
  472. background: $uni-color;
  473. flex: 1;
  474. height: 100%;
  475. display: flex;
  476. justify-content: center;
  477. align-items: center;
  478. }
  479. }
  480. }
  481. }
  482. </style>