酒店桌布为微信小程序
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.

581 lines
12 KiB

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